Whamcloud - gitweb
a32f010fc919d4a1a43064da68b00d3d45efdf44
[fs/lustre-release.git] / lustre / kernel_patches / patches / 2.6.0-test6-mm4.patch
1 --- linux-2.6.0-test6/arch/alpha/Kconfig        2003-09-27 18:57:43.000000000 -0700
2 +++ 25/arch/alpha/Kconfig       2003-10-05 00:36:11.000000000 -0700
3 @@ -471,21 +471,6 @@ config EISA
4         bool
5         depends on ALPHA_GENERIC || ALPHA_JENSEN || ALPHA_ALCOR || ALPHA_MIKASA || ALPHA_SABLE || ALPHA_LYNX || ALPHA_NORITAKE || ALPHA_RAWHIDE
6         default y
7 -       ---help---
8 -         The Extended Industry Standard Architecture (EISA) bus was
9 -         developed as an open alternative to the IBM MicroChannel bus.
10 -
11 -         The EISA bus provided some of the features of the IBM MicroChannel
12 -         bus while maintaining backward compatibility with cards made for
13 -         the older ISA bus.  The EISA bus saw limited use between 1988 and
14 -         1995 when it was made obsolete by the PCI bus.
15 -
16 -         Say Y here if you are building a kernel for an EISA-based machine.
17 -
18 -         Otherwise, say N.
19 -
20 -config EISA_ALWAYS
21 -       def_bool EISA
22  
23  config SMP
24         bool "Symmetric multi-processing support"
25 --- linux-2.6.0-test6/arch/alpha/kernel/core_irongate.c 2003-06-14 12:18:25.000000000 -0700
26 +++ 25/arch/alpha/kernel/core_irongate.c        2003-10-05 00:33:23.000000000 -0700
27 @@ -391,7 +391,7 @@ irongate_ioremap(unsigned long addr, uns
28                 cur_gatt = phys_to_virt(GET_GATT(baddr) & ~1);
29                 pte = cur_gatt[GET_GATT_OFF(baddr)] & ~1;
30  
31 -               if (__alpha_remap_area_pages(VMALLOC_VMADDR(vaddr), 
32 +               if (__alpha_remap_area_pages(vaddr,
33                                              pte, PAGE_SIZE, 0)) {
34                         printk("AGP ioremap: FAILED to map...\n");
35                         vfree(area->addr);
36 --- linux-2.6.0-test6/arch/alpha/kernel/core_marvel.c   2003-08-22 19:23:39.000000000 -0700
37 +++ 25/arch/alpha/kernel/core_marvel.c  2003-10-05 00:33:23.000000000 -0700
38 @@ -696,7 +696,7 @@ marvel_ioremap(unsigned long addr, unsig
39                         }
40                         pfn >>= 1;      /* make it a true pfn */
41                         
42 -                       if (__alpha_remap_area_pages(VMALLOC_VMADDR(vaddr), 
43 +                       if (__alpha_remap_area_pages(vaddr,
44                                                      pfn << PAGE_SHIFT, 
45                                                      PAGE_SIZE, 0)) {
46                                 printk("FAILED to map...\n");
47 --- linux-2.6.0-test6/arch/alpha/kernel/core_titan.c    2003-09-08 13:58:55.000000000 -0700
48 +++ 25/arch/alpha/kernel/core_titan.c   2003-10-05 00:33:23.000000000 -0700
49 @@ -534,7 +534,7 @@ titan_ioremap(unsigned long addr, unsign
50                         }
51                         pfn >>= 1;      /* make it a true pfn */
52                         
53 -                       if (__alpha_remap_area_pages(VMALLOC_VMADDR(vaddr), 
54 +                       if (__alpha_remap_area_pages(vaddr,
55                                                      pfn << PAGE_SHIFT, 
56                                                      PAGE_SIZE, 0)) {
57                                 printk("FAILED to map...\n");
58 --- linux-2.6.0-test6/arch/alpha/kernel/setup.c 2003-08-22 19:23:39.000000000 -0700
59 +++ 25/arch/alpha/kernel/setup.c        2003-10-05 00:36:11.000000000 -0700
60 @@ -33,6 +33,7 @@
61  #include <linux/seq_file.h>
62  #include <linux/root_dev.h>
63  #include <linux/initrd.h>
64 +#include <linux/eisa.h>
65  #ifdef CONFIG_MAGIC_SYSRQ
66  #include <linux/sysrq.h>
67  #include <linux/reboot.h>
68 @@ -680,6 +681,11 @@ setup_arch(char **cmdline_p)
69         /* Default root filesystem to sda2.  */
70         ROOT_DEV = Root_SDA2;
71  
72 +#ifdef CONFIG_EISA
73 +       /* FIXME:  only set this when we actually have EISA in this box? */
74 +       EISA_bus = 1;
75 +#endif
76 +
77         /*
78          * Check ASN in HWRPB for validity, report if bad.
79          * FIXME: how was this failing?  Should we trust it instead,
80 @@ -1203,7 +1209,7 @@ show_cpuinfo(struct seq_file *f, void *s
81                        platform_string(), nr_processors);
82  
83  #ifdef CONFIG_SMP
84 -       seq_printf(f, "cpus active\t\t: %d\n"
85 +       seq_printf(f, "cpus active\t\t: %ld\n"
86                       "cpu active mask\t\t: %016lx\n",
87                        num_online_cpus(), cpu_present_mask);
88  #endif
89 --- linux-2.6.0-test6/arch/alpha/kernel/smp.c   2003-08-22 19:23:40.000000000 -0700
90 +++ 25/arch/alpha/kernel/smp.c  2003-10-05 00:33:23.000000000 -0700
91 @@ -597,7 +597,7 @@ smp_cpus_done(unsigned int max_cpus)
92                 if (cpu_online(cpu))
93                         bogosum += cpu_data[cpu].loops_per_jiffy;
94         
95 -       printk(KERN_INFO "SMP: Total of %d processors activated "
96 +       printk(KERN_INFO "SMP: Total of %ld processors activated "
97                "(%lu.%02lu BogoMIPS).\n",
98                num_online_cpus(), 
99                (bogosum + 2500) / (500000/HZ),
100 --- linux-2.6.0-test6/arch/alpha/kernel/time.c  2003-08-08 22:55:10.000000000 -0700
101 +++ 25/arch/alpha/kernel/time.c 2003-10-05 00:33:23.000000000 -0700
102 @@ -89,6 +89,16 @@ static inline __u32 rpcc(void)
103      return result;
104  }
105  
106 +/*
107 + * Scheduler clock - returns current time in nanosec units.
108 + *
109 + * Copied from ARM code for expediency... ;-}
110 + */
111 +unsigned long long sched_clock(void)
112 +{
113 +        return (unsigned long long)jiffies * (1000000000 / HZ);
114 +}
115 +
116  
117  /*
118   * timer_interrupt() needs to keep up the real-time clock,
119 @@ -239,8 +249,9 @@ validate_cc_value(unsigned long cc)
120   * arch/i386/time.c.
121   */
122  
123 -#define CALIBRATE_LATCH        (52 * LATCH)
124 -#define CALIBRATE_TIME (52 * 1000020 / HZ)
125 +#define PIC_TICK_RATE  1193180UL
126 +#define CALIBRATE_LATCH        0xffff
127 +#define TIMEOUT_COUNT  0x100000
128  
129  static unsigned long __init
130  calibrate_cc_with_pic(void)
131 @@ -263,19 +274,15 @@ calibrate_cc_with_pic(void)
132  
133         cc = rpcc();
134         do {
135 -         count+=100; /* by 1 takes too long to timeout from 0 */
136 -       } while ((inb(0x61) & 0x20) == 0 && count > 0);
137 +               count++;
138 +       } while ((inb(0x61) & 0x20) == 0 && count < TIMEOUT_COUNT);
139         cc = rpcc() - cc;
140  
141         /* Error: ECTCNEVERSET or ECPUTOOFAST.  */
142 -       if (count <= 100)
143 -               return 0;
144 -
145 -       /* Error: ECPUTOOSLOW.  */
146 -       if (cc <= CALIBRATE_TIME)
147 +       if (count <= 1 || count == TIMEOUT_COUNT)
148                 return 0;
149  
150 -       return (cc * 1000000UL) / CALIBRATE_TIME;
151 +       return ((long)cc * PIC_TICK_RATE) / (CALIBRATE_LATCH + 1);
152  }
153  
154  /* The Linux interpretation of the CMOS clock register contents:
155 --- linux-2.6.0-test6/arch/alpha/mm/init.c      2003-07-27 12:14:38.000000000 -0700
156 +++ 25/arch/alpha/mm/init.c     2003-10-05 00:33:23.000000000 -0700
157 @@ -210,7 +210,8 @@ callback_init(void * kernel_end)
158         /* Allocate one PGD and one PMD.  In the case of SRM, we'll need
159            these to actually remap the console.  There is an assumption
160            here that only one of each is needed, and this allows for 8MB.
161 -          Currently (late 1999), big consoles are still under 4MB.
162 +          On systems with larger consoles, additional pages will be
163 +          allocated as needed during the mapping process.
164  
165            In the case of not SRM, but not CONFIG_ALPHA_LARGE_VMALLOC,
166            we need to allocate the PGD we use for vmalloc before we start
167 @@ -237,6 +238,15 @@ callback_init(void * kernel_end)
168                         unsigned long pfn = crb->map[i].pa >> PAGE_SHIFT;
169                         crb->map[i].va = vaddr;
170                         for (j = 0; j < crb->map[i].count; ++j) {
171 +                               /* Newer console's (especially on larger
172 +                                  systems) may require more pages of
173 +                                  PTEs. Grab additional pages as needed. */
174 +                               if (pmd != pmd_offset(pgd, vaddr)) {
175 +                                       memset(kernel_end, 0, PAGE_SIZE);
176 +                                       pmd = pmd_offset(pgd, vaddr);
177 +                                       pmd_set(pmd, (pte_t *)kernel_end);
178 +                                       kernel_end += PAGE_SIZE;
179 +                               }
180                                 set_pte(pte_offset_kernel(pmd, vaddr),
181                                         pfn_pte(pfn, PAGE_KERNEL));
182                                 pfn++;
183 --- linux-2.6.0-test6/arch/arm/boot/compressed/head.S   2003-06-14 12:18:33.000000000 -0700
184 +++ 25/arch/arm/boot/compressed/head.S  2003-10-05 00:33:23.000000000 -0700
185 @@ -477,6 +477,12 @@ proc_types:
186  @              b       __arm6_cache_off
187  @              b       __armv3_cache_flush
188  
189 +               .word   0x00000000              @ old ARM ID
190 +               .word   0x0000f000
191 +               mov     pc, lr
192 +               mov     pc, lr
193 +               mov     pc, lr
194 +
195                 .word   0x41007000              @ ARM7/710
196                 .word   0xfff8fe00
197                 b       __arm7_cache_off
198 @@ -489,6 +495,14 @@ proc_types:
199                 b       __armv4_cache_off
200                 mov     pc, lr
201  
202 +               .word   0x00007000              @ ARM7 IDs
203 +               .word   0x0000f000
204 +               mov     pc, lr
205 +               mov     pc, lr
206 +               mov     pc, lr
207 +
208 +               @ Everything from here on will be the new ID system.
209 +
210                 .word   0x41129200              @ ARM920T
211                 .word   0xff00fff0
212                 b       __armv4_cache_on
213 @@ -507,8 +521,16 @@ proc_types:
214                 b       __armv4_cache_off
215                 b       __armv4_cache_flush
216  
217 -               .word   0x69050000              @ xscale
218 -               .word   0xffff0000
219 +               @ These match on the architecture ID
220 +
221 +               .word   0x00050000              @ ARMv5TE
222 +               .word   0x000f0000
223 +               b       __armv4_cache_on
224 +               b       __armv4_cache_off
225 +               b       __armv4_cache_flush
226 +
227 +               .word   0x00060000              @ ARMv5TEJ
228 +               .word   0x000f0000
229                 b       __armv4_cache_on
230                 b       __armv4_cache_off
231                 b       __armv4_cache_flush
232 --- linux-2.6.0-test6/arch/arm/Kconfig  2003-09-27 18:57:43.000000000 -0700
233 +++ 25/arch/arm/Kconfig 2003-10-05 00:33:23.000000000 -0700
234 @@ -239,7 +239,7 @@ config DISCONTIGMEM
235  
236  # Now handle the bus types
237  config PCI
238 -       bool "PCI support" if ARCH_INTEGRATOR
239 +       bool "PCI support" if ARCH_INTEGRATOR_AP
240         default y if ARCH_FTVPCI || ARCH_SHARK || FOOTBRIDGE_HOST || ARCH_IOP3XX
241         help
242           Find out whether you have a PCI motherboard. PCI is the name of a
243 @@ -645,8 +645,6 @@ source "drivers/misc/Kconfig"
244  
245  source "drivers/usb/Kconfig"
246  
247 -source "net/bluetooth/Kconfig"
248 -
249  
250  menu "Kernel hacking"
251  
252 --- linux-2.6.0-test6/arch/arm/kernel/apm.c     2003-09-08 13:58:55.000000000 -0700
253 +++ 25/arch/arm/kernel/apm.c    2003-10-05 00:33:23.000000000 -0700
254 @@ -179,13 +179,10 @@ static void queue_event(apm_event_t even
255         wake_up_interruptible(&apm_waitqueue);
256  }
257  
258 -/* defined in pm.c */
259 -extern int suspend(void);
260 -
261  static int apm_suspend(void)
262  {
263         struct list_head *l;
264 -       int err = suspend();
265 +       int err = pm_suspend(PM_SUSPEND_MEM);
266  
267         /*
268          * Anyone on the APM queues will think we're still suspended.
269 --- linux-2.6.0-test6/arch/arm/kernel/entry-armv.S      2003-09-27 18:57:43.000000000 -0700
270 +++ 25/arch/arm/kernel/entry-armv.S     2003-10-05 00:33:23.000000000 -0700
271 @@ -439,20 +439,25 @@ ENTRY(soft_irq_mask)
272  
273                 .macro  get_irqnr_and_base, irqnr, irqstat, base, tmp
274  /* FIXME: should not be using soo many LDRs here */
275 -               ldr     \irqnr, =IO_ADDRESS(INTEGRATOR_IC_BASE)
276 -               ldr     \irqstat, [\irqnr, #IRQ_STATUS]         @ get masked status
277 -               ldr     \irqnr, =IO_ADDRESS(INTEGRATOR_HDR_BASE)
278 -               ldr     \irqnr, [\irqnr, #(INTEGRATOR_HDR_IC_OFFSET+IRQ_STATUS)]
279 -               orr     \irqstat, \irqstat, \irqnr, lsl #INTEGRATOR_CM_INT0
280 +               ldr     \base, =IO_ADDRESS(INTEGRATOR_IC_BASE)
281 +               mov     \irqnr, #IRQ_PIC_START
282 +               ldr     \irqstat, [\base, #IRQ_STATUS]          @ get masked status
283 +               ldr     \base, =IO_ADDRESS(INTEGRATOR_HDR_BASE)
284 +               teq     \irqstat, #0
285 +               ldreq   \irqstat, [\base, #(INTEGRATOR_HDR_IC_OFFSET+IRQ_STATUS)]
286 +               moveq   \irqnr, #IRQ_CIC_START
287  
288 -               mov     \irqnr, #0
289 -1001:          tst     \irqstat, #1
290 +1001:          tst     \irqstat, #15
291                 bne     1002f
292 +               add     \irqnr, \irqnr, #4
293 +               movs    \irqstat, \irqstat, lsr #4
294 +               bne     1001b
295 +1002:          tst     \irqstat, #1
296 +               bne     1003f
297                 add     \irqnr, \irqnr, #1
298 -               mov     \irqstat, \irqstat, lsr #1
299 -               cmp     \irqnr, #22
300 -               bcc     1001b
301 -1002:          /* EQ will be set if we reach 22 */
302 +               movs    \irqstat, \irqstat, lsr #1
303 +               bne     1002b
304 +1003:          /* EQ will be set if no irqs pending */
305                 .endm
306  
307                 .macro  irq_prio_table
308 --- linux-2.6.0-test6/arch/arm/kernel/pm.c      2003-09-08 13:58:55.000000000 -0700
309 +++ 25/arch/arm/kernel/pm.c     2003-10-05 00:33:23.000000000 -0700
310 @@ -9,68 +9,18 @@
311   *  sleep.
312   */
313  #include <linux/config.h>
314 +#include <linux/init.h>
315 +#include <linux/sysctl.h>
316  #include <linux/pm.h>
317 -#include <linux/device.h>
318 -#include <linux/sysdev.h>
319  #include <linux/errno.h>
320  #include <linux/sched.h>
321  
322 -#include <asm/leds.h>
323 -#include <asm/system.h>
324 -
325 -/*
326 - * Tell the linker that pm_do_suspend may not be present.
327 - */
328 -extern int pm_do_suspend(void) __attribute__((weak));
329 -
330 -int suspend(void)
331 -{
332 -       int ret;
333 -
334 -       if (!pm_do_suspend)
335 -               return -ENOSYS;
336 -
337 -       /*
338 -        * Suspend "legacy" devices.
339 -        */
340 -       ret = pm_send_all(PM_SUSPEND, (void *)3);
341 -       if (ret != 0)
342 -               goto out;
343 -
344 -       ret = device_suspend(3);
345 -       if (ret)
346 -               goto resume_legacy;
347 -
348 -       local_irq_disable();
349 -       leds_event(led_stop);
350 -
351 -       sysdev_suspend(3);
352 -
353 -       ret = pm_do_suspend();
354 -
355 -       sysdev_resume();
356 -
357 -       leds_event(led_start);
358 -       local_irq_enable();
359 -
360 -       device_resume();
361 -
362 - resume_legacy:
363 -       pm_send_all(PM_RESUME, (void *)0);
364 -
365 - out:
366 -       return ret;
367 -}
368 -
369  #ifdef CONFIG_SYSCTL
370  /*
371   * We really want this to die.  It's a disgusting hack using unallocated
372   * sysctl numbers.  We should be using a real interface.
373   */
374  
375 -#include <linux/init.h>
376 -#include <linux/sysctl.h>
377 -
378  static int
379  pm_sysctl_proc_handler(ctl_table *ctl, int write, struct file *filp,
380                        void *buffer, size_t *lenp)
381 @@ -79,7 +29,7 @@ pm_sysctl_proc_handler(ctl_table *ctl, i
382         printk("PM: task %s (pid %d) uses deprecated sysctl PM interface\n",
383                 current->comm, current->pid);
384         if (write)
385 -               ret = suspend();
386 +               ret = pm_suspend(PM_SUSPEND_MEM);
387         return ret;
388  }
389  
390 --- linux-2.6.0-test6/arch/arm/kernel/process.c 2003-09-27 18:57:43.000000000 -0700
391 +++ 25/arch/arm/kernel/process.c        2003-10-05 00:33:23.000000000 -0700
392 @@ -117,12 +117,10 @@ __setup("reboot=", reboot_setup);
393  
394  void machine_halt(void)
395  {
396 -       leds_event(led_halted);
397  }
398  
399  void machine_power_off(void)
400  {
401 -       leds_event(led_halted);
402         if (pm_power_off)
403                 pm_power_off();
404  }
405 --- linux-2.6.0-test6/arch/arm/kernel/setup.c   2003-09-27 18:57:43.000000000 -0700
406 +++ 25/arch/arm/kernel/setup.c  2003-10-05 00:33:23.000000000 -0700
407 @@ -182,7 +182,7 @@ static const char *proc_arch[] = {
408         "5",
409         "5T",
410         "5TE",
411 -       "?(8)",
412 +       "5TEJ",
413         "?(9)",
414         "?(10)",
415         "?(11)",
416 --- linux-2.6.0-test6/arch/arm/kernel/signal.c  2003-06-14 12:17:56.000000000 -0700
417 +++ 25/arch/arm/kernel/signal.c 2003-10-05 00:33:23.000000000 -0700
418 @@ -21,6 +21,7 @@
419  #include <linux/tty.h>
420  #include <linux/binfmts.h>
421  #include <linux/elf.h>
422 +#include <linux/suspend.h>
423  
424  #include <asm/pgalloc.h>
425  #include <asm/ucontext.h>
426 @@ -539,6 +540,11 @@ static int do_signal(sigset_t *oldset, s
427         if (!user_mode(regs))
428                 return 0;
429  
430 +       if (current->flags & PF_FREEZE) {
431 +               refrigerator(0);
432 +               goto no_signal;
433 +       }
434 +
435         if (current->ptrace & PT_SINGLESTEP)
436                 ptrace_cancel_bpt(current);
437  
438 @@ -550,6 +556,7 @@ static int do_signal(sigset_t *oldset, s
439                 return 1;
440         }
441  
442 + no_signal:
443         /*
444          * No signal to deliver to the process - restart the syscall.
445          */
446 --- linux-2.6.0-test6/arch/arm/kernel/time.c    2003-09-27 18:57:43.000000000 -0700
447 +++ 25/arch/arm/kernel/time.c   2003-10-05 00:33:23.000000000 -0700
448 @@ -26,6 +26,7 @@
449  #include <linux/timex.h>
450  #include <linux/errno.h>
451  #include <linux/profile.h>
452 +#include <linux/sysdev.h>
453  
454  #include <asm/hardware.h>
455  #include <asm/io.h>
456 @@ -72,8 +73,6 @@ unsigned long (*gettimeoffset)(void) = d
457   */
458  unsigned long long sched_clock(void)
459  {
460 -       unsigned long long this_offset;
461 -
462         return (unsigned long long)jiffies * (1000000000 / HZ);
463  }
464  
465 @@ -137,6 +136,47 @@ static void dummy_leds_event(led_event_t
466  
467  void (*leds_event)(led_event_t) = dummy_leds_event;
468  
469 +static int leds_suspend(struct sys_device *dev, u32 state)
470 +{
471 +       leds_event(led_stop);
472 +       return 0;
473 +}
474 +
475 +static int leds_resume(struct sys_device *dev)
476 +{
477 +       leds_event(led_start);
478 +       return 0;
479 +}
480 +
481 +static int leds_shutdown(struct sys_device *dev)
482 +{
483 +       leds_event(led_halted);
484 +       return 0;
485 +}
486 +
487 +static struct sysdev_class leds_sysclass = {
488 +       set_kset_name("leds"),
489 +       .shutdown       = leds_shutdown,
490 +       .suspend        = leds_suspend,
491 +       .resume         = leds_resume,
492 +};
493 +
494 +static struct sys_device leds_device = {
495 +       .id             = 0,
496 +       .cls            = &leds_sysclass,
497 +};
498 +
499 +static int __init leds_init(void)
500 +{
501 +       int ret;
502 +       ret = sysdev_class_register(&leds_sysclass);
503 +       if (ret == 0)
504 +               ret = sys_device_register(&leds_device);
505 +       return ret;
506 +}
507 +
508 +device_initcall(leds_init);
509 +
510  EXPORT_SYMBOL(leds_event);
511  #endif
512  
513 --- linux-2.6.0-test6/arch/arm/kernel/traps.c   2003-08-22 19:23:40.000000000 -0700
514 +++ 25/arch/arm/kernel/traps.c  2003-10-05 00:33:23.000000000 -0700
515 @@ -212,10 +212,10 @@ NORET_TYPE void die(const char *str, str
516         printk("CPU: %d\n", smp_processor_id());
517         show_regs(regs);
518         printk("Process %s (pid: %d, stack limit = 0x%p)\n",
519 -               current->comm, current->pid, tsk->thread_info + 1);
520 +               tsk->comm, tsk->pid, tsk->thread_info + 1);
521  
522         if (!user_mode(regs) || in_interrupt()) {
523 -               dump_mem("Stack: ", (unsigned long)(regs + 1), 8192+(unsigned long)tsk->thread_info);
524 +               dump_mem("Stack: ", regs->ARM_sp, 8192+(unsigned long)tsk->thread_info);
525                 dump_backtrace(regs, tsk);
526                 dump_instr(regs);
527         }
528 --- linux-2.6.0-test6/arch/arm/lib/io-readsl-armv4.S    2003-06-14 12:18:30.000000000 -0700
529 +++ 25/arch/arm/lib/io-readsl-armv4.S   2003-10-05 00:33:23.000000000 -0700
530 @@ -9,7 +9,6 @@
531   */
532  #include <linux/linkage.h>
533  #include <asm/assembler.h>
534 -#include <asm/hardware.h>
535  
536  /*
537   * Note that some reads can be aligned on half-word boundaries.
538 @@ -31,6 +30,10 @@ ENTRY(__raw_readsl)
539                 blt     4f
540                 bgt     6f
541  
542 +#ifndef        __ARMEB__
543 +
544 +               /* little endian code */
545 +
546                 strh    ip, [r1], #2
547                 mov     ip, ip, lsr #16
548  3:             subs    r2, r2, #1
549 @@ -68,3 +71,48 @@ ENTRY(__raw_readsl)
550                 strb    ip, [r1]
551                 mov     pc, lr
552  
553 +#else
554 +
555 +               /* big endian code */
556 +
557 +
558 +               mov     r3, ip, lsr #16
559 +               strh    r3, [r1], #2
560 +3:             mov     r3, ip, lsl #16
561 +               subs    r2, r2, #1
562 +               ldrne   ip, [r0]
563 +               orrne   r3, r3, ip, lsr #16
564 +               strne   r3, [r1], #4
565 +               bne     3b
566 +               strh    ip, [r1], #2
567 +               mov     pc, lr
568 +
569 +4:             mov     r3, ip, lsr #24
570 +               strb    r3, [r1], #1
571 +               mov     r3, ip, lsr #8
572 +               strh    r3, [r1], #2
573 +5:             mov     r3, ip, lsl #24
574 +               subs    r2, r2, #1
575 +               ldrne   ip, [r0]
576 +               orrne   r3, r3, ip, lsr #8
577 +               strne   r3, [r1], #4
578 +               bne     5b
579 +               strb    ip, [r1], #1
580 +               mov     pc, lr
581 +
582 +6:             mov     r3, ip, lsr #24
583 +               strb    r3, [r1], #1
584 +7:             mov     r3, ip, lsl #8
585 +               subs    r2, r2, #1
586 +               ldrne   ip, [r0]
587 +               orrne   r3, r3, ip, lsr #24
588 +               strne   r3, [r1], #4
589 +               bne     7b
590 +               mov     r3, ip, lsr #8
591 +               strh    r3, [r1], #2
592 +               strb    ip, [r1], #1
593 +               mov     pc, lr
594 +
595 +#endif
596 +
597 +
598 --- linux-2.6.0-test6/arch/arm/lib/io-readsw-armv4.S    2003-06-14 12:18:23.000000000 -0700
599 +++ 25/arch/arm/lib/io-readsw-armv4.S   2003-10-05 00:33:23.000000000 -0700
600 @@ -9,7 +9,14 @@
601   */
602  #include <linux/linkage.h>
603  #include <asm/assembler.h>
604 -#include <asm/hardware.h>
605 +
606 +               .macro  pack, rd, hw1, hw2
607 +#ifndef __ARMEB__
608 +               orr     \rd, \hw1, \hw2, lsl #16
609 +#else
610 +               orr     \rd, \hw2, \hw1, lsl #16
611 +#endif
612 +               .endm
613  
614  .insw_bad_alignment:
615                 adr     r0, .insw_bad_align_msg
616 @@ -41,19 +48,19 @@ ENTRY(__raw_readsw)
617  
618  .insw_8_lp:    ldrh    r3, [r0]
619                 ldrh    r4, [r0]
620 -               orr     r3, r3, r4, lsl #16
621 +               pack    r3, r3, r4
622  
623                 ldrh    r4, [r0]
624                 ldrh    r5, [r0]
625 -               orr     r4, r4, r5, lsl #16
626 +               pack    r4, r4, r5
627  
628                 ldrh    r5, [r0]
629                 ldrh    ip, [r0]
630 -               orr     r5, r5, ip, lsl #16
631 +               pack    r5, r5, ip
632  
633                 ldrh    ip, [r0]
634                 ldrh    lr, [r0]
635 -               orr     ip, ip, lr, lsl #16
636 +               pack    ip, ip, lr
637  
638                 stmia   r1!, {r3 - r5, ip}
639  
640 @@ -68,11 +75,11 @@ ENTRY(__raw_readsw)
641  
642                 ldrh    r3, [r0]
643                 ldrh    r4, [r0]
644 -               orr     r3, r3, r4, lsl #16
645 +               pack    r3, r3, r4
646  
647                 ldrh    r4, [r0]
648                 ldrh    ip, [r0]
649 -               orr     r4, r4, ip, lsl #16
650 +               pack    r4, r4, ip
651  
652                 stmia   r1!, {r3, r4}
653  
654 @@ -81,7 +88,7 @@ ENTRY(__raw_readsw)
655  
656                 ldrh    r3, [r0]
657                 ldrh    ip, [r0]
658 -               orr     r3, r3, ip, lsl #16
659 +               pack    r3, r3, ip
660  
661                 str     r3, [r1], #4
662  
663 --- linux-2.6.0-test6/arch/arm/lib/io-writesw-armv4.S   2003-06-14 12:18:34.000000000 -0700
664 +++ 25/arch/arm/lib/io-writesw-armv4.S  2003-10-05 00:33:23.000000000 -0700
665 @@ -9,7 +9,18 @@
666   */
667  #include <linux/linkage.h>
668  #include <asm/assembler.h>
669 -#include <asm/hardware.h>
670 +
671 +               .macro  outword, rd
672 +#ifndef __ARMEB__
673 +               strh    \rd, [r0]
674 +               mov     \rd, \rd, lsr #16
675 +               strh    \rd, [r0]
676 +#else
677 +               mov     lr, \rd, lsr #16
678 +               strh    lr, [r0]
679 +               strh    \rd, [r0]
680 +#endif
681 +               .endm
682  
683  .outsw_bad_alignment:
684                 adr     r0, .outsw_bad_align_msg
685 @@ -40,20 +51,10 @@ ENTRY(__raw_writesw)
686                 bmi     .no_outsw_8
687  
688  .outsw_8_lp:   ldmia   r1!, {r3, r4, r5, ip}
689 -
690 -               strh    r3, [r0]
691 -               mov     r3, r3, lsr #16
692 -               strh    r3, [r0]
693 -               strh    r4, [r0]
694 -               mov     r4, r4, lsr #16
695 -               strh    r4, [r0]
696 -               strh    r5, [r0]
697 -               mov     r5, r5, lsr #16
698 -               strh    r5, [r0]
699 -               strh    ip, [r0]
700 -               mov     ip, ip, lsr #16
701 -               strh    ip, [r0]
702 -
703 +               outword r3
704 +               outword r4
705 +               outword r5
706 +               outword ip
707                 subs    r2, r2, #8
708                 bpl     .outsw_8_lp
709  
710 @@ -64,20 +65,14 @@ ENTRY(__raw_writesw)
711                 beq     .no_outsw_4
712  
713                 ldmia   r1!, {r3, ip}
714 -               strh    r3, [r0]
715 -               mov     r3, r3, lsr #16
716 -               strh    r3, [r0]
717 -               strh    ip, [r0]
718 -               mov     ip, ip, lsr #16
719 -               strh    ip, [r0]
720 +               outword r3
721 +               outword ip
722  
723  .no_outsw_4:   tst     r2, #2
724                 beq     .no_outsw_2
725  
726                 ldr     r3, [r1], #4
727 -               strh    r3, [r0]
728 -               mov     r3, r3, lsr #16
729 -               strh    r3, [r0]
730 +               outword r3
731  
732  .no_outsw_2:   tst     r2, #1
733                 ldrneh  r3, [r1]
734 --- linux-2.6.0-test6/arch/arm/lib/lib1funcs.S  2003-09-27 18:57:43.000000000 -0700
735 +++ 25/arch/arm/lib/lib1funcs.S 2003-10-05 00:33:23.000000000 -0700
736 @@ -1,7 +1,12 @@
737 -@ libgcc1 routines for ARM cpu.
738 -@ Division routines, written by Richard Earnshaw, (rearnsha@armltd.co.uk)
739 +/*
740 + * linux/arch/arm/lib/lib1funcs.S: Optimized ARM division routines
741 + *
742 + * Author: Nicolas Pitre <nico@cam.org>
743 + *   - contributed to gcc-3.4 on Sep 30, 2003
744 + *   - adapted for the Linux kernel on Oct 2, 2003
745 + */
746  
747 -/* Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
748 +/* Copyright 1995, 1996, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
749  
750  This file is free software; you can redistribute it and/or modify it
751  under the terms of the GNU General Public License as published by the
752 @@ -10,11 +15,12 @@ later version.
753  
754  In addition to the permissions in the GNU General Public License, the
755  Free Software Foundation gives you unlimited permission to link the
756 -compiled version of this file with other programs, and to distribute
757 -those programs without any restriction coming from the use of this
758 -file.  (The General Public License restrictions do apply in other
759 -respects; for example, they cover modification of the file, and
760 -distribution when not linked into another program.)
761 +compiled version of this file into combinations with other programs,
762 +and to distribute those combinations without any restriction coming
763 +from the use of this file.  (The General Public License restrictions
764 +do apply in other respects; for example, they cover modification of
765 +the file, and distribution when not linked into a combine
766 +executable.)
767  
768  This file is distributed in the hope that it will be useful, but
769  WITHOUT ANY WARRANTY; without even the implied warranty of
770 @@ -26,286 +32,283 @@ along with this program; see the file CO
771  the Free Software Foundation, 59 Temple Place - Suite 330,
772  Boston, MA 02111-1307, USA.  */
773  
774 -/* As a special exception, if you link this library with other files,
775 -   some of which are compiled with GCC, to produce an executable,
776 -   this library does not by itself cause the resulting executable
777 -   to be covered by the GNU General Public License.
778 -   This exception does not however invalidate any other reasons why
779 -   the executable file might be covered by the GNU General Public License.
780 - */
781 -/* This code is derived from gcc 2.95.3
782 - * 29/07/01 Adapted for linux
783 - * 27/03/03 Ian Molton Clean up CONFIG_CPU
784 - */
785  
786  #include <linux/linkage.h>
787  #include <asm/assembler.h>
788 -#include <asm/hardware.h>
789  
790 -#define RET    mov
791 -#define RETc(x)        mov##x
792 -#define RETCOND
793 -
794 -dividend       .req    r0
795 -divisor                .req    r1
796 -result         .req    r2
797 -overdone        .req    r2
798 -curbit         .req    r3
799 +
800 +.macro ARM_DIV_BODY dividend, divisor, result, curbit
801 +
802 +#if __LINUX_ARM_ARCH__ >= 5
803 +
804 +       clz     \curbit, \divisor
805 +       clz     \result, \dividend
806 +       sub     \result, \curbit, \result
807 +       mov     \curbit, #1
808 +       mov     \divisor, \divisor, lsl \result
809 +       mov     \curbit, \curbit, lsl \result
810 +       mov     \result, #0
811         
812 -ENTRY(__udivsi3)
813 -       cmp     divisor, #0
814 -       beq     Ldiv0
815 -       mov     curbit, #1
816 -       mov     result, #0
817 -       cmp     dividend, divisor
818 -       bcc     Lgot_result_udivsi3
819 -1:
820 +#else
821 +
822 +       @ Initially shift the divisor left 3 bits if possible,
823 +       @ set curbit accordingly.  This allows for curbit to be located
824 +       @ at the left end of each 4 bit nibbles in the division loop
825 +       @ to save one loop in most cases.
826 +       tst     \divisor, #0xe0000000
827 +       moveq   \divisor, \divisor, lsl #3
828 +       moveq   \curbit, #8
829 +       movne   \curbit, #1
830 +
831         @ Unless the divisor is very big, shift it up in multiples of
832         @ four bits, since this is the amount of unwinding in the main
833         @ division loop.  Continue shifting until the divisor is 
834         @ larger than the dividend.
835 -       cmp     divisor, #0x10000000
836 -       cmpcc   divisor, dividend
837 -       movcc   divisor, divisor, lsl #4
838 -       movcc   curbit, curbit, lsl #4
839 -       bcc     1b
840 +1:     cmp     \divisor, #0x10000000
841 +       cmplo   \divisor, \dividend
842 +       movlo   \divisor, \divisor, lsl #4
843 +       movlo   \curbit, \curbit, lsl #4
844 +       blo     1b
845  
846 -2:
847         @ For very big divisors, we must shift it a bit at a time, or
848         @ we will be in danger of overflowing.
849 -       cmp     divisor, #0x80000000
850 -       cmpcc   divisor, dividend
851 -       movcc   divisor, divisor, lsl #1
852 -       movcc   curbit, curbit, lsl #1
853 -       bcc     2b
854 -
855 -3:
856 -       @ Test for possible subtractions, and note which bits
857 -       @ are done in the result.  On the final pass, this may subtract
858 -       @ too much from the dividend, but the result will be ok, since the
859 -       @ "bit" will have been shifted out at the bottom.
860 -       cmp     dividend, divisor
861 -       subcs   dividend, dividend, divisor
862 -       orrcs   result, result, curbit
863 -       cmp     dividend, divisor, lsr #1
864 -       subcs   dividend, dividend, divisor, lsr #1
865 -       orrcs   result, result, curbit, lsr #1
866 -       cmp     dividend, divisor, lsr #2
867 -       subcs   dividend, dividend, divisor, lsr #2
868 -       orrcs   result, result, curbit, lsr #2
869 -       cmp     dividend, divisor, lsr #3
870 -       subcs   dividend, dividend, divisor, lsr #3
871 -       orrcs   result, result, curbit, lsr #3
872 -       cmp     dividend, #0                    @ Early termination?
873 -       movnes  curbit, curbit, lsr #4          @ No, any more bits to do?
874 -       movne   divisor, divisor, lsr #4
875 -       bne     3b
876 -Lgot_result_udivsi3:
877 -       mov     r0, result
878 -       RET     pc, lr
879 +1:     cmp     \divisor, #0x80000000
880 +       cmplo   \divisor, \dividend
881 +       movlo   \divisor, \divisor, lsl #1
882 +       movlo   \curbit, \curbit, lsl #1
883 +       blo     1b
884  
885 -Ldiv0:
886 -       str     lr, [sp, #-4]!
887 -       bl      __div0
888 -       mov     r0, #0                  @ about as wrong as it could be
889 -       ldmia   sp!, {pc}RETCOND
890 +       mov     \result, #0
891  
892 -/* __umodsi3 ----------------------- */
893 +#endif
894 +
895 +       @ Division loop
896 +1:     cmp     \dividend, \divisor
897 +       subhs   \dividend, \dividend, \divisor
898 +       orrhs   \result,   \result,   \curbit
899 +       cmp     \dividend, \divisor,  lsr #1
900 +       subhs   \dividend, \dividend, \divisor, lsr #1
901 +       orrhs   \result,   \result,   \curbit,  lsr #1
902 +       cmp     \dividend, \divisor,  lsr #2
903 +       subhs   \dividend, \dividend, \divisor, lsr #2
904 +       orrhs   \result,   \result,   \curbit,  lsr #2
905 +       cmp     \dividend, \divisor,  lsr #3
906 +       subhs   \dividend, \dividend, \divisor, lsr #3
907 +       orrhs   \result,   \result,   \curbit,  lsr #3
908 +       cmp     \dividend, #0                   @ Early termination?
909 +       movnes  \curbit,   \curbit,  lsr #4     @ No, any more bits to do?
910 +       movne   \divisor,  \divisor, lsr #4
911 +       bne     1b
912 +
913 +.endm
914 +
915 +
916 +.macro ARM_DIV2_ORDER divisor, order
917 +
918 +#if __LINUX_ARM_ARCH__ >= 5
919 +
920 +       clz     \order, \divisor
921 +       rsb     \order, \order, #31
922 +
923 +#else
924 +
925 +       cmp     \divisor, #(1 << 16)
926 +       movhs   \divisor, \divisor, lsr #16
927 +       movhs   \order, #16
928 +       movlo   \order, #0
929 +
930 +       cmp     \divisor, #(1 << 8)
931 +       movhs   \divisor, \divisor, lsr #8
932 +       addhs   \order, \order, #8
933 +
934 +       cmp     \divisor, #(1 << 4)
935 +       movhs   \divisor, \divisor, lsr #4
936 +       addhs   \order, \order, #4
937 +
938 +       cmp     \divisor, #(1 << 2)
939 +       addhi   \order, \order, #3
940 +       addls   \order, \order, \divisor, lsr #1
941 +
942 +#endif
943 +
944 +.endm
945 +
946 +
947 +.macro ARM_MOD_BODY dividend, divisor, order, spare
948 +
949 +#if __LINUX_ARM_ARCH__ >= 5
950 +
951 +       clz     \order, \divisor
952 +       clz     \spare, \dividend
953 +       sub     \order, \order, \spare
954 +       mov     \divisor, \divisor, lsl \order
955 +
956 +#else
957 +
958 +       mov     \order, #0
959  
960 -ENTRY(__umodsi3)
961 -       cmp     divisor, #0
962 -       beq     Ldiv0
963 -       mov     curbit, #1
964 -       cmp     dividend, divisor
965 -       RETc(cc)        pc, lr
966 -1:
967         @ Unless the divisor is very big, shift it up in multiples of
968         @ four bits, since this is the amount of unwinding in the main
969         @ division loop.  Continue shifting until the divisor is 
970         @ larger than the dividend.
971 -       cmp     divisor, #0x10000000
972 -       cmpcc   divisor, dividend
973 -       movcc   divisor, divisor, lsl #4
974 -       movcc   curbit, curbit, lsl #4
975 -       bcc     1b
976 +1:     cmp     \divisor, #0x10000000
977 +       cmplo   \divisor, \dividend
978 +       movlo   \divisor, \divisor, lsl #4
979 +       addlo   \order, \order, #4
980 +       blo     1b
981  
982 -2:
983         @ For very big divisors, we must shift it a bit at a time, or
984         @ we will be in danger of overflowing.
985 -       cmp     divisor, #0x80000000
986 -       cmpcc   divisor, dividend
987 -       movcc   divisor, divisor, lsl #1
988 -       movcc   curbit, curbit, lsl #1
989 -       bcc     2b
990 -
991 -3:
992 -       @ Test for possible subtractions.  On the final pass, this may 
993 -       @ subtract too much from the dividend, so keep track of which
994 -       @ subtractions are done, we can fix them up afterwards...
995 -       mov     overdone, #0
996 -       cmp     dividend, divisor
997 -       subcs   dividend, dividend, divisor
998 -       cmp     dividend, divisor, lsr #1
999 -       subcs   dividend, dividend, divisor, lsr #1
1000 -       orrcs   overdone, overdone, curbit, ror #1
1001 -       cmp     dividend, divisor, lsr #2
1002 -       subcs   dividend, dividend, divisor, lsr #2
1003 -       orrcs   overdone, overdone, curbit, ror #2
1004 -       cmp     dividend, divisor, lsr #3
1005 -       subcs   dividend, dividend, divisor, lsr #3
1006 -       orrcs   overdone, overdone, curbit, ror #3
1007 -       mov     ip, curbit
1008 -       cmp     dividend, #0                    @ Early termination?
1009 -       movnes  curbit, curbit, lsr #4          @ No, any more bits to do?
1010 -       movne   divisor, divisor, lsr #4
1011 -       bne     3b
1012 -
1013 -       @ Any subtractions that we should not have done will be recorded in
1014 -       @ the top three bits of "overdone".  Exactly which were not needed
1015 -       @ are governed by the position of the bit, stored in ip.
1016 -       @ If we terminated early, because dividend became zero,
1017 -       @ then none of the below will match, since the bit in ip will not be
1018 -       @ in the bottom nibble.
1019 -       ands    overdone, overdone, #0xe0000000
1020 -       RETc(eq)        pc, lr                          @ No fixups needed
1021 -       tst     overdone, ip, ror #3
1022 -       addne   dividend, dividend, divisor, lsr #3
1023 -       tst     overdone, ip, ror #2
1024 -       addne   dividend, dividend, divisor, lsr #2
1025 -       tst     overdone, ip, ror #1
1026 -       addne   dividend, dividend, divisor, lsr #1
1027 -       RET     pc, lr
1028 +1:     cmp     \divisor, #0x80000000
1029 +       cmplo   \divisor, \dividend
1030 +       movlo   \divisor, \divisor, lsl #1
1031 +       addlo   \order, \order, #1
1032 +       blo     1b
1033 +
1034 +#endif
1035 +
1036 +       @ Perform all needed substractions to keep only the reminder.
1037 +       @ Do comparisons in batch of 4 first.
1038 +       subs    \order, \order, #3              @ yes, 3 is intended here
1039 +       blt     2f
1040 +
1041 +1:     cmp     \dividend, \divisor
1042 +       subhs   \dividend, \dividend, \divisor
1043 +       cmp     \dividend, \divisor,  lsr #1
1044 +       subhs   \dividend, \dividend, \divisor, lsr #1
1045 +       cmp     \dividend, \divisor,  lsr #2
1046 +       subhs   \dividend, \dividend, \divisor, lsr #2
1047 +       cmp     \dividend, \divisor,  lsr #3
1048 +       subhs   \dividend, \dividend, \divisor, lsr #3
1049 +       cmp     \dividend, #1
1050 +       mov     \divisor, \divisor, lsr #4
1051 +       subges  \order, \order, #4
1052 +       bge     1b
1053 +
1054 +       tst     \order, #3
1055 +       teqne   \dividend, #0
1056 +       beq     5f
1057 +
1058 +       @ Either 1, 2 or 3 comparison/substractions are left.
1059 +2:     cmn     \order, #2
1060 +       blt     4f
1061 +       beq     3f
1062 +       cmp     \dividend, \divisor
1063 +       subhs   \dividend, \dividend, \divisor
1064 +       mov     \divisor,  \divisor,  lsr #1
1065 +3:     cmp     \dividend, \divisor
1066 +       subhs   \dividend, \dividend, \divisor
1067 +       mov     \divisor,  \divisor,  lsr #1
1068 +4:     cmp     \dividend, \divisor
1069 +       subhs   \dividend, \dividend, \divisor
1070 +5:
1071 +.endm
1072 +
1073 +
1074 +ENTRY(__udivsi3)
1075 +
1076 +       subs    r2, r1, #1
1077 +       moveq   pc, lr
1078 +       bcc     Ldiv0
1079 +       cmp     r0, r1
1080 +       bls     11f
1081 +       tst     r1, r2
1082 +       beq     12f
1083 +
1084 +       ARM_DIV_BODY r0, r1, r2, r3
1085 +
1086 +       mov     r0, r2
1087 +       mov     pc, lr
1088 +
1089 +11:    moveq   r0, #1
1090 +       movne   r0, #0
1091 +       mov     pc, lr
1092 +
1093 +12:    ARM_DIV2_ORDER r1, r2
1094 +
1095 +       mov     r0, r0, lsr r2
1096 +       mov     pc, lr
1097 +
1098 +
1099 +ENTRY(__umodsi3)
1100 +
1101 +       subs    r2, r1, #1                      @ compare divisor with 1
1102 +       bcc     Ldiv0
1103 +       cmpne   r0, r1                          @ compare dividend with divisor
1104 +       moveq   r0, #0
1105 +       tsthi   r1, r2                          @ see if divisor is power of 2
1106 +       andeq   r0, r0, r2
1107 +       movls   pc, lr
1108 +
1109 +       ARM_MOD_BODY r0, r1, r2, r3
1110 +
1111 +       mov     pc, lr
1112 +
1113  
1114  ENTRY(__divsi3)
1115 -       eor     ip, dividend, divisor           @ Save the sign of the result.
1116 -       mov     curbit, #1
1117 -       mov     result, #0
1118 -       cmp     divisor, #0
1119 -       rsbmi   divisor, divisor, #0            @ Loops below use unsigned.
1120 +
1121 +       cmp     r1, #0
1122 +       eor     ip, r0, r1                      @ save the sign of the result.
1123         beq     Ldiv0
1124 -       cmp     dividend, #0
1125 -       rsbmi   dividend, dividend, #0
1126 -       cmp     dividend, divisor
1127 -       bcc     Lgot_result_divsi3
1128 +       rsbmi   r1, r1, #0                      @ loops below use unsigned.
1129 +       subs    r2, r1, #1                      @ division by 1 or -1 ?
1130 +       beq     10f
1131 +       movs    r3, r0
1132 +       rsbmi   r3, r0, #0                      @ positive dividend value
1133 +       cmp     r3, r1
1134 +       bls     11f
1135 +       tst     r1, r2                          @ divisor is power of 2 ?
1136 +       beq     12f
1137  
1138 -1:
1139 -       @ Unless the divisor is very big, shift it up in multiples of
1140 -       @ four bits, since this is the amount of unwinding in the main
1141 -       @ division loop.  Continue shifting until the divisor is 
1142 -       @ larger than the dividend.
1143 -       cmp     divisor, #0x10000000
1144 -       cmpcc   divisor, dividend
1145 -       movcc   divisor, divisor, lsl #4
1146 -       movcc   curbit, curbit, lsl #4
1147 -       bcc     1b
1148 +       ARM_DIV_BODY r3, r1, r0, r2
1149  
1150 -2:
1151 -       @ For very big divisors, we must shift it a bit at a time, or
1152 -       @ we will be in danger of overflowing.
1153 -       cmp     divisor, #0x80000000
1154 -       cmpcc   divisor, dividend
1155 -       movcc   divisor, divisor, lsl #1
1156 -       movcc   curbit, curbit, lsl #1
1157 -       bcc     2b
1158 -
1159 -3:
1160 -       @ Test for possible subtractions, and note which bits
1161 -       @ are done in the result.  On the final pass, this may subtract
1162 -       @ too much from the dividend, but the result will be ok, since the
1163 -       @ "bit" will have been shifted out at the bottom.
1164 -       cmp     dividend, divisor
1165 -       subcs   dividend, dividend, divisor
1166 -       orrcs   result, result, curbit
1167 -       cmp     dividend, divisor, lsr #1
1168 -       subcs   dividend, dividend, divisor, lsr #1
1169 -       orrcs   result, result, curbit, lsr #1
1170 -       cmp     dividend, divisor, lsr #2
1171 -       subcs   dividend, dividend, divisor, lsr #2
1172 -       orrcs   result, result, curbit, lsr #2
1173 -       cmp     dividend, divisor, lsr #3
1174 -       subcs   dividend, dividend, divisor, lsr #3
1175 -       orrcs   result, result, curbit, lsr #3
1176 -       cmp     dividend, #0                    @ Early termination?
1177 -       movnes  curbit, curbit, lsr #4          @ No, any more bits to do?
1178 -       movne   divisor, divisor, lsr #4
1179 -       bne     3b
1180 -Lgot_result_divsi3:
1181 -       mov     r0, result
1182         cmp     ip, #0
1183         rsbmi   r0, r0, #0
1184 -       RET     pc, lr
1185 +       mov     pc, lr
1186 +
1187 +10:    teq     ip, r0                          @ same sign ?
1188 +       rsbmi   r0, r0, #0
1189 +       mov     pc, lr
1190 +
1191 +11:    movlo   r0, #0
1192 +       moveq   r0, ip, asr #31
1193 +       orreq   r0, r0, #1
1194 +       mov     pc, lr
1195 +
1196 +12:    ARM_DIV2_ORDER r1, r2
1197 +
1198 +       cmp     ip, #0
1199 +       mov     r0, r3, lsr r2
1200 +       rsbmi   r0, r0, #0
1201 +       mov     pc, lr
1202 +
1203  
1204  ENTRY(__modsi3)
1205 -       mov     curbit, #1
1206 -       cmp     divisor, #0
1207 -       rsbmi   divisor, divisor, #0            @ Loops below use unsigned.
1208 +
1209 +       cmp     r1, #0
1210         beq     Ldiv0
1211 -       @ Need to save the sign of the dividend, unfortunately, we need
1212 -       @ ip later on; this is faster than pushing lr and using that.
1213 -       str     dividend, [sp, #-4]!
1214 -       cmp     dividend, #0
1215 -       rsbmi   dividend, dividend, #0
1216 -       cmp     dividend, divisor
1217 -       bcc     Lgot_result_modsi3
1218 +       rsbmi   r1, r1, #0                      @ loops below use unsigned.
1219 +       movs    ip, r0                          @ preserve sign of dividend
1220 +       rsbmi   r0, r0, #0                      @ if negative make positive
1221 +       subs    r2, r1, #1                      @ compare divisor with 1
1222 +       cmpne   r0, r1                          @ compare dividend with divisor
1223 +       moveq   r0, #0
1224 +       tsthi   r1, r2                          @ see if divisor is power of 2
1225 +       andeq   r0, r0, r2
1226 +       bls     10f
1227 +
1228 +       ARM_MOD_BODY r0, r1, r2, r3
1229 +
1230 +10:    cmp     ip, #0
1231 +       rsbmi   r0, r0, #0
1232 +       mov     pc, lr
1233 +
1234 +
1235 +Ldiv0:
1236 +
1237 +       str     lr, [sp, #-4]!
1238 +       bl      __div0
1239 +       mov     r0, #0                  @ About as wrong as it could be.
1240 +       ldr     pc, [sp], #4
1241  
1242 -1:
1243 -       @ Unless the divisor is very big, shift it up in multiples of
1244 -       @ four bits, since this is the amount of unwinding in the main
1245 -       @ division loop.  Continue shifting until the divisor is 
1246 -       @ larger than the dividend.
1247 -       cmp     divisor, #0x10000000
1248 -       cmpcc   divisor, dividend
1249 -       movcc   divisor, divisor, lsl #4
1250 -       movcc   curbit, curbit, lsl #4
1251 -       bcc     1b
1252  
1253 -2:
1254 -       @ For very big divisors, we must shift it a bit at a time, or
1255 -       @ we will be in danger of overflowing.
1256 -       cmp     divisor, #0x80000000
1257 -       cmpcc   divisor, dividend
1258 -       movcc   divisor, divisor, lsl #1
1259 -       movcc   curbit, curbit, lsl #1
1260 -       bcc     2b
1261 -
1262 -3:
1263 -       @ Test for possible subtractions.  On the final pass, this may 
1264 -       @ subtract too much from the dividend, so keep track of which
1265 -       @ subtractions are done, we can fix them up afterwards...
1266 -       mov     overdone, #0
1267 -       cmp     dividend, divisor
1268 -       subcs   dividend, dividend, divisor
1269 -       cmp     dividend, divisor, lsr #1
1270 -       subcs   dividend, dividend, divisor, lsr #1
1271 -       orrcs   overdone, overdone, curbit, ror #1
1272 -       cmp     dividend, divisor, lsr #2
1273 -       subcs   dividend, dividend, divisor, lsr #2
1274 -       orrcs   overdone, overdone, curbit, ror #2
1275 -       cmp     dividend, divisor, lsr #3
1276 -       subcs   dividend, dividend, divisor, lsr #3
1277 -       orrcs   overdone, overdone, curbit, ror #3
1278 -       mov     ip, curbit
1279 -       cmp     dividend, #0                    @ Early termination?
1280 -       movnes  curbit, curbit, lsr #4          @ No, any more bits to do?
1281 -       movne   divisor, divisor, lsr #4
1282 -       bne     3b
1283 -
1284 -       @ Any subtractions that we should not have done will be recorded in
1285 -       @ the top three bits of "overdone".  Exactly which were not needed
1286 -       @ are governed by the position of the bit, stored in ip.
1287 -       @ If we terminated early, because dividend became zero,
1288 -       @ then none of the below will match, since the bit in ip will not be
1289 -       @ in the bottom nibble.
1290 -       ands    overdone, overdone, #0xe0000000
1291 -       beq     Lgot_result_modsi3
1292 -       tst     overdone, ip, ror #3
1293 -       addne   dividend, dividend, divisor, lsr #3
1294 -       tst     overdone, ip, ror #2
1295 -       addne   dividend, dividend, divisor, lsr #2
1296 -       tst     overdone, ip, ror #1
1297 -       addne   dividend, dividend, divisor, lsr #1
1298 -Lgot_result_modsi3:
1299 -       ldr     ip, [sp], #4
1300 -       cmp     ip, #0
1301 -       rsbmi   dividend, dividend, #0
1302 -       RET     pc, lr
1303 --- linux-2.6.0-test6/arch/arm/mach-integrator/core.c   2003-09-27 18:57:43.000000000 -0700
1304 +++ 25/arch/arm/mach-integrator/core.c  2003-10-05 00:33:23.000000000 -0700
1305 @@ -1,134 +1,59 @@
1306  /*
1307 - *  linux/arch/arm/mach-integrator/arch.c
1308 + *  linux/arch/arm/mach-integrator/core.c
1309   *
1310 - *  Copyright (C) 2000 Deep Blue Solutions Ltd
1311 + *  Copyright (C) 2000-2003 Deep Blue Solutions Ltd
1312   *
1313   * This program is free software; you can redistribute it and/or modify
1314 - * it under the terms of the GNU General Public License as published by
1315 - * the Free Software Foundation; either version 2 of the License, or
1316 - * (at your option) any later version.
1317 - *
1318 - * This program is distributed in the hope that it will be useful,
1319 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1320 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1321 - * GNU General Public License for more details.
1322 - *
1323 - * You should have received a copy of the GNU General Public License
1324 - * along with this program; if not, write to the Free Software
1325 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1326 + * it under the terms of the GNU General Public License version 2, as
1327 + * published by the Free Software Foundation.
1328   */
1329  #include <linux/types.h>
1330  #include <linux/kernel.h>
1331  #include <linux/init.h>
1332 -#include <linux/list.h>
1333  #include <linux/device.h>
1334 -#include <linux/slab.h>
1335 -#include <linux/string.h>
1336  
1337  #include <asm/hardware.h>
1338 -#include <asm/io.h>
1339  #include <asm/irq.h>
1340 -#include <asm/setup.h>
1341 -#include <asm/mach-types.h>
1342  #include <asm/hardware/amba.h>
1343 -#include <asm/hardware/amba_kmi.h>
1344 -
1345 -#include <asm/arch/lm.h>
1346 -
1347 -#include <asm/mach/arch.h>
1348 -#include <asm/mach/irq.h>
1349 -#include <asm/mach/map.h>
1350 -
1351 -/* 
1352 - * All IO addresses are mapped onto VA 0xFFFx.xxxx, where x.xxxx
1353 - * is the (PA >> 12).
1354 - *
1355 - * Setup a VA for the Integrator interrupt controller (for header #0,
1356 - * just for now).
1357 - */
1358 -#define VA_IC_BASE     IO_ADDRESS(INTEGRATOR_IC_BASE) 
1359 -#define VA_SC_BASE     IO_ADDRESS(INTEGRATOR_SC_BASE)
1360 -#define VA_CMIC_BASE   IO_ADDRESS(INTEGRATOR_HDR_BASE) + INTEGRATOR_HDR_IC_OFFSET
1361 -
1362 -/*
1363 - * Logical      Physical
1364 - * e8000000    40000000        PCI memory              PHYS_PCI_MEM_BASE       (max 512M)
1365 - * ec000000    61000000        PCI config space        PHYS_PCI_CONFIG_BASE    (max 16M)
1366 - * ed000000    62000000        PCI V3 regs             PHYS_PCI_V3_BASE        (max 64k)
1367 - * ee000000    60000000        PCI IO                  PHYS_PCI_IO_BASE        (max 16M)
1368 - * ef000000                    Cache flush
1369 - * f1000000    10000000        Core module registers
1370 - * f1100000    11000000        System controller registers
1371 - * f1200000    12000000        EBI registers
1372 - * f1300000    13000000        Counter/Timer
1373 - * f1400000    14000000        Interrupt controller
1374 - * f1500000    15000000        RTC
1375 - * f1600000    16000000        UART 0
1376 - * f1700000    17000000        UART 1
1377 - * f1a00000    1a000000        Debug LEDs
1378 - * f1b00000    1b000000        GPIO
1379 - */
1380  
1381 -static struct map_desc integrator_io_desc[] __initdata = {
1382 - { IO_ADDRESS(INTEGRATOR_HDR_BASE),   INTEGRATOR_HDR_BASE,   SZ_4K,  MT_DEVICE },
1383 - { IO_ADDRESS(INTEGRATOR_SC_BASE),    INTEGRATOR_SC_BASE,    SZ_4K,  MT_DEVICE },
1384 - { IO_ADDRESS(INTEGRATOR_EBI_BASE),   INTEGRATOR_EBI_BASE,   SZ_4K,  MT_DEVICE },
1385 - { IO_ADDRESS(INTEGRATOR_CT_BASE),    INTEGRATOR_CT_BASE,    SZ_4K,  MT_DEVICE },
1386 - { IO_ADDRESS(INTEGRATOR_IC_BASE),    INTEGRATOR_IC_BASE,    SZ_4K,  MT_DEVICE },
1387 - { IO_ADDRESS(INTEGRATOR_RTC_BASE),   INTEGRATOR_RTC_BASE,   SZ_4K,  MT_DEVICE },
1388 - { IO_ADDRESS(INTEGRATOR_UART0_BASE), INTEGRATOR_UART0_BASE, SZ_4K,  MT_DEVICE },
1389 - { IO_ADDRESS(INTEGRATOR_UART1_BASE), INTEGRATOR_UART1_BASE, SZ_4K,  MT_DEVICE },
1390 - { IO_ADDRESS(INTEGRATOR_DBG_BASE),   INTEGRATOR_DBG_BASE,   SZ_4K,  MT_DEVICE },
1391 - { IO_ADDRESS(INTEGRATOR_GPIO_BASE),  INTEGRATOR_GPIO_BASE,  SZ_4K,  MT_DEVICE },
1392 - { PCI_MEMORY_VADDR,                  PHYS_PCI_MEM_BASE,     SZ_16M, MT_DEVICE },
1393 - { PCI_CONFIG_VADDR,                  PHYS_PCI_CONFIG_BASE,  SZ_16M, MT_DEVICE },
1394 - { PCI_V3_VADDR,                      PHYS_PCI_V3_BASE,      SZ_64K, MT_DEVICE },
1395 - { PCI_IO_VADDR,                      PHYS_PCI_IO_BASE,      SZ_64K, MT_DEVICE }
1396 +static struct amba_device rtc_device = {
1397 +       .dev            = {
1398 +               .bus_id = "mb:15",
1399 +       },
1400 +       .res            = {
1401 +               .start  = INTEGRATOR_RTC_BASE,
1402 +               .end    = INTEGRATOR_RTC_BASE + SZ_4K - 1,
1403 +               .flags  = IORESOURCE_MEM,
1404 +       },
1405 +       .irq            = IRQ_RTCINT,
1406 +       .periphid       = 0x00041030,
1407  };
1408  
1409 -static void __init integrator_map_io(void)
1410 -{
1411 -       iotable_init(integrator_io_desc, ARRAY_SIZE(integrator_io_desc));
1412 -}
1413 -
1414 -#define ALLPCI ( (1 << IRQ_PCIINT0) | (1 << IRQ_PCIINT1) | (1 << IRQ_PCIINT2) | (1 << IRQ_PCIINT3) )
1415 -
1416 -static void sc_mask_irq(unsigned int irq)
1417 -{
1418 -       writel(1 << irq, VA_IC_BASE + IRQ_ENABLE_CLEAR);
1419 -}
1420 -
1421 -static void sc_unmask_irq(unsigned int irq)
1422 -{
1423 -       writel(1 << irq, VA_IC_BASE + IRQ_ENABLE_SET);
1424 -}
1425 -
1426 -static struct irqchip sc_chip = {
1427 -       .ack    = sc_mask_irq,
1428 -       .mask   = sc_mask_irq,
1429 -       .unmask = sc_unmask_irq,
1430 +static struct amba_device uart0_device = {
1431 +       .dev            = {
1432 +               .bus_id = "mb:16",
1433 +       },
1434 +       .res            = {
1435 +               .start  = INTEGRATOR_UART0_BASE,
1436 +               .end    = INTEGRATOR_UART0_BASE + SZ_4K - 1,
1437 +               .flags  = IORESOURCE_MEM,
1438 +       },
1439 +       .irq            = IRQ_UARTINT0,
1440 +       .periphid       = 0x0041010,
1441  };
1442  
1443 -static void __init integrator_init_irq(void)
1444 -{
1445 -       unsigned int i;
1446 -
1447 -       /* Disable all interrupts initially. */
1448 -       /* Do the core module ones */
1449 -       writel(-1, VA_CMIC_BASE + IRQ_ENABLE_CLEAR);
1450 -
1451 -       /* do the header card stuff next */
1452 -       writel(-1, VA_IC_BASE + IRQ_ENABLE_CLEAR);
1453 -       writel(-1, VA_IC_BASE + FIQ_ENABLE_CLEAR);
1454 -
1455 -       for (i = 0; i < NR_IRQS; i++) {
1456 -               if (((1 << i) && INTEGRATOR_SC_VALID_INT) != 0) {
1457 -                       set_irq_chip(i, &sc_chip);
1458 -                       set_irq_handler(i, do_level_IRQ);
1459 -                       set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
1460 -               }
1461 -       }
1462 -}
1463 +static struct amba_device uart1_device = {
1464 +       .dev            = {
1465 +               .bus_id = "mb:17",
1466 +       },
1467 +       .res            = {
1468 +               .start  = INTEGRATOR_UART1_BASE,
1469 +               .end    = INTEGRATOR_UART1_BASE + SZ_4K - 1,
1470 +               .flags  = IORESOURCE_MEM,
1471 +       },
1472 +       .irq            = IRQ_UARTINT1,
1473 +       .periphid       = 0x0041010,
1474 +};
1475  
1476  static struct amba_device kmi0_device = {
1477         .dev            = {
1478 @@ -136,7 +61,7 @@ static struct amba_device kmi0_device = 
1479         },
1480         .res            = {
1481                 .start  = KMI0_BASE,
1482 -               .end    = KMI0_BASE + KMI_SIZE - 1,
1483 +               .end    = KMI0_BASE + SZ_4K - 1,
1484                 .flags  = IORESOURCE_MEM,
1485         },
1486         .irq            = IRQ_KMIINT0,
1487 @@ -149,7 +74,7 @@ static struct amba_device kmi1_device = 
1488         },
1489         .res            = {
1490                 .start  = KMI1_BASE,
1491 -               .end    = KMI1_BASE + KMI_SIZE - 1,
1492 +               .end    = KMI1_BASE + SZ_4K - 1,
1493                 .flags  = IORESOURCE_MEM,
1494         },
1495         .irq            = IRQ_KMIINT1,
1496 @@ -157,52 +82,23 @@ static struct amba_device kmi1_device = 
1497  };
1498  
1499  static struct amba_device *amba_devs[] __initdata = {
1500 +       &rtc_device,
1501 +       &uart0_device,
1502 +       &uart1_device,
1503         &kmi0_device,
1504         &kmi1_device,
1505  };
1506  
1507 -static int __init register_devices(void)
1508 +static int __init integrator_init(void)
1509  {
1510 -       unsigned long sc_dec;
1511         int i;
1512  
1513         for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
1514                 struct amba_device *d = amba_devs[i];
1515 -
1516                 amba_device_register(d, &iomem_resource);
1517         }
1518  
1519 -       sc_dec = readl(VA_SC_BASE + INTEGRATOR_SC_DEC_OFFSET);
1520 -       for (i = 0; i < 4; i++) {
1521 -               struct lm_device *lmdev;
1522 -
1523 -               if ((sc_dec & (16 << i)) == 0)
1524 -                       continue;
1525 -
1526 -               lmdev = kmalloc(sizeof(struct lm_device), GFP_KERNEL);
1527 -               if (!lmdev)
1528 -                       continue;
1529 -
1530 -               memset(lmdev, 0, sizeof(struct lm_device));
1531 -
1532 -               lmdev->resource.start = 0xc0000000 + 0x10000000 * i;
1533 -               lmdev->resource.end = lmdev->resource.start + 0x0fffffff;
1534 -               lmdev->resource.flags = IORESOURCE_MEM;
1535 -               lmdev->irq = IRQ_EXPINT0 + i;
1536 -               lmdev->id = i;
1537 -
1538 -               lm_device_register(lmdev);
1539 -       }
1540 -
1541         return 0;
1542  }
1543  
1544 -arch_initcall(register_devices);
1545 -
1546 -MACHINE_START(INTEGRATOR, "ARM-Integrator")
1547 -       MAINTAINER("ARM Ltd/Deep Blue Solutions Ltd")
1548 -       BOOT_MEM(0x00000000, 0x16000000, 0xf1600000)
1549 -       BOOT_PARAMS(0x00000100)
1550 -       MAPIO(integrator_map_io)
1551 -       INITIRQ(integrator_init_irq)
1552 -MACHINE_END
1553 +arch_initcall(integrator_init);
1554 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
1555 +++ 25/arch/arm/mach-integrator/integrator_ap.c 2003-10-05 00:33:23.000000000 -0700
1556 @@ -0,0 +1,294 @@
1557 +/*
1558 + *  linux/arch/arm/mach-integrator/integrator_ap.c
1559 + *
1560 + *  Copyright (C) 2000-2003 Deep Blue Solutions Ltd
1561 + *
1562 + * This program is free software; you can redistribute it and/or modify
1563 + * it under the terms of the GNU General Public License as published by
1564 + * the Free Software Foundation; either version 2 of the License, or
1565 + * (at your option) any later version.
1566 + *
1567 + * This program is distributed in the hope that it will be useful,
1568 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1569 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1570 + * GNU General Public License for more details.
1571 + *
1572 + * You should have received a copy of the GNU General Public License
1573 + * along with this program; if not, write to the Free Software
1574 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1575 + */
1576 +#include <linux/types.h>
1577 +#include <linux/kernel.h>
1578 +#include <linux/init.h>
1579 +#include <linux/list.h>
1580 +#include <linux/device.h>
1581 +#include <linux/slab.h>
1582 +#include <linux/string.h>
1583 +#include <linux/sysdev.h>
1584 +
1585 +#include <asm/hardware.h>
1586 +#include <asm/io.h>
1587 +#include <asm/irq.h>
1588 +#include <asm/setup.h>
1589 +#include <asm/mach-types.h>
1590 +#include <asm/hardware/amba.h>
1591 +#include <asm/hardware/amba_kmi.h>
1592 +
1593 +#include <asm/arch/lm.h>
1594 +
1595 +#include <asm/mach/arch.h>
1596 +#include <asm/mach/flash.h>
1597 +#include <asm/mach/irq.h>
1598 +#include <asm/mach/map.h>
1599 +
1600 +
1601 +/* 
1602 + * All IO addresses are mapped onto VA 0xFFFx.xxxx, where x.xxxx
1603 + * is the (PA >> 12).
1604 + *
1605 + * Setup a VA for the Integrator interrupt controller (for header #0,
1606 + * just for now).
1607 + */
1608 +#define VA_IC_BASE     IO_ADDRESS(INTEGRATOR_IC_BASE) 
1609 +#define VA_SC_BASE     IO_ADDRESS(INTEGRATOR_SC_BASE)
1610 +#define VA_EBI_BASE    IO_ADDRESS(INTEGRATOR_EBI_BASE)
1611 +#define VA_CMIC_BASE   IO_ADDRESS(INTEGRATOR_HDR_BASE) + INTEGRATOR_HDR_IC_OFFSET
1612 +
1613 +/*
1614 + * Logical      Physical
1615 + * e8000000    40000000        PCI memory              PHYS_PCI_MEM_BASE       (max 512M)
1616 + * ec000000    61000000        PCI config space        PHYS_PCI_CONFIG_BASE    (max 16M)
1617 + * ed000000    62000000        PCI V3 regs             PHYS_PCI_V3_BASE        (max 64k)
1618 + * ee000000    60000000        PCI IO                  PHYS_PCI_IO_BASE        (max 16M)
1619 + * ef000000                    Cache flush
1620 + * f1000000    10000000        Core module registers
1621 + * f1100000    11000000        System controller registers
1622 + * f1200000    12000000        EBI registers
1623 + * f1300000    13000000        Counter/Timer
1624 + * f1400000    14000000        Interrupt controller
1625 + * f1500000    15000000        RTC
1626 + * f1600000    16000000        UART 0
1627 + * f1700000    17000000        UART 1
1628 + * f1a00000    1a000000        Debug LEDs
1629 + * f1b00000    1b000000        GPIO
1630 + */
1631 +
1632 +static struct map_desc ap_io_desc[] __initdata = {
1633 + { IO_ADDRESS(INTEGRATOR_HDR_BASE),   INTEGRATOR_HDR_BASE,   SZ_4K,  MT_DEVICE },
1634 + { IO_ADDRESS(INTEGRATOR_SC_BASE),    INTEGRATOR_SC_BASE,    SZ_4K,  MT_DEVICE },
1635 + { IO_ADDRESS(INTEGRATOR_EBI_BASE),   INTEGRATOR_EBI_BASE,   SZ_4K,  MT_DEVICE },
1636 + { IO_ADDRESS(INTEGRATOR_CT_BASE),    INTEGRATOR_CT_BASE,    SZ_4K,  MT_DEVICE },
1637 + { IO_ADDRESS(INTEGRATOR_IC_BASE),    INTEGRATOR_IC_BASE,    SZ_4K,  MT_DEVICE },
1638 + { IO_ADDRESS(INTEGRATOR_RTC_BASE),   INTEGRATOR_RTC_BASE,   SZ_4K,  MT_DEVICE },
1639 + { IO_ADDRESS(INTEGRATOR_UART0_BASE), INTEGRATOR_UART0_BASE, SZ_4K,  MT_DEVICE },
1640 + { IO_ADDRESS(INTEGRATOR_UART1_BASE), INTEGRATOR_UART1_BASE, SZ_4K,  MT_DEVICE },
1641 + { IO_ADDRESS(INTEGRATOR_DBG_BASE),   INTEGRATOR_DBG_BASE,   SZ_4K,  MT_DEVICE },
1642 + { IO_ADDRESS(INTEGRATOR_GPIO_BASE),  INTEGRATOR_GPIO_BASE,  SZ_4K,  MT_DEVICE },
1643 + { PCI_MEMORY_VADDR,                  PHYS_PCI_MEM_BASE,     SZ_16M, MT_DEVICE },
1644 + { PCI_CONFIG_VADDR,                  PHYS_PCI_CONFIG_BASE,  SZ_16M, MT_DEVICE },
1645 + { PCI_V3_VADDR,                      PHYS_PCI_V3_BASE,      SZ_64K, MT_DEVICE },
1646 + { PCI_IO_VADDR,                      PHYS_PCI_IO_BASE,      SZ_64K, MT_DEVICE }
1647 +};
1648 +
1649 +static void __init ap_map_io(void)
1650 +{
1651 +       iotable_init(ap_io_desc, ARRAY_SIZE(ap_io_desc));
1652 +}
1653 +
1654 +#define INTEGRATOR_SC_VALID_INT        0x003fffff
1655 +
1656 +static void sc_mask_irq(unsigned int irq)
1657 +{
1658 +       writel(1 << irq, VA_IC_BASE + IRQ_ENABLE_CLEAR);
1659 +}
1660 +
1661 +static void sc_unmask_irq(unsigned int irq)
1662 +{
1663 +       writel(1 << irq, VA_IC_BASE + IRQ_ENABLE_SET);
1664 +}
1665 +
1666 +static struct irqchip sc_chip = {
1667 +       .ack    = sc_mask_irq,
1668 +       .mask   = sc_mask_irq,
1669 +       .unmask = sc_unmask_irq,
1670 +};
1671 +
1672 +static void __init ap_init_irq(void)
1673 +{
1674 +       unsigned int i;
1675 +
1676 +       /* Disable all interrupts initially. */
1677 +       /* Do the core module ones */
1678 +       writel(-1, VA_CMIC_BASE + IRQ_ENABLE_CLEAR);
1679 +
1680 +       /* do the header card stuff next */
1681 +       writel(-1, VA_IC_BASE + IRQ_ENABLE_CLEAR);
1682 +       writel(-1, VA_IC_BASE + FIQ_ENABLE_CLEAR);
1683 +
1684 +       for (i = 0; i < NR_IRQS; i++) {
1685 +               if (((1 << i) && INTEGRATOR_SC_VALID_INT) != 0) {
1686 +                       set_irq_chip(i, &sc_chip);
1687 +                       set_irq_handler(i, do_level_IRQ);
1688 +                       set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
1689 +               }
1690 +       }
1691 +}
1692 +
1693 +#ifdef CONFIG_PM
1694 +static unsigned long ic_irq_enable;
1695 +
1696 +static int irq_suspend(struct sys_device *dev, u32 state)
1697 +{
1698 +       ic_irq_enable = readl(VA_IC_BASE + IRQ_ENABLE);
1699 +       return 0;
1700 +}
1701 +
1702 +static int irq_resume(struct sys_device *dev)
1703 +{
1704 +       /* disable all irq sources */
1705 +       writel(-1, VA_CMIC_BASE + IRQ_ENABLE_CLEAR);
1706 +       writel(-1, VA_IC_BASE + IRQ_ENABLE_CLEAR);
1707 +       writel(-1, VA_IC_BASE + FIQ_ENABLE_CLEAR);
1708 +
1709 +       writel(ic_irq_enable, VA_IC_BASE + IRQ_ENABLE_SET);
1710 +       return 0;
1711 +}
1712 +#else
1713 +#define irq_suspend NULL
1714 +#define irq_resume NULL
1715 +#endif
1716 +
1717 +static struct sysdev_class irq_class = {
1718 +       set_kset_name("irq"),
1719 +       .suspend        = irq_suspend,
1720 +       .resume         = irq_resume,
1721 +};
1722 +
1723 +static struct sys_device irq_device = {
1724 +       .id     = 0,
1725 +       .cls    = &irq_class,
1726 +};
1727 +
1728 +static int __init irq_init_sysfs(void)
1729 +{
1730 +       int ret = sysdev_class_register(&irq_class);
1731 +       if (ret == 0)
1732 +               ret = sys_device_register(&irq_device);
1733 +       return ret;
1734 +}
1735 +
1736 +device_initcall(irq_init_sysfs);
1737 +
1738 +/*
1739 + * Flash handling.
1740 + */
1741 +#define SC_CTRLC (VA_SC_BASE + INTEGRATOR_SC_CTRLC_OFFSET)
1742 +#define SC_CTRLS (VA_SC_BASE + INTEGRATOR_SC_CTRLS_OFFSET)
1743 +#define EBI_CSR1 (VA_EBI_BASE + INTEGRATOR_EBI_CSR1_OFFSET)
1744 +#define EBI_LOCK (VA_EBI_BASE + INTEGRATOR_EBI_LOCK_OFFSET)
1745 +
1746 +static int ap_flash_init(void)
1747 +{
1748 +       u32 tmp;
1749 +
1750 +       writel(INTEGRATOR_SC_CTRL_nFLVPPEN | INTEGRATOR_SC_CTRL_nFLWP, SC_CTRLC);
1751 +
1752 +       tmp = readl(EBI_CSR1) | INTEGRATOR_EBI_WRITE_ENABLE;
1753 +       writel(tmp, EBI_CSR1);
1754 +
1755 +       if (!(readl(EBI_CSR1) & INTEGRATOR_EBI_WRITE_ENABLE)) {
1756 +               writel(0xa05f, EBI_LOCK);
1757 +               writel(tmp, EBI_CSR1);
1758 +               writel(0, EBI_LOCK);
1759 +       }
1760 +       return 0;
1761 +}
1762 +
1763 +static void ap_flash_exit(void)
1764 +{
1765 +       u32 tmp;
1766 +
1767 +       writel(INTEGRATOR_SC_CTRL_nFLVPPEN | INTEGRATOR_SC_CTRL_nFLWP, SC_CTRLC);
1768 +
1769 +       tmp = readl(EBI_CSR1) & ~INTEGRATOR_EBI_WRITE_ENABLE;
1770 +       writel(tmp, EBI_CSR1);
1771 +
1772 +       if (readl(EBI_CSR1) & INTEGRATOR_EBI_WRITE_ENABLE) {
1773 +               writel(0xa05f, EBI_LOCK);
1774 +               writel(tmp, EBI_CSR1);
1775 +               writel(0, EBI_LOCK);
1776 +       }
1777 +}
1778 +
1779 +static void ap_flash_set_vpp(int on)
1780 +{
1781 +       unsigned long reg = on ? SC_CTRLS : SC_CTRLC;
1782 +
1783 +       writel(INTEGRATOR_SC_CTRL_nFLVPPEN, reg);
1784 +}
1785 +
1786 +static struct flash_platform_data ap_flash_data = {
1787 +       .map_name       = "cfi_probe",
1788 +       .width          = 4,
1789 +       .init           = ap_flash_init,
1790 +       .exit           = ap_flash_exit,
1791 +       .set_vpp        = ap_flash_set_vpp,
1792 +};
1793 +
1794 +static struct resource cfi_flash_resource = {
1795 +       .start          = INTEGRATOR_FLASH_BASE,
1796 +       .end            = INTEGRATOR_FLASH_BASE + INTEGRATOR_FLASH_SIZE - 1,
1797 +       .flags          = IORESOURCE_MEM,
1798 +};
1799 +
1800 +static struct platform_device cfi_flash_device = {
1801 +       .name           = "armflash",
1802 +       .id             = 0,
1803 +       .dev            = {
1804 +               .platform_data  = &ap_flash_data,
1805 +       },
1806 +       .num_resources  = 1,
1807 +       .resource       = &cfi_flash_resource,
1808 +};
1809 +
1810 +static int __init ap_init(void)
1811 +{
1812 +       unsigned long sc_dec;
1813 +       int i;
1814 +
1815 +       platform_add_device(&cfi_flash_device);
1816 +
1817 +       sc_dec = readl(VA_SC_BASE + INTEGRATOR_SC_DEC_OFFSET);
1818 +       for (i = 0; i < 4; i++) {
1819 +               struct lm_device *lmdev;
1820 +
1821 +               if ((sc_dec & (16 << i)) == 0)
1822 +                       continue;
1823 +
1824 +               lmdev = kmalloc(sizeof(struct lm_device), GFP_KERNEL);
1825 +               if (!lmdev)
1826 +                       continue;
1827 +
1828 +               memset(lmdev, 0, sizeof(struct lm_device));
1829 +
1830 +               lmdev->resource.start = 0xc0000000 + 0x10000000 * i;
1831 +               lmdev->resource.end = lmdev->resource.start + 0x0fffffff;
1832 +               lmdev->resource.flags = IORESOURCE_MEM;
1833 +               lmdev->irq = IRQ_AP_EXPINT0 + i;
1834 +               lmdev->id = i;
1835 +
1836 +               lm_device_register(lmdev);
1837 +       }
1838 +
1839 +       return 0;
1840 +}
1841 +
1842 +arch_initcall(ap_init);
1843 +
1844 +MACHINE_START(INTEGRATOR, "ARM-Integrator")
1845 +       MAINTAINER("ARM Ltd/Deep Blue Solutions Ltd")
1846 +       BOOT_MEM(0x00000000, 0x16000000, 0xf1600000)
1847 +       BOOT_PARAMS(0x00000100)
1848 +       MAPIO(ap_map_io)
1849 +       INITIRQ(ap_init_irq)
1850 +MACHINE_END
1851 --- linux-2.6.0-test6/arch/arm/mach-integrator/Kconfig  2003-09-27 18:57:43.000000000 -0700
1852 +++ 25/arch/arm/mach-integrator/Kconfig 2003-10-05 00:33:23.000000000 -0700
1853 @@ -1,8 +1,15 @@
1854  menu "Integrator Options"
1855         depends on ARCH_INTEGRATOR
1856  
1857 +config ARCH_INTEGRATOR_AP
1858 +       bool "Support Integrator/AP and Integrator/PP2 platforms"
1859 +       help
1860 +         Include support for the ARM(R) Integrator/AP and
1861 +         Integrator/PP2 platforms.
1862 +
1863  config INTEGRATOR_IMPD1
1864         tristate "Include support for Integrator/IM-PD1"
1865 +       depends on ARCH_INTEGRATOR_AP
1866         help
1867           The IM-PD1 is an add-on logic module for the Integrator which
1868           allows ARM(R) Ltd PrimeCells to be developed and evaluated.
1869 --- linux-2.6.0-test6/arch/arm/mach-integrator/Makefile 2003-09-27 18:57:43.000000000 -0700
1870 +++ 25/arch/arm/mach-integrator/Makefile        2003-10-05 00:33:23.000000000 -0700
1871 @@ -4,9 +4,10 @@
1872  
1873  # Object file lists.
1874  
1875 -obj-y                  := core.o lm.o time.o
1876 +obj-y                                  := core.o lm.o time.o
1877 +obj-$(CONFIG_ARCH_INTEGRATOR_AP)       += integrator_ap.o
1878  
1879 -obj-$(CONFIG_LEDS)     += leds.o
1880 -obj-$(CONFIG_PCI)      += pci_v3.o pci.o
1881 +obj-$(CONFIG_LEDS)                     += leds.o
1882 +obj-$(CONFIG_PCI)                      += pci_v3.o pci.o
1883  obj-$(CONFIG_CPU_FREQ_INTEGRATOR)      += cpu.o
1884  obj-$(CONFIG_INTEGRATOR_IMPD1)         += impd1.o
1885 --- linux-2.6.0-test6/arch/arm/mach-integrator/pci.c    2003-06-14 12:18:51.000000000 -0700
1886 +++ 25/arch/arm/mach-integrator/pci.c   2003-10-05 00:33:23.000000000 -0700
1887 @@ -96,7 +96,7 @@ static u8 __init integrator_swizzle(stru
1888  }
1889  
1890  static int irq_tab[4] __initdata = {
1891 -       IRQ_PCIINT0,    IRQ_PCIINT1,    IRQ_PCIINT2,    IRQ_PCIINT3
1892 +       IRQ_AP_PCIINT0, IRQ_AP_PCIINT1, IRQ_AP_PCIINT2, IRQ_AP_PCIINT3
1893  };
1894  
1895  /*
1896 --- linux-2.6.0-test6/arch/arm/mach-integrator/pci_v3.c 2003-06-14 12:18:28.000000000 -0700
1897 +++ 25/arch/arm/mach-integrator/pci_v3.c        2003-10-05 00:33:23.000000000 -0700
1898 @@ -575,7 +575,7 @@ void __init pci_v3_preinit(void)
1899         /*
1900          * Grab the PCI error interrupt.
1901          */
1902 -       ret = request_irq(IRQ_V3INT, v3_irq, 0, "V3", NULL);
1903 +       ret = request_irq(IRQ_AP_V3INT, v3_irq, 0, "V3", NULL);
1904         if (ret)
1905                 printk(KERN_ERR "PCI: unable to grab PCI error "
1906                        "interrupt: %d\n", ret);
1907 @@ -596,7 +596,7 @@ void __init pci_v3_postinit(void)
1908         v3_writeb(V3_LB_IMASK, 0x68);
1909  
1910  #if 0
1911 -       ret = request_irq(IRQ_LBUSTIMEOUT, lb_timeout, 0, "bus timeout", NULL);
1912 +       ret = request_irq(IRQ_AP_LBUSTIMEOUT, lb_timeout, 0, "bus timeout", NULL);
1913         if (ret)
1914                 printk(KERN_ERR "PCI: unable to grab local bus timeout "
1915                        "interrupt: %d\n", ret);
1916 --- linux-2.6.0-test6/arch/arm/mach-pxa/irq.c   2003-06-14 12:18:33.000000000 -0700
1917 +++ 25/arch/arm/mach-pxa/irq.c  2003-10-05 00:33:23.000000000 -0700
1918 @@ -58,7 +58,19 @@ static int pxa_gpio_irq_type(unsigned in
1919  {
1920         int gpio, idx;
1921  
1922 -       gpio = irq - ((irq >= IRQ_GPIO(2)) ? IRQ_GPIO(2) + 2 : IRQ_GPIO(0));
1923 +       gpio = IRQ_TO_GPIO(irq);
1924 +       idx = gpio >> 5;
1925 +
1926 +       if (type == IRQT_PROBE) {
1927 +           /* Don't mess with enabled GPIOs using preconfigured edges or
1928 +              GPIOs set to alternate function during probe */
1929 +               if ((GPIO_IRQ_rising_edge[idx] | GPIO_IRQ_falling_edge[idx]) &
1930 +                   GPIO_bit(gpio))
1931 +                       return 0;
1932 +               if (GAFR(gpio) & (0x3 << (((gpio) & 0xf)*2)))
1933 +                       return 0;
1934 +               type = __IRQT_RISEDGE | __IRQT_FALEDGE;
1935 +       }
1936  
1937         printk(KERN_DEBUG "IRQ%d (GPIO%d): ", irq, gpio);
1938  
1939 @@ -78,10 +90,8 @@ static int pxa_gpio_irq_type(unsigned in
1940  
1941         printk("edges\n");
1942  
1943 -       idx = gpio >> 5;
1944         GRER(gpio) = GPIO_IRQ_rising_edge[idx] & GPIO_IRQ_mask[idx];
1945         GFER(gpio) = GPIO_IRQ_falling_edge[idx] & GPIO_IRQ_mask[idx];
1946 -
1947         return 0;
1948  }
1949  
1950 --- linux-2.6.0-test6/arch/arm/mach-pxa/leds.c  2003-09-27 18:57:43.000000000 -0700
1951 +++ 25/arch/arm/mach-pxa/leds.c 2003-10-05 00:33:23.000000000 -0700
1952 @@ -7,6 +7,7 @@
1953   *
1954   * Copyright (c) 2001 Jeff Sutherland, Accelent Systems Inc.
1955   */
1956 +#include <linux/compiler.h>
1957  #include <linux/init.h>
1958  
1959  #include <asm/leds.h>
1960 --- linux-2.6.0-test6/arch/arm/mach-pxa/lubbock.c       2003-08-22 19:23:40.000000000 -0700
1961 +++ 25/arch/arm/mach-pxa/lubbock.c      2003-10-05 00:33:23.000000000 -0700
1962 @@ -78,7 +78,7 @@ static void __init lubbock_init_irq(void
1963         pxa_init_irq();
1964  
1965         /* setup extra lubbock irqs */
1966 -       for (irq = LUBBOCK_IRQ(0); irq <= LUBBOCK_IRQ(5); irq++) {
1967 +       for (irq = LUBBOCK_IRQ(0); irq <= LUBBOCK_LAST_IRQ; irq++) {
1968                 set_irq_chip(irq, &lubbock_irq_chip);
1969                 set_irq_handler(irq, do_level_IRQ);
1970                 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
1971 @@ -124,6 +124,7 @@ static struct map_desc lubbock_io_desc[]
1972    { 0xf0000000, 0x08000000, 0x00100000, MT_DEVICE }, /* CPLD */
1973    { 0xf1000000, 0x0c000000, 0x00100000, MT_DEVICE }, /* LAN91C96 IO */
1974    { 0xf1100000, 0x0e000000, 0x00100000, MT_DEVICE }, /* LAN91C96 Attr */
1975 +  { 0xf4000000, 0x10000000, 0x00800000, MT_DEVICE }, /* SA1111 */
1976  };
1977  
1978  static void __init lubbock_map_io(void)
1979 --- linux-2.6.0-test6/arch/arm/mach-pxa/pm.c    2003-09-27 18:57:43.000000000 -0700
1980 +++ 25/arch/arm/mach-pxa/pm.c   2003-10-05 00:33:23.000000000 -0700
1981 @@ -11,13 +11,14 @@
1982   * modify it under the terms of the GNU General Public License.
1983   */
1984  #include <linux/config.h>
1985 +#include <linux/init.h>
1986 +#include <linux/suspend.h>
1987  #include <linux/errno.h>
1988  #include <linux/time.h>
1989  
1990  #include <asm/hardware.h>
1991  #include <asm/memory.h>
1992  #include <asm/system.h>
1993 -#include <asm/leds.h>
1994  
1995  
1996  /*
1997 @@ -60,13 +61,16 @@ enum {      SLEEP_SAVE_START = 0,
1998  };
1999  
2000  
2001 -int pm_do_suspend(void)
2002 +static int pxa_pm_enter(u32 state)
2003  {
2004         unsigned long sleep_save[SLEEP_SAVE_SIZE];
2005         unsigned long checksum = 0;
2006         unsigned long delta;
2007         int i;
2008  
2009 +       if (state != PM_SUSPEND_MEM)
2010 +               return -EINVAL;
2011 +
2012         /* preserve current time */
2013         delta = xtime.tv_sec - RCNR;
2014  
2015 @@ -194,3 +198,37 @@ unsigned long sleep_phys_sp(void *sp)
2016  {
2017         return virt_to_phys(sp);
2018  }
2019 +
2020 +/*
2021 + * Called after processes are frozen, but before we shut down devices.
2022 + */
2023 +static int pxa_pm_prepare(u32 state)
2024 +{
2025 +       return 0;
2026 +}
2027 +
2028 +/*
2029 + * Called after devices are re-setup, but before processes are thawed.
2030 + */
2031 +static int pxa_pm_finish(u32 state)
2032 +{
2033 +       return 0;
2034 +}
2035 +
2036 +/*
2037 + * Set to PM_DISK_FIRMWARE so we can quickly veto suspend-to-disk.
2038 + */
2039 +static struct pm_ops pxa_pm_ops = {
2040 +       .pm_disk_mode   = PM_DISK_FIRMWARE,
2041 +       .prepare        = pxa_pm_prepare,
2042 +       .enter          = pxa_pm_enter,
2043 +       .finish         = pxa_pm_finish,
2044 +};
2045 +
2046 +static int __init pxa_pm_init(void)
2047 +{
2048 +       pm_set_ops(&pxa_pm_ops);
2049 +       return 0;
2050 +}
2051 +
2052 +late_initcall(pxa_pm_init);
2053 --- linux-2.6.0-test6/arch/arm/mach-sa1100/leds.c       2003-09-08 13:58:55.000000000 -0700
2054 +++ 25/arch/arm/mach-sa1100/leds.c      2003-10-05 00:33:23.000000000 -0700
2055 @@ -5,6 +5,7 @@
2056   * 
2057   * Copyright (C) 2001 Nicolas Pitre
2058   */
2059 +#include <linux/compiler.h>
2060  #include <linux/init.h>
2061  
2062  #include <asm/leds.h>
2063 --- linux-2.6.0-test6/arch/arm/mach-sa1100/pm.c 2003-09-08 13:58:55.000000000 -0700
2064 +++ 25/arch/arm/mach-sa1100/pm.c        2003-10-05 00:33:23.000000000 -0700
2065 @@ -22,6 +22,8 @@
2066   * 2002-05-27: Nicolas Pitre   Killed sleep.h and the kmalloced save array.
2067   *                             Storage is local on the stack now.
2068   */
2069 +#include <linux/init.h>
2070 +#include <linux/suspend.h>
2071  #include <linux/errno.h>
2072  #include <linux/time.h>
2073  
2074 @@ -54,11 +56,14 @@ enum {      SLEEP_SAVE_SP = 0,
2075  };
2076  
2077  
2078 -int pm_do_suspend(void)
2079 +static int sa11x0_pm_enter(u32 state)
2080  {
2081         unsigned long sleep_save[SLEEP_SAVE_SIZE];
2082         unsigned long delta, gpio;
2083  
2084 +       if (state != PM_SUSPEND_MEM)
2085 +               return -EINVAL;
2086 +
2087         /* preserve current time */
2088         delta = xtime.tv_sec - RCNR;
2089         gpio = GPLR;
2090 @@ -139,3 +144,37 @@ unsigned long sleep_phys_sp(void *sp)
2091  {
2092         return virt_to_phys(sp);
2093  }
2094 +
2095 +/*
2096 + * Called after processes are frozen, but before we shut down devices.
2097 + */
2098 +static int sa11x0_pm_prepare(u32 state)
2099 +{
2100 +       return 0;
2101 +}
2102 +
2103 +/*
2104 + * Called after devices are re-setup, but before processes are thawed.
2105 + */
2106 +static int sa11x0_pm_finish(u32 state)
2107 +{
2108 +       return 0;
2109 +}
2110 +
2111 +/*
2112 + * Set to PM_DISK_FIRMWARE so we can quickly veto suspend-to-disk.
2113 + */
2114 +static struct pm_ops sa11x0_pm_ops = {
2115 +       .pm_disk_mode   = PM_DISK_FIRMWARE,
2116 +       .prepare        = sa11x0_pm_prepare,
2117 +       .enter          = sa11x0_pm_enter,
2118 +       .finish         = sa11x0_pm_finish,
2119 +};
2120 +
2121 +static int __init sa11x0_pm_init(void)
2122 +{
2123 +       pm_set_ops(&sa11x0_pm_ops);
2124 +       return 0;
2125 +}
2126 +
2127 +late_initcall(sa11x0_pm_init);
2128 --- linux-2.6.0-test6/arch/arm/Makefile 2003-09-27 18:57:43.000000000 -0700
2129 +++ 25/arch/arm/Makefile        2003-10-05 00:33:23.000000000 -0700
2130 @@ -182,7 +182,6 @@ define archhelp
2131    echo  '* zImage        - Compressed kernel image (arch/$(ARCH)/boot/zImage)'
2132    echo  '  Image         - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
2133    echo  '  bootpImage    - Combined zImage and initial RAM disk' 
2134 -  echo  '  initrd        - Create an initial image'
2135    echo  '  install       - Install uncompressed kernel'
2136    echo  '  zinstall      - Install compressed kernel'
2137    echo  '                  Install using (your) ~/bin/installkernel or'
2138 --- linux-2.6.0-test6/arch/arm/mm/discontig.c   2003-06-14 12:18:31.000000000 -0700
2139 +++ 25/arch/arm/mm/discontig.c  2003-10-05 00:34:40.000000000 -0700
2140 @@ -15,7 +15,7 @@
2141  #include <linux/init.h>
2142  #include <linux/bootmem.h>
2143  
2144 -#if NR_NODES != 4
2145 +#if MAX_NUMNODES != 4
2146  #error Fix Me Please
2147  #endif
2148  
2149 @@ -23,9 +23,9 @@
2150   * Our node_data structure for discontiguous memory.
2151   */
2152  
2153 -static bootmem_data_t node_bootmem_data[NR_NODES];
2154 +static bootmem_data_t node_bootmem_data[MAX_NUMNODES];
2155  
2156 -pg_data_t discontig_node_data[NR_NODES] = {
2157 +pg_data_t discontig_node_data[MAX_NUMNODES] = {
2158    { .bdata = &node_bootmem_data[0] },
2159    { .bdata = &node_bootmem_data[1] },
2160    { .bdata = &node_bootmem_data[2] },
2161 --- linux-2.6.0-test6/arch/arm/mm/init.c        2003-07-10 18:50:30.000000000 -0700
2162 +++ 25/arch/arm/mm/init.c       2003-10-05 00:34:40.000000000 -0700
2163 @@ -33,12 +33,6 @@
2164  #include <asm/mach/arch.h>
2165  #include <asm/mach/map.h>
2166  
2167 -#ifndef CONFIG_DISCONTIGMEM
2168 -#define NR_NODES       1
2169 -#else
2170 -#define NR_NODES       4
2171 -#endif
2172 -
2173  #ifdef CONFIG_CPU_32
2174  #define TABLE_OFFSET   (PTRS_PER_PTE)
2175  #else
2176 @@ -178,7 +172,7 @@ find_memend_and_nodes(struct meminfo *mi
2177  {
2178         unsigned int i, bootmem_pages = 0, memend_pfn = 0;
2179  
2180 -       for (i = 0; i < NR_NODES; i++) {
2181 +       for (i = 0; i < MAX_NUMNODES; i++) {
2182                 np[i].start = -1U;
2183                 np[i].end = 0;
2184                 np[i].bootmap_pages = 0;
2185 @@ -207,7 +201,7 @@ find_memend_and_nodes(struct meminfo *mi
2186                          * we have, we're in trouble.  (maybe we ought to
2187                          * limit, instead of bugging?)
2188                          */
2189 -                       if (numnodes > NR_NODES)
2190 +                       if (numnodes > MAX_NUMNODES)
2191                                 BUG();
2192                 }
2193  
2194 @@ -365,7 +359,7 @@ static inline void free_bootmem_node_ban
2195   */
2196  void __init bootmem_init(struct meminfo *mi)
2197  {
2198 -       struct node_info node_info[NR_NODES], *np = node_info;
2199 +       struct node_info node_info[MAX_NUMNODES], *np = node_info;
2200         unsigned int bootmap_pages, bootmap_pfn, map_pg;
2201         int node, initrd_node;
2202  
2203 --- linux-2.6.0-test6/arch/arm/mm/ioremap.c     2003-06-14 12:18:24.000000000 -0700
2204 +++ 25/arch/arm/mm/ioremap.c    2003-10-05 00:33:23.000000000 -0700
2205 @@ -150,7 +150,7 @@ __ioremap(unsigned long phys_addr, size_
2206         if (!area)
2207                 return NULL;
2208         addr = area->addr;
2209 -       if (remap_area_pages(VMALLOC_VMADDR(addr), phys_addr, size, flags)) {
2210 +       if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) {
2211                 vfree(addr);
2212                 return NULL;
2213         }
2214 --- linux-2.6.0-test6/arch/cris/mm/ioremap.c    2003-07-10 18:50:30.000000000 -0700
2215 +++ 25/arch/cris/mm/ioremap.c   2003-10-05 00:33:23.000000000 -0700
2216 @@ -157,7 +157,7 @@ void * __ioremap(unsigned long phys_addr
2217         if (!area)
2218                 return NULL;
2219         addr = area->addr;
2220 -       if (remap_area_pages(VMALLOC_VMADDR(addr), phys_addr, size, flags)) {
2221 +       if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) {
2222                 vfree(addr);
2223                 return NULL;
2224         }
2225 --- linux-2.6.0-test6/arch/h8300/README 2003-06-14 12:18:26.000000000 -0700
2226 +++ 25/arch/h8300/README        2003-10-05 00:33:23.000000000 -0700
2227 @@ -16,7 +16,7 @@ H8S is planning.
2228  
2229  3.H8MAX 
2230    Under development
2231 -  see http://www.strawbelly-linux.com (Japanese Only)
2232 +  see http://www.strawberry-linux.com (Japanese Only)
2233  
2234  * Toolchain Version
2235  gcc-3.1 or higher and patch
2236 --- linux-2.6.0-test6/arch/i386/boot/setup.S    2003-09-27 18:57:43.000000000 -0700
2237 +++ 25/arch/i386/boot/setup.S   2003-10-05 00:36:48.000000000 -0700
2238 @@ -162,7 +162,7 @@ cmd_line_ptr:       .long 0                 # (Header versio
2239                                         # can be located anywhere in
2240                                         # low memory 0x10000 or higher.
2241  
2242 -ramdisk_max:   .long MAXMEM-1          # (Header version 0x0203 or later)
2243 +ramdisk_max:   .long __MAXMEM-1        # (Header version 0x0203 or later)
2244                                         # The highest safe address for
2245                                         # the contents of an initrd
2246  
2247 --- linux-2.6.0-test6/arch/i386/Kconfig 2003-09-27 18:57:43.000000000 -0700
2248 +++ 25/arch/i386/Kconfig        2003-10-05 00:36:48.000000000 -0700
2249 @@ -397,6 +397,54 @@ config X86_OOSTORE
2250         depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6
2251         default y
2252  
2253 +config X86_4G
2254 +       bool "4 GB kernel-space and 4 GB user-space virtual memory support"
2255 +       help
2256 +          This option is only useful for systems that have more than 1 GB
2257 +          of RAM.
2258 +
2259 +          The default kernel VM layout leaves 1 GB of virtual memory for
2260 +          kernel-space mappings, and 3 GB of VM for user-space applications.
2261 +          This option ups both the kernel-space VM and the user-space VM to
2262 +          4 GB.
2263 +
2264 +          The cost of this option is additional TLB flushes done at
2265 +          system-entry points that transition from user-mode into kernel-mode.
2266 +          I.e. system calls and page faults, and IRQs that interrupt user-mode
2267 +          code. There's also additional overhead to kernel operations that copy
2268 +          memory to/from user-space. The overhead from this is hard to tell and
2269 +          depends on the workload - it can be anything from no visible overhead
2270 +          to 20-30% overhead. A good rule of thumb is to count with a runtime
2271 +          overhead of 20%.
2272 +
2273 +          The upside is the much increased kernel-space VM, which more than
2274 +          quadruples the maximum amount of RAM supported. Kernels compiled with
2275 +          this option boot on 64GB of RAM and still have more than 3.1 GB of
2276 +          'lowmem' left. Another bonus is that highmem IO bouncing decreases,
2277 +          if used with drivers that still use bounce-buffers.
2278 +
2279 +          There's also a 33% increase in user-space VM size - database
2280 +          applications might see a boost from this.
2281 +
2282 +          But the cost of the TLB flushes and the runtime overhead has to be
2283 +          weighed against the bonuses offered by the larger VM spaces. The
2284 +          dividing line depends on the actual workload - there might be 4 GB
2285 +          systems that benefit from this option. Systems with less than 4 GB
2286 +          of RAM will rarely see a benefit from this option - but it's not
2287 +          out of question, the exact circumstances have to be considered.
2288 +
2289 +config X86_SWITCH_PAGETABLES
2290 +       def_bool X86_4G
2291 +
2292 +config X86_4G_VM_LAYOUT
2293 +       def_bool X86_4G
2294 +
2295 +config X86_UACCESS_INDIRECT
2296 +       def_bool X86_4G
2297 +
2298 +config X86_HIGH_ENTRY
2299 +       def_bool X86_4G
2300 +
2301  config HPET_TIMER
2302         bool "HPET Timer Support"
2303         help
2304 @@ -793,7 +841,8 @@ config HAVE_DEC_LOCK
2305  # Summit needs it only when NUMA is on
2306  config BOOT_IOREMAP
2307         bool
2308 -       depends on ((X86_SUMMIT || X86_GENERICARCH) && NUMA)
2309 +       depends on X86_PC
2310 +# depends on (((X86_SUMMIT || X86_GENERICARCH) && NUMA)) || X86_GENERICARCH
2311         default y
2312  
2313  endmenu
2314 @@ -1030,6 +1079,25 @@ config PCI_DIRECT
2315         depends on PCI && ((PCI_GODIRECT || PCI_GOANY) || X86_VISWS)
2316         default y
2317  
2318 +config PCI_USE_VECTOR
2319 +       bool "Vector-based interrupt indexing"
2320 +       depends on X86_LOCAL_APIC
2321 +       default n
2322 +       help
2323 +          This replaces the current existing IRQ-based index interrupt scheme
2324 +          with the vector-base index scheme. The advantages of vector base
2325 +          over IRQ base are listed below:
2326 +          1) Support MSI implementation.
2327 +          2) Support future IOxAPIC hotplug
2328 +
2329 +          Note that this enables MSI, Message Signaled Interrupt, on all
2330 +          MSI capable device functions detected if users also install the
2331 +          MSI patch. Message Signal Interrupt enables an MSI-capable
2332 +          hardware device to send an inbound Memory Write on its PCI bus
2333 +          instead of asserting IRQ signal on device IRQ pin.
2334 +
2335 +          If you don't know what to do here, say N.
2336 +
2337  source "drivers/pci/Kconfig"
2338  
2339  config ISA
2340 @@ -1231,6 +1299,15 @@ config DEBUG_PAGEALLOC
2341           This results in a large slowdown, but helps to find certain types
2342           of memory corruptions.
2343  
2344 +config SPINLINE
2345 +       bool "Spinlock inlining"
2346 +       depends on DEBUG_KERNEL
2347 +       help
2348 +         This will change spinlocks from out of line to inline, making them
2349 +         account cost to the callers in readprofile, rather than the lock
2350 +         itself (as ".text.lock.filename"). This can be helpful for finding
2351 +         the callers of locks.
2352 +
2353  config DEBUG_HIGHMEM
2354         bool "Highmem debugging"
2355         depends on DEBUG_KERNEL && HIGHMEM
2356 @@ -1247,20 +1324,208 @@ config DEBUG_INFO
2357           Say Y here only if you plan to use gdb to debug the kernel.
2358           If you don't debug the kernel, you can say N.
2359           
2360 +config LOCKMETER
2361 +       bool "Kernel lock metering"
2362 +       depends on SMP && !PREEMPT
2363 +       help
2364 +         Say Y to enable kernel lock metering, which adds overhead to SMP locks,
2365 +         but allows you to see various statistics using the lockstat command.
2366 +
2367  config DEBUG_SPINLOCK_SLEEP
2368         bool "Sleep-inside-spinlock checking"
2369         help
2370           If you say Y here, various routines which may sleep will become very
2371           noisy if they are called with a spinlock held.        
2372  
2373 +config KGDB
2374 +       bool "Include kgdb kernel debugger"
2375 +       depends on DEBUG_KERNEL
2376 +       help
2377 +         If you say Y here, the system will be compiled with the debug
2378 +         option (-g) and a debugging stub will be included in the
2379 +         kernel.  This stub communicates with gdb on another (host)
2380 +         computer via a serial port.  The host computer should have
2381 +         access to the kernel binary file (vmlinux) and a serial port
2382 +         that is connected to the target machine.  Gdb can be made to
2383 +         configure the serial port or you can use stty and setserial to
2384 +         do this. See the 'target' command in gdb. This option also
2385 +         configures in the ability to request a breakpoint early in the
2386 +         boot process.  To request the breakpoint just include 'kgdb'
2387 +         as a boot option when booting the target machine.  The system
2388 +         will then break as soon as it looks at the boot options.  This
2389 +         option also installs a breakpoint in panic and sends any
2390 +         kernel faults to the debugger. For more information see the
2391 +         Documentation/i386/kgdb.txt file.
2392 +
2393 +choice
2394 +       depends on KGDB
2395 +       prompt "Debug serial port BAUD"
2396 +       default KGDB_115200BAUD
2397 +       help
2398 +         Gdb and the kernel stub need to agree on the baud rate to be
2399 +         used.  Some systems (x86 family at this writing) allow this to
2400 +         be configured.
2401 +
2402 +config KGDB_9600BAUD
2403 +       bool "9600"
2404 +
2405 +config KGDB_19200BAUD
2406 +       bool "19200"
2407 +
2408 +config KGDB_38400BAUD
2409 +       bool "38400"
2410 +
2411 +config KGDB_57600BAUD
2412 +       bool "57600"
2413 +
2414 +config KGDB_115200BAUD
2415 +       bool "115200"
2416 +endchoice
2417 +
2418 +config KGDB_PORT
2419 +       hex "hex I/O port address of the debug serial port"
2420 +       depends on KGDB
2421 +       default  3f8
2422 +       help
2423 +         Some systems (x86 family at this writing) allow the port
2424 +         address to be configured.  The number entered is assumed to be
2425 +         hex, don't put 0x in front of it.  The standard address are:
2426 +         COM1 3f8 , irq 4 and COM2 2f8 irq 3.  Setserial /dev/ttySx
2427 +         will tell you what you have.  It is good to test the serial
2428 +         connection with a live system before trying to debug.
2429 +
2430 +config KGDB_IRQ
2431 +       int "IRQ of the debug serial port"
2432 +       depends on KGDB
2433 +       default 4
2434 +       help
2435 +         This is the irq for the debug port.  If everything is working
2436 +         correctly and the kernel has interrupts on a control C to the
2437 +         port should cause a break into the kernel debug stub.
2438 +
2439 +config DEBUG_INFO
2440 +       bool
2441 +       depends on KGDB
2442 +       default y
2443 +
2444 +config KGDB_MORE
2445 +       bool "Add any additional compile options"
2446 +       depends on KGDB
2447 +       default n
2448 +       help
2449 +         Saying yes here turns on the ability to enter additional
2450 +         compile options.
2451 +
2452 +
2453 +config KGDB_OPTIONS
2454 +       depends on KGDB_MORE
2455 +       string "Additional compile arguments"
2456 +       default "-O1"
2457 +       help
2458 +         This option allows you enter additional compile options for
2459 +         the whole kernel compile.  Each platform will have a default
2460 +         that seems right for it.  For example on PPC "-ggdb -O1", and
2461 +         for i386 "-O1".  Note that by configuring KGDB "-g" is already
2462 +         turned on.  In addition, on i386 platforms
2463 +         "-fomit-frame-pointer" is deleted from the standard compile
2464 +         options.
2465 +
2466 +config NO_KGDB_CPUS
2467 +       int "Number of CPUs"
2468 +       depends on KGDB && SMP
2469 +       default NR_CPUS
2470 +       help
2471 +
2472 +         This option sets the number of cpus for kgdb ONLY.  It is used
2473 +         to prune some internal structures so they look "nice" when
2474 +         displayed with gdb.  This is to overcome possibly larger
2475 +         numbers that may have been entered above.  Enter the real
2476 +         number to get nice clean kgdb_info displays.
2477 +
2478 +config KGDB_TS
2479 +       bool "Enable kgdb time stamp macros?"
2480 +       depends on KGDB
2481 +       default n
2482 +       help
2483 +         Kgdb event macros allow you to instrument your code with calls
2484 +         to the kgdb event recording function.  The event log may be
2485 +         examined with gdb at a break point.  Turning on this
2486 +         capability also allows you to choose how many events to
2487 +         keep. Kgdb always keeps the lastest events.
2488 +
2489 +choice
2490 +       depends on KGDB_TS
2491 +       prompt "Max number of time stamps to save?"
2492 +       default KGDB_TS_128
2493 +
2494 +config KGDB_TS_64
2495 +       bool "64"
2496 +
2497 +config KGDB_TS_128
2498 +       bool "128"
2499 +
2500 +config KGDB_TS_256
2501 +       bool "256"
2502 +
2503 +config KGDB_TS_512
2504 +       bool "512"
2505 +
2506 +config KGDB_TS_1024
2507 +       bool "1024"
2508 +
2509 +endchoice
2510 +
2511 +config STACK_OVERFLOW_TEST
2512 +       bool "Turn on kernel stack overflow testing?"
2513 +       depends on KGDB
2514 +       default n
2515 +       help
2516 +         This option enables code in the front line interrupt handlers
2517 +         to check for kernel stack overflow on interrupts and system
2518 +         calls.  This is part of the kgdb code on x86 systems.
2519 +
2520 +config KGDB_CONSOLE
2521 +       bool "Enable serial console thru kgdb port"
2522 +       depends on KGDB
2523 +       default n
2524 +       help
2525 +         This option enables the command line "console=kgdb" option.
2526 +         When the system is booted with this option in the command line
2527 +         all kernel printk output is sent to gdb (as well as to other
2528 +         consoles).  For this to work gdb must be connected.  For this
2529 +         reason, this command line option will generate a breakpoint if
2530 +         gdb has not yet connected.  After the gdb continue command is
2531 +         given all pent up console output will be printed by gdb on the
2532 +         host machine.  Neither this option, nor KGDB require the
2533 +         serial driver to be configured.
2534 +
2535 +config KGDB_SYSRQ
2536 +       bool "Turn on SysRq 'G' command to do a break?"
2537 +       depends on KGDB
2538 +       default y
2539 +       help
2540 +         This option includes an option in the SysRq code that allows
2541 +         you to enter SysRq G which generates a breakpoint to the KGDB
2542 +         stub.  This will work if the keyboard is alive and can
2543 +         interrupt the system.  Because of constraints on when the
2544 +         serial port interrupt can be enabled, this code may allow you
2545 +         to interrupt the system before the serial port control C is
2546 +         available.  Just say yes here.
2547 +
2548  config FRAME_POINTER
2549         bool "Compile the kernel with frame pointers"
2550 +       default KGDB
2551         help
2552           If you say Y here the resulting kernel image will be slightly larger
2553           and slower, but it will give very useful debugging information.
2554           If you don't debug the kernel, you can say N, but we may not be able
2555           to solve problems without frame pointers.
2556  
2557 +config MAGIC_SYSRQ
2558 +       bool
2559 +       depends on KGDB_SYSRQ
2560 +       default y
2561 +
2562  config X86_EXTRA_IRQS
2563         bool
2564         depends on X86_LOCAL_APIC || X86_VOYAGER
2565 @@ -1303,3 +1568,8 @@ config X86_TRAMPOLINE
2566         bool
2567         depends on SMP || X86_VISWS
2568         default y
2569 +
2570 +config PC
2571 +       bool
2572 +       depends on X86 && !EMBEDDED
2573 +       default y
2574 --- linux-2.6.0-test6/arch/i386/kernel/acpi/boot.c      2003-09-08 13:58:55.000000000 -0700
2575 +++ 25/arch/i386/kernel/acpi/boot.c     2003-10-05 00:36:22.000000000 -0700
2576 @@ -26,6 +26,7 @@
2577  #include <linux/init.h>
2578  #include <linux/config.h>
2579  #include <linux/acpi.h>
2580 +#include <linux/efi.h>
2581  #include <asm/pgalloc.h>
2582  #include <asm/io_apic.h>
2583  #include <asm/apic.h>
2584 @@ -183,8 +184,7 @@ acpi_parse_lapic_nmi (
2585  
2586  #endif /*CONFIG_X86_LOCAL_APIC*/
2587  
2588 -#ifdef CONFIG_X86_IO_APIC
2589 -
2590 +#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
2591  
2592  static int __init
2593  acpi_parse_ioapic (
2594 @@ -297,6 +297,10 @@ acpi_find_rsdp (void)
2595  {
2596         unsigned long           rsdp_phys = 0;
2597  
2598 +       if (efi.acpi20)
2599 +               return __pa(efi.acpi20);
2600 +       else if (efi.acpi)
2601 +               return __pa(efi.acpi);
2602         /*
2603          * Scan memory looking for the RSDP signature. First search EBDA (low
2604          * memory) paragraphs and then search upper memory (E0000-FFFFF).
2605 @@ -368,7 +372,6 @@ acpi_boot_init (void)
2606  
2607         result = acpi_table_parse(ACPI_APIC, acpi_parse_madt);
2608         if (!result) {
2609 -               printk(KERN_WARNING PREFIX "MADT not present\n");
2610                 return 0;
2611         }
2612         else if (result < 0) {
2613 @@ -416,7 +419,7 @@ acpi_boot_init (void)
2614  
2615  #endif /*CONFIG_X86_LOCAL_APIC*/
2616  
2617 -#ifdef CONFIG_X86_IO_APIC
2618 +#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
2619  
2620         /* 
2621          * I/O APIC 
2622 @@ -472,7 +475,8 @@ acpi_boot_init (void)
2623         acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
2624  
2625         acpi_ioapic = 1;
2626 -#endif /*CONFIG_X86_IO_APIC*/
2627 +
2628 +#endif /* CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER */
2629  
2630  #ifdef CONFIG_X86_LOCAL_APIC
2631         if (acpi_lapic && acpi_ioapic) {
2632 @@ -480,6 +484,7 @@ acpi_boot_init (void)
2633                 clustered_apic_check();
2634         }
2635  #endif
2636 +
2637  #ifdef CONFIG_HPET_TIMER
2638         acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
2639  #endif
2640 --- linux-2.6.0-test6/arch/i386/kernel/asm-offsets.c    2003-06-14 12:18:07.000000000 -0700
2641 +++ 25/arch/i386/kernel/asm-offsets.c   2003-10-05 00:36:48.000000000 -0700
2642 @@ -4,9 +4,11 @@
2643   * to extract and format the required data.
2644   */
2645  
2646 +#include <linux/sched.h>
2647  #include <linux/signal.h>
2648  #include <asm/ucontext.h>
2649  #include "sigframe.h"
2650 +#include <asm/fixmap.h>
2651  
2652  #define DEFINE(sym, val) \
2653          asm volatile("\n->" #sym " %0 " #val : : "i" (val))
2654 @@ -28,4 +30,17 @@ void foo(void)
2655  
2656         DEFINE(RT_SIGFRAME_sigcontext,
2657                offsetof (struct rt_sigframe, uc.uc_mcontext));
2658 +       DEFINE(TI_task, offsetof (struct thread_info, task));
2659 +       DEFINE(TI_exec_domain, offsetof (struct thread_info, exec_domain));
2660 +       DEFINE(TI_flags, offsetof (struct thread_info, flags));
2661 +       DEFINE(TI_preempt_count, offsetof (struct thread_info, preempt_count));
2662 +       DEFINE(TI_addr_limit, offsetof (struct thread_info, addr_limit));
2663 +       DEFINE(TI_real_stack, offsetof (struct thread_info, real_stack));
2664 +       DEFINE(TI_virtual_stack, offsetof (struct thread_info, virtual_stack));
2665 +       DEFINE(TI_user_pgd, offsetof (struct thread_info, user_pgd));
2666 +
2667 +       DEFINE(FIX_ENTRY_TRAMPOLINE_0_addr, __fix_to_virt(FIX_ENTRY_TRAMPOLINE_0));
2668 +       DEFINE(FIX_VSYSCALL_addr, __fix_to_virt(FIX_VSYSCALL));
2669 +       DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
2670 +       DEFINE(task_thread_db7, offsetof (struct task_struct, thread.debugreg[7]));
2671  }
2672 --- linux-2.6.0-test6/arch/i386/kernel/cpu/common.c     2003-09-27 18:57:43.000000000 -0700
2673 +++ 25/arch/i386/kernel/cpu/common.c    2003-10-05 00:36:48.000000000 -0700
2674 @@ -510,16 +510,20 @@ void __init cpu_init (void)
2675                 BUG();
2676         enter_lazy_tlb(&init_mm, current);
2677  
2678 -       load_esp0(t, thread->esp0);
2679 -       set_tss_desc(cpu,t);
2680 +       t->esp0 = thread->esp0;
2681 +       set_tss_desc(cpu, t);
2682         cpu_gdt_table[cpu][GDT_ENTRY_TSS].b &= 0xfffffdff;
2683         load_TR_desc();
2684 -       load_LDT(&init_mm.context);
2685 +       if (cpu)
2686 +               load_LDT(&init_mm.context);
2687  
2688         /* Set up doublefault TSS pointer in the GDT */
2689         __set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss);
2690         cpu_gdt_table[cpu][GDT_ENTRY_DOUBLEFAULT_TSS].b &= 0xfffffdff;
2691  
2692 +       if (cpu)
2693 +               trap_init_virtual_GDT();
2694 +
2695         /* Clear %fs and %gs. */
2696         asm volatile ("xorl %eax, %eax; movl %eax, %fs; movl %eax, %gs");
2697  
2698 --- linux-2.6.0-test6/arch/i386/kernel/cpu/cpufreq/acpi.c       2003-09-27 18:57:43.000000000 -0700
2699 +++ 25/arch/i386/kernel/cpu/cpufreq/acpi.c      2003-10-05 00:33:23.000000000 -0700
2700 @@ -231,7 +231,7 @@ acpi_processor_set_performance (
2701         int                     state)
2702  {
2703         u16                     port = 0;
2704 -       u8                      value = 0;
2705 +       u16                     value = 0;
2706         int                     i = 0;
2707         struct cpufreq_freqs    cpufreq_freqs;
2708  
2709 @@ -282,9 +282,9 @@ acpi_processor_set_performance (
2710         value = (u16) perf->states[state].control;
2711  
2712         ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
2713 -               "Writing 0x%02x to port 0x%04x\n", value, port));
2714 +               "Writing 0x%04x to port 0x%04x\n", value, port));
2715  
2716 -       outb(value, port); 
2717 +       outw(value, port); 
2718  
2719         /*
2720          * Then we read the 'status_register' and compare the value with the
2721 @@ -296,12 +296,12 @@ acpi_processor_set_performance (
2722         port = perf->status_register;
2723  
2724         ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
2725 -               "Looking for 0x%02x from port 0x%04x\n",
2726 -               (u8) perf->states[state].status, port));
2727 +               "Looking for 0x%04x from port 0x%04x\n",
2728 +               (u16) perf->states[state].status, port));
2729  
2730         for (i=0; i<100; i++) {
2731 -               value = inb(port);
2732 -               if (value == (u8) perf->states[state].status)
2733 +               value = inw(port);
2734 +               if (value == (u16) perf->states[state].status)
2735                         break;
2736                 udelay(10);
2737         }
2738 @@ -309,7 +309,7 @@ acpi_processor_set_performance (
2739         /* notify cpufreq */
2740         cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE);
2741  
2742 -       if (value != perf->states[state].status) {
2743 +       if (value != (u16) perf->states[state].status) {
2744                 unsigned int tmp = cpufreq_freqs.new;
2745                 cpufreq_freqs.new = cpufreq_freqs.old;
2746                 cpufreq_freqs.old = tmp;
2747 --- linux-2.6.0-test6/arch/i386/kernel/cpu/cpufreq/Kconfig      2003-09-27 18:57:43.000000000 -0700
2748 +++ 25/arch/i386/kernel/cpu/cpufreq/Kconfig     2003-10-05 00:33:23.000000000 -0700
2749 @@ -88,6 +88,16 @@ config X86_POWERNOW_K7
2750  
2751           If in doubt, say N.
2752  
2753 +config X86_POWERNOW_K8
2754 +       tristate "AMD Opteron/Athlon64 PowerNow!"
2755 +       depends on CPU_FREQ_TABLE
2756 +       help
2757 +         This adds the CPUFreq driver for mobile AMD Opteron/Athlon64 processors.
2758 +
2759 +         For details, take a look at linux/Documentation/cpu-freq. 
2760 +
2761 +         If in doubt, say N.
2762 +
2763  config X86_GX_SUSPMOD
2764         tristate "Cyrix MediaGX/NatSemi Geode Suspend Modulation"
2765         depends on CPU_FREQ
2766 --- linux-2.6.0-test6/arch/i386/kernel/cpu/cpufreq/longhaul.c   2003-09-08 13:58:55.000000000 -0700
2767 +++ 25/arch/i386/kernel/cpu/cpufreq/longhaul.c  2003-10-05 00:33:23.000000000 -0700
2768 @@ -70,21 +70,6 @@ static unsigned int calc_speed (int mult
2769  }
2770  
2771  
2772 -static unsigned int longhaul_get_cpu_fsb (void)
2773 -{
2774 -       unsigned long lo, hi;
2775 -       unsigned int eblcr_fsb_table[] = { 66, 133, 100, -1 };
2776 -       unsigned int invalue=0;
2777 -
2778 -       if (fsb == 0) {
2779 -               rdmsr (MSR_IA32_EBL_CR_POWERON, lo, hi);
2780 -               invalue = (lo & (1<<18|1<<19)) >>18;
2781 -               fsb = eblcr_fsb_table[invalue];
2782 -       }
2783 -       return fsb;
2784 -}
2785 -
2786 -
2787  static int longhaul_get_cpu_mult (void)
2788  {
2789         unsigned long invalue=0,lo, hi;
2790 @@ -168,7 +153,7 @@ static void longhaul_setstate (unsigned 
2791                 break;
2792  
2793         /*
2794 -        * Longhaul v3. (Ezra-T [C5M], Nehemiag [C5N])
2795 +        * Longhaul v3. (Ezra-T [C5M], Nehemiah [C5N])
2796          * This can also do voltage scaling, but see above.
2797          * Ezra-T was alleged to do FSB scaling too, but it never worked in practice.
2798          */
2799 @@ -193,6 +178,39 @@ static void longhaul_setstate (unsigned 
2800         cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
2801  }
2802  
2803 +/*
2804 + * Centaur decided to make life a little more tricky.
2805 + * Only longhaul v1 is allowed to read EBLCR BSEL[0:1].
2806 + * Samuel2 and above have to try and guess what the FSB is.
2807 + * We do this by assuming we booted at maximum multiplier, and interpolate
2808 + * between that value multiplied by possible FSBs and cpu_mhz which
2809 + * was calculated at boot time. Really ugly, but no other way to do this.
2810 + */
2811 +static int _guess (int guess, int maxmult)
2812 +{
2813 +       int target;
2814 +
2815 +       target = ((maxmult/10)*guess);
2816 +       if (maxmult%10 != 0)
2817 +               target += (guess/2);
2818 +       target &= ~0xf;
2819 +       return target;
2820 +}
2821 +
2822 +static int guess_fsb(int maxmult)
2823 +{
2824 +       int speed = (cpu_khz/1000) & ~0xf;
2825 +       int i;
2826 +       int speeds[3] = { 66, 100, 133 };
2827 +
2828 +       for (i=0; i<3; i++) {
2829 +               if (_guess(speeds[i],maxmult) == speed)
2830 +                       return speeds[i];
2831 +       }
2832 +       return 0;
2833 +}
2834 +
2835 +
2836  
2837  static int __init longhaul_get_ranges (void)
2838  {
2839 @@ -203,8 +221,8 @@ static int __init longhaul_get_ranges (v
2840                 -1,110,120,-1,135,115,125,105,130,150,160,140,-1,155,-1,145 };
2841         unsigned int j, k = 0;
2842         union msr_longhaul longhaul;
2843 -
2844 -       fsb = longhaul_get_cpu_fsb();
2845 +       unsigned long lo, hi;
2846 +       unsigned int eblcr_fsb_table[] = { 66, 133, 100, -1 };
2847  
2848         switch (longhaul_version) {
2849         case 1:
2850 @@ -212,6 +230,9 @@ static int __init longhaul_get_ranges (v
2851                    Assume min=3.0x & max = whatever we booted at. */
2852                 minmult = 30;
2853                 maxmult = longhaul_get_cpu_mult();
2854 +               rdmsr (MSR_IA32_EBL_CR_POWERON, lo, hi);
2855 +               invalue = (lo & (1<<18|1<<19)) >>18;
2856 +               fsb = eblcr_fsb_table[invalue];
2857                 break;
2858  
2859         case 2 ... 3:
2860 @@ -222,14 +243,13 @@ static int __init longhaul_get_ranges (v
2861                         invalue += 16;
2862                 maxmult=multipliers[invalue];
2863  
2864 -#if 0
2865                 invalue = longhaul.bits.MinMHzBR;
2866 -               if (longhaul.bits.MinMHzBR4);
2867 -                       invalue += 16;
2868 -               minmult = multipliers[invalue];
2869 -#else
2870 -               minmult = 30; /* as per spec */
2871 -#endif
2872 +               if (longhaul.bits.MinMHzBR4 == 1)
2873 +                       minmult = 30;
2874 +               else
2875 +                       minmult = multipliers[invalue];
2876 +
2877 +               fsb = guess_fsb(maxmult);
2878                 break;
2879         }
2880  
2881 --- linux-2.6.0-test6/arch/i386/kernel/cpu/cpufreq/Makefile     2003-09-27 18:57:43.000000000 -0700
2882 +++ 25/arch/i386/kernel/cpu/cpufreq/Makefile    2003-10-05 00:33:23.000000000 -0700
2883 @@ -1,5 +1,6 @@
2884  obj-$(CONFIG_X86_POWERNOW_K6)  += powernow-k6.o
2885  obj-$(CONFIG_X86_POWERNOW_K7)  += powernow-k7.o
2886 +obj-$(CONFIG_X86_POWERNOW_K8)  += powernow-k8.o
2887  obj-$(CONFIG_X86_LONGHAUL)     += longhaul.o
2888  obj-$(CONFIG_X86_P4_CLOCKMOD)  += p4-clockmod.o
2889  obj-$(CONFIG_ELAN_CPUFREQ)     += elanfreq.o
2890 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
2891 +++ 25/arch/i386/kernel/cpu/cpufreq/powernow-k8.c       2003-10-05 00:33:23.000000000 -0700
2892 @@ -0,0 +1,1020 @@
2893 +/*
2894 + *   (c) 2003 Advanced Micro Devices, Inc.
2895 + *  Your use of this code is subject to the terms and conditions of the
2896 + *  GNU general public license version 2. See "../../../COPYING" or
2897 + *  http://www.gnu.org/licenses/gpl.html
2898 + *
2899 + *  Support : paul.devriendt@amd.com
2900 + *
2901 + *  Based on the powernow-k7.c module written by Dave Jones.
2902 + *  (C) 2003 Dave Jones <davej@codemonkey.ork.uk> on behalf of SuSE Labs
2903 + *  Licensed under the terms of the GNU GPL License version 2.
2904 + *  Based upon datasheets & sample CPUs kindly provided by AMD.
2905 + *
2906 + *  Processor information obtained from Chapter 9 (Power and Thermal Management)
2907 + *  of the "BIOS and Kernel Developer's Guide for the AMD Athlon 64 and AMD
2908 + *  Opteron Processors", revision 3.03, available for download from www.amd.com
2909 + *
2910 + */
2911 +
2912 +#include <linux/kernel.h>
2913 +#include <linux/smp.h>
2914 +#include <linux/module.h>
2915 +#include <linux/init.h>
2916 +#include <linux/cpufreq.h>
2917 +#include <linux/slab.h>
2918 +#include <linux/string.h>
2919 +
2920 +#include <asm/msr.h>
2921 +#include <asm/io.h>
2922 +#include <asm/delay.h>
2923 +
2924 +#define PFX "powernow-k8: "
2925 +#define BFX PFX "BIOS error: "
2926 +#define VERSION "version 1.00.08 - September 26, 2003"
2927 +#include "powernow-k8.h"
2928 +
2929 +#ifdef CONFIG_PREEMPT
2930 +#warning this driver has not been tested on a preempt system
2931 +#endif
2932 +
2933 +static u32 vstable;    /* voltage stabalization time, from PSB, units 20 us */
2934 +static u32 plllock;    /* pll lock time, from PSB, units 1 us */
2935 +static u32 numps;      /* number of p-states, from PSB */
2936 +static u32 rvo;                /* ramp voltage offset, from PSB */
2937 +static u32 irt;                /* isochronous relief time, from PSB */
2938 +static u32 vidmvs;     /* usable value calculated from mvs, from PSB */
2939 +struct pst_s *ppst;    /* array of p states, valid for this part */
2940 +static u32 currvid;    /* keep track of the current fid / vid */
2941 +static u32 currfid;
2942 +
2943 +/*
2944 +The PSB table supplied by BIOS allows for the definition of the number of
2945 +p-states that can be used when running on a/c, and the number of p-states
2946 +that can be used when running on battery. This allows laptop manufacturers
2947 +to force the system to save power when running from battery. The relationship 
2948 +is :
2949 +   1 <= number_of_battery_p_states <= maximum_number_of_p_states
2950 +
2951 +This driver does NOT have the support in it to detect transitions from
2952 +a/c power to battery power, and thus trigger the transition to a lower
2953 +p-state if required. This is because I need ACPI and the 2.6 kernel to do 
2954 +this, and this is a 2.4 kernel driver. Check back for a new improved driver
2955 +for the 2.6 kernel soon.
2956 +
2957 +This code therefore assumes it is on battery at all times, and thus
2958 +restricts performance to number_of_battery_p_states. For desktops, 
2959 +  number_of_battery_p_states == maximum_number_of_pstates, 
2960 +so this is not actually a restriction.
2961 +*/
2962 +
2963 +static u32 batps;      /* limit on the number of p states when on battery */
2964 +                       /* - set by BIOS in the PSB/PST                    */
2965 +
2966 +static struct cpufreq_driver cpufreq_amd64_driver = {
2967 +       .verify = drv_verify,
2968 +       .target = drv_target,
2969 +       .init = drv_cpu_init,
2970 +       .name = "cpufreq-amd64",
2971 +       .owner = THIS_MODULE,
2972 +};
2973 +
2974 +#define SEARCH_UP     1
2975 +#define SEARCH_DOWN   0
2976 +
2977 +/* Return a frequency in MHz, given an input fid */
2978 +u32
2979 +find_freq_from_fid(u32 fid)
2980 +{
2981 +       return 800 + (fid * 100);
2982 +}
2983 +
2984 +/* Return a fid matching an input frequency in MHz */
2985 +u32
2986 +find_fid_from_freq(u32 freq)
2987 +{
2988 +       return (freq - 800) / 100;
2989 +}
2990 +
2991 +/* Return the vco fid for an input fid */
2992 +static u32
2993 +convert_fid_to_vco_fid(u32 fid)
2994 +{
2995 +       if (fid < HI_FID_TABLE_BOTTOM) {
2996 +               return 8 + (2 * fid);
2997 +       } else {
2998 +               return fid;
2999 +       }
3000 +}
3001 +
3002 +/* Sort the fid/vid frequency table into ascending order by fid. The spec */
3003 +/* implies that it will be sorted by BIOS, but, it only implies it, and I */
3004 +/* prefer not to trust when I can check.                                  */
3005 +/* Yes, it is a simple bubble sort, but the PST is really small, so the   */
3006 +/* choice of algorithm is pretty irrelevant.                              */
3007 +static inline void
3008 +sort_pst(struct pst_s *ppst, u32 numpstates)
3009 +{
3010 +       u32 i;
3011 +       u8 tempfid;
3012 +       u8 tempvid;
3013 +       int swaps = 1;
3014 +
3015 +       while (swaps) {
3016 +               swaps = 0;
3017 +               for (i = 0; i < (numpstates - 1); i++) {
3018 +                       if (ppst[i].fid > ppst[i + 1].fid) {
3019 +                               swaps = 1;
3020 +                               tempfid = ppst[i].fid;
3021 +                               tempvid = ppst[i].vid;
3022 +                               ppst[i].fid = ppst[i + 1].fid;
3023 +                               ppst[i].vid = ppst[i + 1].vid;
3024 +                               ppst[i + 1].fid = tempfid;
3025 +                               ppst[i + 1].vid = tempvid;
3026 +                       }
3027 +               }
3028 +       }
3029 +
3030 +       return;
3031 +}
3032 +
3033 +/* Return 1 if the pending bit is set. Unless we are actually just told the */
3034 +/* processor to transition a state, seeing this bit set is really bad news. */
3035 +static inline int
3036 +pending_bit_stuck(void)
3037 +{
3038 +       u32 lo;
3039 +       u32 hi;
3040 +
3041 +       rdmsr(MSR_FIDVID_STATUS, lo, hi);
3042 +       return lo & MSR_S_LO_CHANGE_PENDING ? 1 : 0;
3043 +}
3044 +
3045 +/* Update the global current fid / vid values from the status msr. Returns 1 */
3046 +/* on error.                                                                 */
3047 +static int
3048 +query_current_values_with_pending_wait(void)
3049 +{
3050 +       u32 lo;
3051 +       u32 hi;
3052 +       u32 i = 0;
3053 +
3054 +       lo = MSR_S_LO_CHANGE_PENDING;
3055 +       while (lo & MSR_S_LO_CHANGE_PENDING) {
3056 +               if (i++ > 0x1000000) {
3057 +                       printk(KERN_ERR PFX "detected change pending stuck\n");
3058 +                       return 1;
3059 +               }
3060 +               rdmsr(MSR_FIDVID_STATUS, lo, hi);
3061 +       }
3062 +
3063 +       currvid = hi & MSR_S_HI_CURRENT_VID;
3064 +       currfid = lo & MSR_S_LO_CURRENT_FID;
3065 +
3066 +       return 0;
3067 +}
3068 +
3069 +/* the isochronous relief time */
3070 +static inline void
3071 +count_off_irt(void)
3072 +{
3073 +       udelay((1 << irt) * 10);
3074 +       return;
3075 +}
3076 +
3077 +/* the voltage stabalization time */
3078 +static inline void
3079 +count_off_vst(void)
3080 +{
3081 +       udelay(vstable * VST_UNITS_20US);
3082 +       return;
3083 +}
3084 +
3085 +/* write the new fid value along with the other control fields to the msr */
3086 +static int
3087 +write_new_fid(u32 fid)
3088 +{
3089 +       u32 lo;
3090 +       u32 savevid = currvid;
3091 +
3092 +       if ((fid & INVALID_FID_MASK) || (currvid & INVALID_VID_MASK)) {
3093 +               printk(KERN_ERR PFX "internal error - overflow on fid write\n");
3094 +               return 1;
3095 +       }
3096 +
3097 +       lo = fid | (currvid << MSR_C_LO_VID_SHIFT) | MSR_C_LO_INIT_FID_VID;
3098 +
3099 +       dprintk(KERN_DEBUG PFX "writing fid %x, lo %x, hi %x\n",
3100 +               fid, lo, plllock * PLL_LOCK_CONVERSION);
3101 +
3102 +       wrmsr(MSR_FIDVID_CTL, lo, plllock * PLL_LOCK_CONVERSION);
3103 +
3104 +       if (query_current_values_with_pending_wait())
3105 +               return 1;
3106 +
3107 +       count_off_irt();
3108 +
3109 +       if (savevid != currvid) {
3110 +               printk(KERN_ERR PFX
3111 +                      "vid changed on fid transition, save %x, currvid %x\n",
3112 +                      savevid, currvid);
3113 +               return 1;
3114 +       }
3115 +
3116 +       if (fid != currfid) {
3117 +               printk(KERN_ERR PFX
3118 +                      "fid transition failed, fid %x, currfid %x\n",
3119 +                       fid, currfid);
3120 +               return 1;
3121 +       }
3122 +
3123 +       return 0;
3124 +}
3125 +
3126 +/* Write a new vid to the hardware */
3127 +static int
3128 +write_new_vid(u32 vid)
3129 +{
3130 +       u32 lo;
3131 +       u32 savefid = currfid;
3132 +
3133 +       if ((currfid & INVALID_FID_MASK) || (vid & INVALID_VID_MASK)) {
3134 +               printk(KERN_ERR PFX "internal error - overflow on vid write\n");
3135 +               return 1;
3136 +       }
3137 +
3138 +       lo = currfid | (vid << MSR_C_LO_VID_SHIFT) | MSR_C_LO_INIT_FID_VID;
3139 +
3140 +       dprintk(KERN_DEBUG PFX "writing vid %x, lo %x, hi %x\n",
3141 +               vid, lo, STOP_GRANT_5NS);
3142 +
3143 +       wrmsr(MSR_FIDVID_CTL, lo, STOP_GRANT_5NS);
3144 +
3145 +       if (query_current_values_with_pending_wait()) {
3146 +               return 1;
3147 +       }
3148 +
3149 +       if (savefid != currfid) {
3150 +               printk(KERN_ERR PFX
3151 +                      "fid changed on vid transition, save %x currfid %x\n",
3152 +                      savefid, currfid);
3153 +               return 1;
3154 +       }
3155 +
3156 +       if (vid != currvid) {
3157 +               printk(KERN_ERR PFX
3158 +                      "vid transition failed, vid %x, currvid %x\n",
3159 +                      vid, currvid);
3160 +               return 1;
3161 +       }
3162 +
3163 +       return 0;
3164 +}
3165 +
3166 +/* Reduce the vid by the max of step or reqvid.                   */
3167 +/* Decreasing vid codes represent increasing voltages :           */
3168 +/* vid of 0 is 1.550V, vid of 0x1e is 0.800V, vid of 0x1f is off. */
3169 +static int
3170 +decrease_vid_code_by_step(u32 reqvid, u32 step)
3171 +{
3172 +       if ((currvid - reqvid) > step)
3173 +               reqvid = currvid - step;
3174 +
3175 +       if (write_new_vid(reqvid))
3176 +               return 1;
3177 +
3178 +       count_off_vst();
3179 +
3180 +       return 0;
3181 +}
3182 +
3183 +/* Change the fid and vid, by the 3 phases. */
3184 +static inline int
3185 +transition_fid_vid(u32 reqfid, u32 reqvid)
3186 +{
3187 +       if (core_voltage_pre_transition(reqvid))
3188 +               return 1;
3189 +
3190 +       if (core_frequency_transition(reqfid))
3191 +               return 1;
3192 +
3193 +       if (core_voltage_post_transition(reqvid))
3194 +               return 1;
3195 +
3196 +       if (query_current_values_with_pending_wait())
3197 +               return 1;
3198 +
3199 +       if ((reqfid != currfid) || (reqvid != currvid)) {
3200 +               printk(KERN_ERR PFX "failed: req 0x%x 0x%x, curr 0x%x 0x%x\n",
3201 +                      reqfid, reqvid, currfid, currvid);
3202 +               return 1;
3203 +       }
3204 +
3205 +       dprintk(KERN_INFO PFX
3206 +               "transitioned: new fid 0x%x, vid 0x%x\n", currfid, currvid);
3207 +
3208 +       return 0;
3209 +}
3210 +
3211 +/* Phase 1 - core voltage transition ... setup appropriate voltage for the */
3212 +/* fid transition.                                                         */
3213 +static inline int
3214 +core_voltage_pre_transition(u32 reqvid)
3215 +{
3216 +       u32 rvosteps = rvo;
3217 +       u32 savefid = currfid;
3218 +
3219 +       dprintk(KERN_DEBUG PFX
3220 +               "ph1: start, currfid 0x%x, currvid 0x%x, reqvid 0x%x, rvo %x\n",
3221 +               currfid, currvid, reqvid, rvo);
3222 +
3223 +       while (currvid > reqvid) {
3224 +               dprintk(KERN_DEBUG PFX "ph1: curr 0x%x, requesting vid 0x%x\n",
3225 +                       currvid, reqvid);
3226 +               if (decrease_vid_code_by_step(reqvid, vidmvs))
3227 +                       return 1;
3228 +       }
3229 +
3230 +       while (rvosteps > 0) {
3231 +               if (currvid == 0) {
3232 +                       rvosteps = 0;
3233 +               } else {
3234 +                       dprintk(KERN_DEBUG PFX
3235 +                               "ph1: changing vid for rvo, requesting 0x%x\n",
3236 +                               currvid - 1);
3237 +                       if (decrease_vid_code_by_step(currvid - 1, 1))
3238 +                               return 1;
3239 +                       rvosteps--;
3240 +               }
3241 +       }
3242 +
3243 +       if (query_current_values_with_pending_wait())
3244 +               return 1;
3245 +
3246 +       if (savefid != currfid) {
3247 +               printk(KERN_ERR PFX "ph1 err, currfid changed 0x%x\n", currfid);
3248 +               return 1;
3249 +       }
3250 +
3251 +       dprintk(KERN_DEBUG PFX "ph1 complete, currfid 0x%x, currvid 0x%x\n",
3252 +               currfid, currvid);
3253 +
3254 +       return 0;
3255 +}
3256 +
3257 +/* Phase 2 - core frequency transition */
3258 +static inline int
3259 +core_frequency_transition(u32 reqfid)
3260 +{
3261 +       u32 vcoreqfid;
3262 +       u32 vcocurrfid;
3263 +       u32 vcofiddiff;
3264 +       u32 savevid = currvid;
3265 +
3266 +       if ((reqfid < HI_FID_TABLE_BOTTOM) && (currfid < HI_FID_TABLE_BOTTOM)) {
3267 +               printk(KERN_ERR PFX "ph2 illegal lo-lo transition 0x%x 0x%x\n",
3268 +                      reqfid, currfid);
3269 +               return 1;
3270 +       }
3271 +
3272 +       if (currfid == reqfid) {
3273 +               printk(KERN_ERR PFX "ph2 null fid transition 0x%x\n", currfid);
3274 +               return 0;
3275 +       }
3276 +
3277 +       dprintk(KERN_DEBUG PFX
3278 +               "ph2 starting, currfid 0x%x, currvid 0x%x, reqfid 0x%x\n",
3279 +               currfid, currvid, reqfid);
3280 +
3281 +       vcoreqfid = convert_fid_to_vco_fid(reqfid);
3282 +       vcocurrfid = convert_fid_to_vco_fid(currfid);
3283 +       vcofiddiff = vcocurrfid > vcoreqfid ? vcocurrfid - vcoreqfid
3284 +           : vcoreqfid - vcocurrfid;
3285 +
3286 +       while (vcofiddiff > 2) {
3287 +               if (reqfid > currfid) {
3288 +                       if (currfid > LO_FID_TABLE_TOP) {
3289 +                               if (write_new_fid(currfid + 2)) {
3290 +                                       return 1;
3291 +                               }
3292 +                       } else {
3293 +                               if (write_new_fid
3294 +                                   (2 + convert_fid_to_vco_fid(currfid))) {
3295 +                                       return 1;
3296 +                               }
3297 +                       }
3298 +               } else {
3299 +                       if (write_new_fid(currfid - 2))
3300 +                               return 1;
3301 +               }
3302 +
3303 +               vcocurrfid = convert_fid_to_vco_fid(currfid);
3304 +               vcofiddiff = vcocurrfid > vcoreqfid ? vcocurrfid - vcoreqfid
3305 +                   : vcoreqfid - vcocurrfid;
3306 +       }
3307 +
3308 +       if (write_new_fid(reqfid))
3309 +               return 1;
3310 +
3311 +       if (query_current_values_with_pending_wait())
3312 +               return 1;
3313 +
3314 +       if (currfid != reqfid) {
3315 +               printk(KERN_ERR PFX
3316 +                      "ph2 mismatch, failed fid transition, curr %x, req %x\n",
3317 +                      currfid, reqfid);
3318 +               return 1;
3319 +       }
3320 +
3321 +       if (savevid != currvid) {
3322 +               printk(KERN_ERR PFX
3323 +                      "ph2 vid changed, save %x, curr %x\n", savevid,
3324 +                      currvid);
3325 +               return 1;
3326 +       }
3327 +
3328 +       dprintk(KERN_DEBUG PFX "ph2 complete, currfid 0x%x, currvid 0x%x\n",
3329 +               currfid, currvid);
3330 +
3331 +       return 0;
3332 +}
3333 +
3334 +/* Phase 3 - core voltage transition flow ... jump to the final vid. */
3335 +static inline int
3336 +core_voltage_post_transition(u32 reqvid)
3337 +{
3338 +       u32 savefid = currfid;
3339 +       u32 savereqvid = reqvid;
3340 +
3341 +       dprintk(KERN_DEBUG PFX "ph3 starting, currfid 0x%x, currvid 0x%x\n",
3342 +               currfid, currvid);
3343 +
3344 +       if (reqvid != currvid) {
3345 +               if (write_new_vid(reqvid))
3346 +                       return 1;
3347 +
3348 +               if (savefid != currfid) {
3349 +                       printk(KERN_ERR PFX
3350 +                              "ph3: bad fid change, save %x, curr %x\n",
3351 +                              savefid, currfid);
3352 +                       return 1;
3353 +               }
3354 +
3355 +               if (currvid != reqvid) {
3356 +                       printk(KERN_ERR PFX
3357 +                              "ph3: failed vid transition\n, req %x, curr %x",
3358 +                              reqvid, currvid);
3359 +                       return 1;
3360 +               }
3361 +       }
3362 +
3363 +       if (query_current_values_with_pending_wait())
3364 +               return 1;
3365 +
3366 +       if (savereqvid != currvid) {
3367 +               dprintk(KERN_ERR PFX "ph3 failed, currvid 0x%x\n", currvid);
3368 +               return 1;
3369 +       }
3370 +
3371 +       if (savefid != currfid) {
3372 +               dprintk(KERN_ERR PFX "ph3 failed, currfid changed 0x%x\n",
3373 +                       currfid);
3374 +               return 1;
3375 +       }
3376 +
3377 +       dprintk(KERN_DEBUG PFX "ph3 complete, currfid 0x%x, currvid 0x%x\n",
3378 +               currfid, currvid);
3379 +
3380 +       return 0;
3381 +}
3382 +
3383 +static inline int
3384 +check_supported_cpu(void)
3385 +{
3386 +       struct cpuinfo_x86 *c = cpu_data;
3387 +       u32 eax, ebx, ecx, edx;
3388 +
3389 +       if (num_online_cpus() != 1) {
3390 +               printk(KERN_INFO PFX "multiprocessor systems not supported\n");
3391 +               return 0;
3392 +       }
3393 +
3394 +       if (c->x86_vendor != X86_VENDOR_AMD) {
3395 +               printk(KERN_INFO PFX "Not an AMD processor\n");
3396 +               return 0;
3397 +       }
3398 +
3399 +       eax = cpuid_eax(CPUID_PROCESSOR_SIGNATURE);
3400 +       if ((eax & CPUID_XFAM_MOD) == ATHLON64_XFAM_MOD) {
3401 +               dprintk(KERN_DEBUG PFX "AMD Althon 64 Processor found\n");
3402 +               if ((eax & CPUID_F1_STEP) < ATHLON64_REV_C0) {
3403 +                       printk(KERN_INFO PFX "Revision C0 or better "
3404 +                              "AMD Athlon 64 processor required\n");
3405 +                       return 0;
3406 +               }
3407 +       } else if ((eax & CPUID_XFAM_MOD) == OPTERON_XFAM_MOD) {
3408 +               dprintk(KERN_DEBUG PFX "AMD Opteron Processor found\n");
3409 +       } else {
3410 +               printk(KERN_INFO PFX
3411 +                      "AMD Athlon 64 or AMD Opteron processor required\n");
3412 +               return 0;
3413 +       }
3414 +
3415 +       eax = cpuid_eax(CPUID_GET_MAX_CAPABILITIES);
3416 +       if (eax < CPUID_FREQ_VOLT_CAPABILITIES) {
3417 +               printk(KERN_INFO PFX
3418 +                      "No frequency change capabilities detected\n");
3419 +               return 0;
3420 +       }
3421 +
3422 +       cpuid(CPUID_FREQ_VOLT_CAPABILITIES, &eax, &ebx, &ecx, &edx);
3423 +       if ((edx & P_STATE_TRANSITION_CAPABLE) != P_STATE_TRANSITION_CAPABLE) {
3424 +               printk(KERN_INFO PFX "Power state transitions not supported\n");
3425 +               return 0;
3426 +       }
3427 +
3428 +       printk(KERN_INFO PFX "Found AMD Athlon 64 / Opteron processor "
3429 +              "supporting p-state transitions\n");
3430 +
3431 +       return 1;
3432 +}
3433 +
3434 +/* Find and validate the PSB/PST table in BIOS. */
3435 +static inline int
3436 +find_psb_table(void)
3437 +{
3438 +       struct psb_s *psb;
3439 +       struct pst_s *pst;
3440 +       unsigned i, j;
3441 +       u32 lastfid;
3442 +       u32 mvs;
3443 +       u8 maxvid;
3444 +
3445 +       for (i = 0xc0000; i < 0xffff0; i += 0x10) {
3446 +               /* Scan BIOS looking for the signature. */
3447 +               /* It can not be at ffff0 - it is too big. */
3448 +
3449 +               psb = phys_to_virt(i);
3450 +               if (memcmp(psb, PSB_ID_STRING, PSB_ID_STRING_LEN) != 0)
3451 +                       continue;
3452 +
3453 +               dprintk(KERN_DEBUG PFX "found PSB header at 0x%p\n", psb);
3454 +
3455 +               dprintk(KERN_DEBUG PFX "table vers: 0x%x\n", psb->tableversion);
3456 +               if (psb->tableversion != PSB_VERSION_1_4) {
3457 +                       printk(KERN_INFO BFX "PSB table is not v1.4\n");
3458 +                       return -ENODEV;
3459 +               }
3460 +
3461 +               dprintk(KERN_DEBUG PFX "flags: 0x%x\n", psb->flags1);
3462 +               if (psb->flags1) {
3463 +                       printk(KERN_ERR BFX "unknown flags\n");
3464 +                       return -ENODEV;
3465 +               }
3466 +
3467 +               vstable = psb->voltagestabilizationtime;
3468 +               printk(KERN_INFO PFX "voltage stable time: %d (units 20us)\n",
3469 +                      vstable);
3470 +
3471 +               dprintk(KERN_DEBUG PFX "flags2: 0x%x\n", psb->flags2);
3472 +               rvo = psb->flags2 & 3;
3473 +               irt = ((psb->flags2) >> 2) & 3;
3474 +               mvs = ((psb->flags2) >> 4) & 3;
3475 +               vidmvs = 1 << mvs;
3476 +               batps = ((psb->flags2) >> 6) & 3;
3477 +               printk(KERN_INFO PFX "p states on battery: %d ", batps);
3478 +               switch (batps) {
3479 +               case 0:
3480 +                       printk("- all available\n");
3481 +                       break;
3482 +               case 1:
3483 +                       printk("- only the minimum\n");
3484 +                       break;
3485 +               case 2:
3486 +                       printk("- only the 2 lowest\n");
3487 +                       break;
3488 +               case 3:
3489 +                       printk("- only the 3 lowest\n");
3490 +                       break;
3491 +               }
3492 +               printk(KERN_INFO PFX "ramp voltage offset: %d\n", rvo);
3493 +               printk(KERN_INFO PFX "isochronous relief time: %d\n", irt);
3494 +               printk(KERN_INFO PFX "maximum voltage step: %d\n", mvs);
3495 +
3496 +               dprintk(KERN_DEBUG PFX "numpst: 0x%x\n", psb->numpst);
3497 +               if (psb->numpst != 1) {
3498 +                       printk(KERN_ERR BFX "numpst must be 1\n");
3499 +                       return -ENODEV;
3500 +               }
3501 +
3502 +               dprintk(KERN_DEBUG PFX "cpuid: 0x%x\n", psb->cpuid);
3503 +
3504 +               plllock = psb->plllocktime;
3505 +               printk(KERN_INFO PFX "pll lock time: 0x%x\n", plllock);
3506 +
3507 +               maxvid = psb->maxvid;
3508 +               printk(KERN_INFO PFX "maxfid: 0x%x\n", psb->maxfid);
3509 +               printk(KERN_INFO PFX "maxvid: 0x%x\n", maxvid);
3510 +
3511 +               numps = psb->numpstates;
3512 +               printk(KERN_INFO PFX "numpstates: 0x%x\n", numps);
3513 +               if (numps < 2) {
3514 +                       printk(KERN_ERR BFX "no p states to transition\n");
3515 +                       return -ENODEV;
3516 +               }
3517 +
3518 +               if (batps == 0) {
3519 +                       batps = numps;
3520 +               } else if (batps > numps) {
3521 +                       printk(KERN_ERR BFX "batterypstates > numpstates\n");
3522 +                       batps = numps;
3523 +               } else {
3524 +                       printk(KERN_ERR PFX
3525 +                              "Restricting operation to %d p-states\n", batps);
3526 +                       printk(KERN_ERR PFX
3527 +                              "Check for an updated driver to access all "
3528 +                              "%d p-states\n", numps);
3529 +               }
3530 +
3531 +               if ((numps <= 1) || (batps <= 1)) {
3532 +                       printk(KERN_ERR PFX "only 1 p-state to transition\n");
3533 +                       return -ENODEV;
3534 +               }
3535 +
3536 +               ppst = kmalloc(sizeof (struct pst_s) * numps, GFP_KERNEL);
3537 +               if (!ppst) {
3538 +                       printk(KERN_ERR PFX "ppst memory alloc failure\n");
3539 +                       return -ENOMEM;
3540 +               }
3541 +
3542 +               pst = (struct pst_s *) (psb + 1);
3543 +               for (j = 0; j < numps; j++) {
3544 +                       ppst[j].fid = pst[j].fid;
3545 +                       ppst[j].vid = pst[j].vid;
3546 +                       printk(KERN_INFO PFX
3547 +                              "   %d : fid 0x%x, vid 0x%x\n", j,
3548 +                              ppst[j].fid, ppst[j].vid);
3549 +               }
3550 +               sort_pst(ppst, numps);
3551 +
3552 +               lastfid = ppst[0].fid;
3553 +               if (lastfid > LO_FID_TABLE_TOP)
3554 +                       printk(KERN_INFO BFX "first fid not in lo freq tbl\n");
3555 +
3556 +               if ((lastfid > MAX_FID) || (lastfid & 1) || (ppst[0].vid > LEAST_VID)) {
3557 +                       printk(KERN_ERR BFX "first fid/vid bad (0x%x - 0x%x)\n",
3558 +                              lastfid, ppst[0].vid);
3559 +                       kfree(ppst);
3560 +                       return -ENODEV;
3561 +               }
3562 +
3563 +               for (j = 1; j < numps; j++) {
3564 +                       if ((lastfid >= ppst[j].fid)
3565 +                           || (ppst[j].fid & 1)
3566 +                           || (ppst[j].fid < HI_FID_TABLE_BOTTOM)
3567 +                           || (ppst[j].fid > MAX_FID)
3568 +                           || (ppst[j].vid > LEAST_VID)) {
3569 +                               printk(KERN_ERR BFX
3570 +                                      "invalid fid/vid in pst(%x %x)\n",
3571 +                                      ppst[j].fid, ppst[j].vid);
3572 +                               kfree(ppst);
3573 +                               return -ENODEV;
3574 +                       }
3575 +                       lastfid = ppst[j].fid;
3576 +               }
3577 +
3578 +               for (j = 0; j < numps; j++) {
3579 +                       if (ppst[j].vid < rvo) {        /* vid+rvo >= 0 */
3580 +                               printk(KERN_ERR BFX
3581 +                                      "0 vid exceeded with pstate %d\n", j);
3582 +                               return -ENODEV;
3583 +                       }
3584 +                       if (ppst[j].vid < maxvid+rvo) { /* vid+rvo >= maxvid */
3585 +                               printk(KERN_ERR BFX
3586 +                                      "maxvid exceeded with pstate %d\n", j);
3587 +                               return -ENODEV;
3588 +                       }
3589 +               }
3590 +
3591 +               if (query_current_values_with_pending_wait()) {
3592 +                       kfree(ppst);
3593 +                       return -EIO;
3594 +               }
3595 +
3596 +               printk(KERN_INFO PFX "currfid 0x%x, currvid 0x%x\n",
3597 +                      currfid, currvid);
3598 +
3599 +               for (j = 0; j < numps; j++)
3600 +                       if ((ppst[j].fid==currfid) && (ppst[j].vid==currvid))
3601 +                               return (0);
3602 +
3603 +               printk(KERN_ERR BFX "currfid/vid do not match PST, ignoring\n");
3604 +               return 0;
3605 +       }
3606 +
3607 +       printk(KERN_ERR BFX "no PSB\n");
3608 +       return -ENODEV;
3609 +}
3610 +
3611 +/* Converts a frequency (that might not necessarily be a multiple of 200) */
3612 +/* to a fid.                                                              */
3613 +u32
3614 +find_closest_fid(u32 freq, int searchup)
3615 +{
3616 +       if (searchup == SEARCH_UP)
3617 +               freq += MIN_FREQ_RESOLUTION - 1;
3618 +
3619 +       freq = (freq / MIN_FREQ_RESOLUTION) * MIN_FREQ_RESOLUTION;
3620 +
3621 +       if (freq < MIN_FREQ)
3622 +               freq = MIN_FREQ;
3623 +       else if (freq > MAX_FREQ)
3624 +               freq = MAX_FREQ;
3625 +
3626 +       return find_fid_from_freq(freq);
3627 +}
3628 +
3629 +static int
3630 +find_match(u32 * ptargfreq, u32 * pmin, u32 * pmax, int searchup, u32 * pfid,
3631 +          u32 * pvid)
3632 +{
3633 +       u32 availpstates = batps;
3634 +       u32 targfid = find_closest_fid(*ptargfreq, searchup);
3635 +       u32 minfid = find_closest_fid(*pmin, SEARCH_DOWN);
3636 +       u32 maxfid = find_closest_fid(*pmax, SEARCH_UP);
3637 +       u32 minidx = 0;
3638 +       u32 maxidx = availpstates - 1;
3639 +       u32 targidx = 0xffffffff;
3640 +       int i;
3641 +
3642 +       dprintk(KERN_DEBUG PFX "find match: freq %d MHz, min %d, max %d\n",
3643 +               *ptargfreq, *pmin, *pmax);
3644 +
3645 +       /* Restrict values to the frequency choices in the PST */
3646 +       if (minfid < ppst[0].fid)
3647 +               minfid = ppst[0].fid;
3648 +       if (maxfid > ppst[maxidx].fid)
3649 +               maxfid = ppst[maxidx].fid;
3650 +
3651 +       /* Find appropriate PST index for the minimim fid */
3652 +       for (i = 0; i < (int) availpstates; i++) {
3653 +               if (minfid >= ppst[i].fid)
3654 +                       minidx = i;
3655 +       }
3656 +
3657 +       /* Find appropriate PST index for the maximum fid */
3658 +       for (i = availpstates - 1; i >= 0; i--) {
3659 +               if (maxfid <= ppst[i].fid)
3660 +                       maxidx = i;
3661 +       }
3662 +
3663 +       if (minidx > maxidx)
3664 +               maxidx = minidx;
3665 +
3666 +       /* Frequency ids are now constrained by limits matching PST entries */
3667 +       minfid = ppst[minidx].fid;
3668 +       maxfid = ppst[maxidx].fid;
3669 +
3670 +       /* Limit the target frequency to these limits */
3671 +       if (targfid < minfid)
3672 +               targfid = minfid;
3673 +       else if (targfid > maxfid)
3674 +               targfid = maxfid;
3675 +
3676 +       /* Find the best target index into the PST, contrained by the range */
3677 +       if (searchup == SEARCH_UP) {
3678 +               for (i = maxidx; i >= (int) minidx; i--) {
3679 +                       if (targfid <= ppst[i].fid)
3680 +                               targidx = i;
3681 +               }
3682 +       } else {
3683 +               for (i = minidx; i <= (int) maxidx; i++) {
3684 +                       if (targfid >= ppst[i].fid)
3685 +                               targidx = i;
3686 +               }
3687 +       }
3688 +
3689 +       if (targidx == 0xffffffff) {
3690 +               printk(KERN_ERR PFX "could not find target\n");
3691 +               return 1;
3692 +       }
3693 +
3694 +       *pmin = find_freq_from_fid(minfid);
3695 +       *pmax = find_freq_from_fid(maxfid);
3696 +       *ptargfreq = find_freq_from_fid(ppst[targidx].fid);
3697 +
3698 +       if (pfid)
3699 +               *pfid = ppst[targidx].fid;
3700 +       if (pvid)
3701 +               *pvid = ppst[targidx].vid;
3702 +
3703 +       return 0;
3704 +}
3705 +
3706 +/* Take a frequency, and issue the fid/vid transition command */
3707 +static inline int
3708 +transition_frequency(u32 * preq, u32 * pmin, u32 * pmax, u32 searchup)
3709 +{
3710 +       u32 fid;
3711 +       u32 vid;
3712 +       int res;
3713 +       struct cpufreq_freqs freqs;
3714 +
3715 +       if (find_match(preq, pmin, pmax, searchup, &fid, &vid))
3716 +               return 1;
3717 +
3718 +       dprintk(KERN_DEBUG PFX "table matched fid 0x%x, giving vid 0x%x\n",
3719 +               fid, vid);
3720 +
3721 +       if (query_current_values_with_pending_wait())
3722 +               return 1;
3723 +
3724 +       if ((currvid == vid) && (currfid == fid)) {
3725 +               dprintk(KERN_DEBUG PFX
3726 +                       "target matches current values (fid 0x%x, vid 0x%x)\n",
3727 +                       fid, vid);
3728 +               return 0;
3729 +       }
3730 +
3731 +       if ((fid < HI_FID_TABLE_BOTTOM) && (currfid < HI_FID_TABLE_BOTTOM)) {
3732 +               printk(KERN_ERR PFX
3733 +                      "ignoring illegal change in lo freq table-%x to %x\n",
3734 +                      currfid, fid);
3735 +               return 1;
3736 +       }
3737 +
3738 +       dprintk(KERN_DEBUG PFX "changing to fid 0x%x, vid 0x%x\n", fid, vid);
3739 +
3740 +       freqs.cpu = 0;  /* only true because SMP not supported */
3741 +
3742 +       freqs.old = find_freq_from_fid(currfid);
3743 +       freqs.new = find_freq_from_fid(fid);
3744 +       cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
3745 +
3746 +       res = transition_fid_vid(fid, vid);
3747 +
3748 +       freqs.new = find_freq_from_fid(currfid);
3749 +       cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
3750 +
3751 +       return res;
3752 +}
3753 +
3754 +/* Driver entry point to switch to the target frequency */
3755 +static int
3756 +drv_target(struct cpufreq_policy *pol, unsigned targfreq, unsigned relation)
3757 +{
3758 +       u32 checkfid = currfid;
3759 +       u32 checkvid = currvid;
3760 +       u32 reqfreq = targfreq / 1000;
3761 +       u32 minfreq = pol->min / 1000;
3762 +       u32 maxfreq = pol->max / 1000;
3763 +
3764 +       if (ppst == 0) {
3765 +               printk(KERN_ERR PFX "targ: ppst 0\n");
3766 +               return -ENODEV;
3767 +       }
3768 +
3769 +       if (pending_bit_stuck()) {
3770 +               printk(KERN_ERR PFX "drv targ fail: change pending bit set\n");
3771 +               return -EIO;
3772 +       }
3773 +
3774 +       dprintk(KERN_DEBUG PFX "targ: %d kHz, min %d, max %d, relation %d\n",
3775 +               targfreq, pol->min, pol->max, relation);
3776 +
3777 +       if (query_current_values_with_pending_wait())
3778 +               return -EIO;
3779 +
3780 +       dprintk(KERN_DEBUG PFX "targ: curr fid 0x%x, vid 0x%x\n",
3781 +               currfid, currvid);
3782 +
3783 +       if ((checkvid != currvid) || (checkfid != currfid)) {
3784 +               printk(KERN_ERR PFX
3785 +                      "error - out of sync, fid 0x%x 0x%x, vid 0x%x 0x%x\n",
3786 +                      checkfid, currfid, checkvid, currvid);
3787 +       }
3788 +
3789 +       if (transition_frequency(&reqfreq, &minfreq, &maxfreq,
3790 +                                relation ==
3791 +                                CPUFREQ_RELATION_H ? SEARCH_UP : SEARCH_DOWN))
3792 +       {
3793 +               printk(KERN_ERR PFX "transition frequency failed\n");
3794 +               return 1;
3795 +       }
3796 +
3797 +       pol->cur = 1000 * find_freq_from_fid(currfid);
3798 +
3799 +       return 0;
3800 +}
3801 +
3802 +/* Driver entry point to verify the policy and range of frequencies */
3803 +static int
3804 +drv_verify(struct cpufreq_policy *pol)
3805 +{
3806 +       u32 min = pol->min / 1000;
3807 +       u32 max = pol->max / 1000;
3808 +       u32 targ = min;
3809 +       int res;
3810 +
3811 +       if (ppst == 0) {
3812 +               printk(KERN_ERR PFX "verify - ppst 0\n");
3813 +               return -ENODEV;
3814 +       }
3815 +
3816 +       if (pending_bit_stuck()) {
3817 +               printk(KERN_ERR PFX "failing verify, change pending bit set\n");
3818 +               return -EIO;
3819 +       }
3820 +
3821 +       dprintk(KERN_DEBUG PFX
3822 +               "ver: cpu%d, min %d, max %d, cur %d, pol %d\n", pol->cpu,
3823 +               pol->min, pol->max, pol->cur, pol->policy);
3824 +
3825 +       if (pol->cpu != 0) {
3826 +               printk(KERN_ERR PFX "verify - cpu not 0\n");
3827 +               return -ENODEV;
3828 +       }
3829 +
3830 +       res = find_match(&targ, &min, &max,
3831 +                        pol->policy == CPUFREQ_POLICY_POWERSAVE ?
3832 +                        SEARCH_DOWN : SEARCH_UP, 0, 0);
3833 +       if (!res) {
3834 +               pol->min = min * 1000;
3835 +               pol->max = max * 1000;
3836 +       }
3837 +       return res;
3838 +}
3839 +
3840 +/* per CPU init entry point to the driver */
3841 +static int __init
3842 +drv_cpu_init(struct cpufreq_policy *pol)
3843 +{
3844 +       if (pol->cpu != 0) {
3845 +               printk(KERN_ERR PFX "init not cpu 0\n");
3846 +               return -ENODEV;
3847 +       }
3848 +
3849 +       pol->policy = CPUFREQ_POLICY_PERFORMANCE; /* boot as fast as we can */
3850 +
3851 +       /* Take a crude guess here. */
3852 +       pol->cpuinfo.transition_latency = ((rvo + 8) * vstable * VST_UNITS_20US)
3853 +           + (3 * (1 << irt) * 10);
3854 +
3855 +       if (query_current_values_with_pending_wait())
3856 +               return -EIO;
3857 +
3858 +       pol->cur = 1000 * find_freq_from_fid(currfid);
3859 +       dprintk(KERN_DEBUG PFX "policy current frequency %d kHz\n", pol->cur);
3860 +
3861 +       /* min/max the cpu is capable of */
3862 +       pol->cpuinfo.min_freq = 1000 * find_freq_from_fid(ppst[0].fid);
3863 +       pol->cpuinfo.max_freq = 1000 * find_freq_from_fid(ppst[numps-1].fid);
3864 +       pol->min = 1000 * find_freq_from_fid(ppst[0].fid);
3865 +       pol->max = 1000 * find_freq_from_fid(ppst[batps - 1].fid);
3866 +
3867 +       printk(KERN_INFO PFX "cpu_init done, current fid 0x%x, vid 0x%x\n",
3868 +              currfid, currvid);
3869 +
3870 +       return 0;
3871 +}
3872 +
3873 +/* driver entry point for init */
3874 +static int __init
3875 +drv_init(void)
3876 +{
3877 +       int rc;
3878 +
3879 +       printk(KERN_INFO PFX VERSION "\n");
3880 +
3881 +       if (check_supported_cpu() == 0)
3882 +               return -ENODEV;
3883 +
3884 +       rc = find_psb_table();
3885 +       if (rc)
3886 +               return rc;
3887 +
3888 +       if (pending_bit_stuck()) {
3889 +               printk(KERN_ERR PFX "drv_init fail, change pending bit set\n");
3890 +               kfree(ppst);
3891 +               return -EIO;
3892 +       }
3893 +
3894 +       return cpufreq_register_driver(&cpufreq_amd64_driver);
3895 +}
3896 +
3897 +/* driver entry point for term */
3898 +static void __exit
3899 +drv_exit(void)
3900 +{
3901 +       dprintk(KERN_INFO PFX "drv_exit\n");
3902 +
3903 +       cpufreq_unregister_driver(&cpufreq_amd64_driver);
3904 +       kfree(ppst);
3905 +}
3906 +
3907 +MODULE_AUTHOR("Paul Devriendt <paul.devriendt@amd.com>");
3908 +MODULE_DESCRIPTION("AMD Athlon 64 and Opteron processor frequency driver.");
3909 +MODULE_LICENSE("GPL");
3910 +
3911 +module_init(drv_init);
3912 +module_exit(drv_exit);
3913 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
3914 +++ 25/arch/i386/kernel/cpu/cpufreq/powernow-k8.h       2003-10-05 00:33:23.000000000 -0700
3915 @@ -0,0 +1,126 @@
3916 +/*
3917 + *   (c) 2003 Advanced Micro Devices, Inc.
3918 + *  Your use of this code is subject to the terms and conditions of the
3919 + *  GNU general public license version 2. See "../../../COPYING" or
3920 + *  http://www.gnu.org/licenses/gpl.html
3921 + */
3922 +
3923 +/* processor's cpuid instruction support */
3924 +#define CPUID_PROCESSOR_SIGNATURE             1        /* function 1               */
3925 +#define CPUID_F1_FAM                 0x00000f00        /* family mask              */
3926 +#define CPUID_F1_XFAM                0x0ff00000        /* extended family mask     */
3927 +#define CPUID_F1_MOD                 0x000000f0        /* model mask               */
3928 +#define CPUID_F1_STEP                0x0000000f        /* stepping level mask      */
3929 +#define CPUID_XFAM_MOD               0x0ff00ff0        /* xtended fam, fam + model */
3930 +#define ATHLON64_XFAM_MOD            0x00000f40        /* xtended fam, fam + model */
3931 +#define OPTERON_XFAM_MOD             0x00000f50        /* xtended fam, fam + model */
3932 +#define ATHLON64_REV_C0                       8
3933 +#define CPUID_GET_MAX_CAPABILITIES   0x80000000
3934 +#define CPUID_FREQ_VOLT_CAPABILITIES 0x80000007
3935 +#define P_STATE_TRANSITION_CAPABLE            6
3936 +
3937 +/* Model Specific Registers for p-state transitions. MSRs are 64-bit. For     */
3938 +/* writes (wrmsr - opcode 0f 30), the register number is placed in ecx, and   */
3939 +/* the value to write is placed in edx:eax. For reads (rdmsr - opcode 0f 32), */
3940 +/* the register number is placed in ecx, and the data is returned in edx:eax. */
3941 +
3942 +#define MSR_FIDVID_CTL      0xc0010041
3943 +#define MSR_FIDVID_STATUS   0xc0010042
3944 +
3945 +/* Field definitions within the FID VID Low Control MSR : */
3946 +#define MSR_C_LO_INIT_FID_VID     0x00010000
3947 +#define MSR_C_LO_NEW_VID          0x00001f00
3948 +#define MSR_C_LO_NEW_FID          0x0000002f
3949 +#define MSR_C_LO_VID_SHIFT        8
3950 +
3951 +/* Field definitions within the FID VID High Control MSR : */
3952 +#define MSR_C_HI_STP_GNT_TO       0x000fffff
3953 +
3954 +/* Field definitions within the FID VID Low Status MSR : */
3955 +#define MSR_S_LO_CHANGE_PENDING   0x80000000   /* cleared when completed */
3956 +#define MSR_S_LO_MAX_RAMP_VID     0x1f000000
3957 +#define MSR_S_LO_MAX_FID          0x003f0000
3958 +#define MSR_S_LO_START_FID        0x00003f00
3959 +#define MSR_S_LO_CURRENT_FID      0x0000003f
3960 +
3961 +/* Field definitions within the FID VID High Status MSR : */
3962 +#define MSR_S_HI_MAX_WORKING_VID  0x001f0000
3963 +#define MSR_S_HI_START_VID        0x00001f00
3964 +#define MSR_S_HI_CURRENT_VID      0x0000001f
3965 +
3966 +/* fids (frequency identifiers) are arranged in 2 tables - lo and hi */
3967 +#define LO_FID_TABLE_TOP     6
3968 +#define HI_FID_TABLE_BOTTOM  8
3969 +
3970 +#define LO_VCOFREQ_TABLE_TOP    1400   /* corresponding vco frequency values */
3971 +#define HI_VCOFREQ_TABLE_BOTTOM 1600
3972 +
3973 +#define MIN_FREQ_RESOLUTION  200 /* fids jump by 2 matching freq jumps by 200 */
3974 +
3975 +#define MAX_FID 0x2a   /* Spec only gives FID values as far as 5 GHz */
3976 +
3977 +#define LEAST_VID 0x1e /* Lowest (numerically highest) useful vid value */
3978 +
3979 +#define MIN_FREQ 800   /* Min and max freqs, per spec */
3980 +#define MAX_FREQ 5000
3981 +
3982 +#define INVALID_FID_MASK 0xffffffc1  /* not a valid fid if these bits are set */
3983 +
3984 +#define INVALID_VID_MASK 0xffffffe0  /* not a valid vid if these bits are set */
3985 +
3986 +#define STOP_GRANT_5NS 1 /* min poss memory access latency for voltage change */
3987 +
3988 +#define PLL_LOCK_CONVERSION (1000/5) /* ms to ns, then divide by clock period */
3989 +
3990 +#define MAXIMUM_VID_STEPS 1  /* Current cpus only allow a single step of 25mV */
3991 +
3992 +#define VST_UNITS_20US 20   /* Voltage Stabalization Time is in units of 20us */
3993 +
3994 +/*
3995 +Version 1.4 of the PSB table. This table is constructed by BIOS and is
3996 +to tell the OS's power management driver which VIDs and FIDs are
3997 +supported by this particular processor. This information is obtained from
3998 +the data sheets for each processor model by the system vendor and
3999 +incorporated into the BIOS.
4000 +If the data in the PSB / PST is wrong, then this driver will program the
4001 +wrong values into hardware, which is very likely to lead to a crash.
4002 +*/
4003 +
4004 +#define PSB_ID_STRING      "AMDK7PNOW!"
4005 +#define PSB_ID_STRING_LEN  10
4006 +
4007 +#define PSB_VERSION_1_4  0x14
4008 +
4009 +struct psb_s {
4010 +       u8 signature[10];
4011 +       u8 tableversion;
4012 +       u8 flags1;
4013 +       u16 voltagestabilizationtime;
4014 +       u8 flags2;
4015 +       u8 numpst;
4016 +       u32 cpuid;
4017 +       u8 plllocktime;
4018 +       u8 maxfid;
4019 +       u8 maxvid;
4020 +       u8 numpstates;
4021 +};
4022 +
4023 +/* Pairs of fid/vid values are appended to the version 1.4 PSB table. */
4024 +struct pst_s {
4025 +       u8 fid;
4026 +       u8 vid;
4027 +};
4028 +
4029 +#ifdef DEBUG
4030 +#define dprintk(msg...) printk(msg)
4031 +#else
4032 +#define dprintk(msg...) do { } while(0)
4033 +#endif
4034 +
4035 +static inline int core_voltage_pre_transition(u32 reqvid);
4036 +static inline int core_voltage_post_transition(u32 reqvid);
4037 +static inline int core_frequency_transition(u32 reqfid);
4038 +static int drv_verify(struct cpufreq_policy *pol);
4039 +static int drv_target(struct cpufreq_policy *pol, unsigned targfreq,
4040 +                     unsigned relation);
4041 +static int __init drv_cpu_init(struct cpufreq_policy *pol);
4042 --- linux-2.6.0-test6/arch/i386/kernel/cpu/intel.c      2003-09-27 18:57:43.000000000 -0700
4043 +++ 25/arch/i386/kernel/cpu/intel.c     2003-10-05 00:36:48.000000000 -0700
4044 @@ -8,11 +8,10 @@
4045  #include <asm/processor.h>
4046  #include <asm/msr.h>
4047  #include <asm/uaccess.h>
4048 +#include <asm/desc.h>
4049  
4050  #include "cpu.h"
4051  
4052 -extern int trap_init_f00f_bug(void);
4053 -
4054  #ifdef CONFIG_X86_INTEL_USERCOPY
4055  /*
4056   * Alignment at which movsl is preferred for bulk memory copies.
4057 @@ -157,7 +156,7 @@ static void __init init_intel(struct cpu
4058  
4059                 c->f00f_bug = 1;
4060                 if ( !f00f_workaround_enabled ) {
4061 -                       trap_init_f00f_bug();
4062 +                       trap_init_virtual_IDT();
4063                         printk(KERN_NOTICE "Intel Pentium with F0 0F bug - workaround enabled.\n");
4064                         f00f_workaround_enabled = 1;
4065                 }
4066 @@ -238,12 +237,9 @@ static void __init init_intel(struct cpu
4067         }
4068  
4069         /* SEP CPUID bug: Pentium Pro reports SEP but doesn't have it until model 3 mask 3 */
4070 -       if ( c->x86 == 6) {
4071 -               unsigned model_mask = (c->x86_model << 8) + c->x86_mask;
4072 -               if (model_mask < 0x0303)
4073 -                       clear_bit(X86_FEATURE_SEP, c->x86_capability);
4074 -       }
4075 -       
4076 +       if ((c->x86<<8 | c->x86_model<<4 | c->x86_mask) < 0x633)
4077 +               clear_bit(X86_FEATURE_SEP, c->x86_capability);
4078 +
4079         /* Names for the Pentium II/Celeron processors 
4080            detectable only by also checking the cache size.
4081            Dixon is NOT a Celeron. */
4082 --- linux-2.6.0-test6/arch/i386/kernel/cpu/mcheck/k7.c  2003-08-08 22:55:10.000000000 -0700
4083 +++ 25/arch/i386/kernel/cpu/mcheck/k7.c 2003-10-05 00:33:23.000000000 -0700
4084 @@ -17,7 +17,7 @@
4085  #include "mce.h"
4086  
4087  /* Machine Check Handler For AMD Athlon/Duron */
4088 -static void k7_machine_check(struct pt_regs * regs, long error_code)
4089 +static asmlinkage void k7_machine_check(struct pt_regs * regs, long error_code)
4090  {
4091         int recover=1;
4092         u32 alow, ahigh, high, low;
4093 @@ -31,7 +31,7 @@ static void k7_machine_check(struct pt_r
4094         printk (KERN_EMERG "CPU %d: Machine Check Exception: %08x%08x\n",
4095                 smp_processor_id(), mcgsth, mcgstl);
4096  
4097 -       for (i=0; i<nr_mce_banks; i++) {
4098 +       for (i=1; i<nr_mce_banks; i++) {
4099                 rdmsr (MSR_IA32_MC0_STATUS+i*4,low, high);
4100                 if (high&(1<<31)) {
4101                         if (high & (1<<29))
4102 @@ -81,6 +81,9 @@ void __init amd_mcheck_init(struct cpuin
4103                 wrmsr (MSR_IA32_MCG_CTL, 0xffffffff, 0xffffffff);
4104         nr_mce_banks = l & 0xff;
4105  
4106 +       /* Clear status for MC index 0 separately, we don't touch CTL,
4107 +        * as some Athlons cause spurious MCEs when its enabled. */
4108 +       wrmsr (MSR_IA32_MC0_STATUS, 0x0, 0x0);
4109         for (i=1; i<nr_mce_banks; i++) {
4110                 wrmsr (MSR_IA32_MC0_CTL+4*i, 0xffffffff, 0xffffffff);
4111                 wrmsr (MSR_IA32_MC0_STATUS+4*i, 0x0, 0x0);
4112 --- linux-2.6.0-test6/arch/i386/kernel/cpu/mcheck/mce.c 2003-06-14 12:18:29.000000000 -0700
4113 +++ 25/arch/i386/kernel/cpu/mcheck/mce.c        2003-10-05 00:33:23.000000000 -0700
4114 @@ -18,18 +18,13 @@ int mce_disabled __initdata = 0;
4115  int nr_mce_banks;
4116  
4117  /* Handle unconfigured int18 (should never happen) */
4118 -static void unexpected_machine_check(struct pt_regs * regs, long error_code)
4119 +static asmlinkage void unexpected_machine_check(struct pt_regs * regs, long error_code)
4120  {      
4121         printk(KERN_ERR "CPU#%d: Unexpected int18 (Machine Check).\n", smp_processor_id());
4122  }
4123  
4124  /* Call the installed machine check handler for this CPU setup. */
4125 -void (*machine_check_vector)(struct pt_regs *, long error_code) = unexpected_machine_check;
4126 -
4127 -asmlinkage void do_machine_check(struct pt_regs * regs, long error_code)
4128 -{
4129 -       machine_check_vector(regs, error_code);
4130 -}
4131 +void asmlinkage (*machine_check_vector)(struct pt_regs *, long error_code) = unexpected_machine_check;
4132  
4133  /* This has to be run for each processor */
4134  void __init mcheck_init(struct cpuinfo_x86 *c)
4135 --- linux-2.6.0-test6/arch/i386/kernel/cpu/mcheck/mce.h 2003-06-14 12:17:58.000000000 -0700
4136 +++ 25/arch/i386/kernel/cpu/mcheck/mce.h        2003-10-05 00:33:23.000000000 -0700
4137 @@ -7,7 +7,7 @@ void intel_p6_mcheck_init(struct cpuinfo
4138  void winchip_mcheck_init(struct cpuinfo_x86 *c);
4139  
4140  /* Call the installed machine check handler for this CPU setup. */
4141 -extern void (*machine_check_vector)(struct pt_regs *, long error_code);
4142 +extern asmlinkage void (*machine_check_vector)(struct pt_regs *, long error_code);
4143  
4144  extern int mce_disabled __initdata;
4145  extern int nr_mce_banks;
4146 --- linux-2.6.0-test6/arch/i386/kernel/cpu/mcheck/p4.c  2003-06-14 12:18:24.000000000 -0700
4147 +++ 25/arch/i386/kernel/cpu/mcheck/p4.c 2003-10-05 00:33:23.000000000 -0700
4148 @@ -148,7 +148,7 @@ done:
4149         return mce_num_extended_msrs;
4150  }
4151  
4152 -static void intel_machine_check(struct pt_regs * regs, long error_code)
4153 +static asmlinkage void intel_machine_check(struct pt_regs * regs, long error_code)
4154  {
4155         int recover=1;
4156         u32 alow, ahigh, high, low;
4157 --- linux-2.6.0-test6/arch/i386/kernel/cpu/mcheck/p5.c  2003-06-14 12:18:23.000000000 -0700
4158 +++ 25/arch/i386/kernel/cpu/mcheck/p5.c 2003-10-05 00:33:23.000000000 -0700
4159 @@ -16,7 +16,7 @@
4160  #include "mce.h"
4161  
4162  /* Machine check handler for Pentium class Intel */
4163 -static void pentium_machine_check(struct pt_regs * regs, long error_code)
4164 +static asmlinkage void pentium_machine_check(struct pt_regs * regs, long error_code)
4165  {
4166         u32 loaddr, hi, lotype;
4167         rdmsr(MSR_IA32_P5_MC_ADDR, loaddr, hi);
4168 --- linux-2.6.0-test6/arch/i386/kernel/cpu/mcheck/p6.c  2003-06-14 12:18:24.000000000 -0700
4169 +++ 25/arch/i386/kernel/cpu/mcheck/p6.c 2003-10-05 00:33:23.000000000 -0700
4170 @@ -16,7 +16,7 @@
4171  #include "mce.h"
4172  
4173  /* Machine Check Handler For PII/PIII */
4174 -static void intel_machine_check(struct pt_regs * regs, long error_code)
4175 +static asmlinkage void intel_machine_check(struct pt_regs * regs, long error_code)
4176  {
4177         int recover=1;
4178         u32 alow, ahigh, high, low;
4179 --- linux-2.6.0-test6/arch/i386/kernel/cpu/mcheck/winchip.c     2003-06-14 12:18:22.000000000 -0700
4180 +++ 25/arch/i386/kernel/cpu/mcheck/winchip.c    2003-10-05 00:33:23.000000000 -0700
4181 @@ -15,7 +15,7 @@
4182  #include "mce.h"
4183  
4184  /* Machine check handler for WinChip C6 */
4185 -static void winchip_machine_check(struct pt_regs * regs, long error_code)
4186 +static asmlinkage void winchip_machine_check(struct pt_regs * regs, long error_code)
4187  {
4188         printk(KERN_EMERG "CPU0: Machine Check Exception.\n");
4189  }
4190 --- linux-2.6.0-test6/arch/i386/kernel/dmi_scan.c       2003-09-27 18:57:43.000000000 -0700
4191 +++ 25/arch/i386/kernel/dmi_scan.c      2003-10-05 00:33:23.000000000 -0700
4192 @@ -939,11 +939,6 @@ static __initdata struct dmi_blacklist d
4193                         MATCH(DMI_BOARD_NAME, "CUR-DLS"),
4194                         NO_MATCH, NO_MATCH }},
4195  
4196 -       { force_acpi_ht, "ASUS A7V", {
4197 -                       MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
4198 -                       MATCH(DMI_BOARD_NAME, "<A7V>"),
4199 -                       MATCH(DMI_BIOS_VERSION, "ASUS A7V ACPI BIOS Revision 1011"), NO_MATCH }},
4200 -
4201         { force_acpi_ht, "ABIT i440BX-W83977", {
4202                         MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"),
4203                         MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"),
4204 @@ -978,7 +973,10 @@ static __initdata struct dmi_blacklist d
4205         { disable_acpi_pci, "ASUS A7V", {
4206                         MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC"),
4207                         MATCH(DMI_BOARD_NAME, "<A7V>"),
4208 -                       MATCH(DMI_BIOS_VERSION, "ASUS A7V ACPI BIOS Revision 1007"), NO_MATCH }},
4209 +                       /* newer BIOS, Revision 1011, does work */
4210 +                       MATCH(DMI_BIOS_VERSION, "ASUS A7V ACPI BIOS Revision 1007"),
4211 +                       NO_MATCH }},
4212 +
4213  #endif
4214  
4215         { NULL, }
4216 --- linux-2.6.0-test6/arch/i386/kernel/doublefault.c    2003-08-22 19:23:40.000000000 -0700
4217 +++ 25/arch/i386/kernel/doublefault.c   2003-10-05 00:36:48.000000000 -0700
4218 @@ -7,12 +7,13 @@
4219  #include <asm/uaccess.h>
4220  #include <asm/pgtable.h>
4221  #include <asm/desc.h>
4222 +#include <asm/fixmap.h>
4223  
4224  #define DOUBLEFAULT_STACKSIZE (1024)
4225  static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
4226  #define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
4227  
4228 -#define ptr_ok(x) ((x) > 0xc0000000 && (x) < 0xc1000000)
4229 +#define ptr_ok(x) (((x) > __PAGE_OFFSET && (x) < (__PAGE_OFFSET + 0x01000000)) || ((x) >= FIXADDR_START))
4230  
4231  static void doublefault_fn(void)
4232  {
4233 @@ -38,8 +39,8 @@ static void doublefault_fn(void)
4234  
4235                         printk("eax = %08lx, ebx = %08lx, ecx = %08lx, edx = %08lx\n",
4236                                 t->eax, t->ebx, t->ecx, t->edx);
4237 -                       printk("esi = %08lx, edi = %08lx\n",
4238 -                               t->esi, t->edi);
4239 +                       printk("esi = %08lx, edi = %08lx, ebp = %08lx\n",
4240 +                               t->esi, t->edi, t->ebp);
4241                 }
4242         }
4243  
4244 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
4245 +++ 25/arch/i386/kernel/efi.c   2003-10-05 00:36:25.000000000 -0700
4246 @@ -0,0 +1,611 @@
4247 +/*
4248 + * Extensible Firmware Interface
4249 + *
4250 + * Based on Extensible Firmware Interface Specification version 1.0
4251 + *
4252 + * Copyright (C) 1999 VA Linux Systems
4253 + * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
4254 + * Copyright (C) 1999-2002 Hewlett-Packard Co.
4255 + *     David Mosberger-Tang <davidm@hpl.hp.com>
4256 + *     Stephane Eranian <eranian@hpl.hp.com>
4257 + *
4258 + * All EFI Runtime Services are not implemented yet as EFI only
4259 + * supports physical mode addressing on SoftSDV. This is to be fixed
4260 + * in a future version.  --drummond 1999-07-20
4261 + *
4262 + * Implemented EFI runtime services and virtual mode calls.  --davidm
4263 + *
4264 + * Goutham Rao: <goutham.rao@intel.com>
4265 + *     Skip non-WB memory and ignore empty memory ranges.
4266 + */
4267 +
4268 +#include <linux/config.h>
4269 +#include <linux/kernel.h>
4270 +#include <linux/init.h>
4271 +#include <linux/mm.h>
4272 +#include <linux/types.h>
4273 +#include <linux/time.h>
4274 +#include <linux/spinlock.h>
4275 +#include <linux/bootmem.h>
4276 +#include <linux/ioport.h>
4277 +#include <linux/proc_fs.h>
4278 +#include <linux/efi.h>
4279 +
4280 +#include <asm/setup.h>
4281 +#include <asm/io.h>
4282 +#include <asm/page.h>
4283 +#include <asm/pgtable.h>
4284 +#include <asm/processor.h>
4285 +#include <asm/desc.h>
4286 +#include <asm/pgalloc.h>
4287 +#include <asm/tlbflush.h>
4288 +
4289 +#define EFI_DEBUG      0
4290 +#define PFX            "EFI: "
4291 +
4292 +extern efi_status_t asmlinkage efi_call_phys(void *, ...);
4293 +
4294 +struct efi efi;
4295 +struct efi efi_phys __initdata;
4296 +struct efi_memory_map memmap __initdata;
4297 +
4298 +/*
4299 + * We require an early boot_ioremap mapping mechanism initially
4300 + */
4301 +extern void * boot_ioremap(unsigned long, unsigned long);
4302 +
4303 +/*
4304 + * efi_dir is allocated here, but the directory isn't created
4305 + * here, as proc_mkdir() doesn't work this early in the bootup
4306 + * process.  Therefore, each module, like efivars, must test for
4307 + *    if (!efi_dir) efi_dir = proc_mkdir("efi", NULL);
4308 + * prior to creating their own entries under /proc/efi.
4309 + */
4310 +#ifdef CONFIG_PROC_FS
4311 +struct proc_dir_entry *efi_dir;
4312 +#endif
4313 +
4314 +
4315 +/*
4316 + * To make EFI call EFI runtime service in physical addressing mode we need
4317 + * prelog/epilog before/after the invocation to disable interrupt, to
4318 + * claim EFI runtime service handler exclusively and to duplicate a memory in
4319 + * low memory space say 0 - 3G.
4320 + */
4321 +
4322 +static unsigned long efi_rt_eflags;
4323 +static spinlock_t efi_rt_lock = SPIN_LOCK_UNLOCKED;
4324 +static pgd_t efi_bak_pg_dir_pointer[2];
4325 +
4326 +static void efi_call_phys_prelog(void)
4327 +{
4328 +       unsigned long cr4;
4329 +       unsigned long temp;
4330 +
4331 +       spin_lock(&efi_rt_lock);
4332 +       local_irq_save(efi_rt_eflags);
4333 +
4334 +       /*
4335 +        * If I don't have PSE, I should just duplicate two entries in page
4336 +        * directory. If I have PSE, I just need to duplicate one entry in
4337 +        * page directory.
4338 +        */
4339 +       __asm__ __volatile__("movl %%cr4, %0":"=r"(cr4));
4340 +
4341 +       if (cr4 & X86_CR4_PSE) {
4342 +               efi_bak_pg_dir_pointer[0].pgd =
4343 +                   swapper_pg_dir[pgd_index(0)].pgd;
4344 +               swapper_pg_dir[0].pgd =
4345 +                   swapper_pg_dir[pgd_index(PAGE_OFFSET)].pgd;
4346 +       } else {
4347 +               efi_bak_pg_dir_pointer[0].pgd =
4348 +                   swapper_pg_dir[pgd_index(0)].pgd;
4349 +               efi_bak_pg_dir_pointer[1].pgd =
4350 +                   swapper_pg_dir[pgd_index(0x400000)].pgd;
4351 +               swapper_pg_dir[pgd_index(0)].pgd =
4352 +                   swapper_pg_dir[pgd_index(PAGE_OFFSET)].pgd;
4353 +               temp = PAGE_OFFSET + 0x400000;
4354 +               swapper_pg_dir[pgd_index(0x400000)].pgd =
4355 +                   swapper_pg_dir[pgd_index(temp)].pgd;
4356 +       }
4357 +
4358 +       /*
4359 +        * After the lock is released, the original page table is restored.
4360 +        */
4361 +       local_flush_tlb();
4362 +
4363 +       cpu_gdt_descr[0].address = __pa(cpu_gdt_descr[0].address);
4364 +       __asm__ __volatile__("lgdt %0":"=m"
4365 +                           (*(struct Xgt_desc_struct *) __pa(&cpu_gdt_descr[0])));
4366 +}
4367 +
4368 +static void efi_call_phys_epilog(void)
4369 +{
4370 +       unsigned long cr4;
4371 +
4372 +       cpu_gdt_descr[0].address =
4373 +               (unsigned long) __va(cpu_gdt_descr[0].address);
4374 +       __asm__ __volatile__("lgdt %0":"=m"(cpu_gdt_descr));
4375 +       __asm__ __volatile__("movl %%cr4, %0":"=r"(cr4));
4376 +
4377 +       if (cr4 & X86_CR4_PSE) {
4378 +               swapper_pg_dir[pgd_index(0)].pgd =
4379 +                   efi_bak_pg_dir_pointer[0].pgd;
4380 +       } else {
4381 +               swapper_pg_dir[pgd_index(0)].pgd =
4382 +                   efi_bak_pg_dir_pointer[0].pgd;
4383 +               swapper_pg_dir[pgd_index(0x400000)].pgd =
4384 +                   efi_bak_pg_dir_pointer[1].pgd;
4385 +       }
4386 +
4387 +       /*
4388 +        * After the lock is released, the original page table is restored.
4389 +        */
4390 +       local_flush_tlb();
4391 +
4392 +       local_irq_restore(efi_rt_eflags);
4393 +       spin_unlock(&efi_rt_lock);
4394 +}
4395 +
4396 +static efi_status_t
4397 +phys_efi_set_virtual_address_map(unsigned long memory_map_size,
4398 +                                unsigned long descriptor_size,
4399 +                                u32 descriptor_version,
4400 +                                efi_memory_desc_t *virtual_map)
4401 +{
4402 +       efi_status_t status;
4403 +
4404 +       efi_call_phys_prelog();
4405 +       status = efi_call_phys(efi_phys.set_virtual_address_map,
4406 +                                    memory_map_size, descriptor_size,
4407 +                                    descriptor_version, virtual_map);
4408 +       efi_call_phys_epilog();
4409 +       return status;
4410 +}
4411 +
4412 +efi_status_t
4413 +phys_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
4414 +{
4415 +       efi_status_t status;
4416 +
4417 +       efi_call_phys_prelog();
4418 +       status = efi_call_phys(efi_phys.get_time, tm, tc);
4419 +       efi_call_phys_epilog();
4420 +       return status;
4421 +}
4422 +
4423 +void efi_gettimeofday(struct timespec *tv)
4424 +{
4425 +       efi_time_t tm;
4426 +
4427 +       memset(tv, 0, sizeof(*tv));
4428 +       if ((*efi.get_time) (&tm, 0) != EFI_SUCCESS)
4429 +               return;
4430 +
4431 +       tv->tv_sec = mktime(tm.year, tm.month, tm.day, tm.hour, tm.minute,
4432 +                           tm.second);
4433 +       tv->tv_nsec = tm.nanosecond;
4434 +}
4435 +
4436 +int is_available_memory(efi_memory_desc_t * md)
4437 +{
4438 +       if (!(md->attribute & EFI_MEMORY_WB))
4439 +               return 0;
4440 +
4441 +       switch (md->type) {
4442 +               case EFI_LOADER_CODE:
4443 +               case EFI_LOADER_DATA:
4444 +               case EFI_BOOT_SERVICES_CODE:
4445 +               case EFI_BOOT_SERVICES_DATA:
4446 +               case EFI_CONVENTIONAL_MEMORY:
4447 +                       return 1;
4448 +       }
4449 +       return 0;
4450 +}
4451 +
4452 +/*
4453 + * We need to map the EFI memory map again after paging_init().
4454 + */
4455 +void __init efi_map_memmap(void)
4456 +{
4457 +       memmap.map = NULL;
4458 +
4459 +       memmap.map = (efi_memory_desc_t *)
4460 +               bt_ioremap((unsigned long) memmap.phys_map,
4461 +                       (memmap.nr_map * sizeof(efi_memory_desc_t)));
4462 +
4463 +       if (memmap.map == NULL)
4464 +               printk(KERN_ERR PFX "Could not remap the EFI memmap!\n");
4465 +}
4466 +
4467 +void __init print_efi_memmap(void)
4468 +{
4469 +       efi_memory_desc_t *md;
4470 +       int i;
4471 +
4472 +       for (i = 0; i < memmap.nr_map; i++) {
4473 +               md = &memmap.map[i];
4474 +               printk(KERN_INFO "mem%02u: type=%u, attr=0x%llx, "
4475 +                       "range=[0x%016llx-0x%016llx) (%lluMB)\n",
4476 +                       i, md->type, md->attribute, md->phys_addr,
4477 +                       md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT),
4478 +                       (md->num_pages >> (20 - EFI_PAGE_SHIFT)));
4479 +       }
4480 +}
4481 +
4482 +/*
4483 + * Walks the EFI memory map and calls CALLBACK once for each EFI
4484 + * memory descriptor that has memory that is available for kernel use.
4485 + */
4486 +void efi_memmap_walk(efi_freemem_callback_t callback, void *arg)
4487 +{
4488 +       int prev_valid = 0;
4489 +       struct range {
4490 +               unsigned long start;
4491 +               unsigned long end;
4492 +       } prev, curr;
4493 +       efi_memory_desc_t *md;
4494 +       unsigned long start, end;
4495 +       int i;
4496 +
4497 +       for (i = 0; i < memmap.nr_map; i++) {
4498 +               md = &memmap.map[i];
4499 +
4500 +               if ((md->num_pages == 0) || (!is_available_memory(md)))
4501 +                       continue;
4502 +
4503 +               curr.start = md->phys_addr;
4504 +               curr.end = curr.start + (md->num_pages << EFI_PAGE_SHIFT);
4505 +
4506 +               if (!prev_valid) {
4507 +                       prev = curr;
4508 +                       prev_valid = 1;
4509 +               } else {
4510 +                       if (curr.start < prev.start)
4511 +                               printk(KERN_INFO PFX "Unordered memory map\n");
4512 +                       if (prev.end == curr.start)
4513 +                               prev.end = curr.end;
4514 +                       else {
4515 +                               start =
4516 +                                   (unsigned long) (PAGE_ALIGN(prev.start));
4517 +                               end = (unsigned long) (prev.end & PAGE_MASK);
4518 +                               if ((end > start)
4519 +                                   && (*callback) (start, end, arg) < 0)
4520 +                                       return;
4521 +                               prev = curr;
4522 +                       }
4523 +               }
4524 +       }
4525 +       if (prev_valid) {
4526 +               start = (unsigned long) PAGE_ALIGN(prev.start);
4527 +               end = (unsigned long) (prev.end & PAGE_MASK);
4528 +               if (end > start)
4529 +                       (*callback) (start, end, arg);
4530 +       }
4531 +}
4532 +
4533 +void __init efi_init(void)
4534 +{
4535 +       efi_config_table_t *config_tables;
4536 +       efi_runtime_services_t *runtime;
4537 +       efi_char16_t *c16;
4538 +       char vendor[100] = "unknown";
4539 +       unsigned long num_config_tables;
4540 +       int i = 0;
4541 +
4542 +       memset(&efi, 0, sizeof(efi) );
4543 +       memset(&efi_phys, 0, sizeof(efi_phys));
4544 +
4545 +       efi_phys.systab = EFI_SYSTAB;
4546 +       memmap.phys_map = EFI_MEMMAP;
4547 +       memmap.nr_map = EFI_MEMMAP_SIZE/EFI_MEMDESC_SIZE;
4548 +       memmap.desc_version = EFI_MEMDESC_VERSION;
4549 +
4550 +       efi.systab = (efi_system_table_t *)
4551 +               boot_ioremap((unsigned long) efi_phys.systab,
4552 +                       sizeof(efi_system_table_t));
4553 +       /*
4554 +        * Verify the EFI Table
4555 +        */
4556 +       if (efi.systab == NULL)
4557 +               printk(KERN_ERR PFX "Woah! Couldn't map the EFI system table.\n");
4558 +       if (efi.systab->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE)
4559 +               printk(KERN_ERR PFX "Woah! EFI system table signature incorrect\n");
4560 +       if ((efi.systab->hdr.revision ^ EFI_SYSTEM_TABLE_REVISION) >> 16 != 0)
4561 +               printk(KERN_ERR PFX
4562 +                      "Warning: EFI system table major version mismatch: "
4563 +                      "got %d.%02d, expected %d.%02d\n",
4564 +                      efi.systab->hdr.revision >> 16,
4565 +                      efi.systab->hdr.revision & 0xffff,
4566 +                      EFI_SYSTEM_TABLE_REVISION >> 16,
4567 +                      EFI_SYSTEM_TABLE_REVISION & 0xffff);
4568 +       /*
4569 +        * Grab some details from the system table
4570 +        */
4571 +       num_config_tables = efi.systab->nr_tables;
4572 +       config_tables = (efi_config_table_t *)efi.systab->tables;
4573 +       runtime = efi.systab->runtime;
4574 +
4575 +       /*
4576 +        * Show what we know for posterity
4577 +        */
4578 +       c16 = (efi_char16_t *) boot_ioremap(efi.systab->fw_vendor, 2);
4579 +       if (c16) {
4580 +               for (i = 0; i < sizeof(vendor) && *c16; ++i)
4581 +                       vendor[i] = *c16++;
4582 +               vendor[i] = '\0';
4583 +       } else
4584 +               printk(KERN_ERR PFX "Could not map the firmware vendor!\n");
4585 +
4586 +       printk(KERN_INFO PFX "EFI v%u.%.02u by %s \n",
4587 +              efi.systab->hdr.revision >> 16,
4588 +              efi.systab->hdr.revision & 0xffff, vendor);
4589 +
4590 +       /*
4591 +        * Let's see what config tables the firmware passed to us.
4592 +        */
4593 +       config_tables = (efi_config_table_t *)
4594 +                               boot_ioremap((unsigned long) config_tables,
4595 +                               num_config_tables * sizeof(efi_config_table_t));
4596 +
4597 +       if (config_tables == NULL)
4598 +               printk(KERN_ERR PFX "Could not map EFI Configuration Table!\n");
4599 +
4600 +       for (i = 0; i < num_config_tables; i++) {
4601 +               if (efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID) == 0) {
4602 +                       efi.mps = (void *)config_tables[i].table;
4603 +                       printk(KERN_INFO " MPS=0x%lx ", config_tables[i].table);
4604 +               } else
4605 +                   if (efi_guidcmp(config_tables[i].guid, ACPI_20_TABLE_GUID) == 0) {
4606 +                       efi.acpi20 = __va(config_tables[i].table);
4607 +                       printk(KERN_INFO " ACPI 2.0=0x%lx ", config_tables[i].table);
4608 +               } else
4609 +                   if (efi_guidcmp(config_tables[i].guid, ACPI_TABLE_GUID) == 0) {
4610 +                       efi.acpi = __va(config_tables[i].table);
4611 +                       printk(KERN_INFO " ACPI=0x%lx ", config_tables[i].table);
4612 +               } else
4613 +                   if (efi_guidcmp(config_tables[i].guid, SMBIOS_TABLE_GUID) == 0) {
4614 +                       efi.smbios = (void *) config_tables[i].table;
4615 +                       printk(KERN_INFO " SMBIOS=0x%lx ", config_tables[i].table);
4616 +               } else
4617 +                   if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) == 0) {
4618 +                       efi.hcdp = (void *)config_tables[i].table;
4619 +                       printk(KERN_INFO " HCDP=0x%lx ", config_tables[i].table);
4620 +               } else
4621 +                   if (efi_guidcmp(config_tables[i].guid, UGA_IO_PROTOCOL_GUID) == 0) {
4622 +                       efi.uga = (void *)config_tables[i].table;
4623 +                       printk(KERN_INFO " UGA=0x%lx ", config_tables[i].table);
4624 +               }
4625 +       }
4626 +       printk("\n");
4627 +
4628 +       /*
4629 +        * Check out the runtime services table. We need to map
4630 +        * the runtime services table so that we can grab the physical
4631 +        * address of several of the EFI runtime functions, needed to
4632 +        * set the firmware into virtual mode.
4633 +        */
4634 +
4635 +       runtime = (efi_runtime_services_t *) boot_ioremap((unsigned long)
4636 +                                               runtime,
4637 +                                               sizeof(efi_runtime_services_t));
4638 +       if (runtime != NULL) {
4639 +               /*
4640 +                * We will only need *early* access to the following
4641 +                * two EFI runtime services before set_virtual_address_map
4642 +                * is invoked.
4643 +                */
4644 +               efi_phys.get_time = (efi_get_time_t *) runtime->get_time;
4645 +               efi_phys.set_virtual_address_map =
4646 +                       (efi_set_virtual_address_map_t *)
4647 +                               runtime->set_virtual_address_map;
4648 +       } else
4649 +               printk(KERN_ERR PFX "Could not map the runtime service table!\n");
4650 +
4651 +       /* Map the EFI memory map for use until paging_init() */
4652 +
4653 +       memmap.map = (efi_memory_desc_t *)
4654 +               boot_ioremap((unsigned long) EFI_MEMMAP, EFI_MEMMAP_SIZE);
4655 +
4656 +       if (memmap.map == NULL)
4657 +               printk(KERN_ERR PFX "Could not map the EFI memory map!\n");
4658 +
4659 +       if (EFI_MEMDESC_SIZE != sizeof(efi_memory_desc_t)) {
4660 +               printk(KERN_WARNING PFX "Warning! Kernel-defined memdesc doesn't "
4661 +                          "match the one from EFI!\n");
4662 +       }
4663 +#if EFI_DEBUG
4664 +       print_efi_memmap();
4665 +#endif
4666 +}
4667 +
4668 +/*
4669 + * This function will switch the EFI runtime services to virtual mode.
4670 + * Essentially, look through the EFI memmap and map every region that
4671 + * has the runtime attribute bit set in its memory descriptor and update
4672 + * that memory descriptor with the virtual address obtained from ioremap().
4673 + * This enables the runtime services to be called without having to
4674 + * thunk back into physical mode for every invocation.
4675 + */
4676 +
4677 +void __init efi_enter_virtual_mode(void)
4678 +{
4679 +       efi_memory_desc_t *md;
4680 +       efi_status_t status;
4681 +       int i;
4682 +
4683 +       efi.systab = NULL;
4684 +
4685 +       for (i = 0; i < memmap.nr_map; i++) {
4686 +               md = &memmap.map[i];
4687 +
4688 +               if (md->attribute & EFI_MEMORY_RUNTIME) {
4689 +                       md->virt_addr =
4690 +                               (unsigned long)ioremap(md->phys_addr,
4691 +                                       md->num_pages << EFI_PAGE_SHIFT);
4692 +                       if (!(unsigned long)md->virt_addr) {
4693 +                               printk(KERN_ERR PFX "ioremap of 0x%lX failed\n",
4694 +                                       (unsigned long)md->phys_addr);
4695 +                       }
4696 +
4697 +                       if (((unsigned long)md->phys_addr <=
4698 +                                       (unsigned long)efi_phys.systab) &&
4699 +                               ((unsigned long)efi_phys.systab <
4700 +                                       md->phys_addr +
4701 +                                       ((unsigned long)md->num_pages <<
4702 +                                               EFI_PAGE_SHIFT))) {
4703 +                               unsigned long addr;
4704 +
4705 +                               addr = md->virt_addr - md->phys_addr +
4706 +                                               (unsigned long)efi_phys.systab;
4707 +                               efi.systab = (efi_system_table_t *)addr;
4708 +                       }
4709 +               }
4710 +       }
4711 +
4712 +       if (!efi.systab)
4713 +               BUG();
4714 +
4715 +       status = phys_efi_set_virtual_address_map(
4716 +                       sizeof(efi_memory_desc_t) * memmap.nr_map,
4717 +                       sizeof(efi_memory_desc_t),
4718 +                       memmap.desc_version,
4719 +                       memmap.phys_map);
4720 +
4721 +       if (status != EFI_SUCCESS) {
4722 +               printk (KERN_ALERT "You are screwed! "
4723 +                       "Unable to switch EFI into virtual mode "
4724 +                       "(status=%lx)\n", status);
4725 +               panic("EFI call to SetVirtualAddressMap() failed!");
4726 +       }
4727 +
4728 +       /*
4729 +        * Now that EFI is in virtual mode, update the function
4730 +        * pointers in the runtime service table to the new virtual addresses.
4731 +        */
4732 +
4733 +       efi.get_time = (efi_get_time_t *) efi.systab->runtime->get_time;
4734 +       efi.set_time = (efi_set_time_t *) efi.systab->runtime->set_time;
4735 +       efi.get_wakeup_time = (efi_get_wakeup_time_t *)
4736 +                                       efi.systab->runtime->get_wakeup_time;
4737 +       efi.set_wakeup_time = (efi_set_wakeup_time_t *)
4738 +                                       efi.systab->runtime->set_wakeup_time;
4739 +       efi.get_variable = (efi_get_variable_t *)
4740 +                                       efi.systab->runtime->get_variable;
4741 +       efi.get_next_variable = (efi_get_next_variable_t *)
4742 +                                       efi.systab->runtime->get_next_variable;
4743 +       efi.set_variable = (efi_set_variable_t *)
4744 +                                       efi.systab->runtime->set_variable;
4745 +       efi.get_next_high_mono_count = (efi_get_next_high_mono_count_t *)
4746 +                                       efi.systab->runtime->get_next_high_mono_count;
4747 +       efi.reset_system = (efi_reset_system_t *)
4748 +                                       efi.systab->runtime->reset_system;
4749 +}
4750 +
4751 +void __init
4752 +efi_initialize_iomem_resources(struct resource *code_resource,
4753 +                              struct resource *data_resource)
4754 +{
4755 +       struct resource *res;
4756 +       efi_memory_desc_t *md;
4757 +       int i;
4758 +
4759 +       for (i = 0; i < memmap.nr_map; i++) {
4760 +               md = &memmap.map[i];
4761 +
4762 +               if ((md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT)) >
4763 +                   0x100000000ULL)
4764 +                       continue;
4765 +               res = alloc_bootmem_low(sizeof(struct resource));
4766 +               switch (md->type) {
4767 +               case EFI_RESERVED_TYPE:
4768 +                       res->name = "Reserved Memory";
4769 +                       break;
4770 +               case EFI_LOADER_CODE:
4771 +                       res->name = "Loader Code";
4772 +                       break;
4773 +               case EFI_LOADER_DATA:
4774 +                       res->name = "Loader Data";
4775 +                       break;
4776 +               case EFI_BOOT_SERVICES_DATA:
4777 +                       res->name = "BootServices Data";
4778 +                       break;
4779 +               case EFI_BOOT_SERVICES_CODE:
4780 +                       res->name = "BootServices Code";
4781 +                       break;
4782 +               case EFI_RUNTIME_SERVICES_CODE:
4783 +                       res->name = "Runtime Service Code";
4784 +                       break;
4785 +               case EFI_RUNTIME_SERVICES_DATA:
4786 +                       res->name = "Runtime Service Data";
4787 +                       break;
4788 +               case EFI_CONVENTIONAL_MEMORY:
4789 +                       res->name = "Conventional Memory";
4790 +                       break;
4791 +               case EFI_UNUSABLE_MEMORY:
4792 +                       res->name = "Unusable Memory";
4793 +                       break;
4794 +               case EFI_ACPI_RECLAIM_MEMORY:
4795 +                       res->name = "ACPI Reclaim";
4796 +                       break;
4797 +               case EFI_ACPI_MEMORY_NVS:
4798 +                       res->name = "ACPI NVS";
4799 +                       break;
4800 +               case EFI_MEMORY_MAPPED_IO:
4801 +                       res->name = "Memory Mapped IO";
4802 +                       break;
4803 +               case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
4804 +                       res->name = "Memory Mapped IO Port Space";
4805 +                       break;
4806 +               default:
4807 +                       res->name = "Reserved";
4808 +                       break;
4809 +               }
4810 +               res->start = md->phys_addr;
4811 +               res->end = res->start + ((md->num_pages << EFI_PAGE_SHIFT) - 1);
4812 +               res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
4813 +               if (request_resource(&iomem_resource, res) < 0)
4814 +                       printk(KERN_ERR PFX "Failed to allocate res %s : 0x%lx-0x%lx\n",
4815 +                               res->name, res->start, res->end);
4816 +               /*
4817 +                * We don't know which region contains kernel data so we try
4818 +                * it repeatedly and let the resource manager test it.
4819 +                */
4820 +               if (md->type == EFI_CONVENTIONAL_MEMORY) {
4821 +                       request_resource(res, code_resource);
4822 +                       request_resource(res, data_resource);
4823 +               }
4824 +       }
4825 +}
4826 +
4827 +/*
4828 + * Convenience functions to obtain memory types and attributes
4829 + */
4830 +
4831 +u32 efi_mem_type(unsigned long phys_addr)
4832 +{
4833 +       efi_memory_desc_t *md;
4834 +       int i;
4835 +
4836 +       for (i = 0; i < memmap.nr_map; i++) {
4837 +               md = &memmap.map[i];
4838 +               if ((md->phys_addr <= phys_addr) && (phys_addr <
4839 +                       (md->phys_addr + (md-> num_pages << EFI_PAGE_SHIFT)) ))
4840 +                       return md->type;
4841 +       }
4842 +       return 0;
4843 +}
4844 +
4845 +u64 efi_mem_attributes(unsigned long phys_addr)
4846 +{
4847 +       efi_memory_desc_t *md;
4848 +       int i;
4849 +
4850 +       for (i = 0; i < memmap.nr_map; i++) {
4851 +               md = &memmap.map[i];
4852 +               if ((md->phys_addr <= phys_addr) && (phys_addr <
4853 +                       (md->phys_addr + (md-> num_pages << EFI_PAGE_SHIFT)) ))
4854 +                       return md->attribute;
4855 +       }
4856 +       return 0;
4857 +}
4858 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
4859 +++ 25/arch/i386/kernel/efi_stub.S      2003-10-05 00:36:22.000000000 -0700
4860 @@ -0,0 +1,125 @@
4861 +/*
4862 + * EFI call stub for IA32.
4863 + *
4864 + * This stub allows us to make EFI calls in physical mode with interrupts
4865 + * turned off.
4866 + */
4867 +
4868 +#include <linux/config.h>
4869 +#include <linux/linkage.h>
4870 +#include <asm/page.h>
4871 +#include <asm/pgtable.h>
4872 +
4873 +/*
4874 + * efi_call_phys(void *, ...) is a function with variable parameters.
4875 + * All the callers of this function assure that all the parameters are 4-bytes.
4876 + */
4877 +
4878 +/*
4879 + * In gcc calling convention, EBX, ESP, EBP, ESI and EDI are all callee save.
4880 + * So we'd better save all of them at the beginning of this function and restore
4881 + * at the end no matter how many we use, because we can not assure EFI runtime
4882 + * service functions will comply with gcc calling convention, too.
4883 + */
4884 +
4885 +.text
4886 +.section .text, "a"
4887 +ENTRY(efi_call_phys)
4888 +       /*
4889 +        * 0. The function can only be called in Linux kernel. So CS has been
4890 +        * set to 0x0010, DS and SS have been set to 0x0018. In EFI, I found
4891 +        * the values of these registers are the same. And, the corresponding
4892 +        * GDT entries are identical. So I will do nothing about segment reg
4893 +        * and GDT, but change GDT base register in prelog and epilog.
4894 +        */
4895 +
4896 +       /*
4897 +        * 1. Now I am running with EIP = <physical address> + PAGE_OFFSET.
4898 +        * But to make it smoothly switch from virtual mode to flat mode.
4899 +        * The mapping of lower virtual memory has been created in prelog and
4900 +        * epilog.
4901 +        */
4902 +       movl    $1f, %edx
4903 +       subl    $__PAGE_OFFSET, %edx
4904 +       jmp     *%edx
4905 +1:
4906 +
4907 +       /*
4908 +        * 2. Now on the top of stack is the return
4909 +        * address in the caller of efi_call_phys(), then parameter 1,
4910 +        * parameter 2, ..., param n. To make things easy, we save the return
4911 +        * address of efi_call_phys in a global variable.
4912 +        */
4913 +       popl    %edx
4914 +       movl    %edx, saved_return_addr
4915 +       /* get the function pointer into ECX*/
4916 +       popl    %ecx
4917 +       movl    %ecx, efi_rt_function_ptr
4918 +       movl    $2f, %edx
4919 +       subl    $__PAGE_OFFSET, %edx
4920 +       pushl   %edx
4921 +
4922 +       /*
4923 +        * 3. Clear PG bit in %CR0.
4924 +        */
4925 +       movl    %cr0, %edx
4926 +       andl    $0x7fffffff, %edx
4927 +       movl    %edx, %cr0
4928 +       jmp     1f
4929 +1:
4930 +
4931 +       /*
4932 +        * 4. Adjust stack pointer.
4933 +        */
4934 +       subl    $__PAGE_OFFSET, %esp
4935 +
4936 +       /*
4937 +        * 5. Call the physical function.
4938 +        */
4939 +       jmp     *%ecx
4940 +
4941 +2:
4942 +       /*
4943 +        * 6. After EFI runtime service returns, control will return to
4944 +        * following instruction. We'd better readjust stack pointer first.
4945 +        */
4946 +       addl    $__PAGE_OFFSET, %esp
4947 +
4948 +       /*
4949 +        * 7. Restore PG bit
4950 +        */
4951 +       movl    %cr0, %edx
4952 +       orl     $0x80000000, %edx
4953 +       movl    %edx, %cr0
4954 +       jmp     1f
4955 +1:
4956 +       /*
4957 +        * 8. Now restore the virtual mode from flat mode by
4958 +        * adding EIP with PAGE_OFFSET.
4959 +        */
4960 +       movl    $1f, %edx
4961 +       jmp     *%edx
4962 +1:
4963 +
4964 +       /*
4965 +        * 9. Balance the stack. And because EAX contain the return value,
4966 +        * we'd better not clobber it.
4967 +        */
4968 +       leal    efi_rt_function_ptr, %edx
4969 +       movl    (%edx), %ecx
4970 +       pushl   %ecx
4971 +
4972 +       /*
4973 +        * 10. Push the saved return address onto the stack and return.
4974 +        */
4975 +       leal    saved_return_addr, %edx
4976 +       movl    (%edx), %ecx
4977 +       pushl   %ecx
4978 +       ret
4979 +.previous
4980 +
4981 +.data
4982 +saved_return_addr:
4983 +       .long 0
4984 +efi_rt_function_ptr:
4985 +       .long 0
4986 --- linux-2.6.0-test6/arch/i386/kernel/entry.S  2003-08-22 19:23:40.000000000 -0700
4987 +++ 25/arch/i386/kernel/entry.S 2003-10-05 00:36:48.000000000 -0700
4988 @@ -43,11 +43,25 @@
4989  #include <linux/config.h>
4990  #include <linux/linkage.h>
4991  #include <asm/thread_info.h>
4992 +#include <asm/asm_offsets.h>
4993  #include <asm/errno.h>
4994  #include <asm/segment.h>
4995 +#include <asm/page.h>
4996  #include <asm/smp.h>
4997  #include <asm/page.h>
4998  #include "irq_vectors.h"
4999 +        /* We do not recover from a stack overflow, but at least
5000 +         * we know it happened and should be able to track it down.
5001 +         */
5002 +#ifdef CONFIG_STACK_OVERFLOW_TEST
5003 +#define STACK_OVERFLOW_TEST \
5004 +        testl $7680,%esp;    \
5005 +        jnz   10f;            \
5006 +        call  stack_overflow; \
5007 +10:
5008 +#else
5009 +#define STACK_OVERFLOW_TEST
5010 +#endif
5011  
5012  EBX            = 0x00
5013  ECX            = 0x04
5014 @@ -85,7 +99,102 @@ TSS_ESP0_OFFSET = (4 - 0x200)
5015  #define resume_kernel          restore_all
5016  #endif
5017  
5018 -#define SAVE_ALL \
5019 +#ifdef CONFIG_X86_HIGH_ENTRY
5020 +
5021 +#ifdef CONFIG_X86_SWITCH_PAGETABLES
5022 +
5023 +#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP)
5024 +/*
5025 + * If task is preempted in __SWITCH_KERNELSPACE, and moved to another cpu,
5026 + * __switch_to repoints %esp to the appropriate virtual stack; but %ebp is
5027 + * left stale, so we must check whether to repeat the real stack calculation.
5028 + */
5029 +#define repeat_if_esp_changed                          \
5030 +       xorl %esp, %ebp;                                \
5031 +       testl $0xffffe000, %ebp;                        \
5032 +       jnz 0b
5033 +#else
5034 +#define repeat_if_esp_changed
5035 +#endif
5036 +
5037 +/* clobbers ebx, edx and ebp */
5038 +
5039 +#define __SWITCH_KERNELSPACE                           \
5040 +       cmpl $0xff000000, %esp;                         \
5041 +       jb 1f;                                          \
5042 +                                                       \
5043 +       /*                                              \
5044 +        * switch pagetables and load the real stack,   \
5045 +        * keep the stack offset:                       \
5046 +        */                                             \
5047 +                                                       \
5048 +       movl $swapper_pg_dir-__PAGE_OFFSET, %edx;       \
5049 +                                                       \
5050 +       /* GET_THREAD_INFO(%ebp) intermixed */          \
5051 +0:                                                     \
5052 +       movl %esp, %ebp;                                \
5053 +       movl %esp, %ebx;                                \
5054 +       andl $0xffffe000, %ebp;                         \
5055 +       andl $0x00001fff, %ebx;                         \
5056 +       orl TI_real_stack(%ebp), %ebx;                  \
5057 +       repeat_if_esp_changed;                          \
5058 +                                                       \
5059 +       movl %edx, %cr3;                                \
5060 +       movl %ebx, %esp;                                \
5061 +1:
5062 +
5063 +#endif
5064 +
5065 +
5066 +#define __SWITCH_USERSPACE \
5067 +       /* interrupted any of the user return paths? */ \
5068 +                                                       \
5069 +       movl EIP(%esp), %eax;                           \
5070 +                                                       \
5071 +       cmpl $int80_ret_start_marker, %eax;             \
5072 +       jb 33f; /* nope - continue with sysexit check */\
5073 +       cmpl $int80_ret_end_marker, %eax;               \
5074 +       jb 22f; /* yes - switch to virtual stack */     \
5075 +33:                                                    \
5076 +       cmpl $sysexit_ret_start_marker, %eax;           \
5077 +       jb 44f; /* nope - continue with user check */   \
5078 +       cmpl $sysexit_ret_end_marker, %eax;             \
5079 +       jb 22f; /* yes - switch to virtual stack */     \
5080 +       /* return to userspace? */                      \
5081 +44:                                                    \
5082 +       movl EFLAGS(%esp),%ecx;                         \
5083 +       movb CS(%esp),%cl;                              \
5084 +       testl $(VM_MASK | 3),%ecx;                      \
5085 +       jz 2f;                                          \
5086 +22:                                                    \
5087 +       /*                                              \
5088 +        * switch to the virtual stack, then switch to  \
5089 +        * the userspace pagetables.                    \
5090 +        */                                             \
5091 +                                                       \
5092 +       GET_THREAD_INFO(%ebp);                          \
5093 +       movl TI_virtual_stack(%ebp), %edx;              \
5094 +       movl TI_user_pgd(%ebp), %ecx;                   \
5095 +                                                       \
5096 +       movl %esp, %ebx;                                \
5097 +       andl $0x1fff, %ebx;                             \
5098 +       orl %ebx, %edx;                                 \
5099 +int80_ret_start_marker:                                        \
5100 +       movl %edx, %esp;                                \
5101 +       movl %ecx, %cr3;                                \
5102 +                                                       \
5103 +       __RESTORE_ALL;                                  \
5104 +int80_ret_end_marker:                                  \
5105 +2:
5106 +
5107 +#else /* !CONFIG_X86_HIGH_ENTRY */
5108 +
5109 +#define __SWITCH_KERNELSPACE
5110 +#define __SWITCH_USERSPACE
5111 +
5112 +#endif
5113 +
5114 +#define __SAVE_ALL \
5115         cld; \
5116         pushl %es; \
5117         pushl %ds; \
5118 @@ -100,7 +209,7 @@ TSS_ESP0_OFFSET = (4 - 0x200)
5119         movl %edx, %ds; \
5120         movl %edx, %es;
5121  
5122 -#define RESTORE_INT_REGS \
5123 +#define __RESTORE_INT_REGS \
5124         popl %ebx;      \
5125         popl %ecx;      \
5126         popl %edx;      \
5127 @@ -109,29 +218,28 @@ TSS_ESP0_OFFSET = (4 - 0x200)
5128         popl %ebp;      \
5129         popl %eax
5130  
5131 -#define RESTORE_REGS   \
5132 -       RESTORE_INT_REGS; \
5133 -1:     popl %ds;       \
5134 -2:     popl %es;       \
5135 +#define __RESTORE_REGS \
5136 +       __RESTORE_INT_REGS; \
5137 +111:   popl %ds;       \
5138 +222:   popl %es;       \
5139  .section .fixup,"ax";  \
5140 -3:     movl $0,(%esp); \
5141 -       jmp 1b;         \
5142 -4:     movl $0,(%esp); \
5143 -       jmp 2b;         \
5144 +444:   movl $0,(%esp); \
5145 +       jmp 111b;       \
5146 +555:   movl $0,(%esp); \
5147 +       jmp 222b;       \
5148  .previous;             \
5149  .section __ex_table,"a";\
5150         .align 4;       \
5151 -       .long 1b,3b;    \
5152 -       .long 2b,4b;    \
5153 +       .long 111b,444b;\
5154 +       .long 222b,555b;\
5155  .previous
5156  
5157 -
5158 -#define RESTORE_ALL    \
5159 -       RESTORE_REGS    \
5160 +#define __RESTORE_ALL  \
5161 +       __RESTORE_REGS  \
5162         addl $4, %esp;  \
5163 -1:     iret;           \
5164 +333:   iret;           \
5165  .section .fixup,"ax";   \
5166 -2:     sti;            \
5167 +666:   sti;            \
5168         movl $(__USER_DS), %edx; \
5169         movl %edx, %ds; \
5170         movl %edx, %es; \
5171 @@ -140,10 +248,19 @@ TSS_ESP0_OFFSET = (4 - 0x200)
5172  .previous;             \
5173  .section __ex_table,"a";\
5174         .align 4;       \
5175 -       .long 1b,2b;    \
5176 +       .long 333b,666b;\
5177  .previous
5178  
5179 +#define SAVE_ALL \
5180 +       __SAVE_ALL;                                     \
5181 +       __SWITCH_KERNELSPACE;                           \
5182 +        STACK_OVERFLOW_TEST;
5183 +
5184 +#define RESTORE_ALL                                    \
5185 +       __SWITCH_USERSPACE;                             \
5186 +       __RESTORE_ALL;
5187  
5188 +.section .entry.text,"ax"
5189  
5190  ENTRY(lcall7)
5191         pushfl                  # We get a different stack layout with call
5192 @@ -161,7 +278,7 @@ do_lcall:
5193         movl %edx,EIP(%ebp)     # Now we move them to their "normal" places
5194         movl %ecx,CS(%ebp)      #
5195         andl $-8192, %ebp       # GET_THREAD_INFO
5196 -       movl TI_EXEC_DOMAIN(%ebp), %edx # Get the execution domain
5197 +       movl TI_exec_domain(%ebp), %edx # Get the execution domain
5198         call *4(%edx)           # Call the lcall7 handler for the domain
5199         addl $4, %esp
5200         popl %eax
5201 @@ -206,7 +323,7 @@ ENTRY(resume_userspace)
5202         cli                             # make sure we don't miss an interrupt
5203                                         # setting need_resched or sigpending
5204                                         # between sampling and the iret
5205 -       movl TI_FLAGS(%ebp), %ecx
5206 +       movl TI_flags(%ebp), %ecx
5207         andl $_TIF_WORK_MASK, %ecx      # is there any work to be done on
5208                                         # int/exception return?
5209         jne work_pending
5210 @@ -214,18 +331,18 @@ ENTRY(resume_userspace)
5211  
5212  #ifdef CONFIG_PREEMPT
5213  ENTRY(resume_kernel)
5214 -       cmpl $0,TI_PRE_COUNT(%ebp)      # non-zero preempt_count ?
5215 +       cmpl $0,TI_preempt_count(%ebp)  # non-zero preempt_count ?
5216         jnz restore_all
5217  need_resched:
5218 -       movl TI_FLAGS(%ebp), %ecx       # need_resched set ?
5219 +       movl TI_flags(%ebp), %ecx       # need_resched set ?
5220         testb $_TIF_NEED_RESCHED, %cl
5221         jz restore_all
5222         testl $IF_MASK,EFLAGS(%esp)     # interrupts off (exception path) ?
5223         jz restore_all
5224 -       movl $PREEMPT_ACTIVE,TI_PRE_COUNT(%ebp)
5225 +       movl $PREEMPT_ACTIVE,TI_preempt_count(%ebp)
5226         sti
5227         call schedule
5228 -       movl $0,TI_PRE_COUNT(%ebp)
5229 +       movl $0,TI_preempt_count(%ebp)
5230         cli
5231         jmp need_resched
5232  #endif
5233 @@ -244,37 +361,50 @@ sysenter_past_esp:
5234         pushl $(__USER_CS)
5235         pushl $SYSENTER_RETURN
5236  
5237 -/*
5238 - * Load the potential sixth argument from user stack.
5239 - * Careful about security.
5240 - */
5241 -       cmpl $__PAGE_OFFSET-3,%ebp
5242 -       jae syscall_fault
5243 -1:     movl (%ebp),%ebp
5244 -.section __ex_table,"a"
5245 -       .align 4
5246 -       .long 1b,syscall_fault
5247 -.previous
5248 -
5249         pushl %eax
5250         SAVE_ALL
5251         GET_THREAD_INFO(%ebp)
5252         cmpl $(nr_syscalls), %eax
5253         jae syscall_badsys
5254  
5255 -       testb $_TIF_SYSCALL_TRACE,TI_FLAGS(%ebp)
5256 +       testb $_TIF_SYSCALL_TRACE,TI_flags(%ebp)
5257         jnz syscall_trace_entry
5258         call *sys_call_table(,%eax,4)
5259         movl %eax,EAX(%esp)
5260         cli
5261 -       movl TI_FLAGS(%ebp), %ecx
5262 +       movl TI_flags(%ebp), %ecx
5263         testw $_TIF_ALLWORK_MASK, %cx
5264         jne syscall_exit_work
5265 +
5266 +#ifdef CONFIG_X86_SWITCH_PAGETABLES
5267 +
5268 +       GET_THREAD_INFO(%ebp)
5269 +       movl TI_virtual_stack(%ebp), %edx
5270 +       movl TI_user_pgd(%ebp), %ecx
5271 +       movl %esp, %ebx
5272 +       andl $0x1fff, %ebx
5273 +       orl %ebx, %edx
5274 +sysexit_ret_start_marker:
5275 +       movl %edx, %esp
5276 +       movl %ecx, %cr3
5277 +#endif
5278 +       /*
5279 +        * only ebx is not restored by the userspace sysenter vsyscall
5280 +        * code, it assumes it to be callee-saved.
5281 +        */
5282 +       movl EBX(%esp), %ebx
5283 +
5284  /* if something modifies registers it must also disable sysexit */
5285 +
5286         movl EIP(%esp), %edx
5287         movl OLDESP(%esp), %ecx
5288 +
5289         sti
5290         sysexit
5291 +#ifdef CONFIG_X86_SWITCH_PAGETABLES
5292 +sysexit_ret_end_marker:
5293 +       nop
5294 +#endif
5295  
5296  
5297         # system call handler stub
5298 @@ -285,7 +415,7 @@ ENTRY(system_call)
5299         cmpl $(nr_syscalls), %eax
5300         jae syscall_badsys
5301                                         # system call tracing in operation
5302 -       testb $_TIF_SYSCALL_TRACE,TI_FLAGS(%ebp)
5303 +       testb $_TIF_SYSCALL_TRACE,TI_flags(%ebp)
5304         jnz syscall_trace_entry
5305  syscall_call:
5306         call *sys_call_table(,%eax,4)
5307 @@ -294,10 +424,23 @@ syscall_exit:
5308         cli                             # make sure we don't miss an interrupt
5309                                         # setting need_resched or sigpending
5310                                         # between sampling and the iret
5311 -       movl TI_FLAGS(%ebp), %ecx
5312 +       movl TI_flags(%ebp), %ecx
5313         testw $_TIF_ALLWORK_MASK, %cx   # current->work
5314         jne syscall_exit_work
5315  restore_all:
5316 +#ifdef CONFIG_TRAP_BAD_SYSCALL_EXITS
5317 +       movl EFLAGS(%esp), %eax         # mix EFLAGS and CS
5318 +       movb CS(%esp), %al
5319 +       testl $(VM_MASK | 3), %eax
5320 +       jz resume_kernelX               # returning to kernel or vm86-space
5321 +
5322 +       cmpl $0,TI_preempt_count(%ebp)  # non-zero preempt_count ?
5323 +       jz resume_kernelX
5324 +
5325 +        int $3
5326 +
5327 +resume_kernelX:
5328 +#endif
5329         RESTORE_ALL
5330  
5331         # perform work that needs to be done immediately before resumption
5332 @@ -310,7 +453,7 @@ work_resched:
5333         cli                             # make sure we don't miss an interrupt
5334                                         # setting need_resched or sigpending
5335                                         # between sampling and the iret
5336 -       movl TI_FLAGS(%ebp), %ecx
5337 +       movl TI_flags(%ebp), %ecx
5338         andl $_TIF_WORK_MASK, %ecx      # is there any work to be done other
5339                                         # than syscall tracing?
5340         jz restore_all
5341 @@ -325,6 +468,22 @@ work_notifysig:                            # deal with pending s
5342                                         # vm86-space
5343         xorl %edx, %edx
5344         call do_notify_resume
5345 +
5346 +#if CONFIG_X86_HIGH_ENTRY
5347 +       /*
5348 +        * Reload db7 if necessary:
5349 +        */
5350 +       movl TI_flags(%ebp), %ecx
5351 +       testb $_TIF_DB7, %cl
5352 +       jnz work_db7
5353 +
5354 +       jmp restore_all
5355 +
5356 +work_db7:
5357 +       movl TI_task(%ebp), %edx;
5358 +       movl task_thread_db7(%edx), %edx;
5359 +       movl %edx, %db7;
5360 +#endif
5361         jmp restore_all
5362  
5363         ALIGN
5364 @@ -380,7 +539,7 @@ syscall_badsys:
5365   */
5366  .data
5367  ENTRY(interrupt)
5368 -.text
5369 +.previous
5370  
5371  vector=0
5372  ENTRY(irq_entries_start)
5373 @@ -390,7 +549,7 @@ ENTRY(irq_entries_start)
5374         jmp common_interrupt
5375  .data
5376         .long 1b
5377 -.text
5378 +.previous
5379  vector=vector+1
5380  .endr
5381  
5382 @@ -431,12 +590,17 @@ error_code:
5383         movl ES(%esp), %edi             # get the function address
5384         movl %eax, ORIG_EAX(%esp)
5385         movl %ecx, ES(%esp)
5386 -       movl %esp, %edx
5387         pushl %esi                      # push the error code
5388 -       pushl %edx                      # push the pt_regs pointer
5389         movl $(__USER_DS), %edx
5390         movl %edx, %ds
5391         movl %edx, %es
5392 +
5393 +/* clobbers edx, ebx and ebp */
5394 +       __SWITCH_KERNELSPACE
5395 +
5396 +       leal 4(%esp), %edx              # prepare pt_regs
5397 +       pushl %edx                      # push pt_regs
5398 +
5399         call *%edi
5400         addl $8, %esp
5401         jmp ret_from_exception
5402 @@ -527,7 +691,7 @@ nmi_stack_correct:
5403         pushl %edx
5404         call do_nmi
5405         addl $8, %esp
5406 -       RESTORE_ALL
5407 +       jmp restore_all
5408  
5409  nmi_stack_fixup:
5410         FIX_STACK(12,nmi_stack_correct, 1)
5411 @@ -595,7 +759,7 @@ ENTRY(page_fault)
5412  #ifdef CONFIG_X86_MCE
5413  ENTRY(machine_check)
5414         pushl $0
5415 -       pushl $do_machine_check
5416 +       pushl machine_check_vector
5417         jmp error_code
5418  #endif
5419  
5420 @@ -604,6 +768,8 @@ ENTRY(spurious_interrupt_bug)
5421         pushl $do_spurious_interrupt_bug
5422         jmp error_code
5423  
5424 +.previous
5425 +
5426  .data
5427  ENTRY(sys_call_table)
5428         .long sys_restart_syscall       /* 0 - old "setup()" system call, used for restarting */
5429 @@ -879,5 +1045,60 @@ ENTRY(sys_call_table)
5430         .long sys_tgkill        /* 270 */
5431         .long sys_utimes
5432         .long sys_fadvise64_64
5433 +       .long sys_ni_syscall    /* sys_vserver */
5434  
5435  nr_syscalls=(.-sys_call_table)/4
5436 +
5437 +
5438 +#      Here we do call frames.  We cheat a bit as we only really need
5439 +#      correct frames at locations we can actually look at from a
5440 +#      debugger.  Since the break instruction trap actually goes thru
5441 +#      some of this code, we don't really need info on those areas, but
5442 +#      only after the fact.  I.e. if we can not step or break in a
5443 +#      location or end up with a return address pointing at the
5444 +#      location, we don't need a correct call frame for it.
5445 +
5446 +#if 0
5447 +
5448 +#include <linux/dwarf2-lang.h>
5449 +/*
5450 + * The register numbers as known by gdb
5451 + */
5452 +#define _EAX 0
5453 +#define _ECX 1
5454 +#define _EDX 2
5455 +#define _EBX 3
5456 +#define _ESP 4
5457 +#define _EBP 5
5458 +#define _ESI 6
5459 +#define _EDI 7
5460 +#define _PC  8
5461 +#define _EIP 8
5462 +#define _PS  9
5463 +#define _EFLAGS  9
5464 +#define _CS 10
5465 +#define _SS 11
5466 +#define _DS 12
5467 +#define _ES 13
5468 +#define _FS 14
5469 +#define _GS 15
5470 +
5471 +       CFI_preamble(c1,_PC,1,1)
5472 +       CFA_define_reference(_ESP,OLDESP)
5473 +       CFA_define_offset(_EIP,EIP)
5474 +       CFA_define_offset(_EBX,EBX)
5475 +       CFA_define_offset(_ECX,ECX)
5476 +       CFA_define_offset(_EDX,EDX)
5477 +       CFA_define_offset(_ESI,ESI)
5478 +       CFA_define_offset(_EDI,EDI)
5479 +       CFA_define_offset(_EBP,EBP)
5480 +       CFA_define_offset(_EAX,EAX)
5481 +       CFA_define_offset(_EFLAGS,EFLAGS)
5482 +       CFA_define_offset(_CS,CS)
5483 +       CFA_define_offset(_DS,DS)
5484 +       CFA_define_offset(_ES,ES)
5485 +       CFI_postamble(c1)
5486 +
5487 +       FDE_preamble(c1,f1,ret_from_intr,(divide_error - ret_from_intr))
5488 +       FDE_postamble(f1)
5489 +#endif
5490 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
5491 +++ 25/arch/i386/kernel/entry_trampoline.c      2003-10-05 00:36:48.000000000 -0700
5492 @@ -0,0 +1,75 @@
5493 +/*
5494 + * linux/arch/i386/kernel/entry_trampoline.c
5495 + *
5496 + * (C) Copyright 2003 Ingo Molnar
5497 + *
5498 + * This file contains the needed support code for 4GB userspace
5499 + */
5500 +
5501 +#include <linux/init.h>
5502 +#include <linux/smp.h>
5503 +#include <linux/mm.h>
5504 +#include <linux/sched.h>
5505 +#include <linux/kernel.h>
5506 +#include <linux/string.h>
5507 +#include <linux/highmem.h>
5508 +#include <asm/desc.h>
5509 +#include <asm/atomic_kmap.h>
5510 +
5511 +extern char __entry_tramp_start, __entry_tramp_end, __start___entry_text;
5512 +
5513 +void __init init_entry_mappings(void)
5514 +{
5515 +#ifdef CONFIG_X86_HIGH_ENTRY
5516 +       void *tramp;
5517 +
5518 +       /*
5519 +        * We need a high IDT and GDT for the 4G/4G split:
5520 +        */
5521 +       trap_init_virtual_IDT();
5522 +
5523 +       __set_fixmap(FIX_ENTRY_TRAMPOLINE_0, __pa((unsigned long)&__entry_tramp_start), PAGE_KERNEL);
5524 +       __set_fixmap(FIX_ENTRY_TRAMPOLINE_1, __pa((unsigned long)&__entry_tramp_start) + PAGE_SIZE, PAGE_KERNEL);
5525 +       tramp = (void *)fix_to_virt(FIX_ENTRY_TRAMPOLINE_0);
5526 +
5527 +       printk("mapped 4G/4G trampoline to %p.\n", tramp);
5528 +       BUG_ON((void *)&__start___entry_text != tramp);
5529 +       /*
5530 +        * Virtual kernel stack:
5531 +        */
5532 +       BUG_ON(__kmap_atomic_vaddr(KM_VSTACK0) & 8191);
5533 +       BUG_ON(sizeof(struct desc_struct)*NR_CPUS*GDT_ENTRIES > 2*PAGE_SIZE);
5534 +       BUG_ON((unsigned int)&__entry_tramp_end - (unsigned int)&__entry_tramp_start > 2*PAGE_SIZE);
5535 +
5536 +       /*
5537 +        * set up the initial thread's virtual stack related
5538 +        * fields:
5539 +        */
5540 +       current->thread.stack_page0 = virt_to_page((char *)current->thread_info);
5541 +       current->thread.stack_page1 = virt_to_page((char *)current->thread_info + PAGE_SIZE);
5542 +       current->thread_info->virtual_stack = (void *)__kmap_atomic_vaddr(KM_VSTACK0);
5543 +
5544 +       __kunmap_atomic_type(KM_VSTACK0);
5545 +       __kunmap_atomic_type(KM_VSTACK1);
5546 +        __kmap_atomic(current->thread.stack_page0, KM_VSTACK0);
5547 +        __kmap_atomic(current->thread.stack_page1, KM_VSTACK1);
5548 +
5549 +#endif
5550 +       printk("current: %p\n", current);
5551 +       printk("current->thread_info: %p\n", current->thread_info);
5552 +       current->thread_info->real_stack = (void *)current->thread_info;
5553 +       current->thread_info->user_pgd = NULL;
5554 +       current->thread.esp0 = (unsigned long)current->thread_info->real_stack + THREAD_SIZE;
5555 +}
5556 +
5557 +
5558 +
5559 +void __init entry_trampoline_setup(void)
5560 +{
5561 +       /*
5562 +        * old IRQ entries set up by the boot code will still hang
5563 +        * around - they are a sign of hw trouble anyway, now they'll
5564 +        * produce a double fault message.
5565 +        */
5566 +       trap_init_virtual_GDT();
5567 +}
5568 --- linux-2.6.0-test6/arch/i386/kernel/head.S   2003-08-22 19:23:40.000000000 -0700
5569 +++ 25/arch/i386/kernel/head.S  2003-10-05 00:36:48.000000000 -0700
5570 @@ -16,6 +16,7 @@
5571  #include <asm/pgtable.h>
5572  #include <asm/desc.h>
5573  #include <asm/cache.h>
5574 +#include <asm/asm_offsets.h>
5575  
5576  #define OLD_CL_MAGIC_ADDR      0x90020
5577  #define OLD_CL_MAGIC           0xA33F
5578 @@ -330,7 +331,7 @@ ENTRY(stack_start)
5579  
5580  /* This is the default interrupt "handler" :-) */
5581  int_msg:
5582 -       .asciz "Unknown interrupt\n"
5583 +       .asciz "Unknown interrupt or fault at EIP %p %p %p\n"
5584         ALIGN
5585  ignore_int:
5586         cld
5587 @@ -342,9 +343,17 @@ ignore_int:
5588         movl $(__KERNEL_DS),%eax
5589         movl %eax,%ds
5590         movl %eax,%es
5591 +       pushl 16(%esp)
5592 +       pushl 24(%esp)
5593 +       pushl 32(%esp)
5594 +       pushl 40(%esp)
5595         pushl $int_msg
5596         call printk
5597         popl %eax
5598 +       popl %eax
5599 +       popl %eax
5600 +       popl %eax
5601 +       popl %eax
5602         popl %ds
5603         popl %es
5604         popl %edx
5605 @@ -377,23 +386,27 @@ cpu_gdt_descr:
5606         .fill NR_CPUS-1,8,0             # space for the other GDT descriptors
5607  
5608  /*
5609 - * This is initialized to create an identity-mapping at 0-8M (for bootup
5610 - * purposes) and another mapping of the 0-8M area at virtual address
5611 + * This is initialized to create an identity-mapping at 0-16M (for bootup
5612 + * purposes) and another mapping of the 0-16M area at virtual address
5613   * PAGE_OFFSET.
5614   */
5615  .org 0x1000
5616  ENTRY(swapper_pg_dir)
5617         .long 0x00102007
5618         .long 0x00103007
5619 -       .fill BOOT_USER_PGD_PTRS-2,4,0
5620 -       /* default: 766 entries */
5621 +       .long 0x00104007
5622 +       .long 0x00105007
5623 +       .fill BOOT_USER_PGD_PTRS-4,4,0
5624 +       /* default: 764 entries */
5625         .long 0x00102007
5626         .long 0x00103007
5627 -       /* default: 254 entries */
5628 -       .fill BOOT_KERNEL_PGD_PTRS-2,4,0
5629 +       .long 0x00104007
5630 +       .long 0x00105007
5631 +       /* default: 252 entries */
5632 +       .fill BOOT_KERNEL_PGD_PTRS-4,4,0
5633  
5634  /*
5635 - * The page tables are initialized to only 8MB here - the final page
5636 + * The page tables are initialized to only 16MB here - the final page
5637   * tables are set up later depending on memory size.
5638   */
5639  .org 0x2000
5640 @@ -402,15 +415,21 @@ ENTRY(pg0)
5641  .org 0x3000
5642  ENTRY(pg1)
5643  
5644 +.org 0x4000
5645 +ENTRY(pg2)
5646 +
5647 +.org 0x5000
5648 +ENTRY(pg3)
5649 +
5650  /*
5651   * empty_zero_page must immediately follow the page tables ! (The
5652   * initialization loop counts until empty_zero_page)
5653   */
5654  
5655 -.org 0x4000
5656 +.org 0x6000
5657  ENTRY(empty_zero_page)
5658  
5659 -.org 0x5000
5660 +.org 0x7000
5661  
5662  /*
5663   * Real beginning of normal "text" segment
5664 @@ -419,12 +438,12 @@ ENTRY(stext)
5665  ENTRY(_stext)
5666  
5667  /*
5668 - * This starts the data section. Note that the above is all
5669 - * in the text section because it has alignment requirements
5670 - * that we cannot fulfill any other way.
5671 + * This starts the data section.
5672   */
5673  .data
5674  
5675 +.align PAGE_SIZE_asm
5676 +
5677  /*
5678   * The Global Descriptor Table contains 28 quadwords, per-CPU.
5679   */
5680 @@ -439,7 +458,9 @@ ENTRY(boot_gdt_table)
5681         .quad 0x00cf9a000000ffff        /* kernel 4GB code at 0x00000000 */
5682         .quad 0x00cf92000000ffff        /* kernel 4GB data at 0x00000000 */
5683  #endif
5684 -       .align L1_CACHE_BYTES
5685 +
5686 +.align PAGE_SIZE_asm
5687 +
5688  ENTRY(cpu_gdt_table)
5689         .quad 0x0000000000000000        /* NULL descriptor */
5690         .quad 0x0000000000000000        /* 0x0b reserved */
5691 --- linux-2.6.0-test6/arch/i386/kernel/i386_ksyms.c     2003-09-27 18:57:43.000000000 -0700
5692 +++ 25/arch/i386/kernel/i386_ksyms.c    2003-10-05 00:36:48.000000000 -0700
5693 @@ -98,7 +98,6 @@ EXPORT_SYMBOL_NOVERS(__down_failed_inter
5694  EXPORT_SYMBOL_NOVERS(__down_failed_trylock);
5695  EXPORT_SYMBOL_NOVERS(__up_wakeup);
5696  /* Networking helper routines. */
5697 -EXPORT_SYMBOL(csum_partial_copy_generic);
5698  /* Delay loops */
5699  EXPORT_SYMBOL(__ndelay);
5700  EXPORT_SYMBOL(__udelay);
5701 @@ -112,13 +111,17 @@ EXPORT_SYMBOL_NOVERS(__get_user_4);
5702  EXPORT_SYMBOL(strpbrk);
5703  EXPORT_SYMBOL(strstr);
5704  
5705 +#if !defined(CONFIG_X86_UACCESS_INDIRECT)
5706  EXPORT_SYMBOL(strncpy_from_user);
5707 -EXPORT_SYMBOL(__strncpy_from_user);
5708 +EXPORT_SYMBOL(__direct_strncpy_from_user);
5709  EXPORT_SYMBOL(clear_user);
5710  EXPORT_SYMBOL(__clear_user);
5711  EXPORT_SYMBOL(__copy_from_user_ll);
5712  EXPORT_SYMBOL(__copy_to_user_ll);
5713  EXPORT_SYMBOL(strnlen_user);
5714 +#else /* CONFIG_X86_UACCESS_INDIRECT */
5715 +EXPORT_SYMBOL(direct_csum_partial_copy_generic);
5716 +#endif
5717  
5718  EXPORT_SYMBOL(dma_alloc_coherent);
5719  EXPORT_SYMBOL(dma_free_coherent);
5720 --- linux-2.6.0-test6/arch/i386/kernel/i387.c   2003-06-14 12:18:51.000000000 -0700
5721 +++ 25/arch/i386/kernel/i387.c  2003-10-05 00:36:48.000000000 -0700
5722 @@ -219,6 +219,7 @@ void set_fpu_mxcsr( struct task_struct *
5723  static int convert_fxsr_to_user( struct _fpstate __user *buf,
5724                                         struct i387_fxsave_struct *fxsave )
5725  {
5726 +       struct _fpreg tmp[8]; /* 80 bytes scratch area */
5727         unsigned long env[7];
5728         struct _fpreg __user *to;
5729         struct _fpxreg *from;
5730 @@ -235,23 +236,25 @@ static int convert_fxsr_to_user( struct 
5731         if ( __copy_to_user( buf, env, 7 * sizeof(unsigned long) ) )
5732                 return 1;
5733  
5734 -       to = &buf->_st[0];
5735 +       to = tmp;
5736         from = (struct _fpxreg *) &fxsave->st_space[0];
5737         for ( i = 0 ; i < 8 ; i++, to++, from++ ) {
5738                 unsigned long *t = (unsigned long *)to;
5739                 unsigned long *f = (unsigned long *)from;
5740  
5741 -               if (__put_user(*f, t) ||
5742 -                               __put_user(*(f + 1), t + 1) ||
5743 -                               __put_user(from->exponent, &to->exponent))
5744 -                       return 1;
5745 +               *t = *f;
5746 +               *(t + 1) = *(f+1);
5747 +               to->exponent = from->exponent;
5748         }
5749 +       if (copy_to_user(buf->_st, tmp, sizeof(struct _fpreg [8])))
5750 +               return 1;
5751         return 0;
5752  }
5753  
5754  static int convert_fxsr_from_user( struct i387_fxsave_struct *fxsave,
5755                                           struct _fpstate __user *buf )
5756  {
5757 +       struct _fpreg tmp[8]; /* 80 bytes scratch area */
5758         unsigned long env[7];
5759         struct _fpxreg *to;
5760         struct _fpreg __user *from;
5761 @@ -259,6 +262,8 @@ static int convert_fxsr_from_user( struc
5762  
5763         if ( __copy_from_user( env, buf, 7 * sizeof(long) ) )
5764                 return 1;
5765 +       if (copy_from_user(tmp, buf->_st, sizeof(struct _fpreg [8])))
5766 +               return 1;
5767  
5768         fxsave->cwd = (unsigned short)(env[0] & 0xffff);
5769         fxsave->swd = (unsigned short)(env[1] & 0xffff);
5770 @@ -270,15 +275,14 @@ static int convert_fxsr_from_user( struc
5771         fxsave->fos = env[6];
5772  
5773         to = (struct _fpxreg *) &fxsave->st_space[0];
5774 -       from = &buf->_st[0];
5775 +       from = tmp;
5776         for ( i = 0 ; i < 8 ; i++, to++, from++ ) {
5777                 unsigned long *t = (unsigned long *)to;
5778                 unsigned long *f = (unsigned long *)from;
5779  
5780 -               if (__get_user(*t, f) ||
5781 -                               __get_user(*(t + 1), f + 1) ||
5782 -                               __get_user(to->exponent, &from->exponent))
5783 -                       return 1;
5784 +               *t = *f;
5785 +               *(t + 1) = *(f + 1);
5786 +               to->exponent = from->exponent;
5787         }
5788         return 0;
5789  }
5790 @@ -549,13 +553,3 @@ int dump_task_extended_fpu(struct task_s
5791         }
5792         return fpvalid;
5793  }
5794 -
5795 -
5796 -#ifdef CONFIG_SMP
5797 -void dump_smp_unlazy_fpu(void)
5798 -{
5799 -       unlazy_fpu(current);
5800 -       return;
5801 -}
5802 -#endif
5803 -
5804 --- linux-2.6.0-test6/arch/i386/kernel/i8259.c  2003-06-14 12:18:34.000000000 -0700
5805 +++ 25/arch/i386/kernel/i8259.c 2003-10-05 00:36:20.000000000 -0700
5806 @@ -419,8 +419,10 @@ void __init init_IRQ(void)
5807          * us. (some of these will be overridden and become
5808          * 'special' SMP interrupts)
5809          */
5810 -       for (i = 0; i < NR_IRQS; i++) {
5811 +       for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) {
5812                 int vector = FIRST_EXTERNAL_VECTOR + i;
5813 +               if (i >= NR_IRQS)
5814 +                       break;
5815                 if (vector != SYSCALL_VECTOR) 
5816                         set_intr_gate(vector, interrupt[i]);
5817         }
5818 --- linux-2.6.0-test6/arch/i386/kernel/init_task.c      2003-06-14 12:18:35.000000000 -0700
5819 +++ 25/arch/i386/kernel/init_task.c     2003-10-05 00:36:48.000000000 -0700
5820 @@ -23,7 +23,7 @@ struct mm_struct init_mm = INIT_MM(init_
5821   */
5822  union thread_union init_thread_union 
5823         __attribute__((__section__(".data.init_task"))) =
5824 -               { INIT_THREAD_INFO(init_task) };
5825 +               { INIT_THREAD_INFO(init_task, init_thread_union) };
5826  
5827  /*
5828   * Initial task structure.
5829 @@ -39,5 +39,5 @@ struct task_struct init_task = INIT_TASK
5830   * section. Since TSS's are completely CPU-local, we want them
5831   * on exact cacheline boundaries, to eliminate cacheline ping-pong.
5832   */ 
5833 -struct tss_struct init_tss[NR_CPUS] __cacheline_aligned = { [0 ... NR_CPUS-1] = INIT_TSS };
5834 +struct tss_struct init_tss[NR_CPUS] __attribute__((__section__(".data.tss"))) = { [0 ... NR_CPUS-1] = INIT_TSS };
5835  
5836 --- linux-2.6.0-test6/arch/i386/kernel/io_apic.c        2003-09-27 18:57:43.000000000 -0700
5837 +++ 25/arch/i386/kernel/io_apic.c       2003-10-05 00:36:27.000000000 -0700
5838 @@ -76,6 +76,14 @@ static struct irq_pin_list {
5839         int apic, pin, next;
5840  } irq_2_pin[PIN_MAP_SIZE];
5841  
5842 +#ifdef CONFIG_PCI_USE_VECTOR
5843 +int vector_irq[NR_IRQS] = { [0 ... NR_IRQS -1] = -1};
5844 +#define vector_to_irq(vector)  \
5845 +       (platform_legacy_irq(vector) ? vector : vector_irq[vector])
5846 +#else
5847 +#define vector_to_irq(vector)  (vector)
5848 +#endif
5849 +
5850  /*
5851   * The common case is 1:1 IRQ<->pin mappings. Sometimes there are
5852   * shared ISA-space IRQs, so we have to support them. We are super
5853 @@ -249,7 +257,7 @@ static void clear_IO_APIC (void)
5854                         clear_IO_APIC_pin(apic, pin);
5855  }
5856  
5857 -static void set_ioapic_affinity(unsigned int irq, cpumask_t cpumask)
5858 +static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t cpumask)
5859  {
5860         unsigned long flags;
5861         int pin;
5862 @@ -288,7 +296,7 @@ static void set_ioapic_affinity(unsigned
5863  
5864  extern cpumask_t irq_affinity[NR_IRQS];
5865  
5866 -static cpumask_t __cacheline_aligned pending_irq_balance_cpumask[NR_IRQS];
5867 +cpumask_t __cacheline_aligned pending_irq_balance_cpumask[NR_IRQS];
5868  
5869  #define IRQBALANCE_CHECK_ARCH -999
5870  static int irqbalance_disabled = IRQBALANCE_CHECK_ARCH;
5871 @@ -670,13 +678,11 @@ static int __init irqbalance_disable(cha
5872  
5873  __setup("noirqbalance", irqbalance_disable);
5874  
5875 -static void set_ioapic_affinity(unsigned int irq, cpumask_t mask);
5876 -
5877  static inline void move_irq(int irq)
5878  {
5879         /* note - we hold the desc->lock */
5880         if (unlikely(!cpus_empty(pending_irq_balance_cpumask[irq]))) {
5881 -               set_ioapic_affinity(irq, pending_irq_balance_cpumask[irq]);
5882 +               set_ioapic_affinity_irq(irq, pending_irq_balance_cpumask[irq]);
5883                 cpus_clear(pending_irq_balance_cpumask[irq]);
5884         }
5885  }
5886 @@ -853,7 +859,7 @@ void __init setup_ioapic_dest(cpumask_t 
5887                         if (irq_entry == -1)
5888                                 continue;
5889                         irq = pin_2_irq(irq_entry, ioapic, pin);
5890 -                       set_ioapic_affinity(irq, mask);
5891 +                       set_ioapic_affinity_irq(irq, mask);
5892                 }
5893  
5894         }
5895 @@ -1138,12 +1144,14 @@ static inline int IO_APIC_irq_trigger(in
5896         return 0;
5897  }
5898  
5899 -int irq_vector[NR_IRQS] = { FIRST_DEVICE_VECTOR , 0 };
5900 +u8 *irq_vector;
5901 +int nr_irqs;
5902  
5903 -static int __init assign_irq_vector(int irq)
5904 +#ifndef CONFIG_PCI_USE_VECTOR
5905 +int __init assign_irq_vector(int irq)
5906  {
5907         static int current_vector = FIRST_DEVICE_VECTOR, offset = 0;
5908 -       BUG_ON(irq >= NR_IRQS);
5909 +       BUG_ON(irq >= nr_irqs);
5910         if (IO_APIC_VECTOR(irq) > 0)
5911                 return IO_APIC_VECTOR(irq);
5912  next:
5913 @@ -1157,11 +1165,36 @@ next:
5914         }
5915  
5916         IO_APIC_VECTOR(irq) = current_vector;
5917 +
5918         return current_vector;
5919  }
5920 +#endif
5921  
5922 -static struct hw_interrupt_type ioapic_level_irq_type;
5923 -static struct hw_interrupt_type ioapic_edge_irq_type;
5924 +static struct hw_interrupt_type ioapic_level_type;
5925 +static struct hw_interrupt_type ioapic_edge_type;
5926 +
5927 +#define IOAPIC_AUTO    -1
5928 +#define IOAPIC_EDGE    0
5929 +#define IOAPIC_LEVEL   1
5930 +
5931 +static inline void ioapic_register_intr(int irq, int vector, unsigned long trigger)
5932 +{
5933 +       if (use_pci_vector() && !platform_legacy_irq(irq)) {
5934 +               if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
5935 +                               trigger == IOAPIC_LEVEL)
5936 +                       irq_desc[vector].handler = &ioapic_level_type;
5937 +               else
5938 +                       irq_desc[vector].handler = &ioapic_edge_type;
5939 +               set_intr_gate(vector, interrupt[vector]);
5940 +       } else  {
5941 +               if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
5942 +                               trigger == IOAPIC_LEVEL)
5943 +                       irq_desc[irq].handler = &ioapic_level_type;
5944 +               else
5945 +                       irq_desc[irq].handler = &ioapic_edge_type;
5946 +               set_intr_gate(vector, interrupt[irq]);
5947 +       }
5948 +}
5949  
5950  void __init setup_IO_APIC_irqs(void)
5951  {
5952 @@ -1219,13 +1252,7 @@ void __init setup_IO_APIC_irqs(void)
5953                 if (IO_APIC_IRQ(irq)) {
5954                         vector = assign_irq_vector(irq);
5955                         entry.vector = vector;
5956 -
5957 -                       if (IO_APIC_irq_trigger(irq))
5958 -                               irq_desc[irq].handler = &ioapic_level_irq_type;
5959 -                       else
5960 -                               irq_desc[irq].handler = &ioapic_edge_irq_type;
5961 -
5962 -                       set_intr_gate(vector, interrupt[irq]);
5963 +                       ioapic_register_intr(irq, vector, IOAPIC_AUTO);
5964                 
5965                         if (!apic && (irq < 16))
5966                                 disable_8259A_irq(irq);
5967 @@ -1272,7 +1299,7 @@ void __init setup_ExtINT_IRQ0_pin(unsign
5968          * The timer IRQ doesn't have to know that behind the
5969          * scene we have a 8259A-master in AEOI mode ...
5970          */
5971 -       irq_desc[0].handler = &ioapic_edge_irq_type;
5972 +       irq_desc[0].handler = &ioapic_edge_type;
5973  
5974         /*
5975          * Add it to the IO-APIC irq-routing table:
5976 @@ -1762,9 +1789,6 @@ static int __init timer_irq_works(void)
5977   * that was delayed but this is now handled in the device
5978   * independent code.
5979   */
5980 -#define enable_edge_ioapic_irq unmask_IO_APIC_irq
5981 -
5982 -static void disable_edge_ioapic_irq (unsigned int irq) { /* nothing */ }
5983  
5984  /*
5985   * Starting up a edge-triggered IO-APIC interrupt is
5986 @@ -1775,7 +1799,6 @@ static void disable_edge_ioapic_irq (uns
5987   * This is not complete - we should be able to fake
5988   * an edge even if it isn't on the 8259A...
5989   */
5990 -
5991  static unsigned int startup_edge_ioapic_irq(unsigned int irq)
5992  {
5993         int was_pending = 0;
5994 @@ -1793,8 +1816,6 @@ static unsigned int startup_edge_ioapic_
5995         return was_pending;
5996  }
5997  
5998 -#define shutdown_edge_ioapic_irq       disable_edge_ioapic_irq
5999 -
6000  /*
6001   * Once we have recorded IRQ_PENDING already, we can mask the
6002   * interrupt for real. This prevents IRQ storms from unhandled
6003 @@ -1809,9 +1830,6 @@ static void ack_edge_ioapic_irq(unsigned
6004         ack_APIC_irq();
6005  }
6006  
6007 -static void end_edge_ioapic_irq (unsigned int i) { /* nothing */ }
6008 -
6009 -
6010  /*
6011   * Level triggered interrupts can just be masked,
6012   * and shutting down and starting up the interrupt
6013 @@ -1833,10 +1851,6 @@ static unsigned int startup_level_ioapic
6014         return 0; /* don't check for pending */
6015  }
6016  
6017 -#define shutdown_level_ioapic_irq      mask_IO_APIC_irq
6018 -#define enable_level_ioapic_irq                unmask_IO_APIC_irq
6019 -#define disable_level_ioapic_irq       mask_IO_APIC_irq
6020 -
6021  static void end_level_ioapic_irq (unsigned int irq)
6022  {
6023         unsigned long v;
6024 @@ -1863,6 +1877,7 @@ static void end_level_ioapic_irq (unsign
6025   * The idea is from Manfred Spraul.  --macro
6026   */
6027         i = IO_APIC_VECTOR(irq);
6028 +
6029         v = apic_read(APIC_TMR + ((i & ~0x1f) >> 1));
6030  
6031         ack_APIC_irq();
6032 @@ -1897,7 +1912,57 @@ static void end_level_ioapic_irq (unsign
6033         }
6034  }
6035  
6036 -static void mask_and_ack_level_ioapic_irq (unsigned int irq) { /* nothing */ }
6037 +#ifdef CONFIG_PCI_USE_VECTOR
6038 +static unsigned int startup_edge_ioapic_vector(unsigned int vector)
6039 +{
6040 +       int irq = vector_to_irq(vector);
6041 +
6042 +       return startup_edge_ioapic_irq(irq);
6043 +}
6044 +
6045 +static void ack_edge_ioapic_vector(unsigned int vector)
6046 +{
6047 +       int irq = vector_to_irq(vector);
6048 +
6049 +       ack_edge_ioapic_irq(irq);
6050 +}
6051 +
6052 +static unsigned int startup_level_ioapic_vector (unsigned int vector)
6053 +{
6054 +       int irq = vector_to_irq(vector);
6055 +
6056 +       return startup_level_ioapic_irq (irq);
6057 +}
6058 +
6059 +static void end_level_ioapic_vector (unsigned int vector)
6060 +{
6061 +       int irq = vector_to_irq(vector);
6062 +
6063 +       end_level_ioapic_irq(irq);
6064 +}
6065 +
6066 +static void mask_IO_APIC_vector (unsigned int vector)
6067 +{
6068 +       int irq = vector_to_irq(vector);
6069 +
6070 +       mask_IO_APIC_irq(irq);
6071 +}
6072 +
6073 +static void unmask_IO_APIC_vector (unsigned int vector)
6074 +{
6075 +       int irq = vector_to_irq(vector);
6076 +
6077 +       unmask_IO_APIC_irq(irq);
6078 +}
6079 +
6080 +static void set_ioapic_affinity_vector (unsigned int vector,
6081 +                                       unsigned long cpu_mask)
6082 +{
6083 +       int irq = vector_to_irq(vector);
6084 +
6085 +       set_ioapic_affinity_irq(irq, cpu_mask);
6086 +}
6087 +#endif
6088  
6089  /*
6090   * Level and edge triggered IO-APIC interrupts need different handling,
6091 @@ -1907,26 +1972,25 @@ static void mask_and_ack_level_ioapic_ir
6092   * edge-triggered handler, without risking IRQ storms and other ugly
6093   * races.
6094   */
6095 -
6096 -static struct hw_interrupt_type ioapic_edge_irq_type = {
6097 +static struct hw_interrupt_type ioapic_edge_type = {
6098         .typename       = "IO-APIC-edge",
6099 -       .startup        = startup_edge_ioapic_irq,
6100 -       .shutdown       = shutdown_edge_ioapic_irq,
6101 -       .enable         = enable_edge_ioapic_irq,
6102 -       .disable        = disable_edge_ioapic_irq,
6103 -       .ack            = ack_edge_ioapic_irq,
6104 -       .end            = end_edge_ioapic_irq,
6105 +       .startup        = startup_edge_ioapic,
6106 +       .shutdown       = shutdown_edge_ioapic,
6107 +       .enable         = enable_edge_ioapic,
6108 +       .disable        = disable_edge_ioapic,
6109 +       .ack            = ack_edge_ioapic,
6110 +       .end            = end_edge_ioapic,
6111         .set_affinity   = set_ioapic_affinity,
6112  };
6113  
6114 -static struct hw_interrupt_type ioapic_level_irq_type = {
6115 +static struct hw_interrupt_type ioapic_level_type = {
6116         .typename       = "IO-APIC-level",
6117 -       .startup        = startup_level_ioapic_irq,
6118 -       .shutdown       = shutdown_level_ioapic_irq,
6119 -       .enable         = enable_level_ioapic_irq,
6120 -       .disable        = disable_level_ioapic_irq,
6121 -       .ack            = mask_and_ack_level_ioapic_irq,
6122 -       .end            = end_level_ioapic_irq,
6123 +       .startup        = startup_level_ioapic,
6124 +       .shutdown       = shutdown_level_ioapic,
6125 +       .enable         = enable_level_ioapic,
6126 +       .disable        = disable_level_ioapic,
6127 +       .ack            = mask_and_ack_level_ioapic,
6128 +       .end            = end_level_ioapic,
6129         .set_affinity   = set_ioapic_affinity,
6130  };
6131  
6132 @@ -1946,7 +2010,13 @@ static inline void init_IO_APIC_traps(vo
6133          * 0x80, because int 0x80 is hm, kind of importantish. ;)
6134          */
6135         for (irq = 0; irq < NR_IRQS ; irq++) {
6136 -               if (IO_APIC_IRQ(irq) && !IO_APIC_VECTOR(irq)) {
6137 +               int tmp = irq;
6138 +               if (use_pci_vector()) {
6139 +                       if (!platform_legacy_irq(tmp))
6140 +                               if ((tmp = vector_to_irq(tmp)) == -1)
6141 +                                       continue;
6142 +               }
6143 +               if (IO_APIC_IRQ(tmp) && !IO_APIC_VECTOR(tmp)) {
6144                         /*
6145                          * Hmm.. We don't have an entry for this,
6146                          * so default to an old-fashioned 8259
6147 @@ -2378,10 +2448,12 @@ int io_apic_set_pci_routing (int ioapic,
6148                 "IRQ %d Mode:%i Active:%i)\n", ioapic, 
6149                 mp_ioapics[ioapic].mpc_apicid, pin, entry.vector, irq, edge_level, active_high_low);
6150  
6151 +       if (use_pci_vector() && !platform_legacy_irq(irq))
6152 +               irq = IO_APIC_VECTOR(irq);
6153         if (edge_level) {
6154 -       irq_desc[irq].handler = &ioapic_level_irq_type;
6155 +               irq_desc[irq].handler = &ioapic_level_type;
6156         } else {
6157 -               irq_desc[irq].handler = &ioapic_edge_irq_type;
6158 +               irq_desc[irq].handler = &ioapic_edge_type;
6159         }
6160  
6161         set_intr_gate(entry.vector, interrupt[irq]);
6162 --- linux-2.6.0-test6/arch/i386/kernel/irq.c    2003-08-22 19:23:40.000000000 -0700
6163 +++ 25/arch/i386/kernel/irq.c   2003-10-05 00:33:50.000000000 -0700
6164 @@ -44,6 +44,7 @@
6165  #include <asm/delay.h>
6166  #include <asm/desc.h>
6167  #include <asm/irq.h>
6168 +#include <asm/kgdb.h>
6169  
6170  /*
6171   * Linux has a controller-independent x86 interrupt architecture.
6172 @@ -499,6 +500,17 @@ out:
6173  
6174         irq_exit();
6175  
6176 +#ifdef CONFIG_KGDB
6177 +       /*
6178 +        * We need to do this after clearing out of all the interrupt
6179 +        * machinery because kgdb will reenter the NIC driver and the IRQ
6180 +        * system.  synchronize_irq() (at least) will deadlock.
6181 +        */
6182 +       if (kgdb_eth_need_breakpoint[smp_processor_id()]) {
6183 +               kgdb_eth_need_breakpoint[smp_processor_id()] = 0;
6184 +               BREAKPOINT;
6185 +       }
6186 +#endif
6187         return 1;
6188  }
6189  
6190 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
6191 +++ 25/arch/i386/kernel/kgdb_stub.c     2003-10-05 00:33:51.000000000 -0700
6192 @@ -0,0 +1,2492 @@
6193 +/*
6194 + *
6195 + * This program is free software; you can redistribute it and/or modify it
6196 + * under the terms of the GNU General Public License as published by the
6197 + * Free Software Foundation; either version 2, or (at your option) any
6198 + * later version.
6199 + *
6200 + * This program is distributed in the hope that it will be useful, but
6201 + * WITHOUT ANY WARRANTY; without even the implied warranty of
6202 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the GNU
6203 + * General Public License for more details.
6204 + *
6205 + */
6206 +
6207 +/*
6208 + * Copyright (c) 2000 VERITAS Software Corporation.
6209 + *
6210 + */
6211 +/****************************************************************************
6212 + *  Header: remcom.c,v 1.34 91/03/09 12:29:49 glenne Exp $
6213 + *
6214 + *  Module name: remcom.c $
6215 + *  Revision: 1.34 $
6216 + *  Date: 91/03/09 12:29:49 $
6217 + *  Contributor:     Lake Stevens Instrument Division$
6218 + *
6219 + *  Description:     low level support for gdb debugger. $
6220 + *
6221 + *  Considerations:  only works on target hardware $
6222 + *
6223 + *  Written by:             Glenn Engel $
6224 + *  Updated by:             David Grothe <dave@gcom.com>
6225 + *  Updated by:             Robert Walsh <rjwalsh@durables.org>
6226 + *  Updated by:             wangdi <wangdi@clusterfs.com>
6227 + *  ModuleState:     Experimental $
6228 + *
6229 + *  NOTES:          See Below $
6230 + *
6231 + *  Modified for 386 by Jim Kingdon, Cygnus Support.
6232 + *  Compatibility with 2.1.xx kernel by David Grothe <dave@gcom.com>
6233 + *
6234 + *  Changes to allow auto initilization.  All that is needed is that it
6235 + *  be linked with the kernel and a break point (int 3) be executed.
6236 + *  The header file <asm/kgdb.h> defines BREAKPOINT to allow one to do
6237 + *  this. It should also be possible, once the interrupt system is up, to
6238 + *  call putDebugChar("+").  Once this is done, the remote debugger should
6239 + *  get our attention by sending a ^C in a packet. George Anzinger
6240 + *  <george@mvista.com>
6241 + *  Integrated into 2.2.5 kernel by Tigran Aivazian <tigran@sco.com>
6242 + *  Added thread support, support for multiple processors,
6243 + *     support for ia-32(x86) hardware debugging.
6244 + *     Amit S. Kale ( akale@veritas.com )
6245 + *
6246 + *  Modified to support debugging over ethernet by Robert Walsh
6247 + *  <rjwalsh@durables.org> and wangdi <wangdi@clusterfs.com>, based on
6248 + *  code by San Mehat.
6249 + *
6250 + *
6251 + *  To enable debugger support, two things need to happen.  One, a
6252 + *  call to set_debug_traps() is necessary in order to allow any breakpoints
6253 + *  or error conditions to be properly intercepted and reported to gdb.
6254 + *  Two, a breakpoint needs to be generated to begin communication.  This
6255 + *  is most easily accomplished by a call to breakpoint().  Breakpoint()
6256 + *  simulates a breakpoint by executing an int 3.
6257 + *
6258 + *************
6259 + *
6260 + *    The following gdb commands are supported:
6261 + *
6262 + * command         function                               Return value
6263 + *
6264 + *    g                    return the value of the CPU registers  hex data or ENN
6265 + *    G                    set the value of the CPU registers     OK or ENN
6266 + *
6267 + *    mAA..AA,LLLL  Read LLLL bytes at address AA..AA     hex data or ENN
6268 + *    MAA..AA,LLLL: Write LLLL bytes at address AA.AA     OK or ENN
6269 + *
6270 + *    c                    Resume at current address              SNN   ( signal NN)
6271 + *    cAA..AA      Continue at address AA..AA             SNN
6272 + *
6273 + *    s                    Step one instruction                   SNN
6274 + *    sAA..AA      Step one instruction from AA..AA       SNN
6275 + *
6276 + *    k                    kill
6277 + *
6278 + *    ?                    What was the last sigval ?             SNN   (signal NN)
6279 + *
6280 + * All commands and responses are sent with a packet which includes a
6281 + * checksum.  A packet consists of
6282 + *
6283 + * $<packet info>#<checksum>.
6284 + *
6285 + * where
6286 + * <packet info> :: <characters representing the command or response>
6287 + * <checksum>   :: < two hex digits computed as modulo 256 sum of <packetinfo>>
6288 + *
6289 + * When a packet is received, it is first acknowledged with either '+' or '-'.
6290 + * '+' indicates a successful transfer.         '-' indicates a failed transfer.
6291 + *
6292 + * Example:
6293 + *
6294 + * Host:                 Reply:
6295 + * $m0,10#2a              +$00010203040506070809101112131415#42
6296 + *
6297 + ****************************************************************************/
6298 +#define KGDB_VERSION "<20030915.1651.33>"
6299 +#include <linux/config.h>
6300 +#include <linux/types.h>
6301 +#include <asm/string.h>                /* for strcpy */
6302 +#include <linux/kernel.h>
6303 +#include <linux/sched.h>
6304 +#include <asm/vm86.h>
6305 +#include <asm/system.h>
6306 +#include <asm/ptrace.h>                /* for linux pt_regs struct */
6307 +#include <asm/kgdb_local.h>
6308 +#include <linux/list.h>
6309 +#include <asm/atomic.h>
6310 +#include <asm/processor.h>
6311 +#include <linux/irq.h>
6312 +#include <asm/desc.h>
6313 +#include <linux/inet.h>
6314 +#include <linux/kallsyms.h>
6315 +
6316 +/************************************************************************
6317 + *
6318 + * external low-level support routines
6319 + */
6320 +typedef void (*Function) (void);       /* pointer to a function */
6321 +
6322 +/* Thread reference */
6323 +typedef unsigned char threadref[8];
6324 +
6325 +extern int tty_putDebugChar(int);     /* write a single character      */
6326 +extern int tty_getDebugChar(void);    /* read and return a single char */
6327 +extern void tty_flushDebugChar(void); /* flush pending characters      */
6328 +extern int eth_putDebugChar(int);     /* write a single character      */
6329 +extern int eth_getDebugChar(void);    /* read and return a single char */
6330 +extern void eth_flushDebugChar(void); /* flush pending characters      */
6331 +extern void kgdb_eth_set_trapmode(int);
6332 +extern void kgdb_eth_reply_arp(void);   /*send arp request */
6333 +extern volatile int kgdb_eth_is_initializing;
6334 +
6335 +
6336 +/************************************************************************/
6337 +/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
6338 +/* at least NUMREGBYTES*2 are needed for register packets */
6339 +/* Longer buffer is needed to list all threads */
6340 +#define BUFMAX 400
6341 +
6342 +char *kgdb_version = KGDB_VERSION;
6343 +
6344 +/*  debug >  0 prints ill-formed commands in valid packets & checksum errors */
6345 +int debug_regs = 0;            /* set to non-zero to print registers */
6346 +
6347 +/* filled in by an external module */
6348 +char *gdb_module_offsets;
6349 +
6350 +static const char hexchars[] = "0123456789abcdef";
6351 +
6352 +/* Number of bytes of registers.  */
6353 +#define NUMREGBYTES 64
6354 +/*
6355 + * Note that this register image is in a different order than
6356 + * the register image that Linux produces at interrupt time.
6357 + *
6358 + * Linux's register image is defined by struct pt_regs in ptrace.h.
6359 + * Just why GDB uses a different order is a historical mystery.
6360 + */
6361 +enum regnames { _EAX,          /* 0 */
6362 +       _ECX,                   /* 1 */
6363 +       _EDX,                   /* 2 */
6364 +       _EBX,                   /* 3 */
6365 +       _ESP,                   /* 4 */
6366 +       _EBP,                   /* 5 */
6367 +       _ESI,                   /* 6 */
6368 +       _EDI,                   /* 7 */
6369 +       _PC /* 8 also known as eip */ ,
6370 +       _PS /* 9 also known as eflags */ ,
6371 +       _CS,                    /* 10 */
6372 +       _SS,                    /* 11 */
6373 +       _DS,                    /* 12 */
6374 +       _ES,                    /* 13 */
6375 +       _FS,                    /* 14 */
6376 +       _GS                     /* 15 */
6377 +};
6378 +
6379 +/***************************  ASSEMBLY CODE MACROS *************************/
6380 +/*
6381 + * Put the error code here just in case the user cares.
6382 + * Likewise, the vector number here (since GDB only gets the signal
6383 + * number through the usual means, and that's not very specific).
6384 + * The called_from is the return address so he can tell how we entered kgdb.
6385 + * This will allow him to seperate out the various possible entries.
6386 + */
6387 +#define REMOTE_DEBUG 0         /* set != to turn on printing (also available in info) */
6388 +
6389 +#define PID_MAX PID_MAX_DEFAULT
6390 +
6391 +#ifdef CONFIG_SMP
6392 +void smp_send_nmi_allbutself(void);
6393 +#define IF_SMP(x) x
6394 +#undef MAX_NO_CPUS
6395 +#ifndef CONFIG_NO_KGDB_CPUS
6396 +#define CONFIG_NO_KGDB_CPUS 2
6397 +#endif
6398 +#if CONFIG_NO_KGDB_CPUS > NR_CPUS
6399 +#define MAX_NO_CPUS NR_CPUS
6400 +#else
6401 +#define MAX_NO_CPUS CONFIG_NO_KGDB_CPUS
6402 +#endif
6403 +#define hold_init hold_on_sstep: 1,
6404 +#define MAX_CPU_MASK (unsigned long)((1LL << MAX_NO_CPUS) - 1LL)
6405 +#define NUM_CPUS num_online_cpus()
6406 +#else
6407 +#define IF_SMP(x)
6408 +#define hold_init
6409 +#undef MAX_NO_CPUS
6410 +#define MAX_NO_CPUS 1
6411 +#define NUM_CPUS 1
6412 +#endif
6413 +#define NOCPU (struct task_struct *)0xbad1fbad
6414 +/* *INDENT-OFF*         */
6415 +struct kgdb_info {
6416 +       int used_malloc;
6417 +       void *called_from;
6418 +       long long entry_tsc;
6419 +       int errcode;
6420 +       int vector;
6421 +       int print_debug_info;
6422 +#ifdef CONFIG_SMP
6423 +       int hold_on_sstep;
6424 +       struct {
6425 +               volatile struct task_struct *task;
6426 +               int pid;
6427 +               int hold;
6428 +               struct pt_regs *regs;
6429 +       } cpus_waiting[MAX_NO_CPUS];
6430 +#endif
6431 +} kgdb_info = {hold_init print_debug_info:REMOTE_DEBUG, vector:-1};
6432 +
6433 +/* *INDENT-ON* */
6434 +
6435 +#define used_m kgdb_info.used_malloc
6436 +/*
6437 + * This is little area we set aside to contain the stack we
6438 + * need to build to allow gdb to call functions.  We use one
6439 + * per cpu to avoid locking issues.  We will do all this work
6440 + * with interrupts off so that should take care of the protection
6441 + * issues.
6442 + */
6443 +#define LOOKASIDE_SIZE 200     /* should be more than enough */
6444 +#define MALLOC_MAX   200       /* Max malloc size */
6445 +struct {
6446 +       unsigned int esp;
6447 +       int array[LOOKASIDE_SIZE];
6448 +} fn_call_lookaside[MAX_NO_CPUS];
6449 +
6450 +static int trap_cpu;
6451 +static unsigned int OLD_esp;
6452 +
6453 +#define END_OF_LOOKASIDE  &fn_call_lookaside[trap_cpu].array[LOOKASIDE_SIZE]
6454 +#define IF_BIT 0x200
6455 +#define TF_BIT 0x100
6456 +
6457 +#define MALLOC_ROUND 8-1
6458 +
6459 +static char malloc_array[MALLOC_MAX];
6460 +IF_SMP(static void to_gdb(const char *mess));
6461 +void *
6462 +malloc(int size)
6463 +{
6464 +
6465 +       if (size <= (MALLOC_MAX - used_m)) {
6466 +               int old_used = used_m;
6467 +               used_m += ((size + MALLOC_ROUND) & (~MALLOC_ROUND));
6468 +               return &malloc_array[old_used];
6469 +       } else {
6470 +               return NULL;
6471 +       }
6472 +}
6473 +
6474 +/*
6475 + * I/O dispatch functions...
6476 + * Based upon kgdb_eth, either call the ethernet
6477 + * handler or the serial one..
6478 + */
6479 +void
6480 +putDebugChar(int c)
6481 +{
6482 +       if (kgdb_eth == -1) {
6483 +               tty_putDebugChar(c);
6484 +       } else {
6485 +               eth_putDebugChar(c);
6486 +       }
6487 +}
6488 +
6489 +int
6490 +getDebugChar(void)
6491 +{
6492 +       if (kgdb_eth == -1) {
6493 +               return tty_getDebugChar();
6494 +       } else {
6495 +               return eth_getDebugChar();
6496 +       }
6497 +}
6498 +
6499 +void
6500 +flushDebugChar(void)
6501 +{
6502 +       if (kgdb_eth == -1) {
6503 +               tty_flushDebugChar();
6504 +       } else {
6505 +               eth_flushDebugChar();
6506 +       }
6507 +}
6508 +
6509 +/*
6510 + * Gdb calls functions by pushing agruments, including a return address
6511 + * on the stack and the adjusting EIP to point to the function.         The
6512 + * whole assumption in GDB is that we are on a different stack than the
6513 + * one the "user" i.e. code that hit the break point, is on.  This, of
6514 + * course is not true in the kernel.  Thus various dodges are needed to
6515 + * do the call without directly messing with EIP (which we can not change
6516 + * as it is just a location and not a register.         To adjust it would then
6517 + * require that we move every thing below EIP up or down as needed.  This
6518 + * will not work as we may well have stack relative pointer on the stack
6519 + * (such as the pointer to regs, for example).
6520 +
6521 + * So here is what we do:
6522 + * We detect gdb attempting to store into the stack area and instead, store
6523 + * into the fn_call_lookaside.array at the same relative location as if it
6524 + * were the area ESP pointed at.  We also trap ESP modifications
6525 + * and uses these to adjust fn_call_lookaside.esp.  On entry
6526 + * fn_call_lookaside.esp will be set to point at the last entry in
6527 + * fn_call_lookaside.array.  This allows us to check if it has changed, and
6528 + * if so, on exit, we add the registers we will use to do the move and a
6529 + * trap/ interrupt return exit sequence.  We then adjust the eflags in the
6530 + * regs array (remember we now have a copy in the fn_call_lookaside.array) to
6531 + * kill the interrupt bit, AND we change EIP to point at our set up stub.
6532 + * As part of the register set up we preset the registers to point at the
6533 + * begining and end of the fn_call_lookaside.array, so all the stub needs to
6534 + * do is move words from the array to the stack until ESP= the desired value
6535 + * then do the rti.  This will then transfer to the desired function with
6536 + * all the correct registers.  Nifty huh?
6537 + */
6538 +extern asmlinkage void fn_call_stub(void);
6539 +extern asmlinkage void fn_rtn_stub(void);
6540 +/*                                        *INDENT-OFF*  */
6541 +__asm__("fn_rtn_stub:\n\t"
6542 +       "movl %eax,%esp\n\t"
6543 +       "fn_call_stub:\n\t"
6544 +       "1:\n\t"
6545 +       "addl $-4,%ebx\n\t"
6546 +       "movl (%ebx), %eax\n\t"
6547 +       "pushl %eax\n\t"
6548 +       "cmpl %esp,%ecx\n\t"
6549 +       "jne  1b\n\t"
6550 +       "popl %eax\n\t"
6551 +       "popl %ebx\n\t"
6552 +       "popl %ecx\n\t"
6553 +       "iret \n\t");
6554 +/*                                          *INDENT-ON*  */
6555 +#define gdb_i386vector kgdb_info.vector
6556 +#define gdb_i386errcode kgdb_info.errcode
6557 +#define waiting_cpus   kgdb_info.cpus_waiting
6558 +#define remote_debug   kgdb_info.print_debug_info
6559 +#define hold_cpu(cpu)  kgdb_info.cpus_waiting[cpu].hold
6560 +/* gdb locks */
6561 +
6562 +#ifdef CONFIG_SMP
6563 +static int in_kgdb_called;
6564 +static spinlock_t waitlocks[MAX_NO_CPUS] =
6565 +    {[0 ... MAX_NO_CPUS - 1] = SPIN_LOCK_UNLOCKED };
6566 +/*
6567 + * The following array has the thread pointer of each of the "other"
6568 + * cpus.  We make it global so it can be seen by gdb.
6569 + */
6570 +volatile int in_kgdb_entry_log[MAX_NO_CPUS];
6571 +volatile struct pt_regs *in_kgdb_here_log[MAX_NO_CPUS];
6572 +/*
6573 +static spinlock_t continuelocks[MAX_NO_CPUS];
6574 +*/
6575 +spinlock_t kgdb_spinlock = SPIN_LOCK_UNLOCKED;
6576 +/* waiters on our spinlock plus us */
6577 +static atomic_t spinlock_waiters = ATOMIC_INIT(1);
6578 +static int spinlock_count = 0;
6579 +static int spinlock_cpu = 0;
6580 +/*
6581 + * Note we use nested spin locks to account for the case where a break
6582 + * point is encountered when calling a function by user direction from
6583 + * kgdb. Also there is the memory exception recursion to account for.
6584 + * Well, yes, but this lets other cpus thru too.  Lets add a
6585 + * cpu id to the lock.
6586 + */
6587 +#define KGDB_SPIN_LOCK(x) if( spinlock_count == 0 || \
6588 +                             spinlock_cpu != smp_processor_id()){\
6589 +                                     atomic_inc(&spinlock_waiters); \
6590 +                                     while (! spin_trylock(x)) {\
6591 +                                           in_kgdb(&regs);\
6592 +                                     }\
6593 +                                     atomic_dec(&spinlock_waiters); \
6594 +                                     spinlock_count = 1; \
6595 +                                     spinlock_cpu = smp_processor_id(); \
6596 +                         }else{  \
6597 +                                     spinlock_count++; \
6598 +                         }
6599 +#define KGDB_SPIN_UNLOCK(x) if( --spinlock_count == 0) spin_unlock(x)
6600 +#else
6601 +unsigned kgdb_spinlock = 0;
6602 +#define KGDB_SPIN_LOCK(x) --*x
6603 +#define KGDB_SPIN_UNLOCK(x) ++*x
6604 +#endif
6605 +
6606 +int
6607 +hex(char ch)
6608 +{
6609 +       if ((ch >= 'a') && (ch <= 'f'))
6610 +               return (ch - 'a' + 10);
6611 +       if ((ch >= '0') && (ch <= '9'))
6612 +               return (ch - '0');
6613 +       if ((ch >= 'A') && (ch <= 'F'))
6614 +               return (ch - 'A' + 10);
6615 +       return (-1);
6616 +}
6617 +
6618 +/* scan for the sequence $<data>#<checksum>    */
6619 +void
6620 +getpacket(char *buffer)
6621 +{
6622 +       unsigned char checksum;
6623 +       unsigned char xmitcsum;
6624 +       int i;
6625 +       int count;
6626 +       char ch;
6627 +
6628 +       do {
6629 +               /* wait around for the start character, ignore all other characters */
6630 +               while ((ch = (getDebugChar() & 0x7f)) != '$') ;
6631 +               checksum = 0;
6632 +               xmitcsum = -1;
6633 +
6634 +               count = 0;
6635 +
6636 +               /* now, read until a # or end of buffer is found */
6637 +               while (count < BUFMAX) {
6638 +                       ch = getDebugChar() & 0x7f;
6639 +                       if (ch == '#')
6640 +                               break;
6641 +                       checksum = checksum + ch;
6642 +                       buffer[count] = ch;
6643 +                       count = count + 1;
6644 +               }
6645 +               buffer[count] = 0;
6646 +
6647 +               if (ch == '#') {
6648 +                       xmitcsum = hex(getDebugChar() & 0x7f) << 4;
6649 +                       xmitcsum += hex(getDebugChar() & 0x7f);
6650 +                       if ((remote_debug) && (checksum != xmitcsum)) {
6651 +                               printk
6652 +                                   ("bad checksum.     My count = 0x%x, sent=0x%x. buf=%s\n",
6653 +                                    checksum, xmitcsum, buffer);
6654 +                       }
6655 +
6656 +                       if (checksum != xmitcsum)
6657 +                               putDebugChar('-');      /* failed checksum */
6658 +                       else {
6659 +                               putDebugChar('+');      /* successful transfer */
6660 +                               /* if a sequence char is present, reply the sequence ID */
6661 +                               if (buffer[2] == ':') {
6662 +                                       putDebugChar(buffer[0]);
6663 +                                       putDebugChar(buffer[1]);
6664 +                                       /* remove sequence chars from buffer */
6665 +                                       count = strlen(buffer);
6666 +                                       for (i = 3; i <= count; i++)
6667 +                                               buffer[i - 3] = buffer[i];
6668 +                               }
6669 +                       }
6670 +               }
6671 +       } while (checksum != xmitcsum);
6672 +
6673 +       if (remote_debug)
6674 +               printk("R:%s\n", buffer);
6675 +       flushDebugChar();
6676 +}
6677 +
6678 +/* send the packet in buffer.  */
6679 +
6680 +void
6681 +putpacket(char *buffer)
6682 +{
6683 +       unsigned char checksum;
6684 +       int count;
6685 +       char ch;
6686 +
6687 +       /*  $<packet info>#<checksum>. */
6688 +
6689 +       if (kgdb_eth == -1) {
6690 +               do {
6691 +                       if (remote_debug)
6692 +                               printk("T:%s\n", buffer);
6693 +                       putDebugChar('$');
6694 +                       checksum = 0;
6695 +                       count = 0;
6696 +
6697 +                       while ((ch = buffer[count])) {
6698 +                               putDebugChar(ch);
6699 +                               checksum += ch;
6700 +                               count += 1;
6701 +                       }
6702 +
6703 +                       putDebugChar('#');
6704 +                       putDebugChar(hexchars[checksum >> 4]);
6705 +                       putDebugChar(hexchars[checksum % 16]);
6706 +                       flushDebugChar();
6707 +
6708 +               } while ((getDebugChar() & 0x7f) != '+');
6709 +       } else {
6710 +               /*
6711 +                * For udp, we can not transfer too much bytes once.
6712 +                * We only transfer MAX_SEND_COUNT size bytes each time
6713 +                */
6714 +
6715 +#define MAX_SEND_COUNT 30
6716 +
6717 +               int send_count = 0, i = 0;
6718 +               char send_buf[MAX_SEND_COUNT];
6719 +
6720 +               do {
6721 +                       if (remote_debug)
6722 +                               printk("T:%s\n", buffer);
6723 +                       putDebugChar('$');
6724 +                       checksum = 0;
6725 +                       count = 0;
6726 +                       send_count = 0;
6727 +                       while ((ch = buffer[count])) {
6728 +                               if (send_count >= MAX_SEND_COUNT) {
6729 +                                       for(i = 0; i < MAX_SEND_COUNT; i++) {
6730 +                                               putDebugChar(send_buf[i]);
6731 +                                       }
6732 +                                       flushDebugChar();
6733 +                                       send_count = 0;
6734 +                               } else {
6735 +                                       send_buf[send_count] = ch;
6736 +                                       checksum += ch;
6737 +                                       count ++;
6738 +                                       send_count++;
6739 +                               }
6740 +                       }
6741 +                       for(i = 0; i < send_count; i++)
6742 +                               putDebugChar(send_buf[i]);
6743 +                       putDebugChar('#');
6744 +                       putDebugChar(hexchars[checksum >> 4]);
6745 +                       putDebugChar(hexchars[checksum % 16]);
6746 +                       flushDebugChar();
6747 +               } while ((getDebugChar() & 0x7f) != '+');
6748 +       }
6749 +}
6750 +
6751 +static char remcomInBuffer[BUFMAX];
6752 +static char remcomOutBuffer[BUFMAX];
6753 +static short error;
6754 +
6755 +void
6756 +debug_error(char *format, char *parm)
6757 +{
6758 +       if (remote_debug)
6759 +               printk(format, parm);
6760 +}
6761 +
6762 +static void
6763 +print_regs(struct pt_regs *regs)
6764 +{
6765 +       printk("EAX=%08lx ", regs->eax);
6766 +       printk("EBX=%08lx ", regs->ebx);
6767 +       printk("ECX=%08lx ", regs->ecx);
6768 +       printk("EDX=%08lx ", regs->edx);
6769 +       printk("\n");
6770 +       printk("ESI=%08lx ", regs->esi);
6771 +       printk("EDI=%08lx ", regs->edi);
6772 +       printk("EBP=%08lx ", regs->ebp);
6773 +       printk("ESP=%08lx ", (long) &regs->esp);
6774 +       printk("\n");
6775 +       printk(" DS=%08x ", regs->xds);
6776 +       printk(" ES=%08x ", regs->xes);
6777 +       printk(" SS=%08x ", __KERNEL_DS);
6778 +       printk(" FL=%08lx ", regs->eflags);
6779 +       printk("\n");
6780 +       printk(" CS=%08x ", regs->xcs);
6781 +       printk(" IP=%08lx ", regs->eip);
6782 +#if 0
6783 +       printk(" FS=%08x ", regs->fs);
6784 +       printk(" GS=%08x ", regs->gs);
6785 +#endif
6786 +       printk("\n");
6787 +
6788 +}                              /* print_regs */
6789 +
6790 +#define NEW_esp fn_call_lookaside[trap_cpu].esp
6791 +
6792 +static void
6793 +regs_to_gdb_regs(int *gdb_regs, struct pt_regs *regs)
6794 +{
6795 +       gdb_regs[_EAX] = regs->eax;
6796 +       gdb_regs[_EBX] = regs->ebx;
6797 +       gdb_regs[_ECX] = regs->ecx;
6798 +       gdb_regs[_EDX] = regs->edx;
6799 +       gdb_regs[_ESI] = regs->esi;
6800 +       gdb_regs[_EDI] = regs->edi;
6801 +       gdb_regs[_EBP] = regs->ebp;
6802 +       gdb_regs[_DS] = regs->xds;
6803 +       gdb_regs[_ES] = regs->xes;
6804 +       gdb_regs[_PS] = regs->eflags;
6805 +       gdb_regs[_CS] = regs->xcs;
6806 +       gdb_regs[_PC] = regs->eip;
6807 +       /* Note, as we are a debugging the kernel, we will always
6808 +        * trap in kernel code, this means no priviledge change,
6809 +        * and so the pt_regs structure is not completely valid.  In a non
6810 +        * privilege change trap, only EFLAGS, CS and EIP are put on the stack,
6811 +        * SS and ESP are not stacked, this means that the last 2 elements of
6812 +        * pt_regs is not valid (they would normally refer to the user stack)
6813 +        * also, using regs+1 is no good because you end up will a value that is
6814 +        * 2 longs (8) too high.  This used to cause stepping over functions
6815 +        * to fail, so my fix is to use the address of regs->esp, which
6816 +        * should point at the end of the stack frame.  Note I have ignored
6817 +        * completely exceptions that cause an error code to be stacked, such
6818 +        * as double fault.  Stuart Hughes, Zentropix.
6819 +        * original code: gdb_regs[_ESP] =  (int) (regs + 1) ;
6820 +
6821 +        * this is now done on entry and moved to OLD_esp (as well as NEW_esp).
6822 +        */
6823 +       gdb_regs[_ESP] = NEW_esp;
6824 +       gdb_regs[_SS] = __KERNEL_DS;
6825 +       gdb_regs[_FS] = 0xFFFF;
6826 +       gdb_regs[_GS] = 0xFFFF;
6827 +}                              /* regs_to_gdb_regs */
6828 +
6829 +static void
6830 +gdb_regs_to_regs(int *gdb_regs, struct pt_regs *regs)
6831 +{
6832 +       regs->eax = gdb_regs[_EAX];
6833 +       regs->ebx = gdb_regs[_EBX];
6834 +       regs->ecx = gdb_regs[_ECX];
6835 +       regs->edx = gdb_regs[_EDX];
6836 +       regs->esi = gdb_regs[_ESI];
6837 +       regs->edi = gdb_regs[_EDI];
6838 +       regs->ebp = gdb_regs[_EBP];
6839 +       regs->xds = gdb_regs[_DS];
6840 +       regs->xes = gdb_regs[_ES];
6841 +       regs->eflags = gdb_regs[_PS];
6842 +       regs->xcs = gdb_regs[_CS];
6843 +       regs->eip = gdb_regs[_PC];
6844 +       NEW_esp = gdb_regs[_ESP];       /* keep the value */
6845 +#if 0                          /* can't change these */
6846 +       regs->esp = gdb_regs[_ESP];
6847 +       regs->xss = gdb_regs[_SS];
6848 +       regs->fs = gdb_regs[_FS];
6849 +       regs->gs = gdb_regs[_GS];
6850 +#endif
6851 +
6852 +}                              /* gdb_regs_to_regs */
6853 +extern void scheduling_functions_start_here(void);
6854 +extern void scheduling_functions_end_here(void);
6855 +#define first_sched    ((unsigned long) scheduling_functions_start_here)
6856 +#define last_sched     ((unsigned long) scheduling_functions_end_here)
6857 +
6858 +int thread_list = 0;
6859 +
6860 +void
6861 +get_gdb_regs(struct task_struct *p, struct pt_regs *regs, int *gdb_regs)
6862 +{
6863 +       unsigned long stack_page;
6864 +       int count = 0;
6865 +       IF_SMP(int i);
6866 +       if (!p || p == current) {
6867 +               regs_to_gdb_regs(gdb_regs, regs);
6868 +               return;
6869 +       }
6870 +#ifdef CONFIG_SMP
6871 +       for (i = 0; i < MAX_NO_CPUS; i++) {
6872 +               if (p == kgdb_info.cpus_waiting[i].task) {
6873 +                       regs_to_gdb_regs(gdb_regs,
6874 +                                        kgdb_info.cpus_waiting[i].regs);
6875 +                       gdb_regs[_ESP] =
6876 +                           (int) &kgdb_info.cpus_waiting[i].regs->esp;
6877 +
6878 +                       return;
6879 +               }
6880 +       }
6881 +#endif
6882 +       memset(gdb_regs, 0, NUMREGBYTES);
6883 +       gdb_regs[_ESP] = p->thread.esp;
6884 +       gdb_regs[_PC] = p->thread.eip;
6885 +       gdb_regs[_EBP] = *(int *) gdb_regs[_ESP];
6886 +       gdb_regs[_EDI] = *(int *) (gdb_regs[_ESP] + 4);
6887 +       gdb_regs[_ESI] = *(int *) (gdb_regs[_ESP] + 8);
6888 +
6889 +/*
6890 + * This code is to give a more informative notion of where a process
6891 + * is waiting. It is used only when the user asks for a thread info
6892 + * list.  If he then switches to the thread, s/he will find the task
6893 + * is in schedule, but a back trace should show the same info we come
6894 + * up with.  This code was shamelessly purloined from process.c.  It was
6895 + * then enhanced to provide more registers than simply the program
6896 + * counter.
6897 + */
6898 +
6899 +       if (!thread_list) {
6900 +               return;
6901 +       }
6902 +
6903 +       if (p->state == TASK_RUNNING)
6904 +               return;
6905 +       stack_page = (unsigned long) p->thread_info;
6906 +       if (gdb_regs[_ESP] < stack_page || gdb_regs[_ESP] > 8188 + stack_page)
6907 +               return;
6908 +       /* include/asm-i386/system.h:switch_to() pushes ebp last. */
6909 +       do {
6910 +               if (gdb_regs[_EBP] < stack_page ||
6911 +                   gdb_regs[_EBP] > 8184 + stack_page)
6912 +                       return;
6913 +               gdb_regs[_PC] = *(unsigned long *) (gdb_regs[_EBP] + 4);
6914 +               gdb_regs[_ESP] = gdb_regs[_EBP] + 8;
6915 +               gdb_regs[_EBP] = *(unsigned long *) gdb_regs[_EBP];
6916 +               if (gdb_regs[_PC] < first_sched || gdb_regs[_PC] >= last_sched)
6917 +                       return;
6918 +       } while (count++ < 16);
6919 +       return;
6920 +}
6921 +
6922 +/* Indicate to caller of mem2hex or hex2mem that there has been an
6923 +   error.  */
6924 +static volatile int mem_err = 0;
6925 +static volatile int mem_err_expected = 0;
6926 +static volatile int mem_err_cnt = 0;
6927 +static int garbage_loc = -1;
6928 +
6929 +int
6930 +get_char(char *addr)
6931 +{
6932 +       return *addr;
6933 +}
6934 +
6935 +void
6936 +set_char(char *addr, int val, int may_fault)
6937 +{
6938 +       /*
6939 +        * This code traps references to the area mapped to the kernel
6940 +        * stack as given by the regs and, instead, stores to the
6941 +        * fn_call_lookaside[cpu].array
6942 +        */
6943 +       if (may_fault &&
6944 +           (unsigned int) addr < OLD_esp &&
6945 +           ((unsigned int) addr > (OLD_esp - (unsigned int) LOOKASIDE_SIZE))) {
6946 +               addr = (char *) END_OF_LOOKASIDE - ((char *) OLD_esp - addr);
6947 +       }
6948 +       *addr = val;
6949 +}
6950 +
6951 +/* convert the memory pointed to by mem into hex, placing result in buf */
6952 +/* return a pointer to the last char put in buf (null) */
6953 +/* If MAY_FAULT is non-zero, then we should set mem_err in response to
6954 +   a fault; if zero treat a fault like any other fault in the stub.  */
6955 +char *
6956 +mem2hex(char *mem, char *buf, int count, int may_fault)
6957 +{
6958 +       int i;
6959 +       unsigned char ch;
6960 +
6961 +       if (may_fault) {
6962 +               mem_err_expected = 1;
6963 +               mem_err = 0;
6964 +       }
6965 +       for (i = 0; i < count; i++) {
6966 +               /* printk("%lx = ", mem) ; */
6967 +
6968 +               ch = get_char(mem++);
6969 +
6970 +               /* printk("%02x\n", ch & 0xFF) ; */
6971 +               if (may_fault && mem_err) {
6972 +                       if (remote_debug)
6973 +                               printk("Mem fault fetching from addr %lx\n",
6974 +                                      (long) (mem - 1));
6975 +                       *buf = 0;       /* truncate buffer */
6976 +                       return (buf);
6977 +               }
6978 +               *buf++ = hexchars[ch >> 4];
6979 +               *buf++ = hexchars[ch % 16];
6980 +       }
6981 +       *buf = 0;
6982 +       if (may_fault)
6983 +               mem_err_expected = 0;
6984 +       return (buf);
6985 +}
6986 +
6987 +/* convert the hex array pointed to by buf into binary to be placed in mem */
6988 +/* return a pointer to the character AFTER the last byte written */
6989 +/* NOTE: We use the may fault flag to also indicate if the write is to
6990 + * the registers (0) or "other" memory (!=0)
6991 + */
6992 +char *
6993 +hex2mem(char *buf, char *mem, int count, int may_fault)
6994 +{
6995 +       int i;
6996 +       unsigned char ch;
6997 +
6998 +       if (may_fault) {
6999 +               mem_err_expected = 1;
7000 +               mem_err = 0;
7001 +       }
7002 +       for (i = 0; i < count; i++) {
7003 +               ch = hex(*buf++) << 4;
7004 +               ch = ch + hex(*buf++);
7005 +               set_char(mem++, ch, may_fault);
7006 +
7007 +               if (may_fault && mem_err) {
7008 +                       if (remote_debug)
7009 +                               printk("Mem fault storing to addr %lx\n",
7010 +                                      (long) (mem - 1));
7011 +                       return (mem);
7012 +               }
7013 +       }
7014 +       if (may_fault)
7015 +               mem_err_expected = 0;
7016 +       return (mem);
7017 +}
7018 +
7019 +/**********************************************/
7020 +/* WHILE WE FIND NICE HEX CHARS, BUILD AN INT */
7021 +/* RETURN NUMBER OF CHARS PROCESSED          */
7022 +/**********************************************/
7023 +int
7024 +hexToInt(char **ptr, int *intValue)
7025 +{
7026 +       int numChars = 0;
7027 +       int hexValue;
7028 +
7029 +       *intValue = 0;
7030 +
7031 +       while (**ptr) {
7032 +               hexValue = hex(**ptr);
7033 +               if (hexValue >= 0) {
7034 +                       *intValue = (*intValue << 4) | hexValue;
7035 +                       numChars++;
7036 +               } else
7037 +                       break;
7038 +
7039 +               (*ptr)++;
7040 +       }
7041 +
7042 +       return (numChars);
7043 +}
7044 +
7045 +#define stubhex(h) hex(h)
7046 +#ifdef old_thread_list
7047 +
7048 +static int
7049 +stub_unpack_int(char *buff, int fieldlength)
7050 +{
7051 +       int nibble;
7052 +       int retval = 0;
7053 +
7054 +       while (fieldlength) {
7055 +               nibble = stubhex(*buff++);
7056 +               retval |= nibble;
7057 +               fieldlength--;
7058 +               if (fieldlength)
7059 +                       retval = retval << 4;
7060 +       }
7061 +       return retval;
7062 +}
7063 +#endif
7064 +static char *
7065 +pack_hex_byte(char *pkt, int byte)
7066 +{
7067 +       *pkt++ = hexchars[(byte >> 4) & 0xf];
7068 +       *pkt++ = hexchars[(byte & 0xf)];
7069 +       return pkt;
7070 +}
7071 +
7072 +#define BUF_THREAD_ID_SIZE 16
7073 +
7074 +static char *
7075 +pack_threadid(char *pkt, threadref * id)
7076 +{
7077 +       char *limit;
7078 +       unsigned char *altid;
7079 +
7080 +       altid = (unsigned char *) id;
7081 +       limit = pkt + BUF_THREAD_ID_SIZE;
7082 +       while (pkt < limit)
7083 +               pkt = pack_hex_byte(pkt, *altid++);
7084 +       return pkt;
7085 +}
7086 +
7087 +#ifdef old_thread_list
7088 +static char *
7089 +unpack_byte(char *buf, int *value)
7090 +{
7091 +       *value = stub_unpack_int(buf, 2);
7092 +       return buf + 2;
7093 +}
7094 +
7095 +static char *
7096 +unpack_threadid(char *inbuf, threadref * id)
7097 +{
7098 +       char *altref;
7099 +       char *limit = inbuf + BUF_THREAD_ID_SIZE;
7100 +       int x, y;
7101 +
7102 +       altref = (char *) id;
7103 +
7104 +       while (inbuf < limit) {
7105 +               x = stubhex(*inbuf++);
7106 +               y = stubhex(*inbuf++);
7107 +               *altref++ = (x << 4) | y;
7108 +       }
7109 +       return inbuf;
7110 +}
7111 +#endif
7112 +void
7113 +int_to_threadref(threadref * id, int value)
7114 +{
7115 +       unsigned char *scan;
7116 +
7117 +       scan = (unsigned char *) id;
7118 +       {
7119 +               int i = 4;
7120 +               while (i--)
7121 +                       *scan++ = 0;
7122 +       }
7123 +       *scan++ = (value >> 24) & 0xff;
7124 +       *scan++ = (value >> 16) & 0xff;
7125 +       *scan++ = (value >> 8) & 0xff;
7126 +       *scan++ = (value & 0xff);
7127 +}
7128 +int
7129 +int_to_hex_v(unsigned char * id, int value)
7130 +{
7131 +       unsigned char *start = id;
7132 +       int shift;
7133 +       int ch;
7134 +
7135 +       for (shift = 28; shift >= 0; shift -= 4) {
7136 +               if ((ch = (value >> shift) & 0xf) || (id != start)) {
7137 +                       *id = hexchars[ch];
7138 +                       id++;
7139 +               }
7140 +       }
7141 +       if (id == start)
7142 +               *id++ = '0';
7143 +       return id - start;
7144 +}
7145 +#ifdef old_thread_list
7146 +
7147 +static int
7148 +threadref_to_int(threadref * ref)
7149 +{
7150 +       int i, value = 0;
7151 +       unsigned char *scan;
7152 +
7153 +       scan = (char *) ref;
7154 +       scan += 4;
7155 +       i = 4;
7156 +       while (i-- > 0)
7157 +               value = (value << 8) | ((*scan++) & 0xff);
7158 +       return value;
7159 +}
7160 +#endif
7161 +static int
7162 +cmp_str(char *s1, char *s2, int count)
7163 +{
7164 +       while (count--) {
7165 +               if (*s1++ != *s2++)
7166 +                       return 0;
7167 +       }
7168 +       return 1;
7169 +}
7170 +
7171 +#if 1                          /* this is a hold over from 2.4 where O(1) was "sometimes" */
7172 +extern struct task_struct *kgdb_get_idle(int cpu);
7173 +#define idle_task(cpu) kgdb_get_idle(cpu)
7174 +#else
7175 +#define idle_task(cpu) init_tasks[cpu]
7176 +#endif
7177 +
7178 +extern int kgdb_pid_init_done;
7179 +
7180 +struct task_struct *
7181 +getthread(int pid)
7182 +{
7183 +       struct task_struct *thread;
7184 +       if (pid >= PID_MAX && pid <= (PID_MAX + MAX_NO_CPUS)) {
7185 +
7186 +               return idle_task(pid - PID_MAX);
7187 +       } else {
7188 +               /*
7189 +                * find_task_by_pid is relatively safe all the time
7190 +                * Other pid functions require lock downs which imply
7191 +                * that we may be interrupting them (as we get here
7192 +                * in the middle of most any lock down).
7193 +                * Still we don't want to call until the table exists!
7194 +                */
7195 +               if (kgdb_pid_init_done){
7196 +                       thread = find_task_by_pid(pid);
7197 +                       if (thread) {
7198 +                               return thread;
7199 +                       }
7200 +               }
7201 +       }
7202 +       return NULL;
7203 +}
7204 +/* *INDENT-OFF*         */
7205 +struct hw_breakpoint {
7206 +       unsigned enabled;
7207 +       unsigned type;
7208 +       unsigned len;
7209 +       unsigned addr;
7210 +} breakinfo[4] = { {enabled:0},
7211 +                  {enabled:0},
7212 +                  {enabled:0},
7213 +                  {enabled:0}};
7214 +/* *INDENT-ON* */
7215 +unsigned hw_breakpoint_status;
7216 +void
7217 +correct_hw_break(void)
7218 +{
7219 +       int breakno;
7220 +       int correctit;
7221 +       int breakbit;
7222 +       unsigned dr7;
7223 +
7224 +       asm volatile ("movl %%db7, %0\n":"=r" (dr7)
7225 +                     :);
7226 +       /* *INDENT-OFF*  */
7227 +       do {
7228 +               unsigned addr0, addr1, addr2, addr3;
7229 +               asm volatile ("movl %%db0, %0\n"
7230 +                             "movl %%db1, %1\n"
7231 +                             "movl %%db2, %2\n"
7232 +                             "movl %%db3, %3\n"
7233 +                             :"=r" (addr0), "=r"(addr1),
7234 +                             "=r"(addr2), "=r"(addr3)
7235 +                             :);
7236 +       } while (0);
7237 +       /* *INDENT-ON*  */
7238 +       correctit = 0;
7239 +       for (breakno = 0; breakno < 3; breakno++) {
7240 +               breakbit = 2 << (breakno << 1);
7241 +               if (!(dr7 & breakbit) && breakinfo[breakno].enabled) {
7242 +                       correctit = 1;
7243 +                       dr7 |= breakbit;
7244 +                       dr7 &= ~(0xf0000 << (breakno << 2));
7245 +                       dr7 |= (((breakinfo[breakno].len << 2) |
7246 +                                breakinfo[breakno].type) << 16) <<
7247 +                           (breakno << 2);
7248 +                       switch (breakno) {
7249 +                       case 0:
7250 +                               asm volatile ("movl %0, %%dr0\n"::"r"
7251 +                                             (breakinfo[breakno].addr));
7252 +                               break;
7253 +
7254 +                       case 1:
7255 +                               asm volatile ("movl %0, %%dr1\n"::"r"
7256 +                                             (breakinfo[breakno].addr));
7257 +                               break;
7258 +
7259 +                       case 2:
7260 +                               asm volatile ("movl %0, %%dr2\n"::"r"
7261 +                                             (breakinfo[breakno].addr));
7262 +                               break;
7263 +
7264 +                       case 3:
7265 +                               asm volatile ("movl %0, %%dr3\n"::"r"
7266 +                                             (breakinfo[breakno].addr));
7267 +                               break;
7268 +                       }
7269 +               } else if ((dr7 & breakbit) && !breakinfo[breakno].enabled) {
7270 +                       correctit = 1;
7271 +                       dr7 &= ~breakbit;
7272 +                       dr7 &= ~(0xf0000 << (breakno << 2));
7273 +               }
7274 +       }
7275 +       if (correctit) {
7276 +               asm volatile ("movl %0, %%db7\n"::"r" (dr7));
7277 +       }
7278 +}
7279 +
7280 +int
7281 +remove_hw_break(unsigned breakno)
7282 +{
7283 +       if (!breakinfo[breakno].enabled) {
7284 +               return -1;
7285 +       }
7286 +       breakinfo[breakno].enabled = 0;
7287 +       return 0;
7288 +}
7289 +
7290 +int
7291 +set_hw_break(unsigned breakno, unsigned type, unsigned len, unsigned addr)
7292 +{
7293 +       if (breakinfo[breakno].enabled) {
7294 +               return -1;
7295 +       }
7296 +       breakinfo[breakno].enabled = 1;
7297 +       breakinfo[breakno].type = type;
7298 +       breakinfo[breakno].len = len;
7299 +       breakinfo[breakno].addr = addr;
7300 +       return 0;
7301 +}
7302 +
7303 +#ifdef CONFIG_SMP
7304 +static int in_kgdb_console = 0;
7305 +
7306 +int
7307 +in_kgdb(struct pt_regs *regs)
7308 +{
7309 +       unsigned flags;
7310 +       int cpu = smp_processor_id();
7311 +       in_kgdb_called = 1;
7312 +       if (!spin_is_locked(&kgdb_spinlock)) {
7313 +               if (in_kgdb_here_log[cpu] ||    /* we are holding this cpu */
7314 +                   in_kgdb_console) {  /* or we are doing slow i/o */
7315 +                       return 1;
7316 +               }
7317 +               return 0;
7318 +       }
7319 +
7320 +       /* As I see it the only reason not to let all cpus spin on
7321 +        * the same spin_lock is to allow selected ones to proceed.
7322 +        * This would be a good thing, so we leave it this way.
7323 +        * Maybe someday....  Done !
7324 +
7325 +        * in_kgdb() is called from an NMI so we don't pretend
7326 +        * to have any resources, like printk() for example.
7327 +        */
7328 +
7329 +       kgdb_local_irq_save(flags);     /* only local here, to avoid hanging */
7330 +       /*
7331 +        * log arival of this cpu
7332 +        * The NMI keeps on ticking.  Protect against recurring more
7333 +        * than once, and ignor the cpu that has the kgdb lock
7334 +        */
7335 +       in_kgdb_entry_log[cpu]++;
7336 +       in_kgdb_here_log[cpu] = regs;
7337 +       if (cpu == spinlock_cpu || waiting_cpus[cpu].task) {
7338 +               goto exit_in_kgdb;
7339 +       }
7340 +       /*
7341 +        * For protection of the initilization of the spin locks by kgdb
7342 +        * it locks the kgdb spinlock before it gets the wait locks set
7343 +        * up.  We wait here for the wait lock to be taken.  If the
7344 +        * kgdb lock goes away first??  Well, it could be a slow exit
7345 +        * sequence where the wait lock is removed prior to the kgdb lock
7346 +        * so if kgdb gets unlocked, we just exit.
7347 +        */
7348 +       while (spin_is_locked(&kgdb_spinlock) &&
7349 +              !spin_is_locked(waitlocks + cpu)) ;
7350 +       if (!spin_is_locked(&kgdb_spinlock)) {
7351 +               goto exit_in_kgdb;
7352 +       }
7353 +       waiting_cpus[cpu].task = current;
7354 +       waiting_cpus[cpu].pid = (current->pid) ? : (PID_MAX + cpu);
7355 +       waiting_cpus[cpu].regs = regs;
7356 +
7357 +       spin_unlock_wait(waitlocks + cpu);
7358 +       /*
7359 +        * log departure of this cpu
7360 +        */
7361 +       waiting_cpus[cpu].task = 0;
7362 +       waiting_cpus[cpu].pid = 0;
7363 +       waiting_cpus[cpu].regs = 0;
7364 +       correct_hw_break();
7365 +      exit_in_kgdb:
7366 +       in_kgdb_here_log[cpu] = 0;
7367 +       kgdb_local_irq_restore(flags);
7368 +       return 1;
7369 +       /*
7370 +          spin_unlock(continuelocks + smp_processor_id());
7371 +        */
7372 +}
7373 +
7374 +void
7375 +smp__in_kgdb(struct pt_regs regs)
7376 +{
7377 +       ack_APIC_irq();
7378 +       in_kgdb(&regs);
7379 +}
7380 +#else
7381 +int
7382 +in_kgdb(struct pt_regs *regs)
7383 +{
7384 +       return (kgdb_spinlock);
7385 +}
7386 +#endif
7387 +
7388 +void
7389 +printexceptioninfo(int exceptionNo, int errorcode, char *buffer)
7390 +{
7391 +       unsigned dr6;
7392 +       int i;
7393 +       switch (exceptionNo) {
7394 +       case 1:         /* debug exception */
7395 +               break;
7396 +       case 3:         /* breakpoint */
7397 +               sprintf(buffer, "Software breakpoint");
7398 +               return;
7399 +       default:
7400 +               sprintf(buffer, "Details not available");
7401 +               return;
7402 +       }
7403 +       asm volatile ("movl %%db6, %0\n":"=r" (dr6)
7404 +                     :);
7405 +       if (dr6 & 0x4000) {
7406 +               sprintf(buffer, "Single step");
7407 +               return;
7408 +       }
7409 +       for (i = 0; i < 4; ++i) {
7410 +               if (dr6 & (1 << i)) {
7411 +                       sprintf(buffer, "Hardware breakpoint %d", i);
7412 +                       return;
7413 +               }
7414 +       }
7415 +       sprintf(buffer, "Unknown trap");
7416 +       return;
7417 +}
7418 +
7419 +/*
7420 + * This function does all command procesing for interfacing to gdb.
7421 + *
7422 + * NOTE:  The INT nn instruction leaves the state of the interrupt
7423 + *       enable flag UNCHANGED.  That means that when this routine
7424 + *       is entered via a breakpoint (INT 3) instruction from code
7425 + *       that has interrupts enabled, then interrupts will STILL BE
7426 + *       enabled when this routine is entered.  The first thing that
7427 + *       we do here is disable interrupts so as to prevent recursive
7428 + *       entries and bothersome serial interrupts while we are
7429 + *       trying to run the serial port in polled mode.
7430 + *
7431 + * For kernel version 2.1.xx the kgdb_cli() actually gets a spin lock so
7432 + * it is always necessary to do a restore_flags before returning
7433 + * so as to let go of that lock.
7434 + */
7435 +int
7436 +kgdb_handle_exception(int exceptionVector,
7437 +                     int signo, int err_code, struct pt_regs *linux_regs)
7438 +{
7439 +       struct task_struct *usethread = NULL;
7440 +       struct task_struct *thread_list_start = 0, *thread = NULL;
7441 +       int addr, length;
7442 +       unsigned long address;
7443 +       int breakno, breaktype;
7444 +       char *ptr;
7445 +       int newPC;
7446 +       threadref thref;
7447 +       int threadid;
7448 +       int thread_min = PID_MAX + MAX_NO_CPUS;
7449 +#ifdef old_thread_list
7450 +       int maxthreads;
7451 +#endif
7452 +       int nothreads;
7453 +       unsigned long flags;
7454 +       int gdb_regs[NUMREGBYTES / 4];
7455 +       int dr6;
7456 +       IF_SMP(int entry_state = 0);    /* 0, ok, 1, no nmi, 2 sync failed */
7457 +#define NO_NMI 1
7458 +#define NO_SYNC 2
7459 +#define        regs    (*linux_regs)
7460 +#define NUMREGS NUMREGBYTES/4
7461 +       /*
7462 +        * If the entry is not from the kernel then return to the Linux
7463 +        * trap handler and let it process the interrupt normally.
7464 +        */
7465 +       if ((linux_regs->eflags & VM_MASK) || (3 & linux_regs->xcs)) {
7466 +               printk("ignoring non-kernel exception\n");
7467 +               print_regs(&regs);
7468 +               return (0);
7469 +       }
7470 +       /*
7471 +        * If we're using eth mode, set the 'mode' in the netdevice.
7472 +        */
7473 +
7474 +       __asm__("movl %%cr2,%0":"=r" (address));
7475 +
7476 +       if (kgdb_eth != -1) {
7477 +               kgdb_eth_set_trapmode(1);
7478 +       }
7479 +
7480 +       kgdb_local_irq_save(flags);
7481 +
7482 +       /* Get kgdb spinlock */
7483 +
7484 +       KGDB_SPIN_LOCK(&kgdb_spinlock);
7485 +       rdtscll(kgdb_info.entry_tsc);
7486 +       /*
7487 +        * We depend on this spinlock and the NMI watch dog to control the
7488 +        * other cpus.  They will arrive at "in_kgdb()" as a result of the
7489 +        * NMI and will wait there for the following spin locks to be
7490 +        * released.
7491 +        */
7492 +#ifdef CONFIG_SMP
7493 +
7494 +#if 0
7495 +       if (cpu_callout_map & ~MAX_CPU_MASK) {
7496 +               printk("kgdb : too many cpus, possibly not mapped"
7497 +                      " in contiguous space, change MAX_NO_CPUS"
7498 +                      " in kgdb_stub and make new kernel.\n"
7499 +                      " cpu_callout_map is %lx\n", cpu_callout_map);
7500 +               goto exit_just_unlock;
7501 +       }
7502 +#endif
7503 +       if (spinlock_count == 1) {
7504 +               int time, end_time, dum;
7505 +               int i;
7506 +               int cpu_logged_in[MAX_NO_CPUS] = {[0 ... MAX_NO_CPUS - 1] = (0)
7507 +               };
7508 +               if (remote_debug) {
7509 +                       printk("kgdb : cpu %d entry, syncing others\n",
7510 +                              smp_processor_id());
7511 +               }
7512 +               for (i = 0; i < MAX_NO_CPUS; i++) {
7513 +                       /*
7514 +                        * Use trylock as we may already hold the lock if
7515 +                        * we are holding the cpu.  Net result is all
7516 +                        * locked.
7517 +                        */
7518 +                       spin_trylock(&waitlocks[i]);
7519 +               }
7520 +               for (i = 0; i < MAX_NO_CPUS; i++)
7521 +                       cpu_logged_in[i] = 0;
7522 +               /*
7523 +                * Wait for their arrival.  We know the watch dog is active if
7524 +                * in_kgdb() has ever been called, as it is always called on a
7525 +                * watchdog tick.
7526 +                */
7527 +               rdtsc(dum, time);
7528 +               end_time = time + 2;    /* Note: we use the High order bits! */
7529 +               i = 1;
7530 +               if (num_online_cpus() > 1) {
7531 +                       int me_in_kgdb = in_kgdb_entry_log[smp_processor_id()];
7532 +                       smp_send_nmi_allbutself();
7533 +                       while (i < num_online_cpus() && time != end_time) {
7534 +                               int j;
7535 +                               for (j = 0; j < MAX_NO_CPUS; j++) {
7536 +                                       if (waiting_cpus[j].task &&
7537 +                                           !cpu_logged_in[j]) {
7538 +                                               i++;
7539 +                                               cpu_logged_in[j] = 1;
7540 +                                               if (remote_debug) {
7541 +                                                       printk
7542 +                                                           ("kgdb : cpu %d arrived at kgdb\n",
7543 +                                                            j);
7544 +                                               }
7545 +                                               break;
7546 +                                       } else if (!waiting_cpus[j].task &&
7547 +                                                  !cpu_online(j)) {
7548 +                                               waiting_cpus[j].task = NOCPU;
7549 +                                               cpu_logged_in[j] = 1;
7550 +                                               waiting_cpus[j].hold = 1;
7551 +                                               break;
7552 +                                       }
7553 +                                       if (!waiting_cpus[j].task &&
7554 +                                           in_kgdb_here_log[j]) {
7555 +
7556 +                                               int wait = 100000;
7557 +                                               while (wait--) ;
7558 +                                               if (!waiting_cpus[j].task &&
7559 +                                                   in_kgdb_here_log[j]) {
7560 +                                                       printk
7561 +                                                           ("kgdb : cpu %d stall"
7562 +                                                            " in in_kgdb\n",
7563 +                                                            j);
7564 +                                                       i++;
7565 +                                                       cpu_logged_in[j] = 1;
7566 +                                                       waiting_cpus[j].task =
7567 +                                                           (struct task_struct
7568 +                                                            *) 1;
7569 +                                               }
7570 +                                       }
7571 +                               }
7572 +
7573 +                               if (in_kgdb_entry_log[smp_processor_id()] >
7574 +                                   (me_in_kgdb + 10)) {
7575 +                                       break;
7576 +                               }
7577 +
7578 +                               rdtsc(dum, time);
7579 +                       }
7580 +                       if (i < num_online_cpus()) {
7581 +                               printk
7582 +                                   ("kgdb : time out, proceeding without sync\n");
7583 +#if 0
7584 +                               printk("kgdb : Waiting_cpus: 0 = %d, 1 = %d\n",
7585 +                                      waiting_cpus[0].task != 0,
7586 +                                      waiting_cpus[1].task != 0);
7587 +                               printk("kgdb : Cpu_logged in: 0 = %d, 1 = %d\n",
7588 +                                      cpu_logged_in[0], cpu_logged_in[1]);
7589 +                               printk
7590 +                                   ("kgdb : in_kgdb_here_log in: 0 = %d, 1 = %d\n",
7591 +                                    in_kgdb_here_log[0] != 0,
7592 +                                    in_kgdb_here_log[1] != 0);
7593 +#endif
7594 +                               entry_state = NO_SYNC;
7595 +                       } else {
7596 +#if 0
7597 +                               int ent =
7598 +                                   in_kgdb_entry_log[smp_processor_id()] -
7599 +                                   me_in_kgdb;
7600 +                               printk("kgdb : sync after %d entries\n", ent);
7601 +#endif
7602 +                       }
7603 +               } else {
7604 +                       if (remote_debug) {
7605 +                               printk
7606 +                                   ("kgdb : %d cpus, but watchdog not active\n"
7607 +                                    "proceeding without locking down other cpus\n",
7608 +                                    num_online_cpus());
7609 +                               entry_state = NO_NMI;
7610 +                       }
7611 +               }
7612 +       }
7613 +#endif
7614 +
7615 +       if (remote_debug) {
7616 +               printk("handle_exception(exceptionVector=%d, "
7617 +                      "signo=%d, err_code=%d, linux_regs=%p)\n",
7618 +                      exceptionVector, signo, err_code, linux_regs);
7619 +               printk(" address: %lx\n", address);
7620 +
7621 +               if (debug_regs) {
7622 +                       print_regs(&regs);
7623 +                       show_trace(current, (unsigned long *)&regs);
7624 +               }
7625 +       }
7626 +
7627 +       /* Disable hardware debugging while we are in kgdb */
7628 +       /* Get the debug register status register */
7629 +/*                                    *INDENT-OFF*  */
7630 +      __asm__("movl %0,%%db7"
7631 +             : /* no output */
7632 +             :"r"(0));
7633 +
7634 +       asm volatile ("movl %%db6, %0\n"
7635 +                     :"=r" (hw_breakpoint_status)
7636 +                     :);
7637 +
7638 +/*                                    *INDENT-ON*  */
7639 +       switch (exceptionVector) {
7640 +       case 0:         /* divide error */
7641 +       case 1:         /* debug exception */
7642 +       case 2:         /* NMI */
7643 +       case 3:         /* breakpoint */
7644 +       case 4:         /* overflow */
7645 +       case 5:         /* bounds check */
7646 +       case 6:         /* invalid opcode */
7647 +       case 7:         /* device not available */
7648 +       case 8:         /* double fault (errcode) */
7649 +       case 10:                /* invalid TSS (errcode) */
7650 +       case 12:                /* stack fault (errcode) */
7651 +       case 16:                /* floating point error */
7652 +       case 17:                /* alignment check (errcode) */
7653 +       default:                /* any undocumented */
7654 +               break;
7655 +       case 11:                /* segment not present (errcode) */
7656 +       case 13:                /* general protection (errcode) */
7657 +       case 14:                /* page fault (special errcode) */
7658 +       case 19:                /* cache flush denied */
7659 +               if (mem_err_expected) {
7660 +                       /*
7661 +                        * This fault occured because of the
7662 +                        * get_char or set_char routines.  These
7663 +                        * two routines use either eax of edx to
7664 +                        * indirectly reference the location in
7665 +                        * memory that they are working with.
7666 +                        * For a page fault, when we return the
7667 +                        * instruction will be retried, so we
7668 +                        * have to make sure that these
7669 +                        * registers point to valid memory.
7670 +                        */
7671 +                       mem_err = 1;    /* set mem error flag */
7672 +                       mem_err_expected = 0;
7673 +                       mem_err_cnt++;  /* helps in debugging */
7674 +                       /* make valid address */
7675 +                       regs.eax = (long) &garbage_loc;
7676 +                       /* make valid address */
7677 +                       regs.edx = (long) &garbage_loc;
7678 +                       if (remote_debug)
7679 +                               printk("Return after memory error: "
7680 +                                      "mem_err_cnt=%d\n", mem_err_cnt);
7681 +                       if (debug_regs)
7682 +                               print_regs(&regs);
7683 +                       goto exit_kgdb;
7684 +               }
7685 +               break;
7686 +       }
7687 +       if (remote_debug)
7688 +               printk("kgdb : entered kgdb on cpu %d\n", smp_processor_id());
7689 +
7690 +       gdb_i386vector = exceptionVector;
7691 +       gdb_i386errcode = err_code;
7692 +       kgdb_info.called_from = __builtin_return_address(0);
7693 +#ifdef CONFIG_SMP
7694 +       /*
7695 +        * OK, we can now communicate, lets tell gdb about the sync.
7696 +        * but only if we had a problem.
7697 +        */
7698 +       switch (entry_state) {
7699 +       case NO_NMI:
7700 +               to_gdb("NMI not active, other cpus not stopped\n");
7701 +               break;
7702 +       case NO_SYNC:
7703 +               to_gdb("Some cpus not stopped, see 'kgdb_info' for details\n");
7704 +       default:;
7705 +       }
7706 +
7707 +#endif
7708 +/*
7709 + * Set up the gdb function call area.
7710 + */
7711 +       trap_cpu = smp_processor_id();
7712 +       OLD_esp = NEW_esp = (int) (&linux_regs->esp);
7713 +
7714 +      IF_SMP(once_again:)
7715 +           /* reply to host that an exception has occurred */
7716 +           remcomOutBuffer[0] = 'S';
7717 +       remcomOutBuffer[1] = hexchars[signo >> 4];
7718 +       remcomOutBuffer[2] = hexchars[signo % 16];
7719 +       remcomOutBuffer[3] = 0;
7720 +
7721 +       if (kgdb_eth_is_initializing) {
7722 +               kgdb_eth_is_initializing = 0;
7723 +       } else {
7724 +               putpacket(remcomOutBuffer);
7725 +       }
7726 +
7727 +       kgdb_eth_reply_arp();
7728 +       while (1 == 1) {
7729 +               error = 0;
7730 +               remcomOutBuffer[0] = 0;
7731 +               getpacket(remcomInBuffer);
7732 +               switch (remcomInBuffer[0]) {
7733 +               case '?':
7734 +                       remcomOutBuffer[0] = 'S';
7735 +                       remcomOutBuffer[1] = hexchars[signo >> 4];
7736 +                       remcomOutBuffer[2] = hexchars[signo % 16];
7737 +                       remcomOutBuffer[3] = 0;
7738 +                       break;
7739 +               case 'd':
7740 +                       remote_debug = !(remote_debug); /* toggle debug flag */
7741 +                       printk("Remote debug %s\n",
7742 +                              remote_debug ? "on" : "off");
7743 +                       break;
7744 +               case 'g':       /* return the value of the CPU registers */
7745 +                       get_gdb_regs(usethread, &regs, gdb_regs);
7746 +                       mem2hex((char *) gdb_regs,
7747 +                               remcomOutBuffer, NUMREGBYTES, 0);
7748 +                       break;
7749 +               case 'G':       /* set the value of the CPU registers - return OK */
7750 +                       hex2mem(&remcomInBuffer[1],
7751 +                               (char *) gdb_regs, NUMREGBYTES, 0);
7752 +                       if (!usethread || usethread == current) {
7753 +                               gdb_regs_to_regs(gdb_regs, &regs);
7754 +                               strcpy(remcomOutBuffer, "OK");
7755 +                       } else {
7756 +                               strcpy(remcomOutBuffer, "E00");
7757 +                       }
7758 +                       break;
7759 +
7760 +               case 'P':{      /* set the value of a single CPU register -
7761 +                                  return OK */
7762 +                               /*
7763 +                                * For some reason, gdb wants to talk about psudo
7764 +                                * registers (greater than 15).  These may have
7765 +                                * meaning for ptrace, but for us it is safe to
7766 +                                * ignor them.  We do this by dumping them into
7767 +                                * _GS which we also ignor, but do have memory for.
7768 +                                */
7769 +                               int regno;
7770 +
7771 +                               ptr = &remcomInBuffer[1];
7772 +                               regs_to_gdb_regs(gdb_regs, &regs);
7773 +                               if ((!usethread || usethread == current) &&
7774 +                                   hexToInt(&ptr, &regno) &&
7775 +                                   *ptr++ == '=' && (regno >= 0)) {
7776 +                                       regno =
7777 +                                           (regno >= NUMREGS ? _GS : regno);
7778 +                                       hex2mem(ptr, (char *) &gdb_regs[regno],
7779 +                                               4, 0);
7780 +                                       gdb_regs_to_regs(gdb_regs, &regs);
7781 +                                       strcpy(remcomOutBuffer, "OK");
7782 +                                       break;
7783 +                               }
7784 +                               strcpy(remcomOutBuffer, "E01");
7785 +                               break;
7786 +                       }
7787 +
7788 +                       /* mAA..AA,LLLL  Read LLLL bytes at address AA..AA */
7789 +               case 'm':
7790 +                       /* TRY TO READ %x,%x.  IF SUCCEED, SET PTR = 0 */
7791 +                       ptr = &remcomInBuffer[1];
7792 +                       if (hexToInt(&ptr, &addr) &&
7793 +                           (*(ptr++) == ',') && (hexToInt(&ptr, &length))) {
7794 +                               ptr = 0;
7795 +                               /*
7796 +                                * hex doubles the byte count
7797 +                                */
7798 +                               if (length > (BUFMAX / 2))
7799 +                                       length = BUFMAX / 2;
7800 +                               mem2hex((char *) addr,
7801 +                                       remcomOutBuffer, length, 1);
7802 +                               if (mem_err) {
7803 +                                       strcpy(remcomOutBuffer, "E03");
7804 +                                       debug_error("memory fault\n", NULL);
7805 +                               }
7806 +                       }
7807 +
7808 +                       if (ptr) {
7809 +                               strcpy(remcomOutBuffer, "E01");
7810 +                               debug_error
7811 +                                   ("malformed read memory command: %s\n",
7812 +                                    remcomInBuffer);
7813 +                       }
7814 +                       break;
7815 +
7816 +                       /* MAA..AA,LLLL:
7817 +                          Write LLLL bytes at address AA.AA return OK */
7818 +               case 'M':
7819 +                       /* TRY TO READ '%x,%x:'.  IF SUCCEED, SET PTR = 0 */
7820 +                       ptr = &remcomInBuffer[1];
7821 +                       if (hexToInt(&ptr, &addr) &&
7822 +                           (*(ptr++) == ',') &&
7823 +                           (hexToInt(&ptr, &length)) && (*(ptr++) == ':')) {
7824 +                               hex2mem(ptr, (char *) addr, length, 1);
7825 +
7826 +                               if (mem_err) {
7827 +                                       strcpy(remcomOutBuffer, "E03");
7828 +                                       debug_error("memory fault\n", NULL);
7829 +                               } else {
7830 +                                       strcpy(remcomOutBuffer, "OK");
7831 +                               }
7832 +
7833 +                               ptr = 0;
7834 +                       }
7835 +                       if (ptr) {
7836 +                               strcpy(remcomOutBuffer, "E02");
7837 +                               debug_error
7838 +                                   ("malformed write memory command: %s\n",
7839 +                                    remcomInBuffer);
7840 +                       }
7841 +                       break;
7842 +               case 'S':
7843 +                       remcomInBuffer[0] = 's';
7844 +               case 'C':
7845 +                       /* Csig;AA..AA where ;AA..AA is optional
7846 +                        * continue with signal
7847 +                        * Since signals are meaning less to us, delete that
7848 +                        * part and then fall into the 'c' code.
7849 +                        */
7850 +                       ptr = &remcomInBuffer[1];
7851 +                       length = 2;
7852 +                       while (*ptr && *ptr != ';') {
7853 +                               length++;
7854 +                               ptr++;
7855 +                       }
7856 +                       if (*ptr) {
7857 +                               do {
7858 +                                       ptr++;
7859 +                                       *(ptr - length++) = *ptr;
7860 +                               } while (*ptr);
7861 +                       } else {
7862 +                               remcomInBuffer[1] = 0;
7863 +                       }
7864 +
7865 +                       /* cAA..AA  Continue at address AA..AA(optional) */
7866 +                       /* sAA..AA  Step one instruction from AA..AA(optional) */
7867 +                       /* D        detach, reply OK and then continue */
7868 +               case 'c':
7869 +               case 's':
7870 +               case 'D':
7871 +
7872 +                       /* try to read optional parameter,
7873 +                          pc unchanged if no parm */
7874 +                       ptr = &remcomInBuffer[1];
7875 +                       if (hexToInt(&ptr, &addr)) {
7876 +                               if (remote_debug)
7877 +                                       printk("Changing EIP to 0x%x\n", addr);
7878 +
7879 +                               regs.eip = addr;
7880 +                       }
7881 +
7882 +                       newPC = regs.eip;
7883 +
7884 +                       if (kgdb_eth != -1) {
7885 +                               kgdb_eth_set_trapmode(0);
7886 +                       }
7887 +
7888 +                       /* clear the trace bit */
7889 +                       regs.eflags &= 0xfffffeff;
7890 +
7891 +                       /* set the trace bit if we're stepping */
7892 +                       if (remcomInBuffer[0] == 's')
7893 +                               regs.eflags |= 0x100;
7894 +
7895 +                       /* detach is a friendly version of continue. Note that
7896 +                          debugging is still enabled (e.g hit control C)
7897 +                        */
7898 +                       if (remcomInBuffer[0] == 'D') {
7899 +                               strcpy(remcomOutBuffer, "OK");
7900 +                               putpacket(remcomOutBuffer);
7901 +                       }
7902 +
7903 +                       if (remote_debug) {
7904 +                               printk("Resuming execution\n");
7905 +                               print_regs(&regs);
7906 +                       }
7907 +                       asm volatile ("movl %%db6, %0\n":"=r" (dr6)
7908 +                                     :);
7909 +                       if (!(dr6 & 0x4000)) {
7910 +                               for (breakno = 0; breakno < 4; ++breakno) {
7911 +                                       if (dr6 & (1 << breakno) &&
7912 +                                           (breakinfo[breakno].type == 0)) {
7913 +                                               /* Set restore flag */
7914 +                                               regs.eflags |= 0x10000;
7915 +                                               break;
7916 +                                       }
7917 +                               }
7918 +                       }
7919 +                       correct_hw_break();
7920 +                       asm volatile ("movl %0, %%db6\n"::"r" (0));
7921 +                       goto exit_kgdb;
7922 +
7923 +                       /* kill the program */
7924 +               case 'k':       /* do nothing */
7925 +                       break;
7926 +
7927 +                       /* query */
7928 +               case 'q':
7929 +                       nothreads = 0;
7930 +                       switch (remcomInBuffer[1]) {
7931 +                       case 'f':
7932 +                               threadid = 1;
7933 +                               thread_list = 2;
7934 +                               thread_list_start = (usethread ? : current);
7935 +                       case 's':
7936 +                               if (!cmp_str(&remcomInBuffer[2],
7937 +                                            "ThreadInfo", 10))
7938 +                                       break;
7939 +
7940 +                               remcomOutBuffer[nothreads++] = 'm';
7941 +                               for (; threadid < PID_MAX + MAX_NO_CPUS;
7942 +                                    threadid++) {
7943 +                                       thread = getthread(threadid);
7944 +                                       if (thread) {
7945 +                                               nothreads += int_to_hex_v(
7946 +                                                       &remcomOutBuffer[
7947 +                                                               nothreads],
7948 +                                                       threadid);
7949 +                                               if (thread_min > threadid)
7950 +                                                       thread_min = threadid;
7951 +                                               remcomOutBuffer[
7952 +                                                       nothreads] = ',';
7953 +                                               nothreads++;
7954 +                                               if (nothreads > BUFMAX - 10)
7955 +                                                       break;
7956 +                                       }
7957 +                               }
7958 +                               if (remcomOutBuffer[nothreads - 1] == 'm') {
7959 +                                       remcomOutBuffer[nothreads - 1] = 'l';
7960 +                               } else {
7961 +                                       nothreads--;
7962 +                               }
7963 +                               remcomOutBuffer[nothreads] = 0;
7964 +                               break;
7965 +
7966 +#ifdef old_thread_list /* Old thread info request */
7967 +                       case 'L':
7968 +                               /* List threads */
7969 +                               thread_list = 2;
7970 +                               thread_list_start = (usethread ? : current);
7971 +                               unpack_byte(remcomInBuffer + 3, &maxthreads);
7972 +                               unpack_threadid(remcomInBuffer + 5, &thref);
7973 +                               do {
7974 +                                       int buf_thread_limit =
7975 +                                           (BUFMAX - 22) / BUF_THREAD_ID_SIZE;
7976 +                                       if (maxthreads > buf_thread_limit) {
7977 +                                               maxthreads = buf_thread_limit;
7978 +                                       }
7979 +                               } while (0);
7980 +                               remcomOutBuffer[0] = 'q';
7981 +                               remcomOutBuffer[1] = 'M';
7982 +                               remcomOutBuffer[4] = '0';
7983 +                               pack_threadid(remcomOutBuffer + 5, &thref);
7984 +
7985 +                               threadid = threadref_to_int(&thref);
7986 +                               for (nothreads = 0;
7987 +                                    nothreads < maxthreads &&
7988 +                                    threadid < PID_MAX + MAX_NO_CPUS;
7989 +                                    threadid++) {
7990 +                                       thread = getthread(threadid);
7991 +                                       if (thread) {
7992 +                                               int_to_threadref(&thref,
7993 +                                                                threadid);
7994 +                                               pack_threadid(remcomOutBuffer +
7995 +                                                             21 +
7996 +                                                             nothreads * 16,
7997 +                                                             &thref);
7998 +                                               nothreads++;
7999 +                                               if (thread_min > threadid)
8000 +                                                       thread_min = threadid;
8001 +                                       }
8002 +                               }
8003 +
8004 +                               if (threadid == PID_MAX + MAX_NO_CPUS) {
8005 +                                       remcomOutBuffer[4] = '1';
8006 +                               }
8007 +                               pack_hex_byte(remcomOutBuffer + 2, nothreads);
8008 +                               remcomOutBuffer[21 + nothreads * 16] = '\0';
8009 +                               break;
8010 +#endif
8011 +                       case 'C':
8012 +                               /* Current thread id */
8013 +                               remcomOutBuffer[0] = 'Q';
8014 +                               remcomOutBuffer[1] = 'C';
8015 +                               threadid = current->pid;
8016 +                               if (!threadid) {
8017 +                                       /*
8018 +                                        * idle thread
8019 +                                        */
8020 +                                       for (threadid = PID_MAX;
8021 +                                            threadid < PID_MAX + MAX_NO_CPUS;
8022 +                                            threadid++) {
8023 +                                               if (current ==
8024 +                                                   idle_task(threadid -
8025 +                                                             PID_MAX))
8026 +                                                       break;
8027 +                                       }
8028 +                               }
8029 +                               int_to_threadref(&thref, threadid);
8030 +                               pack_threadid(remcomOutBuffer + 2, &thref);
8031 +                               remcomOutBuffer[18] = '\0';
8032 +                               break;
8033 +
8034 +                       case 'E':
8035 +                               /* Print exception info */
8036 +                               printexceptioninfo(exceptionVector,
8037 +                                                  err_code, remcomOutBuffer);
8038 +                               break;
8039 +                       case 'T':{
8040 +                               char * nptr;
8041 +                               /* Thread extra info */
8042 +                               if (!cmp_str(&remcomInBuffer[2],
8043 +                                           "hreadExtraInfo,", 15)) {
8044 +                                       break;
8045 +                               }
8046 +                               ptr = &remcomInBuffer[17];
8047 +                               hexToInt(&ptr, &threadid);
8048 +                               thread = getthread(threadid);
8049 +                               nptr = &thread->comm[0];
8050 +                               length = 0;
8051 +                               ptr = &remcomOutBuffer[0];
8052 +                               do {
8053 +                                       length++;
8054 +                                       ptr = pack_hex_byte(ptr, *nptr++);
8055 +                                } while (*nptr && length < 16);
8056 +                               /*
8057 +                                * would like that 16 to be the size of
8058 +                                * task_struct.comm but don't know the
8059 +                                * syntax..
8060 +                                */
8061 +                               *ptr = 0;
8062 +                       }
8063 +                       }
8064 +                       break;
8065 +
8066 +                       /* task related */
8067 +               case 'H':
8068 +                       switch (remcomInBuffer[1]) {
8069 +                       case 'g':
8070 +                               ptr = &remcomInBuffer[2];
8071 +                               hexToInt(&ptr, &threadid);
8072 +                               thread = getthread(threadid);
8073 +                               if (!thread) {
8074 +                                       remcomOutBuffer[0] = 'E';
8075 +                                       remcomOutBuffer[1] = '\0';
8076 +                                       break;
8077 +                               }
8078 +                               /*
8079 +                                * Just in case I forget what this is all about,
8080 +                                * the "thread info" command to gdb causes it
8081 +                                * to ask for a thread list.  It then switches
8082 +                                * to each thread and asks for the registers.
8083 +                                * For this (and only this) usage, we want to
8084 +                                * fudge the registers of tasks not on the run
8085 +                                * list (i.e. waiting) to show the routine that
8086 +                                * called schedule. Also, gdb, is a minimalist
8087 +                                * in that if the current thread is the last
8088 +                                * it will not re-read the info when done.
8089 +                                * This means that in this case we must show
8090 +                                * the real registers. So here is how we do it:
8091 +                                * Each entry we keep track of the min
8092 +                                * thread in the list (the last that gdb will)
8093 +                                * get info for.  We also keep track of the
8094 +                                * starting thread.
8095 +                                * "thread_list" is cleared when switching back
8096 +                                * to the min thread if it is was current, or
8097 +                                * if it was not current, thread_list is set
8098 +                                * to 1.  When the switch to current comes,
8099 +                                * if thread_list is 1, clear it, else do
8100 +                                * nothing.
8101 +                                */
8102 +                               usethread = thread;
8103 +                               if ((thread_list == 1) &&
8104 +                                   (thread == thread_list_start)) {
8105 +                                       thread_list = 0;
8106 +                               }
8107 +                               if (thread_list && (threadid == thread_min)) {
8108 +                                       if (thread == thread_list_start) {
8109 +                                               thread_list = 0;
8110 +                                       } else {
8111 +                                               thread_list = 1;
8112 +                                       }
8113 +                               }
8114 +                               /* follow through */
8115 +                       case 'c':
8116 +                               remcomOutBuffer[0] = 'O';
8117 +                               remcomOutBuffer[1] = 'K';
8118 +                               remcomOutBuffer[2] = '\0';
8119 +                               break;
8120 +                       }
8121 +                       break;
8122 +
8123 +                       /* Query thread status */
8124 +               case 'T':
8125 +                       ptr = &remcomInBuffer[1];
8126 +                       hexToInt(&ptr, &threadid);
8127 +                       thread = getthread(threadid);
8128 +                       if (thread) {
8129 +                               remcomOutBuffer[0] = 'O';
8130 +                               remcomOutBuffer[1] = 'K';
8131 +                               remcomOutBuffer[2] = '\0';
8132 +                               if (thread_min > threadid)
8133 +                                       thread_min = threadid;
8134 +                       } else {
8135 +                               remcomOutBuffer[0] = 'E';
8136 +                               remcomOutBuffer[1] = '\0';
8137 +                       }
8138 +                       break;
8139 +
8140 +               case 'Y': /* set up a hardware breakpoint */
8141 +                       ptr = &remcomInBuffer[1];
8142 +                       hexToInt(&ptr, &breakno);
8143 +                       ptr++;
8144 +                       hexToInt(&ptr, &breaktype);
8145 +                       ptr++;
8146 +                       hexToInt(&ptr, &length);
8147 +                       ptr++;
8148 +                       hexToInt(&ptr, &addr);
8149 +                       if (set_hw_break(breakno & 0x3,
8150 +                                        breaktype & 0x3,
8151 +                                        length & 0x3, addr) == 0) {
8152 +                               strcpy(remcomOutBuffer, "OK");
8153 +                       } else {
8154 +                               strcpy(remcomOutBuffer, "ERROR");
8155 +                       }
8156 +                       break;
8157 +
8158 +                       /* Remove hardware breakpoint */
8159 +               case 'y':
8160 +                       ptr = &remcomInBuffer[1];
8161 +                       hexToInt(&ptr, &breakno);
8162 +                       if (remove_hw_break(breakno & 0x3) == 0) {
8163 +                               strcpy(remcomOutBuffer, "OK");
8164 +                       } else {
8165 +                               strcpy(remcomOutBuffer, "ERROR");
8166 +                       }
8167 +                       break;
8168 +
8169 +               case 'r':       /* reboot */
8170 +                       strcpy(remcomOutBuffer, "OK");
8171 +                       putpacket(remcomOutBuffer);
8172 +                       /*to_gdb("Rebooting\n"); */
8173 +                       /* triplefault   no return from here */
8174 +                       {
8175 +                               static long no_idt[2];
8176 +                               __asm__ __volatile__("lidt %0"::"m"(no_idt[0]));
8177 +                               BREAKPOINT;
8178 +                       }
8179 +
8180 +               }               /* switch */
8181 +
8182 +               /* reply to the request */
8183 +               putpacket(remcomOutBuffer);
8184 +       }                       /* while(1==1) */
8185 +       /*
8186 +        *  reached by goto only.
8187 +        */
8188 +      exit_kgdb:
8189 +       /*
8190 +        * Here is where we set up to trap a gdb function call.  NEW_esp
8191 +        * will be changed if we are trying to do this.  We handle both
8192 +        * adding and subtracting, thus allowing gdb to put grung on
8193 +        * the stack which it removes later.
8194 +        */
8195 +       if (NEW_esp != OLD_esp) {
8196 +               int *ptr = END_OF_LOOKASIDE;
8197 +               if (NEW_esp < OLD_esp)
8198 +                       ptr -= (OLD_esp - NEW_esp) / sizeof (int);
8199 +               *--ptr = linux_regs->eflags;
8200 +               *--ptr = linux_regs->xcs;
8201 +               *--ptr = linux_regs->eip;
8202 +               *--ptr = linux_regs->ecx;
8203 +               *--ptr = linux_regs->ebx;
8204 +               *--ptr = linux_regs->eax;
8205 +               linux_regs->ecx = NEW_esp - (sizeof (int) * 6);
8206 +               linux_regs->ebx = (unsigned int) END_OF_LOOKASIDE;
8207 +               if (NEW_esp < OLD_esp) {
8208 +                       linux_regs->eip = (unsigned int) fn_call_stub;
8209 +               } else {
8210 +                       linux_regs->eip = (unsigned int) fn_rtn_stub;
8211 +                       linux_regs->eax = NEW_esp;
8212 +               }
8213 +               linux_regs->eflags &= ~(IF_BIT | TF_BIT);
8214 +       }
8215 +#ifdef CONFIG_SMP
8216 +       /*
8217 +        * Release gdb wait locks
8218 +        * Sanity check time.  Must have at least one cpu to run.  Also single
8219 +        * step must not be done if the current cpu is on hold.
8220 +        */
8221 +       if (spinlock_count == 1) {
8222 +               int ss_hold = (regs.eflags & 0x100) && kgdb_info.hold_on_sstep;
8223 +               int cpu_avail = 0;
8224 +               int i;
8225 +
8226 +               for (i = 0; i < MAX_NO_CPUS; i++) {
8227 +                       if (!cpu_online(i))
8228 +                               break;
8229 +                       if (!hold_cpu(i)) {
8230 +                               cpu_avail = 1;
8231 +                       }
8232 +               }
8233 +               /*
8234 +                * Early in the bring up there will be NO cpus on line...
8235 +                */
8236 +               if (!cpu_avail && !cpus_empty(cpu_online_map)) {
8237 +                       to_gdb("No cpus unblocked, see 'kgdb_info.hold_cpu'\n");
8238 +                       goto once_again;
8239 +               }
8240 +               if (hold_cpu(smp_processor_id()) && (regs.eflags & 0x100)) {
8241 +                       to_gdb
8242 +                           ("Current cpu must be unblocked to single step\n");
8243 +                       goto once_again;
8244 +               }
8245 +               if (!(ss_hold)) {
8246 +                       int i;
8247 +                       for (i = 0; i < MAX_NO_CPUS; i++) {
8248 +                               if (!hold_cpu(i)) {
8249 +                                       spin_unlock(&waitlocks[i]);
8250 +                               }
8251 +                       }
8252 +               } else {
8253 +                       spin_unlock(&waitlocks[smp_processor_id()]);
8254 +               }
8255 +               /* Release kgdb spinlock */
8256 +               KGDB_SPIN_UNLOCK(&kgdb_spinlock);
8257 +               /*
8258 +                * If this cpu is on hold, this is where we
8259 +                * do it.  Note, the NMI will pull us out of here,
8260 +                * but will return as the above lock is not held.
8261 +                * We will stay here till another cpu releases the lock for us.
8262 +                */
8263 +               spin_unlock_wait(waitlocks + smp_processor_id());
8264 +               kgdb_local_irq_restore(flags);
8265 +               return (0);
8266 +       }
8267 +#if 0
8268 +exit_just_unlock:
8269 +#endif
8270 +#endif
8271 +       /* Release kgdb spinlock */
8272 +       KGDB_SPIN_UNLOCK(&kgdb_spinlock);
8273 +       kgdb_local_irq_restore(flags);
8274 +       return (0);
8275 +}
8276 +
8277 +/* this function is used to set up exception handlers for tracing and
8278 + * breakpoints.
8279 + * This function is not needed as the above line does all that is needed.
8280 + * We leave it for backward compatitability...
8281 + */
8282 +void
8283 +set_debug_traps(void)
8284 +{
8285 +       /*
8286 +        * linux_debug_hook is defined in traps.c.  We store a pointer
8287 +        * to our own exception handler into it.
8288 +
8289 +        * But really folks, every hear of labeled common, an old Fortran
8290 +        * concept.  Lots of folks can reference it and it is define if
8291 +        * anyone does.  Only one can initialize it at link time.  We do
8292 +        * this with the hook.  See the statement above.  No need for any
8293 +        * executable code and it is ready as soon as the kernel is
8294 +        * loaded.  Very desirable in kernel debugging.
8295 +
8296 +        linux_debug_hook = handle_exception ;
8297 +        */
8298 +
8299 +       /* In case GDB is started before us, ack any packets (presumably
8300 +          "$?#xx") sitting there.
8301 +          putDebugChar ('+');
8302 +
8303 +          initialized = 1;
8304 +        */
8305 +}
8306 +
8307 +/* This function will generate a breakpoint exception. It is used at the
8308 +   beginning of a program to sync up with a debugger and can be used
8309 +   otherwise as a quick means to stop program execution and "break" into
8310 +   the debugger. */
8311 +/* But really, just use the BREAKPOINT macro.  We will handle the int stuff
8312 + */
8313 +
8314 +#ifdef later
8315 +/*
8316 + * possibly we should not go thru the traps.c code at all?  Someday.
8317 + */
8318 +void
8319 +do_kgdb_int3(struct pt_regs *regs, long error_code)
8320 +{
8321 +       kgdb_handle_exception(3, 5, error_code, regs);
8322 +       return;
8323 +}
8324 +#endif
8325 +#undef regs
8326 +#ifdef CONFIG_TRAP_BAD_SYSCALL_EXITS
8327 +asmlinkage void
8328 +bad_sys_call_exit(int stuff)
8329 +{
8330 +       struct pt_regs *regs = (struct pt_regs *) &stuff;
8331 +       printk("Sys call %d return with %x preempt_count\n",
8332 +              (int) regs->orig_eax, preempt_count());
8333 +}
8334 +#endif
8335 +#ifdef CONFIG_STACK_OVERFLOW_TEST
8336 +#include <asm/kgdb.h>
8337 +asmlinkage void
8338 +stack_overflow(void)
8339 +{
8340 +#ifdef BREAKPOINT
8341 +       BREAKPOINT;
8342 +#else
8343 +       printk("Kernel stack overflow, looping forever\n");
8344 +#endif
8345 +       while (1) {
8346 +       }
8347 +}
8348 +#endif
8349 +
8350 +#if defined(CONFIG_SMP) || defined(CONFIG_KGDB_CONSOLE)
8351 +char gdbconbuf[BUFMAX];
8352 +
8353 +static void
8354 +kgdb_gdb_message(const char *s, unsigned count)
8355 +{
8356 +       int i;
8357 +       int wcount;
8358 +       char *bufptr;
8359 +       /*
8360 +        * This takes care of NMI while spining out chars to gdb
8361 +        */
8362 +       IF_SMP(in_kgdb_console = 1);
8363 +       gdbconbuf[0] = 'O';
8364 +       bufptr = gdbconbuf + 1;
8365 +       while (count > 0) {
8366 +               if ((count << 1) > (BUFMAX - 2)) {
8367 +                       wcount = (BUFMAX - 2) >> 1;
8368 +               } else {
8369 +                       wcount = count;
8370 +               }
8371 +               count -= wcount;
8372 +               for (i = 0; i < wcount; i++) {
8373 +                       bufptr = pack_hex_byte(bufptr, s[i]);
8374 +               }
8375 +               *bufptr = '\0';
8376 +               s += wcount;
8377 +
8378 +               putpacket(gdbconbuf);
8379 +
8380 +       }
8381 +       IF_SMP(in_kgdb_console = 0);
8382 +}
8383 +#endif
8384 +#ifdef CONFIG_SMP
8385 +static void
8386 +to_gdb(const char *s)
8387 +{
8388 +       int count = 0;
8389 +       while (s[count] && (count++ < BUFMAX)) ;
8390 +       kgdb_gdb_message(s, count);
8391 +}
8392 +#endif
8393 +#ifdef CONFIG_KGDB_CONSOLE
8394 +#include <linux/console.h>
8395 +#include <linux/init.h>
8396 +#include <linux/fs.h>
8397 +#include <asm/uaccess.h>
8398 +#include <asm/semaphore.h>
8399 +
8400 +void
8401 +kgdb_console_write(struct console *co, const char *s, unsigned count)
8402 +{
8403 +
8404 +       if (gdb_i386vector == -1) {
8405 +               /*
8406 +                * We have not yet talked to gdb.  What to do...
8407 +                * lets break, on continue we can do the write.
8408 +                * But first tell him whats up. Uh, well no can do,
8409 +                * as this IS the console.  Oh well...
8410 +                * We do need to wait or the messages will be lost.
8411 +                * Other option would be to tell the above code to
8412 +                * ignore this breakpoint and do an auto return,
8413 +                * but that might confuse gdb.  Also this happens
8414 +                * early enough in boot up that we don't have the traps
8415 +                * set up yet, so...
8416 +                */
8417 +               breakpoint();
8418 +       }
8419 +       kgdb_gdb_message(s, count);
8420 +}
8421 +
8422 +/*
8423 + * ------------------------------------------------------------
8424 + * Serial KGDB driver
8425 + * ------------------------------------------------------------
8426 + */
8427 +
8428 +static struct console kgdbcons = {
8429 +       name:"kgdb",
8430 +       write:kgdb_console_write,
8431 +#ifdef CONFIG_KGDB_USER_CONSOLE
8432 +       device:kgdb_console_device,
8433 +#endif
8434 +       flags:CON_PRINTBUFFER | CON_ENABLED,
8435 +       index:-1,
8436 +};
8437 +
8438 +/*
8439 + * The trick here is that this file gets linked before printk.o
8440 + * That means we get to peer at the console info in the command
8441 + * line before it does.         If we are up, we register, otherwise,
8442 + * do nothing. By returning 0, we allow printk to look also.
8443 + */
8444 +static int kgdb_console_enabled;
8445 +
8446 +int __init
8447 +kgdb_console_init(char *str)
8448 +{
8449 +       if ((strncmp(str, "kgdb", 4) == 0) || (strncmp(str, "gdb", 3) == 0)) {
8450 +               register_console(&kgdbcons);
8451 +               kgdb_console_enabled = 1;
8452 +       }
8453 +       return 0;               /* let others look at the string */
8454 +}
8455 +
8456 +__setup("console=", kgdb_console_init);
8457 +
8458 +#ifdef CONFIG_KGDB_USER_CONSOLE
8459 +static kdev_t kgdb_console_device(struct console *c);
8460 +/* This stuff sort of works, but it knocks out telnet devices
8461 + * we are leaving it here in case we (or you) find time to figure it out
8462 + * better..
8463 + */
8464 +
8465 +/*
8466 + * We need a real char device as well for when the console is opened for user
8467 + * space activities.
8468 + */
8469 +
8470 +static int
8471 +kgdb_consdev_open(struct inode *inode, struct file *file)
8472 +{
8473 +       return 0;
8474 +}
8475 +
8476 +static ssize_t
8477 +kgdb_consdev_write(struct file *file, const char *buf,
8478 +                  size_t count, loff_t * ppos)
8479 +{
8480 +       int size, ret = 0;
8481 +       static char kbuf[128];
8482 +       static DECLARE_MUTEX(sem);
8483 +
8484 +       /* We are not reentrant... */
8485 +       if (down_interruptible(&sem))
8486 +               return -ERESTARTSYS;
8487 +
8488 +       while (count > 0) {
8489 +               /* need to copy the data from user space */
8490 +               size = count;
8491 +               if (size > sizeof (kbuf))
8492 +                       size = sizeof (kbuf);
8493 +               if (copy_from_user(kbuf, buf, size)) {
8494 +                       ret = -EFAULT;
8495 +                       break;;
8496 +               }
8497 +               kgdb_console_write(&kgdbcons, kbuf, size);
8498 +               count -= size;
8499 +               ret += size;
8500 +               buf += size;
8501 +       }
8502 +
8503 +       up(&sem);
8504 +
8505 +       return ret;
8506 +}
8507 +
8508 +struct file_operations kgdb_consdev_fops = {
8509 +       open:kgdb_consdev_open,
8510 +       write:kgdb_consdev_write
8511 +};
8512 +static kdev_t
8513 +kgdb_console_device(struct console *c)
8514 +{
8515 +       return MKDEV(TTYAUX_MAJOR, 1);
8516 +}
8517 +
8518 +/*
8519 + * This routine gets called from the serial stub in the i386/lib
8520 + * This is so it is done late in bring up (just before the console open).
8521 + */
8522 +void
8523 +kgdb_console_finit(void)
8524 +{
8525 +       if (kgdb_console_enabled) {
8526 +               char *cptr = cdevname(MKDEV(TTYAUX_MAJOR, 1));
8527 +               char *cp = cptr;
8528 +               while (*cptr && *cptr != '(')
8529 +                       cptr++;
8530 +               *cptr = 0;
8531 +               unregister_chrdev(TTYAUX_MAJOR, cp);
8532 +               register_chrdev(TTYAUX_MAJOR, "kgdb", &kgdb_consdev_fops);
8533 +       }
8534 +}
8535 +#endif
8536 +#endif
8537 +#ifdef CONFIG_KGDB_TS
8538 +#include <asm/msr.h>           /* time stamp code */
8539 +#include <asm/hardirq.h>       /* in_interrupt */
8540 +#ifdef CONFIG_KGDB_TS_64
8541 +#define DATA_POINTS 64
8542 +#endif
8543 +#ifdef CONFIG_KGDB_TS_128
8544 +#define DATA_POINTS 128
8545 +#endif
8546 +#ifdef CONFIG_KGDB_TS_256
8547 +#define DATA_POINTS 256
8548 +#endif
8549 +#ifdef CONFIG_KGDB_TS_512
8550 +#define DATA_POINTS 512
8551 +#endif
8552 +#ifdef CONFIG_KGDB_TS_1024
8553 +#define DATA_POINTS 1024
8554 +#endif
8555 +#ifndef DATA_POINTS
8556 +#define DATA_POINTS 128                /* must be a power of two */
8557 +#endif
8558 +#define INDEX_MASK (DATA_POINTS - 1)
8559 +#if (INDEX_MASK & DATA_POINTS)
8560 +#error "CONFIG_KGDB_TS_COUNT must be a power of 2"
8561 +#endif
8562 +struct kgdb_and_then_struct {
8563 +#ifdef CONFIG_SMP
8564 +       int on_cpu;
8565 +#endif
8566 +       struct task_struct *task;
8567 +       long long at_time;
8568 +       int from_ln;
8569 +       char *in_src;
8570 +       void *from;
8571 +       int *with_shpf;
8572 +       int data0;
8573 +       int data1;
8574 +};
8575 +struct kgdb_and_then_struct2 {
8576 +#ifdef CONFIG_SMP
8577 +       int on_cpu;
8578 +#endif
8579 +       struct task_struct *task;
8580 +       long long at_time;
8581 +       int from_ln;
8582 +       char *in_src;
8583 +       void *from;
8584 +       int *with_shpf;
8585 +       struct task_struct *t1;
8586 +       struct task_struct *t2;
8587 +};
8588 +struct kgdb_and_then_struct kgdb_data[DATA_POINTS];
8589 +
8590 +struct kgdb_and_then_struct *kgdb_and_then = &kgdb_data[0];
8591 +int kgdb_and_then_count;
8592 +
8593 +void
8594 +kgdb_tstamp(int line, char *source, int data0, int data1)
8595 +{
8596 +       static spinlock_t ts_spin = SPIN_LOCK_UNLOCKED;
8597 +       int flags;
8598 +       kgdb_local_irq_save(flags);
8599 +       spin_lock(&ts_spin);
8600 +       rdtscll(kgdb_and_then->at_time);
8601 +#ifdef CONFIG_SMP
8602 +       kgdb_and_then->on_cpu = smp_processor_id();
8603 +#endif
8604 +       kgdb_and_then->task = current;
8605 +       kgdb_and_then->from_ln = line;
8606 +       kgdb_and_then->in_src = source;
8607 +       kgdb_and_then->from = __builtin_return_address(0);
8608 +       kgdb_and_then->with_shpf = (int *) (((flags & IF_BIT) >> 9) |
8609 +                                           (preempt_count() << 8));
8610 +       kgdb_and_then->data0 = data0;
8611 +       kgdb_and_then->data1 = data1;
8612 +       kgdb_and_then = &kgdb_data[++kgdb_and_then_count & INDEX_MASK];
8613 +       spin_unlock(&ts_spin);
8614 +       kgdb_local_irq_restore(flags);
8615 +#ifdef CONFIG_PREEMPT
8616 +
8617 +#endif
8618 +       return;
8619 +}
8620 +#endif
8621 +typedef int gdb_debug_hook(int exceptionVector,
8622 +                          int signo, int err_code, struct pt_regs *linux_regs);
8623 +gdb_debug_hook *linux_debug_hook = &kgdb_handle_exception;     /* histerical reasons... */
8624 +
8625 +static int __init kgdb_opt_kgdbeth(char *str)
8626 +{
8627 +       kgdb_eth = simple_strtoul(str, NULL, 10);
8628 +       return 1;
8629 +}
8630 +
8631 +static int __init kgdb_opt_kgdbeth_remoteip(char *str)
8632 +{
8633 +       kgdb_remoteip = in_aton(str);
8634 +       return 1;
8635 +}
8636 +
8637 +static int __init kgdb_opt_kgdbeth_listenport(char *str)
8638 +{
8639 +       kgdb_listenport = simple_strtoul(str, NULL, 10);
8640 +       kgdb_sendport = kgdb_listenport - 1;
8641 +       return 1;
8642 +}
8643 +
8644 +static int __init parse_hw_addr(char *str, unsigned char *addr)
8645 +{
8646 +       int  i;
8647 +       char *p;
8648 +
8649 +       p = str;
8650 +       i = 0;
8651 +       while(1)
8652 +       {
8653 +               unsigned int c;
8654 +
8655 +               sscanf(p, "%x:", &c);
8656 +               addr[i++] = c;
8657 +               while((*p != 0) && (*p != ':')) {
8658 +                       p++;
8659 +               }
8660 +               if (*p == 0) {
8661 +                       break;
8662 +               }
8663 +               p++;
8664 +       }
8665 +
8666 +       return 1;
8667 +}
8668 +
8669 +static int __init kgdb_opt_kgdbeth_remotemac(char *str)
8670 +{
8671 +       return parse_hw_addr(str, kgdb_remotemac);
8672 +}
8673 +static int __init kgdb_opt_kgdbeth_localmac(char *str)
8674 +{
8675 +       return parse_hw_addr(str, kgdb_localmac);
8676 +}
8677 +
8678 +
8679 +__setup("gdbeth=", kgdb_opt_kgdbeth);
8680 +__setup("gdbeth_remoteip=", kgdb_opt_kgdbeth_remoteip);
8681 +__setup("gdbeth_listenport=", kgdb_opt_kgdbeth_listenport);
8682 +__setup("gdbeth_remotemac=", kgdb_opt_kgdbeth_remotemac);
8683 +__setup("gdbeth_localmac=", kgdb_opt_kgdbeth_localmac);
8684 +
8685 --- linux-2.6.0-test6/arch/i386/kernel/ldt.c    2003-08-22 19:23:40.000000000 -0700
8686 +++ 25/arch/i386/kernel/ldt.c   2003-10-05 00:36:48.000000000 -0700
8687 @@ -2,7 +2,7 @@
8688   * linux/kernel/ldt.c
8689   *
8690   * Copyright (C) 1992 Krishna Balasubramanian and Linus Torvalds
8691 - * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
8692 + * Copyright (C) 1999, 2003 Ingo Molnar <mingo@redhat.com>
8693   */
8694  
8695  #include <linux/errno.h>
8696 @@ -18,6 +18,8 @@
8697  #include <asm/system.h>
8698  #include <asm/ldt.h>
8699  #include <asm/desc.h>
8700 +#include <linux/highmem.h>
8701 +#include <asm/atomic_kmap.h>
8702  
8703  #ifdef CONFIG_SMP /* avoids "defined but not used" warnig */
8704  static void flush_ldt(void *null)
8705 @@ -29,34 +31,31 @@ static void flush_ldt(void *null)
8706  
8707  static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
8708  {
8709 -       void *oldldt;
8710 -       void *newldt;
8711 -       int oldsize;
8712 +       int oldsize, newsize, i;
8713  
8714         if (mincount <= pc->size)
8715                 return 0;
8716 +       /*
8717 +        * LDT got larger - reallocate if necessary.
8718 +        */
8719         oldsize = pc->size;
8720         mincount = (mincount+511)&(~511);
8721 -       if (mincount*LDT_ENTRY_SIZE > PAGE_SIZE)
8722 -               newldt = vmalloc(mincount*LDT_ENTRY_SIZE);
8723 -       else
8724 -               newldt = kmalloc(mincount*LDT_ENTRY_SIZE, GFP_KERNEL);
8725 -
8726 -       if (!newldt)
8727 -               return -ENOMEM;
8728 -
8729 -       if (oldsize)
8730 -               memcpy(newldt, pc->ldt, oldsize*LDT_ENTRY_SIZE);
8731 -       oldldt = pc->ldt;
8732 -       memset(newldt+oldsize*LDT_ENTRY_SIZE, 0, (mincount-oldsize)*LDT_ENTRY_SIZE);
8733 -       pc->ldt = newldt;
8734 -       wmb();
8735 +       newsize = mincount*LDT_ENTRY_SIZE;
8736 +       for (i = 0; i < newsize; i += PAGE_SIZE) {
8737 +               int nr = i/PAGE_SIZE;
8738 +               BUG_ON(i >= 64*1024);
8739 +               if (!pc->ldt_pages[nr]) {
8740 +                       pc->ldt_pages[nr] = alloc_page(GFP_HIGHUSER);
8741 +                       if (!pc->ldt_pages[nr])
8742 +                               return -ENOMEM;
8743 +                       clear_highpage(pc->ldt_pages[nr]);
8744 +               }
8745 +       }
8746         pc->size = mincount;
8747 -       wmb();
8748 -
8749         if (reload) {
8750  #ifdef CONFIG_SMP
8751                 cpumask_t mask;
8752 +
8753                 preempt_disable();
8754                 load_LDT(pc);
8755                 mask = cpumask_of_cpu(smp_processor_id());
8756 @@ -67,21 +66,20 @@ static int alloc_ldt(mm_context_t *pc, i
8757                 load_LDT(pc);
8758  #endif
8759         }
8760 -       if (oldsize) {
8761 -               if (oldsize*LDT_ENTRY_SIZE > PAGE_SIZE)
8762 -                       vfree(oldldt);
8763 -               else
8764 -                       kfree(oldldt);
8765 -       }
8766         return 0;
8767  }
8768  
8769  static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
8770  {
8771 -       int err = alloc_ldt(new, old->size, 0);
8772 -       if (err < 0)
8773 +       int i, err, size = old->size, nr_pages = (size*LDT_ENTRY_SIZE + PAGE_SIZE-1)/PAGE_SIZE;
8774 +
8775 +       err = alloc_ldt(new, size, 0);
8776 +       if (err < 0) {
8777 +               new->size = 0;
8778                 return err;
8779 -       memcpy(new->ldt, old->ldt, old->size*LDT_ENTRY_SIZE);
8780 +       }
8781 +       for (i = 0; i < nr_pages; i++)
8782 +               copy_user_highpage(new->ldt_pages[i], old->ldt_pages[i], 0);
8783         return 0;
8784  }
8785  
8786 @@ -96,6 +94,7 @@ int init_new_context(struct task_struct 
8787  
8788         init_MUTEX(&mm->context.sem);
8789         mm->context.size = 0;
8790 +       memset(mm->context.ldt_pages, 0, sizeof(struct page *) * MAX_LDT_PAGES);
8791         old_mm = current->mm;
8792         if (old_mm && old_mm->context.size > 0) {
8793                 down(&old_mm->context.sem);
8794 @@ -107,23 +106,21 @@ int init_new_context(struct task_struct 
8795  
8796  /*
8797   * No need to lock the MM as we are the last user
8798 + * Do not touch the ldt register, we are already
8799 + * in the next thread.
8800   */
8801  void destroy_context(struct mm_struct *mm)
8802  {
8803 -       if (mm->context.size) {
8804 -               if (mm == current->active_mm)
8805 -                       clear_LDT();
8806 -               if (mm->context.size*LDT_ENTRY_SIZE > PAGE_SIZE)
8807 -                       vfree(mm->context.ldt);
8808 -               else
8809 -                       kfree(mm->context.ldt);
8810 -               mm->context.size = 0;
8811 -       }
8812 +       int i, nr_pages = (mm->context.size*LDT_ENTRY_SIZE + PAGE_SIZE-1) / PAGE_SIZE;
8813 +
8814 +       for (i = 0; i < nr_pages; i++)
8815 +               __free_page(mm->context.ldt_pages[i]);
8816 +       mm->context.size = 0;
8817  }
8818  
8819  static int read_ldt(void __user * ptr, unsigned long bytecount)
8820  {
8821 -       int err;
8822 +       int err, i;
8823         unsigned long size;
8824         struct mm_struct * mm = current->mm;
8825  
8826 @@ -138,8 +135,25 @@ static int read_ldt(void __user * ptr, u
8827                 size = bytecount;
8828  
8829         err = 0;
8830 -       if (copy_to_user(ptr, mm->context.ldt, size))
8831 -               err = -EFAULT;
8832 +       /*
8833 +        * This is necessary just in case we got here straight from a
8834 +        * context-switch where the ptes were set but no tlb flush
8835 +        * was done yet. We rather avoid doing a TLB flush in the
8836 +        * context-switch path and do it here instead.
8837 +        */
8838 +       __flush_tlb_global();
8839 +
8840 +       for (i = 0; i < size; i += PAGE_SIZE) {
8841 +               int nr = i / PAGE_SIZE, bytes;
8842 +               char *kaddr = kmap(mm->context.ldt_pages[nr]);
8843 +
8844 +               bytes = size - i;
8845 +               if (bytes > PAGE_SIZE)
8846 +                       bytes = PAGE_SIZE;
8847 +               if (copy_to_user(ptr + i, kaddr, size - i))
8848 +                       err = -EFAULT;
8849 +               kunmap(mm->context.ldt_pages[nr]);
8850 +       }
8851         up(&mm->context.sem);
8852         if (err < 0)
8853                 return err;
8854 @@ -158,7 +172,7 @@ static int read_default_ldt(void __user 
8855  
8856         err = 0;
8857         address = &default_ldt[0];
8858 -       size = 5*sizeof(struct desc_struct);
8859 +       size = 5*LDT_ENTRY_SIZE;
8860         if (size > bytecount)
8861                 size = bytecount;
8862  
8863 @@ -200,7 +214,15 @@ static int write_ldt(void __user * ptr, 
8864                         goto out_unlock;
8865         }
8866  
8867 -       lp = (__u32 *) ((ldt_info.entry_number << 3) + (char *) mm->context.ldt);
8868 +       /*
8869 +        * No rescheduling allowed from this point to the install.
8870 +        *
8871 +        * We do a TLB flush for the same reason as in the read_ldt() path.
8872 +        */
8873 +       preempt_disable();
8874 +       __flush_tlb_global();
8875 +       lp = (__u32 *) ((ldt_info.entry_number << 3) +
8876 +                       (char *) __kmap_atomic_vaddr(KM_LDT_PAGE0));
8877  
8878         /* Allow LDTs to be cleared by the user. */
8879         if (ldt_info.base_addr == 0 && ldt_info.limit == 0) {
8880 @@ -221,6 +243,7 @@ install:
8881         *lp     = entry_1;
8882         *(lp+1) = entry_2;
8883         error = 0;
8884 +       preempt_enable();
8885  
8886  out_unlock:
8887         up(&mm->context.sem);
8888 @@ -248,3 +271,26 @@ asmlinkage int sys_modify_ldt(int func, 
8889         }
8890         return ret;
8891  }
8892 +
8893 +/*
8894 + * load one particular LDT into the current CPU
8895 + */
8896 +void load_LDT_nolock(mm_context_t *pc, int cpu)
8897 +{
8898 +       struct page **pages = pc->ldt_pages;
8899 +       int count = pc->size;
8900 +       int nr_pages, i;
8901 +
8902 +       if (likely(!count)) {
8903 +               pages = &default_ldt_page;
8904 +               count = 5;
8905 +       }
8906 +               nr_pages = (count*LDT_ENTRY_SIZE + PAGE_SIZE-1) / PAGE_SIZE;
8907 +
8908 +       for (i = 0; i < nr_pages; i++) {
8909 +               __kunmap_atomic_type(KM_LDT_PAGE0 - i);
8910 +               __kmap_atomic(pages[i], KM_LDT_PAGE0 - i);
8911 +       }
8912 +       set_ldt_desc(cpu, (void *)__kmap_atomic_vaddr(KM_LDT_PAGE0), count);
8913 +       load_LDT_desc();
8914 +}
8915 --- linux-2.6.0-test6/arch/i386/kernel/Makefile 2003-09-27 18:57:43.000000000 -0700
8916 +++ 25/arch/i386/kernel/Makefile        2003-10-05 00:36:48.000000000 -0700
8917 @@ -7,13 +7,14 @@ extra-y := head.o init_task.o vmlinux.ld
8918  obj-y  := process.o semaphore.o signal.o entry.o traps.o irq.o vm86.o \
8919                 ptrace.o i8259.o ioport.o ldt.o setup.o time.o sys_i386.o \
8920                 pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \
8921 -               doublefault.o
8922 +               doublefault.o efi.o efi_stub.o entry_trampoline.o
8923  
8924  obj-y                          += cpu/
8925  obj-y                          += timers/
8926  obj-$(CONFIG_ACPI_BOOT)                += acpi/
8927  obj-$(CONFIG_X86_BIOS_REBOOT)  += reboot.o
8928  obj-$(CONFIG_MCA)              += mca.o
8929 +obj-$(CONFIG_KGDB)             += kgdb_stub.o
8930  obj-$(CONFIG_X86_MSR)          += msr.o
8931  obj-$(CONFIG_X86_CPUID)                += cpuid.o
8932  obj-$(CONFIG_MICROCODE)                += microcode.o
8933 --- linux-2.6.0-test6/arch/i386/kernel/mca.c    2003-08-22 19:23:40.000000000 -0700
8934 +++ 25/arch/i386/kernel/mca.c   2003-10-05 00:36:10.000000000 -0700
8935 @@ -132,7 +132,9 @@ struct resource mca_standard_resources[]
8936  #define MCA_STANDARD_RESOURCES (sizeof(mca_standard_resources)/sizeof(struct resource))
8937  
8938  /**
8939 - *     mca_read_pos - read the POS registers into a memory buffer
8940 + *     mca_read_and_store_pos - read the POS registers into a memory buffer
8941 + *      @pos: a char pointer to 8 bytes, contains the POS register value on
8942 + *            successful return
8943   *
8944   *     Returns 1 if a card actually exists (i.e. the pos isn't
8945   *     all 0xff) or 0 otherwise
8946 --- linux-2.6.0-test6/arch/i386/kernel/mpparse.c        2003-09-27 18:57:43.000000000 -0700
8947 +++ 25/arch/i386/kernel/mpparse.c       2003-10-05 00:36:48.000000000 -0700
8948 @@ -169,7 +169,7 @@ void __init MP_processor_info (struct mp
8949  
8950         if (num_processors >= NR_CPUS) {
8951                 printk(KERN_WARNING "NR_CPUS limit of %i reached.  Cannot "
8952 -                       "boot CPU(apicid 0x%d).\n", NR_CPUS, m->mpc_apicid);
8953 +                       "boot CPU(apicid 0x%x).\n", NR_CPUS, m->mpc_apicid);
8954                 return;
8955         }
8956         num_processors++;
8957 @@ -616,6 +616,31 @@ static inline void __init construct_defa
8958         }
8959  }
8960  
8961 +#ifdef CONFIG_X86_IO_APIC
8962 +/* irq_vector must be have an entry for all RTEs of all I/O APICs. */
8963 +void __init alloc_irq_vector_array(void)
8964 +{
8965 +       int     total = 0;
8966 +       int     idx;
8967 +       union IO_APIC_reg_01    reg_01;
8968 +
8969 +       /* The I/O APIC fixmaps aren't inited yet, so use the first one. */
8970 +       for (idx = 0; idx < nr_ioapics; idx++) {
8971 +               set_fixmap_nocache(FIX_IO_APIC_BASE_0, mp_ioapics[idx].mpc_apicaddr);
8972 +               reg_01.raw = io_apic_read(0, 1);
8973 +               total += reg_01.bits.entries + 1;
8974 +       }
8975 +
8976 +       /* Always alloc at least NR_IRQS vectors. */
8977 +       nr_irqs = max(total, NR_IRQS);
8978 +       irq_vector = (u8 *) alloc_bootmem(nr_irqs);
8979 +       memset(irq_vector, 0, nr_irqs);
8980 +       irq_vector[0] = FIRST_DEVICE_VECTOR;
8981 +}
8982 +#else
8983 +void __init alloc_irq_vector_array(void) { }
8984 +#endif /* CONFIG_X86_IO_APIC */
8985 +
8986  static struct intel_mp_floating *mpf_found;
8987  
8988  /*
8989 @@ -633,6 +658,7 @@ void __init get_smp_config (void)
8990          */
8991         if (acpi_lapic && acpi_ioapic) {
8992                 printk(KERN_INFO "Using ACPI (MADT) for SMP configuration information\n");
8993 +               alloc_irq_vector_array();
8994                 return;
8995         }
8996         else if (acpi_lapic)
8997 @@ -661,10 +687,11 @@ void __init get_smp_config (void)
8998                  * Read the physical hardware table.  Anything here will
8999                  * override the defaults.
9000                  */
9001 -               if (!smp_read_mpc((void *)mpf->mpf_physptr)) {
9002 +               if (!smp_read_mpc((void *)phys_to_virt(mpf->mpf_physptr))) {
9003                         smp_found_config = 0;
9004                         printk(KERN_ERR "BIOS bug, MP table errors detected!...\n");
9005                         printk(KERN_ERR "... disabling SMP support. (tell your hw vendor)\n");
9006 +                       alloc_irq_vector_array();
9007                         return;
9008                 }
9009                 /*
9010 @@ -688,6 +715,7 @@ void __init get_smp_config (void)
9011         } else
9012                 BUG();
9013  
9014 +       alloc_irq_vector_array();
9015         printk(KERN_INFO "Processors: %d\n", num_processors);
9016         /*
9017          * Only use the first configuration found.
9018 @@ -830,7 +858,7 @@ void __init mp_register_lapic (
9019         MP_processor_info(&processor);
9020  }
9021  
9022 -#ifdef CONFIG_X86_IO_APIC
9023 +#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)
9024  
9025  #define MP_ISA_BUS             0
9026  #define MP_MAX_IOAPIC_PIN      127
9027 @@ -1019,10 +1047,6 @@ void __init mp_config_acpi_legacy_irqs (
9028         }
9029  }
9030  
9031 -#ifdef CONFIG_ACPI
9032 -
9033 -/* Ensure the ACPI SCI interrupt level is active low, edge-triggered */
9034 -
9035  extern FADT_DESCRIPTOR acpi_fadt;
9036  
9037  void __init mp_config_ioapic_for_sci(int irq)
9038 @@ -1031,6 +1055,7 @@ void __init mp_config_ioapic_for_sci(int
9039         int ioapic_pin;
9040         struct acpi_table_madt *madt;
9041         struct acpi_table_int_src_ovr *entry = NULL;
9042 +       acpi_interrupt_flags flags;
9043         void *madt_end;
9044         acpi_status status;
9045  
9046 @@ -1049,32 +1074,37 @@ void __init mp_config_ioapic_for_sci(int
9047  
9048                 while ((void *) entry < madt_end) {
9049                         if (entry->header.type == ACPI_MADT_INT_SRC_OVR &&
9050 -                           acpi_fadt.sci_int == entry->bus_irq) {
9051 -                               /*
9052 -                                * See the note at the end of ACPI 2.0b section
9053 -                                * 5.2.10.8 for what this is about.
9054 -                                */
9055 -                               if (entry->bus_irq != entry->global_irq) {
9056 -                                       acpi_fadt.sci_int = entry->global_irq;
9057 -                                       irq = entry->global_irq;
9058 -                                       break;
9059 -                               }
9060 -                               else
9061 -                                       return;
9062 -                       }
9063 -
9064 +                           acpi_fadt.sci_int == entry->bus_irq)
9065 +                               goto found;
9066 +                       
9067                         entry = (struct acpi_table_int_src_ovr *)
9068                                 ((unsigned long) entry + entry->header.length);
9069                 }
9070         }
9071 +       /*
9072 +        * Although the ACPI spec says that the SCI should be level/low
9073 +        * don't reprogram it unless there is an explicit MADT OVR entry
9074 +        * instructing us to do so -- otherwise we break Tyan boards which
9075 +        * have the SCI wired edge/high but no MADT OVR.
9076 +        */
9077 +       return;
9078 +
9079 +found:
9080 +       /*
9081 +        * See the note at the end of ACPI 2.0b section
9082 +        * 5.2.10.8 for what this is about.
9083 +        */
9084 +       flags = entry->flags;
9085 +       acpi_fadt.sci_int = entry->global_irq;
9086 +       irq = entry->global_irq;
9087  
9088         ioapic = mp_find_ioapic(irq);
9089  
9090         ioapic_pin = irq - mp_ioapic_routing[ioapic].irq_start;
9091  
9092 -       io_apic_set_pci_routing(ioapic, ioapic_pin, irq, 1, 1); // Active low, level triggered
9093 +       io_apic_set_pci_routing(ioapic, ioapic_pin, irq, 
9094 +                               (flags.trigger >> 1) , (flags.polarity >> 1));
9095  }
9096 -#endif /* CONFIG_ACPI */
9097  
9098  #ifdef CONFIG_ACPI_PCI
9099  
9100 @@ -1110,8 +1140,10 @@ void __init mp_parse_prt (void)
9101                 }
9102  
9103                 /* Don't set up the ACPI SCI because it's already set up */
9104 -               if (acpi_fadt.sci_int == irq)
9105 +                if (acpi_fadt.sci_int == irq) {
9106 +                        entry->irq = irq; /*we still need to set entry's irq*/
9107                         continue;
9108 +                }
9109         
9110                 ioapic = mp_find_ioapic(irq);
9111                 if (ioapic < 0)
9112 @@ -1136,15 +1168,19 @@ void __init mp_parse_prt (void)
9113                 if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {
9114                         printk(KERN_DEBUG "Pin %d-%d already programmed\n",
9115                                 mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
9116 -                       entry->irq = irq;
9117 +                       if (use_pci_vector() && !platform_legacy_irq(irq))
9118 +                               irq = IO_APIC_VECTOR(irq);
9119 +                       entry->irq = irq;
9120                         continue;
9121                 }
9122  
9123                 mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
9124  
9125 -               if (!io_apic_set_pci_routing(ioapic, ioapic_pin, irq, edge_level, active_high_low))
9126 -                       entry->irq = irq;
9127 -
9128 +               if (!io_apic_set_pci_routing(ioapic, ioapic_pin, irq, edge_level, active_high_low)) {
9129 +                       if (use_pci_vector() && !platform_legacy_irq(irq))
9130 +                               irq = IO_APIC_VECTOR(irq);
9131 +                       entry->irq = irq;
9132 +               }
9133                 printk(KERN_DEBUG "%02x:%02x:%02x[%c] -> %d-%d -> IRQ %d\n",
9134                         entry->id.segment, entry->id.bus, 
9135                         entry->id.device, ('A' + entry->pin), 
9136 @@ -1154,5 +1190,5 @@ void __init mp_parse_prt (void)
9137  }
9138  
9139  #endif /*CONFIG_ACPI_PCI*/
9140 -#endif /* CONFIG_X86_IO_APIC */
9141 +#endif /*CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER*/
9142  #endif /*CONFIG_ACPI_BOOT*/
9143 --- linux-2.6.0-test6/arch/i386/kernel/nmi.c    2003-08-08 22:55:10.000000000 -0700
9144 +++ 25/arch/i386/kernel/nmi.c   2003-10-05 00:33:38.000000000 -0700
9145 @@ -31,7 +31,16 @@
9146  #include <asm/mpspec.h>
9147  #include <asm/nmi.h>
9148  
9149 +#ifdef CONFIG_KGDB
9150 +#include <asm/kgdb.h>
9151 +#ifdef CONFIG_SMP
9152 +unsigned int nmi_watchdog = NMI_IO_APIC;
9153 +#else
9154 +unsigned int nmi_watchdog = NMI_LOCAL_APIC;
9155 +#endif
9156 +#else
9157  unsigned int nmi_watchdog = NMI_NONE;
9158 +#endif
9159  static unsigned int nmi_hz = HZ;
9160  unsigned int nmi_perfctr_msr;  /* the MSR to reset in NMI handler */
9161  extern void show_registers(struct pt_regs *regs);
9162 @@ -408,6 +417,9 @@ void touch_nmi_watchdog (void)
9163         for (i = 0; i < NR_CPUS; i++)
9164                 alert_counter[i] = 0;
9165  }
9166 +#ifdef CONFIG_KGDB
9167 +int tune_watchdog = 5*HZ;
9168 +#endif
9169  
9170  void nmi_watchdog_tick (struct pt_regs * regs)
9171  {
9172 @@ -421,12 +433,24 @@ void nmi_watchdog_tick (struct pt_regs *
9173  
9174         sum = irq_stat[cpu].apic_timer_irqs;
9175  
9176 +#ifdef CONFIG_KGDB
9177 +       if (! in_kgdb(regs) && last_irq_sums[cpu] == sum ) {
9178 +
9179 +#else
9180         if (last_irq_sums[cpu] == sum) {
9181 +#endif
9182                 /*
9183                  * Ayiee, looks like this CPU is stuck ...
9184                  * wait a few IRQs (5 seconds) before doing the oops ...
9185                  */
9186                 alert_counter[cpu]++;
9187 +#ifdef CONFIG_KGDB
9188 +                if (alert_counter[cpu] == tune_watchdog) {
9189 +                        kgdb_handle_exception(2, SIGPWR, 0, regs);
9190 +                        last_irq_sums[cpu] = sum;
9191 +                        alert_counter[cpu] = 0;
9192 +                }
9193 +#endif
9194                 if (alert_counter[cpu] == 5*nmi_hz) {
9195                         spin_lock(&nmi_print_lock);
9196                         /*
9197 --- linux-2.6.0-test6/arch/i386/kernel/process.c        2003-09-27 18:57:43.000000000 -0700
9198 +++ 25/arch/i386/kernel/process.c       2003-10-05 00:36:48.000000000 -0700
9199 @@ -47,6 +47,7 @@
9200  #include <asm/i387.h>
9201  #include <asm/irq.h>
9202  #include <asm/desc.h>
9203 +#include <asm/atomic_kmap.h>
9204  #ifdef CONFIG_MATH_EMULATION
9205  #include <asm/math_emu.h>
9206  #endif
9207 @@ -298,6 +299,9 @@ void flush_thread(void)
9208         struct task_struct *tsk = current;
9209  
9210         memset(tsk->thread.debugreg, 0, sizeof(unsigned long)*8);
9211 +#ifdef CONFIG_X86_HIGH_ENTRY
9212 +       clear_thread_flag(TIF_DB7);
9213 +#endif
9214         memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));        
9215         /*
9216          * Forget coprocessor state..
9217 @@ -311,9 +315,8 @@ void release_thread(struct task_struct *
9218         if (dead_task->mm) {
9219                 // temporary debugging check
9220                 if (dead_task->mm->context.size) {
9221 -                       printk("WARNING: dead process %8s still has LDT? <%p/%d>\n",
9222 +                       printk("WARNING: dead process %8s still has LDT? <%d>\n",
9223                                         dead_task->comm,
9224 -                                       dead_task->mm->context.ldt,
9225                                         dead_task->mm->context.size);
9226                         BUG();
9227                 }
9228 @@ -348,7 +351,17 @@ int copy_thread(int nr, unsigned long cl
9229         p->thread.esp = (unsigned long) childregs;
9230         p->thread.esp0 = (unsigned long) (childregs+1);
9231  
9232 +       /*
9233 +        * get the two stack pages, for the virtual stack.
9234 +        *
9235 +        * IMPORTANT: this code relies on the fact that the task
9236 +        * structure is an 8K aligned piece of physical memory.
9237 +        */
9238 +       p->thread.stack_page0 = virt_to_page((unsigned long)p->thread_info);
9239 +       p->thread.stack_page1 = virt_to_page((unsigned long)p->thread_info + PAGE_SIZE);
9240 +
9241         p->thread.eip = (unsigned long) ret_from_fork;
9242 +       p->thread_info->real_stack = p->thread_info;
9243  
9244         savesegment(fs,p->thread.fs);
9245         savesegment(gs,p->thread.gs);
9246 @@ -500,10 +513,40 @@ struct task_struct * __switch_to(struct 
9247  
9248         __unlazy_fpu(prev_p);
9249  
9250 +#ifdef CONFIG_X86_HIGH_ENTRY
9251 +       /*
9252 +        * Set the ptes of the virtual stack. (NOTE: a one-page TLB flush is
9253 +        * needed because otherwise NMIs could interrupt the
9254 +        * user-return code with a virtual stack and stale TLBs.)
9255 +        */
9256 +       __kunmap_atomic_type(KM_VSTACK0);
9257 +       __kunmap_atomic_type(KM_VSTACK1);
9258 +       __kmap_atomic(next->stack_page0, KM_VSTACK0);
9259 +       __kmap_atomic(next->stack_page1, KM_VSTACK1);
9260 +
9261 +       /*
9262 +        * NOTE: here we rely on the task being the stack as well
9263 +        */
9264 +       next_p->thread_info->virtual_stack = (void *)__kmap_atomic_vaddr(KM_VSTACK0);
9265 +
9266 +#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP)
9267 +       /*
9268 +        * If next was preempted on entry from userspace to kernel,
9269 +        * and now it's on a different cpu, we need to adjust %esp.
9270 +        * This assumes that entry.S does not copy %esp while on the
9271 +        * virtual stack (with interrupts enabled): which is so,
9272 +        * except within __SWITCH_KERNELSPACE itself.
9273 +        */
9274 +       if (unlikely(next->esp >= TASK_SIZE)) {
9275 +               next->esp &= THREAD_SIZE - 1;
9276 +               next->esp |= (unsigned long) next_p->thread_info->virtual_stack;
9277 +       }
9278 +#endif
9279 +#endif
9280         /*
9281 -        * Reload esp0, LDT and the page table pointer:
9282 +        * Reload esp0:
9283          */
9284 -       load_esp0(tss, next->esp0);
9285 +       load_esp0(tss, virtual_esp0(next_p));
9286  
9287         /*
9288          * Load the per-thread Thread-Local Storage descriptor.
9289 --- linux-2.6.0-test6/arch/i386/kernel/reboot.c 2003-09-27 18:57:43.000000000 -0700
9290 +++ 25/arch/i386/kernel/reboot.c        2003-10-05 00:36:48.000000000 -0700
9291 @@ -7,6 +7,7 @@
9292  #include <linux/init.h>
9293  #include <linux/interrupt.h>
9294  #include <linux/mc146818rtc.h>
9295 +#include <linux/efi.h>
9296  #include <asm/uaccess.h>
9297  #include <asm/apic.h>
9298  #include "mach_reboot.h"
9299 @@ -153,12 +154,11 @@ void machine_real_restart(unsigned char 
9300         CMOS_WRITE(0x00, 0x8f);
9301         spin_unlock_irqrestore(&rtc_lock, flags);
9302  
9303 -       /* Remap the kernel at virtual address zero, as well as offset zero
9304 -          from the kernel segment.  This assumes the kernel segment starts at
9305 -          virtual address PAGE_OFFSET. */
9306 -
9307 -       memcpy (swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS,
9308 -               sizeof (swapper_pg_dir [0]) * KERNEL_PGD_PTRS);
9309 +       /*
9310 +        * Remap the first 16 MB of RAM (which includes the kernel image)
9311 +        * at virtual address zero:
9312 +        */
9313 +       setup_identity_mappings(swapper_pg_dir, 0, 16*1024*1024);
9314  
9315         /*
9316          * Use `swapper_pg_dir' as our page directory.
9317 @@ -262,7 +262,12 @@ void machine_restart(char * __unused)
9318         disable_IO_APIC();
9319  #endif
9320  
9321 -       if(!reboot_thru_bios) {
9322 +       if (!reboot_thru_bios) {
9323 +               if (efi_enabled) {
9324 +                       efi.reset_system(EFI_RESET_COLD, EFI_SUCCESS, 0, 0);
9325 +                       __asm__ __volatile__("lidt %0": :"m" (no_idt));
9326 +                       __asm__ __volatile__("int3");
9327 +               }
9328                 /* rebooting needs to touch the page at absolute addr 0 */
9329                 *((unsigned short *)__va(0x472)) = reboot_mode;
9330                 for (;;) {
9331 @@ -272,6 +277,8 @@ void machine_restart(char * __unused)
9332                         __asm__ __volatile__("int3");
9333                 }
9334         }
9335 +       if (efi_enabled)
9336 +               efi.reset_system(EFI_RESET_WARM, EFI_SUCCESS, 0, 0);
9337  
9338         machine_real_restart(jump_to_bios, sizeof(jump_to_bios));
9339  }
9340 @@ -282,6 +289,8 @@ void machine_halt(void)
9341  
9342  void machine_power_off(void)
9343  {
9344 +       if (efi_enabled)
9345 +               efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, 0);
9346         if (pm_power_off)
9347                 pm_power_off();
9348  }
9349 --- linux-2.6.0-test6/arch/i386/kernel/setup.c  2003-09-27 18:57:43.000000000 -0700
9350 +++ 25/arch/i386/kernel/setup.c 2003-10-05 00:36:22.000000000 -0700
9351 @@ -36,6 +36,8 @@
9352  #include <linux/root_dev.h>
9353  #include <linux/highmem.h>
9354  #include <linux/module.h>
9355 +#include <linux/efi.h>
9356 +#include <linux/init.h>
9357  #include <video/edid.h>
9358  #include <asm/e820.h>
9359  #include <asm/mpspec.h>
9360 @@ -56,6 +58,8 @@ static inline char * __init machine_spec
9361   * Machine setup..
9362   */
9363  
9364 +int efi_enabled = 0;
9365 +
9366  /* cpu data as detected by the assembly code in head.S */
9367  struct cpuinfo_x86 new_cpu_data __initdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
9368  /* common cpu data for all cpus */
9369 @@ -64,10 +68,10 @@ struct cpuinfo_x86 boot_cpu_data = { 0, 
9370  unsigned long mmu_cr4_features;
9371  EXPORT_SYMBOL_GPL(mmu_cr4_features);
9372  
9373 -#ifdef CONFIG_ACPI
9374 -       int acpi_disabled __initdata = 0;
9375 +#ifdef CONFIG_ACPI_INTERPRETER
9376 +       int acpi_disabled = 0;
9377  #else
9378 -       int acpi_disabled __initdata = 1;
9379 +       int acpi_disabled = 1;
9380  #endif
9381  EXPORT_SYMBOL(acpi_disabled);
9382  
9383 @@ -144,6 +148,20 @@ static void __init limit_regions (unsign
9384         int i;
9385         unsigned long long current_size = 0;
9386  
9387 +       if (efi_enabled) {
9388 +               for (i = 0; i < memmap.nr_map; i++) {
9389 +                       current_size = memmap.map[i].phys_addr +
9390 +                                      (memmap.map[i].num_pages << 12);
9391 +                       if (memmap.map[i].type == EFI_CONVENTIONAL_MEMORY) {
9392 +                               if (current_size > size) {
9393 +                                       memmap.map[i].num_pages -=
9394 +                                               (((current_size-size) + PAGE_SIZE-1) >> PAGE_SHIFT);
9395 +                                       memmap.nr_map = i + 1;
9396 +                                       return;
9397 +                               }
9398 +                       }
9399 +               }
9400 +       }
9401         for (i = 0; i < e820.nr_map; i++) {
9402                 if (e820.map[i].type == E820_RAM) {
9403                         current_size += e820.map[i].size;
9404 @@ -158,17 +176,21 @@ static void __init limit_regions (unsign
9405  static void __init add_memory_region(unsigned long long start,
9406                                    unsigned long long size, int type)
9407  {
9408 -       int x = e820.nr_map;
9409 +       int x;
9410  
9411 -       if (x == E820MAX) {
9412 -           printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
9413 -           return;
9414 -       }
9415 +       if (!efi_enabled) {
9416 +                       x = e820.nr_map;
9417  
9418 -       e820.map[x].addr = start;
9419 -       e820.map[x].size = size;
9420 -       e820.map[x].type = type;
9421 -       e820.nr_map++;
9422 +               if (x == E820MAX) {
9423 +                   printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
9424 +                   return;
9425 +               }
9426 +
9427 +               e820.map[x].addr = start;
9428 +               e820.map[x].size = size;
9429 +               e820.map[x].type = type;
9430 +               e820.nr_map++;
9431 +       }
9432  } /* add_memory_region */
9433  
9434  #define E820_DEBUG     1
9435 @@ -445,7 +467,6 @@ static inline void copy_edd(void)
9436  static void __init setup_memory_region(void)
9437  {
9438         char *who = machine_specific_memory_setup();
9439 -
9440         printk(KERN_INFO "BIOS-provided physical RAM map:\n");
9441         print_memory_map(who);
9442  } /* setup_memory_region */
9443 @@ -583,6 +604,23 @@ static void __init parse_cmdline_early (
9444  }
9445  
9446  /*
9447 + * Callback for efi_memory_walk.
9448 + */
9449 +static int __init
9450 +efi_find_max_pfn(unsigned long start, unsigned long end, void *arg)
9451 +{
9452 +       unsigned long *max_pfn = arg, pfn;
9453 +
9454 +       if (start < end) {
9455 +               pfn = PFN_UP(end -1);
9456 +               if (pfn > *max_pfn)
9457 +                       *max_pfn = pfn;
9458 +       }
9459 +       return 0;
9460 +}
9461 +
9462 +
9463 +/*
9464   * Find the highest page frame number we have available
9465   */
9466  void __init find_max_pfn(void)
9467 @@ -590,6 +628,11 @@ void __init find_max_pfn(void)
9468         int i;
9469  
9470         max_pfn = 0;
9471 +       if (efi_enabled) {
9472 +               efi_memmap_walk(efi_find_max_pfn, &max_pfn);
9473 +               return;
9474 +       }
9475 +
9476         for (i = 0; i < e820.nr_map; i++) {
9477                 unsigned long start, end;
9478                 /* RAM? */
9479 @@ -664,6 +707,25 @@ unsigned long __init find_max_low_pfn(vo
9480  }
9481  
9482  #ifndef CONFIG_DISCONTIGMEM
9483 +
9484 +/*
9485 + * Free all available memory for boot time allocation.  Used
9486 + * as a callback function by efi_memory_walk()
9487 + */
9488 +
9489 +static int __init
9490 +free_available_memory(unsigned long start, unsigned long end, void *arg)
9491 +{
9492 +       /* check max_low_pfn */
9493 +       if (start >= ((max_low_pfn + 1) << PAGE_SHIFT))
9494 +               return 0;
9495 +       if (end >= ((max_low_pfn + 1) << PAGE_SHIFT))
9496 +               end = (max_low_pfn + 1) << PAGE_SHIFT;
9497 +       if (start < end)
9498 +               free_bootmem(start, end - start);
9499 +
9500 +       return 0;
9501 +}
9502  /*
9503   * Register fully available low RAM pages with the bootmem allocator.
9504   */
9505 @@ -671,6 +733,10 @@ static void __init register_bootmem_low_
9506  {
9507         int i;
9508  
9509 +       if (efi_enabled) {
9510 +               efi_memmap_walk(free_available_memory, NULL);
9511 +               return;
9512 +       }
9513         for (i = 0; i < e820.nr_map; i++) {
9514                 unsigned long curr_pfn, last_pfn, size;
9515                 /*
9516 @@ -798,9 +864,9 @@ extern unsigned long setup_memory(void);
9517   * Request address space for all standard RAM and ROM resources
9518   * and also for regions reported as reserved by the e820.
9519   */
9520 -static void __init register_memory(unsigned long max_low_pfn)
9521 +static void __init
9522 +legacy_init_iomem_resources(struct resource *code_resource, struct resource *data_resource)
9523  {
9524 -       unsigned long low_mem_size;
9525         int i;
9526  
9527         probe_roms();
9528 @@ -825,11 +891,26 @@ static void __init register_memory(unsig
9529                          *  so we try it repeatedly and let the resource manager
9530                          *  test it.
9531                          */
9532 -                       request_resource(res, &code_resource);
9533 -                       request_resource(res, &data_resource);
9534 +                       request_resource(res, code_resource);
9535 +                       request_resource(res, data_resource);
9536                 }
9537         }
9538 +}
9539 +
9540 +/*
9541 + * Request address space for all standard resources
9542 + */
9543 +static void __init register_memory(unsigned long max_low_pfn)
9544 +{
9545 +       unsigned long low_mem_size;
9546 +       int i;
9547  
9548 +       if (efi_enabled)
9549 +               efi_initialize_iomem_resources(&code_resource, &data_resource);
9550 +       else
9551 +               legacy_init_iomem_resources(&code_resource, &data_resource);
9552 +
9553 +        /* EFI systems may still have VGA */
9554         request_graphics_resource();
9555  
9556         /* request I/O space for devices used on all i[345]86 PCs */
9557 @@ -949,6 +1030,13 @@ static int __init noreplacement_setup(ch
9558  
9559  __setup("noreplacement", noreplacement_setup); 
9560  
9561 +/*
9562 + * Determine if we were loaded by an EFI loader.  If so, then we have also been
9563 + * passed the efi memmap, systab, etc., so we should use these data structures
9564 + * for initialization.  Note, the efi init code path is determined by the
9565 + * global efi_enabled. This allows the same kernel image to be used on existing
9566 + * systems (with a traditional BIOS) as well as on EFI systems.
9567 + */
9568  void __init setup_arch(char **cmdline_p)
9569  {
9570         unsigned long max_low_pfn;
9571 @@ -957,6 +1045,12 @@ void __init setup_arch(char **cmdline_p)
9572         pre_setup_arch_hook();
9573         early_cpu_init();
9574  
9575 +       /* FIXME: This isn't an official loader_type right
9576 +        * now but does currently work with elilo.
9577 +        */
9578 +       if ((LOADER_TYPE == 0x50) && EFI_SYSTAB)
9579 +               efi_enabled = 1;
9580 +
9581         ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
9582         drive_info = DRIVE_INFO;
9583         screen_info = SCREEN_INFO;
9584 @@ -979,7 +1073,11 @@ void __init setup_arch(char **cmdline_p)
9585         rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
9586  #endif
9587         ARCH_SETUP
9588 -       setup_memory_region();
9589 +       if (efi_enabled)
9590 +               efi_init();
9591 +       else
9592 +               setup_memory_region();
9593 +
9594         copy_edd();
9595  
9596         if (!MOUNT_ROOT_RDONLY)
9597 @@ -1013,6 +1111,8 @@ void __init setup_arch(char **cmdline_p)
9598  #ifdef CONFIG_X86_GENERICARCH
9599         generic_apic_probe(*cmdline_p);
9600  #endif 
9601 +       if (efi_enabled)
9602 +               efi_map_memmap();
9603  
9604         /*
9605          * Parse the ACPI tables for possible boot-time SMP configuration.
9606 @@ -1028,7 +1128,8 @@ void __init setup_arch(char **cmdline_p)
9607  
9608  #ifdef CONFIG_VT
9609  #if defined(CONFIG_VGA_CONSOLE)
9610 -       conswitchp = &vga_con;
9611 +       if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
9612 +               conswitchp = &vga_con;
9613  #elif defined(CONFIG_DUMMY_CONSOLE)
9614         conswitchp = &dummy_con;
9615  #endif
9616 --- linux-2.6.0-test6/arch/i386/kernel/signal.c 2003-06-14 12:18:09.000000000 -0700
9617 +++ 25/arch/i386/kernel/signal.c        2003-10-05 00:36:48.000000000 -0700
9618 @@ -128,25 +128,25 @@ sys_sigaltstack(const stack_t __user *us
9619   */
9620  
9621  static int
9622 -restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *peax)
9623 +restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *__sc, int *peax)
9624  {
9625 -       unsigned int err = 0;
9626 +       struct sigcontext scratch; /* 88 bytes of scratch area */
9627  
9628 -#define COPY(x)                err |= __get_user(regs->x, &sc->x)
9629 +       if (copy_from_user(&scratch, __sc, sizeof(scratch)))
9630 +               return -EFAULT;
9631 +
9632 +#define COPY(x)                regs->x = scratch.x
9633  
9634  #define COPY_SEG(seg)                                                  \
9635 -       { unsigned short tmp;                                           \
9636 -         err |= __get_user(tmp, &sc->seg);                             \
9637 +       { unsigned short tmp = scratch.seg;                             \
9638           regs->x##seg = tmp; }
9639  
9640  #define COPY_SEG_STRICT(seg)                                           \
9641 -       { unsigned short tmp;                                           \
9642 -         err |= __get_user(tmp, &sc->seg);                             \
9643 +       { unsigned short tmp = scratch.seg;                             \
9644           regs->x##seg = tmp|3; }
9645  
9646  #define GET_SEG(seg)                                                   \
9647 -       { unsigned short tmp;                                           \
9648 -         err |= __get_user(tmp, &sc->seg);                             \
9649 +       { unsigned short tmp = scratch.seg;                             \
9650           loadsegment(seg,tmp); }
9651  
9652         GET_SEG(gs);
9653 @@ -165,27 +165,23 @@ restore_sigcontext(struct pt_regs *regs,
9654         COPY_SEG_STRICT(ss);
9655         
9656         {
9657 -               unsigned int tmpflags;
9658 -               err |= __get_user(tmpflags, &sc->eflags);
9659 +               unsigned int tmpflags = scratch.eflags;
9660                 regs->eflags = (regs->eflags & ~0x40DD5) | (tmpflags & 0x40DD5);
9661                 regs->orig_eax = -1;            /* disable syscall checks */
9662         }
9663  
9664         {
9665 -               struct _fpstate __user * buf;
9666 -               err |= __get_user(buf, &sc->fpstate);
9667 +               struct _fpstate * buf = scratch.fpstate;
9668                 if (buf) {
9669                         if (verify_area(VERIFY_READ, buf, sizeof(*buf)))
9670 -                               goto badframe;
9671 -                       err |= restore_i387(buf);
9672 +                               return -EFAULT;
9673 +                       if (restore_i387(buf))
9674 +                               return -EFAULT;
9675                 }
9676         }
9677  
9678 -       err |= __get_user(*peax, &sc->eax);
9679 -       return err;
9680 -
9681 -badframe:
9682 -       return 1;
9683 +       *peax = scratch.eax;
9684 +       return 0;
9685  }
9686  
9687  asmlinkage int sys_sigreturn(unsigned long __unused)
9688 @@ -263,46 +259,47 @@ badframe:
9689   */
9690  
9691  static int
9692 -setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate,
9693 +setup_sigcontext(struct sigcontext __user *__sc, struct _fpstate __user *fpstate,
9694                  struct pt_regs *regs, unsigned long mask)
9695  {
9696 -       int tmp, err = 0;
9697 +       struct sigcontext sc; /* 88 bytes of scratch area */
9698 +       int tmp;
9699  
9700         tmp = 0;
9701         __asm__("movl %%gs,%0" : "=r"(tmp): "0"(tmp));
9702 -       err |= __put_user(tmp, (unsigned int *)&sc->gs);
9703 +       *(unsigned int *)&sc.gs = tmp;
9704         __asm__("movl %%fs,%0" : "=r"(tmp): "0"(tmp));
9705 -       err |= __put_user(tmp, (unsigned int *)&sc->fs);
9706 -
9707 -       err |= __put_user(regs->xes, (unsigned int *)&sc->es);
9708 -       err |= __put_user(regs->xds, (unsigned int *)&sc->ds);
9709 -       err |= __put_user(regs->edi, &sc->edi);
9710 -       err |= __put_user(regs->esi, &sc->esi);
9711 -       err |= __put_user(regs->ebp, &sc->ebp);
9712 -       err |= __put_user(regs->esp, &sc->esp);
9713 -       err |= __put_user(regs->ebx, &sc->ebx);
9714 -       err |= __put_user(regs->edx, &sc->edx);
9715 -       err |= __put_user(regs->ecx, &sc->ecx);
9716 -       err |= __put_user(regs->eax, &sc->eax);
9717 -       err |= __put_user(current->thread.trap_no, &sc->trapno);
9718 -       err |= __put_user(current->thread.error_code, &sc->err);
9719 -       err |= __put_user(regs->eip, &sc->eip);
9720 -       err |= __put_user(regs->xcs, (unsigned int *)&sc->cs);
9721 -       err |= __put_user(regs->eflags, &sc->eflags);
9722 -       err |= __put_user(regs->esp, &sc->esp_at_signal);
9723 -       err |= __put_user(regs->xss, (unsigned int *)&sc->ss);
9724 +       *(unsigned int *)&sc.fs = tmp;
9725 +       *(unsigned int *)&sc.es = regs->xes;
9726 +       *(unsigned int *)&sc.ds = regs->xds;
9727 +       sc.edi = regs->edi;
9728 +       sc.esi = regs->esi;
9729 +       sc.ebp = regs->ebp;
9730 +       sc.esp = regs->esp;
9731 +       sc.ebx = regs->ebx;
9732 +       sc.edx = regs->edx;
9733 +       sc.ecx = regs->ecx;
9734 +       sc.eax = regs->eax;
9735 +       sc.trapno = current->thread.trap_no;
9736 +       sc.err = current->thread.error_code;
9737 +       sc.eip = regs->eip;
9738 +       *(unsigned int *)&sc.cs = regs->xcs;
9739 +       sc.eflags = regs->eflags;
9740 +       sc.esp_at_signal = regs->esp;
9741 +       *(unsigned int *)&sc.ss = regs->xss;
9742  
9743         tmp = save_i387(fpstate);
9744         if (tmp < 0)
9745 -         err = 1;
9746 -       else
9747 -         err |= __put_user(tmp ? fpstate : NULL, &sc->fpstate);
9748 +               return 1;
9749 +       sc.fpstate = tmp ? fpstate : NULL;
9750  
9751         /* non-iBCS2 extensions.. */
9752 -       err |= __put_user(mask, &sc->oldmask);
9753 -       err |= __put_user(current->thread.cr2, &sc->cr2);
9754 +       sc.oldmask = mask;
9755 +       sc.cr2 = current->thread.cr2;
9756  
9757 -       return err;
9758 +       if (copy_to_user(__sc, &sc, sizeof(sc)))
9759 +               return 1;
9760 +       return 0;
9761  }
9762  
9763  /*
9764 @@ -440,7 +437,7 @@ static void setup_rt_frame(int sig, stru
9765         /* Create the ucontext.  */
9766         err |= __put_user(0, &frame->uc.uc_flags);
9767         err |= __put_user(0, &frame->uc.uc_link);
9768 -       err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
9769 +       err |= __put_user(current->sas_ss_sp, (unsigned long *)&frame->uc.uc_stack.ss_sp);
9770         err |= __put_user(sas_ss_flags(regs->esp),
9771                           &frame->uc.uc_stack.ss_flags);
9772         err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
9773 --- linux-2.6.0-test6/arch/i386/kernel/smpboot.c        2003-09-27 18:57:43.000000000 -0700
9774 +++ 25/arch/i386/kernel/smpboot.c       2003-10-05 00:34:39.000000000 -0700
9775 @@ -499,8 +499,8 @@ static struct task_struct * __init fork_
9776  #ifdef CONFIG_NUMA
9777  
9778  /* which logical CPUs are on which nodes */
9779 -cpumask_t node_2_cpu_mask[MAX_NR_NODES] =
9780 -                               { [0 ... MAX_NR_NODES-1] = CPU_MASK_NONE };
9781 +cpumask_t node_2_cpu_mask[MAX_NUMNODES] =
9782 +                               { [0 ... MAX_NUMNODES-1] = CPU_MASK_NONE };
9783  /* which node each logical CPU is on */
9784  int cpu_2_node[NR_CPUS] = { [0 ... NR_CPUS-1] = 0 };
9785  
9786 @@ -518,7 +518,7 @@ static inline void unmap_cpu_to_node(int
9787         int node;
9788  
9789         printk("Unmapping cpu %d from all nodes\n", cpu);
9790 -       for (node = 0; node < MAX_NR_NODES; node ++)
9791 +       for (node = 0; node < MAX_NUMNODES; node ++)
9792                 cpu_clear(cpu, node_2_cpu_mask[node]);
9793         cpu_2_node[cpu] = -1;
9794  }
9795 @@ -937,6 +937,7 @@ int cpu_sibling_map[NR_CPUS] __cacheline
9796  static void __init smp_boot_cpus(unsigned int max_cpus)
9797  {
9798         int apicid, cpu, bit, kicked;
9799 +       unsigned long bogosum = 0;
9800  
9801         /*
9802          * Setup boot CPU information
9803 @@ -1048,26 +1049,25 @@ static void __init smp_boot_cpus(unsigne
9804         /*
9805          * Allow the user to impress friends.
9806          */
9807 -
9808         Dprintk("Before bogomips.\n");
9809 -       if (!cpucount) {
9810 -               printk(KERN_ERR "Error: only one processor found.\n");
9811 -       } else {
9812 -               unsigned long bogosum = 0;
9813 -               for (cpu = 0; cpu < NR_CPUS; cpu++)
9814 -                       if (cpu_isset(cpu, cpu_callout_map))
9815 -                               bogosum += cpu_data[cpu].loops_per_jiffy;
9816 -               printk(KERN_INFO "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
9817 -                       cpucount+1,
9818 -                       bogosum/(500000/HZ),
9819 -                       (bogosum/(5000/HZ))%100);
9820 -               Dprintk("Before bogocount - setting activated=1.\n");
9821 -       }
9822 +       for (cpu = 0; cpu < NR_CPUS; cpu++)
9823 +               if (cpu_isset(cpu, cpu_callout_map))
9824 +                       bogosum += cpu_data[cpu].loops_per_jiffy;
9825 +       printk(KERN_INFO
9826 +               "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
9827 +               cpucount+1,
9828 +               bogosum/(500000/HZ),
9829 +               (bogosum/(5000/HZ))%100);
9830 +       
9831 +       Dprintk("Before bogocount - setting activated=1.\n");
9832  
9833         if (smp_b_stepping)
9834                 printk(KERN_WARNING "WARNING: SMP operation may be unreliable with B stepping processors.\n");
9835  
9836 -       /* Don't taint if we are running SMP kernel on a single non-MP approved Athlon  */
9837 +       /*
9838 +        * Don't taint if we are running SMP kernel on a single non-MP
9839 +        * approved Athlon
9840 +        */
9841         if (tainted & TAINT_UNSAFE_SMP) {
9842                 if (cpucount)
9843                         printk (KERN_INFO "WARNING: This combination of AMD processors is not suitable for SMP.\n");
9844 --- linux-2.6.0-test6/arch/i386/kernel/smp.c    2003-08-22 19:23:40.000000000 -0700
9845 +++ 25/arch/i386/kernel/smp.c   2003-10-05 00:36:48.000000000 -0700
9846 @@ -327,10 +327,12 @@ asmlinkage void smp_invalidate_interrupt
9847                  
9848         if (flush_mm == cpu_tlbstate[cpu].active_mm) {
9849                 if (cpu_tlbstate[cpu].state == TLBSTATE_OK) {
9850 +#ifndef CONFIG_X86_SWITCH_PAGETABLES
9851                         if (flush_va == FLUSH_ALL)
9852                                 local_flush_tlb();
9853                         else
9854                                 __flush_tlb_one(flush_va);
9855 +#endif
9856                 } else
9857                         leave_mm(cpu);
9858         }
9859 @@ -396,21 +398,6 @@ static void flush_tlb_others(cpumask_t c
9860         spin_unlock(&tlbstate_lock);
9861  }
9862         
9863 -void flush_tlb_current_task(void)
9864 -{
9865 -       struct mm_struct *mm = current->mm;
9866 -       cpumask_t cpu_mask;
9867 -
9868 -       preempt_disable();
9869 -       cpu_mask = mm->cpu_vm_mask;
9870 -       cpu_clear(smp_processor_id(), cpu_mask);
9871 -
9872 -       local_flush_tlb();
9873 -       if (!cpus_empty(cpu_mask))
9874 -               flush_tlb_others(cpu_mask, mm, FLUSH_ALL);
9875 -       preempt_enable();
9876 -}
9877 -
9878  void flush_tlb_mm (struct mm_struct * mm)
9879  {
9880         cpumask_t cpu_mask;
9881 @@ -442,7 +429,10 @@ void flush_tlb_page(struct vm_area_struc
9882  
9883         if (current->active_mm == mm) {
9884                 if(current->mm)
9885 -                       __flush_tlb_one(va);
9886 +#ifndef CONFIG_X86_SWITCH_PAGETABLES
9887 +                       __flush_tlb_one(va)
9888 +#endif
9889 +                               ;
9890                  else
9891                         leave_mm(smp_processor_id());
9892         }
9893 @@ -466,7 +456,17 @@ void flush_tlb_all(void)
9894  {
9895         on_each_cpu(do_flush_tlb_all, 0, 1, 1);
9896  }
9897 -
9898 +#ifdef CONFIG_KGDB
9899 +/*
9900 + * By using the NMI code instead of a vector we just sneak thru the
9901 + * word generator coming out with just what we want.  AND it does
9902 + * not matter if clustered_apic_mode is set or not.
9903 + */
9904 +void smp_send_nmi_allbutself(void)
9905 +{
9906 +       send_IPI_allbutself(APIC_DM_NMI);
9907 +}
9908 +#endif
9909  /*
9910   * this function sends a 'reschedule' IPI to another CPU.
9911   * it goes straight through and wastes no time serializing
9912 --- linux-2.6.0-test6/arch/i386/kernel/sysenter.c       2003-08-08 22:55:10.000000000 -0700
9913 +++ 25/arch/i386/kernel/sysenter.c      2003-10-05 00:36:48.000000000 -0700
9914 @@ -18,13 +18,18 @@
9915  #include <asm/msr.h>
9916  #include <asm/pgtable.h>
9917  #include <asm/unistd.h>
9918 +#include <linux/highmem.h>
9919  
9920  extern asmlinkage void sysenter_entry(void);
9921  
9922  void enable_sep_cpu(void *info)
9923  {
9924         int cpu = get_cpu();
9925 +#ifdef CONFIG_X86_HIGH_ENTRY
9926 +       struct tss_struct *tss = (struct tss_struct *) __fix_to_virt(FIX_TSS_0) + cpu;
9927 +#else
9928         struct tss_struct *tss = init_tss + cpu;
9929 +#endif
9930  
9931         tss->ss1 = __KERNEL_CS;
9932         tss->esp1 = sizeof(struct tss_struct) + (unsigned long) tss;
9933 --- linux-2.6.0-test6/arch/i386/kernel/time.c   2003-09-08 13:58:55.000000000 -0700
9934 +++ 25/arch/i386/kernel/time.c  2003-10-05 00:36:22.000000000 -0700
9935 @@ -44,6 +44,7 @@
9936  #include <linux/module.h>
9937  #include <linux/sysdev.h>
9938  #include <linux/bcd.h>
9939 +#include <linux/efi.h>
9940  
9941  #include <asm/io.h>
9942  #include <asm/smp.h>
9943 @@ -160,6 +161,37 @@ static int set_rtc_mmss(unsigned long no
9944         return retval;
9945  }
9946  
9947 +static int efi_set_rtc_mmss(unsigned long nowtime)
9948 +{
9949 +       int real_seconds, real_minutes;
9950 +       unsigned long   flags;
9951 +       efi_status_t    status;
9952 +       efi_time_t      eft;
9953 +       efi_time_cap_t  cap;
9954 +
9955 +       spin_lock_irqsave(&rtc_lock, flags);
9956 +
9957 +       status = efi.get_time(&eft, &cap);
9958 +       if (status != EFI_SUCCESS)
9959 +               panic("Ooops, efitime: can't read time!\n");
9960 +       real_seconds = nowtime % 60;
9961 +       real_minutes = nowtime / 60;
9962 +
9963 +       if (((abs(real_minutes - eft.minute) + 15)/30) & 1)
9964 +               real_minutes += 30;
9965 +       real_minutes %= 60;
9966 +
9967 +       eft.minute = real_minutes;
9968 +       eft.second = real_seconds;
9969 +
9970 +       status = efi.set_time(&eft);
9971 +       if (status != EFI_SUCCESS)
9972 +               panic("Ooops: efitime: can't read time!\n");
9973 +
9974 +       spin_unlock_irqrestore(&rtc_lock, flags);
9975 +       return 0;
9976 +}
9977 +
9978  /* last time the cmos clock got updated */
9979  static long last_rtc_update;
9980  
9981 @@ -212,7 +244,7 @@ static inline void do_timer_interrupt(in
9982                         >= USEC_AFTER - ((unsigned) TICK_SIZE) / 2 &&
9983             (xtime.tv_nsec / 1000)
9984                         <= USEC_BEFORE + ((unsigned) TICK_SIZE) / 2) {
9985 -               if (set_rtc_mmss(xtime.tv_sec) == 0)
9986 +               if ((efi_enabled && (!efi_set_rtc_mmss(xtime.tv_sec) )) || (set_rtc_mmss(xtime.tv_sec) == 0))
9987                         last_rtc_update = xtime.tv_sec;
9988                 else
9989                         last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
9990 @@ -277,6 +309,27 @@ static struct sysdev_class pit_sysclass 
9991         set_kset_name("pit"),
9992  };
9993  
9994 +/*
9995 + * This is called before the RT mappings are in place, so we
9996 + * need to be able to get the time in physical mode.
9997 + */
9998 +unsigned long efi_get_time(void)
9999 +{
10000 +       efi_status_t status;
10001 +       unsigned long flags;
10002 +       efi_time_t eft;
10003 +       efi_time_cap_t cap;
10004 +
10005 +       spin_lock_irqsave(&rtc_lock, flags);
10006 +       status = phys_efi_get_time(&eft, &cap);
10007 +       if (status != EFI_SUCCESS)
10008 +               printk("Oops: efitime: can't read time status: 0x%lx\n", status);
10009 +
10010 +       spin_unlock_irqrestore(&rtc_lock, flags);
10011 +
10012 +       return mktime(eft.year, eft.month, eft.day, eft.hour, eft.minute, eft.second);
10013 +}
10014 +
10015  /* XXX this driverfs stuff should probably go elsewhere later -john */
10016  static struct sys_device device_i8253 = {
10017         .id     = 0,
10018 @@ -298,7 +351,10 @@ extern void (*late_time_init)(void);
10019  /* Duplicate of time_init() below, with hpet_enable part added */
10020  void __init hpet_time_init(void)
10021  {
10022 -       xtime.tv_sec = get_cmos_time();
10023 +       if (efi_enabled)
10024 +               xtime.tv_sec = efi_get_time();
10025 +       else
10026 +               xtime.tv_sec = get_cmos_time();
10027         wall_to_monotonic.tv_sec = -xtime.tv_sec;
10028         xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
10029         wall_to_monotonic.tv_nsec = -xtime.tv_nsec;
10030 @@ -324,8 +380,10 @@ void __init time_init(void)
10031                 return;
10032         }
10033  #endif
10034 -
10035 -       xtime.tv_sec = get_cmos_time();
10036 +       if (efi_enabled)
10037 +               xtime.tv_sec = efi_get_time();
10038 +       else
10039 +               xtime.tv_sec = get_cmos_time();
10040         wall_to_monotonic.tv_sec = -xtime.tv_sec;
10041         xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
10042         wall_to_monotonic.tv_nsec = -xtime.tv_nsec;
10043 --- linux-2.6.0-test6/arch/i386/kernel/traps.c  2003-09-27 18:57:43.000000000 -0700
10044 +++ 25/arch/i386/kernel/traps.c 2003-10-05 00:36:48.000000000 -0700
10045 @@ -54,12 +54,8 @@
10046  
10047  #include "mach_traps.h"
10048  
10049 -asmlinkage int system_call(void);
10050 -asmlinkage void lcall7(void);
10051 -asmlinkage void lcall27(void);
10052 -
10053 -struct desc_struct default_ldt[] = { { 0, 0 }, { 0, 0 }, { 0, 0 },
10054 -               { 0, 0 }, { 0, 0 } };
10055 +struct desc_struct default_ldt[] __attribute__((__section__(".data.default_ldt"))) = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } };
10056 +struct page *default_ldt_page;
10057  
10058  /* Do we ignore FPU interrupts ? */
10059  char ignore_fpu_irq = 0;
10060 @@ -91,6 +87,43 @@ asmlinkage void alignment_check(void);
10061  asmlinkage void spurious_interrupt_bug(void);
10062  asmlinkage void machine_check(void);
10063  
10064 +#ifdef CONFIG_KGDB
10065 +extern void sysenter_entry(void);
10066 +#include <asm/kgdb.h>
10067 +#include <linux/init.h>
10068 +extern void int3(void);
10069 +extern void debug(void);
10070 +void set_intr_gate(unsigned int n, void *addr);
10071 +static void set_intr_usr_gate(unsigned int n, void *addr);
10072 +/*
10073 + * Should be able to call this breakpoint() very early in
10074 + * bring up.  Just hard code the call where needed.
10075 + * The breakpoint() code is here because set_?_gate() functions
10076 + * are local (static) to trap.c.  They need be done only once,
10077 + * but it does not hurt to do them over.
10078 + */
10079 +void breakpoint(void)
10080 +{
10081 +       init_entry_mappings();
10082 +        set_intr_usr_gate(3,&int3); /* disable ints on trap */
10083 +       set_intr_gate(1,&debug);
10084 +       set_intr_gate(14,&page_fault);
10085 +
10086 +        BREAKPOINT;
10087 +}
10088 +#define        CHK_REMOTE_DEBUG(trapnr,signr,error_code,regs,after)            \
10089 +    {                                                                  \
10090 +       if (!user_mode(regs)  ) \
10091 +       {                                                               \
10092 +               kgdb_handle_exception(trapnr, signr, error_code, regs); \
10093 +               after;                                                  \
10094 +       } else if ((trapnr == 3) && (regs->eflags &0x200)) local_irq_enable(); \
10095 +    }
10096 +#else
10097 +#define        CHK_REMOTE_DEBUG(trapnr,signr,error_code,regs,after)
10098 +#endif
10099 +
10100 +
10101  static int kstack_depth_to_print = 24;
10102  
10103  void show_trace(struct task_struct *task, unsigned long * stack)
10104 @@ -173,8 +206,9 @@ void show_registers(struct pt_regs *regs
10105                 ss = regs->xss & 0xffff;
10106         }
10107         print_modules();
10108 -       printk("CPU:    %d\nEIP:    %04x:[<%08lx>]    %s\nEFLAGS: %08lx\n",
10109 -               smp_processor_id(), 0xffff & regs->xcs, regs->eip, print_tainted(), regs->eflags);
10110 +       printk("CPU:    %d\nEIP:    %04x:[<%08lx>]    %s VLI\nEFLAGS: %08lx\n",
10111 +               smp_processor_id(), 0xffff & regs->xcs,
10112 +               regs->eip, print_tainted(), regs->eflags);
10113  
10114         print_symbol("EIP is at %s\n", regs->eip);
10115         printk("eax: %08lx   ebx: %08lx   ecx: %08lx   edx: %08lx\n",
10116 @@ -190,23 +224,27 @@ void show_registers(struct pt_regs *regs
10117          * time of the fault..
10118          */
10119         if (in_kernel) {
10120 +               u8 *eip;
10121  
10122                 printk("\nStack: ");
10123                 show_stack(NULL, (unsigned long*)esp);
10124  
10125                 printk("Code: ");
10126 -               if(regs->eip < PAGE_OFFSET)
10127 -                       goto bad;
10128  
10129 -               for(i=0;i<20;i++)
10130 -               {
10131 -                       unsigned char c;
10132 -                       if(__get_user(c, &((unsigned char*)regs->eip)[i])) {
10133 -bad:
10134 +               eip = (u8 *)regs->eip - 43;
10135 +               for (i = 0; i < 64; i++, eip++) {
10136 +                       unsigned char c = 0xff;
10137 +
10138 +                       if ((user_mode(regs) && get_user(c, eip)) ||
10139 +                           (!user_mode(regs) && __direct_get_user(c, eip))) {
10140 +
10141                                 printk(" Bad EIP value.");
10142                                 break;
10143                         }
10144 -                       printk("%02x ", c);
10145 +                       if (eip == (u8 *)regs->eip)
10146 +                               printk("<%02x> ", c);
10147 +                       else
10148 +                               printk("%02x ", c);
10149                 }
10150         }
10151         printk("\n");
10152 @@ -253,12 +291,36 @@ spinlock_t die_lock = SPIN_LOCK_UNLOCKED
10153  void die(const char * str, struct pt_regs * regs, long err)
10154  {
10155         static int die_counter;
10156 +       int nl = 0;
10157  
10158         console_verbose();
10159         spin_lock_irq(&die_lock);
10160         bust_spinlocks(1);
10161         handle_BUG(regs);
10162         printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
10163 +#ifdef CONFIG_PREEMPT
10164 +       printk("PREEMPT ");
10165 +       nl = 1;
10166 +#endif
10167 +#ifdef CONFIG_SMP
10168 +       printk("SMP ");
10169 +       nl = 1;
10170 +#endif
10171 +#ifdef CONFIG_DEBUG_PAGEALLOC
10172 +       printk("DEBUG_PAGEALLOC");
10173 +       nl = 1;
10174 +#endif
10175 +       if (nl)
10176 +               printk("\n");
10177 +#ifdef CONFIG_KGDB
10178 +       /* This is about the only place we want to go to kgdb even if in
10179 +        * user mode.  But we must go in via a trap so within kgdb we will
10180 +        * always be in kernel mode.
10181 +        */
10182 +       if (user_mode(regs))
10183 +               BREAKPOINT;
10184 +#endif
10185 +       CHK_REMOTE_DEBUG(0,SIGTRAP,err,regs,)
10186         show_registers(regs);
10187         bust_spinlocks(0);
10188         spin_unlock_irq(&die_lock);
10189 @@ -328,6 +390,7 @@ static inline void do_trap(int trapnr, i
10190  #define DO_ERROR(trapnr, signr, str, name) \
10191  asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
10192  { \
10193 +       CHK_REMOTE_DEBUG(trapnr,signr,error_code,regs,)\
10194         do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \
10195  }
10196  
10197 @@ -345,7 +408,9 @@ asmlinkage void do_##name(struct pt_regs
10198  #define DO_VM86_ERROR(trapnr, signr, str, name) \
10199  asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
10200  { \
10201 +       CHK_REMOTE_DEBUG(trapnr, signr, error_code,regs, return)\
10202         do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \
10203 +       return; \
10204  }
10205  
10206  #define DO_VM86_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
10207 @@ -388,8 +453,10 @@ gp_in_vm86:
10208         return;
10209  
10210  gp_in_kernel:
10211 -       if (!fixup_exception(regs))
10212 +       if (!fixup_exception(regs)){
10213 +               CHK_REMOTE_DEBUG(13,SIGSEGV,error_code,regs,)
10214                 die("general protection fault", regs, error_code);
10215 +       }
10216  }
10217  
10218  static void mem_parity_error(unsigned char reason, struct pt_regs * regs)
10219 @@ -528,10 +595,18 @@ asmlinkage void do_debug(struct pt_regs 
10220         if (regs->eflags & X86_EFLAGS_IF)
10221                 local_irq_enable();
10222  
10223 -       /* Mask out spurious debug traps due to lazy DR7 setting */
10224 +       /*
10225 +        * Mask out spurious debug traps due to lazy DR7 setting or
10226 +        * due to 4G/4G kernel mode:
10227 +        */
10228         if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) {
10229                 if (!tsk->thread.debugreg[7])
10230                         goto clear_dr7;
10231 +               if (!user_mode(regs)) {
10232 +                       // restore upon return-to-userspace:
10233 +                       set_thread_flag(TIF_DB7);
10234 +                       goto clear_dr7;
10235 +               }
10236         }
10237  
10238         if (regs->eflags & VM_MASK)
10239 @@ -551,8 +626,18 @@ asmlinkage void do_debug(struct pt_regs 
10240                  * allowing programs to debug themselves without the ptrace()
10241                  * interface.
10242                  */
10243 +#ifdef CONFIG_KGDB
10244 +               /*
10245 +                * I think this is the only "real" case of a TF in the kernel
10246 +                * that really belongs to user space.  Others are
10247 +                * "Ours all ours!"
10248 +                */
10249 +               if (((regs->xcs & 3) == 0) && ((void *)regs->eip == sysenter_entry))
10250 +                       goto clear_TF_reenable;
10251 +#else
10252                 if ((regs->xcs & 3) == 0)
10253                         goto clear_TF_reenable;
10254 +#endif
10255                 if ((tsk->ptrace & (PT_DTRACE|PT_PTRACED)) == PT_DTRACE)
10256                         goto clear_TF;
10257         }
10258 @@ -564,6 +649,17 @@ asmlinkage void do_debug(struct pt_regs 
10259         info.si_errno = 0;
10260         info.si_code = TRAP_BRKPT;
10261         
10262 +#ifdef CONFIG_KGDB
10263 +        /*
10264 +        * If this is a kernel mode trap, we need to reset db7 to allow us
10265 +        * to continue sanely ALSO skip the signal delivery
10266 +         */
10267 +       if ((regs->xcs & 3) == 0)
10268 +               goto clear_dr7;
10269 +
10270 +        /* if not kernel, allow ints but only if they were on */
10271 +       if ( regs->eflags & 0x200) local_irq_enable();
10272 +#endif
10273         /* If this is a kernel mode trap, save the user PC on entry to 
10274          * the kernel, that's what the debugger can make sense of.
10275          */
10276 @@ -578,6 +674,7 @@ clear_dr7:
10277         __asm__("movl %0,%%db7"
10278                 : /* no output */
10279                 : "r" (0));
10280 +       CHK_REMOTE_DEBUG(1,SIGTRAP,error_code,regs,)
10281         return;
10282  
10283  debug_vm86:
10284 @@ -773,19 +870,53 @@ asmlinkage void math_emulate(long arg)
10285  
10286  #endif /* CONFIG_MATH_EMULATION */
10287  
10288 -#ifdef CONFIG_X86_F00F_BUG
10289 -void __init trap_init_f00f_bug(void)
10290 +void __init trap_init_virtual_IDT(void)
10291  {
10292 -       __set_fixmap(FIX_F00F_IDT, __pa(&idt_table), PAGE_KERNEL_RO);
10293 -
10294         /*
10295 -        * Update the IDT descriptor and reload the IDT so that
10296 -        * it uses the read-only mapped virtual address.
10297 +        * "idt" is magic - it overlaps the idt_descr
10298 +        * variable so that updating idt will automatically
10299 +        * update the idt descriptor..
10300          */
10301 -       idt_descr.address = fix_to_virt(FIX_F00F_IDT);
10302 +       __set_fixmap(FIX_IDT, __pa(&idt_table), PAGE_KERNEL_RO);
10303 +       idt_descr.address = __fix_to_virt(FIX_IDT);
10304 +
10305         __asm__ __volatile__("lidt %0" : : "m" (idt_descr));
10306  }
10307 +
10308 +void __init trap_init_virtual_GDT(void)
10309 +{
10310 +       int cpu = smp_processor_id();
10311 +       struct Xgt_desc_struct *gdt_desc = cpu_gdt_descr + cpu;
10312 +       struct Xgt_desc_struct tmp_desc = {0, 0};
10313 +       struct tss_struct * t;
10314 +
10315 +       __asm__ __volatile__("sgdt %0": "=m" (tmp_desc): :"memory");
10316 +
10317 +#ifdef CONFIG_X86_HIGH_ENTRY
10318 +       if (!cpu) {
10319 +               __set_fixmap(FIX_GDT_0, __pa(cpu_gdt_table), PAGE_KERNEL);
10320 +               __set_fixmap(FIX_GDT_1, __pa(cpu_gdt_table) + PAGE_SIZE, PAGE_KERNEL);
10321 +               __set_fixmap(FIX_TSS_0, __pa(init_tss), PAGE_KERNEL);
10322 +               __set_fixmap(FIX_TSS_1, __pa(init_tss) + 1*PAGE_SIZE, PAGE_KERNEL);
10323 +               __set_fixmap(FIX_TSS_2, __pa(init_tss) + 2*PAGE_SIZE, PAGE_KERNEL);
10324 +               __set_fixmap(FIX_TSS_3, __pa(init_tss) + 3*PAGE_SIZE, PAGE_KERNEL);
10325 +       }
10326 +
10327 +       gdt_desc->address = __fix_to_virt(FIX_GDT_0) + sizeof(cpu_gdt_table[0]) * cpu;
10328 +#else
10329 +       gdt_desc->address = (unsigned long)cpu_gdt_table[cpu];
10330 +#endif
10331 +       __asm__ __volatile__("lgdt %0": "=m" (*gdt_desc));
10332 +
10333 +#ifdef CONFIG_X86_HIGH_ENTRY
10334 +       t = (struct tss_struct *) __fix_to_virt(FIX_TSS_0) + cpu;
10335 +#else
10336 +       t = init_tss + cpu;
10337  #endif
10338 +       set_tss_desc(cpu, t);
10339 +       cpu_gdt_table[cpu][GDT_ENTRY_TSS].b &= 0xfffffdff;
10340 +       load_TR_desc();
10341 +}
10342  
10343  #define _set_gate(gate_addr,type,dpl,addr,seg) \
10344  do { \
10345 @@ -812,20 +943,26 @@ void set_intr_gate(unsigned int n, void 
10346         _set_gate(idt_table+n,14,0,addr,__KERNEL_CS);
10347  }
10348  
10349 -static void __init set_trap_gate(unsigned int n, void *addr)
10350 +void __init set_trap_gate(unsigned int n, void *addr)
10351  {
10352         _set_gate(idt_table+n,15,0,addr,__KERNEL_CS);
10353  }
10354  
10355 -static void __init set_system_gate(unsigned int n, void *addr)
10356 +void __init set_system_gate(unsigned int n, void *addr)
10357  {
10358         _set_gate(idt_table+n,15,3,addr,__KERNEL_CS);
10359  }
10360  
10361 -static void __init set_call_gate(void *a, void *addr)
10362 +void __init set_call_gate(void *a, void *addr)
10363  {
10364         _set_gate(a,12,3,addr,__KERNEL_CS);
10365  }
10366 +#ifdef CONFIG_KGDB
10367 +void set_intr_usr_gate(unsigned int n, void *addr)
10368 +{
10369 +       _set_gate(idt_table+n,14,3,addr,__KERNEL_CS);
10370 +}
10371 +#endif
10372  
10373  static void __init set_task_gate(unsigned int n, unsigned int gdt_entry)
10374  {
10375 @@ -844,11 +981,16 @@ void __init trap_init(void)
10376  #ifdef CONFIG_X86_LOCAL_APIC
10377         init_apic_mappings();
10378  #endif
10379 +       init_entry_mappings();
10380  
10381         set_trap_gate(0,&divide_error);
10382         set_intr_gate(1,&debug);
10383         set_intr_gate(2,&nmi);
10384 +#ifndef CONFIG_KGDB
10385         set_system_gate(3,&int3);       /* int3-5 can be called from all */
10386 +#else
10387 +       set_intr_usr_gate(3,&int3);     /* int3-5 can be called from all */
10388 +#endif
10389         set_system_gate(4,&overflow);
10390         set_system_gate(5,&bounds);
10391         set_trap_gate(6,&invalid_op);
10392 --- linux-2.6.0-test6/arch/i386/kernel/vm86.c   2003-06-14 12:17:58.000000000 -0700
10393 +++ 25/arch/i386/kernel/vm86.c  2003-10-05 00:36:48.000000000 -0700
10394 @@ -117,7 +117,7 @@ struct pt_regs * save_v86_state(struct k
10395  
10396         tss = init_tss + get_cpu();
10397         current->thread.esp0 = current->thread.saved_esp0;
10398 -       load_esp0(tss, current->thread.esp0);
10399 +       load_esp0(tss, virtual_esp0(current));
10400         current->thread.saved_esp0 = 0;
10401         put_cpu();
10402  
10403 @@ -294,7 +294,8 @@ static void do_sys_vm86(struct kernel_vm
10404         asm volatile("movl %%gs,%0":"=m" (tsk->thread.saved_gs));
10405  
10406         tss = init_tss + get_cpu();
10407 -       tss->esp0 = tsk->thread.esp0 = (unsigned long) &info->VM86_TSS_ESP0;
10408 +       tsk->thread.esp0 = (unsigned long) &info->VM86_TSS_ESP0;
10409 +       tss->esp0 = virtual_esp0(tsk);
10410         disable_sysenter(tss);
10411         put_cpu();
10412  
10413 --- linux-2.6.0-test6/arch/i386/kernel/vmlinux.lds.S    2003-08-22 19:23:40.000000000 -0700
10414 +++ 25/arch/i386/kernel/vmlinux.lds.S   2003-10-05 00:36:48.000000000 -0700
10415 @@ -3,6 +3,9 @@
10416   */
10417  
10418  #include <asm-generic/vmlinux.lds.h>
10419 +#include <linux/config.h>
10420 +#include <asm/page.h>
10421 +#include <asm/asm_offsets.h>
10422         
10423  OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
10424  OUTPUT_ARCH(i386)
10425 @@ -10,7 +13,7 @@ ENTRY(startup_32)
10426  jiffies = jiffies_64;
10427  SECTIONS
10428  {
10429 -  . = 0xC0000000 + 0x100000;
10430 +  . = __PAGE_OFFSET + 0x100000;
10431    /* read-only */
10432    _text = .;                   /* Text and read-only data */
10433    .text : {
10434 @@ -19,6 +22,19 @@ SECTIONS
10435         *(.gnu.warning)
10436         } = 0x9090
10437  
10438 +#ifdef CONFIG_X86_4G
10439 +  . = ALIGN(PAGE_SIZE_asm);
10440 +  __entry_tramp_start = .;
10441 +  . = FIX_ENTRY_TRAMPOLINE_0_addr;
10442 +  __start___entry_text = .;
10443 +  .entry.text : AT (__entry_tramp_start) { *(.entry.text) }
10444 +  __entry_tramp_end = __entry_tramp_start + SIZEOF(.entry.text);
10445 +  . = __entry_tramp_end;
10446 +  . = ALIGN(PAGE_SIZE_asm);
10447 +#else
10448 +  .entry.text : { *(.entry.text) }
10449 +#endif
10450 +
10451    _etext = .;                  /* End of text section */
10452  
10453    . = ALIGN(16);               /* Exception table */
10454 @@ -34,15 +50,12 @@ SECTIONS
10455         CONSTRUCTORS
10456         }
10457  
10458 -  . = ALIGN(4096);
10459 +  . = ALIGN(PAGE_SIZE_asm);
10460    __nosave_begin = .;
10461    .data_nosave : { *(.data.nosave) }
10462 -  . = ALIGN(4096);
10463 +  . = ALIGN(PAGE_SIZE_asm);
10464    __nosave_end = .;
10465  
10466 -  . = ALIGN(4096);
10467 -  .data.page_aligned : { *(.data.idt) }
10468 -
10469    . = ALIGN(32);
10470    .data.cacheline_aligned : { *(.data.cacheline_aligned) }
10471  
10472 @@ -52,7 +65,7 @@ SECTIONS
10473    .data.init_task : { *(.data.init_task) }
10474  
10475    /* will be freed after init */
10476 -  . = ALIGN(4096);             /* Init code and data */
10477 +  . = ALIGN(PAGE_SIZE_asm);            /* Init code and data */
10478    __init_begin = .;
10479    .init.text : { 
10480         _sinittext = .;
10481 @@ -91,7 +104,7 @@ SECTIONS
10482       from .altinstructions and .eh_frame */
10483    .exit.text : { *(.exit.text) }
10484    .exit.data : { *(.exit.data) }
10485 -  . = ALIGN(4096);
10486 +  . = ALIGN(PAGE_SIZE_asm);
10487    __initramfs_start = .;
10488    .init.ramfs : { *(.init.ramfs) }
10489    __initramfs_end = .;
10490 @@ -99,10 +112,22 @@ SECTIONS
10491    __per_cpu_start = .;
10492    .data.percpu  : { *(.data.percpu) }
10493    __per_cpu_end = .;
10494 -  . = ALIGN(4096);
10495 +  . = ALIGN(PAGE_SIZE_asm);
10496    __init_end = .;
10497    /* freed after init ends here */
10498 -       
10499 +
10500 +  . = ALIGN(PAGE_SIZE_asm);
10501 +  .data.page_aligned_tss : { *(.data.tss) }
10502 +
10503 +  . = ALIGN(PAGE_SIZE_asm);
10504 +  .data.page_aligned_default_ldt : { *(.data.default_ldt) }
10505 +
10506 +  . = ALIGN(PAGE_SIZE_asm);
10507 +  .data.page_aligned_idt : { *(.data.idt) }
10508 +
10509 +  . = ALIGN(PAGE_SIZE_asm);
10510 +  .data.page_aligned_gdt : { *(.data.gdt) }
10511 +
10512    __bss_start = .;             /* BSS */
10513    .bss : { *(.bss) }
10514    __bss_stop = .; 
10515 @@ -122,4 +147,6 @@ SECTIONS
10516    .stab.index 0 : { *(.stab.index) }
10517    .stab.indexstr 0 : { *(.stab.indexstr) }
10518    .comment 0 : { *(.comment) }
10519 +
10520 +
10521  }
10522 --- linux-2.6.0-test6/arch/i386/kernel/vsyscall.lds     2003-06-14 12:18:07.000000000 -0700
10523 +++ 25/arch/i386/kernel/vsyscall.lds    2003-10-05 00:36:48.000000000 -0700
10524 @@ -5,7 +5,7 @@
10525   */
10526  
10527  /* This must match <asm/fixmap.h>.  */
10528 -VSYSCALL_BASE = 0xffffe000;
10529 +VSYSCALL_BASE = 0xffffd000;
10530  
10531  SECTIONS
10532  {
10533 --- linux-2.6.0-test6/arch/i386/kernel/vsyscall-sysenter.S      2003-06-14 12:18:08.000000000 -0700
10534 +++ 25/arch/i386/kernel/vsyscall-sysenter.S     2003-10-05 00:36:48.000000000 -0700
10535 @@ -7,6 +7,11 @@
10536         .type __kernel_vsyscall,@function
10537  __kernel_vsyscall:
10538  .LSTART_vsyscall:
10539 +       cmpl $192, %eax
10540 +       jne 1f
10541 +       int $0x80
10542 +       ret
10543 +1:
10544         push %ecx
10545  .Lpush_ecx:
10546         push %edx
10547 --- linux-2.6.0-test6/arch/i386/lib/checksum.S  2003-06-14 12:18:30.000000000 -0700
10548 +++ 25/arch/i386/lib/checksum.S 2003-10-05 00:36:48.000000000 -0700
10549 @@ -280,14 +280,14 @@ unsigned int csum_partial_copy_generic (
10550         .previous
10551  
10552  .align 4
10553 -.globl csum_partial_copy_generic
10554 +.globl direct_csum_partial_copy_generic
10555                                 
10556  #ifndef CONFIG_X86_USE_PPRO_CHECKSUM
10557  
10558  #define ARGBASE 16             
10559  #define FP             12
10560                 
10561 -csum_partial_copy_generic:
10562 +direct_csum_partial_copy_generic:
10563         subl  $4,%esp   
10564         pushl %edi
10565         pushl %esi
10566 @@ -422,7 +422,7 @@ DST(        movb %cl, (%edi)        )
10567  
10568  #define ARGBASE 12
10569                 
10570 -csum_partial_copy_generic:
10571 +direct_csum_partial_copy_generic:
10572         pushl %ebx
10573         pushl %edi
10574         pushl %esi
10575 --- linux-2.6.0-test6/arch/i386/lib/dec_and_lock.c      2003-06-26 22:07:23.000000000 -0700
10576 +++ 25/arch/i386/lib/dec_and_lock.c     2003-10-05 00:36:40.000000000 -0700
10577 @@ -10,6 +10,7 @@
10578  #include <linux/spinlock.h>
10579  #include <asm/atomic.h>
10580  
10581 +#ifndef ATOMIC_DEC_AND_LOCK
10582  int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
10583  {
10584         int counter;
10585 @@ -38,3 +39,5 @@ slow_path:
10586         spin_unlock(lock);
10587         return 0;
10588  }
10589 +#endif
10590 +
10591 --- linux-2.6.0-test6/arch/i386/lib/getuser.S   2003-06-14 12:17:56.000000000 -0700
10592 +++ 25/arch/i386/lib/getuser.S  2003-10-05 00:36:48.000000000 -0700
10593 @@ -9,6 +9,7 @@
10594   * return value.
10595   */
10596  #include <asm/thread_info.h>
10597 +#include <asm/asm_offsets.h>
10598  
10599  
10600  /*
10601 @@ -28,7 +29,7 @@
10602  .globl __get_user_1
10603  __get_user_1:
10604         GET_THREAD_INFO(%edx)
10605 -       cmpl TI_ADDR_LIMIT(%edx),%eax
10606 +       cmpl TI_addr_limit(%edx),%eax
10607         jae bad_get_user
10608  1:     movzbl (%eax),%edx
10609         xorl %eax,%eax
10610 @@ -40,7 +41,7 @@ __get_user_2:
10611         addl $1,%eax
10612         jc bad_get_user
10613         GET_THREAD_INFO(%edx)
10614 -       cmpl TI_ADDR_LIMIT(%edx),%eax
10615 +       cmpl TI_addr_limit(%edx),%eax
10616         jae bad_get_user
10617  2:     movzwl -1(%eax),%edx
10618         xorl %eax,%eax
10619 @@ -52,7 +53,7 @@ __get_user_4:
10620         addl $3,%eax
10621         jc bad_get_user
10622         GET_THREAD_INFO(%edx)
10623 -       cmpl TI_ADDR_LIMIT(%edx),%eax
10624 +       cmpl TI_addr_limit(%edx),%eax
10625         jae bad_get_user
10626  3:     movl -3(%eax),%edx
10627         xorl %eax,%eax
10628 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
10629 +++ 25/arch/i386/lib/kgdb_serial.c      2003-10-05 00:33:44.000000000 -0700
10630 @@ -0,0 +1,499 @@
10631 +/*
10632 + * Serial interface GDB stub
10633 + *
10634 + * Written (hacked together) by David Grothe (dave@gcom.com)
10635 + * Modified to allow invokation early in boot see also
10636 + * kgdb.h for instructions by George Anzinger(george@mvista.com)
10637 + * Modified to handle debugging over ethernet by Robert Walsh
10638 + * <rjwalsh@durables.org> and wangdi <wangdi@clusterfs.com>, based on
10639 + * code by San Mehat.
10640 + *
10641 + */
10642 +
10643 +#include <linux/module.h>
10644 +#include <linux/errno.h>
10645 +#include <linux/signal.h>
10646 +#include <linux/sched.h>
10647 +#include <linux/timer.h>
10648 +#include <linux/interrupt.h>
10649 +#include <linux/tty.h>
10650 +#include <linux/tty_flip.h>
10651 +#include <linux/serial.h>
10652 +#include <linux/serial_reg.h>
10653 +#include <linux/config.h>
10654 +#include <linux/major.h>
10655 +#include <linux/string.h>
10656 +#include <linux/fcntl.h>
10657 +#include <linux/ptrace.h>
10658 +#include <linux/ioport.h>
10659 +#include <linux/mm.h>
10660 +#include <linux/init.h>
10661 +#include <linux/highmem.h>
10662 +#include <asm/system.h>
10663 +#include <asm/io.h>
10664 +#include <asm/segment.h>
10665 +#include <asm/bitops.h>
10666 +#include <asm/system.h>
10667 +#include <asm/kgdb_local.h>
10668 +#ifdef CONFIG_KGDB_USER_CONSOLE
10669 +extern void kgdb_console_finit(void);
10670 +#endif
10671 +#define PRNT_off
10672 +#define TEST_EXISTANCE
10673 +#ifdef PRNT
10674 +#define dbprintk(s) printk s
10675 +#else
10676 +#define dbprintk(s)
10677 +#endif
10678 +#define TEST_INTERRUPT_off
10679 +#ifdef TEST_INTERRUPT
10680 +#define intprintk(s) printk s
10681 +#else
10682 +#define intprintk(s)
10683 +#endif
10684 +
10685 +#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? SA_SHIRQ : SA_INTERRUPT)
10686 +
10687 +#define        GDB_BUF_SIZE    512     /* power of 2, please */
10688 +
10689 +static char gdb_buf[GDB_BUF_SIZE];
10690 +static int gdb_buf_in_inx;
10691 +static atomic_t gdb_buf_in_cnt;
10692 +static int gdb_buf_out_inx;
10693 +
10694 +struct async_struct *gdb_async_info;
10695 +static int gdb_async_irq;
10696 +
10697 +#define outb_px(a,b) outb_p(b,a)
10698 +
10699 +static void program_uart(struct async_struct *info);
10700 +static void write_char(struct async_struct *info, int chr);
10701 +/*
10702 + * Get a byte from the hardware data buffer and return it
10703 + */
10704 +static int
10705 +read_data_bfr(struct async_struct *info)
10706 +{
10707 +       char it = inb_p(info->port + UART_LSR);
10708 +
10709 +       if (it & UART_LSR_DR)
10710 +               return (inb_p(info->port + UART_RX));
10711 +       /*
10712 +        * If we have a framing error assume somebody messed with
10713 +        * our uart.  Reprogram it and send '-' both ways...
10714 +        */
10715 +       if (it & 0xc) {
10716 +               program_uart(info);
10717 +               write_char(info, '-');
10718 +               return ('-');
10719 +       }
10720 +       return (-1);
10721 +
10722 +}                              /* read_data_bfr */
10723 +
10724 +/*
10725 + * Get a char if available, return -1 if nothing available.
10726 + * Empty the receive buffer first, then look at the interface hardware.
10727 +
10728 + * Locking here is a bit of a problem. We MUST not lock out communication
10729 + * if we are trying to talk to gdb about a kgdb entry. ON the other hand
10730 + * we can loose chars in the console pass thru if we don't lock.  It is also
10731 + * possible that we could hold the lock or be waiting for it when kgdb
10732 + * NEEDS to talk.  Since kgdb locks down the world, it does not need locks.
10733 + * We do, of course have possible issues with interrupting a uart operation,
10734 + * but we will just depend on the uart status to help keep that straight.
10735 +
10736 + */
10737 +static spinlock_t uart_interrupt_lock = SPIN_LOCK_UNLOCKED;
10738 +#ifdef CONFIG_SMP
10739 +extern spinlock_t kgdb_spinlock;
10740 +#endif
10741 +
10742 +static int
10743 +read_char(struct async_struct *info)
10744 +{
10745 +       int chr;
10746 +       unsigned long flags;
10747 +       local_irq_save(flags);
10748 +#ifdef CONFIG_SMP
10749 +       if (!spin_is_locked(&kgdb_spinlock)) {
10750 +               spin_lock(&uart_interrupt_lock);
10751 +       }
10752 +#endif
10753 +       if (atomic_read(&gdb_buf_in_cnt) != 0) {        /* intr routine has q'd chars */
10754 +               chr = gdb_buf[gdb_buf_out_inx++];
10755 +               gdb_buf_out_inx &= (GDB_BUF_SIZE - 1);
10756 +               atomic_dec(&gdb_buf_in_cnt);
10757 +       } else {
10758 +               chr = read_data_bfr(info);
10759 +       }
10760 +#ifdef CONFIG_SMP
10761 +       if (!spin_is_locked(&kgdb_spinlock)) {
10762 +               spin_unlock(&uart_interrupt_lock);
10763 +       }
10764 +#endif
10765 +       local_irq_restore(flags);
10766 +       return (chr);
10767 +}
10768 +
10769 +/*
10770 + * Wait until the interface can accept a char, then write it.
10771 + */
10772 +static void
10773 +write_char(struct async_struct *info, int chr)
10774 +{
10775 +       while (!(inb_p(info->port + UART_LSR) & UART_LSR_THRE)) ;
10776 +
10777 +       outb_p(chr, info->port + UART_TX);
10778 +
10779 +}                              /* write_char */
10780 +
10781 +/*
10782 + * Mostly we don't need a spinlock, but since the console goes
10783 + * thru here with interrutps on, well, we need to catch those
10784 + * chars.
10785 + */
10786 +/*
10787 + * This is the receiver interrupt routine for the GDB stub.
10788 + * It will receive a limited number of characters of input
10789 + * from the gdb  host machine and save them up in a buffer.
10790 + *
10791 + * When the gdb stub routine tty_getDebugChar() is called it
10792 + * draws characters out of the buffer until it is empty and
10793 + * then reads directly from the serial port.
10794 + *
10795 + * We do not attempt to write chars from the interrupt routine
10796 + * since the stubs do all of that via tty_putDebugChar() which
10797 + * writes one byte after waiting for the interface to become
10798 + * ready.
10799 + *
10800 + * The debug stubs like to run with interrupts disabled since,
10801 + * after all, they run as a consequence of a breakpoint in
10802 + * the kernel.
10803 + *
10804 + * Perhaps someone who knows more about the tty driver than I
10805 + * care to learn can make this work for any low level serial
10806 + * driver.
10807 + */
10808 +static irqreturn_t
10809 +gdb_interrupt(int irq, void *dev_id, struct pt_regs *regs)
10810 +{
10811 +       struct async_struct *info;
10812 +       unsigned long flags;
10813 +
10814 +       info = gdb_async_info;
10815 +       if (!info || !info->tty || irq != gdb_async_irq)
10816 +               return IRQ_NONE;
10817 +
10818 +       local_irq_save(flags);
10819 +       spin_lock(&uart_interrupt_lock);
10820 +       do {
10821 +               int chr = read_data_bfr(info);
10822 +               intprintk(("Debug char on int: %x hex\n", chr));
10823 +               if (chr < 0)
10824 +                       continue;
10825 +
10826 +               if (chr == 3) { /* Ctrl-C means remote interrupt */
10827 +                       BREAKPOINT;
10828 +                       continue;
10829 +               }
10830 +
10831 +               if (atomic_read(&gdb_buf_in_cnt) >= GDB_BUF_SIZE) {
10832 +                       /* buffer overflow tosses early char */
10833 +                       read_char(info);
10834 +               }
10835 +               gdb_buf[gdb_buf_in_inx++] = chr;
10836 +               gdb_buf_in_inx &= (GDB_BUF_SIZE - 1);
10837 +       } while (inb_p(info->port + UART_IIR) & UART_IIR_RDI);
10838 +       spin_unlock(&uart_interrupt_lock);
10839 +       local_irq_restore(flags);
10840 +       return IRQ_HANDLED;
10841 +}                              /* gdb_interrupt */
10842 +
10843 +/*
10844 + * Just a NULL routine for testing.
10845 + */
10846 +void
10847 +gdb_null(void)
10848 +{
10849 +}                              /* gdb_null */
10850 +
10851 +/* These structure are filled in with values defined in asm/kgdb_local.h
10852 + */
10853 +static struct serial_state state = SB_STATE;
10854 +static struct async_struct local_info = SB_INFO;
10855 +static int ok_to_enable_ints = 0;
10856 +static void kgdb_enable_ints_now(void);
10857 +
10858 +extern char *kgdb_version;
10859 +/*
10860 + * Hook an IRQ for KGDB.
10861 + *
10862 + * This routine is called from tty_putDebugChar, below.
10863 + */
10864 +static int ints_disabled = 1;
10865 +int
10866 +gdb_hook_interrupt(struct async_struct *info, int verb)
10867 +{
10868 +       struct serial_state *state = info->state;
10869 +       unsigned long flags;
10870 +       int port;
10871 +#ifdef TEST_EXISTANCE
10872 +       int scratch, scratch2;
10873 +#endif
10874 +
10875 +       /* The above fails if memory managment is not set up yet.
10876 +        * Rather than fail the set up, just keep track of the fact
10877 +        * and pick up the interrupt thing later.
10878 +        */
10879 +       gdb_async_info = info;
10880 +       port = gdb_async_info->port;
10881 +       gdb_async_irq = state->irq;
10882 +       if (verb) {
10883 +               printk("kgdb %s : port =%x, IRQ=%d, divisor =%d\n",
10884 +                      kgdb_version,
10885 +                      port,
10886 +                      gdb_async_irq, gdb_async_info->state->custom_divisor);
10887 +       }
10888 +       local_irq_save(flags);
10889 +#ifdef TEST_EXISTANCE
10890 +       /* Existance test */
10891 +       /* Should not need all this, but just in case.... */
10892 +
10893 +       scratch = inb_p(port + UART_IER);
10894 +       outb_px(port + UART_IER, 0);
10895 +       outb_px(0xff, 0x080);
10896 +       scratch2 = inb_p(port + UART_IER);
10897 +       outb_px(port + UART_IER, scratch);
10898 +       if (scratch2) {
10899 +               printk
10900 +                   ("gdb_hook_interrupt: Could not clear IER, not a UART!\n");
10901 +               local_irq_restore(flags);
10902 +               return 1;       /* We failed; there's nothing here */
10903 +       }
10904 +       scratch2 = inb_p(port + UART_LCR);
10905 +       outb_px(port + UART_LCR, 0xBF); /* set up for StarTech test */
10906 +       outb_px(port + UART_EFR, 0);    /* EFR is the same as FCR */
10907 +       outb_px(port + UART_LCR, 0);
10908 +       outb_px(port + UART_FCR, UART_FCR_ENABLE_FIFO);
10909 +       scratch = inb_p(port + UART_IIR) >> 6;
10910 +       if (scratch == 1) {
10911 +               printk("gdb_hook_interrupt: Undefined UART type!"
10912 +                      "  Not a UART! \n");
10913 +               local_irq_restore(flags);
10914 +               return 1;
10915 +       } else {
10916 +               dbprintk(("gdb_hook_interrupt: UART type "
10917 +                         "is %d where 0=16450, 2=16550 3=16550A\n", scratch));
10918 +       }
10919 +       scratch = inb_p(port + UART_MCR);
10920 +       outb_px(port + UART_MCR, UART_MCR_LOOP | scratch);
10921 +       outb_px(port + UART_MCR, UART_MCR_LOOP | 0x0A);
10922 +       scratch2 = inb_p(port + UART_MSR) & 0xF0;
10923 +       outb_px(port + UART_MCR, scratch);
10924 +       if (scratch2 != 0x90) {
10925 +               printk("gdb_hook_interrupt: "
10926 +                      "Loop back test failed! Not a UART!\n");
10927 +               local_irq_restore(flags);
10928 +               return scratch2 + 1000; /* force 0 to fail */
10929 +       }
10930 +#endif                         /* test existance */
10931 +       program_uart(info);
10932 +       local_irq_restore(flags);
10933 +
10934 +       return (0);
10935 +
10936 +}                              /* gdb_hook_interrupt */
10937 +
10938 +static void
10939 +program_uart(struct async_struct *info)
10940 +{
10941 +       int port = info->port;
10942 +
10943 +       (void) inb_p(port + UART_RX);
10944 +       outb_px(port + UART_IER, 0);
10945 +
10946 +       (void) inb_p(port + UART_RX);   /* serial driver comments say */
10947 +       (void) inb_p(port + UART_IIR);  /* this clears the interrupt regs */
10948 +       (void) inb_p(port + UART_MSR);
10949 +       outb_px(port + UART_LCR, UART_LCR_WLEN8 | UART_LCR_DLAB);
10950 +       outb_px(port + UART_DLL, info->state->custom_divisor & 0xff);   /* LS */
10951 +       outb_px(port + UART_DLM, info->state->custom_divisor >> 8);     /* MS  */
10952 +       outb_px(port + UART_MCR, info->MCR);
10953 +
10954 +       outb_px(port + UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1 | UART_FCR_CLEAR_XMIT | UART_FCR_CLEAR_RCVR);        /* set fcr */
10955 +       outb_px(port + UART_LCR, UART_LCR_WLEN8);       /* reset DLAB */
10956 +       outb_px(port + UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1);    /* set fcr */
10957 +       if (!ints_disabled) {
10958 +               intprintk(("KGDB: Sending %d to port %x offset %d\n",
10959 +                          gdb_async_info->IER,
10960 +                          (int) gdb_async_info->port, UART_IER));
10961 +               outb_px(gdb_async_info->port + UART_IER, gdb_async_info->IER);
10962 +       }
10963 +       return;
10964 +}
10965 +
10966 +/*
10967 + * tty_getDebugChar
10968 + *
10969 + * This is a GDB stub routine. It waits for a character from the
10970 + * serial interface and then returns it.  If there is no serial
10971 + * interface connection then it returns a bogus value which will
10972 + * almost certainly cause the system to hang.  In the
10973 + */
10974 +int kgdb_in_isr = 0;
10975 +int kgdb_in_lsr = 0;
10976 +extern spinlock_t kgdb_spinlock;
10977 +
10978 +/* Caller takes needed protections */
10979 +
10980 +int
10981 +tty_getDebugChar(void)
10982 +{
10983 +       volatile int chr, dum, time, end_time;
10984 +
10985 +       dbprintk(("tty_getDebugChar(port %x): ", gdb_async_info->port));
10986 +
10987 +       if (gdb_async_info == NULL) {
10988 +               gdb_hook_interrupt(&local_info, 0);
10989 +       }
10990 +       /*
10991 +        * This trick says if we wait a very long time and get
10992 +        * no char, return the -1 and let the upper level deal
10993 +        * with it.
10994 +        */
10995 +       rdtsc(dum, time);
10996 +       end_time = time + 2;
10997 +       while (((chr = read_char(gdb_async_info)) == -1) &&
10998 +              (end_time - time) > 0) {
10999 +               rdtsc(dum, time);
11000 +       };
11001 +       /*
11002 +        * This covers our butts if some other code messes with
11003 +        * our uart, hay, it happens :o)
11004 +        */
11005 +       if (chr == -1)
11006 +               program_uart(gdb_async_info);
11007 +
11008 +       dbprintk(("%c\n", chr > ' ' && chr < 0x7F ? chr : ' '));
11009 +       return (chr);
11010 +
11011 +}                              /* tty_getDebugChar */
11012 +
11013 +static int count = 3;
11014 +static spinlock_t one_at_atime = SPIN_LOCK_UNLOCKED;
11015 +
11016 +static int __init
11017 +kgdb_enable_ints(void)
11018 +{
11019 +       if (kgdb_eth != -1) {
11020 +               return 0;
11021 +       }
11022 +       if (gdb_async_info == NULL) {
11023 +               gdb_hook_interrupt(&local_info, 1);
11024 +       }
11025 +       ok_to_enable_ints = 1;
11026 +       kgdb_enable_ints_now();
11027 +#ifdef CONFIG_KGDB_USER_CONSOLE
11028 +       kgdb_console_finit();
11029 +#endif
11030 +       return 0;
11031 +}
11032 +
11033 +#ifdef CONFIG_SERIAL_8250
11034 +void shutdown_for_kgdb(struct async_struct *gdb_async_info);
11035 +#endif
11036 +
11037 +#ifdef CONFIG_DISCONTIGMEM
11038 +static inline int kgdb_mem_init_done(void)
11039 +{
11040 +       return highmem_start_page != NULL;
11041 +}
11042 +#else
11043 +static inline int kgdb_mem_init_done(void)
11044 +{
11045 +       return max_mapnr != 0;
11046 +}
11047 +#endif
11048 +
11049 +static void
11050 +kgdb_enable_ints_now(void)
11051 +{
11052 +       if (!spin_trylock(&one_at_atime))
11053 +               return;
11054 +       if (!ints_disabled)
11055 +               goto exit;
11056 +       if (kgdb_mem_init_done() &&
11057 +                       ints_disabled) {        /* don't try till mem init */
11058 +#ifdef CONFIG_SERIAL_8250
11059 +               /*
11060 +                * The ifdef here allows the system to be configured
11061 +                * without the serial driver.
11062 +                * Don't make it a module, however, it will steal the port
11063 +                */
11064 +               shutdown_for_kgdb(gdb_async_info);
11065 +#endif
11066 +               ints_disabled = request_irq(gdb_async_info->state->irq,
11067 +                                           gdb_interrupt,
11068 +                                           IRQ_T(gdb_async_info),
11069 +                                           "KGDB-stub", NULL);
11070 +               intprintk(("KGDB: request_irq returned %d\n", ints_disabled));
11071 +       }
11072 +       if (!ints_disabled) {
11073 +               intprintk(("KGDB: Sending %d to port %x offset %d\n",
11074 +                          gdb_async_info->IER,
11075 +                          (int) gdb_async_info->port, UART_IER));
11076 +               outb_px(gdb_async_info->port + UART_IER, gdb_async_info->IER);
11077 +       }
11078 +      exit:
11079 +       spin_unlock(&one_at_atime);
11080 +}
11081 +
11082 +/*
11083 + * tty_putDebugChar
11084 + *
11085 + * This is a GDB stub routine. It waits until the interface is ready
11086 + * to transmit a char and then sends it.  If there is no serial
11087 + * interface connection then it simply returns to its caller, having
11088 + * pretended to send the char. Caller takes needed protections.
11089 + */
11090 +void
11091 +tty_putDebugChar(int chr)
11092 +{
11093 +       dbprintk(("tty_putDebugChar(port %x): chr=%02x '%c', ints_on=%d\n",
11094 +                 gdb_async_info->port,
11095 +                 chr,
11096 +                 chr > ' ' && chr < 0x7F ? chr : ' ', ints_disabled ? 0 : 1));
11097 +
11098 +       if (gdb_async_info == NULL) {
11099 +               gdb_hook_interrupt(&local_info, 0);
11100 +       }
11101 +
11102 +       write_char(gdb_async_info, chr);        /* this routine will wait */
11103 +       count = (chr == '#') ? 0 : count + 1;
11104 +       if ((count == 2)) {     /* try to enable after */
11105 +               if (ints_disabled & ok_to_enable_ints)
11106 +                       kgdb_enable_ints_now(); /* try to enable after */
11107 +
11108 +               /* We do this a lot because, well we really want to get these
11109 +                * interrupts.  The serial driver will clear these bits when it
11110 +                * initializes the chip.  Every thing else it does is ok,
11111 +                * but this.
11112 +                */
11113 +               if (!ints_disabled) {
11114 +                       outb_px(gdb_async_info->port + UART_IER,
11115 +                               gdb_async_info->IER);
11116 +               }
11117 +       }
11118 +
11119 +}                              /* tty_putDebugChar */
11120 +
11121 +/*
11122 + * This does nothing for the serial port, since it doesn't buffer.
11123 + */
11124 +
11125 +void tty_flushDebugChar(void)
11126 +{
11127 +}
11128 +
11129 +module_init(kgdb_enable_ints);
11130 --- linux-2.6.0-test6/arch/i386/lib/Makefile    2003-06-26 22:07:23.000000000 -0700
11131 +++ 25/arch/i386/lib/Makefile   2003-10-05 00:33:38.000000000 -0700
11132 @@ -9,4 +9,5 @@ lib-y = checksum.o delay.o \
11133  
11134  lib-$(CONFIG_X86_USE_3DNOW) += mmx.o
11135  lib-$(CONFIG_HAVE_DEC_LOCK) += dec_and_lock.o
11136 +lib-$(CONFIG_KGDB) += kgdb_serial.o
11137  lib-$(CONFIG_DEBUG_IOVIRT)  += iodebug.o
11138 --- linux-2.6.0-test6/arch/i386/lib/usercopy.c  2003-08-22 19:23:40.000000000 -0700
11139 +++ 25/arch/i386/lib/usercopy.c 2003-10-05 00:36:48.000000000 -0700
11140 @@ -76,7 +76,7 @@ do {                                                                     \
11141   * and returns @count.
11142   */
11143  long
11144 -__strncpy_from_user(char *dst, const char __user *src, long count)
11145 +__direct_strncpy_from_user(char *dst, const char __user *src, long count)
11146  {
11147         long res;
11148         __do_strncpy_from_user(dst, src, count, res);
11149 @@ -102,7 +102,7 @@ __strncpy_from_user(char *dst, const cha
11150   * and returns @count.
11151   */
11152  long
11153 -strncpy_from_user(char *dst, const char __user *src, long count)
11154 +direct_strncpy_from_user(char *dst, const char __user *src, long count)
11155  {
11156         long res = -EFAULT;
11157         if (access_ok(VERIFY_READ, src, 1))
11158 @@ -147,7 +147,7 @@ do {                                                                        \
11159   * On success, this will be zero.
11160   */
11161  unsigned long
11162 -clear_user(void __user *to, unsigned long n)
11163 +direct_clear_user(void __user *to, unsigned long n)
11164  {
11165         might_sleep();
11166         if (access_ok(VERIFY_WRITE, to, n))
11167 @@ -167,7 +167,7 @@ clear_user(void __user *to, unsigned lon
11168   * On success, this will be zero.
11169   */
11170  unsigned long
11171 -__clear_user(void __user *to, unsigned long n)
11172 +__direct_clear_user(void __user *to, unsigned long n)
11173  {
11174         __do_clear_user(to, n);
11175         return n;
11176 @@ -184,7 +184,7 @@ __clear_user(void __user *to, unsigned l
11177   * On exception, returns 0.
11178   * If the string is too long, returns a value greater than @n.
11179   */
11180 -long strnlen_user(const char __user *s, long n)
11181 +long direct_strnlen_user(const char __user *s, long n)
11182  {
11183         unsigned long mask = -__addr_ok(s);
11184         unsigned long res, tmp;
11185 @@ -573,3 +573,4 @@ unsigned long __copy_from_user_ll(void *
11186                 n = __copy_user_zeroing_intel(to, (const void *) from, n);
11187         return n;
11188  }
11189 +
11190 --- linux-2.6.0-test6/arch/i386/Makefile        2003-09-27 18:57:43.000000000 -0700
11191 +++ 25/arch/i386/Makefile       2003-10-05 00:33:38.000000000 -0700
11192 @@ -84,6 +84,9 @@ mcore-$(CONFIG_X86_ES7000)    := mach-es700
11193  # default subarch .h files
11194  mflags-y += -Iinclude/asm-i386/mach-default
11195  
11196 +mflags-$(CONFIG_KGDB) += -gdwarf-2
11197 +mflags-$(CONFIG_KGDB_MORE) += $(shell echo $(CONFIG_KGDB_OPTIONS) | sed -e 's/"//g')
11198 +
11199  head-y := arch/i386/kernel/head.o arch/i386/kernel/init_task.o
11200  
11201  libs-y                                         += arch/i386/lib/
11202 --- linux-2.6.0-test6/arch/i386/math-emu/fpu_system.h   2003-06-14 12:18:06.000000000 -0700
11203 +++ 25/arch/i386/math-emu/fpu_system.h  2003-10-05 00:36:48.000000000 -0700
11204 @@ -15,6 +15,7 @@
11205  #include <linux/sched.h>
11206  #include <linux/kernel.h>
11207  #include <linux/mm.h>
11208 +#include <asm/atomic_kmap.h>
11209  
11210  /* This sets the pointer FPU_info to point to the argument part
11211     of the stack frame of math_emulate() */
11212 @@ -22,7 +23,7 @@
11213  
11214  /* s is always from a cpu register, and the cpu does bounds checking
11215   * during register load --> no further bounds checks needed */
11216 -#define LDT_DESCRIPTOR(s)      (((struct desc_struct *)current->mm->context.ldt)[(s) >> 3])
11217 +#define LDT_DESCRIPTOR(s)      (((struct desc_struct *)__kmap_atomic_vaddr(KM_LDT_PAGE0))[(s) >> 3])
11218  #define SEG_D_SIZE(x)          ((x).b & (3 << 21))
11219  #define SEG_G_BIT(x)           ((x).b & (1 << 23))
11220  #define SEG_GRANULARITY(x)     (((x).b & (1 << 23)) ? 4096 : 1)
11221 --- linux-2.6.0-test6/arch/i386/mm/extable.c    2003-06-14 12:18:51.000000000 -0700
11222 +++ 25/arch/i386/mm/extable.c   2003-10-05 00:36:48.000000000 -0700
11223 @@ -6,6 +6,52 @@
11224  #include <linux/module.h>
11225  #include <linux/spinlock.h>
11226  #include <asm/uaccess.h>
11227 +#include <asm/pgtable.h>
11228 +
11229 +extern struct exception_table_entry __start___ex_table[];
11230 +extern struct exception_table_entry __stop___ex_table[];
11231 +
11232 +/*
11233 + * The exception table needs to be sorted because we use the macros
11234 + * which put things into the exception table in a variety of sections
11235 + * as well as the init section and the main kernel text section.
11236 + */
11237 +static inline void
11238 +sort_ex_table(struct exception_table_entry *start,
11239 +             struct exception_table_entry *finish)
11240 +{
11241 +       struct exception_table_entry el, *p, *q;
11242 +
11243 +       /* insertion sort */
11244 +       for (p = start + 1; p < finish; ++p) {
11245 +               /* start .. p-1 is sorted */
11246 +               if (p[0].insn < p[-1].insn) {
11247 +                       /* move element p down to its right place */
11248 +                       el = *p;
11249 +                       q = p;
11250 +                       do {
11251 +                               /* el comes before q[-1], move q[-1] up one */
11252 +                               q[0] = q[-1];
11253 +                               --q;
11254 +                       } while (q > start && el.insn < q[-1].insn);
11255 +                       *q = el;
11256 +               }
11257 +       }
11258 +}
11259 +
11260 +void fixup_sort_exception_table(void)
11261 +{
11262 +       struct exception_table_entry *p;
11263 +
11264 +       /*
11265 +        * Fix up the trampoline exception addresses:
11266 +        */
11267 +       for (p = __start___ex_table; p < __stop___ex_table; p++) {
11268 +               p->insn = (unsigned long)(void *)p->insn;
11269 +               p->fixup = (unsigned long)(void *)p->fixup;
11270 +       }
11271 +       sort_ex_table(__start___ex_table, __stop___ex_table);
11272 +}
11273  
11274  /* Simple binary search */
11275  const struct exception_table_entry *
11276 @@ -15,13 +61,15 @@ search_extable(const struct exception_ta
11277  {
11278          while (first <= last) {
11279                 const struct exception_table_entry *mid;
11280 -               long diff;
11281  
11282                 mid = (last - first) / 2 + first;
11283 -               diff = mid->insn - value;
11284 -                if (diff == 0)
11285 +               /*
11286 +                * careful, the distance between entries can be
11287 +                * larger than 2GB:
11288 +                */
11289 +                if (mid->insn == value)
11290                          return mid;
11291 -                else if (diff < 0)
11292 +                else if (mid->insn < value)
11293                          first = mid+1;
11294                  else
11295                          last = mid-1;
11296 --- linux-2.6.0-test6/arch/i386/mm/fault.c      2003-06-26 22:07:23.000000000 -0700
11297 +++ 25/arch/i386/mm/fault.c     2003-10-05 00:36:50.000000000 -0700
11298 @@ -19,6 +19,7 @@
11299  #include <linux/init.h>
11300  #include <linux/tty.h>
11301  #include <linux/vt_kern.h>             /* For unblank_screen() */
11302 +#include <linux/highmem.h>
11303  #include <linux/module.h>
11304  
11305  #include <asm/system.h>
11306 @@ -26,6 +27,7 @@
11307  #include <asm/pgalloc.h>
11308  #include <asm/hardirq.h>
11309  #include <asm/desc.h>
11310 +#include <asm/tlbflush.h>
11311  
11312  extern void die(const char *,struct pt_regs *,long);
11313  
11314 @@ -55,6 +57,161 @@ void bust_spinlocks(int yes)
11315         console_loglevel = loglevel_save;
11316  }
11317  
11318 +/*
11319 + * Return EIP plus the CS segment base.  The segment limit is also
11320 + * adjusted, clamped to the kernel/user address space (whichever is
11321 + * appropriate), and returned in *eip_limit.
11322 + *
11323 + * The segment is checked, because it might have been changed by another
11324 + * task between the original faulting instruction and here.
11325 + *
11326 + * If CS is no longer a valid code segment, or if EIP is beyond the
11327 + * limit, or if it is a kernel address when CS is not a kernel segment,
11328 + * then the returned value will be greater than *eip_limit.
11329 + */
11330 +static inline unsigned long get_segment_eip(struct pt_regs *regs,
11331 +                                           unsigned long *eip_limit)
11332 +{
11333 +       unsigned long eip = regs->eip;
11334 +       unsigned seg = regs->xcs & 0xffff;
11335 +       u32 seg_ar, seg_limit, base, *desc;
11336 +
11337 +       /* The standard kernel/user address space limit. */
11338 +       *eip_limit = (seg & 3) ? USER_DS.seg : KERNEL_DS.seg;
11339 +
11340 +       /* Unlikely, but must come before segment checks. */
11341 +       if (unlikely((regs->eflags & VM_MASK) != 0))
11342 +               return eip + (seg << 4);
11343 +
11344 +       /* By far the commonest cases. */
11345 +       if (likely(seg == __USER_CS || seg == __KERNEL_CS))
11346 +               return eip;
11347 +
11348 +       /* Check the segment exists, is within the current LDT/GDT size,
11349 +          that kernel/user (ring 0..3) has the appropriate privilege,
11350 +          that it's a code segment, and get the limit. */
11351 +       __asm__ ("larl %3,%0; lsll %3,%1"
11352 +                : "=&r" (seg_ar), "=r" (seg_limit) : "0" (0), "rm" (seg));
11353 +       if ((~seg_ar & 0x9800) || eip > seg_limit) {
11354 +               *eip_limit = 0;
11355 +               return 1;        /* So that returned eip > *eip_limit. */
11356 +       }
11357 +
11358 +       /* Get the GDT/LDT descriptor base.
11359 +          When you look for races in this code remember that
11360 +          LDT and other horrors are only used in user space. */
11361 +       if (seg & (1<<2)) {
11362 +               /* Must lock the LDT while reading it. */
11363 +               down(&current->mm->context.sem);
11364 +#if 1
11365 +               /* horrible hack for 4/4 disabled kernels.
11366 +                  I'm not quite sure what the TLB flush is good for,
11367 +                  it's mindlessly copied from the read_ldt code */
11368 +               __flush_tlb_global();
11369 +               desc = kmap(current->mm->context.ldt_pages[(seg & ~7)/PAGE_SIZE]);
11370 +               desc = (void *)desc + ((seg & ~7) % PAGE_SIZE);
11371 +#else
11372 +               desc = current->mm->context.ldt;
11373 +               desc = (void *)desc + (seg & ~7);
11374 +#endif
11375 +       } else {
11376 +               /* Must disable preemption while reading the GDT. */
11377 +               desc = (u32 *)&cpu_gdt_table[get_cpu()];
11378 +               desc = (void *)desc + (seg & ~7);
11379 +       }
11380 +       base = (desc[0] >> 16) |
11381 +               ((desc[1] & 0xff) << 16) |
11382 +               (desc[1] & 0xff000000);
11383 +       if (seg & (1<<2)) {
11384 +#if 1
11385 +               kunmap((void *)((unsigned long)desc & PAGE_MASK));
11386 +#endif
11387 +               up(&current->mm->context.sem);
11388 +       } else
11389 +               put_cpu();
11390 +
11391 +       /* Adjust EIP and segment limit, and clamp at the kernel limit.
11392 +          It's legitimate for segments to wrap at 0xffffffff. */
11393 +       seg_limit += base;
11394 +       if (seg_limit < *eip_limit && seg_limit >= base)
11395 +               *eip_limit = seg_limit;
11396 +       return eip + base;
11397 +}
11398 +
11399 +/*
11400 + * Sometimes AMD Athlon/Opteron CPUs report invalid exceptions on prefetch.
11401 + * Check that here and ignore it.
11402 + */
11403 +static int __is_prefetch(struct pt_regs *regs, unsigned long addr)
11404 +{
11405 +       unsigned long limit;
11406 +       unsigned long instr = get_segment_eip (regs, &limit);
11407 +       int scan_more = 1;
11408 +       int prefetch = 0;
11409 +       int i;
11410 +
11411 +       for (i = 0; scan_more && i < 15; i++) {
11412 +               unsigned char opcode;
11413 +               unsigned char instr_hi;
11414 +               unsigned char instr_lo;
11415 +
11416 +               if (instr > limit)
11417 +                       break;
11418 +               if (__get_user(opcode, (unsigned char *) instr))
11419 +                       break;
11420 +
11421 +               instr_hi = opcode & 0xf0;
11422 +               instr_lo = opcode & 0x0f;
11423 +               instr++;
11424 +
11425 +               switch (instr_hi) {
11426 +               case 0x20:
11427 +               case 0x30:
11428 +                       /* Values 0x26,0x2E,0x36,0x3E are valid x86 prefixes. */
11429 +                       scan_more = ((instr_lo & 7) == 0x6);
11430 +                       break;
11431 +
11432 +               case 0x60:
11433 +                       /* 0x64 thru 0x67 are valid prefixes in all modes. */
11434 +                       scan_more = (instr_lo & 0xC) == 0x4;
11435 +                       break;
11436 +               case 0xF0:
11437 +                       /* 0xF0, 0xF2, and 0xF3 are valid prefixes in all modes. */
11438 +                       scan_more = !instr_lo || (instr_lo>>1) == 1;
11439 +                       break;
11440 +               case 0x00:
11441 +                       /* Prefetch instruction is 0x0F0D or 0x0F18 */
11442 +                       scan_more = 0;
11443 +                       if (instr > limit)
11444 +                               break;
11445 +                       if (__get_user(opcode, (unsigned char *) instr))
11446 +                               break;
11447 +                       prefetch = (instr_lo == 0xF) &&
11448 +                               (opcode == 0x0D || opcode == 0x18);
11449 +                       break;
11450 +               default:
11451 +                       scan_more = 0;
11452 +                       break;
11453 +               }
11454 +       }
11455 +
11456 +#if 1
11457 +       if (prefetch)
11458 +               printk("prefetch handled at %lx eip %lx instr %lx cs %x\n",
11459 +                      addr, regs->eip, instr, regs->xcs);
11460 +#endif
11461 +
11462 +       return prefetch;
11463 +}
11464 +
11465 +static inline int is_prefetch(struct pt_regs *regs, unsigned long addr)
11466 +{
11467 +       if (unlikely(boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
11468 +                    boot_cpu_data.x86 >= 6))
11469 +               return __is_prefetch(regs, addr);
11470 +       return 0;
11471 +}
11472 +
11473  asmlinkage void do_invalid_op(struct pt_regs *, unsigned long);
11474  
11475  /*
11476 @@ -86,6 +243,8 @@ asmlinkage void do_page_fault(struct pt_
11477  
11478         tsk = current;
11479  
11480 +       info.si_code = SEGV_MAPERR;
11481 +
11482         /*
11483          * We fault-in kernel-space virtual memory on-demand. The
11484          * 'reference' page table is init_mm.pgd.
11485 @@ -99,18 +258,26 @@ asmlinkage void do_page_fault(struct pt_
11486          * (error_code & 4) == 0, and that the fault was not a
11487          * protection error (error_code & 1) == 0.
11488          */
11489 -       if (address >= TASK_SIZE && !(error_code & 5))
11490 +#ifdef CONFIG_X86_4G
11491 +       /* On 4/4 all kernels faults are either bugs, vmalloc or prefetch */
11492 +       if (unlikely((regs->xcs & 3) == 0))
11493                 goto vmalloc_fault;
11494 +#else
11495 +       if (unlikely(address >= TASK_SIZE)) {
11496 +               if (!(error_code & 5))
11497 +                       goto vmalloc_fault;
11498 +               goto bad_area_nosemaphore;
11499 +       }
11500 +#endif
11501  
11502         mm = tsk->mm;
11503 -       info.si_code = SEGV_MAPERR;
11504  
11505         /*
11506          * If we're in an interrupt, have no user context or are running in an
11507          * atomic region then we must not take the fault..
11508          */
11509         if (in_atomic() || !mm)
11510 -               goto no_context;
11511 +               goto bad_area_nosemaphore;
11512  
11513         down_read(&mm->mmap_sem);
11514  
11515 @@ -198,8 +365,16 @@ good_area:
11516  bad_area:
11517         up_read(&mm->mmap_sem);
11518  
11519 +bad_area_nosemaphore:
11520         /* User mode accesses just cause a SIGSEGV */
11521         if (error_code & 4) {
11522 +               /*
11523 +                * Valid to do another page fault here because this one came
11524 +                * from user space.
11525 +                */
11526 +               if (is_prefetch(regs, address))
11527 +                       return;
11528 +
11529                 tsk->thread.cr2 = address;
11530                 tsk->thread.error_code = error_code;
11531                 tsk->thread.trap_no = 14;
11532 @@ -232,10 +407,24 @@ no_context:
11533         if (fixup_exception(regs))
11534                 return;
11535  
11536 +       /*
11537 +        * Valid to do another page fault here, because if this fault
11538 +        * had been triggered by is_prefetch fixup_exception would have
11539 +        * handled it.
11540 +        */
11541 +       if (is_prefetch(regs, address))
11542 +               return;
11543 +
11544  /*
11545   * Oops. The kernel tried to access some bad page. We'll have to
11546   * terminate things with extreme prejudice.
11547   */
11548 +#ifdef CONFIG_KGDB
11549 +        if (!user_mode(regs)){
11550 +                kgdb_handle_exception(14,SIGBUS, error_code, regs);
11551 +                return;
11552 +        }
11553 +#endif
11554  
11555         bust_spinlocks(1);
11556  
11557 @@ -286,10 +475,14 @@ out_of_memory:
11558  do_sigbus:
11559         up_read(&mm->mmap_sem);
11560  
11561 -       /*
11562 -        * Send a sigbus, regardless of whether we were in kernel
11563 -        * or user mode.
11564 -        */
11565 +       /* Kernel mode? Handle exceptions or die */
11566 +       if (!(error_code & 4))
11567 +               goto no_context;
11568 +
11569 +       /* User space => ok to do another page fault */
11570 +       if (is_prefetch(regs, address))
11571 +               return;
11572 +
11573         tsk->thread.cr2 = address;
11574         tsk->thread.error_code = error_code;
11575         tsk->thread.trap_no = 14;
11576 @@ -298,10 +491,6 @@ do_sigbus:
11577         info.si_code = BUS_ADRERR;
11578         info.si_addr = (void *)address;
11579         force_sig_info(SIGBUS, &info, tsk);
11580 -
11581 -       /* Kernel mode? Handle exceptions or die */
11582 -       if (!(error_code & 4))
11583 -               goto no_context;
11584         return;
11585  
11586  vmalloc_fault:
11587 --- linux-2.6.0-test6/arch/i386/mm/init.c       2003-08-08 22:55:10.000000000 -0700
11588 +++ 25/arch/i386/mm/init.c      2003-10-05 00:36:48.000000000 -0700
11589 @@ -25,6 +25,7 @@
11590  #include <linux/bootmem.h>
11591  #include <linux/slab.h>
11592  #include <linux/proc_fs.h>
11593 +#include <linux/efi.h>
11594  
11595  #include <asm/processor.h>
11596  #include <asm/system.h>
11597 @@ -38,125 +39,13 @@
11598  #include <asm/tlb.h>
11599  #include <asm/tlbflush.h>
11600  #include <asm/sections.h>
11601 +#include <asm/desc.h>
11602  
11603  DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
11604  unsigned long highstart_pfn, highend_pfn;
11605  
11606  static int do_test_wp_bit(void);
11607  
11608 -/*
11609 - * Creates a middle page table and puts a pointer to it in the
11610 - * given global directory entry. This only returns the gd entry
11611 - * in non-PAE compilation mode, since the middle layer is folded.
11612 - */
11613 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
11614 -{
11615 -       pmd_t *pmd_table;
11616 -               
11617 -#ifdef CONFIG_X86_PAE
11618 -       pmd_table = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
11619 -       set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
11620 -       if (pmd_table != pmd_offset(pgd, 0)) 
11621 -               BUG();
11622 -#else
11623 -       pmd_table = pmd_offset(pgd, 0);
11624 -#endif
11625 -
11626 -       return pmd_table;
11627 -}
11628 -
11629 -/*
11630 - * Create a page table and place a pointer to it in a middle page
11631 - * directory entry.
11632 - */
11633 -static pte_t * __init one_page_table_init(pmd_t *pmd)
11634 -{
11635 -       if (pmd_none(*pmd)) {
11636 -               pte_t *page_table = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
11637 -               set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
11638 -               if (page_table != pte_offset_kernel(pmd, 0))
11639 -                       BUG();  
11640 -
11641 -               return page_table;
11642 -       }
11643 -       
11644 -       return pte_offset_kernel(pmd, 0);
11645 -}
11646 -
11647 -/*
11648 - * This function initializes a certain range of kernel virtual memory 
11649 - * with new bootmem page tables, everywhere page tables are missing in
11650 - * the given range.
11651 - */
11652 -
11653 -/*
11654 - * NOTE: The pagetables are allocated contiguous on the physical space 
11655 - * so we can cache the place of the first one and move around without 
11656 - * checking the pgd every time.
11657 - */
11658 -static void __init page_table_range_init (unsigned long start, unsigned long end, pgd_t *pgd_base)
11659 -{
11660 -       pgd_t *pgd;
11661 -       pmd_t *pmd;
11662 -       int pgd_idx, pmd_idx;
11663 -       unsigned long vaddr;
11664 -
11665 -       vaddr = start;
11666 -       pgd_idx = pgd_index(vaddr);
11667 -       pmd_idx = pmd_index(vaddr);
11668 -       pgd = pgd_base + pgd_idx;
11669 -
11670 -       for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
11671 -               if (pgd_none(*pgd)) 
11672 -                       one_md_table_init(pgd);
11673 -
11674 -               pmd = pmd_offset(pgd, vaddr);
11675 -               for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end); pmd++, pmd_idx++) {
11676 -                       if (pmd_none(*pmd)) 
11677 -                               one_page_table_init(pmd);
11678 -
11679 -                       vaddr += PMD_SIZE;
11680 -               }
11681 -               pmd_idx = 0;
11682 -       }
11683 -}
11684 -
11685 -/*
11686 - * This maps the physical memory to kernel virtual address space, a total 
11687 - * of max_low_pfn pages, by creating page tables starting from address 
11688 - * PAGE_OFFSET.
11689 - */
11690 -static void __init kernel_physical_mapping_init(pgd_t *pgd_base)
11691 -{
11692 -       unsigned long pfn;
11693 -       pgd_t *pgd;
11694 -       pmd_t *pmd;
11695 -       pte_t *pte;
11696 -       int pgd_idx, pmd_idx, pte_ofs;
11697 -
11698 -       pgd_idx = pgd_index(PAGE_OFFSET);
11699 -       pgd = pgd_base + pgd_idx;
11700 -       pfn = 0;
11701 -
11702 -       for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
11703 -               pmd = one_md_table_init(pgd);
11704 -               if (pfn >= max_low_pfn)
11705 -                       continue;
11706 -               for (pmd_idx = 0; pmd_idx < PTRS_PER_PMD && pfn < max_low_pfn; pmd++, pmd_idx++) {
11707 -                       /* Map with big pages if possible, otherwise create normal page tables. */
11708 -                       if (cpu_has_pse) {
11709 -                               set_pmd(pmd, pfn_pmd(pfn, PAGE_KERNEL_LARGE));
11710 -                               pfn += PTRS_PER_PTE;
11711 -                       } else {
11712 -                               pte = one_page_table_init(pmd);
11713 -
11714 -                               for (pte_ofs = 0; pte_ofs < PTRS_PER_PTE && pfn < max_low_pfn; pte++, pfn++, pte_ofs++)
11715 -                                       set_pte(pte, pfn_pte(pfn, PAGE_KERNEL));
11716 -                       }
11717 -               }
11718 -       }       
11719 -}
11720 -
11721  static inline int page_kills_ppro(unsigned long pagenr)
11722  {
11723         if (pagenr >= 0x70000 && pagenr <= 0x7003F)
11724 @@ -164,12 +53,30 @@ static inline int page_kills_ppro(unsign
11725         return 0;
11726  }
11727  
11728 +extern int is_available_memory(efi_memory_desc_t *);
11729 +
11730  static inline int page_is_ram(unsigned long pagenr)
11731  {
11732         int i;
11733 +       unsigned long addr, end;
11734 +
11735 +       if (efi_enabled) {
11736 +               efi_memory_desc_t *md;
11737 +
11738 +               for (i = 0; i < memmap.nr_map; i++) {
11739 +                       md = &memmap.map[i];
11740 +                       if (!is_available_memory(md))
11741 +                               continue;
11742 +                       addr = (md->phys_addr+PAGE_SIZE-1) >> PAGE_SHIFT;
11743 +                       end = (md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT)) >> PAGE_SHIFT;
11744 +
11745 +                       if ((pagenr >= addr) && (pagenr < end))
11746 +                               return 1;
11747 +               }
11748 +               return 0;
11749 +       }
11750  
11751         for (i = 0; i < e820.nr_map; i++) {
11752 -               unsigned long addr, end;
11753  
11754                 if (e820.map[i].type != E820_RAM)       /* not usable memory */
11755                         continue;
11756 @@ -186,38 +93,14 @@ static inline int page_is_ram(unsigned l
11757         return 0;
11758  }
11759  
11760 -#ifdef CONFIG_HIGHMEM
11761  pte_t *kmap_pte;
11762 -pgprot_t kmap_prot;
11763  
11764  #define kmap_get_fixmap_pte(vaddr)                                     \
11765         pte_offset_kernel(pmd_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr))
11766  
11767  void __init kmap_init(void)
11768  {
11769 -       unsigned long kmap_vstart;
11770 -
11771 -       /* cache the first kmap pte */
11772 -       kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
11773 -       kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
11774 -
11775 -       kmap_prot = PAGE_KERNEL;
11776 -}
11777 -
11778 -void __init permanent_kmaps_init(pgd_t *pgd_base)
11779 -{
11780 -       pgd_t *pgd;
11781 -       pmd_t *pmd;
11782 -       pte_t *pte;
11783 -       unsigned long vaddr;
11784 -
11785 -       vaddr = PKMAP_BASE;
11786 -       page_table_range_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base);
11787 -
11788 -       pgd = swapper_pg_dir + pgd_index(vaddr);
11789 -       pmd = pmd_offset(pgd, vaddr);
11790 -       pte = pte_offset_kernel(pmd, vaddr);
11791 -       pkmap_page_table = pte; 
11792 +       kmap_pte = kmap_get_fixmap_pte(__fix_to_virt(FIX_KMAP_BEGIN));
11793  }
11794  
11795  void __init one_highpage_init(struct page *page, int pfn, int bad_ppro)
11796 @@ -232,6 +115,8 @@ void __init one_highpage_init(struct pag
11797                 SetPageReserved(page);
11798  }
11799  
11800 +#ifdef CONFIG_HIGHMEM
11801 +
11802  #ifndef CONFIG_DISCONTIGMEM
11803  void __init set_highmem_pages_init(int bad_ppro) 
11804  {
11805 @@ -243,12 +128,9 @@ void __init set_highmem_pages_init(int b
11806  #else
11807  extern void set_highmem_pages_init(int);
11808  #endif /* !CONFIG_DISCONTIGMEM */
11809 -
11810  #else
11811 -#define kmap_init() do { } while (0)
11812 -#define permanent_kmaps_init(pgd_base) do { } while (0)
11813 -#define set_highmem_pages_init(bad_ppro) do { } while (0)
11814 -#endif /* CONFIG_HIGHMEM */
11815 +# define set_highmem_pages_init(bad_ppro) do { } while (0)
11816 +#endif
11817  
11818  unsigned long __PAGE_KERNEL = _PAGE_KERNEL;
11819  
11820 @@ -258,30 +140,125 @@ unsigned long __PAGE_KERNEL = _PAGE_KERN
11821  extern void __init remap_numa_kva(void);
11822  #endif
11823  
11824 -static void __init pagetable_init (void)
11825 +static __init void prepare_pagetables(pgd_t *pgd_base, unsigned long address)
11826 +{
11827 +       pgd_t *pgd;
11828 +       pmd_t *pmd;
11829 +       pte_t *pte;
11830 +
11831 +       pgd = pgd_base + pgd_index(address);
11832 +       pmd = pmd_offset(pgd, address);
11833 +       if (!pmd_present(*pmd)) {
11834 +               pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
11835 +               set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)));
11836 +       }
11837 +}
11838 +
11839 +static void __init fixrange_init (unsigned long start, unsigned long end, pgd_t *pgd_base)
11840 +{
11841 +       unsigned long vaddr;
11842 +
11843 +       for (vaddr = start; vaddr != end; vaddr += PAGE_SIZE)
11844 +               prepare_pagetables(pgd_base, vaddr);
11845 +}
11846 +
11847 +void setup_identity_mappings(pgd_t *pgd_base, unsigned long start, unsigned long end)
11848  {
11849         unsigned long vaddr;
11850 -       pgd_t *pgd_base = swapper_pg_dir;
11851 +       pgd_t *pgd;
11852 +       int i, j, k;
11853 +       pmd_t *pmd;
11854 +       pte_t *pte, *pte_base;
11855 +
11856 +       pgd = pgd_base;
11857 +
11858 +       for (i = 0; i < PTRS_PER_PGD; pgd++, i++) {
11859 +               vaddr = i*PGDIR_SIZE;
11860 +               if (end && (vaddr >= end))
11861 +                       break;
11862 +               pmd = pmd_offset(pgd, 0);
11863 +               for (j = 0; j < PTRS_PER_PMD; pmd++, j++) {
11864 +                       vaddr = i*PGDIR_SIZE + j*PMD_SIZE;
11865 +                       if (end && (vaddr >= end))
11866 +                               break;
11867 +                       if (vaddr < start)
11868 +                               continue;
11869 +                       if (cpu_has_pse) {
11870 +                               unsigned long __pe;
11871 +
11872 +                               set_in_cr4(X86_CR4_PSE);
11873 +                               boot_cpu_data.wp_works_ok = 1;
11874 +                               __pe = _KERNPG_TABLE + _PAGE_PSE + vaddr - start;
11875 +                               /* Make it "global" too if supported */
11876 +                               if (cpu_has_pge) {
11877 +                                       set_in_cr4(X86_CR4_PGE);
11878 +#if !defined(CONFIG_X86_SWITCH_PAGETABLES)
11879 +                                       __pe += _PAGE_GLOBAL;
11880 +                                       __PAGE_KERNEL |= _PAGE_GLOBAL;
11881 +#endif
11882 +                               }
11883 +                               set_pmd(pmd, __pmd(__pe));
11884 +                               continue;
11885 +                       }
11886 +                       if (!pmd_present(*pmd))
11887 +                               pte_base = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
11888 +                       else
11889 +                               pte_base = (pte_t *) page_address(pmd_page(*pmd));
11890 +                       pte = pte_base;
11891 +                       for (k = 0; k < PTRS_PER_PTE; pte++, k++) {
11892 +                               vaddr = i*PGDIR_SIZE + j*PMD_SIZE + k*PAGE_SIZE;
11893 +                               if (end && (vaddr >= end))
11894 +                                       break;
11895 +                               if (vaddr < start)
11896 +                                       continue;
11897 +                               *pte = mk_pte_phys(vaddr-start, PAGE_KERNEL);
11898 +                       }
11899 +                       set_pmd(pmd, __pmd(_KERNPG_TABLE + __pa(pte_base)));
11900 +               }
11901 +       }
11902 +}
11903  
11904 +static void __init pagetable_init (void)
11905 +{
11906 +       unsigned long vaddr, end;
11907 +       pgd_t *pgd_base;
11908  #ifdef CONFIG_X86_PAE
11909         int i;
11910 -       /* Init entries of the first-level page table to the zero page */
11911 -       for (i = 0; i < PTRS_PER_PGD; i++)
11912 -               set_pgd(pgd_base + i, __pgd(__pa(empty_zero_page) | _PAGE_PRESENT));
11913  #endif
11914  
11915 -       /* Enable PSE if available */
11916 -       if (cpu_has_pse) {
11917 -               set_in_cr4(X86_CR4_PSE);
11918 -       }
11919 +       /*
11920 +        * This can be zero as well - no problem, in that case we exit
11921 +        * the loops anyway due to the PTRS_PER_* conditions.
11922 +        */
11923 +       end = (unsigned long)__va(max_low_pfn*PAGE_SIZE);
11924  
11925 -       /* Enable PGE if available */
11926 -       if (cpu_has_pge) {
11927 -               set_in_cr4(X86_CR4_PGE);
11928 -               __PAGE_KERNEL |= _PAGE_GLOBAL;
11929 +       pgd_base = swapper_pg_dir;
11930 +#ifdef CONFIG_X86_PAE
11931 +       /*
11932 +        * It causes too many problems if there's no proper pmd set up
11933 +        * for all 4 entries of the PGD - so we allocate all of them.
11934 +        * PAE systems will not miss this extra 4-8K anyway ...
11935 +        */
11936 +       for (i = 0; i < PTRS_PER_PGD; i++) {
11937 +               pmd_t *pmd = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
11938 +               set_pgd(pgd_base + i, __pgd(__pa(pmd) + 0x1));
11939         }
11940 +#endif
11941 +       /*
11942 +        * Set up lowmem-sized identity mappings at PAGE_OFFSET:
11943 +        */
11944 +       setup_identity_mappings(pgd_base, PAGE_OFFSET, end);
11945  
11946 -       kernel_physical_mapping_init(pgd_base);
11947 +       /*
11948 +        * Add flat-mode identity-mappings - SMP needs it when
11949 +        * starting up on an AP from real-mode. (In the non-PAE
11950 +        * case we already have these mappings through head.S.)
11951 +        * All user-space mappings are explicitly cleared after
11952 +        * SMP startup.
11953 +        */
11954 +#if CONFIG_SMP && CONFIG_X86_PAE
11955 +       setup_identity_mappings(pgd_base, 0, 16*1024*1024);
11956 +#endif
11957         remap_numa_kva();
11958  
11959         /*
11960 @@ -289,38 +266,64 @@ static void __init pagetable_init (void)
11961          * created - mappings will be set by set_fixmap():
11962          */
11963         vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
11964 -       page_table_range_init(vaddr, 0, pgd_base);
11965 +       fixrange_init(vaddr, 0, pgd_base);
11966  
11967 -       permanent_kmaps_init(pgd_base);
11968 +#if CONFIG_HIGHMEM
11969 +       {
11970 +               pgd_t *pgd;
11971 +               pmd_t *pmd;
11972 +               pte_t *pte;
11973  
11974 -#ifdef CONFIG_X86_PAE
11975 -       /*
11976 -        * Add low memory identity-mappings - SMP needs it when
11977 -        * starting up on an AP from real-mode. In the non-PAE
11978 -        * case we already have these mappings through head.S.
11979 -        * All user-space mappings are explicitly cleared after
11980 -        * SMP startup.
11981 -        */
11982 -       pgd_base[0] = pgd_base[USER_PTRS_PER_PGD];
11983 +               /*
11984 +                * Permanent kmaps:
11985 +                */
11986 +               vaddr = PKMAP_BASE;
11987 +               fixrange_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base);
11988 +
11989 +               pgd = swapper_pg_dir + pgd_index(vaddr);
11990 +               pmd = pmd_offset(pgd, vaddr);
11991 +               pte = pte_offset_kernel(pmd, vaddr);
11992 +               pkmap_page_table = pte;
11993 +       }
11994  #endif
11995  }
11996  
11997 -void zap_low_mappings (void)
11998 +/*
11999 + * Clear kernel pagetables in a PMD_SIZE-aligned range.
12000 + */
12001 +static void clear_mappings(pgd_t *pgd_base, unsigned long start, unsigned long end)
12002  {
12003 -       int i;
12004 +       unsigned long vaddr;
12005 +       pgd_t *pgd;
12006 +       pmd_t *pmd;
12007 +       int i, j;
12008 +
12009 +       pgd = pgd_base;
12010 +
12011 +       for (i = 0; i < PTRS_PER_PGD; pgd++, i++) {
12012 +               vaddr = i*PGDIR_SIZE;
12013 +               if (end && (vaddr >= end))
12014 +                       break;
12015 +               pmd = pmd_offset(pgd, 0);
12016 +               for (j = 0; j < PTRS_PER_PMD; pmd++, j++) {
12017 +                       vaddr = i*PGDIR_SIZE + j*PMD_SIZE;
12018 +                       if (end && (vaddr >= end))
12019 +                               break;
12020 +                       if (vaddr < start)
12021 +                               continue;
12022 +                       pmd_clear(pmd);
12023 +               }
12024 +       }
12025 +       flush_tlb_all();
12026 +}
12027 +
12028 +void __init zap_low_mappings(void)
12029 +{
12030 +       printk("zapping low mappings.\n");
12031         /*
12032          * Zap initial low-memory mappings.
12033 -        *
12034 -        * Note that "pgd_clear()" doesn't do it for
12035 -        * us, because pgd_clear() is a no-op on i386.
12036          */
12037 -       for (i = 0; i < USER_PTRS_PER_PGD; i++)
12038 -#ifdef CONFIG_X86_PAE
12039 -               set_pgd(swapper_pg_dir+i, __pgd(1 + __pa(empty_zero_page)));
12040 -#else
12041 -               set_pgd(swapper_pg_dir+i, __pgd(0));
12042 -#endif
12043 -       flush_tlb_all();
12044 +       clear_mappings(swapper_pg_dir, 0, 16*1024*1024);
12045  }
12046  
12047  #ifndef CONFIG_DISCONTIGMEM
12048 @@ -424,6 +427,7 @@ extern void set_max_mapnr_init(void);
12049  #endif /* !CONFIG_DISCONTIGMEM */
12050  
12051  static struct kcore_list kcore_mem, kcore_vmalloc; 
12052 +extern void fixup_sort_exception_table(void);
12053  
12054  void __init mem_init(void)
12055  {
12056 @@ -432,6 +436,8 @@ void __init mem_init(void)
12057         int tmp;
12058         int bad_ppro;
12059  
12060 +       fixup_sort_exception_table();
12061 +
12062  #ifndef CONFIG_DISCONTIGMEM
12063         if (!mem_map)
12064                 BUG();
12065 @@ -507,13 +513,18 @@ void __init mem_init(void)
12066  #ifndef CONFIG_SMP
12067         zap_low_mappings();
12068  #endif
12069 +       entry_trampoline_setup();
12070 +       default_ldt_page = virt_to_page(default_ldt);
12071 +       load_LDT(&init_mm.context);
12072  }
12073  
12074 -kmem_cache_t *pgd_cache;
12075 -kmem_cache_t *pmd_cache;
12076 +kmem_cache_t *pgd_cache, *pmd_cache, *kpmd_cache;
12077  
12078  void __init pgtable_cache_init(void)
12079  {
12080 +       void (*ctor)(void *, kmem_cache_t *, unsigned long);
12081 +       void (*dtor)(void *, kmem_cache_t *, unsigned long);
12082 +
12083         if (PTRS_PER_PMD > 1) {
12084                 pmd_cache = kmem_cache_create("pmd",
12085                                         PTRS_PER_PMD*sizeof(pmd_t),
12086 @@ -523,13 +534,36 @@ void __init pgtable_cache_init(void)
12087                                         NULL);
12088                 if (!pmd_cache)
12089                         panic("pgtable_cache_init(): cannot create pmd cache");
12090 +
12091 +               if (TASK_SIZE > PAGE_OFFSET) {
12092 +                       kpmd_cache = kmem_cache_create("kpmd",
12093 +                                       PTRS_PER_PMD*sizeof(pmd_t),
12094 +                                       0,
12095 +                                       SLAB_HWCACHE_ALIGN | SLAB_MUST_HWCACHE_ALIGN,
12096 +                                       kpmd_ctor,
12097 +                                       NULL);
12098 +                       if (!kpmd_cache)
12099 +                               panic("pgtable_cache_init(): "
12100 +                                               "cannot create kpmd cache");
12101 +               }
12102         }
12103 +
12104 +       if (PTRS_PER_PMD == 1 || TASK_SIZE <= PAGE_OFFSET)
12105 +               ctor = pgd_ctor;
12106 +       else
12107 +               ctor = NULL;
12108 +
12109 +       if (PTRS_PER_PMD == 1 && TASK_SIZE <= PAGE_OFFSET)
12110 +               dtor = pgd_dtor;
12111 +       else
12112 +               dtor = NULL;
12113 +
12114         pgd_cache = kmem_cache_create("pgd",
12115                                 PTRS_PER_PGD*sizeof(pgd_t),
12116                                 0,
12117                                 SLAB_HWCACHE_ALIGN | SLAB_MUST_HWCACHE_ALIGN,
12118 -                               pgd_ctor,
12119 -                               PTRS_PER_PMD == 1 ? pgd_dtor : NULL);
12120 +                               ctor,
12121 +                               dtor);
12122         if (!pgd_cache)
12123                 panic("pgtable_cache_init(): Cannot create pgd cache");
12124  }
12125 --- linux-2.6.0-test6/arch/i386/mm/ioremap.c    2003-06-14 12:18:04.000000000 -0700
12126 +++ 25/arch/i386/mm/ioremap.c   2003-10-05 00:33:23.000000000 -0700
12127 @@ -158,7 +158,7 @@ void * __ioremap(unsigned long phys_addr
12128                 return NULL;
12129         area->phys_addr = phys_addr;
12130         addr = area->addr;
12131 -       if (remap_area_pages(VMALLOC_VMADDR(addr), phys_addr, size, flags)) {
12132 +       if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) {
12133                 vunmap(addr);
12134                 return NULL;
12135         }
12136 --- linux-2.6.0-test6/arch/i386/mm/pgtable.c    2003-08-08 22:55:10.000000000 -0700
12137 +++ 25/arch/i386/mm/pgtable.c   2003-10-05 00:36:48.000000000 -0700
12138 @@ -21,6 +21,7 @@
12139  #include <asm/e820.h>
12140  #include <asm/tlb.h>
12141  #include <asm/tlbflush.h>
12142 +#include <asm/atomic_kmap.h>
12143  
12144  void show_mem(void)
12145  {
12146 @@ -157,11 +158,20 @@ void pmd_ctor(void *pmd, kmem_cache_t *c
12147         memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
12148  }
12149  
12150 +void kpmd_ctor(void *__pmd, kmem_cache_t *cache, unsigned long flags)
12151 +{
12152 +       pmd_t *kpmd, *pmd;
12153 +       kpmd = pmd_offset(&swapper_pg_dir[PTRS_PER_PGD-1],
12154 +                               (PTRS_PER_PMD - NR_SHARED_PMDS)*PMD_SIZE);
12155 +       pmd = (pmd_t *)__pmd + (PTRS_PER_PMD - NR_SHARED_PMDS);
12156 +
12157 +       memset(__pmd, 0, (PTRS_PER_PMD - NR_SHARED_PMDS)*sizeof(pmd_t));
12158 +       memcpy(pmd, kpmd, NR_SHARED_PMDS*sizeof(pmd_t));
12159 +}
12160 +
12161  /*
12162 - * List of all pgd's needed for non-PAE so it can invalidate entries
12163 - * in both cached and uncached pgd's; not needed for PAE since the
12164 - * kernel pmd is shared. If PAE were not to share the pmd a similar
12165 - * tactic would be needed. This is essentially codepath-based locking
12166 + * List of all pgd's needed so it can invalidate entries in both cached
12167 + * and uncached pgd's. This is essentially codepath-based locking
12168   * against pageattr.c; it is the unique case in which a valid change
12169   * of kernel pagetables can't be lazily synchronized by vmalloc faults.
12170   * vmalloc faults work because attached pagetables are never freed.
12171 @@ -170,30 +180,60 @@ void pmd_ctor(void *pmd, kmem_cache_t *c
12172   * could be used. The locking scheme was chosen on the basis of
12173   * manfred's recommendations and having no core impact whatsoever.
12174   * -- wli
12175 + *
12176 + * The entire issue goes away when XKVA is configured.
12177   */
12178  spinlock_t pgd_lock = SPIN_LOCK_UNLOCKED;
12179  LIST_HEAD(pgd_list);
12180  
12181 -void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused)
12182 +/*
12183 + * This is not that hard to figure out.
12184 + * (a) PTRS_PER_PMD == 1 means non-PAE.
12185 + * (b) PTRS_PER_PMD > 1 means PAE.
12186 + * (c) TASK_SIZE > PAGE_OFFSET means XKVA.
12187 + * (d) TASK_SIZE <= PAGE_OFFSET means non-XKVA.
12188 + *
12189 + * Do *NOT* back out the preconstruction like the patch I'm cleaning
12190 + * up after this very instant did, or at all, for that matter.
12191 + * This is never called when PTRS_PER_PMD > 1 && TASK_SIZE > PAGE_OFFSET.
12192 + * -- wli
12193 + */
12194 +void pgd_ctor(void *__pgd, kmem_cache_t *cache, unsigned long unused)
12195  {
12196 +       pgd_t *pgd = (pgd_t *)__pgd;
12197         unsigned long flags;
12198  
12199 -       if (PTRS_PER_PMD == 1)
12200 -               spin_lock_irqsave(&pgd_lock, flags);
12201 +       if (PTRS_PER_PMD == 1) {
12202 +               if (TASK_SIZE <= PAGE_OFFSET)
12203 +                       spin_lock_irqsave(&pgd_lock, flags);
12204 +               else
12205 +                       memcpy(&pgd[PTRS_PER_PGD - NR_SHARED_PMDS],
12206 +                               &swapper_pg_dir[PTRS_PER_PGD - NR_SHARED_PMDS],
12207 +                               NR_SHARED_PMDS * sizeof(pgd_t));
12208 +       }
12209  
12210 -       memcpy((pgd_t *)pgd + USER_PTRS_PER_PGD,
12211 -                       swapper_pg_dir + USER_PTRS_PER_PGD,
12212 -                       (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
12213 +       if (TASK_SIZE <= PAGE_OFFSET)
12214 +               memcpy(pgd + USER_PTRS_PER_PGD,
12215 +                       swapper_pg_dir + USER_PTRS_PER_PGD,
12216 +                       (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
12217  
12218         if (PTRS_PER_PMD > 1)
12219                 return;
12220  
12221 -       list_add(&virt_to_page(pgd)->lru, &pgd_list);
12222 -       spin_unlock_irqrestore(&pgd_lock, flags);
12223 -       memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));
12224 +       if (TASK_SIZE > PAGE_OFFSET)
12225 +               memset(pgd, 0, (PTRS_PER_PGD - NR_SHARED_PMDS)*sizeof(pgd_t));
12226 +       else {
12227 +               list_add(&virt_to_page(pgd)->lru, &pgd_list);
12228 +               spin_unlock_irqrestore(&pgd_lock, flags);
12229 +               memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));
12230 +       }
12231  }
12232  
12233 -/* never called when PTRS_PER_PMD > 1 */
12234 +/*
12235 + * Never called when PTRS_PER_PMD > 1 || TASK_SIZE > PAGE_OFFSET
12236 + * for with PAE we would list_del() multiple times, and for non-PAE
12237 + * with XKVA all the AGP pgd shootdown code is unnecessary.
12238 + */
12239  void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long unused)
12240  {
12241         unsigned long flags; /* can be called from interrupt context */
12242 @@ -203,6 +243,12 @@ void pgd_dtor(void *pgd, kmem_cache_t *c
12243         spin_unlock_irqrestore(&pgd_lock, flags);
12244  }
12245  
12246 +/*
12247 + * See the comments above pgd_ctor() wrt. preconstruction.
12248 + * Do *NOT* memcpy() here. If you do, you back out important
12249 + * anti- cache pollution code.
12250 + *
12251 + */
12252  pgd_t *pgd_alloc(struct mm_struct *mm)
12253  {
12254         int i;
12255 @@ -211,15 +257,33 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
12256         if (PTRS_PER_PMD == 1 || !pgd)
12257                 return pgd;
12258  
12259 +       /*
12260 +        * In the 4G userspace case alias the top 16 MB virtual
12261 +        * memory range into the user mappings as well (these
12262 +        * include the trampoline and CPU data structures).
12263 +        */
12264         for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
12265 -               pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
12266 +               kmem_cache_t *cache;
12267 +               pmd_t *pmd;
12268 +
12269 +               if (TASK_SIZE > PAGE_OFFSET && i == USER_PTRS_PER_PGD - 1)
12270 +                       cache = kpmd_cache;
12271 +               else
12272 +                       cache = pmd_cache;
12273 +
12274 +               pmd = kmem_cache_alloc(cache, GFP_KERNEL);
12275                 if (!pmd)
12276                         goto out_oom;
12277                 set_pgd(&pgd[i], __pgd(1 + __pa((u64)((u32)pmd))));
12278         }
12279 -       return pgd;
12280  
12281 +       return pgd;
12282  out_oom:
12283 +       /*
12284 +        * we don't have to handle the kpmd_cache here, since it's the
12285 +        * last allocation, and has either nothing to free or when it
12286 +        * succeeds the whole operation succeeds.
12287 +        */
12288         for (i--; i >= 0; i--)
12289                 kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
12290         kmem_cache_free(pgd_cache, pgd);
12291 @@ -230,10 +294,29 @@ void pgd_free(pgd_t *pgd)
12292  {
12293         int i;
12294  
12295 -       /* in the PAE case user pgd entries are overwritten before usage */
12296 -       if (PTRS_PER_PMD > 1)
12297 -               for (i = 0; i < USER_PTRS_PER_PGD; ++i)
12298 -                       kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
12299         /* in the non-PAE case, clear_page_tables() clears user pgd entries */
12300 +       if (PTRS_PER_PMD == 1)
12301 +               goto out_free;
12302 +
12303 +       /* in the PAE case user pgd entries are overwritten before usage */
12304 +       for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
12305 +               kmem_cache_t *cache;
12306 +               pmd_t *pmd = __va(pgd_val(pgd[i]) - 1);
12307 +
12308 +               /*
12309 +                * only userspace pmd's are cleared for us
12310 +                * by mm/memory.c; it's a slab cache invariant
12311 +                * that we must separate the kernel pmd slab
12312 +                * all times, else we'll have bad pmd's.
12313 +                */
12314 +               if (TASK_SIZE > PAGE_OFFSET && i == USER_PTRS_PER_PGD - 1)
12315 +                       cache = kpmd_cache;
12316 +               else
12317 +                       cache = pmd_cache;
12318 +
12319 +               kmem_cache_free(cache, pmd);
12320 +       }
12321 +out_free:
12322         kmem_cache_free(pgd_cache, pgd);
12323  }
12324 +
12325 --- linux-2.6.0-test6/arch/i386/pci/acpi.c      2003-08-22 19:23:40.000000000 -0700
12326 +++ 25/arch/i386/pci/acpi.c     2003-10-05 00:34:16.000000000 -0700
12327 @@ -15,10 +15,11 @@ struct pci_bus * __devinit pci_acpi_scan
12328  
12329  static int __init pci_acpi_init(void)
12330  {
12331 +       extern int acpi_disabled;
12332         if (pcibios_scanned)
12333                 return 0;
12334  
12335 -       if (!(pci_probe & PCI_NO_ACPI_ROUTING)) {
12336 +       if (!(pci_probe & PCI_NO_ACPI_ROUTING) && !acpi_disabled) {
12337                 if (!acpi_pci_irq_init()) {
12338                         printk(KERN_INFO "PCI: Using ACPI for IRQ routing\n");
12339                         printk(KERN_INFO "PCI: if you experience problems, try using option 'pci=noacpi' or even 'acpi=off'\n");
12340 --- linux-2.6.0-test6/arch/i386/pci/irq.c       2003-08-08 22:55:10.000000000 -0700
12341 +++ 25/arch/i386/pci/irq.c      2003-10-05 00:36:20.000000000 -0700
12342 @@ -680,8 +680,10 @@ static int pcibios_lookup_irq(struct pci
12343                         if ( dev2->irq && dev2->irq != irq && \
12344                         (!(pci_probe & PCI_USE_PIRQ_MASK) || \
12345                         ((1 << dev2->irq) & mask)) ) {
12346 +#ifndef CONFIG_PCI_USE_VECTOR
12347                                 printk(KERN_INFO "IRQ routing conflict for %s, have irq %d, want irq %d\n",
12348                                        pci_name(dev2), dev2->irq, irq);
12349 +#endif
12350                                 continue;
12351                         }
12352                         dev2->irq = irq;
12353 @@ -745,6 +747,10 @@ static void __init pcibios_fixup_irqs(vo
12354                                                         bridge->bus->number, PCI_SLOT(bridge->devfn), pin, irq);
12355                                 }
12356                                 if (irq >= 0) {
12357 +                                       if (use_pci_vector() &&
12358 +                                               !platform_legacy_irq(irq))
12359 +                                               irq = IO_APIC_VECTOR(irq);
12360 +
12361                                         printk(KERN_INFO "PCI->APIC IRQ transform: (B%d,I%d,P%d) -> %d\n",
12362                                                 dev->bus->number, PCI_SLOT(dev->devfn), pin, irq);
12363                                         dev->irq = irq;
12364 --- linux-2.6.0-test6/arch/ia64/ia32/ia32_ioctl.c       2003-09-08 13:58:56.000000000 -0700
12365 +++ 25/arch/ia64/ia32/ia32_ioctl.c      2003-10-05 00:34:44.000000000 -0700
12366 @@ -26,43 +26,11 @@
12367         _ret;                                           \
12368  })
12369  
12370 -#define P(i)   ((void *)(unsigned long)(i))
12371 -
12372  asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
12373  
12374  #define CODE
12375  #include "compat_ioctl.c"
12376  
12377 -#define        VFAT_IOCTL_READDIR_BOTH32       _IOR('r', 1, struct linux32_dirent[2])
12378 -#define        VFAT_IOCTL_READDIR_SHORT32      _IOR('r', 2, struct linux32_dirent[2])
12379 -
12380 -static long
12381 -put_dirent32 (struct dirent *d, struct linux32_dirent *d32)
12382 -{
12383 -       size_t namelen = strlen(d->d_name);
12384 -
12385 -       return (put_user(d->d_ino, &d32->d_ino)
12386 -               || put_user(d->d_off, &d32->d_off)
12387 -               || put_user(d->d_reclen, &d32->d_reclen)
12388 -               || copy_to_user(d32->d_name, d->d_name, namelen + 1));
12389 -}
12390 -
12391 -static int vfat_ioctl32(unsigned fd, unsigned cmd,  void *ptr) 
12392 -{
12393 -       int ret;
12394 -       mm_segment_t oldfs = get_fs();
12395 -       struct dirent d[2]; 
12396 -
12397 -       set_fs(KERNEL_DS);
12398 -       ret = sys_ioctl(fd,cmd,(unsigned long)&d); 
12399 -       set_fs(oldfs); 
12400 -       if (!ret) { 
12401 -               ret |= put_dirent32(&d[0], (struct linux32_dirent *)ptr); 
12402 -               ret |= put_dirent32(&d[1], ((struct linux32_dirent *)ptr) + 1); 
12403 -       }
12404 -       return ret; 
12405 -} 
12406 -
12407  typedef int (* ioctl32_handler_t)(unsigned int, unsigned int, unsigned long, struct file *);
12408  
12409  #define COMPATIBLE_IOCTL(cmd)          HANDLE_IOCTL((cmd),sys_ioctl)
12410 @@ -73,8 +41,6 @@ typedef int (* ioctl32_handler_t)(unsign
12411         };
12412  
12413  IOCTL_TABLE_START
12414 -HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32)
12415 -HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32, vfat_ioctl32)
12416  #define DECLARES
12417  #include "compat_ioctl.c"
12418  #include <linux/compat_ioctl.h>
12419 --- linux-2.6.0-test6/arch/ia64/ia32/ia32priv.h 2003-09-27 18:57:43.000000000 -0700
12420 +++ 25/arch/ia64/ia32/ia32priv.h        2003-10-05 00:34:44.000000000 -0700
12421 @@ -249,13 +249,6 @@ typedef struct siginfo32 {
12422         } _sifields;
12423  } siginfo_t32;
12424  
12425 -struct linux32_dirent {
12426 -       u32     d_ino;
12427 -       u32     d_off;
12428 -       u16     d_reclen;
12429 -       char    d_name[256];
12430 -};
12431 -
12432  struct old_linux32_dirent {
12433         u32     d_ino;
12434         u32     d_offset;
12435 --- linux-2.6.0-test6/arch/ia64/ia32/sys_ia32.c 2003-09-27 18:57:43.000000000 -0700
12436 +++ 25/arch/ia64/ia32/sys_ia32.c        2003-10-05 00:34:44.000000000 -0700
12437 @@ -707,8 +707,8 @@ sys32_settimeofday (struct compat_timeva
12438  }
12439  
12440  struct getdents32_callback {
12441 -       struct linux32_dirent * current_dir;
12442 -       struct linux32_dirent * previous;
12443 +       struct compat_dirent * current_dir;
12444 +       struct compat_dirent * previous;
12445         int count;
12446         int error;
12447  };
12448 @@ -722,7 +722,7 @@ static int
12449  filldir32 (void *__buf, const char *name, int namlen, loff_t offset, ino_t ino,
12450            unsigned int d_type)
12451  {
12452 -       struct linux32_dirent * dirent;
12453 +       struct compat_dirent * dirent;
12454         struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
12455         int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1, 4);
12456  
12457 @@ -748,10 +748,10 @@ filldir32 (void *__buf, const char *name
12458  }
12459  
12460  asmlinkage long
12461 -sys32_getdents (unsigned int fd, struct linux32_dirent *dirent, unsigned int count)
12462 +sys32_getdents (unsigned int fd, struct compat_dirent *dirent, unsigned int count)
12463  {
12464         struct file * file;
12465 -       struct linux32_dirent * lastdirent;
12466 +       struct compat_dirent * lastdirent;
12467         struct getdents32_callback buf;
12468         int error;
12469  
12470 --- linux-2.6.0-test6/arch/ia64/kernel/acpi.c   2003-09-27 18:57:43.000000000 -0700
12471 +++ 25/arch/ia64/kernel/acpi.c  2003-10-05 00:34:41.000000000 -0700
12472 @@ -41,6 +41,7 @@
12473  #include <linux/irq.h>
12474  #include <linux/acpi.h>
12475  #include <linux/efi.h>
12476 +#include <linux/mmzone.h>
12477  #include <asm/io.h>
12478  #include <asm/iosapic.h>
12479  #include <asm/machvec.h>
12480 @@ -56,7 +57,7 @@ void (*pm_power_off) (void);
12481  
12482  unsigned char acpi_kbd_controller_present = 1;
12483  
12484 -int acpi_disabled __initdata;  /* XXX this shouldn't be needed---we can't boot without ACPI! */
12485 +int acpi_disabled;     /* XXX this shouldn't be needed---we can't boot without ACPI! */
12486  
12487  const char *
12488  acpi_get_sysname (void)
12489 @@ -341,7 +342,7 @@ static u32 __initdata pxm_flag[PXM_FLAG_
12490  #define pxm_bit_test(bit)      (test_bit(bit,(void *)pxm_flag))
12491  /* maps to convert between proximity domain and logical node ID */
12492  int __initdata pxm_to_nid_map[MAX_PXM_DOMAINS];
12493 -int __initdata nid_to_pxm_map[NR_NODES];
12494 +int __initdata nid_to_pxm_map[MAX_NUMNODES];
12495  static struct acpi_table_slit __initdata *slit_table;
12496  
12497  /*
12498 --- linux-2.6.0-test6/arch/ia64/kernel/perfmon.c        2003-09-27 18:57:43.000000000 -0700
12499 +++ 25/arch/ia64/kernel/perfmon.c       2003-10-05 00:34:03.000000000 -0700
12500 @@ -2165,6 +2165,7 @@ pfm_alloc_fd(struct file **cfile)
12501  
12502         d_add(file->f_dentry, inode);
12503         file->f_vfsmnt = mntget(pfmfs_mnt);
12504 +       file->f_mapping = inode->i_mapping;
12505  
12506         file->f_op    = &pfm_file_ops;
12507         file->f_mode  = FMODE_READ;
12508 --- linux-2.6.0-test6/arch/ia64/kernel/unaligned.c      2003-08-22 19:23:40.000000000 -0700
12509 +++ 25/arch/ia64/kernel/unaligned.c     2003-10-05 00:36:18.000000000 -0700
12510 @@ -1347,7 +1347,7 @@ ia64_handle_unaligned (unsigned long ifa
12511                          * be holding locks...
12512                          */
12513                         if (user_mode(regs))
12514 -                               tty_write_message(current->tty, buf);
12515 +                               tty_write_message(process_tty(current), buf);
12516                         buf[len-1] = '\0';      /* drop '\r' */
12517                         printk(KERN_WARNING "%s", buf); /* watch for command names containing %s */
12518                 }
12519 --- linux-2.6.0-test6/arch/ia64/mm/discontig.c  2003-09-27 18:57:43.000000000 -0700
12520 +++ 25/arch/ia64/mm/discontig.c 2003-10-05 00:34:41.000000000 -0700
12521 @@ -14,7 +14,6 @@
12522  #include <linux/mm.h>
12523  #include <linux/swap.h>
12524  #include <linux/bootmem.h>
12525 -#include <linux/mmzone.h>
12526  #include <linux/acpi.h>
12527  #include <linux/efi.h>
12528  #include <asm/pgalloc.h>
12529 @@ -26,10 +25,10 @@
12530   */
12531  #define GRANULEROUNDUP(n) (((n)+IA64_GRANULE_SIZE-1) & ~(IA64_GRANULE_SIZE-1))
12532  
12533 -static struct ia64_node_data   *node_data[NR_NODES];
12534 -static long                    boot_pg_data[8*NR_NODES+sizeof(pg_data_t)]  __initdata;
12535 -static pg_data_t               *pg_data_ptr[NR_NODES] __initdata;
12536 -static bootmem_data_t          bdata[NR_NODES][NR_BANKS_PER_NODE+1] __initdata;
12537 +static struct ia64_node_data   *node_data[MAX_NUMNODES];
12538 +static long                    boot_pg_data[8*MAX_NUMNODES+sizeof(pg_data_t)]  __initdata;
12539 +static pg_data_t               *pg_data_ptr[MAX_NUMNODES] __initdata;
12540 +static bootmem_data_t          bdata[MAX_NUMNODES][NR_BANKS_PER_NODE+1] __initdata;
12541  /*
12542   * Return the compact node number of this cpu. Used prior to
12543   * setting up the cpu_data area.
12544 --- linux-2.6.0-test6/arch/ia64/mm/numa.c       2003-09-08 13:58:56.000000000 -0700
12545 +++ 25/arch/ia64/mm/numa.c      2003-10-05 00:34:41.000000000 -0700
12546 @@ -15,7 +15,6 @@
12547  #include <linux/mm.h>
12548  #include <linux/init.h>
12549  #include <linux/bootmem.h>
12550 -#include <linux/mmzone.h>
12551  #include <asm/numa.h>
12552  
12553  /*
12554 @@ -29,7 +28,7 @@ struct node_cpuid_s node_cpuid[NR_CPUS];
12555   * This is a matrix with "distances" between nodes, they should be
12556   * proportional to the memory access latency ratios.
12557   */
12558 -u8 numa_slit[NR_NODES * NR_NODES];
12559 +u8 numa_slit[MAX_NUMNODES * MAX_NUMNODES];
12560  
12561  /* Identify which cnode a physical address resides on */
12562  int
12563 --- linux-2.6.0-test6/arch/ia64/sn/io/sn2/module.c      2003-07-10 18:50:30.000000000 -0700
12564 +++ 25/arch/ia64/sn/io/sn2/module.c     2003-10-05 00:33:23.000000000 -0700
12565 @@ -166,7 +166,6 @@ int module_probe_snum(module_t *m, nasid
12566  {
12567      lboard_t          *board;
12568      klmod_serial_num_t *comp;
12569 -    char * bcopy(const char * src, char * dest, int count);
12570      char serial_number[16];
12571  
12572      /*
12573 @@ -215,9 +214,9 @@ int module_probe_snum(module_t *m, nasid
12574  #endif
12575  
12576             if (comp->snum.snum_str[0] != '\0') {
12577 -               bcopy(comp->snum.snum_str,
12578 -                     m->sys_snum,
12579 -                     MAX_SERIAL_NUM_SIZE);
12580 +               memcpy(m->sys_snum,
12581 +                      comp->snum.snum_str,
12582 +                      MAX_SERIAL_NUM_SIZE);
12583                 m->sys_snum_valid = 1;
12584             }
12585      }
12586 --- linux-2.6.0-test6/arch/ia64/sn/io/sn2/pic.c 2003-09-27 18:57:43.000000000 -0700
12587 +++ 25/arch/ia64/sn/io/sn2/pic.c        2003-10-05 00:33:23.000000000 -0700
12588 @@ -29,8 +29,6 @@
12589  #include <asm/sn/io.h>
12590  #include <asm/sn/sn_private.h>
12591  
12592 -extern char *bcopy(const char * src, char * dest, int count);
12593 -
12594  
12595  #define PCI_BUS_NO_1 1
12596  
12597 @@ -51,7 +49,7 @@ pic_bus1_inventory_dup(vertex_hdl_t conn
12598                                 (arbitrary_info_t *)&pinv) == GRAPH_SUCCESS)
12599   {
12600                 NEW(peer_pinv);
12601 -               bcopy((const char *)pinv, (char *)peer_pinv, sizeof(inventory_t));
12602 +               memcpy(peer_pinv, pinv, sizeof(inventory_t));
12603                 if (hwgraph_info_add_LBL(peer_conn_v, INFO_LBL_INVENT,
12604                             (arbitrary_info_t)peer_pinv) != GRAPH_SUCCESS) {
12605                         DEL(peer_pinv);
12606 --- linux-2.6.0-test6/arch/m68k/atari/stram.c   2003-09-08 13:58:56.000000000 -0700
12607 +++ 25/arch/m68k/atari/stram.c  2003-10-05 00:33:23.000000000 -0700
12608 @@ -22,6 +22,7 @@
12609  #include <linux/shm.h>
12610  #include <linux/bootmem.h>
12611  #include <linux/mount.h>
12612 +#include <linux/blkdev.h>
12613  
12614  #include <asm/setup.h>
12615  #include <asm/machdep.h>
12616 --- linux-2.6.0-test6/arch/m68k/Kconfig 2003-09-27 18:57:43.000000000 -0700
12617 +++ 25/arch/m68k/Kconfig        2003-10-05 00:33:23.000000000 -0700
12618 @@ -87,7 +87,7 @@ config ATARI
12619  
12620  config HADES
12621         bool "Hades support"
12622 -       depends on ATARI
12623 +       depends on ATARI && BROKEN
12624         help
12625           This option enables support for the Hades Atari clone. If you plan
12626           to use this kernel on a Hades, say Y here; otherwise say N.
12627 @@ -361,7 +361,7 @@ config AMIGA_PCMCIA
12628  
12629  config STRAM_SWAP
12630         bool "Support for ST-RAM as swap space"
12631 -       depends on ATARI
12632 +       depends on ATARI && BROKEN
12633         ---help---
12634           Some Atari 68k macines (including the 520STF and 1020STE) divide
12635           their addressible memory into ST and TT sections.  The TT section
12636 @@ -961,7 +961,7 @@ config MVME147_SCC
12637  
12638  config SERIAL167
12639         bool "CD2401 support for MVME166/7 serial ports"
12640 -       depends on MVME16x
12641 +       depends on MVME16x && BROKEN
12642         help
12643           This is the driver for the serial ports on the Motorola MVME166,
12644           167, and 172 boards.  Everyone using one of these boards should say
12645 --- linux-2.6.0-test6/arch/m68k/kernel/time.c   2003-07-13 21:44:34.000000000 -0700
12646 +++ 25/arch/m68k/kernel/time.c  2003-10-05 00:33:23.000000000 -0700
12647 @@ -171,3 +171,12 @@ int do_settimeofday(struct timespec *tv)
12648         write_sequnlock_irq(&xtime_lock);
12649         return 0;
12650  }
12651 +
12652 +/*
12653 + * Scheduler clock - returns current time in ns units.
12654 + */
12655 +unsigned long long sched_clock(void)
12656 +{
12657 +       return (unsigned long long)jiffies*(1000000000/HZ);
12658 +}
12659 +
12660 --- linux-2.6.0-test6/arch/m68k/Makefile        2003-07-27 12:14:38.000000000 -0700
12661 +++ 25/arch/m68k/Makefile       2003-10-05 00:33:23.000000000 -0700
12662 @@ -76,6 +76,8 @@ core-$(CONFIG_M68040)         += arch/m68k/fpsp
12663  core-$(CONFIG_M68060)          += arch/m68k/ifpsp060/
12664  core-$(CONFIG_M68KFPU_EMU)     += arch/m68k/math-emu/
12665  
12666 +all:   zImage
12667 +
12668  lilo:  vmlinux
12669         if [ -f $(INSTALL_PATH)/vmlinux ]; then mv -f $(INSTALL_PATH)/vmlinux $(INSTALL_PATH)/vmlinux.old; fi
12670         if [ -f $(INSTALL_PATH)/System.map ]; then mv -f $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
12671 --- linux-2.6.0-test6/arch/m68k/q40/q40ints.c   2003-07-27 12:14:38.000000000 -0700
12672 +++ 25/arch/m68k/q40/q40ints.c  2003-10-05 00:33:23.000000000 -0700
12673 @@ -200,7 +200,9 @@ void q40_free_irq(unsigned int irq, void
12674  
12675  irqreturn_t q40_process_int (int level, struct pt_regs *fp)
12676  {
12677 -  printk("unexpected interrupt %x\n",level);
12678 +  printk("unexpected interrupt vec=%x, pc=%lx, d0=%lx, d0_orig=%lx, d1=%lx, d2=%lx\n",
12679 +          level, fp->pc, fp->d0, fp->orig_d0, fp->d1, fp->d2);
12680 +  printk("\tIIRQ_REG = %x, EIRQ_REG = %x\n",master_inb(IIRQ_REG),master_inb(EIRQ_REG));
12681    return IRQ_HANDLED;
12682  }
12683  
12684 @@ -378,7 +380,7 @@ irqreturn_t q40_irq2_handler (int vec, v
12685                                   /*printk("reenabling irq %d\n",irq); */
12686  #endif
12687                           }
12688 -// used to do 'goto repeat;' her, this delayed bh processing too long
12689 +// used to do 'goto repeat;' here, this delayed bh processing too long
12690                           return IRQ_HANDLED;
12691                   }
12692           }
12693 @@ -387,6 +389,7 @@ irqreturn_t q40_irq2_handler (int vec, v
12694    } 
12695   iirq:
12696    mir=master_inb(IIRQ_REG);
12697 +  /* should test whether keyboard irq is really enabled, doing it in defhand */
12698    if (mir&Q40_IRQ_KEYB_MASK) {
12699           irq_tab[Q40_IRQ_KEYBOARD].count++;
12700           irq_tab[Q40_IRQ_KEYBOARD].handler(Q40_IRQ_KEYBOARD,irq_tab[Q40_IRQ_KEYBOARD].dev_id,fp);
12701 @@ -413,7 +416,9 @@ int show_q40_interrupts (struct seq_file
12702  
12703  static irqreturn_t q40_defhand (int irq, void *dev_id, struct pt_regs *fp)
12704  {
12705 -       printk ("Unknown q40 interrupt 0x%02x\n", irq);
12706 +        if (irq!=Q40_IRQ_KEYBOARD)
12707 +            printk ("Unknown q40 interrupt %d\n", irq);
12708 +       else master_outb(-1,KEYBOARD_UNLOCK_REG);
12709         return IRQ_NONE;
12710  }
12711  static irqreturn_t sys_default_handler(int lev, void *dev_id, struct pt_regs *regs)
12712 --- linux-2.6.0-test6/arch/m68k/sun3/config.c   2003-06-14 12:18:25.000000000 -0700
12713 +++ 25/arch/m68k/sun3/config.c  2003-10-05 00:33:23.000000000 -0700
12714 @@ -129,7 +129,7 @@ void __init sun3_bootmem_alloc(unsigned 
12715         high_memory = (void *)memory_end;
12716         availmem = memory_start;
12717  
12718 -       availmem += init_bootmem(start_page, num_pages);
12719 +       availmem += init_bootmem_node(NODE_DATA(0), start_page, 0, num_pages);
12720         availmem = (availmem + (PAGE_SIZE-1)) & PAGE_MASK;
12721  
12722         free_bootmem(__pa(availmem), memory_end - (availmem));
12723 --- linux-2.6.0-test6/arch/mips/mm/ioremap.c    2003-08-08 22:55:11.000000000 -0700
12724 +++ 25/arch/mips/mm/ioremap.c   2003-10-05 00:33:23.000000000 -0700
12725 @@ -162,7 +162,7 @@ void * __ioremap(phys_t phys_addr, phys_
12726         if (!area)
12727                 return NULL;
12728         addr = area->addr;
12729 -       if (remap_area_pages(VMALLOC_VMADDR(addr), phys_addr, size, flags)) {
12730 +       if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) {
12731                 vunmap(addr);
12732                 return NULL;
12733         }
12734 --- linux-2.6.0-test6/arch/parisc/Kconfig       2003-09-27 18:57:43.000000000 -0700
12735 +++ 25/arch/parisc/Kconfig      2003-10-05 00:33:23.000000000 -0700
12736 @@ -150,6 +150,7 @@ config COMPAT
12737  
12738  config HPUX
12739         bool "Support for HP-UX binaries"
12740 +       depends on !PARISC64
12741  
12742  config NR_CPUS
12743         int "Maximum number of CPUs (2-32)"
12744 @@ -190,6 +191,8 @@ source drivers/message/fusion/Kconfig
12745  
12746  #source drivers/message/i2o/Kconfig
12747  
12748 +source "net/Kconfig"
12749 +
12750  #source "drivers/isdn/Kconfig"
12751  
12752  #source "drivers/telephony/Kconfig"
12753 --- linux-2.6.0-test6/arch/parisc/kernel/asm-offsets.c  2003-06-14 12:17:58.000000000 -0700
12754 +++ 25/arch/parisc/kernel/asm-offsets.c 2003-10-05 00:33:23.000000000 -0700
12755 @@ -8,6 +8,7 @@
12756  #include <linux/sched.h>
12757  #include <linux/thread_info.h>
12758  #include <linux/version.h>
12759 +#include <linux/ptrace.h>
12760  
12761  #include <asm/ptrace.h>
12762  #include <asm/processor.h>
12763 @@ -249,5 +250,8 @@ int main(void)
12764         DEFINE(DTLB_OFF_COUNT, offsetof(struct pdc_cache_info, dt_off_count));
12765         DEFINE(DTLB_LOOP, offsetof(struct pdc_cache_info, dt_loop));
12766         BLANK();
12767 +       DEFINE(PA_BLOCKSTEP_BIT, 31-PT_BLOCKSTEP_BIT);
12768 +       DEFINE(PA_SINGLESTEP_BIT, 31-PT_SINGLESTEP_BIT);
12769 +       BLANK();
12770         return 0;
12771  }
12772 --- linux-2.6.0-test6/arch/parisc/kernel/binfmt_elf32.c 2003-06-14 12:18:07.000000000 -0700
12773 +++ 25/arch/parisc/kernel/binfmt_elf32.c        2003-10-05 00:33:23.000000000 -0700
12774 @@ -88,7 +88,9 @@ struct elf_prpsinfo32
12775   */
12776  
12777  #define SET_PERSONALITY(ex, ibcs2) \
12778 -       current->personality = PER_LINUX_32BIT
12779 +       current->personality = PER_LINUX32; \
12780 +       current->thread.map_base = DEFAULT_MAP_BASE32; \
12781 +       current->thread.task_size = DEFAULT_TASK_SIZE32 \
12782  
12783  #define jiffies_to_timeval jiffies_to_compat_timeval 
12784  static __inline__ void
12785 @@ -99,3 +101,25 @@ jiffies_to_compat_timeval(unsigned long 
12786  }
12787  
12788  #include "../../../fs/binfmt_elf.c"
12789 +
12790 +/* Set up a separate execution domain for ELF32 binaries running
12791 + * on an ELF64 kernel */
12792 +
12793 +static struct exec_domain parisc32_exec_domain = { 
12794 +       .name = "Linux/ELF32",
12795 +       .pers_low = PER_LINUX32,
12796 +       .pers_high = PER_LINUX32,
12797 +};      
12798 +
12799 +static int __init parisc32_exec_init(void)
12800 +{
12801 +       /* steal the identity signal mappings from the default domain */
12802 +       parisc32_exec_domain.signal_map = default_exec_domain.signal_map;
12803 +       parisc32_exec_domain.signal_invmap = default_exec_domain.signal_invmap;
12804 +
12805 +       register_exec_domain(&parisc32_exec_domain);
12806 +
12807 +       return 0;
12808 +}
12809 +
12810 +__initcall(parisc32_exec_init);
12811 --- linux-2.6.0-test6/arch/parisc/kernel/drivers.c      2003-09-27 18:57:43.000000000 -0700
12812 +++ 25/arch/parisc/kernel/drivers.c     2003-10-05 00:33:23.000000000 -0700
12813 @@ -28,6 +28,7 @@
12814  
12815  /* See comments in include/asm-parisc/pci.h */
12816  struct hppa_dma_ops *hppa_dma_ops;
12817 +EXPORT_SYMBOL(hppa_dma_ops);
12818  
12819  static struct parisc_device root;
12820  
12821 @@ -155,6 +156,7 @@ int register_parisc_driver(struct parisc
12822  
12823         return driver_register(&driver->drv);
12824  }
12825 +EXPORT_SYMBOL(register_parisc_driver);
12826  
12827  /**
12828   * count_parisc_driver - count # of devices this driver would match
12829 @@ -187,6 +189,7 @@ int unregister_parisc_driver(struct pari
12830         driver_unregister(&driver->drv);
12831         return 0;
12832  }
12833 +EXPORT_SYMBOL(unregister_parisc_driver);
12834  
12835  static struct parisc_device *find_device_by_addr(unsigned long hpa)
12836  {
12837 @@ -257,7 +260,7 @@ char *print_pa_hwpath(struct parisc_devi
12838         path.mod = dev->hw_path;
12839         return print_hwpath(&path, output);
12840  }
12841 -
12842 +EXPORT_SYMBOL(print_pa_hwpath);
12843  
12844  #if defined(CONFIG_PCI) || defined(CONFIG_ISA)
12845  /**
12846 @@ -289,6 +292,7 @@ void get_pci_node_path(struct pci_dev *d
12847                 padev = padev->parent;
12848         }
12849  }
12850 +EXPORT_SYMBOL(get_pci_node_path);
12851  
12852  /**
12853   * print_pci_hwpath - Returns hardware path for PCI devices
12854 @@ -306,6 +310,8 @@ char *print_pci_hwpath(struct pci_dev *d
12855         get_pci_node_path(dev, &path);
12856         return print_hwpath(&path, output);
12857  }
12858 +EXPORT_SYMBOL(print_pci_hwpath);
12859 +
12860  #endif /* defined(CONFIG_PCI) || defined(CONFIG_ISA) */
12861  
12862  
12863 --- linux-2.6.0-test6/arch/parisc/kernel/entry.S        2003-06-16 22:32:20.000000000 -0700
12864 +++ 25/arch/parisc/kernel/entry.S       2003-10-05 00:33:23.000000000 -0700
12865 @@ -2225,18 +2225,23 @@ syscall_exit:
12866         LDREG     TI_TASK(%r1),%r1
12867         STREG     %r28,TASK_PT_GR28(%r1)
12868  
12869 -       /* Save other hpux returns if personality is PER_HPUX */
12870 +#ifdef CONFIG_HPUX
12871  
12872  /* <linux/personality.h> cannot be easily included */
12873  #define PER_HPUX 0x10
12874         LDREG     TASK_PERSONALITY(%r1),%r19
12875 -#warning the ldo+CMPIB could probably be done better but 0x10 i soutside of range of CMPIB
12876 +
12877 +       /* We can't use "CMPIB<> PER_HPUX" since "im5" field is sign extended */
12878         ldo       -PER_HPUX(%r19), %r19
12879         CMPIB<>,n 0,%r19,1f
12880 +
12881 +       /* Save other hpux returns if personality is PER_HPUX */
12882         STREG     %r22,TASK_PT_GR22(%r1)
12883         STREG     %r29,TASK_PT_GR29(%r1)
12884  1:
12885  
12886 +#endif /* CONFIG_HPUX */
12887 +
12888         /* Seems to me that dp could be wrong here, if the syscall involved
12889          * calling a module, and nothing got round to restoring dp on return.
12890          */
12891 @@ -2315,18 +2320,16 @@ syscall_restore:
12892         depi    3,31,2,%r31                        /* ensure return to user mode. */
12893  
12894  #ifdef __LP64__
12895 -       /* Since we are returning to a 32 bit user process, we always
12896 -        * clear the W bit. This means that the be (and mtsp) gets
12897 -        * executed in narrow mode, but that is OK, since we are
12898 -        * returning to a 32 bit process. When we support 64 bit processes
12899 -        * we won't clear the W bit, so the be will run in wide mode.
12900 -        */
12901 -
12902 -       be      0(%sr3,%r31)                       /* return to user space */
12903 +       /* decide whether to reset the wide mode bit
12904 +        *
12905 +        * For a syscall, the W bit is stored in the lowest bit
12906 +        * of sp.  Extract it and reset W if it is zero */
12907 +       extrd,u,*<>     %r30,63,1,%r1
12908         rsm     PSW_SM_W, %r0
12909 -#else
12910 -       be,n    0(%sr3,%r31)                       /* return to user space */
12911 +       /* now reset the lowest bit of sp if it was set */
12912 +       xor     %r30,%r1,%r30
12913  #endif
12914 +       be,n    0(%sr3,%r31)                       /* return to user space */
12915  
12916         /* We have to return via an RFI, so that PSW T and R bits can be set
12917          * appropriately.
12918 @@ -2340,12 +2343,19 @@ syscall_restore_rfi:
12919         LDREG   TASK_PT_PSW(%r1),%r2               /* Get old PSW */
12920         ldi     0x0b,%r20                          /* Create new PSW */
12921         depi    -1,13,1,%r20                       /* C, Q, D, and I bits */
12922 -       bb,>=,n %r19,15,try_tbit                   /* PT_SINGLESTEP */
12923 +
12924 +       /* The values of PA_SINGLESTEP_BIT and PA_BLOCKSTEP_BIT are
12925 +        * set in include/linux/ptrace.h and converted to PA bitmap
12926 +        * numbers in asm-offsets.c */
12927 +
12928 +       /* if ((%r19.PA_SINGLESTEP_BIT)) { %r20.27=1} */
12929 +       extru,= %r19,PA_SINGLESTEP_BIT,1,%r0
12930         depi    -1,27,1,%r20                       /* R bit */
12931 -try_tbit:
12932 -       bb,>=,n %r19,14,psw_setup                  /* PT_BLOCKSTEP, see ptrace.c */
12933 +
12934 +       /* if ((%r19.PA_BLOCKSTEP_BIT)) { %r20.7=1} */
12935 +       extru,= %r19,PA_BLOCKSTEP_BIT,1,%r0
12936         depi    -1,7,1,%r20                        /* T bit */
12937 -psw_setup:
12938 +
12939         STREG   %r20,TASK_PT_PSW(%r1)
12940  
12941         /* Always store space registers, since sr3 can be changed (e.g. fork) */
12942 --- linux-2.6.0-test6/arch/parisc/kernel/firmware.c     2003-06-14 12:17:57.000000000 -0700
12943 +++ 25/arch/parisc/kernel/firmware.c    2003-10-05 00:33:23.000000000 -0700
12944 @@ -41,19 +41,20 @@
12945   *                                     prumpf  991016  
12946   */
12947  
12948 +#include <stdarg.h>
12949 +
12950 +#include <linux/delay.h>
12951 +#include <linux/init.h>
12952  #include <linux/kernel.h>
12953 +#include <linux/module.h>
12954  #include <linux/string.h>
12955  #include <linux/spinlock.h>
12956 -#include <linux/init.h>
12957 -#include <linux/delay.h>
12958  
12959  #include <asm/page.h>
12960  #include <asm/pdc.h>
12961  #include <asm/system.h>
12962  #include <asm/processor.h>     /* for boot_cpu_data */
12963  
12964 -#include <stdarg.h>
12965 -
12966  static spinlock_t pdc_lock = SPIN_LOCK_UNLOCKED;
12967  static unsigned long pdc_result[32] __attribute__ ((aligned (8)));
12968  static unsigned long pdc_result2[32] __attribute__ ((aligned (8)));
12969 @@ -151,6 +152,7 @@ int pdc_add_valid(unsigned long address)
12970  
12971          return retval;
12972  }
12973 +EXPORT_SYMBOL(pdc_add_valid);
12974  
12975  /**
12976   * pdc_chassis_info - Return chassis information.
12977 @@ -264,6 +266,7 @@ int pdc_iodc_read(unsigned long *actcnt,
12978  
12979         return retval;
12980  }
12981 +EXPORT_SYMBOL(pdc_iodc_read);
12982  
12983  /**
12984   * pdc_system_map_find_mods - Locate unarchitected modules.
12985 @@ -518,6 +521,7 @@ int pdc_lan_station_id(char *lan_addr, u
12986  
12987         return retval;
12988  }
12989 +EXPORT_SYMBOL(pdc_lan_station_id);
12990  
12991  
12992  /**
12993 @@ -594,6 +598,7 @@ int pdc_get_initiator( struct hardware_p
12994         spin_unlock_irq(&pdc_lock);
12995         return retval >= PDC_OK;
12996  }
12997 +EXPORT_SYMBOL(pdc_get_initiator);
12998  
12999  
13000  /**
13001 @@ -660,6 +665,7 @@ int pdc_tod_read(struct pdc_tod *tod)
13002  
13003          return retval;
13004  }
13005 +EXPORT_SYMBOL(pdc_tod_read);
13006  
13007  /**
13008   * pdc_tod_set - Set the Time-Of-Day clock.
13009 @@ -678,6 +684,7 @@ int pdc_tod_set(unsigned long sec, unsig
13010  
13011          return retval;
13012  }
13013 +EXPORT_SYMBOL(pdc_tod_set);
13014  
13015  #ifdef __LP64__
13016  int pdc_mem_mem_table(struct pdc_memory_table_raddr *r_addr,
13017 @@ -772,20 +779,34 @@ int pdc_soft_power_button(int sw_control
13018  }
13019  
13020  /*
13021 - * pdc_suspend_usb - Stop USB controller
13022 + * pdc_io_reset - Hack to avoid overlapping range registers of Bridges devices.
13023 + * Primarily a problem on T600 (which parisc-linux doesn't support) but
13024 + * who knows what other platform firmware might do with this OS "hook".
13025 + */
13026 +void pdc_io_reset(void)
13027 +{
13028 +       spin_lock_irq(&pdc_lock);  
13029 +       mem_pdc_call(PDC_IO, PDC_IO_RESET, 0);
13030 +       spin_unlock_irq(&pdc_lock);
13031 +}
13032 +
13033 +/*
13034 + * pdc_io_reset_devices - Hack to Stop USB controller
13035   *
13036   * If PDC used the usb controller, the usb controller
13037   * is still running and will crash the machines during iommu 
13038   * setup, because of still running DMA. This PDC call
13039 - * stops the USB controller
13040 + * stops the USB controller.
13041 + * Normally called after calling pdc_io_reset().
13042   */
13043 -void pdc_suspend_usb(void)
13044 +void pdc_io_reset_devices(void)
13045  {
13046         spin_lock_irq(&pdc_lock);  
13047 -       mem_pdc_call(PDC_IO, PDC_IO_SUSPEND_USB, 0);
13048 +       mem_pdc_call(PDC_IO, PDC_IO_RESET_DEVICES, 0);
13049         spin_unlock_irq(&pdc_lock);
13050  }
13051  
13052 +
13053  /**
13054   * pdc_iodc_putc - Console character print using IODC.
13055   * @c: the character to output.
13056 @@ -905,6 +926,7 @@ int pdc_sti_call(unsigned long func, uns
13057  
13058          return retval;
13059  }
13060 +EXPORT_SYMBOL(pdc_sti_call);
13061  
13062  #ifdef __LP64__
13063  /**
13064 --- linux-2.6.0-test6/arch/parisc/kernel/inventory.c    2003-06-14 12:17:57.000000000 -0700
13065 +++ 25/arch/parisc/kernel/inventory.c   2003-10-05 00:33:23.000000000 -0700
13066 @@ -526,12 +526,14 @@ static void __init system_map_inventory(
13067         int i;
13068         long status = PDC_OK;
13069      
13070 +#if defined(CONFIG_IOMMU_SBA) && defined(CONFIG_SUPERIO)
13071         /*
13072 -        * first stop the usb controller, otherwise the machine
13073 -        * might crash during iommu setup
13074 +        * Stop the suckyio usb controller on Astro based systems.
13075 +        * Otherwise the machine might crash during iommu setup.
13076          */
13077 -#warning We still probably need to worry about USB here, but how?
13078 -        /* pdc_suspend_usb(); */
13079 +       pdc_io_reset();
13080 +       pdc_io_reset_devices();
13081 +#endif
13082  
13083         for (i = 0; status != PDC_BAD_PROC && status != PDC_NE_MOD; i++) {
13084                 struct parisc_device *dev;
13085 --- linux-2.6.0-test6/arch/parisc/kernel/irq.c  2003-09-27 18:57:43.000000000 -0700
13086 +++ 25/arch/parisc/kernel/irq.c 2003-10-05 00:33:23.000000000 -0700
13087 @@ -193,6 +193,7 @@ void disable_irq(int irq)
13088         else
13089                 BUG();
13090  }
13091 +EXPORT_SYMBOL(disable_irq);
13092  
13093  void enable_irq(int irq)
13094  {
13095 @@ -208,6 +209,7 @@ void enable_irq(int irq)
13096         else
13097                 BUG();
13098  }
13099 +EXPORT_SYMBOL(enable_irq);
13100  
13101  int show_interrupts(struct seq_file *p, void *v)
13102  {
13103 @@ -698,6 +700,7 @@ void synchronize_irq(unsigned int irqnum
13104  {
13105         while (in_irq()) ;
13106  }
13107 +EXPORT_SYMBOL(synchronize_irq);
13108  #endif
13109  
13110  
13111 @@ -847,6 +850,7 @@ unsigned int probe_irq_mask(unsigned lon
13112  {
13113         return 0;
13114  }
13115 +EXPORT_SYMBOL(probe_irq_mask);
13116  
13117  void __init init_IRQ(void)
13118  {
13119 --- linux-2.6.0-test6/arch/parisc/kernel/module.c       2003-09-27 18:57:43.000000000 -0700
13120 +++ 25/arch/parisc/kernel/module.c      2003-10-05 00:33:23.000000000 -0700
13121 @@ -73,10 +73,7 @@ struct got_entry {
13122         Elf32_Addr addr;
13123  };
13124  
13125 -struct fdesc_entry {
13126 -       Elf32_Addr addr;
13127 -       Elf32_Addr gp;
13128 -};
13129 +#define Elf_Fdesc      Elf32_Fdesc
13130  
13131  struct stub_entry {
13132         Elf32_Word insns[2]; /* each stub entry has two insns */
13133 @@ -86,11 +83,7 @@ struct got_entry {
13134         Elf64_Addr addr;
13135  };
13136  
13137 -struct fdesc_entry {
13138 -       Elf64_Addr dummy[2];
13139 -       Elf64_Addr addr;
13140 -       Elf64_Addr gp;
13141 -};
13142 +#define Elf_Fdesc      Elf64_Fdesc
13143  
13144  struct stub_entry {
13145         Elf64_Word insns[4]; /* each stub entry has four insns */
13146 @@ -276,7 +269,7 @@ int module_frob_arch_sections(CONST Elf_
13147  
13148         me->core_size = ALIGN(me->core_size, 16);
13149         me->arch.fdesc_offset = me->core_size;
13150 -       me->core_size += fdescs * sizeof(struct fdesc_entry);
13151 +       me->core_size += fdescs * sizeof(Elf_Fdesc);
13152  
13153         me->core_size = ALIGN(me->core_size, 16);
13154         me->arch.stub_offset = me->core_size;
13155 @@ -322,7 +315,7 @@ static Elf64_Word get_got(struct module 
13156  #ifdef __LP64__
13157  static Elf_Addr get_fdesc(struct module *me, unsigned long value)
13158  {
13159 -       struct fdesc_entry *fdesc = me->module_core + me->arch.fdesc_offset;
13160 +       Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
13161  
13162         if (!value) {
13163                 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
13164 @@ -664,7 +657,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs
13165                                 *loc64 = get_fdesc(me, val+addend);
13166                                 DEBUGP("FDESC for %s at %p points to %lx\n",
13167                                        strtab + sym->st_name, *loc64,
13168 -                                      ((struct fdesc_entry *)*loc64)->addr);
13169 +                                      ((Elf_Fdesc *)*loc64)->addr);
13170                         } else {
13171                                 /* if the symbol is not local to this
13172                                  * module then val+addend is a pointer
13173 @@ -696,10 +689,10 @@ int module_finalize(const Elf_Ehdr *hdr,
13174         Elf_Sym *newptr, *oldptr;
13175         Elf_Shdr *symhdr = NULL;
13176  #ifdef DEBUG
13177 -       struct fdesc_entry *entry;
13178 +       Elf_Fdesc *entry;
13179         u32 *addr;
13180  
13181 -       entry = (struct fdesc_entry *)me->init;
13182 +       entry = (Elf_Fdesc *)me->init;
13183         printk("FINALIZE, ->init FPTR is %p, GP %lx ADDR %lx\n", entry,
13184                entry->gp, entry->addr);
13185         addr = (u32 *)entry->addr;
13186 --- linux-2.6.0-test6/arch/parisc/kernel/parisc_ksyms.c 2003-09-27 18:57:43.000000000 -0700
13187 +++ 25/arch/parisc/kernel/parisc_ksyms.c        2003-10-05 00:33:23.000000000 -0700
13188 @@ -26,19 +26,6 @@ EXPORT_SYMBOL(strrchr);
13189  EXPORT_SYMBOL(strstr);
13190  EXPORT_SYMBOL(strpbrk);
13191  
13192 -#include <asm/hardware.h>      /* struct parisc_device for asm/pci.h */
13193 -#include <linux/pci.h>
13194 -EXPORT_SYMBOL(hppa_dma_ops);
13195 -#if defined(CONFIG_PCI) || defined(CONFIG_ISA)
13196 -EXPORT_SYMBOL(get_pci_node_path);
13197 -#endif
13198 -
13199 -#include <linux/sched.h>
13200 -#include <asm/irq.h>
13201 -EXPORT_SYMBOL(enable_irq);
13202 -EXPORT_SYMBOL(disable_irq);
13203 -EXPORT_SYMBOL(probe_irq_mask);
13204 -
13205  #include <asm/processor.h>
13206  EXPORT_SYMBOL(kernel_thread);
13207  EXPORT_SYMBOL(boot_cpu_data);
13208 @@ -46,10 +33,6 @@ EXPORT_SYMBOL(boot_cpu_data);
13209  #include <linux/pm.h>
13210  EXPORT_SYMBOL(pm_power_off);
13211  
13212 -#ifdef CONFIG_SMP
13213 -EXPORT_SYMBOL(synchronize_irq);
13214 -#endif /* CONFIG_SMP */
13215 -
13216  #include <asm/atomic.h>
13217  EXPORT_SYMBOL(__xchg8);
13218  EXPORT_SYMBOL(__xchg32);
13219 @@ -74,14 +57,6 @@ extern int $global$;
13220  EXPORT_SYMBOL($global$);
13221  #endif
13222  
13223 -EXPORT_SYMBOL(register_parisc_driver);
13224 -EXPORT_SYMBOL(unregister_parisc_driver);
13225 -EXPORT_SYMBOL(print_pci_hwpath);
13226 -EXPORT_SYMBOL(print_pa_hwpath);
13227 -EXPORT_SYMBOL(pdc_iodc_read);
13228 -EXPORT_SYMBOL(pdc_tod_read);
13229 -EXPORT_SYMBOL(pdc_tod_set);
13230 -
13231  #include <asm/io.h>
13232  EXPORT_SYMBOL(__ioremap);
13233  EXPORT_SYMBOL(iounmap);
13234 @@ -89,22 +64,6 @@ EXPORT_SYMBOL(__memcpy_toio);
13235  EXPORT_SYMBOL(__memcpy_fromio);
13236  EXPORT_SYMBOL(__memset_io);
13237  
13238 -#if defined(CONFIG_PCI) || defined(CONFIG_ISA)
13239 -EXPORT_SYMBOL(inb);
13240 -EXPORT_SYMBOL(inw);
13241 -EXPORT_SYMBOL(inl);
13242 -EXPORT_SYMBOL(outb);
13243 -EXPORT_SYMBOL(outw);
13244 -EXPORT_SYMBOL(outl);
13245 -
13246 -EXPORT_SYMBOL(insb);
13247 -EXPORT_SYMBOL(insw);
13248 -EXPORT_SYMBOL(insl);
13249 -EXPORT_SYMBOL(outsb);
13250 -EXPORT_SYMBOL(outsw);
13251 -EXPORT_SYMBOL(outsl);
13252 -#endif
13253 -
13254  #include <asm/cache.h>
13255  EXPORT_SYMBOL(flush_kernel_dcache_range_asm);
13256  EXPORT_SYMBOL(flush_kernel_dcache_page);
13257 @@ -130,17 +89,6 @@ EXPORT_SYMBOL(__up);
13258  EXPORT_SYMBOL(__down_interruptible);
13259  EXPORT_SYMBOL(__down);
13260  
13261 -#include <linux/in6.h>
13262 -#include <asm/checksum.h>
13263 -EXPORT_SYMBOL(csum_partial_copy_nocheck);
13264 -EXPORT_SYMBOL(csum_partial_copy_from_user);
13265 -
13266 -#include <asm/pdc.h>
13267 -EXPORT_SYMBOL(pdc_add_valid);
13268 -EXPORT_SYMBOL(pdc_lan_station_id);
13269 -EXPORT_SYMBOL(pdc_get_initiator);
13270 -EXPORT_SYMBOL(pdc_sti_call);
13271 -
13272  extern void $$divI(void);
13273  extern void $$divU(void);
13274  extern void $$remI(void);
13275 @@ -218,6 +166,3 @@ EXPORT_SYMBOL(__moddi3);
13276  extern void $$dyncall(void);
13277  EXPORT_SYMBOL($$dyncall);
13278  #endif
13279 -
13280 -#include <asm/pgtable.h>
13281 -EXPORT_SYMBOL(vmalloc_start);
13282 --- linux-2.6.0-test6/arch/parisc/kernel/pci.c  2003-09-27 18:57:43.000000000 -0700
13283 +++ 25/arch/parisc/kernel/pci.c 2003-10-05 00:33:23.000000000 -0700
13284 @@ -88,7 +88,8 @@ u##size in##type (int addr) \
13285         EISA_IN(size); \
13286         if (!parisc_pci_hba[b]) return (u##size) -1; \
13287         return pci_port->in##type(parisc_pci_hba[b], PCI_PORT_ADDR(addr)); \
13288 -}
13289 +} \
13290 +EXPORT_SYMBOL(in##type);
13291  
13292  PCI_PORT_IN(b,  8)
13293  PCI_PORT_IN(w, 16)
13294 @@ -102,7 +103,8 @@ void out##type (u##size d, int addr) \
13295         EISA_OUT(size); \
13296         if (!parisc_pci_hba[b]) return; \
13297         pci_port->out##type(parisc_pci_hba[b], PCI_PORT_ADDR(addr), d); \
13298 -}
13299 +} \
13300 +EXPORT_SYMBOL(out##type);
13301  
13302  PCI_PORT_OUT(b,  8)
13303  PCI_PORT_OUT(w, 16)
13304 --- linux-2.6.0-test6/arch/parisc/kernel/ptrace.c       2003-06-14 12:17:58.000000000 -0700
13305 +++ 25/arch/parisc/kernel/ptrace.c      2003-10-05 00:33:23.000000000 -0700
13306 @@ -23,16 +23,6 @@
13307  #include <asm/processor.h>
13308  #include <asm/offsets.h>
13309  
13310 -/* These are used in entry.S, syscall_restore_rfi.  We need to record the
13311 - * current stepping mode somewhere other than in PSW, because there is no
13312 - * concept of saving and restoring the users PSW over a syscall.  We choose
13313 - * to use these two bits in task->ptrace.  These bits must not clash with
13314 - * any PT_* defined in include/linux/sched.h, and must match with the bit
13315 - * tests in entry.S
13316 - */
13317 -#define PT_SINGLESTEP  0x10000
13318 -#define PT_BLOCKSTEP   0x20000
13319 -
13320  /* PSW bits we allow the debugger to modify */
13321  #define USER_PSW_BITS  (PSW_N | PSW_V | PSW_CB)
13322  
13323 --- linux-2.6.0-test6/arch/parisc/kernel/setup.c        2003-09-27 18:57:43.000000000 -0700
13324 +++ 25/arch/parisc/kernel/setup.c       2003-10-05 00:33:23.000000000 -0700
13325 @@ -43,6 +43,7 @@
13326  #include <asm/led.h>
13327  #include <asm/machdep.h>       /* for pa7300lc_init() proto */
13328  #include <asm/pdc_chassis.h>
13329 +#include <asm/io.h>
13330  
13331  #define COMMAND_LINE_SIZE 1024
13332  char   saved_command_line[COMMAND_LINE_SIZE];
13333 @@ -208,27 +209,32 @@ static void __init parisc_proc_mkdir(voi
13334                          proc_runway_root = proc_mkdir("bus/runway", 0);
13335                  }
13336                  break;
13337 +       default:
13338 +               /* FIXME: this was added to prevent the compiler 
13339 +                * complaining about missing pcx, pcxs and pcxt
13340 +                * I'm assuming they have neither gsc nor runway */
13341 +               break;
13342         }
13343  }
13344  
13345  static struct resource central_bus = {
13346         .name   = "Central Bus",
13347 -       .start  = (unsigned long)0xfffffffffff80000,
13348 -       .end    = (unsigned long)0xfffffffffffaffff,
13349 +       .start  = F_EXTEND(0xfff80000),
13350 +       .end    = F_EXTEND(0xfffaffff),
13351         .flags  = IORESOURCE_MEM,
13352  };
13353  
13354  static struct resource local_broadcast = {
13355         .name   = "Local Broadcast",
13356 -       .start  = (unsigned long)0xfffffffffffb0000,
13357 -       .end    = (unsigned long)0xfffffffffffdffff,
13358 +       .start  = F_EXTEND(0xfffb0000),
13359 +       .end    = F_EXTEND(0xfffdffff),
13360         .flags  = IORESOURCE_MEM,
13361  };
13362  
13363  static struct resource global_broadcast = {
13364         .name   = "Global Broadcast",
13365 -       .start  = (unsigned long)0xfffffffffffe0000,
13366 -       .end    = (unsigned long)0xffffffffffffffff,
13367 +       .start  = F_EXTEND(0xfffe0000),
13368 +       .end    = F_EXTEND(0xffffffff),
13369         .flags  = IORESOURCE_MEM,
13370  };
13371  
13372 --- linux-2.6.0-test6/arch/parisc/kernel/signal.c       2003-09-27 18:57:43.000000000 -0700
13373 +++ 25/arch/parisc/kernel/signal.c      2003-10-05 00:33:23.000000000 -0700
13374 @@ -25,6 +25,8 @@
13375  #include <linux/unistd.h>
13376  #include <linux/stddef.h>
13377  #include <linux/compat.h>
13378 +#include <linux/elf.h>
13379 +#include <linux/personality.h>
13380  #include <asm/ucontext.h>
13381  #include <asm/rt_sigframe.h>
13382  #include <asm/uaccess.h>
13383 @@ -41,8 +43,11 @@
13384  
13385  #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
13386  
13387 -/* Use this to get at 32-bit user passed pointers. 
13388 - *    See sys_sparc32.c for description about these. */
13389 +/* gcc will complain if a pointer is cast to an integer of different
13390 + * size.  If you really need to do this (and we do for an ELF32 user
13391 + * application in an ELF64 kernel) then you have to do a cast to an
13392 + * integer of the same size first.  The A() macro accomplishes
13393 + * this. */
13394  #define A(__x) ((unsigned long)(__x))
13395  
13396  int do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall);
13397 @@ -166,11 +171,17 @@ sys_rt_sigreturn(struct pt_regs *regs, i
13398         struct rt_sigframe *frame;
13399         struct siginfo si;
13400         sigset_t set;
13401 -       unsigned long usp = regs->gr[30];
13402 +       unsigned long usp = (regs->gr[30] & ~(0x01UL));
13403 +       unsigned long sigframe_size = PARISC_RT_SIGFRAME_SIZE;
13404 +#ifdef __LP64__
13405 +       if(personality(current->personality) == PER_LINUX32)
13406 +               sigframe_size = PARISC_RT_SIGFRAME_SIZE32;
13407 +#endif
13408 +
13409  
13410         /* Unwind the user stack to get the rt_sigframe structure. */
13411         frame = (struct rt_sigframe *)
13412 -               (usp - PARISC_RT_SIGFRAME_SIZE);
13413 +               (usp - sigframe_size);
13414         DBG(("in sys_rt_sigreturn, frame is %p\n", frame));
13415  
13416         if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
13417 @@ -271,11 +282,12 @@ setup_rt_frame(int sig, struct k_sigacti
13418                sigset_t *set, struct pt_regs *regs, int in_syscall)
13419  {
13420         struct rt_sigframe *frame;
13421 -       unsigned long rp, usp, haddr;
13422 +       unsigned long rp, usp;
13423 +       unsigned long haddr, sigframe_size;
13424         struct siginfo si;
13425         int err = 0;
13426  
13427 -       usp = regs->gr[30];
13428 +       usp = (regs->gr[30] & ~(0x01UL));
13429         frame = get_sigframe(ka, usp, sizeof(*frame));
13430  
13431         DBG(("setup_rt_frame 1: frame %p info %p\n", frame, info));
13432 @@ -308,64 +320,86 @@ setup_rt_frame(int sig, struct k_sigacti
13433         }
13434  #endif
13435  
13436 -#undef CACHE_FLUSHING_IS_NOT_BROKEN
13437 -#ifdef CACHE_FLUSHING_IS_NOT_BROKEN
13438 +       flush_user_dcache_range((unsigned long) &frame->tramp[0],
13439 +                          (unsigned long) &frame->tramp[4]);
13440         flush_user_icache_range((unsigned long) &frame->tramp[0],
13441                            (unsigned long) &frame->tramp[4]);
13442 -#else
13443 -       /* It should *always* be cache line-aligned, but the compiler
13444 -       sometimes screws up. */
13445 -       asm volatile("fdc 0(%%sr3,%0)\n\t"
13446 -                    "fdc %1(%%sr3,%0)\n\t"
13447 -                    "sync\n\t"
13448 -                    "fic 0(%%sr3,%0)\n\t"
13449 -                    "fic %1(%%sr3,%0)\n\t"
13450 -                    "sync\n\t"
13451 -                     : : "r" (frame->tramp), "r" (L1_CACHE_BYTES));
13452 -#endif
13453  
13454         rp = (unsigned long) frame->tramp;
13455  
13456         if (err)
13457                 goto give_sigsegv;
13458  
13459 -/* Much more has to happen with signals than this -- but it'll at least */
13460 -/* provide a pointer to some places which definitely need a look. */
13461 -#define HACK u32
13462 -
13463 -       haddr = (HACK)A(ka->sa.sa_handler);
13464 -       /* ARGH!  Fucking brain damage.  You don't want to know. */
13465 -       if (haddr & 2) {
13466 -               HACK *plabel;
13467 -               HACK ltp;
13468 -
13469 -               plabel = (HACK *) (haddr & ~3);
13470 -               err |= __get_user(haddr, plabel);
13471 -               err |= __get_user(ltp, plabel + 1);
13472 +       haddr = A(ka->sa.sa_handler);
13473 +       /* The sa_handler may be a pointer to a function descriptor */
13474 +#ifdef __LP64__
13475 +       if(personality(current->personality) == PER_LINUX32) {
13476 +#endif
13477 +               if (haddr & PA_PLABEL_FDESC) {
13478 +                       Elf32_Fdesc fdesc;
13479 +                       Elf32_Fdesc *ufdesc = (Elf32_Fdesc *)A(haddr & ~3);
13480 +
13481 +                       err = __copy_from_user(&fdesc, ufdesc, sizeof(fdesc));
13482 +
13483 +                       if (err)
13484 +                               goto give_sigsegv;
13485 +
13486 +                       haddr = fdesc.addr;
13487 +                       regs->gr[19] = fdesc.gp;
13488 +               }
13489 +#ifdef __LP64__
13490 +       } else {
13491 +               Elf64_Fdesc fdesc;
13492 +               Elf64_Fdesc *ufdesc = (Elf64_Fdesc *)A(haddr & ~3);
13493 +               
13494 +               err = __copy_from_user(&fdesc, ufdesc, sizeof(fdesc));
13495 +               
13496                 if (err)
13497                         goto give_sigsegv;
13498 -               regs->gr[19] = ltp;
13499 +               
13500 +               haddr = fdesc.addr;
13501 +               regs->gr[19] = fdesc.gp;
13502 +               DBG(("64 bit signal, exe=%#lx, r19=%#lx, in_syscall=%d\n",
13503 +                    haddr, regs->gr[19], in_syscall));
13504         }
13505 +#endif
13506  
13507         /* The syscall return path will create IAOQ values from r31.
13508          */
13509 -       if (in_syscall)
13510 -               regs->gr[31] = (HACK) haddr;
13511 -       else {
13512 -               regs->gr[0] = USER_PSW;
13513 -               regs->iaoq[0] = (HACK) haddr | 3;
13514 +       sigframe_size = PARISC_RT_SIGFRAME_SIZE;
13515 +#ifdef __LP64__
13516 +       if(personality(current->personality) == PER_LINUX32)
13517 +               sigframe_size = PARISC_RT_SIGFRAME_SIZE32;
13518 +#endif
13519 +       if (in_syscall) {
13520 +               regs->gr[31] = haddr;
13521 +#ifdef __LP64__
13522 +               if(personality(current->personality) == PER_LINUX)
13523 +                       sigframe_size |= 1;
13524 +#endif
13525 +       } else {
13526 +               unsigned long psw = USER_PSW;
13527 +#ifdef __LP64__
13528 +               if(personality(current->personality) == PER_LINUX)
13529 +                       psw |= PSW_W;
13530 +#endif
13531 +
13532 +               regs->gr[0] = psw;
13533 +               regs->iaoq[0] = haddr | 3;
13534                 regs->iaoq[1] = regs->iaoq[0] + 4;
13535         }
13536  
13537         regs->gr[2]  = rp;                /* userland return pointer */
13538         regs->gr[26] = sig;               /* signal number */
13539 -       regs->gr[25] = (HACK)A(&frame->info); /* siginfo pointer */
13540 -       regs->gr[24] = (HACK)A(&frame->uc);   /* ucontext pointer */
13541 +       regs->gr[25] = A(&frame->info); /* siginfo pointer */
13542 +       regs->gr[24] = A(&frame->uc);   /* ucontext pointer */
13543 +       
13544         DBG(("making sigreturn frame: %#lx + %#x = %#lx\n",
13545 -              regs->gr[30], PARISC_RT_SIGFRAME_SIZE,
13546 -              regs->gr[30] + PARISC_RT_SIGFRAME_SIZE));
13547 +              regs->gr[30], sigframe_size,
13548 +              regs->gr[30] + sigframe_size));
13549         /* Raise the user stack pointer to make a proper call frame. */
13550 -       regs->gr[30] = ((HACK)A(frame) + PARISC_RT_SIGFRAME_SIZE);
13551 +       regs->gr[30] = (A(frame) + sigframe_size);
13552 +
13553  
13554         DBG(("SIG deliver (%s:%d): frame=0x%p sp=%#lx iaoq=%#lx/%#lx rp=%#lx\n",
13555                current->comm, current->pid, frame, regs->gr[30],
13556 --- linux-2.6.0-test6/arch/parisc/kernel/syscall.S      2003-09-27 18:57:43.000000000 -0700
13557 +++ 25/arch/parisc/kernel/syscall.S     2003-10-05 00:33:23.000000000 -0700
13558 @@ -69,9 +69,14 @@ linux_gateway_entry:
13559          * exit from the syscall, and also use that value to know
13560          * whether to do narrow or wide syscalls. -PB
13561          */
13562 -       ssm     PSW_SM_W, %r0
13563 +       ssm     PSW_SM_W, %r1
13564 +       extrd,u %r1,PSW_W_BIT,1,%r1
13565 +       /* sp must be aligned on 4, so deposit the W bit setting into
13566 +        * the bottom of sp temporarily */
13567 +       or,ev   %r1,%r30,%r30
13568 +       b,n     1f
13569         /* The top halves of argument registers must be cleared on syscall
13570 -        * entry.
13571 +        * entry from narrow executable.
13572          */
13573         depdi   0, 31, 32, %r26
13574         depdi   0, 31, 32, %r25
13575 @@ -79,11 +84,13 @@ linux_gateway_entry:
13576         depdi   0, 31, 32, %r23
13577         depdi   0, 31, 32, %r22
13578         depdi   0, 31, 32, %r21
13579 +1:     
13580  #endif
13581         mfctl   %cr30,%r1
13582         xor     %r1,%r30,%r30                   /* ye olde xor trick */
13583         xor     %r1,%r30,%r1
13584         xor     %r1,%r30,%r30
13585 +       
13586         ldo     THREAD_SZ_ALGN+FRAME_SIZE(%r30),%r30  /* set up kernel stack */
13587  
13588         /* N.B.: It is critical that we don't set sr7 to 0 until r30
13589 @@ -104,9 +111,19 @@ linux_gateway_entry:
13590            PSW value is stored.  This is needed for gdb and sys_ptrace. */
13591         STREG   %r0,  TASK_PT_PSW(%r1)
13592         STREG   %r2,  TASK_PT_GR2(%r1)          /* preserve rp */
13593 +       STREG   %r19, TASK_PT_GR19(%r1)
13594 +
13595         LDREGM  -FRAME_SIZE(%r30), %r2          /* get users sp back */
13596 +#ifdef __LP64__
13597 +       extrd,u %r2,63,1,%r19                   /* W hidden in bottom bit */
13598 +#if 0
13599 +       xor     %r19,%r2,%r2                    /* clear bottom bit */
13600 +       depd,z  %r19,1,1,%r19
13601 +       std     %r19,TASK_PT_PSW(%r1)
13602 +#endif
13603 +#endif
13604         STREG   %r2,  TASK_PT_GR30(%r1)         /* ... and save it */
13605 -       STREG   %r19, TASK_PT_GR19(%r1)
13606 +       
13607         STREG   %r20, TASK_PT_GR20(%r1)
13608         STREG   %r21, TASK_PT_GR21(%r1)
13609         STREG   %r22, TASK_PT_GR22(%r1)
13610 @@ -130,6 +147,7 @@ linux_gateway_entry:
13611  
13612  #ifdef __LP64__
13613         ldo     -16(%r30),%r29                  /* Reference param save area */
13614 +       copy    %r19,%r2                        /* W bit back to r2 */
13615  #else
13616         /* no need to save these on stack in wide mode because the first 8
13617          * args are passed in registers */
13618 @@ -144,9 +162,17 @@ linux_gateway_entry:
13619         /* Note!  We cannot use the syscall table that is mapped
13620         nearby since the gateway page is mapped execute-only. */
13621  
13622 +#ifdef __LP64__
13623 +       ldil    L%sys_call_table, %r1
13624 +       or,=    %r2,%r2,%r2
13625 +       addil   L%(sys_call_table64-sys_call_table), %r1
13626 +       ldo     R%sys_call_table(%r1), %r19
13627 +       or,=    %r2,%r2,%r2
13628 +       ldo     R%sys_call_table64(%r1), %r19
13629 +#else
13630         ldil    L%sys_call_table, %r1
13631         ldo     R%sys_call_table(%r1), %r19
13632 -       
13633 +#endif 
13634         comiclr,>>=     __NR_Linux_syscalls, %r20, %r0
13635         b,n     .Lsyscall_nosys
13636         
13637 @@ -317,304 +343,21 @@ tracesys_sigexit:
13638         ldil    L%syscall_exit_rfi,%r1
13639         be,n    R%syscall_exit_rfi(%sr7,%r1)
13640  
13641 -#ifdef __LP64__
13642 -/* Use ENTRY_SAME for 32-bit syscalls which are the same on wide and
13643 - * narrow palinux.  Use ENTRY_DIFF for those where a 32-bit specific
13644 - * implementation is required on wide palinux.  Use ENTRY_COMP where
13645 - * the compatability layer has a useful 32-bit implementation.
13646 - */
13647 -#define ENTRY_SAME(_name_) .dword sys_##_name_
13648 -#define ENTRY_DIFF(_name_) .dword sys32_##_name_
13649 -#define ENTRY_UHOH(_name_) .dword sys32_##unimplemented
13650 -#define ENTRY_OURS(_name_) .dword parisc_##_name_
13651 -#define ENTRY_COMP(_name_) .dword compat_sys_##_name_
13652 -#else
13653 -#define ENTRY_SAME(_name_) .word sys_##_name_
13654 -#define ENTRY_DIFF(_name_) .word sys_##_name_
13655 -#define ENTRY_UHOH(_name_) .word sys_##_name_
13656 -#define ENTRY_OURS(_name_) .word parisc_##_name_
13657 -#define ENTRY_COMP(_name_) .word sys_##_name_
13658 -#endif
13659 -
13660 -       .align 8
13661 +       .align 4096
13662         .export sys_call_table
13663  .Lsys_call_table:
13664  sys_call_table:
13665 -       ENTRY_SAME(ni_syscall)  /* 0  -  old "setup()" system call*/
13666 -       ENTRY_SAME(exit)
13667 -       ENTRY_SAME(fork_wrapper)
13668 -       ENTRY_SAME(read)
13669 -       ENTRY_SAME(write)
13670 -       ENTRY_SAME(open)                /* 5 */
13671 -       ENTRY_SAME(close)
13672 -       ENTRY_SAME(waitpid)
13673 -       ENTRY_SAME(creat)
13674 -       ENTRY_SAME(link)
13675 -       ENTRY_SAME(unlink)              /* 10 */
13676 -       ENTRY_DIFF(execve_wrapper)
13677 -       ENTRY_SAME(chdir)
13678 -       /* See comments in kernel/time.c!!! Maybe we don't need this? */
13679 -       ENTRY_DIFF(time)
13680 -       ENTRY_SAME(mknod)
13681 -       ENTRY_SAME(chmod)               /* 15 */
13682 -       ENTRY_SAME(lchown)
13683 -       ENTRY_SAME(socket)
13684 -       /* struct stat is MAYBE identical wide and narrow ?? */
13685 -       ENTRY_COMP(newstat)
13686 -       ENTRY_DIFF(lseek)
13687 -       ENTRY_SAME(getpid)              /* 20 */
13688 -       /* the 'void * data' parameter may need re-packing in wide */
13689 -       ENTRY_DIFF(mount)
13690 -       /* concerned about struct sockaddr in wide/narrow */
13691 -       /* ---> I think sockaddr is OK unless the compiler packs the struct */
13692 -       /*      differently to align the char array */
13693 -       ENTRY_SAME(bind)
13694 -       ENTRY_SAME(setuid)
13695 -       ENTRY_SAME(getuid)
13696 -       ENTRY_SAME(stime)               /* 25 */
13697 -       ENTRY_SAME(ptrace)
13698 -       ENTRY_SAME(alarm)
13699 -       /* see stat comment */
13700 -       ENTRY_COMP(newfstat)
13701 -       ENTRY_SAME(pause)
13702 -       /* struct utimbuf uses time_t which might vary */
13703 -       ENTRY_COMP(utime)               /* 30 */
13704 -       /* struct sockaddr... */
13705 -       ENTRY_SAME(connect)
13706 -       ENTRY_SAME(listen)
13707 -       ENTRY_SAME(access)
13708 -       ENTRY_SAME(nice)
13709 -       /* struct sockaddr... */
13710 -       ENTRY_SAME(accept)              /* 35 */
13711 -       ENTRY_SAME(sync)
13712 -       ENTRY_SAME(kill)
13713 -       ENTRY_SAME(rename)
13714 -       ENTRY_SAME(mkdir)
13715 -       ENTRY_SAME(rmdir)               /* 40 */
13716 -       ENTRY_SAME(dup)
13717 -       ENTRY_SAME(pipe)
13718 -       ENTRY_COMP(times)
13719 -       /* struct sockaddr... */
13720 -       ENTRY_SAME(getsockname)
13721 -       /* it seems possible brk() could return a >4G pointer... */
13722 -       ENTRY_SAME(brk)                 /* 45 */
13723 -       ENTRY_SAME(setgid)
13724 -       ENTRY_SAME(getgid)
13725 -       ENTRY_SAME(signal)
13726 -       ENTRY_SAME(geteuid)
13727 -       ENTRY_SAME(getegid)             /* 50 */
13728 -       ENTRY_SAME(acct)
13729 -       ENTRY_SAME(umount)
13730 -       /* struct sockaddr... */
13731 -       ENTRY_SAME(getpeername)
13732 -       ENTRY_COMP(ioctl)
13733 -       ENTRY_COMP(fcntl)               /* 55 */
13734 -       ENTRY_SAME(socketpair)
13735 -       ENTRY_SAME(setpgid)
13736 -       ENTRY_SAME(send)
13737 -       ENTRY_SAME(newuname)
13738 -       ENTRY_SAME(umask)               /* 60 */
13739 -       ENTRY_SAME(chroot)
13740 -       ENTRY_SAME(ustat)
13741 -       ENTRY_SAME(dup2)
13742 -       ENTRY_SAME(getppid)
13743 -       ENTRY_SAME(getpgrp)             /* 65 */
13744 -       ENTRY_SAME(setsid)
13745 -       ENTRY_SAME(pivot_root)
13746 -       /* I don't like this */
13747 -       ENTRY_UHOH(sgetmask)
13748 -       ENTRY_UHOH(ssetmask)
13749 -       ENTRY_SAME(setreuid)            /* 70 */
13750 -       ENTRY_SAME(setregid)
13751 -       ENTRY_SAME(mincore)
13752 -       ENTRY_COMP(sigpending)
13753 -       ENTRY_SAME(sethostname)
13754 -       /* Following 3 have linux-common-code structs containing longs -( */
13755 -       ENTRY_COMP(setrlimit)           /* 75 */
13756 -       ENTRY_COMP(getrlimit)
13757 -       ENTRY_COMP(getrusage)
13758 -       /* struct timeval and timezone are maybe?? consistent wide and narrow */
13759 -       ENTRY_DIFF(gettimeofday)
13760 -       ENTRY_DIFF(settimeofday)
13761 -       ENTRY_SAME(getgroups)           /* 80 */
13762 -       ENTRY_SAME(setgroups)
13763 -       /* struct socketaddr... */
13764 -       ENTRY_SAME(sendto)
13765 -       ENTRY_SAME(symlink)
13766 -       /* see stat comment */
13767 -       ENTRY_COMP(newlstat)
13768 -       ENTRY_SAME(readlink)            /* 85 */
13769 -       ENTRY_SAME(ni_syscall)  /* was uselib */
13770 -       ENTRY_SAME(swapon)
13771 -       ENTRY_SAME(reboot)
13772 -       ENTRY_SAME(mmap2)
13773 -       ENTRY_SAME(mmap)                /* 90 */
13774 -       ENTRY_SAME(munmap)
13775 -       ENTRY_SAME(truncate)
13776 -       ENTRY_SAME(ftruncate)
13777 -       ENTRY_SAME(fchmod)
13778 -       ENTRY_SAME(fchown)              /* 95 */
13779 -       ENTRY_SAME(getpriority)
13780 -       ENTRY_SAME(setpriority)
13781 -       ENTRY_SAME(recv)
13782 -       ENTRY_COMP(statfs)
13783 -       ENTRY_COMP(fstatfs)             /* 100 */
13784 -       ENTRY_SAME(stat64)
13785 -       ENTRY_SAME(ni_syscall)  /* was socketcall */
13786 -       ENTRY_SAME(syslog)
13787 -       /* even though manpage says struct timeval contains longs, ours has
13788 -        * time_t and suseconds_t -- both of which are safe wide/narrow */
13789 -       ENTRY_COMP(setitimer)
13790 -       ENTRY_COMP(getitimer)           /* 105 */
13791 -       ENTRY_SAME(capget)
13792 -       ENTRY_SAME(capset)
13793 -       ENTRY_OURS(pread64)
13794 -       ENTRY_OURS(pwrite64)
13795 -       ENTRY_SAME(getcwd)              /* 110 */
13796 -       ENTRY_SAME(vhangup)
13797 -       ENTRY_SAME(fstat64)
13798 -       ENTRY_SAME(vfork_wrapper)
13799 -       /* struct rusage contains longs... */
13800 -       ENTRY_COMP(wait4)
13801 -       ENTRY_SAME(swapoff)             /* 115 */
13802 -       ENTRY_DIFF(sysinfo)
13803 -       ENTRY_SAME(shutdown)
13804 -       ENTRY_SAME(fsync)
13805 -       ENTRY_SAME(madvise)
13806 -       ENTRY_SAME(clone_wrapper)       /* 120 */
13807 -       ENTRY_SAME(setdomainname)
13808 -       ENTRY_DIFF(sendfile)
13809 -       /* struct sockaddr... */
13810 -       ENTRY_SAME(recvfrom)
13811 -       /* struct timex contains longs */
13812 -       ENTRY_DIFF(adjtimex)
13813 -       ENTRY_SAME(mprotect)            /* 125 */
13814 -       /* old_sigset_t forced to 32 bits.  Beware glibc sigset_t */
13815 -       ENTRY_COMP(sigprocmask)
13816 -       ENTRY_SAME(ni_syscall)  /* create_module */
13817 -       ENTRY_SAME(init_module)
13818 -       ENTRY_SAME(delete_module)
13819 -       ENTRY_SAME(ni_syscall)          /* 130: get_kernel_syms */
13820 -       /* time_t inside struct dqblk */
13821 -       ENTRY_SAME(quotactl)
13822 -       ENTRY_SAME(getpgid)
13823 -       ENTRY_SAME(fchdir)
13824 -       ENTRY_SAME(bdflush)
13825 -       ENTRY_SAME(sysfs)               /* 135 */
13826 -       ENTRY_SAME(personality)
13827 -       ENTRY_SAME(ni_syscall)  /* for afs_syscall */
13828 -       ENTRY_SAME(setfsuid)
13829 -       ENTRY_SAME(setfsgid)
13830 -       /* I think this might work */
13831 -       ENTRY_SAME(llseek)              /* 140 */
13832 -       /* struct linux_dirent has longs, like 'unsigned long d_ino' which
13833 -        * almost definitely should be 'ino_t d_ino' but it's too late now */
13834 -       ENTRY_DIFF(getdents)
13835 -       /* it is POSSIBLE that select will be OK because even though fd_set
13836 -        * contains longs, the macros and sizes are clever. */
13837 -       ENTRY_DIFF(select)
13838 -       ENTRY_SAME(flock)
13839 -       ENTRY_SAME(msync)
13840 -       /* struct iovec contains pointers */
13841 -       ENTRY_DIFF(readv)               /* 145 */
13842 -       ENTRY_DIFF(writev)
13843 -       ENTRY_SAME(getsid)
13844 -       ENTRY_SAME(fdatasync)
13845 -       /* struct __sysctl_args is a mess */
13846 -       ENTRY_DIFF(sysctl)
13847 -       ENTRY_SAME(mlock)               /* 150 */
13848 -       ENTRY_SAME(munlock)
13849 -       ENTRY_SAME(mlockall)
13850 -       ENTRY_SAME(munlockall)
13851 -       /* struct sched_param is ok for now */
13852 -       ENTRY_SAME(sched_setparam)
13853 -       ENTRY_SAME(sched_getparam)      /* 155 */
13854 -       ENTRY_SAME(sched_setscheduler)
13855 -       ENTRY_SAME(sched_getscheduler)
13856 -       ENTRY_SAME(sched_yield)
13857 -       ENTRY_SAME(sched_get_priority_max)
13858 -       ENTRY_SAME(sched_get_priority_min)      /* 160 */
13859 -       /* These 2 would've worked if someone had defined struct timespec
13860 -        * carefully, like timeval for example (which is about the same).
13861 -        * Unfortunately it contains a long :-( */
13862 -       ENTRY_DIFF(sched_rr_get_interval)
13863 -       ENTRY_COMP(nanosleep)
13864 -       ENTRY_SAME(mremap)
13865 -       ENTRY_SAME(setresuid)
13866 -       ENTRY_SAME(getresuid)           /* 165 */
13867 -       ENTRY_DIFF(sigaltstack_wrapper)
13868 -       ENTRY_SAME(ni_syscall)          /* query_module */
13869 -       ENTRY_SAME(poll)
13870 -       /* structs contain pointers and an in_addr... */
13871 -       ENTRY_DIFF(nfsservctl)
13872 -       ENTRY_SAME(setresgid)           /* 170 */
13873 -       ENTRY_SAME(getresgid)
13874 -       ENTRY_SAME(prctl)
13875 -       /* signals need a careful review */
13876 -       ENTRY_SAME(rt_sigreturn_wrapper)
13877 -       ENTRY_DIFF(rt_sigaction)
13878 -       ENTRY_DIFF(rt_sigprocmask)      /* 175 */
13879 -       ENTRY_DIFF(rt_sigpending)
13880 -       ENTRY_UHOH(rt_sigtimedwait)
13881 -       /* even though the struct siginfo_t is different, it appears like
13882 -        * all the paths use values which should be same wide and narrow.
13883 -        * Also the struct is padded to 128 bytes which means we don't have
13884 -        * to worry about faulting trying to copy in a larger 64-bit
13885 -        * struct from a 32-bit user-space app.
13886 -        */
13887 -       ENTRY_SAME(rt_sigqueueinfo)
13888 -       ENTRY_SAME(rt_sigsuspend_wrapper) /* not really SAME -- see the code */
13889 -       ENTRY_SAME(chown)               /* 180 */
13890 -       /* setsockopt() used by iptables: SO_SET_REPLACE/SO_SET_ADD_COUNTERS */
13891 -       ENTRY_COMP(setsockopt)
13892 -       ENTRY_SAME(getsockopt)
13893 -       ENTRY_COMP(sendmsg)
13894 -       ENTRY_COMP(recvmsg)
13895 -       ENTRY_SAME(semop)               /* 185 */
13896 -       ENTRY_SAME(semget)
13897 -       ENTRY_DIFF(semctl_broken)
13898 -       ENTRY_DIFF(msgsnd)
13899 -       ENTRY_DIFF(msgrcv)
13900 -       ENTRY_SAME(msgget)              /* 190 */
13901 -       ENTRY_SAME(msgctl_broken)
13902 -       ENTRY_SAME(shmat_wrapper)
13903 -       ENTRY_SAME(shmdt)
13904 -       ENTRY_SAME(shmget)
13905 -       ENTRY_SAME(shmctl_broken)       /* 195 */
13906 -       ENTRY_SAME(ni_syscall)          /* streams1 */
13907 -       ENTRY_SAME(ni_syscall)          /* streams2 */
13908 -       ENTRY_SAME(lstat64)
13909 -       ENTRY_OURS(truncate64)
13910 -       ENTRY_OURS(ftruncate64)         /* 200 */
13911 -       ENTRY_SAME(getdents64)
13912 -       ENTRY_COMP(fcntl64)
13913 -       ENTRY_SAME(ni_syscall)
13914 -       ENTRY_SAME(ni_syscall)
13915 -       ENTRY_SAME(ni_syscall)          /* 205 */
13916 -       ENTRY_SAME(gettid)             
13917 -       ENTRY_OURS(readahead)          
13918 -       ENTRY_SAME(ni_syscall)          /* tkill */
13919 -
13920 -       ENTRY_SAME(sendfile64)
13921 -       ENTRY_COMP(futex)               /* 210 */
13922 -       ENTRY_COMP(sched_setaffinity)
13923 -       ENTRY_COMP(sched_getaffinity)
13924 -       ENTRY_SAME(ni_syscall)
13925 -       ENTRY_SAME(ni_syscall)
13926 -       ENTRY_SAME(io_setup)            /* 215 */
13927 -       ENTRY_SAME(io_destroy)
13928 -       ENTRY_SAME(io_getevents)
13929 -       ENTRY_SAME(io_submit)
13930 -       ENTRY_SAME(io_cancel)
13931 -       ENTRY_SAME(alloc_hugepages)     /* 220 */
13932 -       ENTRY_SAME(free_hugepages)
13933 -       ENTRY_SAME(exit_group)
13934 -       ENTRY_DIFF(lookup_dcookie)
13935 -       ENTRY_SAME(epoll_create)
13936 -       ENTRY_SAME(epoll_ctl)           /* 225 */
13937 -       ENTRY_SAME(epoll_wait)
13938 -       ENTRY_SAME(remap_file_pages)
13939 +#include "syscall_table.S"
13940  .end
13941 +#ifdef __LP64__
13942 +       .align 4096
13943 +       .export sys_call_table64
13944 +.Lsys_call_table64:
13945 +sys_call_table64:
13946 +#define SYSCALL_TABLE_64BIT
13947 +#include "syscall_table.S"
13948 +#endif
13949 +
13950  
13951         /* Make sure nothing else is placed on this page */
13952  
13953 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
13954 +++ 25/arch/parisc/kernel/syscall_table.S       2003-10-05 00:33:23.000000000 -0700
13955 @@ -0,0 +1,304 @@
13956 +#undef ENTRY_SAME
13957 +#undef ENTRY_DIFF
13958 +#undef ENTRY_UHOH
13959 +#undef ENTRY_COMP
13960 +#undef ENTRY_OURS
13961 +#if defined(__LP64__) && !defined(SYSCALL_TABLE_64BIT)
13962 +/* Use ENTRY_SAME for 32-bit syscalls which are the same on wide and
13963 + * narrow palinux.  Use ENTRY_DIFF for those where a 32-bit specific
13964 + * implementation is required on wide palinux.  Use ENTRY_COMP where
13965 + * the compatability layer has a useful 32-bit implementation.
13966 + */
13967 +#define ENTRY_SAME(_name_) .dword sys_##_name_
13968 +#define ENTRY_DIFF(_name_) .dword sys32_##_name_
13969 +#define ENTRY_UHOH(_name_) .dword sys32_##unimplemented
13970 +#define ENTRY_OURS(_name_) .dword parisc_##_name_
13971 +#define ENTRY_COMP(_name_) .dword compat_sys_##_name_
13972 +#elif defined(__LP64__) && defined(SYSCALL_TABLE_64BIT)
13973 +#define ENTRY_SAME(_name_) .dword sys_##_name_
13974 +#define ENTRY_DIFF(_name_) .dword sys_##_name_
13975 +#define ENTRY_UHOH(_name_) .dword sys_##_name_
13976 +#define ENTRY_OURS(_name_) .dword sys_##_name_
13977 +#define ENTRY_COMP(_name_) .dword sys_##_name_
13978 +#else
13979 +#define ENTRY_SAME(_name_) .word sys_##_name_
13980 +#define ENTRY_DIFF(_name_) .word sys_##_name_
13981 +#define ENTRY_UHOH(_name_) .word sys_##_name_
13982 +#define ENTRY_OURS(_name_) .word parisc_##_name_
13983 +#define ENTRY_COMP(_name_) .word sys_##_name_
13984 +#endif
13985 +
13986 +       ENTRY_SAME(ni_syscall)  /* 0  -  old "setup()" system call*/
13987 +       ENTRY_SAME(exit)
13988 +       ENTRY_SAME(fork_wrapper)
13989 +       ENTRY_SAME(read)
13990 +       ENTRY_SAME(write)
13991 +       ENTRY_SAME(open)                /* 5 */
13992 +       ENTRY_SAME(close)
13993 +       ENTRY_SAME(waitpid)
13994 +       ENTRY_SAME(creat)
13995 +       ENTRY_SAME(link)
13996 +       ENTRY_SAME(unlink)              /* 10 */
13997 +       ENTRY_DIFF(execve_wrapper)
13998 +       ENTRY_SAME(chdir)
13999 +       /* See comments in kernel/time.c!!! Maybe we don't need this? */
14000 +       ENTRY_DIFF(time)
14001 +       ENTRY_SAME(mknod)
14002 +       ENTRY_SAME(chmod)               /* 15 */
14003 +       ENTRY_SAME(lchown)
14004 +       ENTRY_SAME(socket)
14005 +       /* struct stat is MAYBE identical wide and narrow ?? */
14006 +       ENTRY_COMP(newstat)
14007 +       ENTRY_DIFF(lseek)
14008 +       ENTRY_SAME(getpid)              /* 20 */
14009 +       /* the 'void * data' parameter may need re-packing in wide */
14010 +       ENTRY_DIFF(mount)
14011 +       /* concerned about struct sockaddr in wide/narrow */
14012 +       /* ---> I think sockaddr is OK unless the compiler packs the struct */
14013 +       /*      differently to align the char array */
14014 +       ENTRY_SAME(bind)
14015 +       ENTRY_SAME(setuid)
14016 +       ENTRY_SAME(getuid)
14017 +       ENTRY_SAME(stime)               /* 25 */
14018 +       ENTRY_SAME(ptrace)
14019 +       ENTRY_SAME(alarm)
14020 +       /* see stat comment */
14021 +       ENTRY_COMP(newfstat)
14022 +       ENTRY_SAME(pause)
14023 +       /* struct utimbuf uses time_t which might vary */
14024 +       ENTRY_COMP(utime)               /* 30 */
14025 +       /* struct sockaddr... */
14026 +       ENTRY_SAME(connect)
14027 +       ENTRY_SAME(listen)
14028 +       ENTRY_SAME(access)
14029 +       ENTRY_SAME(nice)
14030 +       /* struct sockaddr... */
14031 +       ENTRY_SAME(accept)              /* 35 */
14032 +       ENTRY_SAME(sync)
14033 +       ENTRY_SAME(kill)
14034 +       ENTRY_SAME(rename)
14035 +       ENTRY_SAME(mkdir)
14036 +       ENTRY_SAME(rmdir)               /* 40 */
14037 +       ENTRY_SAME(dup)
14038 +       ENTRY_SAME(pipe)
14039 +       ENTRY_COMP(times)
14040 +       /* struct sockaddr... */
14041 +       ENTRY_SAME(getsockname)
14042 +       /* it seems possible brk() could return a >4G pointer... */
14043 +       ENTRY_SAME(brk)                 /* 45 */
14044 +       ENTRY_SAME(setgid)
14045 +       ENTRY_SAME(getgid)
14046 +       ENTRY_SAME(signal)
14047 +       ENTRY_SAME(geteuid)
14048 +       ENTRY_SAME(getegid)             /* 50 */
14049 +       ENTRY_SAME(acct)
14050 +       ENTRY_SAME(umount)
14051 +       /* struct sockaddr... */
14052 +       ENTRY_SAME(getpeername)
14053 +       ENTRY_COMP(ioctl)
14054 +       ENTRY_COMP(fcntl)               /* 55 */
14055 +       ENTRY_SAME(socketpair)
14056 +       ENTRY_SAME(setpgid)
14057 +       ENTRY_SAME(send)
14058 +       ENTRY_SAME(newuname)
14059 +       ENTRY_SAME(umask)               /* 60 */
14060 +       ENTRY_SAME(chroot)
14061 +       ENTRY_SAME(ustat)
14062 +       ENTRY_SAME(dup2)
14063 +       ENTRY_SAME(getppid)
14064 +       ENTRY_SAME(getpgrp)             /* 65 */
14065 +       ENTRY_SAME(setsid)
14066 +       ENTRY_SAME(pivot_root)
14067 +       /* I don't like this */
14068 +       ENTRY_UHOH(sgetmask)
14069 +       ENTRY_UHOH(ssetmask)
14070 +       ENTRY_SAME(setreuid)            /* 70 */
14071 +       ENTRY_SAME(setregid)
14072 +       ENTRY_SAME(mincore)
14073 +       ENTRY_COMP(sigpending)
14074 +       ENTRY_SAME(sethostname)
14075 +       /* Following 3 have linux-common-code structs containing longs -( */
14076 +       ENTRY_COMP(setrlimit)           /* 75 */
14077 +       ENTRY_COMP(getrlimit)
14078 +       ENTRY_COMP(getrusage)
14079 +       /* struct timeval and timezone are maybe?? consistent wide and narrow */
14080 +       ENTRY_DIFF(gettimeofday)
14081 +       ENTRY_DIFF(settimeofday)
14082 +       ENTRY_SAME(getgroups)           /* 80 */
14083 +       ENTRY_SAME(setgroups)
14084 +       /* struct socketaddr... */
14085 +       ENTRY_SAME(sendto)
14086 +       ENTRY_SAME(symlink)
14087 +       /* see stat comment */
14088 +       ENTRY_COMP(newlstat)
14089 +       ENTRY_SAME(readlink)            /* 85 */
14090 +       ENTRY_SAME(ni_syscall)  /* was uselib */
14091 +       ENTRY_SAME(swapon)
14092 +       ENTRY_SAME(reboot)
14093 +       ENTRY_SAME(mmap2)
14094 +       ENTRY_SAME(mmap)                /* 90 */
14095 +       ENTRY_SAME(munmap)
14096 +       ENTRY_SAME(truncate)
14097 +       ENTRY_SAME(ftruncate)
14098 +       ENTRY_SAME(fchmod)
14099 +       ENTRY_SAME(fchown)              /* 95 */
14100 +       ENTRY_SAME(getpriority)
14101 +       ENTRY_SAME(setpriority)
14102 +       ENTRY_SAME(recv)
14103 +       ENTRY_COMP(statfs)
14104 +       ENTRY_COMP(fstatfs)             /* 100 */
14105 +       ENTRY_SAME(stat64)
14106 +       ENTRY_SAME(ni_syscall)  /* was socketcall */
14107 +       ENTRY_SAME(syslog)
14108 +       /* even though manpage says struct timeval contains longs, ours has
14109 +        * time_t and suseconds_t -- both of which are safe wide/narrow */
14110 +       ENTRY_COMP(setitimer)
14111 +       ENTRY_COMP(getitimer)           /* 105 */
14112 +       ENTRY_SAME(capget)
14113 +       ENTRY_SAME(capset)
14114 +       ENTRY_OURS(pread64)
14115 +       ENTRY_OURS(pwrite64)
14116 +       ENTRY_SAME(getcwd)              /* 110 */
14117 +       ENTRY_SAME(vhangup)
14118 +       ENTRY_SAME(fstat64)
14119 +       ENTRY_SAME(vfork_wrapper)
14120 +       /* struct rusage contains longs... */
14121 +       ENTRY_COMP(wait4)
14122 +       ENTRY_SAME(swapoff)             /* 115 */
14123 +       ENTRY_DIFF(sysinfo)
14124 +       ENTRY_SAME(shutdown)
14125 +       ENTRY_SAME(fsync)
14126 +       ENTRY_SAME(madvise)
14127 +       ENTRY_SAME(clone_wrapper)       /* 120 */
14128 +       ENTRY_SAME(setdomainname)
14129 +       ENTRY_DIFF(sendfile)
14130 +       /* struct sockaddr... */
14131 +       ENTRY_SAME(recvfrom)
14132 +       /* struct timex contains longs */
14133 +       ENTRY_DIFF(adjtimex)
14134 +       ENTRY_SAME(mprotect)            /* 125 */
14135 +       /* old_sigset_t forced to 32 bits.  Beware glibc sigset_t */
14136 +       ENTRY_COMP(sigprocmask)
14137 +       ENTRY_SAME(ni_syscall)  /* create_module */
14138 +       ENTRY_SAME(init_module)
14139 +       ENTRY_SAME(delete_module)
14140 +       ENTRY_SAME(ni_syscall)          /* 130: get_kernel_syms */
14141 +       /* time_t inside struct dqblk */
14142 +       ENTRY_SAME(quotactl)
14143 +       ENTRY_SAME(getpgid)
14144 +       ENTRY_SAME(fchdir)
14145 +       ENTRY_SAME(bdflush)
14146 +       ENTRY_SAME(sysfs)               /* 135 */
14147 +       ENTRY_SAME(personality)
14148 +       ENTRY_SAME(ni_syscall)  /* for afs_syscall */
14149 +       ENTRY_SAME(setfsuid)
14150 +       ENTRY_SAME(setfsgid)
14151 +       /* I think this might work */
14152 +       ENTRY_SAME(llseek)              /* 140 */
14153 +       /* struct linux_dirent has longs, like 'unsigned long d_ino' which
14154 +        * almost definitely should be 'ino_t d_ino' but it's too late now */
14155 +       ENTRY_DIFF(getdents)
14156 +       /* it is POSSIBLE that select will be OK because even though fd_set
14157 +        * contains longs, the macros and sizes are clever. */
14158 +       ENTRY_DIFF(select)
14159 +       ENTRY_SAME(flock)
14160 +       ENTRY_SAME(msync)
14161 +       /* struct iovec contains pointers */
14162 +       ENTRY_DIFF(readv)               /* 145 */
14163 +       ENTRY_DIFF(writev)
14164 +       ENTRY_SAME(getsid)
14165 +       ENTRY_SAME(fdatasync)
14166 +       /* struct __sysctl_args is a mess */
14167 +       ENTRY_DIFF(sysctl)
14168 +       ENTRY_SAME(mlock)               /* 150 */
14169 +       ENTRY_SAME(munlock)
14170 +       ENTRY_SAME(mlockall)
14171 +       ENTRY_SAME(munlockall)
14172 +       /* struct sched_param is ok for now */
14173 +       ENTRY_SAME(sched_setparam)
14174 +       ENTRY_SAME(sched_getparam)      /* 155 */
14175 +       ENTRY_SAME(sched_setscheduler)
14176 +       ENTRY_SAME(sched_getscheduler)
14177 +       ENTRY_SAME(sched_yield)
14178 +       ENTRY_SAME(sched_get_priority_max)
14179 +       ENTRY_SAME(sched_get_priority_min)      /* 160 */
14180 +       /* These 2 would've worked if someone had defined struct timespec
14181 +        * carefully, like timeval for example (which is about the same).
14182 +        * Unfortunately it contains a long :-( */
14183 +       ENTRY_DIFF(sched_rr_get_interval)
14184 +       ENTRY_COMP(nanosleep)
14185 +       ENTRY_SAME(mremap)
14186 +       ENTRY_SAME(setresuid)
14187 +       ENTRY_SAME(getresuid)           /* 165 */
14188 +       ENTRY_DIFF(sigaltstack_wrapper)
14189 +       ENTRY_SAME(ni_syscall)          /* query_module */
14190 +       ENTRY_SAME(poll)
14191 +       /* structs contain pointers and an in_addr... */
14192 +       ENTRY_DIFF(nfsservctl)
14193 +       ENTRY_SAME(setresgid)           /* 170 */
14194 +       ENTRY_SAME(getresgid)
14195 +       ENTRY_SAME(prctl)
14196 +       /* signals need a careful review */
14197 +       ENTRY_SAME(rt_sigreturn_wrapper)
14198 +       ENTRY_DIFF(rt_sigaction)
14199 +       ENTRY_DIFF(rt_sigprocmask)      /* 175 */
14200 +       ENTRY_DIFF(rt_sigpending)
14201 +       ENTRY_UHOH(rt_sigtimedwait)
14202 +       /* even though the struct siginfo_t is different, it appears like
14203 +        * all the paths use values which should be same wide and narrow.
14204 +        * Also the struct is padded to 128 bytes which means we don't have
14205 +        * to worry about faulting trying to copy in a larger 64-bit
14206 +        * struct from a 32-bit user-space app.
14207 +        */
14208 +       ENTRY_SAME(rt_sigqueueinfo)
14209 +       ENTRY_SAME(rt_sigsuspend_wrapper) /* not really SAME -- see the code */
14210 +       ENTRY_SAME(chown)               /* 180 */
14211 +       /* setsockopt() used by iptables: SO_SET_REPLACE/SO_SET_ADD_COUNTERS */
14212 +       ENTRY_COMP(setsockopt)
14213 +       ENTRY_SAME(getsockopt)
14214 +       ENTRY_COMP(sendmsg)
14215 +       ENTRY_COMP(recvmsg)
14216 +       ENTRY_SAME(semop)               /* 185 */
14217 +       ENTRY_SAME(semget)
14218 +       ENTRY_DIFF(semctl_broken)
14219 +       ENTRY_DIFF(msgsnd)
14220 +       ENTRY_DIFF(msgrcv)
14221 +       ENTRY_SAME(msgget)              /* 190 */
14222 +       ENTRY_SAME(msgctl_broken)
14223 +       ENTRY_SAME(shmat_wrapper)
14224 +       ENTRY_SAME(shmdt)
14225 +       ENTRY_SAME(shmget)
14226 +       ENTRY_SAME(shmctl_broken)       /* 195 */
14227 +       ENTRY_SAME(ni_syscall)          /* streams1 */
14228 +       ENTRY_SAME(ni_syscall)          /* streams2 */
14229 +       ENTRY_SAME(lstat64)
14230 +       ENTRY_OURS(truncate64)
14231 +       ENTRY_OURS(ftruncate64)         /* 200 */
14232 +       ENTRY_SAME(getdents64)
14233 +       ENTRY_COMP(fcntl64)
14234 +       ENTRY_SAME(ni_syscall)
14235 +       ENTRY_SAME(ni_syscall)
14236 +       ENTRY_SAME(ni_syscall)          /* 205 */
14237 +       ENTRY_SAME(gettid)             
14238 +       ENTRY_OURS(readahead)          
14239 +       ENTRY_SAME(ni_syscall)          /* tkill */
14240 +
14241 +       ENTRY_SAME(sendfile64)
14242 +       ENTRY_COMP(futex)               /* 210 */
14243 +       ENTRY_COMP(sched_setaffinity)
14244 +       ENTRY_COMP(sched_getaffinity)
14245 +       ENTRY_SAME(ni_syscall)
14246 +       ENTRY_SAME(ni_syscall)
14247 +       ENTRY_SAME(io_setup)            /* 215 */
14248 +       ENTRY_SAME(io_destroy)
14249 +       ENTRY_SAME(io_getevents)
14250 +       ENTRY_SAME(io_submit)
14251 +       ENTRY_SAME(io_cancel)
14252 +       ENTRY_SAME(alloc_hugepages)     /* 220 */
14253 +       ENTRY_SAME(free_hugepages)
14254 +       ENTRY_SAME(exit_group)
14255 +       ENTRY_DIFF(lookup_dcookie)
14256 +       ENTRY_SAME(epoll_create)
14257 +       ENTRY_SAME(epoll_ctl)           /* 225 */
14258 +       ENTRY_SAME(epoll_wait)
14259 +       ENTRY_SAME(remap_file_pages)
14260 --- linux-2.6.0-test6/arch/parisc/kernel/sys_parisc.c   2003-09-27 18:57:43.000000000 -0700
14261 +++ 25/arch/parisc/kernel/sys_parisc.c  2003-10-05 00:34:08.000000000 -0700
14262 @@ -65,7 +65,7 @@ static int get_offset(struct address_spa
14263   */
14264  static int get_offset(struct address_space *mapping)
14265  {
14266 -       int offset = (int) mapping << (PAGE_SHIFT - 8);
14267 +       int offset = (unsigned long) mapping << (PAGE_SHIFT - 8);
14268         return offset & 0x3FF000;
14269  }
14270  #endif
14271 @@ -93,17 +93,13 @@ static unsigned long get_shared_area(str
14272  unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
14273                 unsigned long len, unsigned long pgoff, unsigned long flags)
14274  {
14275 -       struct inode *inode;
14276 -
14277         if (len > TASK_SIZE)
14278                 return -ENOMEM;
14279         if (!addr)
14280                 addr = TASK_UNMAPPED_BASE;
14281  
14282 -       inode = filp ? filp->f_dentry->d_inode : NULL;
14283 -
14284 -       if (inode && (flags & MAP_SHARED)) {
14285 -               addr = get_shared_area(inode->i_mapping, addr, len, pgoff);
14286 +       if (filp && (flags & MAP_SHARED)) {
14287 +               addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
14288         } else {
14289                 addr = get_unshared_area(addr, len);
14290         }
14291 @@ -165,12 +161,13 @@ long sys_shmat_wrapper(int shmid, char *
14292         return raddr;
14293  }
14294  
14295 -
14296  /* Fucking broken ABI */
14297  
14298  #ifdef CONFIG_PARISC64
14299  extern asmlinkage long sys_truncate(const char *, unsigned long);
14300  extern asmlinkage long sys_ftruncate(unsigned int, unsigned long);
14301 +extern asmlinkage long sys_fcntl(unsigned int, unsigned int, unsigned long);
14302 +
14303  asmlinkage long parisc_truncate64(const char * path,
14304                                         unsigned int high, unsigned int low)
14305  {
14306 @@ -182,6 +179,21 @@ asmlinkage long parisc_ftruncate64(unsig
14307  {
14308         return sys_ftruncate(fd, (long)high << 32 | low);
14309  }
14310 +
14311 +/* stubs for the benefit of the syscall_table since truncate64 and truncate 
14312 + * are identical on LP64 */
14313 +asmlinkage long sys_truncate64(const char * path, unsigned long length)
14314 +{
14315 +       return sys_truncate(path, length);
14316 +}
14317 +asmlinkage long sys_ftruncate64(unsigned int fd, unsigned long length)
14318 +{
14319 +       return sys_ftruncate(fd, length);
14320 +}
14321 +asmlinkage long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
14322 +{
14323 +       return sys_fcntl(fd, cmd, arg);
14324 +}
14325  #else
14326  
14327  extern asmlinkage long sys_truncate64(const char *, loff_t);
14328 --- linux-2.6.0-test6/arch/parisc/kernel/time.c 2003-07-13 21:44:34.000000000 -0700
14329 +++ 25/arch/parisc/kernel/time.c        2003-10-05 00:33:23.000000000 -0700
14330 @@ -48,7 +48,9 @@ static inline void
14331  parisc_do_profile(struct pt_regs *regs)
14332  {
14333         unsigned long pc = regs->iaoq[0];
14334 +#if 0
14335         extern unsigned long prof_cpu_mask;
14336 +#endif
14337         extern char _stext;
14338  
14339         profile_hook(regs);
14340 @@ -60,6 +62,10 @@ parisc_do_profile(struct pt_regs *regs)
14341                 return;
14342  
14343  #if 0
14344 +       /* FIXME: when we have irq affinity to cpu, we need to
14345 +        * only look at the cpus specified in this mask 
14346 +        */
14347 +
14348         if (!((1 << smp_processor_id()) & prof_cpu_mask))
14349                 return;
14350  #endif
14351 @@ -206,7 +212,6 @@ do_settimeofday (struct timespec *tv)
14352                  * done, and then undo it!
14353                  */
14354                 nsec -= gettimeoffset() * 1000;
14355 -               nsec -= (jiffies - wall_jiffies) * (NSEC_PER_SEC / HZ);
14356  
14357                 wtm_sec  = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
14358                 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
14359 @@ -223,6 +228,16 @@ do_settimeofday (struct timespec *tv)
14360         return 0;
14361  }
14362  
14363 +/*
14364 + * XXX: We can do better than this.
14365 + * Returns nanoseconds
14366 + */
14367 +
14368 +unsigned long long sched_clock(void)
14369 +{
14370 +       return (unsigned long long)jiffies * (1000000000 / HZ);
14371 +}
14372 +
14373  
14374  void __init time_init(void)
14375  {
14376 --- linux-2.6.0-test6/arch/parisc/kernel/traps.c        2003-09-27 18:57:43.000000000 -0700
14377 +++ 25/arch/parisc/kernel/traps.c       2003-10-05 00:33:23.000000000 -0700
14378 @@ -678,12 +678,13 @@ void handle_interruption(int code, struc
14379         }
14380  
14381         if (user_mode(regs)) {
14382 -           if (fault_space != regs->sr[7]) {
14383 +           if ((fault_space>>SPACEID_SHIFT) != (regs->sr[7] >> SPACEID_SHIFT)) {
14384  #ifdef PRINT_USER_FAULTS
14385                 if (fault_space == 0)
14386                         printk(KERN_DEBUG "User Fault on Kernel Space ");
14387                 else
14388 -                       printk(KERN_DEBUG "User Fault (long pointer) ");
14389 +                       printk(KERN_DEBUG "User Fault (long pointer) (fault %d) ",
14390 +                              code);
14391                 printk("pid=%d command='%s'\n", current->pid, current->comm);
14392                 show_regs(regs);
14393  #endif
14394 --- linux-2.6.0-test6/arch/parisc/kernel/unaligned.c    2003-07-13 21:44:34.000000000 -0700
14395 +++ 25/arch/parisc/kernel/unaligned.c   2003-10-05 00:33:23.000000000 -0700
14396 @@ -369,8 +369,8 @@ static int emulate_std(struct pt_regs *r
14397  
14398  void handle_unaligned(struct pt_regs *regs)
14399  {
14400 -       unsigned long unaligned_count = 0;
14401 -       unsigned long last_time = 0;
14402 +       static unsigned long unaligned_count = 0;
14403 +       static unsigned long last_time = 0;
14404         unsigned long newbase = R1(regs->iir)?regs->gr[R1(regs->iir)]:0;
14405         int modify = 0;
14406         int ret = -1;
14407 @@ -380,7 +380,6 @@ void handle_unaligned(struct pt_regs *re
14408         /* if the unaligned access is inside the kernel:
14409          *   if the access is caused by a syscall, then we fault the calling
14410          *     user process
14411 -        *   otherwise we halt the kernel
14412          */
14413         if (!user_mode(regs))
14414         {
14415 @@ -427,10 +426,10 @@ void handle_unaligned(struct pt_regs *re
14416                         show_regs(regs);
14417  #endif         
14418                 }
14419 -       }
14420  
14421 -       if (!unaligned_enabled)
14422 -               goto force_sigbus;
14423 +               if (!unaligned_enabled)
14424 +                       goto force_sigbus;
14425 +       }
14426  
14427         /* handle modification - OK, it's ugly, see the instruction manual */
14428         switch (MAJOR_OP(regs->iir))
14429 --- linux-2.6.0-test6/arch/parisc/lib/checksum.c        2003-06-14 12:18:24.000000000 -0700
14430 +++ 25/arch/parisc/lib/checksum.c       2003-10-05 00:33:23.000000000 -0700
14431 @@ -16,8 +16,10 @@
14432   *
14433   * $Id: 2.6.0-test6-mm4.patch,v 1.5 2004/02/23 23:37:02 phil Exp $
14434   */
14435 -#include <net/checksum.h>
14436 +#include <linux/module.h>
14437  #include <linux/types.h>
14438 +
14439 +#include <net/checksum.h>
14440  #include <asm/byteorder.h>
14441  #include <asm/string.h>
14442  #include <asm/uaccess.h>
14443 @@ -109,6 +111,7 @@ unsigned int csum_partial_copy_nocheck(c
14444  
14445         return sum;
14446  }
14447 +EXPORT_SYMBOL(csum_partial_copy_nocheck);
14448  
14449  /*
14450   * Copy from userspace and compute checksum.  If we catch an exception
14451 @@ -128,3 +131,4 @@ unsigned int csum_partial_copy_from_user
14452                 
14453         return csum_partial(dst, len, sum);
14454  }
14455 +EXPORT_SYMBOL(csum_partial_copy_from_user);
14456 --- linux-2.6.0-test6/arch/parisc/lib/io.c      2003-06-14 12:17:58.000000000 -0700
14457 +++ 25/arch/parisc/lib/io.c     2003-10-05 00:33:23.000000000 -0700
14458 @@ -8,6 +8,7 @@
14459   */
14460  
14461  #include <linux/kernel.h>
14462 +#include <linux/module.h>
14463  #include <asm/io.h>
14464  
14465  /* Copies a block of memory to a device in an efficient manner.
14466 @@ -457,3 +458,10 @@ void outsl (unsigned long port, const vo
14467                 break;
14468         }
14469  }
14470 +
14471 +EXPORT_SYMBOL(insb);
14472 +EXPORT_SYMBOL(insw);
14473 +EXPORT_SYMBOL(insl);
14474 +EXPORT_SYMBOL(outsb);
14475 +EXPORT_SYMBOL(outsw);
14476 +EXPORT_SYMBOL(outsl);
14477 --- linux-2.6.0-test6/arch/parisc/math-emu/denormal.c   2003-06-14 12:18:09.000000000 -0700
14478 +++ 25/arch/parisc/math-emu/denormal.c  2003-10-05 00:33:23.000000000 -0700
14479 @@ -47,7 +47,7 @@
14480  #include "sgl_float.h"
14481  #include "dbl_float.h"
14482  #include "hppa.h"
14483 -#include "types.h"
14484 +#include <linux/kernel.h>
14485  /* #include <machine/sys/mdep_private.h> */
14486  
14487  #undef Fpustatus_register
14488 --- linux-2.6.0-test6/arch/parisc/math-emu/fpudispatch.c        2003-06-14 12:17:56.000000000 -0700
14489 +++ 25/arch/parisc/math-emu/fpudispatch.c       2003-10-05 00:33:23.000000000 -0700
14490 @@ -50,7 +50,7 @@
14491  #define FPUDEBUG 0
14492  
14493  #include "float.h"
14494 -#include "types.h"
14495 +#include <linux/kernel.h>
14496  #include <asm/processor.h>
14497  /* #include <sys/debug.h> */
14498  /* #include <machine/sys/mdep_private.h> */
14499 --- linux-2.6.0-test6/arch/parisc/math-emu/Makefile     2003-06-14 12:18:09.000000000 -0700
14500 +++ 25/arch/parisc/math-emu/Makefile    2003-10-05 00:33:23.000000000 -0700
14501 @@ -2,6 +2,11 @@
14502  # Makefile for the linux/parisc floating point code
14503  #
14504  
14505 +# See arch/parisc/math-emu/README
14506 +CFLAGS += -Wno-parentheses -Wno-implicit-function-declaration \
14507 +       -Wno-uninitialized -Wno-strict-prototypes -Wno-return-type \
14508 +       -Wno-implicit-int
14509 +
14510  obj-y   := frnd.o driver.o decode_exc.o fpudispatch.o denormal.o \
14511                 dfmpy.o sfmpy.o sfsqrt.o dfsqrt.o dfadd.o fmpyfadd.o \
14512                 sfadd.o dfsub.o sfsub.o fcnvfxt.o fcnvff.o fcnvxf.o \
14513 --- linux-2.6.0-test6/arch/parisc/math-emu/types.h      2003-06-14 12:18:00.000000000 -0700
14514 +++ /dev/null   2002-08-30 16:31:37.000000000 -0700
14515 @@ -1,25 +0,0 @@
14516 -/*
14517 - * Linux/PA-RISC Project (http://www.parisc-linux.org/)
14518 - *
14519 - * Floating-point emulation code
14520 - *  Copyright (C) 2001 Hewlett-Packard (Paul Bame) <bame@debian.org>
14521 - *
14522 - *    This program is free software; you can redistribute it and/or modify
14523 - *    it under the terms of the GNU General Public License as published by
14524 - *    the Free Software Foundation; either version 2, or (at your option)
14525 - *    any later version.
14526 - *
14527 - *    This program is distributed in the hope that it will be useful,
14528 - *    but WITHOUT ANY WARRANTY; without even the implied warranty of
14529 - *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14530 - *    GNU General Public License for more details.
14531 - *
14532 - *    You should have received a copy of the GNU General Public License
14533 - *    along with this program; if not, write to the Free Software
14534 - *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
14535 - */
14536 -
14537 -#include <linux/kernel.h>
14538 -#define BUG() do { \
14539 -        printk(KERN_ERR "floating-pt emulation BUG at %s:%d!\n", __FILE__, __LINE__); \
14540 -} while (0)
14541 --- linux-2.6.0-test6/arch/parisc/mm/init.c     2003-06-16 22:32:20.000000000 -0700
14542 +++ 25/arch/parisc/mm/init.c    2003-10-05 00:33:23.000000000 -0700
14543 @@ -430,6 +430,8 @@ void free_initmem(void)
14544                                      & ~(VM_MAP_OFFSET-1)))
14545  
14546  void *vmalloc_start;
14547 +EXPORT_SYMBOL(vmalloc_start);
14548 +
14549  #ifdef CONFIG_PA11
14550  unsigned long pcxl_dma_start;
14551  #endif
14552 @@ -618,8 +620,6 @@ static void __init pagetable_init(void)
14553  {
14554         int range;
14555  
14556 -       printk("pagetable_init\n");
14557 -
14558         /* Map each physical memory range to its kernel vaddr */
14559  
14560         for (range = 0; range < npmem_ranges; range++) {
14561 --- linux-2.6.0-test6/arch/parisc/mm/ioremap.c  2003-06-14 12:18:07.000000000 -0700
14562 +++ 25/arch/parisc/mm/ioremap.c 2003-10-05 00:33:23.000000000 -0700
14563 @@ -159,7 +159,7 @@ void * __ioremap(unsigned long phys_addr
14564         if (!area)
14565                 return NULL;
14566         addr = area->addr;
14567 -       if (remap_area_pages(VMALLOC_VMADDR(addr), phys_addr, size, flags)) {
14568 +       if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) {
14569                 vfree(addr);
14570                 return NULL;
14571         }
14572 --- linux-2.6.0-test6/arch/ppc64/kernel/ioctl32.c       2003-09-08 13:58:56.000000000 -0700
14573 +++ 25/arch/ppc64/kernel/ioctl32.c      2003-10-05 00:34:44.000000000 -0700
14574 @@ -328,396 +328,6 @@ static int do_ncp_setprivatedata(unsigne
14575         return err;
14576  }
14577  
14578 -struct usbdevfs_ctrltransfer32 {
14579 -       __u8 bRequestType;
14580 -       __u8 bRequest;
14581 -       __u16 wValue;
14582 -       __u16 wIndex;
14583 -       __u16 wLength;
14584 -       __u32 timeout;  /* in milliseconds */
14585 -       __u32 data;
14586 -};
14587 -
14588 -#define USBDEVFS_CONTROL32           _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
14589 -
14590 -static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
14591 -{
14592 -       struct usbdevfs_ctrltransfer kctrl;
14593 -       struct usbdevfs_ctrltransfer32 *uctrl;
14594 -       mm_segment_t old_fs;
14595 -       __u32 udata;
14596 -       void *uptr, *kptr;
14597 -       int err;
14598 -
14599 -       uctrl = (struct usbdevfs_ctrltransfer32 *) arg;
14600 -
14601 -       if (copy_from_user(&kctrl, uctrl,
14602 -                          (sizeof(struct usbdevfs_ctrltransfer) -
14603 -                           sizeof(void *))))
14604 -               return -EFAULT;
14605 -
14606 -       if (get_user(udata, &uctrl->data))
14607 -               return -EFAULT;
14608 -       uptr = (void *) A(udata);
14609 -
14610 -       /* In usbdevice_fs, it limits the control buffer to a page,
14611 -        * for simplicity so do we.
14612 -        */
14613 -       if (!uptr || kctrl.wLength > PAGE_SIZE)
14614 -               return -EINVAL;
14615 -
14616 -       kptr = (void *)__get_free_page(GFP_KERNEL);
14617 -
14618 -       if ((kctrl.bRequestType & 0x80) == 0) {
14619 -               err = -EFAULT;
14620 -               if (copy_from_user(kptr, uptr, kctrl.wLength))
14621 -                       goto out;
14622 -       }
14623 -
14624 -       kctrl.data = kptr;
14625 -
14626 -       old_fs = get_fs();
14627 -       set_fs(KERNEL_DS);
14628 -       err = sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)&kctrl);
14629 -       set_fs(old_fs);
14630 -
14631 -       if (err >= 0 &&
14632 -           ((kctrl.bRequestType & 0x80) != 0)) {
14633 -               if (copy_to_user(uptr, kptr, kctrl.wLength))
14634 -                       err = -EFAULT;
14635 -       }
14636 -
14637 -out:
14638 -       free_page((unsigned long) kptr);
14639 -       return err;
14640 -}
14641 -
14642 -struct usbdevfs_bulktransfer32 {
14643 -       unsigned int ep;
14644 -       unsigned int len;
14645 -       unsigned int timeout; /* in milliseconds */
14646 -       __u32 data;
14647 -};
14648 -
14649 -#define USBDEVFS_BULK32              _IOWR('U', 2, struct usbdevfs_bulktransfer32)
14650 -
14651 -static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
14652 -{
14653 -       struct usbdevfs_bulktransfer kbulk;
14654 -       struct usbdevfs_bulktransfer32 *ubulk;
14655 -       mm_segment_t old_fs;
14656 -       __u32 udata;
14657 -       void *uptr, *kptr;
14658 -       int err;
14659 -
14660 -       ubulk = (struct usbdevfs_bulktransfer32 *) arg;
14661 -
14662 -       if (get_user(kbulk.ep, &ubulk->ep) ||
14663 -           get_user(kbulk.len, &ubulk->len) ||
14664 -           get_user(kbulk.timeout, &ubulk->timeout) ||
14665 -           get_user(udata, &ubulk->data))
14666 -               return -EFAULT;
14667 -
14668 -       uptr = (void *) A(udata);
14669 -
14670 -       /* In usbdevice_fs, it limits the control buffer to a page,
14671 -        * for simplicity so do we.
14672 -        */
14673 -       if (!uptr || kbulk.len > PAGE_SIZE)
14674 -               return -EINVAL;
14675 -
14676 -       kptr = (void *) __get_free_page(GFP_KERNEL);
14677 -
14678 -       if ((kbulk.ep & 0x80) == 0) {
14679 -               err = -EFAULT;
14680 -               if (copy_from_user(kptr, uptr, kbulk.len))
14681 -                       goto out;
14682 -       }
14683 -
14684 -       kbulk.data = kptr;
14685 -
14686 -       old_fs = get_fs();
14687 -       set_fs(KERNEL_DS);
14688 -       err = sys_ioctl(fd, USBDEVFS_BULK, (unsigned long) &kbulk);
14689 -       set_fs(old_fs);
14690 -
14691 -       if (err >= 0 &&
14692 -           ((kbulk.ep & 0x80) != 0)) {
14693 -               if (copy_to_user(uptr, kptr, kbulk.len))
14694 -                       err = -EFAULT;
14695 -       }
14696 -
14697 -out:
14698 -       free_page((unsigned long) kptr);
14699 -       return err;
14700 -}
14701 -
14702 -/* This needs more work before we can enable it.  Unfortunately
14703 - * because of the fancy asynchronous way URB status/error is written
14704 - * back to userspace, we'll need to fiddle with USB devio internals
14705 - * and/or reimplement entirely the frontend of it ourselves. -DaveM
14706 - *
14707 - * The issue is:
14708 - *
14709 - *     When an URB is submitted via usbdevicefs it is put onto an
14710 - *     asynchronous queue.  When the URB completes, it may be reaped
14711 - *     via another ioctl.  During this reaping the status is written
14712 - *     back to userspace along with the length of the transfer.
14713 - *
14714 - *     We must translate into 64-bit kernel types so we pass in a kernel
14715 - *     space copy of the usbdevfs_urb structure.  This would mean that we
14716 - *     must do something to deal with the async entry reaping.  First we
14717 - *     have to deal somehow with this transitory memory we've allocated.
14718 - *     This is problematic since there are many call sites from which the
14719 - *     async entries can be destroyed (and thus when we'd need to free up
14720 - *     this kernel memory).  One of which is the close() op of usbdevicefs.
14721 - *     To handle that we'd need to make our own file_operations struct which
14722 - *     overrides usbdevicefs's release op with our own which runs usbdevicefs's
14723 - *     real release op then frees up the kernel memory.
14724 - *
14725 - *     But how to keep track of these kernel buffers?  We'd need to either
14726 - *     keep track of them in some table _or_ know about usbdevicefs internals
14727 - *     (ie. the exact layout of its file private, which is actually defined
14728 - *     in linux/usbdevice_fs.h, the layout of the async queues are private to
14729 - *     devio.c)
14730 - *
14731 - * There is one possible other solution I considered, also involving knowledge
14732 - * of usbdevicefs internals:
14733 - *
14734 - *     After an URB is submitted, we "fix up" the address back to the user
14735 - *     space one.  This would work if the status/length fields written back
14736 - *     by the async URB completion lines up perfectly in the 32-bit type with
14737 - *     the 64-bit kernel type.  Unfortunately, it does not because the iso
14738 - *     frame descriptors, at the end of the struct, can be written back.
14739 - *
14740 - * I think we'll just need to simply duplicate the devio URB engine here.
14741 - */
14742 -#if 0
14743 -struct usbdevfs_urb32 {
14744 -       __u8 type;
14745 -       __u8 endpoint;
14746 -       __s32 status;
14747 -       __u32 flags;
14748 -       __u32 buffer;
14749 -       __s32 buffer_length;
14750 -       __s32 actual_length;
14751 -       __s32 start_frame;
14752 -       __s32 number_of_packets;
14753 -       __s32 error_count;
14754 -       __u32 signr;
14755 -       __u32 usercontext; /* unused */
14756 -       struct usbdevfs_iso_packet_desc iso_frame_desc[0];
14757 -};
14758 -
14759 -#define USBDEVFS_SUBMITURB32       _IOR('U', 10, struct usbdevfs_urb32)
14760 -
14761 -static int get_urb32(struct usbdevfs_urb *kurb,
14762 -                    struct usbdevfs_urb32 *uurb)
14763 -{
14764 -       if (get_user(kurb->type, &uurb->type) ||
14765 -           __get_user(kurb->endpoint, &uurb->endpoint) ||
14766 -           __get_user(kurb->status, &uurb->status) ||
14767 -           __get_user(kurb->flags, &uurb->flags) ||
14768 -           __get_user(kurb->buffer_length, &uurb->buffer_length) ||
14769 -           __get_user(kurb->actual_length, &uurb->actual_length) ||
14770 -           __get_user(kurb->start_frame, &uurb->start_frame) ||
14771 -           __get_user(kurb->number_of_packets, &uurb->number_of_packets) ||
14772 -           __get_user(kurb->error_count, &uurb->error_count) ||
14773 -           __get_user(kurb->signr, &uurb->signr))
14774 -               return -EFAULT;
14775 -
14776 -       kurb->usercontext = 0; /* unused currently */
14777 -
14778 -       return 0;
14779 -}
14780 -
14781 -/* Just put back the values which usbdevfs actually changes. */
14782 -static int put_urb32(struct usbdevfs_urb *kurb,
14783 -                    struct usbdevfs_urb32 *uurb)
14784 -{
14785 -       if (put_user(kurb->status, &uurb->status) ||
14786 -           __put_user(kurb->actual_length, &uurb->actual_length) ||
14787 -           __put_user(kurb->error_count, &uurb->error_count))
14788 -               return -EFAULT;
14789 -
14790 -       if (kurb->number_of_packets != 0) {
14791 -               int i;
14792 -
14793 -               for (i = 0; i < kurb->number_of_packets; i++) {
14794 -                       if (__put_user(kurb->iso_frame_desc[i].actual_length,
14795 -                                      &uurb->iso_frame_desc[i].actual_length) ||
14796 -                           __put_user(kurb->iso_frame_desc[i].status,
14797 -                                      &uurb->iso_frame_desc[i].status))
14798 -                               return -EFAULT;
14799 -               }
14800 -       }
14801 -
14802 -       return 0;
14803 -}
14804 -
14805 -static int get_urb32_isoframes(struct usbdevfs_urb *kurb,
14806 -                              struct usbdevfs_urb32 *uurb)
14807 -{
14808 -       unsigned int totlen;
14809 -       int i;
14810 -
14811 -       if (kurb->type != USBDEVFS_URB_TYPE_ISO) {
14812 -               kurb->number_of_packets = 0;
14813 -               return 0;
14814 -       }
14815 -
14816 -       if (kurb->number_of_packets < 1 ||
14817 -           kurb->number_of_packets > 128)
14818 -               return -EINVAL;
14819 -
14820 -       if (copy_from_user(&kurb->iso_frame_desc[0],
14821 -                          &uurb->iso_frame_desc[0],
14822 -                          sizeof(struct usbdevfs_iso_packet_desc) *
14823 -                          kurb->number_of_packets))
14824 -               return -EFAULT;
14825 -
14826 -       totlen = 0;
14827 -       for (i = 0; i < kurb->number_of_packets; i++) {
14828 -               unsigned int this_len;
14829 -
14830 -               this_len = kurb->iso_frame_desc[i].length;
14831 -               if (this_len > 1023)
14832 -                       return -EINVAL;
14833 -
14834 -               totlen += this_len;
14835 -       }
14836 -
14837 -       if (totlen > 32768)
14838 -               return -EINVAL;
14839 -
14840 -       kurb->buffer_length = totlen;
14841 -
14842 -       return 0;
14843 -}
14844 -
14845 -static int do_usbdevfs_urb(unsigned int fd, unsigned int cmd, unsigned long arg)
14846 -{
14847 -       struct usbdevfs_urb *kurb;
14848 -       struct usbdevfs_urb32 *uurb;
14849 -       mm_segment_t old_fs;
14850 -       __u32 udata;
14851 -       void *uptr, *kptr;
14852 -       unsigned int buflen;
14853 -       int err;
14854 -
14855 -       uurb = (struct usbdevfs_urb32 *) arg;
14856 -
14857 -       err = -ENOMEM;
14858 -       kurb = kmalloc(sizeof(struct usbdevfs_urb) +
14859 -                      (sizeof(struct usbdevfs_iso_packet_desc) * 128),
14860 -                      GFP_KERNEL);
14861 -       if (!kurb)
14862 -               goto out;
14863 -
14864 -       err = -EFAULT;
14865 -       if (get_urb32(kurb, uurb))
14866 -               goto out;
14867 -
14868 -       err = get_urb32_isoframes(kurb, uurb);
14869 -       if (err)
14870 -               goto out;
14871 -
14872 -       err = -EFAULT;
14873 -       if (__get_user(udata, &uurb->buffer))
14874 -               goto out;
14875 -       uptr = (void *) A(udata);
14876 -
14877 -       err = -ENOMEM;
14878 -       buflen = kurb->buffer_length;
14879 -       kptr = kmalloc(buflen, GFP_KERNEL);
14880 -       if (!kptr)
14881 -               goto out;
14882 -
14883 -       kurb->buffer = kptr;
14884 -
14885 -       err = -EFAULT;
14886 -       if (copy_from_user(kptr, uptr, buflen))
14887 -               goto out_kptr;
14888 -
14889 -       old_fs = get_fs();
14890 -       set_fs(KERNEL_DS);
14891 -       err = sys_ioctl(fd, USBDEVFS_SUBMITURB, (unsigned long) kurb);
14892 -       set_fs(old_fs);
14893 -
14894 -       if (err >= 0) {
14895 -               /* XXX Shit, this doesn't work for async URBs :-( XXX */
14896 -               if (put_urb32(kurb, uurb)) {
14897 -                       err = -EFAULT;
14898 -               } else if ((kurb->endpoint & USB_DIR_IN) != 0) {
14899 -                       if (copy_to_user(uptr, kptr, buflen))
14900 -                               err = -EFAULT;
14901 -               }
14902 -       }
14903 -
14904 -out_kptr:
14905 -       kfree(kptr);
14906 -
14907 -out:
14908 -       kfree(kurb);
14909 -       return err;
14910 -}
14911 -#endif
14912 -
14913 -#define USBDEVFS_REAPURB32         _IOW('U', 12, u32)
14914 -#define USBDEVFS_REAPURBNDELAY32   _IOW('U', 13, u32)
14915 -
14916 -static int do_usbdevfs_reapurb(unsigned int fd, unsigned int cmd, unsigned long arg)
14917 -{
14918 -       mm_segment_t old_fs;
14919 -       void *kptr;
14920 -       int err;
14921 -
14922 -       old_fs = get_fs();
14923 -       set_fs(KERNEL_DS);
14924 -       err = sys_ioctl(fd,
14925 -                       (cmd == USBDEVFS_REAPURB32 ?
14926 -                        USBDEVFS_REAPURB :
14927 -                        USBDEVFS_REAPURBNDELAY),
14928 -                       (unsigned long) &kptr);
14929 -       set_fs(old_fs);
14930 -
14931 -       if (err >= 0 &&
14932 -           put_user(((u32)(long)kptr), (u32 *) A(arg)))
14933 -               err = -EFAULT;
14934 -
14935 -       return err;
14936 -}
14937 -
14938 -struct usbdevfs_disconnectsignal32 {
14939 -       unsigned int signr;
14940 -       u32 context;
14941 -};
14942 -
14943 -#define USBDEVFS_DISCSIGNAL32      _IOR('U', 14, struct usbdevfs_disconnectsignal32)
14944 -
14945 -static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
14946 -{
14947 -       struct usbdevfs_disconnectsignal kdis;
14948 -       struct usbdevfs_disconnectsignal32 *udis;
14949 -       mm_segment_t old_fs;
14950 -       u32 uctx;
14951 -       int err;
14952 -
14953 -       udis = (struct usbdevfs_disconnectsignal32 *) arg;
14954 -
14955 -       if (get_user(kdis.signr, &udis->signr) ||
14956 -           __get_user(uctx, &udis->context))
14957 -               return -EFAULT;
14958 -
14959 -       kdis.context = (void *) (long)uctx;
14960 -
14961 -       old_fs = get_fs();
14962 -       set_fs(KERNEL_DS);
14963 -       err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
14964 -       set_fs(old_fs);
14965 -
14966 -       return err;
14967 -}
14968  
14969  #define HANDLE_IOCTL(cmd,handler) { cmd, (ioctl_trans_handler_t)handler, 0 },
14970  #define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd,sys_ioctl)
14971 @@ -734,8 +344,6 @@ IOCTL_TABLE_START
14972  COMPATIBLE_IOCTL(TCSBRKP)
14973  COMPATIBLE_IOCTL(TIOCSTART)
14974  COMPATIBLE_IOCTL(TIOCSTOP)
14975 -COMPATIBLE_IOCTL(TIOCGSERIAL)
14976 -COMPATIBLE_IOCTL(TIOCSSERIAL)
14977  COMPATIBLE_IOCTL(TIOCSLTC)
14978  #if 0
14979  COMPATIBLE_IOCTL(FBIOBLANK)
14980 @@ -755,13 +363,6 @@ HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32, d
14981  HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata)
14982  HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata)
14983  
14984 -/* USB devfs */
14985 -HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
14986 -HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
14987 -/*HANDLE_IOCTL(USBDEVFS_SUBMITURB32, do_usbdevfs_urb)*/
14988 -HANDLE_IOCTL(USBDEVFS_REAPURB32, do_usbdevfs_reapurb)
14989 -HANDLE_IOCTL(USBDEVFS_REAPURBNDELAY32, do_usbdevfs_reapurb)
14990 -HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
14991  IOCTL_TABLE_END
14992  
14993  int ioctl_table_size = ARRAY_SIZE(ioctl_start);
14994 --- linux-2.6.0-test6/arch/ppc64/kernel/process.c       2003-09-27 18:57:44.000000000 -0700
14995 +++ 25/arch/ppc64/kernel/process.c      2003-10-05 00:33:23.000000000 -0700
14996 @@ -70,23 +70,6 @@ enable_kernel_fp(void)
14997  #endif /* CONFIG_SMP */
14998  }
14999  
15000 -#ifdef CONFIG_SMP
15001 -static void smp_unlazy_onefpu(void *arg)
15002 -{
15003 -       struct pt_regs *regs = current->thread.regs;
15004 -
15005 -       if (!regs)
15006 -               return;
15007 -       if (regs->msr & MSR_FP)
15008 -               giveup_fpu(current);
15009 -}
15010 -
15011 -void dump_smp_unlazy_fpu(void)
15012 -{
15013 -       smp_call_function(smp_unlazy_onefpu, NULL, 1, 1);
15014 -}
15015 -#endif
15016 -
15017  int dump_task_fpu(struct task_struct *tsk, elf_fpregset_t *fpregs)
15018  {
15019         struct pt_regs *regs = tsk->thread.regs;
15020 --- linux-2.6.0-test6/arch/ppc64/kernel/semaphore.c     2003-09-27 18:57:44.000000000 -0700
15021 +++ 25/arch/ppc64/kernel/semaphore.c    2003-10-05 00:34:19.000000000 -0700
15022 @@ -21,6 +21,7 @@
15023  #include <asm/semaphore.h>
15024  #include <asm/errno.h>
15025  
15026 +#if 0
15027  /*
15028   * Atomically update sem->count.
15029   * This does the equivalent of the following:
15030 @@ -128,3 +129,140 @@ int __down_interruptible(struct semaphor
15031         wake_up(&sem->wait);
15032         return retval;
15033  }
15034 +#else
15035 +
15036 +static __inline__ int atomic_add_negative(int i, atomic_t *v)
15037 +{
15038 +       if (atomic_add_return(i, v) < 0)
15039 +               return 1;
15040 +       else
15041 +               return 0;
15042 +}
15043 +
15044 +void __up(struct semaphore *sem)
15045 +{
15046 +       wake_up(&sem->wait);
15047 +}
15048 +
15049 +void __down(struct semaphore * sem)
15050 +{
15051 +       struct task_struct *tsk = current;
15052 +       DECLARE_WAITQUEUE(wait, tsk);
15053 +       unsigned long flags;
15054 +
15055 +       tsk->state = TASK_UNINTERRUPTIBLE;
15056 +       spin_lock_irqsave(&sem->wait.lock, flags);
15057 +       add_wait_queue_exclusive_locked(&sem->wait, &wait);
15058 +
15059 +       sem->sleepers++;
15060 +       for (;;) {
15061 +               int sleepers = sem->sleepers;
15062 +
15063 +               /*
15064 +                * Add "everybody else" into it. They aren't
15065 +                * playing, because we own the spinlock in
15066 +                * the wait_queue_head.
15067 +                */
15068 +               if (!atomic_add_negative(sleepers - 1, &sem->count)) {
15069 +                       sem->sleepers = 0;
15070 +                       break;
15071 +               }
15072 +               sem->sleepers = 1;      /* us - see -1 above */
15073 +               spin_unlock_irqrestore(&sem->wait.lock, flags);
15074 +
15075 +               schedule();
15076 +
15077 +               spin_lock_irqsave(&sem->wait.lock, flags);
15078 +               tsk->state = TASK_UNINTERRUPTIBLE;
15079 +       }
15080 +       remove_wait_queue_locked(&sem->wait, &wait);
15081 +       wake_up_locked(&sem->wait);
15082 +       spin_unlock_irqrestore(&sem->wait.lock, flags);
15083 +       tsk->state = TASK_RUNNING;
15084 +}
15085 +
15086 +int __down_interruptible(struct semaphore * sem)
15087 +{
15088 +       int retval = 0;
15089 +       struct task_struct *tsk = current;
15090 +       DECLARE_WAITQUEUE(wait, tsk);
15091 +       unsigned long flags;
15092 +
15093 +       tsk->state = TASK_INTERRUPTIBLE;
15094 +       spin_lock_irqsave(&sem->wait.lock, flags);
15095 +       add_wait_queue_exclusive_locked(&sem->wait, &wait);
15096 +
15097 +       sem->sleepers++;
15098 +       for (;;) {
15099 +               int sleepers = sem->sleepers;
15100 +
15101 +               /*
15102 +                * With signals pending, this turns into
15103 +                * the trylock failure case - we won't be
15104 +                * sleeping, and we* can't get the lock as
15105 +                * it has contention. Just correct the count
15106 +                * and exit.
15107 +                */
15108 +               if (signal_pending(current)) {
15109 +                       retval = -EINTR;
15110 +                       sem->sleepers = 0;
15111 +                       atomic_add(sleepers, &sem->count);
15112 +                       break;
15113 +               }
15114 +
15115 +               /*
15116 +                * Add "everybody else" into it. They aren't
15117 +                * playing, because we own the spinlock in
15118 +                * wait_queue_head. The "-1" is because we're
15119 +                * still hoping to get the semaphore.
15120 +                */
15121 +               if (!atomic_add_negative(sleepers - 1, &sem->count)) {
15122 +                       sem->sleepers = 0;
15123 +                       break;
15124 +               }
15125 +               sem->sleepers = 1;      /* us - see -1 above */
15126 +               spin_unlock_irqrestore(&sem->wait.lock, flags);
15127 +
15128 +               schedule();
15129 +
15130 +               spin_lock_irqsave(&sem->wait.lock, flags);
15131 +               tsk->state = TASK_INTERRUPTIBLE;
15132 +       }
15133 +       remove_wait_queue_locked(&sem->wait, &wait);
15134 +       wake_up_locked(&sem->wait);
15135 +       spin_unlock_irqrestore(&sem->wait.lock, flags);
15136 +
15137 +       tsk->state = TASK_RUNNING;
15138 +       return retval;
15139 +}
15140 +
15141 +/*
15142 + * Trylock failed - make sure we correct for
15143 + * having decremented the count.
15144 + *
15145 + * We could have done the trylock with a
15146 + * single "cmpxchg" without failure cases,
15147 + * but then it wouldn't work on a 386.
15148 + */
15149 +int __down_trylock(struct semaphore * sem)
15150 +{
15151 +       int sleepers;
15152 +       unsigned long flags;
15153 +
15154 +       spin_lock_irqsave(&sem->wait.lock, flags);
15155 +       sleepers = sem->sleepers + 1;
15156 +       sem->sleepers = 0;
15157 +
15158 +       /*
15159 +        * Add "everybody else" and us into it. They aren't
15160 +        * playing, because we own the spinlock in the
15161 +        * wait_queue_head.
15162 +        */
15163 +       if (!atomic_add_negative(sleepers, &sem->count)) {
15164 +               wake_up_locked(&sem->wait);
15165 +       }
15166 +
15167 +       spin_unlock_irqrestore(&sem->wait.lock, flags);
15168 +       return 1;
15169 +}
15170 +#endif
15171 --- linux-2.6.0-test6/arch/ppc/boot/ld.script   2003-09-08 13:58:56.000000000 -0700
15172 +++ 25/arch/ppc/boot/ld.script  2003-10-05 00:36:51.000000000 -0700
15173 @@ -82,6 +82,7 @@ SECTIONS
15174      *(__ksymtab)
15175      *(__ksymtab_strings)
15176      *(__bug_table)
15177 +    *(__kcrctab)
15178    }
15179  
15180  }
15181 --- linux-2.6.0-test6/arch/ppc/mm/cachemap.c    2003-09-08 13:58:56.000000000 -0700
15182 +++ 25/arch/ppc/mm/cachemap.c   2003-10-05 00:33:23.000000000 -0700
15183 @@ -101,7 +101,7 @@ void *consistent_alloc(int gfp, size_t s
15184         if (! area)
15185                 goto out;
15186  
15187 -       va = VMALLOC_VMADDR(area->addr);
15188 +       va = (unsigned long) area->addr;
15189  
15190         flags = _PAGE_KERNEL | _PAGE_NO_CACHE;
15191         
15192 --- linux-2.6.0-test6/arch/ppc/mm/pgtable.c     2003-09-27 18:57:43.000000000 -0700
15193 +++ 25/arch/ppc/mm/pgtable.c    2003-10-05 00:33:23.000000000 -0700
15194 @@ -195,7 +195,7 @@ __ioremap(phys_addr_t addr, unsigned lon
15195                 area = get_vm_area(size, VM_IOREMAP);
15196                 if (area == 0)
15197                         return NULL;
15198 -               v = VMALLOC_VMADDR(area->addr);
15199 +               v = (unsigned long) area->addr;
15200         } else {
15201                 v = (ioremap_bot -= size);
15202         }
15203 --- linux-2.6.0-test6/arch/s390/mm/ioremap.c    2003-06-14 12:17:58.000000000 -0700
15204 +++ 25/arch/s390/mm/ioremap.c   2003-10-05 00:33:23.000000000 -0700
15205 @@ -124,7 +124,7 @@ void * __ioremap(unsigned long phys_addr
15206         if (!area)
15207                 return NULL;
15208         addr = area->addr;
15209 -       if (remap_area_pages(VMALLOC_VMADDR(addr), phys_addr, size, flags)) {
15210 +       if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) {
15211                 vfree(addr);
15212                 return NULL;
15213         }
15214 --- linux-2.6.0-test6/arch/sh/mm/init.c 2003-07-27 12:14:38.000000000 -0700
15215 +++ 25/arch/sh/mm/init.c        2003-10-05 00:34:40.000000000 -0700
15216 @@ -51,8 +51,8 @@ unsigned long mmu_context_cache = NO_CON
15217  #endif
15218  
15219  #ifdef CONFIG_DISCONTIGMEM
15220 -pg_data_t discontig_page_data[NR_NODES];
15221 -bootmem_data_t discontig_node_bdata[NR_NODES];
15222 +pg_data_t discontig_page_data[MAX_NUMNODES];
15223 +bootmem_data_t discontig_node_bdata[MAX_NUMNODES];
15224  #endif
15225  
15226  void show_mem(void)
15227 --- linux-2.6.0-test6/arch/sh/mm/ioremap.c      2003-07-02 14:53:14.000000000 -0700
15228 +++ 25/arch/sh/mm/ioremap.c     2003-10-05 00:33:23.000000000 -0700
15229 @@ -149,7 +149,7 @@ void * p3_ioremap(unsigned long phys_add
15230         if (!area)
15231                 return NULL;
15232         addr = area->addr;
15233 -       if (remap_area_pages(VMALLOC_VMADDR(addr), phys_addr, size, flags)) {
15234 +       if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) {
15235                 vfree(addr);
15236                 return NULL;
15237         }
15238 --- linux-2.6.0-test6/arch/sparc64/defconfig    2003-09-27 18:57:44.000000000 -0700
15239 +++ 25/arch/sparc64/defconfig   2003-10-05 00:33:23.000000000 -0700
15240 @@ -571,6 +571,7 @@ CONFIG_BRIDGE_EBT_T_NAT=m
15241  CONFIG_BRIDGE_EBT_802_3=m
15242  CONFIG_BRIDGE_EBT_ARP=m
15243  CONFIG_BRIDGE_EBT_IP=m
15244 +CONFIG_BRIDGE_EBT_LIMIT=m
15245  CONFIG_BRIDGE_EBT_MARK=m
15246  CONFIG_BRIDGE_EBT_PKTTYPE=m
15247  CONFIG_BRIDGE_EBT_STP=m
15248 @@ -665,7 +666,7 @@ CONFIG_TUN=m
15249  # Ethernet (10 or 100Mbit)
15250  #
15251  CONFIG_NET_ETHERNET=y
15252 -# CONFIG_MII is not set
15253 +CONFIG_MII=m
15254  CONFIG_SUNLANCE=y
15255  CONFIG_HAPPYMEAL=y
15256  CONFIG_SUNBMAC=m
15257 @@ -729,15 +730,6 @@ CONFIG_YELLOWFIN=m
15258  CONFIG_R8169=m
15259  # CONFIG_SIS190 is not set
15260  CONFIG_SK98LIN=m
15261 -CONFIG_CONFIG_SK98LIN_T1=y
15262 -CONFIG_CONFIG_SK98LIN_T2=y
15263 -CONFIG_CONFIG_SK98LIN_T3=y
15264 -CONFIG_CONFIG_SK98LIN_T4=y
15265 -CONFIG_CONFIG_SK98LIN_T5=y
15266 -CONFIG_CONFIG_SK98LIN_T6=y
15267 -CONFIG_CONFIG_SK98LIN_T7=y
15268 -CONFIG_CONFIG_SK98LIN_T8=y
15269 -CONFIG_CONFIG_SK98LIN_T9=y
15270  CONFIG_TIGON3=m
15271  
15272  #
15273 @@ -895,6 +887,30 @@ CONFIG_IRDA_FAST_RR=y
15274  # CONFIG_VLSI_FIR is not set
15275  
15276  #
15277 +# Bluetooth support
15278 +#
15279 +CONFIG_BT=m
15280 +CONFIG_BT_L2CAP=m
15281 +CONFIG_BT_SCO=m
15282 +CONFIG_BT_RFCOMM=m
15283 +CONFIG_BT_RFCOMM_TTY=y
15284 +CONFIG_BT_BNEP=m
15285 +CONFIG_BT_BNEP_MC_FILTER=y
15286 +CONFIG_BT_BNEP_PROTO_FILTER=y
15287 +
15288 +#
15289 +# Bluetooth device drivers
15290 +#
15291 +CONFIG_BT_HCIUSB=m
15292 +CONFIG_BT_USB_SCO=y
15293 +# CONFIG_BT_USB_ZERO_PACKET is not set
15294 +CONFIG_BT_HCIUART=m
15295 +CONFIG_BT_HCIUART_H4=y
15296 +CONFIG_BT_HCIUART_BCSP=y
15297 +CONFIG_BT_HCIUART_BCSP_TXCRC=y
15298 +CONFIG_BT_HCIVHCI=m
15299 +
15300 +#
15301  # ISDN subsystem
15302  #
15303  CONFIG_ISDN_BOOL=y
15304 @@ -1517,30 +1533,6 @@ CONFIG_USB_TEST=m
15305  # CONFIG_USB_GADGET is not set
15306  
15307  #
15308 -# Bluetooth support
15309 -#
15310 -CONFIG_BT=m
15311 -CONFIG_BT_L2CAP=m
15312 -CONFIG_BT_SCO=m
15313 -CONFIG_BT_RFCOMM=m
15314 -CONFIG_BT_RFCOMM_TTY=y
15315 -CONFIG_BT_BNEP=m
15316 -CONFIG_BT_BNEP_MC_FILTER=y
15317 -CONFIG_BT_BNEP_PROTO_FILTER=y
15318 -
15319 -#
15320 -# Bluetooth device drivers
15321 -#
15322 -CONFIG_BT_HCIUSB=m
15323 -CONFIG_BT_USB_SCO=y
15324 -# CONFIG_BT_USB_ZERO_PACKET is not set
15325 -CONFIG_BT_HCIUART=m
15326 -CONFIG_BT_HCIUART_H4=y
15327 -CONFIG_BT_HCIUART_BCSP=y
15328 -CONFIG_BT_HCIUART_BCSP_TXCRC=y
15329 -CONFIG_BT_HCIVHCI=m
15330 -
15331 -#
15332  # Watchdog
15333  #
15334  # CONFIG_SOFT_WATCHDOG is not set
15335 --- linux-2.6.0-test6/arch/sparc64/Kconfig      2003-09-27 18:57:44.000000000 -0700
15336 +++ 25/arch/sparc64/Kconfig     2003-10-05 00:36:40.000000000 -0700
15337 @@ -787,12 +787,19 @@ config DEBUG_SPINLOCK
15338           best used in conjunction with the NMI watchdog so that spinlock
15339           deadlocks are also debuggable.
15340  
15341 +config LOCKMETER
15342 +       bool "Kernel lock metering"
15343 +       depends on SMP && !PREEMPT
15344 +       help
15345 +         Say Y to enable kernel lock metering, which adds overhead to SMP locks,
15346 +         but allows you to see various statistics using the lockstat command.
15347 +
15348  # We have a custom atomic_dec_and_lock() implementation but it's not
15349  # compatible with spinlock debugging so we need to fall back on
15350  # the generic version in that case.
15351  config HAVE_DEC_LOCK
15352         bool
15353 -       depends on !DEBUG_SPINLOCK
15354 +       depends on !DEBUG_SPINLOCK && !LOCKMETER
15355         default y
15356  
15357  config DEBUG_SPINLOCK_SLEEP
15358 --- linux-2.6.0-test6/arch/sparc64/kernel/entry.S       2003-09-08 13:58:56.000000000 -0700
15359 +++ 25/arch/sparc64/kernel/entry.S      2003-10-05 00:33:23.000000000 -0700
15360 @@ -26,7 +26,7 @@
15361  
15362  #define curptr      g6
15363  
15364 -#define NR_SYSCALLS 267      /* Each OS is different... */
15365 +#define NR_SYSCALLS 268      /* Each OS is different... */
15366  
15367         .text
15368         .align          32
15369 --- linux-2.6.0-test6/arch/sparc64/kernel/ioctl32.c     2003-09-08 13:58:56.000000000 -0700
15370 +++ 25/arch/sparc64/kernel/ioctl32.c    2003-10-05 00:34:44.000000000 -0700
15371 @@ -985,402 +985,6 @@ static int drm32_res_ctx(unsigned int fd
15372  
15373  #endif
15374  
15375 -/* HERE! */
15376 -
15377 -struct usbdevfs_ctrltransfer32 {
15378 -       __u8 bRequestType;
15379 -       __u8 bRequest;
15380 -       __u16 wValue;
15381 -       __u16 wIndex;
15382 -       __u16 wLength;
15383 -       __u32 timeout;  /* in milliseconds */
15384 -       __u32 data;
15385 -};
15386 -
15387 -#define USBDEVFS_CONTROL32           _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
15388 -
15389 -static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
15390 -{
15391 -       struct usbdevfs_ctrltransfer kctrl;
15392 -       struct usbdevfs_ctrltransfer32 *uctrl;
15393 -       mm_segment_t old_fs;
15394 -       __u32 udata;
15395 -       void __user *uptr;
15396 -       void *kptr;
15397 -       int err;
15398 -
15399 -       uctrl = (struct usbdevfs_ctrltransfer32 *) arg;
15400 -
15401 -       if (copy_from_user(&kctrl, uctrl,
15402 -                          (sizeof(struct usbdevfs_ctrltransfer) -
15403 -                           sizeof(void *))))
15404 -               return -EFAULT;
15405 -
15406 -       if (get_user(udata, &uctrl->data))
15407 -               return -EFAULT;
15408 -       uptr = A(udata);
15409 -
15410 -       /* In usbdevice_fs, it limits the control buffer to a page,
15411 -        * for simplicity so do we.
15412 -        */
15413 -       if (!uptr || kctrl.wLength > PAGE_SIZE)
15414 -               return -EINVAL;
15415 -
15416 -       kptr = (void *)__get_free_page(GFP_KERNEL);
15417 -
15418 -       if ((kctrl.bRequestType & 0x80) == 0) {
15419 -               err = -EFAULT;
15420 -               if (copy_from_user(kptr, uptr, kctrl.wLength))
15421 -                       goto out;
15422 -       }
15423 -
15424 -       kctrl.data = kptr;
15425 -
15426 -       old_fs = get_fs();
15427 -       set_fs(KERNEL_DS);
15428 -       err = sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)&kctrl);
15429 -       set_fs(old_fs);
15430 -
15431 -       if (err >= 0 &&
15432 -           ((kctrl.bRequestType & 0x80) != 0)) {
15433 -               if (copy_to_user(uptr, kptr, kctrl.wLength))
15434 -                       err = -EFAULT;
15435 -       }
15436 -
15437 -out:
15438 -       free_page((unsigned long) kptr);
15439 -       return err;
15440 -}
15441 -
15442 -struct usbdevfs_bulktransfer32 {
15443 -       unsigned int ep;
15444 -       unsigned int len;
15445 -       unsigned int timeout; /* in milliseconds */
15446 -       __u32 data;
15447 -};
15448 -
15449 -#define USBDEVFS_BULK32              _IOWR('U', 2, struct usbdevfs_bulktransfer32)
15450 -
15451 -static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
15452 -{
15453 -       struct usbdevfs_bulktransfer kbulk;
15454 -       struct usbdevfs_bulktransfer32 *ubulk;
15455 -       mm_segment_t old_fs;
15456 -       __u32 udata;
15457 -       void __user *uptr;
15458 -       void *kptr;
15459 -       int err;
15460 -
15461 -       ubulk = (struct usbdevfs_bulktransfer32 *) arg;
15462 -
15463 -       if (get_user(kbulk.ep, &ubulk->ep) ||
15464 -           get_user(kbulk.len, &ubulk->len) ||
15465 -           get_user(kbulk.timeout, &ubulk->timeout) ||
15466 -           get_user(udata, &ubulk->data))
15467 -               return -EFAULT;
15468 -
15469 -       uptr = A(udata);
15470 -
15471 -       /* In usbdevice_fs, it limits the control buffer to a page,
15472 -        * for simplicity so do we.
15473 -        */
15474 -       if (!uptr || kbulk.len > PAGE_SIZE)
15475 -               return -EINVAL;
15476 -
15477 -       kptr = (void *) __get_free_page(GFP_KERNEL);
15478 -
15479 -       if ((kbulk.ep & 0x80) == 0) {
15480 -               err = -EFAULT;
15481 -               if (copy_from_user(kptr, uptr, kbulk.len))
15482 -                       goto out;
15483 -       }
15484 -
15485 -       kbulk.data = kptr;
15486 -
15487 -       old_fs = get_fs();
15488 -       set_fs(KERNEL_DS);
15489 -       err = sys_ioctl(fd, USBDEVFS_BULK, (unsigned long) &kbulk);
15490 -       set_fs(old_fs);
15491 -
15492 -       if (err >= 0 &&
15493 -           ((kbulk.ep & 0x80) != 0)) {
15494 -               if (copy_to_user(uptr, kptr, kbulk.len))
15495 -                       err = -EFAULT;
15496 -       }
15497 -
15498 -out:
15499 -       free_page((unsigned long) kptr);
15500 -       return err;
15501 -}
15502 -
15503 -/* This needs more work before we can enable it.  Unfortunately
15504 - * because of the fancy asynchronous way URB status/error is written
15505 - * back to userspace, we'll need to fiddle with USB devio internals
15506 - * and/or reimplement entirely the frontend of it ourselves. -DaveM
15507 - *
15508 - * The issue is:
15509 - *
15510 - *     When an URB is submitted via usbdevicefs it is put onto an
15511 - *     asynchronous queue.  When the URB completes, it may be reaped
15512 - *     via another ioctl.  During this reaping the status is written
15513 - *     back to userspace along with the length of the transfer.
15514 - *
15515 - *     We must translate into 64-bit kernel types so we pass in a kernel
15516 - *     space copy of the usbdevfs_urb structure.  This would mean that we
15517 - *     must do something to deal with the async entry reaping.  First we
15518 - *     have to deal somehow with this transitory memory we've allocated.
15519 - *     This is problematic since there are many call sites from which the
15520 - *     async entries can be destroyed (and thus when we'd need to free up
15521 - *     this kernel memory).  One of which is the close() op of usbdevicefs.
15522 - *     To handle that we'd need to make our own file_operations struct which
15523 - *     overrides usbdevicefs's release op with our own which runs usbdevicefs's
15524 - *     real release op then frees up the kernel memory.
15525 - *
15526 - *     But how to keep track of these kernel buffers?  We'd need to either
15527 - *     keep track of them in some table _or_ know about usbdevicefs internals
15528 - *     (ie. the exact layout of its file private, which is actually defined
15529 - *     in linux/usbdevice_fs.h, the layout of the async queues are private to
15530 - *     devio.c)
15531 - *
15532 - * There is one possible other solution I considered, also involving knowledge
15533 - * of usbdevicefs internals:
15534 - *
15535 - *     After an URB is submitted, we "fix up" the address back to the user
15536 - *     space one.  This would work if the status/length fields written back
15537 - *     by the async URB completion lines up perfectly in the 32-bit type with
15538 - *     the 64-bit kernel type.  Unfortunately, it does not because the iso
15539 - *     frame descriptors, at the end of the struct, can be written back.
15540 - *
15541 - * I think we'll just need to simply duplicate the devio URB engine here.
15542 - */
15543 -#if 0
15544 -struct usbdevfs_urb32 {
15545 -       __u8 type;
15546 -       __u8 endpoint;
15547 -       __s32 status;
15548 -       __u32 flags;
15549 -       __u32 buffer;
15550 -       __s32 buffer_length;
15551 -       __s32 actual_length;
15552 -       __s32 start_frame;
15553 -       __s32 number_of_packets;
15554 -       __s32 error_count;
15555 -       __u32 signr;
15556 -       __u32 usercontext; /* unused */
15557 -       struct usbdevfs_iso_packet_desc iso_frame_desc[0];
15558 -};
15559 -
15560 -#define USBDEVFS_SUBMITURB32       _IOR('U', 10, struct usbdevfs_urb32)
15561 -
15562 -static int get_urb32(struct usbdevfs_urb *kurb,
15563 -                    struct usbdevfs_urb32 *uurb)
15564 -{
15565 -       if (get_user(kurb->type, &uurb->type) ||
15566 -           __get_user(kurb->endpoint, &uurb->endpoint) ||
15567 -           __get_user(kurb->status, &uurb->status) ||
15568 -           __get_user(kurb->flags, &uurb->flags) ||
15569 -           __get_user(kurb->buffer_length, &uurb->buffer_length) ||
15570 -           __get_user(kurb->actual_length, &uurb->actual_length) ||
15571 -           __get_user(kurb->start_frame, &uurb->start_frame) ||
15572 -           __get_user(kurb->number_of_packets, &uurb->number_of_packets) ||
15573 -           __get_user(kurb->error_count, &uurb->error_count) ||
15574 -           __get_user(kurb->signr, &uurb->signr))
15575 -               return -EFAULT;
15576 -
15577 -       kurb->usercontext = 0; /* unused currently */
15578 -
15579 -       return 0;
15580 -}
15581 -
15582 -/* Just put back the values which usbdevfs actually changes. */
15583 -static int put_urb32(struct usbdevfs_urb *kurb,
15584 -                    struct usbdevfs_urb32 *uurb)
15585 -{
15586 -       if (put_user(kurb->status, &uurb->status) ||
15587 -           __put_user(kurb->actual_length, &uurb->actual_length) ||
15588 -           __put_user(kurb->error_count, &uurb->error_count))
15589 -               return -EFAULT;
15590 -
15591 -       if (kurb->number_of_packets != 0) {
15592 -               int i;
15593 -
15594 -               for (i = 0; i < kurb->number_of_packets; i++) {
15595 -                       if (__put_user(kurb->iso_frame_desc[i].actual_length,
15596 -                                      &uurb->iso_frame_desc[i].actual_length) ||
15597 -                           __put_user(kurb->iso_frame_desc[i].status,
15598 -                                      &uurb->iso_frame_desc[i].status))
15599 -                               return -EFAULT;
15600 -               }
15601 -       }
15602 -
15603 -       return 0;
15604 -}
15605 -
15606 -static int get_urb32_isoframes(struct usbdevfs_urb *kurb,
15607 -                              struct usbdevfs_urb32 *uurb)
15608 -{
15609 -       unsigned int totlen;
15610 -       int i;
15611 -
15612 -       if (kurb->type != USBDEVFS_URB_TYPE_ISO) {
15613 -               kurb->number_of_packets = 0;
15614 -               return 0;
15615 -       }
15616 -
15617 -       if (kurb->number_of_packets < 1 ||
15618 -           kurb->number_of_packets > 128)
15619 -               return -EINVAL;
15620 -
15621 -       if (copy_from_user(&kurb->iso_frame_desc[0],
15622 -                          &uurb->iso_frame_desc[0],
15623 -                          sizeof(struct usbdevfs_iso_packet_desc) *
15624 -                          kurb->number_of_packets))
15625 -               return -EFAULT;
15626 -
15627 -       totlen = 0;
15628 -       for (i = 0; i < kurb->number_of_packets; i++) {
15629 -               unsigned int this_len;
15630 -
15631 -               this_len = kurb->iso_frame_desc[i].length;
15632 -               if (this_len > 1023)
15633 -                       return -EINVAL;
15634 -
15635 -               totlen += this_len;
15636 -       }
15637 -
15638 -       if (totlen > 32768)
15639 -               return -EINVAL;
15640 -
15641 -       kurb->buffer_length = totlen;
15642 -
15643 -       return 0;
15644 -}
15645 -
15646 -static int do_usbdevfs_urb(unsigned int fd, unsigned int cmd, unsigned long arg)
15647 -{
15648 -       struct usbdevfs_urb *kurb;
15649 -       struct usbdevfs_urb32 *uurb;
15650 -       mm_segment_t old_fs;
15651 -       __u32 udata;
15652 -       void __user *uptr;
15653 -       void *kptr;
15654 -       unsigned int buflen;
15655 -       int err;
15656 -
15657 -       uurb = (struct usbdevfs_urb32 *) arg;
15658 -
15659 -       err = -ENOMEM;
15660 -       kurb = kmalloc(sizeof(struct usbdevfs_urb) +
15661 -                      (sizeof(struct usbdevfs_iso_packet_desc) * 128),
15662 -                      GFP_KERNEL);
15663 -       if (!kurb)
15664 -               goto out;
15665 -
15666 -       err = -EFAULT;
15667 -       if (get_urb32(kurb, uurb))
15668 -               goto out;
15669 -
15670 -       err = get_urb32_isoframes(kurb, uurb);
15671 -       if (err)
15672 -               goto out;
15673 -
15674 -       err = -EFAULT;
15675 -       if (__get_user(udata, &uurb->buffer))
15676 -               goto out;
15677 -       uptr = A(udata);
15678 -
15679 -       err = -ENOMEM;
15680 -       buflen = kurb->buffer_length;
15681 -       kptr = kmalloc(buflen, GFP_KERNEL);
15682 -       if (!kptr)
15683 -               goto out;
15684 -
15685 -       kurb->buffer = kptr;
15686 -
15687 -       err = -EFAULT;
15688 -       if (copy_from_user(kptr, uptr, buflen))
15689 -               goto out_kptr;
15690 -
15691 -       old_fs = get_fs();
15692 -       set_fs(KERNEL_DS);
15693 -       err = sys_ioctl(fd, USBDEVFS_SUBMITURB, (unsigned long) kurb);
15694 -       set_fs(old_fs);
15695 -
15696 -       if (err >= 0) {
15697 -               /* XXX Shit, this doesn't work for async URBs :-( XXX */
15698 -               if (put_urb32(kurb, uurb)) {
15699 -                       err = -EFAULT;
15700 -               } else if ((kurb->endpoint & USB_DIR_IN) != 0) {
15701 -                       if (copy_to_user(uptr, kptr, buflen))
15702 -                               err = -EFAULT;
15703 -               }
15704 -       }
15705 -
15706 -out_kptr:
15707 -       kfree(kptr);
15708 -
15709 -out:
15710 -       kfree(kurb);
15711 -       return err;
15712 -}
15713 -#endif
15714 -
15715 -#define USBDEVFS_REAPURB32         _IOW('U', 12, u32)
15716 -#define USBDEVFS_REAPURBNDELAY32   _IOW('U', 13, u32)
15717 -
15718 -static int do_usbdevfs_reapurb(unsigned int fd, unsigned int cmd, unsigned long arg)
15719 -{
15720 -       mm_segment_t old_fs;
15721 -       void *kptr;
15722 -       int err;
15723 -
15724 -       old_fs = get_fs();
15725 -       set_fs(KERNEL_DS);
15726 -       err = sys_ioctl(fd,
15727 -                       (cmd == USBDEVFS_REAPURB32 ?
15728 -                        USBDEVFS_REAPURB :
15729 -                        USBDEVFS_REAPURBNDELAY),
15730 -                       (unsigned long) &kptr);
15731 -       set_fs(old_fs);
15732 -
15733 -       if (err >= 0 &&
15734 -           put_user(((u32)(long)kptr), (u32 __user *) A(arg)))
15735 -               err = -EFAULT;
15736 -
15737 -       return err;
15738 -}
15739 -
15740 -struct usbdevfs_disconnectsignal32 {
15741 -       unsigned int signr;
15742 -       u32 context;
15743 -};
15744 -
15745 -#define USBDEVFS_DISCSIGNAL32      _IOR('U', 14, struct usbdevfs_disconnectsignal32)
15746 -
15747 -static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
15748 -{
15749 -       struct usbdevfs_disconnectsignal kdis;
15750 -       struct usbdevfs_disconnectsignal32 *udis;
15751 -       mm_segment_t old_fs;
15752 -       u32 uctx;
15753 -       int err;
15754 -
15755 -       udis = (struct usbdevfs_disconnectsignal32 *) arg;
15756 -
15757 -       if (get_user(kdis.signr, &udis->signr) ||
15758 -           __get_user(uctx, &udis->context))
15759 -               return -EFAULT;
15760 -
15761 -       kdis.context = (void *) (long)uctx;
15762 -
15763 -       old_fs = get_fs();
15764 -       set_fs(KERNEL_DS);
15765 -       err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
15766 -       set_fs(old_fs);
15767 -
15768 -       return err;
15769 -}
15770 -
15771  typedef int (* ioctl32_handler_t)(unsigned int, unsigned int, unsigned long, struct file *);
15772  
15773  #define COMPATIBLE_IOCTL(cmd)          HANDLE_IOCTL((cmd),sys_ioctl)
15774 @@ -1397,8 +1001,6 @@ IOCTL_TABLE_START
15775  COMPATIBLE_IOCTL(TCSBRKP)
15776  COMPATIBLE_IOCTL(TIOCSTART)
15777  COMPATIBLE_IOCTL(TIOCSTOP)
15778 -COMPATIBLE_IOCTL(TIOCGSERIAL)
15779 -COMPATIBLE_IOCTL(TIOCSSERIAL)
15780  COMPATIBLE_IOCTL(TIOCSLTC)
15781  COMPATIBLE_IOCTL(FBIOGTYPE)
15782  COMPATIBLE_IOCTL(FBIOSATTR)
15783 @@ -1467,9 +1069,6 @@ COMPATIBLE_IOCTL(AUDIO_GETDEV)
15784  COMPATIBLE_IOCTL(AUDIO_GETDEV_SUNOS)
15785  COMPATIBLE_IOCTL(AUDIO_FLUSH)
15786  COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI)
15787 -/* Raw devices */
15788 -COMPATIBLE_IOCTL(RAW_SETBIND)
15789 -COMPATIBLE_IOCTL(RAW_GETBIND)
15790  /* NCP ioctls which do not need any translations */
15791  COMPATIBLE_IOCTL(NCP_IOC_CONN_LOGGED_IN)
15792  COMPATIBLE_IOCTL(NCP_IOC_SIGN_INIT)
15793 @@ -1575,12 +1174,6 @@ HANDLE_IOCTL(RTC32_IRQP_SET, do_rtc_ioct
15794  HANDLE_IOCTL(RTC32_EPOCH_READ, do_rtc_ioctl)
15795  HANDLE_IOCTL(RTC32_EPOCH_SET, do_rtc_ioctl)
15796  #endif
15797 -HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
15798 -HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
15799 -/*HANDLE_IOCTL(USBDEVFS_SUBMITURB32, do_usbdevfs_urb)*/
15800 -HANDLE_IOCTL(USBDEVFS_REAPURB32, do_usbdevfs_reapurb)
15801 -HANDLE_IOCTL(USBDEVFS_REAPURBNDELAY32, do_usbdevfs_reapurb)
15802 -HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
15803  /* take care of sizeof(sizeof()) breakage */
15804  IOCTL_TABLE_END
15805  
15806 --- linux-2.6.0-test6/arch/sparc64/kernel/module.c      2003-09-27 18:57:44.000000000 -0700
15807 +++ 25/arch/sparc64/kernel/module.c     2003-10-05 00:33:23.000000000 -0700
15808 @@ -14,6 +14,9 @@
15809  #include <linux/vmalloc.h>
15810  #include <linux/mm.h>
15811  
15812 +#include <asm/processor.h>
15813 +#include <asm/spitfire.h>
15814 +
15815  static struct vm_struct * modvmlist = NULL;
15816  
15817  static void module_unmap(void * addr)
15818 @@ -279,6 +282,16 @@ int module_finalize(const Elf_Ehdr *hdr,
15819                     const Elf_Shdr *sechdrs,
15820                     struct module *me)
15821  {
15822 +       /* Cheetah's I-cache is fully coherent.  */
15823 +       if (tlb_type == spitfire) {
15824 +               unsigned long va;
15825 +
15826 +               flushw_all();
15827 +               for (va =  0; va < (PAGE_SIZE << 1); va += 32)
15828 +                       spitfire_put_icache_tag(va, 0x0);
15829 +               __asm__ __volatile__("flush %g6");
15830 +       }
15831 +
15832         return 0;
15833  }
15834  
15835 --- linux-2.6.0-test6/arch/sparc64/kernel/smp.c 2003-08-22 19:23:40.000000000 -0700
15836 +++ 25/arch/sparc64/kernel/smp.c        2003-10-05 00:33:23.000000000 -0700
15837 @@ -118,7 +118,6 @@ void __init smp_callin(void)
15838  
15839         inherit_locked_prom_mappings(0);
15840  
15841 -       __flush_cache_all();
15842         __flush_tlb_all();
15843  
15844         smp_setup_percpu_timer();
15845 @@ -661,7 +660,6 @@ extern unsigned long xcall_flush_tlb_ran
15846  extern unsigned long xcall_flush_tlb_kernel_range;
15847  extern unsigned long xcall_flush_tlb_all_spitfire;
15848  extern unsigned long xcall_flush_tlb_all_cheetah;
15849 -extern unsigned long xcall_flush_cache_all_spitfire;
15850  extern unsigned long xcall_report_regs;
15851  extern unsigned long xcall_receive_signal;
15852  extern unsigned long xcall_flush_dcache_page_cheetah;
15853 @@ -776,15 +774,6 @@ void smp_report_regs(void)
15854         smp_cross_call(&xcall_report_regs, 0, 0, 0);
15855  }
15856  
15857 -void smp_flush_cache_all(void)
15858 -{
15859 -       /* Cheetah need do nothing. */
15860 -       if (tlb_type == spitfire) {
15861 -               smp_cross_call(&xcall_flush_cache_all_spitfire, 0, 0, 0);
15862 -               __flush_cache_all();
15863 -       }
15864 -}
15865 -
15866  void smp_flush_tlb_all(void)
15867  {
15868         if (tlb_type == spitfire)
15869 --- linux-2.6.0-test6/arch/sparc64/kernel/systbls.S     2003-09-08 13:58:56.000000000 -0700
15870 +++ 25/arch/sparc64/kernel/systbls.S    2003-10-05 00:33:23.000000000 -0700
15871 @@ -72,7 +72,7 @@ sys_call_table32:
15872  /*250*/        .word sys32_mremap, sys32_sysctl, sys_getsid, sys_fdatasync, sys32_nfsservctl
15873         .word sys_ni_syscall, compat_clock_settime, compat_clock_gettime, compat_clock_getres, compat_clock_nanosleep
15874  /*260*/        .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, compat_timer_settime, compat_timer_gettime, sys_timer_getoverrun
15875 -       .word sys_timer_delete, sys32_timer_create, sys_ni_syscall
15876 +       .word sys_timer_delete, sys32_timer_create, sys_ni_syscall, sys_ni_syscall
15877  
15878         /* Now the 64-bit native Linux syscall table. */
15879  
15880 @@ -133,7 +133,7 @@ sys_call_table:
15881  /*250*/        .word sys64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
15882         .word sys_ni_syscall, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
15883  /*260*/        .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
15884 -       .word sys_timer_delete, sys_timer_create, sys_ni_syscall
15885 +       .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_ni_syscall
15886  
15887  #if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
15888      defined(CONFIG_SOLARIS_EMUL_MODULE)
15889 @@ -233,5 +233,6 @@ sunos_sys_table:
15890         .word sunos_nosys, sunos_nosys, sunos_nosys
15891         .word sunos_nosys, sunos_nosys, sunos_nosys
15892         .word sunos_nosys, sunos_nosys, sunos_nosys
15893 +       .word sunos_nosys
15894  
15895  #endif
15896 --- linux-2.6.0-test6/arch/sparc64/lib/rwlock.S 2003-06-26 22:07:24.000000000 -0700
15897 +++ 25/arch/sparc64/lib/rwlock.S        2003-10-05 00:36:40.000000000 -0700
15898 @@ -63,5 +63,33 @@ __write_lock: /* %o0 = lock_ptr */
15899         be,pt           %icc, 99b
15900          membar         #StoreLoad | #StoreStore
15901         ba,a,pt         %xcc, 1b
15902 +
15903 +       .globl  __read_trylock
15904 +__read_trylock: /* %o0 = lock_ptr */
15905 +       ldsw            [%o0], %g5
15906 +       brlz,pn         %g5, 100f
15907 +        add            %g5, 1, %g7
15908 +       cas             [%o0], %g5, %g7
15909 +       cmp             %g5, %g7
15910 +       bne,pn          %icc, __read_trylock
15911 +        membar         #StoreLoad | #StoreStore
15912 +       retl
15913 +        mov            1, %o0
15914 +
15915 +       .globl          __write_trylock
15916 +__write_trylock: /* %o0 = lock_ptr */
15917 +       sethi           %hi(0x80000000), %g2
15918 +1:     lduw            [%o0], %g5
15919 +4:     brnz,pn         %g5, 100f
15920 +        or             %g5, %g2, %g7
15921 +       cas             [%o0], %g5, %g7
15922 +       cmp             %g5, %g7
15923 +       bne,pn          %icc, 1b
15924 +        membar         #StoreLoad | #StoreStore
15925 +       retl
15926 +        mov            1, %o0
15927 +100:   retl
15928 +        mov            0, %o0
15929 +
15930  rwlock_impl_end:
15931  
15932 --- linux-2.6.0-test6/arch/sparc64/mm/init.c    2003-09-27 18:57:44.000000000 -0700
15933 +++ 25/arch/sparc64/mm/init.c   2003-10-05 00:33:23.000000000 -0700
15934 @@ -1025,19 +1025,6 @@ void __flush_dcache_range(unsigned long 
15935         }
15936  }
15937  
15938 -void __flush_cache_all(void)
15939 -{
15940 -       /* Cheetah should be fine here too. */
15941 -       if (tlb_type == spitfire) {
15942 -               unsigned long va;
15943 -
15944 -               flushw_all();
15945 -               for (va =  0; va < (PAGE_SIZE << 1); va += 32)
15946 -                       spitfire_put_icache_tag(va, 0x0);
15947 -               __asm__ __volatile__("flush %g6");
15948 -       }
15949 -}
15950 -
15951  /* If not locked, zap it. */
15952  void __flush_tlb_all(void)
15953  {
15954 --- linux-2.6.0-test6/arch/sparc64/mm/ultra.S   2003-06-14 12:18:28.000000000 -0700
15955 +++ 25/arch/sparc64/mm/ultra.S  2003-10-05 00:33:23.000000000 -0700
15956 @@ -721,20 +721,6 @@ xcall_flush_tlb_all_cheetah:
15957         stxa            %g0, [%g2] ASI_IMMU_DEMAP
15958         retry
15959  
15960 -       .globl          xcall_flush_cache_all_spitfire
15961 -xcall_flush_cache_all_spitfire:
15962 -       sethi           %hi(16383), %g2
15963 -       or              %g2, %lo(16383), %g2
15964 -       clr             %g3
15965 -1:     stxa            %g0, [%g3] ASI_IC_TAG
15966 -       membar          #Sync
15967 -       add             %g3, 32, %g3
15968 -       cmp             %g3, %g2
15969 -       bleu,pt         %xcc, 1b
15970 -        nop
15971 -       flush           %g6
15972 -       retry
15973 -
15974         /* These just get rescheduled to PIL vectors. */
15975         .globl          xcall_call_function
15976  xcall_call_function:
15977 --- linux-2.6.0-test6/arch/sparc/kernel/entry.S 2003-09-08 13:58:56.000000000 -0700
15978 +++ 25/arch/sparc/kernel/entry.S        2003-10-05 00:33:23.000000000 -0700
15979 @@ -38,7 +38,7 @@
15980  
15981  #define curptr      g6
15982  
15983 -#define NR_SYSCALLS 267      /* Each OS is different... */
15984 +#define NR_SYSCALLS 268      /* Each OS is different... */
15985  
15986  /* These are just handy. */
15987  #define _SV    save    %sp, -STACKFRAME_SZ, %sp
15988 --- linux-2.6.0-test6/arch/sparc/kernel/systbls.S       2003-09-08 13:58:56.000000000 -0700
15989 +++ 25/arch/sparc/kernel/systbls.S      2003-10-05 00:33:23.000000000 -0700
15990 @@ -72,7 +72,7 @@ sys_call_table:
15991  /*250*/        .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
15992  /*255*/        .long sys_nis_syscall, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
15993  /*260*/        .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
15994 -/*265*/        .long sys_timer_delete, sys_timer_create, sys_nis_syscall
15995 +/*265*/        .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_nis_syscall
15996  
15997  #ifdef CONFIG_SUNOS_EMUL
15998         /* Now the SunOS syscall table. */
15999 @@ -171,6 +171,6 @@ sunos_sys_table:
16000         .long sunos_nosys
16001  /*260*/        .long sunos_nosys, sunos_nosys, sunos_nosys
16002         .long sunos_nosys, sunos_nosys, sunos_nosys
16003 -       .long sunos_nosys, sunos_nosys
16004 +       .long sunos_nosys, sunos_nosys, sunos_nosys
16005  
16006  #endif
16007 --- linux-2.6.0-test6/arch/sparc/kernel/time.c  2003-07-13 21:44:34.000000000 -0700
16008 +++ 25/arch/sparc/kernel/time.c 2003-10-05 00:36:33.000000000 -0700
16009 @@ -617,3 +617,12 @@ static int set_rtc_mmss(unsigned long no
16010                 return -1;
16011         }
16012  }
16013 +
16014 +/*
16015 + * Returns nanoseconds
16016 +  */
16017 +
16018 +unsigned long long sched_clock(void)
16019 +{
16020 +       return (unsigned long long)jiffies * (1000000000 / HZ);
16021 +}
16022 --- linux-2.6.0-test6/arch/um/config.release    2003-08-08 22:55:11.000000000 -0700
16023 +++ 25/arch/um/config.release   2003-10-05 00:34:32.000000000 -0700
16024 @@ -228,7 +228,6 @@ CONFIG_ROMFS_FS=m
16025  CONFIG_EXT2_FS=y
16026  CONFIG_SYSV_FS=m
16027  CONFIG_UDF_FS=m
16028 -# CONFIG_UDF_RW is not set
16029  CONFIG_UFS_FS=m
16030  # CONFIG_UFS_FS_WRITE is not set
16031  
16032 --- linux-2.6.0-test6/arch/um/defconfig 2003-08-08 22:55:11.000000000 -0700
16033 +++ 25/arch/um/defconfig        2003-10-05 00:34:32.000000000 -0700
16034 @@ -3,29 +3,19 @@
16035  #
16036  CONFIG_USERMODE=y
16037  CONFIG_MMU=y
16038 -CONFIG_SWAP=y
16039  CONFIG_UID16=y
16040  CONFIG_RWSEM_GENERIC_SPINLOCK=y
16041 -CONFIG_CONFIG_LOG_BUF_SHIFT=14
16042 -
16043 -#
16044 -# Code maturity level options
16045 -#
16046 -CONFIG_EXPERIMENTAL=y
16047  
16048  #
16049 -# General Setup
16050 +# UML-specific options
16051  #
16052  CONFIG_MODE_TT=y
16053  CONFIG_MODE_SKAS=y
16054  CONFIG_NET=y
16055 -CONFIG_SYSVIPC=y
16056 -CONFIG_BSD_PROCESS_ACCT=y
16057 -CONFIG_SYSCTL=y
16058 -CONFIG_BINFMT_AOUT=y
16059  CONFIG_BINFMT_ELF=y
16060  CONFIG_BINFMT_MISC=y
16061  CONFIG_HOSTFS=y
16062 +CONFIG_HPPFS=y
16063  CONFIG_MCONSOLE=y
16064  CONFIG_MAGIC_SYSRQ=y
16065  # CONFIG_HOST_2G_2G is not set
16066 @@ -38,10 +28,38 @@ CONFIG_PROC_MM=y
16067  CONFIG_KERNEL_STACK_ORDER=2
16068  
16069  #
16070 +# Code maturity level options
16071 +#
16072 +CONFIG_EXPERIMENTAL=y
16073 +CONFIG_CLEAN_COMPILE=y
16074 +CONFIG_STANDALONE=y
16075 +CONFIG_BROKEN_ON_SMP=y
16076 +
16077 +#
16078 +# General setup
16079 +#
16080 +CONFIG_SWAP=y
16081 +CONFIG_SYSVIPC=y
16082 +CONFIG_BSD_PROCESS_ACCT=y
16083 +CONFIG_SYSCTL=y
16084 +CONFIG_LOG_BUF_SHIFT=14
16085 +# CONFIG_IKCONFIG is not set
16086 +# CONFIG_EMBEDDED is not set
16087 +CONFIG_KALLSYMS=y
16088 +CONFIG_FUTEX=y
16089 +CONFIG_EPOLL=y
16090 +CONFIG_IOSCHED_NOOP=y
16091 +CONFIG_IOSCHED_AS=y
16092 +CONFIG_IOSCHED_DEADLINE=y
16093 +
16094 +#
16095  # Loadable module support
16096  #
16097 -CONFIG_MODULES=y
16098 -# CONFIG_KMOD is not set
16099 +# CONFIG_MODULES is not set
16100 +
16101 +#
16102 +# Generic Driver Options
16103 +#
16104  
16105  #
16106  # Character Devices
16107 @@ -69,6 +87,7 @@ CONFIG_HOSTAUDIO=y
16108  #
16109  CONFIG_BLK_DEV_UBD=y
16110  # CONFIG_BLK_DEV_UBD_SYNC is not set
16111 +CONFIG_BLK_DEV_COW_COMMON=y
16112  CONFIG_BLK_DEV_LOOP=y
16113  CONFIG_BLK_DEV_NBD=y
16114  CONFIG_BLK_DEV_RAM=y
16115 @@ -78,7 +97,7 @@ CONFIG_BLK_DEV_INITRD=y
16116  CONFIG_NETDEVICES=y
16117  
16118  #
16119 -# Network Devices
16120 +# UML Network Devices
16121  #
16122  CONFIG_UML_NET=y
16123  CONFIG_UML_NET_ETHERTAP=y
16124 @@ -88,22 +107,6 @@ CONFIG_UML_NET_DAEMON=y
16125  CONFIG_UML_NET_MCAST=y
16126  # CONFIG_UML_NET_PCAP is not set
16127  CONFIG_UML_NET_SLIRP=y
16128 -CONFIG_DUMMY=y
16129 -# CONFIG_BONDING is not set
16130 -# CONFIG_EQUALIZER is not set
16131 -CONFIG_TUN=y
16132 -# CONFIG_ETHERTAP is not set
16133 -CONFIG_PPP=y
16134 -# CONFIG_PPP_MULTILINK is not set
16135 -# CONFIG_PPP_ASYNC is not set
16136 -# CONFIG_PPP_SYNC_TTY is not set
16137 -# CONFIG_PPP_DEFLATE is not set
16138 -# CONFIG_PPP_BSDCOMP is not set
16139 -# CONFIG_PPPOE is not set
16140 -CONFIG_SLIP=y
16141 -# CONFIG_SLIP_COMPRESSED is not set
16142 -# CONFIG_SLIP_SMART is not set
16143 -# CONFIG_SLIP_MODE_SLIP6 is not set
16144  
16145  #
16146  # Networking support
16147 @@ -115,8 +118,6 @@ CONFIG_SLIP=y
16148  CONFIG_PACKET=y
16149  CONFIG_PACKET_MMAP=y
16150  # CONFIG_NETLINK_DEV is not set
16151 -# CONFIG_NETFILTER is not set
16152 -# CONFIG_FILTER is not set
16153  CONFIG_UNIX=y
16154  # CONFIG_NET_KEY is not set
16155  CONFIG_INET=y
16156 @@ -130,8 +131,11 @@ CONFIG_INET=y
16157  # CONFIG_SYN_COOKIES is not set
16158  # CONFIG_INET_AH is not set
16159  # CONFIG_INET_ESP is not set
16160 -# CONFIG_XFRM_USER is not set
16161 +# CONFIG_INET_IPCOMP is not set
16162  # CONFIG_IPV6 is not set
16163 +# CONFIG_DECNET is not set
16164 +# CONFIG_BRIDGE is not set
16165 +# CONFIG_NETFILTER is not set
16166  
16167  #
16168  # SCTP Configuration (EXPERIMENTAL)
16169 @@ -141,8 +145,6 @@ CONFIG_IPV6_SCTP__=y
16170  # CONFIG_ATM is not set
16171  # CONFIG_VLAN_8021Q is not set
16172  # CONFIG_LLC is not set
16173 -# CONFIG_DECNET is not set
16174 -# CONFIG_BRIDGE is not set
16175  # CONFIG_X25 is not set
16176  # CONFIG_LAPB is not set
16177  # CONFIG_NET_DIVERT is not set
16178 @@ -160,6 +162,10 @@ CONFIG_IPV6_SCTP__=y
16179  # Network testing
16180  #
16181  # CONFIG_NET_PKTGEN is not set
16182 +CONFIG_DUMMY=y
16183 +# CONFIG_BONDING is not set
16184 +# CONFIG_EQUALIZER is not set
16185 +CONFIG_TUN=y
16186  
16187  #
16188  # Ethernet (10 or 100Mbit)
16189 @@ -171,6 +177,22 @@ CONFIG_IPV6_SCTP__=y
16190  #
16191  
16192  #
16193 +# Ethernet (10000 Mbit)
16194 +#
16195 +CONFIG_PPP=y
16196 +# CONFIG_PPP_MULTILINK is not set
16197 +# CONFIG_PPP_FILTER is not set
16198 +# CONFIG_PPP_ASYNC is not set
16199 +# CONFIG_PPP_SYNC_TTY is not set
16200 +# CONFIG_PPP_DEFLATE is not set
16201 +# CONFIG_PPP_BSDCOMP is not set
16202 +# CONFIG_PPPOE is not set
16203 +CONFIG_SLIP=y
16204 +# CONFIG_SLIP_COMPRESSED is not set
16205 +# CONFIG_SLIP_SMART is not set
16206 +# CONFIG_SLIP_MODE_SLIP6 is not set
16207 +
16208 +#
16209  # Wireless LAN (non-hamradio)
16210  #
16211  # CONFIG_NET_RADIO is not set
16212 @@ -188,66 +210,82 @@ CONFIG_IPV6_SCTP__=y
16213  #
16214  # File systems
16215  #
16216 +CONFIG_EXT2_FS=y
16217 +# CONFIG_EXT2_FS_XATTR is not set
16218 +# CONFIG_EXT3_FS is not set
16219 +# CONFIG_JBD is not set
16220 +CONFIG_REISERFS_FS=y
16221 +# CONFIG_REISERFS_CHECK is not set
16222 +# CONFIG_REISERFS_PROC_INFO is not set
16223 +# CONFIG_JFS_FS is not set
16224 +# CONFIG_XFS_FS is not set
16225 +CONFIG_MINIX_FS=y
16226 +# CONFIG_ROMFS_FS is not set
16227  CONFIG_QUOTA=y
16228  # CONFIG_QFMT_V1 is not set
16229  # CONFIG_QFMT_V2 is not set
16230  CONFIG_QUOTACTL=y
16231 -CONFIG_AUTOFS_FS=m
16232 -CONFIG_AUTOFS4_FS=m
16233 -CONFIG_REISERFS_FS=m
16234 -# CONFIG_REISERFS_CHECK is not set
16235 -# CONFIG_REISERFS_PROC_INFO is not set
16236 +CONFIG_AUTOFS_FS=y
16237 +CONFIG_AUTOFS4_FS=y
16238 +
16239 +#
16240 +# CD-ROM/DVD Filesystems
16241 +#
16242 +CONFIG_ISO9660_FS=y
16243 +# CONFIG_JOLIET is not set
16244 +# CONFIG_ZISOFS is not set
16245 +# CONFIG_UDF_FS is not set
16246 +
16247 +#
16248 +# DOS/FAT/NT Filesystems
16249 +#
16250 +CONFIG_FAT_FS=y
16251 +CONFIG_MSDOS_FS=y
16252 +CONFIG_VFAT_FS=y
16253 +# CONFIG_NTFS_FS is not set
16254 +
16255 +#
16256 +# Pseudo filesystems
16257 +#
16258 +CONFIG_PROC_FS=y
16259 +CONFIG_DEVFS_FS=y
16260 +CONFIG_DEVFS_MOUNT=y
16261 +# CONFIG_DEVFS_DEBUG is not set
16262 +CONFIG_DEVPTS_FS=y
16263 +# CONFIG_DEVPTS_FS_XATTR is not set
16264 +# CONFIG_TMPFS is not set
16265 +CONFIG_RAMFS=y
16266 +
16267 +#
16268 +# Miscellaneous filesystems
16269 +#
16270  # CONFIG_ADFS_FS is not set
16271  # CONFIG_AFFS_FS is not set
16272  # CONFIG_HFS_FS is not set
16273  # CONFIG_BEFS_FS is not set
16274  # CONFIG_BFS_FS is not set
16275 -# CONFIG_EXT3_FS is not set
16276 -# CONFIG_JBD is not set
16277 -CONFIG_FAT_FS=m
16278 -CONFIG_MSDOS_FS=m
16279 -CONFIG_VFAT_FS=m
16280  # CONFIG_EFS_FS is not set
16281  CONFIG_JFFS_FS=y
16282  CONFIG_JFFS_FS_VERBOSE=0
16283 -CONFIG_JFFS_PROC_FS=y
16284  # CONFIG_JFFS2_FS is not set
16285  # CONFIG_CRAMFS is not set
16286 -# CONFIG_TMPFS is not set
16287 -CONFIG_RAMFS=y
16288 -CONFIG_ISO9660_FS=m
16289 -# CONFIG_JOLIET is not set
16290 -# CONFIG_ZISOFS is not set
16291 -# CONFIG_JFS_FS is not set
16292 -CONFIG_MINIX_FS=m
16293  # CONFIG_VXFS_FS is not set
16294 -# CONFIG_NTFS_FS is not set
16295  # CONFIG_HPFS_FS is not set
16296 -CONFIG_PROC_FS=y
16297 -CONFIG_DEVFS_FS=y
16298 -CONFIG_DEVFS_MOUNT=y
16299 -# CONFIG_DEVFS_DEBUG is not set
16300 -CONFIG_DEVPTS_FS=y
16301  # CONFIG_QNX4FS_FS is not set
16302 -# CONFIG_ROMFS_FS is not set
16303 -CONFIG_EXT2_FS=y
16304 -# CONFIG_EXT2_FS_XATTR is not set
16305  # CONFIG_SYSV_FS is not set
16306 -# CONFIG_UDF_FS is not set
16307  # CONFIG_UFS_FS is not set
16308 -# CONFIG_XFS_FS is not set
16309  
16310  #
16311  # Network File Systems
16312  #
16313 -# CONFIG_CODA_FS is not set
16314 -# CONFIG_INTERMEZZO_FS is not set
16315  # CONFIG_NFS_FS is not set
16316  # CONFIG_NFSD is not set
16317  # CONFIG_EXPORTFS is not set
16318 -# CONFIG_CIFS is not set
16319  # CONFIG_SMB_FS is not set
16320 +# CONFIG_CIFS is not set
16321  # CONFIG_NCP_FS is not set
16322 +# CONFIG_CODA_FS is not set
16323 +# CONFIG_INTERMEZZO_FS is not set
16324  # CONFIG_AFS_FS is not set
16325  
16326  #
16327 @@ -317,28 +355,7 @@ CONFIG_NLS_DEFAULT="iso8859-1"
16328  #
16329  # SCSI support
16330  #
16331 -CONFIG_SCSI=y
16332 -CONFIG_GENERIC_ISA_DMA=y
16333 -
16334 -#
16335 -# SCSI support type (disk, tape, CD-ROM)
16336 -#
16337 -CONFIG_BLK_DEV_SD=y
16338 -CONFIG_SD_EXTRA_DEVS=40
16339 -CONFIG_CHR_DEV_ST=y
16340 -CONFIG_BLK_DEV_SR=y
16341 -CONFIG_BLK_DEV_SR_VENDOR=y
16342 -CONFIG_SR_EXTRA_DEVS=2
16343 -CONFIG_CHR_DEV_SG=y
16344 -
16345 -#
16346 -# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
16347 -#
16348 -CONFIG_SCSI_DEBUG_QUEUES=y
16349 -CONFIG_SCSI_MULTI_LUN=y
16350 -CONFIG_SCSI_CONSTANTS=y
16351 -CONFIG_SCSI_LOGGING=y
16352 -CONFIG_SCSI_DEBUG=y
16353 +# CONFIG_SCSI is not set
16354  
16355  #
16356  # Multi-device support (RAID and LVM)
16357 @@ -360,6 +377,7 @@ CONFIG_MTD_CHAR=y
16358  CONFIG_MTD_BLOCK=y
16359  # CONFIG_FTL is not set
16360  # CONFIG_NFTL is not set
16361 +# CONFIG_INFTL is not set
16362  
16363  #
16364  # RAM/ROM/Flash chip drivers
16365 @@ -374,20 +392,21 @@ CONFIG_MTD_BLOCK=y
16366  #
16367  # Mapping drivers for chip access
16368  #
16369 +# CONFIG_MTD_COMPLEX_MAPPINGS is not set
16370  
16371  #
16372  # Self-contained MTD device drivers
16373  #
16374  # CONFIG_MTD_SLRAM is not set
16375  # CONFIG_MTD_MTDRAM is not set
16376 -CONFIG_MTD_BLKMTD=m
16377 +CONFIG_MTD_BLKMTD=y
16378  
16379  #
16380  # Disk-On-Chip Device Drivers
16381  #
16382 -# CONFIG_MTD_DOC1000 is not set
16383  # CONFIG_MTD_DOC2000 is not set
16384  # CONFIG_MTD_DOC2001 is not set
16385 +# CONFIG_MTD_DOC2001PLUS is not set
16386  
16387  #
16388  # NAND Flash Device Drivers
16389 --- linux-2.6.0-test6/arch/um/drivers/chan_kern.c       2003-06-14 12:18:35.000000000 -0700
16390 +++ 25/arch/um/drivers/chan_kern.c      2003-10-05 00:34:32.000000000 -0700
16391 @@ -8,6 +8,7 @@
16392  #include <linux/list.h>
16393  #include <linux/slab.h>
16394  #include <linux/tty.h>
16395 +#include <linux/string.h>
16396  #include <linux/tty_flip.h>
16397  #include <asm/irq.h>
16398  #include "chan_kern.h"
16399 --- linux-2.6.0-test6/arch/um/drivers/chan_user.c       2003-06-14 12:17:56.000000000 -0700
16400 +++ 25/arch/um/drivers/chan_user.c      2003-10-05 00:34:32.000000000 -0700
16401 @@ -188,8 +188,8 @@ void register_winch(int fd, void *device
16402         if(!isatty(fd)) return;
16403  
16404         pid = tcgetpgrp(fd);
16405 -       if(!CHOOSE_MODE(is_tracer_winch(pid, fd, device_data), 0) && 
16406 -          (pid == -1)){
16407 +       if(!CHOOSE_MODE_PROC(is_tracer_winch, is_skas_winch, pid, fd, 
16408 +                            device_data) && (pid == -1)){
16409                 thread = winch_tramp(fd, device_data, &thread_fd);
16410                 if(fd != -1){
16411                         register_winch_irq(thread_fd, fd, thread, device_data);
16412 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
16413 +++ 25/arch/um/drivers/cow.h    2003-10-05 00:34:32.000000000 -0700
16414 @@ -0,0 +1,40 @@
16415 +#ifndef __COW_H__
16416 +#define __COW_H__
16417 +
16418 +#include <asm/types.h>
16419 +
16420 +#if __BYTE_ORDER == __BIG_ENDIAN
16421 +# define ntohll(x) (x)
16422 +# define htonll(x) (x)
16423 +#elif __BYTE_ORDER == __LITTLE_ENDIAN
16424 +# define ntohll(x)  bswap_64(x)
16425 +# define htonll(x)  bswap_64(x)
16426 +#else
16427 +#error "__BYTE_ORDER not defined"
16428 +#endif
16429 +
16430 +extern int init_cow_file(int fd, char *cow_file, char *backing_file, 
16431 +                        int sectorsize, int *bitmap_offset_out, 
16432 +                        unsigned long *bitmap_len_out, int *data_offset_out);
16433 +
16434 +extern int file_reader(__u64 offset, char *buf, int len, void *arg);
16435 +extern int read_cow_header(int (*reader)(__u64, char *, int, void *), 
16436 +                          void *arg, __u32 *magic_out, 
16437 +                          char **backing_file_out, time_t *mtime_out, 
16438 +                          __u64 *size_out, int *sectorsize_out, 
16439 +                          int *bitmap_offset_out);
16440 +
16441 +extern int write_cow_header(char *cow_file, int fd, char *backing_file, 
16442 +                           int sectorsize, long long *size);
16443 +
16444 +extern void cow_sizes(__u64 size, int sectorsize, int bitmap_offset, 
16445 +                     unsigned long *bitmap_len_out, int *data_offset_out);
16446 +
16447 +#endif
16448 +
16449 +/*
16450 + * ---------------------------------------------------------------------------
16451 + * Local variables:
16452 + * c-file-style: "linux"
16453 + * End:
16454 + */
16455 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
16456 +++ 25/arch/um/drivers/cow_kern.c       2003-10-05 00:34:32.000000000 -0700
16457 @@ -0,0 +1,628 @@
16458 +#define COW_MAJOR 60
16459 +#define MAJOR_NR COW_MAJOR
16460 +
16461 +#include <linux/stddef.h>
16462 +#include <linux/kernel.h>
16463 +#include <linux/ctype.h>
16464 +#include <linux/stat.h>
16465 +#include <linux/vmalloc.h>
16466 +#include <linux/blkdev.h>
16467 +#include <linux/blk.h>
16468 +#include <linux/fs.h>
16469 +#include <linux/genhd.h>
16470 +#include <linux/devfs_fs.h>
16471 +#include <asm/uaccess.h>
16472 +#include "2_5compat.h"
16473 +#include "cow.h"
16474 +#include "ubd_user.h"
16475 +
16476 +#define COW_SHIFT 4
16477 +
16478 +struct cow {
16479 +       int count;
16480 +       char *cow_path;
16481 +       dev_t cow_dev;
16482 +       struct block_device *cow_bdev;
16483 +       char *backing_path;
16484 +       dev_t backing_dev;
16485 +       struct block_device *backing_bdev;
16486 +       int sectorsize;
16487 +       unsigned long *bitmap;
16488 +       unsigned long bitmap_len;
16489 +       int bitmap_offset;
16490 +       int data_offset;
16491 +       devfs_handle_t devfs;
16492 +       struct semaphore sem;
16493 +       struct semaphore io_sem;
16494 +       atomic_t working;
16495 +       spinlock_t io_lock;
16496 +       struct buffer_head *bh;
16497 +       struct buffer_head *bhtail;
16498 +       void *end_io;
16499 +};
16500 +
16501 +#define DEFAULT_COW { \
16502 +       .count                  = 0, \
16503 +       .cow_path               = NULL, \
16504 +       .cow_dev                = 0, \
16505 +       .backing_path           = NULL, \
16506 +       .backing_dev            = 0, \
16507 +        .bitmap                        = NULL, \
16508 +       .bitmap_len             = 0, \
16509 +       .bitmap_offset          = 0, \
16510 +        .data_offset           = 0, \
16511 +       .devfs                  = NULL, \
16512 +       .working                = ATOMIC_INIT(0), \
16513 +       .io_lock                = SPIN_LOCK_UNLOCKED, \
16514 +}
16515 +
16516 +#define MAX_DEV (8)
16517 +#define MAX_MINOR (MAX_DEV << COW_SHIFT)
16518 +
16519 +struct cow cow_dev[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_COW };
16520 +
16521 +/* Not modified by this driver */
16522 +static int blk_sizes[MAX_MINOR] = { [ 0 ... MAX_MINOR - 1 ] = BLOCK_SIZE };
16523 +static int hardsect_sizes[MAX_MINOR] = { [ 0 ... MAX_MINOR - 1 ] = 512 };
16524 +
16525 +/* Protected by cow_lock */
16526 +static int sizes[MAX_MINOR] = { [ 0 ... MAX_MINOR - 1 ] = 0 };
16527 +
16528 +static struct hd_struct        cow_part[MAX_MINOR] =
16529 +       { [ 0 ... MAX_MINOR - 1 ] = { 0, 0, 0 } };
16530 +
16531 +/* Protected by io_request_lock */
16532 +static request_queue_t *cow_queue;
16533 +
16534 +static int cow_open(struct inode *inode, struct file *filp);
16535 +static int cow_release(struct inode * inode, struct file * file);
16536 +static int cow_ioctl(struct inode * inode, struct file * file,
16537 +                    unsigned int cmd, unsigned long arg);
16538 +static int cow_revalidate(kdev_t rdev);
16539 +
16540 +static struct block_device_operations cow_blops = {
16541 +       .open           = cow_open,
16542 +       .release        = cow_release,
16543 +       .ioctl          = cow_ioctl,
16544 +       .revalidate     = cow_revalidate,
16545 +};
16546 +
16547 +/* Initialized in an initcall, and unchanged thereafter */
16548 +devfs_handle_t cow_dir_handle;
16549 +
16550 +#define INIT_GENDISK(maj, name, parts, shift, bsizes, max, blops) \
16551 +{ \
16552 +       .major          = maj, \
16553 +       .major_name     = name, \
16554 +       .minor_shift    = shift, \
16555 +       .max_p          = 1 << shift, \
16556 +       .part           = parts, \
16557 +       .sizes          = bsizes, \
16558 +       .nr_real        = max, \
16559 +       .real_devices   = NULL, \
16560 +       .next           = NULL, \
16561 +       .fops           = blops, \
16562 +       .de_arr         = NULL, \
16563 +       .flags          = 0 \
16564 +}
16565 +
16566 +static spinlock_t cow_lock = SPIN_LOCK_UNLOCKED;
16567 +
16568 +static struct gendisk cow_gendisk = INIT_GENDISK(MAJOR_NR, "cow", cow_part,
16569 +                                                COW_SHIFT, sizes, MAX_DEV, 
16570 +                                                &cow_blops);
16571 +
16572 +static int cow_add(int n)
16573 +{
16574 +       struct cow *dev = &cow_dev[n];
16575 +       char name[sizeof("nnnnnn\0")];
16576 +       int err = -ENODEV;
16577 +
16578 +       if(dev->cow_path == NULL)
16579 +               goto out;
16580 +
16581 +       sprintf(name, "%d", n);
16582 +       dev->devfs = devfs_register(cow_dir_handle, name, DEVFS_FL_REMOVABLE,
16583 +                                   MAJOR_NR, n << COW_SHIFT, S_IFBLK | 
16584 +                                   S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
16585 +                                   &cow_blops, NULL);
16586 +
16587 +       init_MUTEX_LOCKED(&dev->sem);
16588 +       init_MUTEX(&dev->io_sem);
16589 +
16590 +       return(0);
16591 +
16592 +out:
16593 +       return(err);
16594 +}
16595 +
16596 +/*
16597 +* Add buffer_head to back of pending list
16598 +*/
16599 +static void cow_add_bh(struct cow *cow, struct buffer_head *bh)
16600 +{
16601 +       unsigned long flags;
16602 +
16603 +       spin_lock_irqsave(&cow->io_lock, flags);
16604 +       if(cow->bhtail != NULL){
16605 +               cow->bhtail->b_reqnext = bh;
16606 +               cow->bhtail = bh;
16607 +       }
16608 +       else {
16609 +               cow->bh = bh;
16610 +               cow->bhtail = bh;
16611 +       }
16612 +       spin_unlock_irqrestore(&cow->io_lock, flags);
16613 +}
16614 +
16615 +/*
16616 +* Grab first pending buffer
16617 +*/
16618 +static struct buffer_head *cow_get_bh(struct cow *cow)
16619 +{
16620 +       struct buffer_head *bh;
16621 +
16622 +       spin_lock_irq(&cow->io_lock);
16623 +       bh = cow->bh;
16624 +       if(bh != NULL){
16625 +               if(bh == cow->bhtail)
16626 +                       cow->bhtail = NULL;
16627 +               cow->bh = bh->b_reqnext;
16628 +               bh->b_reqnext = NULL;
16629 +       }
16630 +       spin_unlock_irq(&cow->io_lock);
16631 +
16632 +       return(bh);
16633 +}
16634 +
16635 +static void cow_handle_bh(struct cow *cow, struct buffer_head *bh, 
16636 +                         struct buffer_head **cow_bh, int ncow_bh)
16637 +{
16638 +       int i;
16639 +
16640 +       if(ncow_bh > 0)
16641 +               ll_rw_block(WRITE, ncow_bh, cow_bh);
16642 +
16643 +       for(i = 0; i < ncow_bh ; i++){
16644 +               wait_on_buffer(cow_bh[i]);
16645 +               brelse(cow_bh[i]);
16646 +       }
16647 +
16648 +       ll_rw_block(WRITE, 1, &bh);
16649 +       brelse(bh);
16650 +}
16651 +
16652 +static struct buffer_head *cow_new_bh(struct cow *dev, int sector)
16653 +{
16654 +       struct buffer_head *bh;
16655 +
16656 +       sector = (dev->bitmap_offset + sector / 8) / dev->sectorsize;
16657 +       bh = getblk(dev->cow_dev, sector, dev->sectorsize);
16658 +       memcpy(bh->b_data, dev->bitmap + sector / (8 * sizeof(dev->bitmap[0])),
16659 +              dev->sectorsize);
16660 +       return(bh);
16661 +}
16662 +
16663 +/* Copied from loop.c, needed to avoid deadlocking in make_request. */
16664 +
16665 +static int cow_thread(void *data)
16666 +{
16667 +       struct cow *dev = data;
16668 +       struct buffer_head *bh;
16669 +
16670 +       daemonize();
16671 +       exit_files(current);
16672 +
16673 +       sprintf(current->comm, "cow%d", dev - cow_dev);
16674 +
16675 +       spin_lock_irq(&current->sigmask_lock);
16676 +       sigfillset(&current->blocked);
16677 +       flush_signals(current);
16678 +       spin_unlock_irq(&current->sigmask_lock);
16679 +
16680 +       atomic_inc(&dev->working);
16681 +
16682 +       current->policy = SCHED_OTHER;
16683 +       current->nice = -20;
16684 +
16685 +       current->flags |= PF_NOIO;
16686 +
16687 +       /*
16688 +        * up sem, we are running
16689 +        */
16690 +       up(&dev->sem);
16691 +
16692 +       for(;;){
16693 +               int start, len, nbh, i, update_bitmap = 0;
16694 +               struct buffer_head *cow_bh[2];
16695 +
16696 +               down_interruptible(&dev->io_sem);
16697 +               /*
16698 +                * could be upped because of tear-down, not because of
16699 +                * pending work
16700 +                */
16701 +               if(!atomic_read(&dev->working))
16702 +                       break;
16703 +
16704 +               bh = cow_get_bh(dev);
16705 +               if(bh == NULL){
16706 +                       printk(KERN_ERR "cow: missing bh\n");
16707 +                       continue;
16708 +               }
16709 +
16710 +               start = bh->b_blocknr * bh->b_size / dev->sectorsize;
16711 +               len = bh->b_size / dev->sectorsize;
16712 +               for(i = 0; i < len ; i++){
16713 +                       if(ubd_test_bit(start +ni, 
16714 +                                       (unsigned char *) dev->bitmap))
16715 +                               continue;
16716 +
16717 +                       update_bitmap = 1;
16718 +                       ubd_set_bit(start + i, (unsigned char *) dev->bitmap);
16719 +               }
16720 +
16721 +               cow_bh[0] = NULL;
16722 +               cow_bh[1] = NULL;
16723 +               nbh = 0;
16724 +               if(update_bitmap){
16725 +                       cow_bh[0] = cow_new_bh(dev, start);
16726 +                       nbh++;
16727 +                       if(start / dev->sectorsize != 
16728 +                          (start + len) / dev->sectorsize){
16729 +                               cow_bh[1] = cow_new_bh(dev, start + len);
16730 +                               nbh++;
16731 +                       }
16732 +               }
16733 +               
16734 +               bh->b_dev = dev->cow_dev;
16735 +               bh->b_blocknr += dev->data_offset / dev->sectorsize;
16736 +
16737 +               cow_handle_bh(dev, bh, cow_bh, nbh);
16738 +
16739 +               /*
16740 +                * upped both for pending work and tear-down, lo_pending
16741 +                * will hit zero then
16742 +                */
16743 +               if(atomic_dec_and_test(&dev->working))
16744 +                       break;
16745 +       }
16746 +
16747 +       up(&dev->sem);
16748 +       return(0);
16749 +}
16750 +
16751 +static int cow_make_request(request_queue_t *q, int rw, struct buffer_head *bh)
16752 +{
16753 +       struct cow *dev;
16754 +       int n, minor;
16755 +
16756 +       minor = MINOR(bh->b_rdev);
16757 +       n = minor >> COW_SHIFT;
16758 +       dev = &cow_dev[n];
16759 +
16760 +       dev->end_io = NULL;
16761 +       if(ubd_test_bit(bh->b_rsector, (unsigned char *) dev->bitmap)){
16762 +               bh->b_rdev = dev->cow_dev;
16763 +               bh->b_rsector += dev->data_offset / dev->sectorsize;
16764 +       }
16765 +       else if(rw == WRITE){
16766 +               bh->b_dev = dev->cow_dev;
16767 +               bh->b_blocknr += dev->data_offset / dev->sectorsize;
16768 +
16769 +               cow_add_bh(dev, bh);
16770 +               up(&dev->io_sem);
16771 +               return(0);
16772 +       }
16773 +       else {
16774 +               bh->b_rdev = dev->backing_dev;
16775 +       }
16776 +
16777 +       return(1);
16778 +}
16779 +
16780 +int cow_init(void)
16781 +{
16782 +       int i;
16783 +
16784 +       cow_dir_handle = devfs_mk_dir (NULL, "cow", NULL);
16785 +       if (devfs_register_blkdev(MAJOR_NR, "cow", &cow_blops)) {
16786 +               printk(KERN_ERR "cow: unable to get major %d\n", MAJOR_NR);
16787 +               return -1;
16788 +       }
16789 +       read_ahead[MAJOR_NR] = 8;               /* 8 sector (4kB) read-ahead */
16790 +       blksize_size[MAJOR_NR] = blk_sizes;
16791 +       blk_size[MAJOR_NR] = sizes;
16792 +       INIT_HARDSECT(hardsect_size, MAJOR_NR, hardsect_sizes);
16793 +
16794 +       cow_queue = BLK_DEFAULT_QUEUE(MAJOR_NR);
16795 +       blk_init_queue(cow_queue, NULL);
16796 +       INIT_ELV(cow_queue, &cow_queue->elevator);
16797 +       blk_queue_make_request(cow_queue, cow_make_request);
16798 +
16799 +       add_gendisk(&cow_gendisk);
16800 +
16801 +       for(i=0;i<MAX_DEV;i++) 
16802 +               cow_add(i);
16803 +
16804 +       return(0);
16805 +}
16806 +
16807 +__initcall(cow_init);
16808 +
16809 +static int reader(__u64 start, char *buf, int count, void *arg)
16810 +{
16811 +       dev_t dev = *((dev_t *) arg);
16812 +       struct buffer_head *bh;
16813 +       __u64 block;
16814 +       int cur, offset, left, n, blocksize = get_hardsect_size(dev);
16815 +
16816 +       if(blocksize == 0)
16817 +               panic("Zero blocksize");
16818 +
16819 +       block = start / blocksize;
16820 +       offset = start % blocksize;
16821 +       left = count;
16822 +       cur = 0;
16823 +       while(left > 0){
16824 +               n = (left > blocksize) ? blocksize : left;
16825 +
16826 +               bh = bread(dev, block, (n < 512) ? 512 : n);
16827 +               if(bh == NULL)
16828 +                       return(-EIO);
16829 +
16830 +               n -= offset;
16831 +               memcpy(&buf[cur], bh->b_data + offset, n);
16832 +               block++;
16833 +               left -= n;
16834 +               cur += n;
16835 +               offset = 0;
16836 +               brelse(bh);
16837 +       }
16838 +
16839 +       return(count);
16840 +}
16841 +
16842 +static int cow_open(struct inode *inode, struct file *filp)
16843 +{
16844 +       int (*dev_ioctl)(struct inode *, struct file *, unsigned int, 
16845 +                        unsigned long);
16846 +       mm_segment_t fs;
16847 +       struct cow *dev;
16848 +       __u64 size;
16849 +       __u32 magic;
16850 +       time_t mtime;
16851 +       char *backing_file;
16852 +       int n, offset, err = 0;
16853 +
16854 +       n = DEVICE_NR(inode->i_rdev);
16855 +       if(n >= MAX_DEV)
16856 +               return(-ENODEV);
16857 +       dev = &cow_dev[n];
16858 +       offset = n << COW_SHIFT;
16859 +
16860 +       spin_lock(&cow_lock);
16861 +
16862 +       if(dev->count == 0){
16863 +               dev->cow_dev = name_to_kdev_t(dev->cow_path);
16864 +               if(dev->cow_dev == 0){
16865 +                       printk(KERN_ERR "cow_open - name_to_kdev_t(\"%s\") "
16866 +                              "failed\n", dev->cow_path);
16867 +                       err = -ENODEV;
16868 +               }
16869 +
16870 +               dev->backing_dev = name_to_kdev_t(dev->backing_path);
16871 +               if(dev->backing_dev == 0){
16872 +                       printk(KERN_ERR "cow_open - name_to_kdev_t(\"%s\") "
16873 +                              "failed\n", dev->backing_path);
16874 +                       err = -ENODEV;
16875 +               }
16876 +
16877 +               if(err) 
16878 +                       goto out;
16879 +
16880 +               dev->cow_bdev = bdget(dev->cow_dev);
16881 +               if(dev->cow_bdev == NULL){
16882 +                       printk(KERN_ERR "cow_open - bdget(\"%s\") failed\n", 
16883 +                              dev->cow_path);
16884 +                       err = -ENOMEM;
16885 +               }
16886 +               dev->backing_bdev = bdget(dev->backing_dev);
16887 +               if(dev->backing_bdev == NULL){
16888 +                       printk(KERN_ERR "cow_open - bdget(\"%s\") failed\n", 
16889 +                              dev->backing_path);
16890 +                       err = -ENOMEM;
16891 +               }
16892 +
16893 +               if(err) 
16894 +                       goto out;
16895 +
16896 +               err = blkdev_get(dev->cow_bdev, FMODE_READ|FMODE_WRITE, 0, 
16897 +                                BDEV_RAW);
16898 +               if(err){
16899 +                       printk("cow_open - blkdev_get of COW device failed, "
16900 +                              "error = %d\n", err);
16901 +                       goto out;
16902 +               }
16903 +               
16904 +               err = blkdev_get(dev->backing_bdev, FMODE_READ, 0, BDEV_RAW);
16905 +               if(err){
16906 +                       printk("cow_open - blkdev_get of backing device "
16907 +                              "failed, error = %d\n", err);
16908 +                       goto out;
16909 +               }
16910 +               
16911 +               err = read_cow_header(reader, &dev->cow_dev, &magic, 
16912 +                                     &backing_file, &mtime, &size,
16913 +                                     &dev->sectorsize, &dev->bitmap_offset);
16914 +               if(err){
16915 +                       printk(KERN_ERR "cow_open - read_cow_header failed, "
16916 +                              "err = %d\n", err);
16917 +                       goto out;
16918 +               }
16919 +
16920 +               cow_sizes(size, dev->sectorsize, dev->bitmap_offset, 
16921 +                         &dev->bitmap_len, &dev->data_offset);
16922 +               dev->bitmap = (void *) vmalloc(dev->bitmap_len);
16923 +               if(dev->bitmap == NULL){
16924 +                       err = -ENOMEM;
16925 +                       printk(KERN_ERR "Failed to vmalloc COW bitmap\n");
16926 +                       goto out;
16927 +               }
16928 +               flush_tlb_kernel_vm();
16929 +               
16930 +               err = reader(dev->bitmap_offset, (char *) dev->bitmap, 
16931 +                            dev->bitmap_len, &dev->cow_dev);
16932 +               if(err < 0){
16933 +                       printk(KERN_ERR "Failed to read COW bitmap\n");
16934 +                       vfree(dev->bitmap);
16935 +                       goto out;
16936 +               }
16937 +
16938 +               dev_ioctl = dev->backing_bdev->bd_op->ioctl;
16939 +               fs = get_fs();
16940 +               set_fs(KERNEL_DS);
16941 +               err = (*dev_ioctl)(inode, filp, BLKGETSIZE, 
16942 +                                  (unsigned long) &sizes[offset]);
16943 +               set_fs(fs);
16944 +               if(err){
16945 +                       printk(KERN_ERR "cow_open - BLKGETSIZE failed, "
16946 +                              "error = %d\n", err);
16947 +                       goto out;
16948 +               }
16949 +
16950 +               kernel_thread(cow_thread, dev, 
16951 +                             CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
16952 +               down(&dev->sem);
16953 +       }
16954 +       dev->count++;
16955 +out:
16956 +       spin_unlock(&cow_lock);
16957 +       return(err);
16958 +}
16959 +
16960 +static int cow_release(struct inode * inode, struct file * file)
16961 +{
16962 +       struct cow *dev;
16963 +       int n, err;
16964 +
16965 +       n = DEVICE_NR(inode->i_rdev);
16966 +       if(n >= MAX_DEV)
16967 +               return(-ENODEV);
16968 +       dev = &cow_dev[n];
16969 +
16970 +       spin_lock(&cow_lock);
16971 +
16972 +       if(--dev->count > 0)
16973 +               goto out;
16974 +
16975 +       err = blkdev_put(dev->cow_bdev, BDEV_RAW);
16976 +       if(err)
16977 +               printk("cow_release - blkdev_put of cow device failed, "
16978 +                      "error = %d\n", err);
16979 +       bdput(dev->cow_bdev);
16980 +       dev->cow_bdev = 0;
16981 +
16982 +       err = blkdev_put(dev->backing_bdev, BDEV_RAW);
16983 +       if(err)
16984 +               printk("cow_release - blkdev_put of backing device failed, "
16985 +                      "error = %d\n", err);
16986 +       bdput(dev->backing_bdev);
16987 +       dev->backing_bdev = 0;
16988 +
16989 +out:
16990 +       spin_unlock(&cow_lock);
16991 +       return(0);
16992 +}
16993 +
16994 +static int cow_ioctl(struct inode * inode, struct file * file,
16995 +                    unsigned int cmd, unsigned long arg)
16996 +{
16997 +       struct cow *dev;
16998 +       int (*dev_ioctl)(struct inode *, struct file *, unsigned int, 
16999 +                        unsigned long);
17000 +       int n;
17001 +
17002 +       n = DEVICE_NR(inode->i_rdev);
17003 +       if(n >= MAX_DEV)
17004 +               return(-ENODEV);
17005 +       dev = &cow_dev[n];
17006 +
17007 +       dev_ioctl = dev->backing_bdev->bd_op->ioctl;
17008 +       return((*dev_ioctl)(inode, file, cmd, arg));
17009 +}
17010 +
17011 +static int cow_revalidate(kdev_t rdev)
17012 +{
17013 +       printk(KERN_ERR "Need to implement cow_revalidate\n");
17014 +       return(0);
17015 +}
17016 +
17017 +static int parse_unit(char **ptr)
17018 +{
17019 +       char *str = *ptr, *end;
17020 +       int n = -1;
17021 +
17022 +       if(isdigit(*str)) {
17023 +               n = simple_strtoul(str, &end, 0);
17024 +               if(end == str)
17025 +                       return(-1);
17026 +               *ptr = end;
17027 +       }
17028 +       else if (('a' <= *str) && (*str <= 'h')) {
17029 +               n = *str - 'a';
17030 +               str++;
17031 +               *ptr = str;
17032 +       }
17033 +       return(n);
17034 +}
17035 +
17036 +static int cow_setup(char *str)
17037 +{
17038 +       struct cow *dev;
17039 +       char *cow_name, *backing_name;
17040 +       int unit;
17041 +
17042 +       unit = parse_unit(&str);
17043 +       if(unit < 0){
17044 +               printk(KERN_ERR "cow_setup - Couldn't parse unit number\n");
17045 +               return(1);
17046 +       }
17047 +
17048 +       if(*str != '='){
17049 +               printk(KERN_ERR "cow_setup - Missing '=' after unit "
17050 +                      "number\n");
17051 +               return(1);
17052 +       }
17053 +       str++;
17054 +
17055 +       cow_name = str;
17056 +       backing_name = strchr(str, ',');
17057 +       if(backing_name == NULL){
17058 +               printk(KERN_ERR "cow_setup - missing backing device name\n");
17059 +               return(0);
17060 +       }
17061 +       *backing_name = '\0';
17062 +       backing_name++;
17063 +
17064 +       spin_lock(&cow_lock);
17065 +
17066 +       dev = &cow_dev[unit];
17067 +       dev->cow_path = cow_name;
17068 +       dev->backing_path = backing_name;
17069 +       
17070 +       spin_unlock(&cow_lock);
17071 +       return(0);
17072 +}
17073 +
17074 +__setup("cow", cow_setup);
17075 +
17076 +/*
17077 + * Overrides for Emacs so that we follow Linus's tabbing style.
17078 + * Emacs will notice this stuff at the end of the file and automatically
17079 + * adjust the settings for this buffer only.  This must remain at the end
17080 + * of the file.
17081 + * ---------------------------------------------------------------------------
17082 + * Local variables:
17083 + * c-file-style: "linux"
17084 + * End:
17085 + */
17086 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
17087 +++ 25/arch/um/drivers/cow_sys.h        2003-10-05 00:34:32.000000000 -0700
17088 @@ -0,0 +1,48 @@
17089 +#ifndef __COW_SYS_H__
17090 +#define __COW_SYS_H__
17091 +
17092 +#include "kern_util.h"
17093 +#include "user_util.h"
17094 +#include "os.h"
17095 +#include "user.h"
17096 +
17097 +static inline void *cow_malloc(int size)
17098 +{
17099 +       return(um_kmalloc(size));
17100 +}
17101 +
17102 +static inline void cow_free(void *ptr)
17103 +{
17104 +       kfree(ptr);
17105 +}
17106 +
17107 +#define cow_printf printk
17108 +
17109 +static inline char *cow_strdup(char *str)
17110 +{
17111 +       return(uml_strdup(str));
17112 +}
17113 +
17114 +static inline int cow_seek_file(int fd, __u64 offset)
17115 +{
17116 +       return(os_seek_file(fd, offset));
17117 +}
17118 +
17119 +static inline int cow_file_size(char *file, __u64 *size_out)
17120 +{
17121 +       return(os_file_size(file, size_out));
17122 +}
17123 +
17124 +static inline int cow_write_file(int fd, char *buf, int size)
17125 +{
17126 +       return(os_write_file(fd, buf, size));
17127 +}
17128 +
17129 +#endif
17130 +
17131 +/*
17132 + * ---------------------------------------------------------------------------
17133 + * Local variables:
17134 + * c-file-style: "linux"
17135 + * End:
17136 + */
17137 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
17138 +++ 25/arch/um/drivers/cow_user.c       2003-10-05 00:34:32.000000000 -0700
17139 @@ -0,0 +1,296 @@
17140 +#include <stddef.h>
17141 +#include <string.h>
17142 +#include <errno.h>
17143 +#include <unistd.h>
17144 +#include <byteswap.h>
17145 +#include <sys/stat.h>
17146 +#include <sys/time.h>
17147 +#include <sys/param.h>
17148 +#include <netinet/in.h>
17149 +
17150 +#include "cow.h"
17151 +#include "cow_sys.h"
17152 +
17153 +#define PATH_LEN_V1 256
17154 +
17155 +struct cow_header_v1 {
17156 +       int magic;
17157 +       int version;
17158 +       char backing_file[PATH_LEN_V1];
17159 +       time_t mtime;
17160 +       __u64 size;
17161 +       int sectorsize;
17162 +};
17163 +
17164 +#define PATH_LEN_V2 MAXPATHLEN
17165 +
17166 +struct cow_header_v2 {
17167 +       unsigned long magic;
17168 +       unsigned long version;
17169 +       char backing_file[PATH_LEN_V2];
17170 +       time_t mtime;
17171 +       __u64 size;
17172 +       int sectorsize;
17173 +};
17174 +
17175 +union cow_header {
17176 +       struct cow_header_v1 v1;
17177 +       struct cow_header_v2 v2;
17178 +};
17179 +
17180 +#define COW_MAGIC 0x4f4f4f4d  /* MOOO */
17181 +#define COW_VERSION 2
17182 +
17183 +void cow_sizes(__u64 size, int sectorsize, int bitmap_offset, 
17184 +              unsigned long *bitmap_len_out, int *data_offset_out)
17185 +{
17186 +       *bitmap_len_out = (size + sectorsize - 1) / (8 * sectorsize);
17187 +
17188 +       *data_offset_out = bitmap_offset + *bitmap_len_out;
17189 +       *data_offset_out = (*data_offset_out + sectorsize - 1) / sectorsize;
17190 +       *data_offset_out *= sectorsize;
17191 +}
17192 +
17193 +static int absolutize(char *to, int size, char *from)
17194 +{
17195 +       char save_cwd[256], *slash;
17196 +       int remaining;
17197 +
17198 +       if(getcwd(save_cwd, sizeof(save_cwd)) == NULL) {
17199 +               cow_printf("absolutize : unable to get cwd - errno = %d\n", 
17200 +                          errno);
17201 +               return(-1);
17202 +       }
17203 +       slash = strrchr(from, '/');
17204 +       if(slash != NULL){
17205 +               *slash = '\0';
17206 +               if(chdir(from)){
17207 +                       *slash = '/';
17208 +                       cow_printf("absolutize : Can't cd to '%s' - " 
17209 +                                  "errno = %d\n", from, errno);
17210 +                       return(-1);
17211 +               }
17212 +               *slash = '/';
17213 +               if(getcwd(to, size) == NULL){
17214 +                       cow_printf("absolutize : unable to get cwd of '%s' - "
17215 +                              "errno = %d\n", from, errno);
17216 +                       return(-1);
17217 +               }
17218 +               remaining = size - strlen(to);
17219 +               if(strlen(slash) + 1 > remaining){
17220 +                       cow_printf("absolutize : unable to fit '%s' into %d "
17221 +                              "chars\n", from, size);
17222 +                       return(-1);
17223 +               }
17224 +               strcat(to, slash);
17225 +       }
17226 +       else {
17227 +               if(strlen(save_cwd) + 1 + strlen(from) + 1 > size){
17228 +                       cow_printf("absolutize : unable to fit '%s' into %d "
17229 +                              "chars\n", from, size);
17230 +                       return(-1);
17231 +               }
17232 +               strcpy(to, save_cwd);
17233 +               strcat(to, "/");
17234 +               strcat(to, from);
17235 +       }
17236 +       chdir(save_cwd);
17237 +       return(0);
17238 +}
17239 +
17240 +int write_cow_header(char *cow_file, int fd, char *backing_file, 
17241 +                    int sectorsize, long long *size)
17242 +{
17243 +       struct cow_header_v2 *header;
17244 +       struct stat64 buf;
17245 +       int err;
17246 +
17247 +       err = cow_seek_file(fd, 0);
17248 +       if(err != 0){
17249 +               cow_printf("write_cow_header - lseek failed, errno = %d\n", 
17250 +                          errno);
17251 +               return(-errno);
17252 +       }
17253 +
17254 +       err = -ENOMEM;
17255 +       header = cow_malloc(sizeof(*header));
17256 +       if(header == NULL){
17257 +               cow_printf("Failed to allocate COW V2 header\n");
17258 +               goto out;
17259 +       }
17260 +       header->magic = htonl(COW_MAGIC);
17261 +       header->version = htonl(COW_VERSION);
17262 +
17263 +       err = -EINVAL;
17264 +       if(strlen(backing_file) > sizeof(header->backing_file) - 1){
17265 +               cow_printf("Backing file name \"%s\" is too long - names are "
17266 +                          "limited to %d characters\n", backing_file, 
17267 +                          sizeof(header->backing_file) - 1);
17268 +               goto out_free;
17269 +       }
17270 +
17271 +       if(absolutize(header->backing_file, sizeof(header->backing_file), 
17272 +                     backing_file))
17273 +               goto out_free;
17274 +
17275 +       err = stat64(header->backing_file, &buf);
17276 +       if(err < 0){
17277 +               cow_printf("Stat of backing file '%s' failed, errno = %d\n",
17278 +                          header->backing_file, errno);
17279 +               err = -errno;
17280 +               goto out_free;
17281 +       }
17282 +
17283 +       err = cow_file_size(header->backing_file, size);
17284 +       if(err){
17285 +               cow_printf("Couldn't get size of backing file '%s', "
17286 +                          "errno = %d\n", header->backing_file, -*size);
17287 +               goto out_free;
17288 +       }
17289 +
17290 +       header->mtime = htonl(buf.st_mtime);
17291 +       header->size = htonll(*size);
17292 +       header->sectorsize = htonl(sectorsize);
17293 +
17294 +       err = write(fd, header, sizeof(*header));
17295 +       if(err != sizeof(*header)){
17296 +               cow_printf("Write of header to new COW file '%s' failed, "
17297 +                          "errno = %d\n", cow_file, errno);
17298 +               goto out_free;
17299 +       }
17300 +       err = 0;
17301 + out_free:
17302 +       cow_free(header);
17303 + out:
17304 +       return(err);
17305 +}
17306 +
17307 +int file_reader(__u64 offset, char *buf, int len, void *arg)
17308 +{
17309 +       int fd = *((int *) arg);
17310 +
17311 +       return(pread(fd, buf, len, offset));
17312 +}
17313 +
17314 +int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, 
17315 +                   __u32 *magic_out, char **backing_file_out, 
17316 +                   time_t *mtime_out, __u64 *size_out, 
17317 +                   int *sectorsize_out, int *bitmap_offset_out)
17318 +{
17319 +       union cow_header *header;
17320 +       char *file;
17321 +       int err, n;
17322 +       unsigned long version, magic;
17323 +
17324 +       header = cow_malloc(sizeof(*header));
17325 +       if(header == NULL){
17326 +               cow_printf("read_cow_header - Failed to allocate header\n");
17327 +               return(-ENOMEM);
17328 +       }
17329 +       err = -EINVAL;
17330 +       n = (*reader)(0, (char *) header, sizeof(*header), arg);
17331 +       if(n < offsetof(typeof(header->v1), backing_file)){
17332 +               cow_printf("read_cow_header - short header\n");
17333 +               goto out;
17334 +       }
17335 +
17336 +       magic = header->v1.magic;
17337 +       if(magic == COW_MAGIC) {
17338 +               version = header->v1.version;
17339 +       }
17340 +       else if(magic == ntohl(COW_MAGIC)){
17341 +               version = ntohl(header->v1.version);
17342 +       }
17343 +       /* No error printed because the non-COW case comes through here */
17344 +       else goto out;
17345 +
17346 +       *magic_out = COW_MAGIC;
17347 +
17348 +       if(version == 1){
17349 +               if(n < sizeof(header->v1)){
17350 +                       cow_printf("read_cow_header - failed to read V1 "
17351 +                                  "header\n");
17352 +                       goto out;
17353 +               }
17354 +               *mtime_out = header->v1.mtime;
17355 +               *size_out = header->v1.size;
17356 +               *sectorsize_out = header->v1.sectorsize;
17357 +               *bitmap_offset_out = sizeof(header->v1);
17358 +               file = header->v1.backing_file;
17359 +       }
17360 +       else if(version == 2){
17361 +               if(n < sizeof(header->v2)){
17362 +                       cow_printf("read_cow_header - failed to read V2 "
17363 +                                  "header\n");
17364 +                       goto out;
17365 +               }
17366 +               *mtime_out = ntohl(header->v2.mtime);
17367 +               *size_out = ntohll(header->v2.size);
17368 +               *sectorsize_out = ntohl(header->v2.sectorsize);
17369 +               *bitmap_offset_out = sizeof(header->v2);
17370 +               file = header->v2.backing_file;
17371 +       }
17372 +       else {
17373 +               cow_printf("read_cow_header - invalid COW version\n");
17374 +               goto out;
17375 +       }
17376 +       err = -ENOMEM;
17377 +       *backing_file_out = cow_strdup(file);
17378 +       if(*backing_file_out == NULL){
17379 +               cow_printf("read_cow_header - failed to allocate backing "
17380 +                          "file\n");
17381 +               goto out;
17382 +       }
17383 +       err = 0;
17384 + out:
17385 +       cow_free(header);
17386 +       return(err);
17387 +}
17388 +
17389 +int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize,
17390 +                 int *bitmap_offset_out, unsigned long *bitmap_len_out, 
17391 +                 int *data_offset_out)
17392 +{
17393 +       __u64 size, offset;
17394 +       char zero = 0;
17395 +       int err;
17396 +
17397 +       err = write_cow_header(cow_file, fd, backing_file, sectorsize, &size);
17398 +       if(err) 
17399 +               goto out;
17400 +       
17401 +       cow_sizes(size, sectorsize, sizeof(struct cow_header_v2), 
17402 +                 bitmap_len_out, data_offset_out);
17403 +       *bitmap_offset_out = sizeof(struct cow_header_v2);
17404 +
17405 +       offset = *data_offset_out + size - sizeof(zero);
17406 +       err = cow_seek_file(fd, offset);
17407 +       if(err != 0){
17408 +               cow_printf("cow bitmap lseek failed : errno = %d\n", errno);
17409 +               goto out;
17410 +       }
17411 +
17412 +       /* does not really matter how much we write it is just to set EOF 
17413 +        * this also sets the entire COW bitmap
17414 +        * to zero without having to allocate it 
17415 +        */
17416 +       err = cow_write_file(fd, &zero, sizeof(zero));
17417 +       if(err != sizeof(zero)){
17418 +               err = -EINVAL;
17419 +               cow_printf("Write of bitmap to new COW file '%s' failed, "
17420 +                          "errno = %d\n", cow_file, errno);
17421 +               goto out;
17422 +       }
17423 +
17424 +       return(0);
17425 +
17426 + out:
17427 +       return(err);
17428 +}
17429 +
17430 +/*
17431 + * ---------------------------------------------------------------------------
17432 + * Local variables:
17433 + * c-file-style: "linux"
17434 + * End:
17435 + */
17436 --- linux-2.6.0-test6/arch/um/drivers/hostaudio_kern.c  2003-06-14 12:18:35.000000000 -0700
17437 +++ 25/arch/um/drivers/hostaudio_kern.c 2003-10-05 00:34:32.000000000 -0700
17438 @@ -11,6 +11,7 @@
17439  #include "linux/fs.h"
17440  #include "linux/sound.h"
17441  #include "linux/soundcard.h"
17442 +#include "asm/uaccess.h"
17443  #include "kern_util.h"
17444  #include "init.h"
17445  #include "hostaudio.h"
17446 @@ -22,7 +23,7 @@ char *mixer = HOSTAUDIO_DEV_MIXER;
17447  #ifndef MODULE
17448  static int set_dsp(char *name, int *add)
17449  {
17450 -       dsp = uml_strdup(name);
17451 +       dsp = name;
17452         return(0);
17453  }
17454  
17455 @@ -34,7 +35,7 @@ __uml_setup("dsp=", set_dsp,
17456  
17457  static int set_mixer(char *name, int *add)
17458  {
17459 -       mixer = uml_strdup(name);
17460 +       mixer = name;
17461         return(0);
17462  }
17463  
17464 @@ -51,23 +52,55 @@ static ssize_t hostaudio_read(struct fil
17465                               loff_t *ppos)
17466  {
17467          struct hostaudio_state *state = file->private_data;
17468 +       void *kbuf;
17469 +       int err;
17470  
17471  #ifdef DEBUG
17472          printk("hostaudio: read called, count = %d\n", count);
17473  #endif
17474  
17475 -        return(hostaudio_read_user(state, buffer, count, ppos));
17476 +       kbuf = kmalloc(count, GFP_KERNEL);
17477 +       if(kbuf == NULL)
17478 +               return(-ENOMEM);
17479 +
17480 +        err = hostaudio_read_user(state, kbuf, count, ppos);
17481 +       if(err < 0)
17482 +               goto out;
17483 +
17484 +       if(copy_to_user(buffer, kbuf, err))
17485 +               err = -EFAULT;
17486 +
17487 + out:
17488 +       kfree(kbuf);
17489 +       return(err);
17490  }
17491  
17492  static ssize_t hostaudio_write(struct file *file, const char *buffer, 
17493                                size_t count, loff_t *ppos)
17494  {
17495          struct hostaudio_state *state = file->private_data;
17496 +       void *kbuf;
17497 +       int err;
17498  
17499  #ifdef DEBUG
17500          printk("hostaudio: write called, count = %d\n", count);
17501  #endif
17502 -        return(hostaudio_write_user(state, buffer, count, ppos));
17503 +
17504 +       kbuf = kmalloc(count, GFP_KERNEL);
17505 +       if(kbuf == NULL)
17506 +               return(-ENOMEM);
17507 +
17508 +       err = -EFAULT;
17509 +       if(copy_from_user(kbuf, buffer, count))
17510 +               goto out;
17511 +
17512 +        err = hostaudio_write_user(state, kbuf, count, ppos);
17513 +       if(err < 0)
17514 +               goto out;
17515 +
17516 + out:
17517 +       kfree(kbuf);
17518 +       return(err);
17519  }
17520  
17521  static unsigned int hostaudio_poll(struct file *file, 
17522 @@ -86,12 +119,43 @@ static int hostaudio_ioctl(struct inode 
17523                            unsigned int cmd, unsigned long arg)
17524  {
17525          struct hostaudio_state *state = file->private_data;
17526 +       unsigned long data = 0;
17527 +       int err;
17528  
17529  #ifdef DEBUG
17530          printk("hostaudio: ioctl called, cmd = %u\n", cmd);
17531  #endif
17532 +       switch(cmd){
17533 +       case SNDCTL_DSP_SPEED:
17534 +       case SNDCTL_DSP_STEREO:
17535 +       case SNDCTL_DSP_GETBLKSIZE:
17536 +       case SNDCTL_DSP_CHANNELS:
17537 +       case SNDCTL_DSP_SUBDIVIDE:
17538 +       case SNDCTL_DSP_SETFRAGMENT:
17539 +               if(get_user(data, (int *) arg))
17540 +                       return(-EFAULT);
17541 +               break;
17542 +       default:
17543 +               break;
17544 +       }
17545 +
17546 +        err = hostaudio_ioctl_user(state, cmd, (unsigned long) &data);
17547 +
17548 +       switch(cmd){
17549 +       case SNDCTL_DSP_SPEED:
17550 +       case SNDCTL_DSP_STEREO:
17551 +       case SNDCTL_DSP_GETBLKSIZE:
17552 +       case SNDCTL_DSP_CHANNELS:
17553 +       case SNDCTL_DSP_SUBDIVIDE:
17554 +       case SNDCTL_DSP_SETFRAGMENT:
17555 +               if(put_user(data, (int *) arg))
17556 +                       return(-EFAULT);
17557 +               break;
17558 +       default:
17559 +               break;
17560 +       }
17561  
17562 -        return(hostaudio_ioctl_user(state, cmd, arg));
17563 +       return(err);
17564  }
17565  
17566  static int hostaudio_open(struct inode *inode, struct file *file)
17567 @@ -225,7 +289,8 @@ MODULE_LICENSE("GPL");
17568  
17569  static int __init hostaudio_init_module(void)
17570  {
17571 -        printk(KERN_INFO "UML Audio Relay\n");
17572 +        printk(KERN_INFO "UML Audio Relay (host dsp = %s, host mixer = %s)\n",
17573 +              dsp, mixer);
17574  
17575         module_data.dev_audio = register_sound_dsp(&hostaudio_fops, -1);
17576          if(module_data.dev_audio < 0){
17577 --- linux-2.6.0-test6/arch/um/drivers/line.c    2003-06-14 12:18:33.000000000 -0700
17578 +++ 25/arch/um/drivers/line.c   2003-10-05 00:34:32.000000000 -0700
17579 @@ -6,8 +6,8 @@
17580  #include "linux/sched.h"
17581  #include "linux/slab.h"
17582  #include "linux/list.h"
17583 +#include "linux/interrupt.h"
17584  #include "linux/devfs_fs_kernel.h"
17585 -#include "asm/irq.h"
17586  #include "asm/uaccess.h"
17587  #include "chan_kern.h"
17588  #include "irq_user.h"
17589 @@ -16,16 +16,18 @@
17590  #include "user_util.h"
17591  #include "kern_util.h"
17592  #include "os.h"
17593 +#include "irq_kern.h"
17594  
17595  #define LINE_BUFSIZE 4096
17596  
17597 -void line_interrupt(int irq, void *data, struct pt_regs *unused)
17598 +irqreturn_t line_interrupt(int irq, void *data, struct pt_regs *unused)
17599  {
17600         struct line *dev = data;
17601  
17602         if(dev->count > 0) 
17603                 chan_interrupt(&dev->chan_list, &dev->task, dev->tty, irq, 
17604                                dev);
17605 +       return IRQ_HANDLED;
17606  }
17607  
17608  void line_timer_cb(void *arg)
17609 @@ -136,20 +138,22 @@ int line_write(struct line *lines, struc
17610         return(len);
17611  }
17612  
17613 -void line_write_interrupt(int irq, void *data, struct pt_regs *unused)
17614 +irqreturn_t line_write_interrupt(int irq, void *data, struct pt_regs *unused)
17615  {
17616         struct line *dev = data;
17617         struct tty_struct *tty = dev->tty;
17618         int err;
17619  
17620         err = flush_buffer(dev);
17621 -       if(err == 0) return;
17622 +       if(err == 0) 
17623 +               return(IRQ_NONE);
17624         else if(err < 0){
17625                 dev->head = dev->buffer;
17626                 dev->tail = dev->buffer;
17627         }
17628  
17629 -       if(tty == NULL) return;
17630 +       if(tty == NULL) 
17631 +               return(IRQ_NONE);
17632  
17633         if(test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) &&
17634            (tty->ldisc.write_wakeup != NULL))
17635 @@ -161,9 +165,9 @@ void line_write_interrupt(int irq, void 
17636          * writes.
17637          */
17638  
17639 -       if (waitqueue_active(&tty->write_wait))
17640 +       if(waitqueue_active(&tty->write_wait))
17641                 wake_up_interruptible(&tty->write_wait);
17642 -
17643 +       return(IRQ_HANDLED);
17644  }
17645  
17646  int line_write_room(struct tty_struct *tty)
17647 @@ -369,7 +373,7 @@ int line_get_config(char *name, struct l
17648  
17649         dev = simple_strtoul(name, &end, 0);
17650         if((*end != '\0') || (end == name)){
17651 -               *error_out = "line_setup failed to parse device number";
17652 +               *error_out = "line_get_config failed to parse device number";
17653                 return(0);
17654         }
17655  
17656 @@ -379,15 +383,15 @@ int line_get_config(char *name, struct l
17657         }
17658  
17659         line = &lines[dev];
17660 +
17661         down(&line->sem);
17662 -       
17663         if(!line->valid)
17664                 CONFIG_CHUNK(str, size, n, "none", 1);
17665         else if(line->count == 0)
17666                 CONFIG_CHUNK(str, size, n, line->init_str, 1);
17667         else n = chan_config_string(&line->chan_list, str, size, error_out);
17668 -
17669         up(&line->sem);
17670 +
17671         return(n);
17672  }
17673  
17674 @@ -412,7 +416,8 @@ struct tty_driver *line_register_devfs(s
17675                 return NULL;
17676  
17677         driver->driver_name = line_driver->name;
17678 -       driver->name = line_driver->devfs_name;
17679 +       driver->name = line_driver->device_name;
17680 +       driver->devfs_name = line_driver->devfs_name;
17681         driver->major = line_driver->major;
17682         driver->minor_start = line_driver->minor_start;
17683         driver->type = line_driver->type;
17684 @@ -432,7 +437,7 @@ struct tty_driver *line_register_devfs(s
17685  
17686         for(i = 0; i < nlines; i++){
17687                 if(!lines[i].valid) 
17688 -                       tty_unregister_devfs(driver, i);
17689 +                       tty_unregister_device(driver, i);
17690         }
17691  
17692         mconsole_register_dev(&line_driver->mc);
17693 @@ -465,24 +470,25 @@ struct winch {
17694         struct line *line;
17695  };
17696  
17697 -void winch_interrupt(int irq, void *data, struct pt_regs *unused)
17698 +irqreturn_t winch_interrupt(int irq, void *data, struct pt_regs *unused)
17699  {
17700         struct winch *winch = data;
17701         struct tty_struct *tty;
17702         int err;
17703         char c;
17704  
17705 -       err = generic_read(winch->fd, &c, NULL);
17706 -       if(err < 0){
17707 -               if(err != -EAGAIN){
17708 -                       printk("winch_interrupt : read failed, errno = %d\n", 
17709 -                              -err);
17710 -                       printk("fd %d is losing SIGWINCH support\n", 
17711 -                              winch->tty_fd);
17712 -                       free_irq(irq, data);
17713 -                       return;
17714 +       if(winch->fd != -1){
17715 +               err = generic_read(winch->fd, &c, NULL);
17716 +               if(err < 0){
17717 +                       if(err != -EAGAIN){
17718 +                               printk("winch_interrupt : read failed, "
17719 +                                      "errno = %d\n", -err);
17720 +                               printk("fd %d is losing SIGWINCH support\n", 
17721 +                                      winch->tty_fd);
17722 +                               return(IRQ_HANDLED);
17723 +                       }
17724 +                       goto out;
17725                 }
17726 -               goto out;
17727         }
17728         tty = winch->line->tty;
17729         if(tty != NULL){
17730 @@ -492,7 +498,9 @@ void winch_interrupt(int irq, void *data
17731                 kill_pg(tty->pgrp, SIGWINCH, 1);
17732         }
17733   out:
17734 -       reactivate_fd(winch->fd, WINCH_IRQ);
17735 +       if(winch->fd != -1)
17736 +               reactivate_fd(winch->fd, WINCH_IRQ);
17737 +       return(IRQ_HANDLED);
17738  }
17739  
17740  DECLARE_MUTEX(winch_handler_sem);
17741 @@ -529,7 +537,10 @@ static void winch_cleanup(void)
17742  
17743         list_for_each(ele, &winch_handlers){
17744                 winch = list_entry(ele, struct winch, list);
17745 -               close(winch->fd);
17746 +               if(winch->fd != -1){
17747 +                       deactivate_fd(winch->fd, WINCH_IRQ);
17748 +                       close(winch->fd);
17749 +               }
17750                 if(winch->pid != -1) 
17751                         os_kill_process(winch->pid, 1);
17752         }
17753 --- linux-2.6.0-test6/arch/um/drivers/Makefile  2003-06-14 12:18:23.000000000 -0700
17754 +++ 25/arch/um/drivers/Makefile 2003-10-05 00:34:32.000000000 -0700
17755 @@ -1,5 +1,5 @@
17756  # 
17757 -# Copyright (C) 2000, 2002 Jeff Dike (jdike@karaya.com)
17758 +# Copyright (C) 2000, 2002, 2003 Jeff Dike (jdike@karaya.com)
17759  # Licensed under the GPL
17760  #
17761  
17762 @@ -39,6 +39,8 @@ obj-$(CONFIG_PTY_CHAN) += pty.o
17763  obj-$(CONFIG_TTY_CHAN) += tty.o 
17764  obj-$(CONFIG_XTERM_CHAN) += xterm.o xterm_kern.o
17765  obj-$(CONFIG_UML_WATCHDOG) += harddog.o
17766 +obj-$(CONFIG_BLK_DEV_COW) += cow_kern.o
17767 +obj-$(CONFIG_BLK_DEV_COW_COMMON) += cow_user.o
17768  
17769  obj-y += stdio_console.o $(CHAN_OBJS)
17770  
17771 @@ -46,7 +48,7 @@ USER_SINGLE_OBJS = $(foreach f,$(patsubs
17772  
17773  USER_OBJS := $(filter %_user.o,$(obj-y) $(obj-m) $(USER_SINGLE_OBJS)) fd.o \
17774         null.o pty.o tty.o xterm.o
17775 -USER_OBJS := $(foreach file,$(USER_OBJS),arch/um/drivers/$(file))
17776 +USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
17777  
17778  $(USER_OBJS) : %.o: %.c
17779         $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
17780 --- linux-2.6.0-test6/arch/um/drivers/mconsole_kern.c   2003-06-14 12:17:56.000000000 -0700
17781 +++ 25/arch/um/drivers/mconsole_kern.c  2003-10-05 00:34:32.000000000 -0700
17782 @@ -27,6 +27,7 @@
17783  #include "init.h"
17784  #include "os.h"
17785  #include "umid.h"
17786 +#include "irq_kern.h"
17787  
17788  static int do_unlink_socket(struct notifier_block *notifier, 
17789                             unsigned long what, void *data)
17790 @@ -67,7 +68,7 @@ void mc_work_proc(void *unused)
17791  
17792  DECLARE_WORK(mconsole_work, mc_work_proc, NULL);
17793  
17794 -void mconsole_interrupt(int irq, void *dev_id, struct pt_regs *regs)
17795 +irqreturn_t mconsole_interrupt(int irq, void *dev_id, struct pt_regs *regs)
17796  {
17797         int fd;
17798         struct mconsole_entry *new;
17799 @@ -88,6 +89,7 @@ void mconsole_interrupt(int irq, void *d
17800         }
17801         if(!list_empty(&mc_requests)) schedule_work(&mconsole_work);
17802         reactivate_fd(fd, MCONSOLE_IRQ);
17803 +       return(IRQ_HANDLED);
17804  }
17805  
17806  void mconsole_version(struct mc_request *req)
17807 @@ -100,20 +102,34 @@ void mconsole_version(struct mc_request 
17808         mconsole_reply(req, version, 0, 0);
17809  }
17810  
17811 +void mconsole_log(struct mc_request *req)
17812 +{
17813 +       int len;
17814 +       char *ptr = req->request.data;
17815 +       
17816 +       ptr += strlen("log");
17817 +       while(isspace(*ptr)) ptr++;
17818 +
17819 +       len = ptr - req->request.data;
17820 +       printk("%.*s", len, ptr);
17821 +       mconsole_reply(req, "", 0, 0);
17822 +}
17823 +
17824  #define UML_MCONSOLE_HELPTEXT \
17825 -"Commands:
17826 -    version - Get kernel version
17827 -    help - Print this message
17828 -    halt - Halt UML
17829 -    reboot - Reboot UML
17830 -    config <dev>=<config> - Add a new device to UML; 
17831 -       same syntax as command line
17832 -    config <dev> - Query the configuration of a device
17833 -    remove <dev> - Remove a device from UML
17834 -    sysrq <letter> - Performs the SysRq action controlled by the letter
17835 -    cad - invoke the Ctl-Alt-Del handler
17836 -    stop - pause the UML; it will do nothing until it receives a 'go'
17837 -    go - continue the UML after a 'stop'
17838 +"Commands: \n\
17839 +    version - Get kernel version \n\
17840 +    help - Print this message \n\
17841 +    halt - Halt UML \n\
17842 +    reboot - Reboot UML \n\
17843 +    config <dev>=<config> - Add a new device to UML;  \n\
17844 +       same syntax as command line \n\
17845 +    config <dev> - Query the configuration of a device \n\
17846 +    remove <dev> - Remove a device from UML \n\
17847 +    sysrq <letter> - Performs the SysRq action controlled by the letter \n\
17848 +    cad - invoke the Ctl-Alt-Del handler \n\
17849 +    stop - pause the UML; it will do nothing until it receives a 'go' \n\
17850 +    go - continue the UML after a 'stop' \n\
17851 +    log <string> - make UML enter <string> into the kernel log\n\
17852  "
17853  
17854  void mconsole_help(struct mc_request *req)
17855 @@ -302,7 +318,7 @@ int mconsole_init(void)
17856         if(umid_file_name("mconsole", file, sizeof(file))) return(-1);
17857         snprintf(mconsole_socket_name, sizeof(file), "%s", file);
17858  
17859 -       sock = create_unix_socket(file, sizeof(file));
17860 +       sock = create_unix_socket(file, sizeof(file), 1);
17861         if (sock < 0){
17862                 printk("Failed to initialize management console\n");
17863                 return(1);
17864 --- linux-2.6.0-test6/arch/um/drivers/mconsole_user.c   2003-06-14 12:17:59.000000000 -0700
17865 +++ 25/arch/um/drivers/mconsole_user.c  2003-10-05 00:34:32.000000000 -0700
17866 @@ -28,6 +28,7 @@ static struct mconsole_command commands[
17867         { "cad", mconsole_cad, 1 },
17868         { "stop", mconsole_stop, 0 },
17869         { "go", mconsole_go, 1 },
17870 +       { "log", mconsole_log, 1 },
17871  };
17872  
17873  /* Initialized in mconsole_init, which is an initcall */
17874 @@ -139,6 +140,7 @@ int mconsole_reply(struct mc_request *re
17875                 memcpy(reply.data, str, len);
17876                 reply.data[len] = '\0';
17877                 total -= len;
17878 +               str += len;
17879                 reply.len = len + 1;
17880  
17881                 len = sizeof(reply) + reply.len - sizeof(reply.data);
17882 --- linux-2.6.0-test6/arch/um/drivers/mmapper_kern.c    2003-06-14 12:17:58.000000000 -0700
17883 +++ 25/arch/um/drivers/mmapper_kern.c   2003-10-05 00:34:32.000000000 -0700
17884 @@ -120,7 +120,10 @@ static int __init mmapper_init(void)
17885         printk(KERN_INFO "Mapper v0.1\n");
17886  
17887         v_buf = (char *) find_iomem("mmapper", &mmapper_size);
17888 -       if(mmapper_size == 0) return(0);
17889 +       if(mmapper_size == 0){
17890 +               printk(KERN_ERR "mmapper_init - find_iomem failed\n");
17891 +               return(0);
17892 +       }
17893  
17894         p_buf = __pa(v_buf);
17895  
17896 --- linux-2.6.0-test6/arch/um/drivers/net_kern.c        2003-08-22 19:23:40.000000000 -0700
17897 +++ 25/arch/um/drivers/net_kern.c       2003-10-05 00:34:32.000000000 -0700
17898 @@ -26,6 +26,7 @@
17899  #include "mconsole_kern.h"
17900  #include "init.h"
17901  #include "irq_user.h"
17902 +#include "irq_kern.h"
17903  
17904  static spinlock_t opened_lock = SPIN_LOCK_UNLOCKED;
17905  LIST_HEAD(opened);
17906 @@ -61,14 +62,14 @@ static int uml_net_rx(struct net_device 
17907         return pkt_len;
17908  }
17909  
17910 -void uml_net_interrupt(int irq, void *dev_id, struct pt_regs *regs)
17911 +irqreturn_t uml_net_interrupt(int irq, void *dev_id, struct pt_regs *regs)
17912  {
17913         struct net_device *dev = dev_id;
17914         struct uml_net_private *lp = dev->priv;
17915         int err;
17916  
17917         if(!netif_running(dev))
17918 -               return;
17919 +               return(IRQ_NONE);
17920  
17921         spin_lock(&lp->lock);
17922         while((err = uml_net_rx(dev)) > 0) ;
17923 @@ -83,6 +84,7 @@ void uml_net_interrupt(int irq, void *de
17924  
17925   out:
17926         spin_unlock(&lp->lock);
17927 +       return(IRQ_HANDLED);
17928  }
17929  
17930  static int uml_net_open(struct net_device *dev)
17931 @@ -252,37 +254,6 @@ void uml_net_user_timer_expire(unsigned 
17932  #endif
17933  }
17934  
17935 -/*
17936 - * default do nothing hard header packet routines for struct net_device init.
17937 - * real ethernet transports will overwrite with real routines.
17938 - */
17939 -static int uml_net_hard_header(struct sk_buff *skb, struct net_device *dev,
17940 -                 unsigned short type, void *daddr, void *saddr, unsigned len)
17941 -{
17942 -       return(0); /* no change */
17943 -}
17944 -
17945 -static int uml_net_rebuild_header(struct sk_buff *skb)
17946 -{
17947 -       return(0); /* ignore */ 
17948 -}
17949 -
17950 -static int uml_net_header_cache(struct neighbour *neigh, struct hh_cache *hh)
17951 -{
17952 -       return(-1); /* fail */
17953 -}
17954 -
17955 -static void uml_net_header_cache_update(struct hh_cache *hh,
17956 -                 struct net_device *dev, unsigned char * haddr)
17957 -{
17958 -       /* ignore */
17959 -}
17960 -
17961 -static int uml_net_header_parse(struct sk_buff *skb, unsigned char *haddr)
17962 -{
17963 -       return(0); /* nothing */
17964 -}
17965 -
17966  static spinlock_t devices_lock = SPIN_LOCK_UNLOCKED;
17967  static struct list_head devices = LIST_HEAD_INIT(devices);
17968  
17969 @@ -292,7 +263,7 @@ static int eth_configure(int n, void *in
17970         struct uml_net *device;
17971         struct net_device *dev;
17972         struct uml_net_private *lp;
17973 -       int err, size;
17974 +       int save, err, size;
17975  
17976         size = transport->private_size + sizeof(struct uml_net_private) + 
17977                 sizeof(((struct uml_net_private *) 0)->user);
17978 @@ -334,12 +305,6 @@ static int eth_configure(int n, void *in
17979         snprintf(dev->name, sizeof(dev->name), "eth%d", n);
17980         device->dev = dev;
17981  
17982 -        dev->hard_header = uml_net_hard_header;
17983 -        dev->rebuild_header = uml_net_rebuild_header;
17984 -        dev->hard_header_cache = uml_net_header_cache;
17985 -        dev->header_cache_update= uml_net_header_cache_update;
17986 -        dev->hard_header_parse = uml_net_header_parse;
17987 -
17988         (*transport->kern->init)(dev, init);
17989  
17990         dev->mtu = transport->user->max_packet;
17991 @@ -362,21 +327,29 @@ static int eth_configure(int n, void *in
17992                 return 1;
17993         lp = dev->priv;
17994  
17995 -       INIT_LIST_HEAD(&lp->list);
17996 -       spin_lock_init(&lp->lock);
17997 -       lp->dev = dev;
17998 -       lp->fd = -1;
17999 -       lp->mac = { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0 };
18000 -       lp->have_mac = device->have_mac;
18001 -       lp->protocol = transport->kern->protocol;
18002 -       lp->open = transport->user->open;
18003 -       lp->close = transport->user->close;
18004 -       lp->remove = transport->user->remove;
18005 -       lp->read = transport->kern->read;
18006 -       lp->write = transport->kern->write;
18007 -       lp->add_address = transport->user->add_address;
18008 -       lp->delete_address = transport->user->delete_address;
18009 -       lp->set_mtu = transport->user->set_mtu;
18010 +       /* lp.user is the first four bytes of the transport data, which
18011 +        * has already been initialized.  This structure assignment will
18012 +        * overwrite that, so we make sure that .user gets overwritten with
18013 +        * what it already has.
18014 +        */
18015 +       save = lp->user[0];
18016 +       *lp = ((struct uml_net_private) 
18017 +               { .list                 = LIST_HEAD_INIT(lp->list),
18018 +                 .lock                 = SPIN_LOCK_UNLOCKED,
18019 +                 .dev                  = dev,
18020 +                 .fd                   = -1,
18021 +                 .mac                  = { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0},
18022 +                 .have_mac             = device->have_mac,
18023 +                 .protocol             = transport->kern->protocol,
18024 +                 .open                 = transport->user->open,
18025 +                 .close                = transport->user->close,
18026 +                 .remove               = transport->user->remove,
18027 +                 .read                 = transport->kern->read,
18028 +                 .write                = transport->kern->write,
18029 +                 .add_address          = transport->user->add_address,
18030 +                 .delete_address       = transport->user->delete_address,
18031 +                 .set_mtu              = transport->user->set_mtu,
18032 +                 .user                 = { save } });
18033  
18034         init_timer(&lp->tl);
18035         lp->tl.function = uml_net_user_timer_expire;
18036 @@ -609,7 +582,8 @@ static int net_remove(char *str)
18037         unregister_netdev(dev);
18038  
18039         list_del(&device->list);
18040 -       free_netdev(device);
18041 +       kfree(device);
18042 +       free_netdev(dev);
18043         return(0);
18044  }
18045  
18046 --- linux-2.6.0-test6/arch/um/drivers/port_kern.c       2003-06-14 12:17:57.000000000 -0700
18047 +++ 25/arch/um/drivers/port_kern.c      2003-10-05 00:34:32.000000000 -0700
18048 @@ -6,6 +6,7 @@
18049  #include "linux/list.h"
18050  #include "linux/sched.h"
18051  #include "linux/slab.h"
18052 +#include "linux/interrupt.h"
18053  #include "linux/irq.h"
18054  #include "linux/spinlock.h"
18055  #include "linux/errno.h"
18056 @@ -14,6 +15,7 @@
18057  #include "kern_util.h"
18058  #include "kern.h"
18059  #include "irq_user.h"
18060 +#include "irq_kern.h"
18061  #include "port.h"
18062  #include "init.h"
18063  #include "os.h"
18064 @@ -44,7 +46,7 @@ struct connection {
18065         struct port_list *port;
18066  };
18067  
18068 -static void pipe_interrupt(int irq, void *data, struct pt_regs *regs)
18069 +static irqreturn_t pipe_interrupt(int irq, void *data, struct pt_regs *regs)
18070  {
18071         struct connection *conn = data;
18072         int fd;
18073 @@ -52,7 +54,7 @@ static void pipe_interrupt(int irq, void
18074         fd = os_rcv_fd(conn->socket[0], &conn->helper_pid);
18075         if(fd < 0){
18076                 if(fd == -EAGAIN)
18077 -                       return;
18078 +                       return(IRQ_NONE);
18079  
18080                 printk(KERN_ERR "pipe_interrupt : os_rcv_fd returned %d\n", 
18081                        -fd);
18082 @@ -65,6 +67,7 @@ static void pipe_interrupt(int irq, void
18083         list_add(&conn->list, &conn->port->connections);
18084  
18085         up(&conn->port->sem);
18086 +       return(IRQ_HANDLED);
18087  }
18088  
18089  static int port_accept(struct port_list *port)
18090 @@ -138,12 +141,13 @@ void port_work_proc(void *unused)
18091  
18092  DECLARE_WORK(port_work, port_work_proc, NULL);
18093  
18094 -static void port_interrupt(int irq, void *data, struct pt_regs *regs)
18095 +static irqreturn_t port_interrupt(int irq, void *data, struct pt_regs *regs)
18096  {
18097         struct port_list *port = data;
18098  
18099         port->has_connection = 1;
18100         schedule_work(&port_work);
18101 +       return(IRQ_HANDLED);
18102  } 
18103  
18104  void *port_data(int port_num)
18105 --- linux-2.6.0-test6/arch/um/drivers/ssl.c     2003-06-14 12:18:21.000000000 -0700
18106 +++ 25/arch/um/drivers/ssl.c    2003-10-05 00:34:32.000000000 -0700
18107 @@ -53,8 +53,9 @@ static int ssl_remove(char *str);
18108  
18109  static struct line_driver driver = {
18110         .name                   = "UML serial line",
18111 -       .devfs_name             = "tts/%d",
18112 -       .major                  = TTYAUX_MAJOR,
18113 +       .device_name            = "ttS",
18114 +       .devfs_name             = "tts/",
18115 +       .major                  = TTY_MAJOR,
18116         .minor_start            = 64,
18117         .type                   = TTY_DRIVER_TYPE_SERIAL,
18118         .subtype                = 0,
18119 --- linux-2.6.0-test6/arch/um/drivers/stdio_console.c   2003-06-14 12:18:04.000000000 -0700
18120 +++ 25/arch/um/drivers/stdio_console.c  2003-10-05 00:34:32.000000000 -0700
18121 @@ -83,7 +83,8 @@ static int con_remove(char *str);
18122  
18123  static struct line_driver driver = {
18124         .name                   = "UML console",
18125 -       .devfs_name             = "vc/%d",
18126 +       .device_name            = "tty",
18127 +       .devfs_name             = "vc/",
18128         .major                  = TTY_MAJOR,
18129         .minor_start            = 0,
18130         .type                   = TTY_DRIVER_TYPE_CONSOLE,
18131 @@ -159,6 +160,15 @@ static int chars_in_buffer(struct tty_st
18132  
18133  static int con_init_done = 0;
18134  
18135 +static struct tty_operations console_ops = {
18136 +       .open                   = con_open,
18137 +       .close                  = con_close,
18138 +       .write                  = con_write,
18139 +       .chars_in_buffer        = chars_in_buffer,
18140 +       .set_termios            = set_termios,
18141 +       .write_room             = line_write_room,
18142 +};
18143 +
18144  int stdio_init(void)
18145  {
18146         char *new_title;
18147 @@ -166,7 +176,8 @@ int stdio_init(void)
18148         printk(KERN_INFO "Initializing stdio console driver\n");
18149  
18150         console_driver = line_register_devfs(&console_lines, &driver,
18151 -                               &console_ops, vts, sizeof(vts)/sizeof(vts[0]));
18152 +                                            &console_ops, vts,
18153 +                                            sizeof(vts)/sizeof(vts[0]));
18154  
18155         lines_init(vts, sizeof(vts)/sizeof(vts[0]));
18156  
18157 @@ -188,15 +199,6 @@ static void console_write(struct console
18158         if(con_init_done) up(&vts[console->index].sem);
18159  }
18160  
18161 -static struct tty_operations console_ops = {
18162 -       .open                   = con_open,
18163 -       .close                  = con_close,
18164 -       .write                  = con_write,
18165 -       .chars_in_buffer        = chars_in_buffer,
18166 -       .set_termios            = set_termios,
18167 -       .write_room             = line_write_room,
18168 -};
18169 -
18170  static struct tty_driver *console_device(struct console *c, int *index)
18171  {
18172         *index = c->index;
18173 @@ -212,12 +214,14 @@ static struct console stdiocons = INIT_C
18174                                                console_device, console_setup,
18175                                                CON_PRINTBUFFER);
18176  
18177 -static void __init stdio_console_init(void)
18178 +static int __init stdio_console_init(void)
18179  {
18180         INIT_LIST_HEAD(&vts[0].chan_list);
18181         list_add(&init_console_chan.list, &vts[0].chan_list);
18182         register_console(&stdiocons);
18183 +       return(0);
18184  }
18185 +
18186  console_initcall(stdio_console_init);
18187  
18188  static int console_chan_setup(char *str)
18189 --- linux-2.6.0-test6/arch/um/drivers/ubd_kern.c        2003-09-08 13:58:56.000000000 -0700
18190 +++ 25/arch/um/drivers/ubd_kern.c       2003-10-05 00:34:32.000000000 -0700
18191 @@ -8,6 +8,13 @@
18192   * old style ubd by setting UBD_SHIFT to 0
18193   * 2002-09-27...2002-10-18 massive tinkering for 2.5
18194   * partitions have changed in 2.5
18195 + * 2003-01-29 more tinkering for 2.5.59-1
18196 + * This should now address the sysfs problems and has
18197 + * the symlink for devfs to allow for booting with
18198 + * the common /dev/ubd/discX/... names rather than
18199 + * only /dev/ubdN/discN this version also has lots of
18200 + * clean ups preparing for ubd-many.
18201 + * James McMechan
18202   */
18203  
18204  #define MAJOR_NR UBD_MAJOR
18205 @@ -40,6 +47,7 @@
18206  #include "mconsole_kern.h"
18207  #include "init.h"
18208  #include "irq_user.h"
18209 +#include "irq_kern.h"
18210  #include "ubd_user.h"
18211  #include "2_5compat.h"
18212  #include "os.h"
18213 @@ -49,9 +57,9 @@ static spinlock_t ubd_lock = SPIN_LOCK_U
18214  
18215  static void (*do_ubd)(void);
18216  
18217 -static int ubd_open(struct inode * inode, struct file * filp);
18218 -static int ubd_release(struct inode * inode, struct file * file);
18219 -static int ubd_ioctl(struct inode * inode, struct file * file,
18220 +static int ubd_open(struct block_device *bdev, struct file * filp);
18221 +static int ubd_release(struct gendisk *disk);
18222 +static int ubd_ioctl(struct block_device *bdev, struct file * file,
18223                      unsigned int cmd, unsigned long arg);
18224  
18225  #define MAX_DEV (8)
18226 @@ -67,7 +75,7 @@ static struct block_device_operations ub
18227  static request_queue_t *ubd_queue;
18228  
18229  /* Protected by ubd_lock */
18230 -static int fake_major = 0;
18231 +static int fake_major = MAJOR_NR;
18232  
18233  static struct gendisk *ubd_gendisk[MAX_DEV];
18234  static struct gendisk *fake_gendisk[MAX_DEV];
18235 @@ -96,12 +104,12 @@ struct cow {
18236  
18237  struct ubd {
18238         char *file;
18239 -       int is_dir;
18240         int count;
18241         int fd;
18242         __u64 size;
18243         struct openflags boot_openflags;
18244         struct openflags openflags;
18245 +       int no_cow;
18246         struct cow cow;
18247  };
18248  
18249 @@ -115,12 +123,12 @@ struct ubd {
18250  
18251  #define DEFAULT_UBD { \
18252         .file =                 NULL, \
18253 -       .is_dir =               0, \
18254         .count =                0, \
18255         .fd =                   -1, \
18256         .size =                 -1, \
18257         .boot_openflags =       OPEN_FLAGS, \
18258         .openflags =            OPEN_FLAGS, \
18259 +        .no_cow =               0, \
18260          .cow =                 DEFAULT_COW, \
18261  }
18262  
18263 @@ -128,8 +136,10 @@ struct ubd ubd_dev[MAX_DEV] = { [ 0 ... 
18264  
18265  static int ubd0_init(void)
18266  {
18267 -       if(ubd_dev[0].file == NULL)
18268 -               ubd_dev[0].file = "root_fs";
18269 +       struct ubd *dev = &ubd_dev[0];
18270 +
18271 +       if(dev->file == NULL)
18272 +               dev->file = "root_fs";
18273         return(0);
18274  }
18275  
18276 @@ -196,19 +206,39 @@ __uml_help(fake_ide_setup,
18277  "    Create ide0 entries that map onto ubd devices.\n\n"
18278  );
18279  
18280 +static int parse_unit(char **ptr)
18281 +{
18282 +       char *str = *ptr, *end;
18283 +       int n = -1;
18284 +
18285 +       if(isdigit(*str)) {
18286 +               n = simple_strtoul(str, &end, 0);
18287 +               if(end == str)
18288 +                       return(-1);
18289 +               *ptr = end;
18290 +       }
18291 +       else if (('a' <= *str) && (*str <= 'h')) {
18292 +               n = *str - 'a';
18293 +               str++;
18294 +               *ptr = str;
18295 +       }
18296 +       return(n);
18297 +}
18298 +
18299  static int ubd_setup_common(char *str, int *index_out)
18300  {
18301 +       struct ubd *dev;
18302         struct openflags flags = global_openflags;
18303         char *backing_file;
18304         int n, err;
18305  
18306         if(index_out) *index_out = -1;
18307 -       n = *str++;
18308 +       n = *str;
18309         if(n == '='){
18310 -               static int fake_major_allowed = 1;
18311                 char *end;
18312                 int major;
18313  
18314 +               str++;
18315                 if(!strcmp(str, "sync")){
18316                         global_openflags.s = 1;
18317                         return(0);
18318 @@ -220,20 +250,14 @@ static int ubd_setup_common(char *str, i
18319                         return(1);
18320                 }
18321  
18322 -               if(!fake_major_allowed){
18323 -                       printk(KERN_ERR "Can't assign a fake major twice\n");
18324 -                       return(1);
18325 -               }
18326 -
18327                 err = 1;
18328                 spin_lock(&ubd_lock);
18329 -               if(!fake_major_allowed){
18330 +               if(fake_major != MAJOR_NR){
18331                         printk(KERN_ERR "Can't assign a fake major twice\n");
18332                         goto out1;
18333                 }
18334   
18335                 fake_major = major;
18336 -               fake_major_allowed = 0;
18337  
18338                 printk(KERN_INFO "Setting extra ubd major number to %d\n",
18339                        major);
18340 @@ -243,25 +267,23 @@ static int ubd_setup_common(char *str, i
18341                 return(err);
18342         }
18343  
18344 -       if(n < '0'){
18345 -               printk(KERN_ERR "ubd_setup : index out of range\n"); }
18346 -
18347 -       if((n >= '0') && (n <= '9')) n -= '0';
18348 -       else if((n >= 'a') && (n <= 'z')) n -= 'a';
18349 -       else {
18350 -               printk(KERN_ERR "ubd_setup : device syntax invalid\n");
18351 +       n = parse_unit(&str);
18352 +       if(n < 0){
18353 +               printk(KERN_ERR "ubd_setup : couldn't parse unit number "
18354 +                      "'%s'\n", str);
18355                 return(1);
18356         }
18357         if(n >= MAX_DEV){
18358 -               printk(KERN_ERR "ubd_setup : index out of range "
18359 -                      "(%d devices)\n", MAX_DEV);      
18360 +               printk(KERN_ERR "ubd_setup : index %d out of range "
18361 +                      "(%d devices)\n", n, MAX_DEV);
18362                 return(1);
18363         }
18364  
18365         err = 1;
18366         spin_lock(&ubd_lock);
18367  
18368 -       if(ubd_dev[n].file != NULL){
18369 +       dev = &ubd_dev[n];
18370 +       if(dev->file != NULL){
18371                 printk(KERN_ERR "ubd_setup : device already configured\n");
18372                 goto out2;
18373         }
18374 @@ -276,6 +298,11 @@ static int ubd_setup_common(char *str, i
18375                 flags.s = 1;
18376                 str++;
18377         }
18378 +       if (*str == 'd'){
18379 +               dev->no_cow = 1;
18380 +               str++;
18381 +       }
18382 +
18383         if(*str++ != '='){
18384                 printk(KERN_ERR "ubd_setup : Expected '='\n");
18385                 goto out2;
18386 @@ -284,14 +311,17 @@ static int ubd_setup_common(char *str, i
18387         err = 0;
18388         backing_file = strchr(str, ',');
18389         if(backing_file){
18390 -               *backing_file = '\0';
18391 -               backing_file++;
18392 +               if(dev->no_cow)
18393 +                       printk(KERN_ERR "Can't specify both 'd' and a "
18394 +                              "cow file\n");
18395 +               else {
18396 +                       *backing_file = '\0';
18397 +                       backing_file++;
18398 +               }
18399         }
18400 -       ubd_dev[n].file = str;
18401 -       if(ubd_is_dir(ubd_dev[n].file))
18402 -               ubd_dev[n].is_dir = 1;
18403 -       ubd_dev[n].cow.file = backing_file;
18404 -       ubd_dev[n].boot_openflags = flags;
18405 +       dev->file = str;
18406 +       dev->cow.file = backing_file;
18407 +       dev->boot_openflags = flags;
18408   out2:
18409         spin_unlock(&ubd_lock);
18410         return(err);
18411 @@ -321,8 +351,7 @@ __uml_help(ubd_setup,
18412  static int fakehd_set = 0;
18413  static int fakehd(char *str)
18414  {
18415 -       printk(KERN_INFO 
18416 -              "fakehd : Changing ubd name to \"hd\".\n");
18417 +       printk(KERN_INFO "fakehd : Changing ubd name to \"hd\".\n");
18418         fakehd_set = 1;
18419         return 1;
18420  }
18421 @@ -391,9 +420,10 @@ static void ubd_handler(void)
18422         do_ubd_request(ubd_queue);
18423  }
18424  
18425 -static void ubd_intr(int irq, void *dev, struct pt_regs *unused)
18426 +static irqreturn_t ubd_intr(int irq, void *dev, struct pt_regs *unused)
18427  {
18428         ubd_handler();
18429 +       return(IRQ_HANDLED);
18430  }
18431  
18432  /* Only changed by ubd_init, which is an initcall. */
18433 @@ -429,16 +459,18 @@ static void ubd_close(struct ubd *dev)
18434  static int ubd_open_dev(struct ubd *dev)
18435  {
18436         struct openflags flags;
18437 -       int err, n, create_cow, *create_ptr;
18438 +       char **back_ptr;
18439 +       int err, create_cow, *create_ptr;
18440  
18441 +       dev->openflags = dev->boot_openflags;
18442         create_cow = 0;
18443         create_ptr = (dev->cow.file != NULL) ? &create_cow : NULL;
18444 -       dev->fd = open_ubd_file(dev->file, &dev->openflags, &dev->cow.file,
18445 +       back_ptr = dev->no_cow ? NULL : &dev->cow.file;
18446 +       dev->fd = open_ubd_file(dev->file, &dev->openflags, back_ptr,
18447                                 &dev->cow.bitmap_offset, &dev->cow.bitmap_len, 
18448                                 &dev->cow.data_offset, create_ptr);
18449  
18450         if((dev->fd == -ENOENT) && create_cow){
18451 -               n = dev - ubd_dev;
18452                 dev->fd = create_cow_file(dev->file, dev->cow.file, 
18453                                           dev->openflags, 1 << 9,
18454                                           &dev->cow.bitmap_offset, 
18455 @@ -455,7 +487,10 @@ static int ubd_open_dev(struct ubd *dev)
18456         if(dev->cow.file != NULL){
18457                 err = -ENOMEM;
18458                 dev->cow.bitmap = (void *) vmalloc(dev->cow.bitmap_len);
18459 -               if(dev->cow.bitmap == NULL) goto error;
18460 +               if(dev->cow.bitmap == NULL){
18461 +                       printk(KERN_ERR "Failed to vmalloc COW bitmap\n");
18462 +                       goto error;
18463 +               }
18464                 flush_tlb_kernel_vm();
18465  
18466                 err = read_cow_bitmap(dev->fd, dev->cow.bitmap, 
18467 @@ -481,17 +516,31 @@ static int ubd_new_disk(int major, u64 s
18468                         
18469  {
18470         struct gendisk *disk;
18471 +       char from[sizeof("ubd/nnnnn\0")], to[sizeof("discnnnnn/disc\0")];
18472 +       int err;
18473  
18474         disk = alloc_disk(1 << UBD_SHIFT);
18475 -       if (!disk)
18476 -               return -ENOMEM;
18477 +       if(disk == NULL)
18478 +               return(-ENOMEM);
18479  
18480         disk->major = major;
18481         disk->first_minor = unit << UBD_SHIFT;
18482         disk->fops = &ubd_blops;
18483         set_capacity(disk, size / 512);
18484 -       sprintf(disk->disk_name, "ubd");
18485 -       sprintf(disk->devfs_name, "ubd/disc%d", unit);
18486 +       if(major == MAJOR_NR){
18487 +               sprintf(disk->disk_name, "ubd%d", unit);
18488 +               sprintf(disk->devfs_name, "ubd/disc%d", unit);
18489 +               sprintf(from, "ubd/%d", unit);
18490 +               sprintf(to, "disc%d/disc", unit);
18491 +               err = devfs_mk_symlink(from, to);
18492 +               if(err)
18493 +                       printk("ubd_new_disk failed to make link from %s to "
18494 +                              "%s, error = %d\n", from, to, err);
18495 +       }
18496 +       else {
18497 +               sprintf(disk->disk_name, "ubd_fake%d", unit);
18498 +               sprintf(disk->devfs_name, "ubd_fake/disc%d", unit);
18499 +       }
18500  
18501         disk->private_data = &ubd_dev[unit];
18502         disk->queue = ubd_queue;
18503 @@ -506,10 +555,7 @@ static int ubd_add(int n)
18504         struct ubd *dev = &ubd_dev[n];
18505         int err;
18506  
18507 -       if(dev->is_dir)
18508 -               return(-EISDIR);
18509 -
18510 -       if (!dev->file)
18511 +       if(dev->file == NULL)
18512                 return(-ENODEV);
18513  
18514         if (ubd_open_dev(dev))
18515 @@ -523,7 +569,7 @@ static int ubd_add(int n)
18516         if(err) 
18517                 return(err);
18518   
18519 -       if(fake_major)
18520 +       if(fake_major != MAJOR_NR)
18521                 ubd_new_disk(fake_major, dev->size, n, 
18522                              &fake_gendisk[n]);
18523  
18524 @@ -561,42 +607,42 @@ static int ubd_config(char *str)
18525         return(err);
18526  }
18527  
18528 -static int ubd_get_config(char *dev, char *str, int size, char **error_out)
18529 +static int ubd_get_config(char *name, char *str, int size, char **error_out)
18530  {
18531 -       struct ubd *ubd;
18532 +       struct ubd *dev;
18533         char *end;
18534 -       int major, n = 0;
18535 +       int n, len = 0;
18536  
18537 -       major = simple_strtoul(dev, &end, 0);
18538 -       if((*end != '\0') || (end == dev)){
18539 -               *error_out = "ubd_get_config : didn't parse major number";
18540 +       n = simple_strtoul(name, &end, 0);
18541 +       if((*end != '\0') || (end == name)){
18542 +               *error_out = "ubd_get_config : didn't parse device number";
18543                 return(-1);
18544         }
18545  
18546 -       if((major >= MAX_DEV) || (major < 0)){
18547 -               *error_out = "ubd_get_config : major number out of range";
18548 +       if((n >= MAX_DEV) || (n < 0)){
18549 +               *error_out = "ubd_get_config : device number out of range";
18550                 return(-1);
18551         }
18552  
18553 -       ubd = &ubd_dev[major];
18554 +       dev = &ubd_dev[n];
18555         spin_lock(&ubd_lock);
18556  
18557 -       if(ubd->file == NULL){
18558 -               CONFIG_CHUNK(str, size, n, "", 1);
18559 +       if(dev->file == NULL){
18560 +               CONFIG_CHUNK(str, size, len, "", 1);
18561                 goto out;
18562         }
18563  
18564 -       CONFIG_CHUNK(str, size, n, ubd->file, 0);
18565 +       CONFIG_CHUNK(str, size, len, dev->file, 0);
18566  
18567 -       if(ubd->cow.file != NULL){
18568 -               CONFIG_CHUNK(str, size, n, ",", 0);
18569 -               CONFIG_CHUNK(str, size, n, ubd->cow.file, 1);
18570 +       if(dev->cow.file != NULL){
18571 +               CONFIG_CHUNK(str, size, len, ",", 0);
18572 +               CONFIG_CHUNK(str, size, len, dev->cow.file, 1);
18573         }
18574 -       else CONFIG_CHUNK(str, size, n, "", 1);
18575 +       else CONFIG_CHUNK(str, size, len, "", 1);
18576  
18577   out:
18578         spin_unlock(&ubd_lock);
18579 -       return(n);
18580 +       return(len);
18581  }
18582  
18583  static int ubd_remove(char *str)
18584 @@ -604,11 +650,9 @@ static int ubd_remove(char *str)
18585         struct ubd *dev;
18586         int n, err = -ENODEV;
18587  
18588 -       if(!isdigit(*str))
18589 -               return(err);    /* it should be a number 0-7/a-h */
18590 +       n = parse_unit(&str);
18591  
18592 -       n = *str - '0';
18593 -       if(n >= MAX_DEV) 
18594 +       if((n < 0) || (n >= MAX_DEV))
18595                 return(err);
18596  
18597         dev = &ubd_dev[n];
18598 @@ -669,7 +713,7 @@ int ubd_init(void)
18599                 
18600         elevator_init(ubd_queue, &elevator_noop);
18601  
18602 -       if (fake_major != 0) {
18603 +       if (fake_major != MAJOR_NR) {
18604                 char name[sizeof("ubd_nnn\0")];
18605  
18606                 snprintf(name, sizeof(name), "ubd_%d", fake_major);
18607 @@ -710,19 +754,13 @@ int ubd_driver_init(void){
18608  
18609  device_initcall(ubd_driver_init);
18610  
18611 -static int ubd_open(struct inode *inode, struct file *filp)
18612 +static int ubd_open(struct block_device *bdev, struct file *filp)
18613  {
18614 -       struct gendisk *disk = inode->i_bdev->bd_disk;
18615 +       struct gendisk *disk = bdev->bd_disk;
18616         struct ubd *dev = disk->private_data;
18617 -       int err = -EISDIR;
18618 -
18619 -       if(dev->is_dir == 1)
18620 -               goto out;
18621 +       int err = 0;
18622  
18623 -       err = 0;
18624         if(dev->count == 0){
18625 -               dev->openflags = dev->boot_openflags;
18626 -
18627                 err = ubd_open_dev(dev);
18628                 if(err){
18629                         printk(KERN_ERR "%s: Can't open \"%s\": errno = %d\n",
18630 @@ -739,9 +777,8 @@ static int ubd_open(struct inode *inode,
18631         return(err);
18632  }
18633  
18634 -static int ubd_release(struct inode * inode, struct file * file)
18635 +static int ubd_release(struct gendisk *disk)
18636  {
18637 -       struct gendisk *disk = inode->i_bdev->bd_disk;
18638         struct ubd *dev = disk->private_data;
18639  
18640         if(--dev->count == 0)
18641 @@ -796,15 +833,6 @@ static int prepare_request(struct reques
18642  
18643         if(req->rq_status == RQ_INACTIVE) return(1);
18644  
18645 -       if(dev->is_dir){
18646 -               strcpy(req->buffer, "HOSTFS:");
18647 -               strcat(req->buffer, dev->file);
18648 -               spin_lock(&ubd_io_lock);
18649 -               end_request(req, 1);
18650 -               spin_unlock(&ubd_io_lock);
18651 -               return(1);
18652 -       }
18653 -
18654         if((rq_data_dir(req) == WRITE) && !dev->openflags.w){
18655                 printk("Write attempted on readonly ubd device %s\n", 
18656                        disk->disk_name);
18657 @@ -865,11 +893,11 @@ static void do_ubd_request(request_queue
18658         }
18659  }
18660  
18661 -static int ubd_ioctl(struct inode * inode, struct file * file,
18662 +static int ubd_ioctl(struct block_device *bdev, struct file * file,
18663                      unsigned int cmd, unsigned long arg)
18664  {
18665         struct hd_geometry *loc = (struct hd_geometry *) arg;
18666 -       struct ubd *dev = inode->i_bdev->bd_disk->private_data;
18667 +       struct ubd *dev = bdev->bd_disk->private_data;
18668         int err;
18669         struct hd_driveid ubd_id = {
18670                 .cyls           = 0,
18671 @@ -890,7 +918,7 @@ static int ubd_ioctl(struct inode * inod
18672  
18673         case HDIO_SET_UNMASKINTR:
18674                 if(!capable(CAP_SYS_ADMIN)) return(-EACCES);
18675 -               if((arg > 1) || (inode->i_bdev->bd_contains != inode->i_bdev))
18676 +               if((arg > 1) || (bdev->bd_contains != bdev))
18677                         return(-EINVAL);
18678                 return(0);
18679  
18680 @@ -910,7 +938,7 @@ static int ubd_ioctl(struct inode * inod
18681  
18682         case HDIO_SET_MULTCOUNT:
18683                 if(!capable(CAP_SYS_ADMIN)) return(-EACCES);
18684 -               if(inode->i_bdev->bd_contains != inode->i_bdev)
18685 +               if(bdev->bd_contains != bdev)
18686                         return(-EINVAL);
18687                 return(0);
18688  
18689 --- linux-2.6.0-test6/arch/um/drivers/ubd_user.c        2003-06-14 12:18:04.000000000 -0700
18690 +++ 25/arch/um/drivers/ubd_user.c       2003-10-05 00:34:32.000000000 -0700
18691 @@ -24,142 +24,24 @@
18692  #include "user.h"
18693  #include "ubd_user.h"
18694  #include "os.h"
18695 +#include "cow.h"
18696  
18697  #include <endian.h>
18698  #include <byteswap.h>
18699 -#if __BYTE_ORDER == __BIG_ENDIAN
18700 -# define ntohll(x) (x)
18701 -# define htonll(x) (x)
18702 -#elif __BYTE_ORDER == __LITTLE_ENDIAN
18703 -# define ntohll(x)  bswap_64(x)
18704 -# define htonll(x)  bswap_64(x)
18705 -#else
18706 -#error "__BYTE_ORDER not defined"
18707 -#endif
18708 -
18709 -#define PATH_LEN_V1 256
18710 -
18711 -struct cow_header_v1 {
18712 -       int magic;
18713 -       int version;
18714 -       char backing_file[PATH_LEN_V1];
18715 -       time_t mtime;
18716 -       __u64 size;
18717 -       int sectorsize;
18718 -};
18719 -
18720 -#define PATH_LEN_V2 MAXPATHLEN
18721 -
18722 -struct cow_header_v2 {
18723 -       unsigned long magic;
18724 -       unsigned long version;
18725 -       char backing_file[PATH_LEN_V2];
18726 -       time_t mtime;
18727 -       __u64 size;
18728 -       int sectorsize;
18729 -};
18730 -
18731 -union cow_header {
18732 -       struct cow_header_v1 v1;
18733 -       struct cow_header_v2 v2;
18734 -};
18735 -
18736 -#define COW_MAGIC 0x4f4f4f4d  /* MOOO */
18737 -#define COW_VERSION 2
18738 -
18739 -static void sizes(__u64 size, int sectorsize, int bitmap_offset, 
18740 -                 unsigned long *bitmap_len_out, int *data_offset_out)
18741 -{
18742 -       *bitmap_len_out = (size + sectorsize - 1) / (8 * sectorsize);
18743 -
18744 -       *data_offset_out = bitmap_offset + *bitmap_len_out;
18745 -       *data_offset_out = (*data_offset_out + sectorsize - 1) / sectorsize;
18746 -       *data_offset_out *= sectorsize;
18747 -}
18748 -
18749 -static int read_cow_header(int fd, int *magic_out, char **backing_file_out, 
18750 -                          time_t *mtime_out, __u64 *size_out, 
18751 -                          int *sectorsize_out, int *bitmap_offset_out)
18752 -{
18753 -       union cow_header *header;
18754 -       char *file;
18755 -       int err, n;
18756 -       unsigned long version, magic;
18757 -
18758 -       header = um_kmalloc(sizeof(*header));
18759 -       if(header == NULL){
18760 -               printk("read_cow_header - Failed to allocate header\n");
18761 -               return(-ENOMEM);
18762 -       }
18763 -       err = -EINVAL;
18764 -       n = read(fd, header, sizeof(*header));
18765 -       if(n < offsetof(typeof(header->v1), backing_file)){
18766 -               printk("read_cow_header - short header\n");
18767 -               goto out;
18768 -       }
18769 -
18770 -       magic = header->v1.magic;
18771 -       if(magic == COW_MAGIC) {
18772 -               version = header->v1.version;
18773 -       }
18774 -       else if(magic == ntohl(COW_MAGIC)){
18775 -               version = ntohl(header->v1.version);
18776 -       }
18777 -       else goto out;
18778 -
18779 -       *magic_out = COW_MAGIC;
18780 -
18781 -       if(version == 1){
18782 -               if(n < sizeof(header->v1)){
18783 -                       printk("read_cow_header - failed to read V1 header\n");
18784 -                       goto out;
18785 -               }
18786 -               *mtime_out = header->v1.mtime;
18787 -               *size_out = header->v1.size;
18788 -               *sectorsize_out = header->v1.sectorsize;
18789 -               *bitmap_offset_out = sizeof(header->v1);
18790 -               file = header->v1.backing_file;
18791 -       }
18792 -       else if(version == 2){
18793 -               if(n < sizeof(header->v2)){
18794 -                       printk("read_cow_header - failed to read V2 header\n");
18795 -                       goto out;
18796 -               }
18797 -               *mtime_out = ntohl(header->v2.mtime);
18798 -               *size_out = ntohll(header->v2.size);
18799 -               *sectorsize_out = ntohl(header->v2.sectorsize);
18800 -               *bitmap_offset_out = sizeof(header->v2);
18801 -               file = header->v2.backing_file;
18802 -       }
18803 -       else {
18804 -               printk("read_cow_header - invalid COW version\n");
18805 -               goto out;
18806 -       }
18807 -       err = -ENOMEM;
18808 -       *backing_file_out = uml_strdup(file);
18809 -       if(*backing_file_out == NULL){
18810 -               printk("read_cow_header - failed to allocate backing file\n");
18811 -               goto out;
18812 -       }
18813 -       err = 0;
18814 - out:
18815 -       kfree(header);
18816 -       return(err);
18817 -}
18818  
18819  static int same_backing_files(char *from_cmdline, char *from_cow, char *cow)
18820  {
18821 -       struct stat buf1, buf2;
18822 +       struct stat64 buf1, buf2;
18823  
18824         if(from_cmdline == NULL) return(1);
18825         if(!strcmp(from_cmdline, from_cow)) return(1);
18826  
18827 -       if(stat(from_cmdline, &buf1) < 0){
18828 +       if(stat64(from_cmdline, &buf1) < 0){
18829                 printk("Couldn't stat '%s', errno = %d\n", from_cmdline, 
18830                        errno);
18831                 return(1);
18832         }
18833 -       if(stat(from_cow, &buf2) < 0){
18834 +       if(stat64(from_cow, &buf2) < 0){
18835                 printk("Couldn't stat '%s', errno = %d\n", from_cow, errno);
18836                 return(1);
18837         }
18838 @@ -215,118 +97,6 @@ int read_cow_bitmap(int fd, void *buf, i
18839         return(0);
18840  }
18841  
18842 -static int absolutize(char *to, int size, char *from)
18843 -{
18844 -       char save_cwd[256], *slash;
18845 -       int remaining;
18846 -
18847 -       if(getcwd(save_cwd, sizeof(save_cwd)) == NULL) {
18848 -               printk("absolutize : unable to get cwd - errno = %d\n", errno);
18849 -               return(-1);
18850 -       }
18851 -       slash = strrchr(from, '/');
18852 -       if(slash != NULL){
18853 -               *slash = '\0';
18854 -               if(chdir(from)){
18855 -                       *slash = '/';
18856 -                       printk("absolutize : Can't cd to '%s' - errno = %d\n",
18857 -                              from, errno);
18858 -                       return(-1);
18859 -               }
18860 -               *slash = '/';
18861 -               if(getcwd(to, size) == NULL){
18862 -                       printk("absolutize : unable to get cwd of '%s' - "
18863 -                              "errno = %d\n", from, errno);
18864 -                       return(-1);
18865 -               }
18866 -               remaining = size - strlen(to);
18867 -               if(strlen(slash) + 1 > remaining){
18868 -                       printk("absolutize : unable to fit '%s' into %d "
18869 -                              "chars\n", from, size);
18870 -                       return(-1);
18871 -               }
18872 -               strcat(to, slash);
18873 -       }
18874 -       else {
18875 -               if(strlen(save_cwd) + 1 + strlen(from) + 1 > size){
18876 -                       printk("absolutize : unable to fit '%s' into %d "
18877 -                              "chars\n", from, size);
18878 -                       return(-1);
18879 -               }
18880 -               strcpy(to, save_cwd);
18881 -               strcat(to, "/");
18882 -               strcat(to, from);
18883 -       }
18884 -       chdir(save_cwd);
18885 -       return(0);
18886 -}
18887 -
18888 -static int write_cow_header(char *cow_file, int fd, char *backing_file, 
18889 -                           int sectorsize, long long *size)
18890 -{
18891 -        struct cow_header_v2 *header;
18892 -       struct stat64 buf;
18893 -       int err;
18894 -
18895 -       err = os_seek_file(fd, 0);
18896 -       if(err != 0){
18897 -               printk("write_cow_header - lseek failed, errno = %d\n", errno);
18898 -               return(-errno);
18899 -       }
18900 -
18901 -       err = -ENOMEM;
18902 -       header = um_kmalloc(sizeof(*header));
18903 -       if(header == NULL){
18904 -               printk("Failed to allocate COW V2 header\n");
18905 -               goto out;
18906 -       }
18907 -       header->magic = htonl(COW_MAGIC);
18908 -       header->version = htonl(COW_VERSION);
18909 -
18910 -       err = -EINVAL;
18911 -       if(strlen(backing_file) > sizeof(header->backing_file) - 1){
18912 -               printk("Backing file name \"%s\" is too long - names are "
18913 -                      "limited to %d characters\n", backing_file, 
18914 -                      sizeof(header->backing_file) - 1);
18915 -               goto out_free;
18916 -       }
18917 -
18918 -       if(absolutize(header->backing_file, sizeof(header->backing_file), 
18919 -                     backing_file))
18920 -               goto out_free;
18921 -
18922 -       err = stat64(header->backing_file, &buf);
18923 -       if(err < 0){
18924 -               printk("Stat of backing file '%s' failed, errno = %d\n",
18925 -                      header->backing_file, errno);
18926 -               err = -errno;
18927 -               goto out_free;
18928 -       }
18929 -
18930 -       err = os_file_size(header->backing_file, size);
18931 -       if(err){
18932 -               printk("Couldn't get size of backing file '%s', errno = %d\n",
18933 -                      header->backing_file, -*size);
18934 -               goto out_free;
18935 -       }
18936 -
18937 -       header->mtime = htonl(buf.st_mtime);
18938 -       header->size = htonll(*size);
18939 -       header->sectorsize = htonl(sectorsize);
18940 -
18941 -       err = write(fd, header, sizeof(*header));
18942 -       if(err != sizeof(*header)){
18943 -               printk("Write of header to new COW file '%s' failed, "
18944 -                      "errno = %d\n", cow_file, errno);
18945 -               goto out_free;
18946 -       }
18947 -       err = 0;
18948 - out_free:
18949 -       kfree(header);
18950 - out:
18951 -       return(err);
18952 -}
18953 -
18954  int open_ubd_file(char *file, struct openflags *openflags, 
18955                   char **backing_file_out, int *bitmap_offset_out, 
18956                   unsigned long *bitmap_len_out, int *data_offset_out, 
18957 @@ -346,10 +116,17 @@ int open_ubd_file(char *file, struct ope
18958                  if((fd = os_open_file(file, *openflags, mode)) < 0) 
18959                         return(fd);
18960          }
18961 +
18962 +       err = os_lock_file(fd, openflags->w);
18963 +       if(err){
18964 +               printk("Failed to lock '%s', errno = %d\n", file, -err);
18965 +               goto error;
18966 +       }
18967 +       
18968         if(backing_file_out == NULL) return(fd);
18969  
18970 -       err = read_cow_header(fd, &magic, &backing_file, &mtime, &size, 
18971 -                             &sectorsize, bitmap_offset_out);
18972 +       err = read_cow_header(file_reader, &fd, &magic, &backing_file, &mtime, 
18973 +                             &size, &sectorsize, bitmap_offset_out);
18974         if(err && (*backing_file_out != NULL)){
18975                 printk("Failed to read COW header from COW file \"%s\", "
18976                        "errno = %d\n", file, err);
18977 @@ -376,12 +153,12 @@ int open_ubd_file(char *file, struct ope
18978                 if(err) goto error;
18979         }
18980  
18981 -       sizes(size, sectorsize, *bitmap_offset_out, bitmap_len_out, 
18982 -             data_offset_out);
18983 +       cow_sizes(size, sectorsize, *bitmap_offset_out, bitmap_len_out, 
18984 +                 data_offset_out);
18985  
18986          return(fd);
18987   error:
18988 -       close(fd);
18989 +       os_close_file(fd);
18990         return(err);
18991  }
18992  
18993 @@ -389,10 +166,7 @@ int create_cow_file(char *cow_file, char
18994                     int sectorsize, int *bitmap_offset_out, 
18995                     unsigned long *bitmap_len_out, int *data_offset_out)
18996  {
18997 -       __u64 blocks;
18998 -       long zero;
18999 -       int err, fd, i;
19000 -       long long size;
19001 +       int err, fd;
19002  
19003         flags.c = 1;
19004         fd = open_ubd_file(cow_file, &flags, NULL, NULL, NULL, NULL, NULL);
19005 @@ -403,29 +177,12 @@ int create_cow_file(char *cow_file, char
19006                 goto out;
19007         }
19008  
19009 -       err = write_cow_header(cow_file, fd, backing_file, sectorsize, &size);
19010 -       if(err) goto out_close;
19011 -
19012 -       blocks = (size + sectorsize - 1) / sectorsize;
19013 -       blocks = (blocks + sizeof(long) * 8 - 1) / (sizeof(long) * 8);
19014 -       zero = 0;
19015 -       for(i = 0; i < blocks; i++){
19016 -               err = write(fd, &zero, sizeof(zero));
19017 -               if(err != sizeof(zero)){
19018 -                       printk("Write of bitmap to new COW file '%s' failed, "
19019 -                              "errno = %d\n", cow_file, errno);
19020 -                       goto out_close;
19021 -               }
19022 -       }
19023 -
19024 -       sizes(size, sectorsize, sizeof(struct cow_header_v2), 
19025 -             bitmap_len_out, data_offset_out);
19026 -       *bitmap_offset_out = sizeof(struct cow_header_v2);
19027 -
19028 -       return(fd);
19029 -
19030 - out_close:
19031 -       close(fd);
19032 +       err = init_cow_file(fd, cow_file, backing_file, sectorsize, 
19033 +                           bitmap_offset_out, bitmap_len_out, 
19034 +                           data_offset_out);
19035 +       if(!err)
19036 +               return(fd);
19037 +       os_close_file(fd);
19038   out:
19039         return(err);
19040  }
19041 @@ -448,14 +205,6 @@ int write_ubd_fs(int fd, char *buffer, i
19042         else return(n);
19043  }
19044  
19045 -int ubd_is_dir(char *file)
19046 -{
19047 -       struct stat64 buf;
19048 -
19049 -       if(stat64(file, &buf) < 0) return(0);
19050 -       return(S_ISDIR(buf.st_mode));
19051 -}
19052 -
19053  void do_io(struct io_thread_req *req)
19054  {
19055         char *buf;
19056 --- linux-2.6.0-test6/arch/um/drivers/xterm.c   2003-06-14 12:17:57.000000000 -0700
19057 +++ 25/arch/um/drivers/xterm.c  2003-10-05 00:34:32.000000000 -0700
19058 @@ -108,7 +108,7 @@ int xterm_open(int input, int output, in
19059         }
19060         close(fd);
19061  
19062 -       fd = create_unix_socket(file, sizeof(file));
19063 +       fd = create_unix_socket(file, sizeof(file), 1);
19064         if(fd < 0){
19065                 printk("xterm_open : create_unix_socket failed, errno = %d\n", 
19066                        -fd);
19067 --- linux-2.6.0-test6/arch/um/drivers/xterm_kern.c      2003-06-14 12:18:28.000000000 -0700
19068 +++ 25/arch/um/drivers/xterm_kern.c     2003-10-05 00:34:32.000000000 -0700
19069 @@ -5,9 +5,12 @@
19070  
19071  #include "linux/errno.h"
19072  #include "linux/slab.h"
19073 +#include "linux/signal.h"
19074 +#include "linux/interrupt.h"
19075  #include "asm/semaphore.h"
19076  #include "asm/irq.h"
19077  #include "irq_user.h"
19078 +#include "irq_kern.h"
19079  #include "kern_util.h"
19080  #include "os.h"
19081  #include "xterm.h"
19082 @@ -19,17 +22,18 @@ struct xterm_wait {
19083         int new_fd;
19084  };
19085  
19086 -static void xterm_interrupt(int irq, void *data, struct pt_regs *regs)
19087 +static irqreturn_t xterm_interrupt(int irq, void *data, struct pt_regs *regs)
19088  {
19089         struct xterm_wait *xterm = data;
19090         int fd;
19091  
19092         fd = os_rcv_fd(xterm->fd, &xterm->pid);
19093         if(fd == -EAGAIN)
19094 -               return;
19095 +               return(IRQ_NONE);
19096  
19097         xterm->new_fd = fd;
19098         up(&xterm->sem);
19099 +       return(IRQ_HANDLED);
19100  }
19101  
19102  int xterm_fd(int socket, int *pid_out)
19103 --- linux-2.6.0-test6/arch/um/dyn.lds.S 2003-06-14 12:18:21.000000000 -0700
19104 +++ 25/arch/um/dyn.lds.S        2003-10-05 00:34:32.000000000 -0700
19105 @@ -15,7 +15,11 @@ SECTIONS
19106    . = ALIGN(4096);             /* Init code and data */
19107    _stext = .;
19108    __init_begin = .;
19109 -  .text.init : { *(.text.init) }
19110 +  .init.text : { 
19111 +       _sinittext = .;
19112 +       *(.init.text)
19113 +       _einittext = .;
19114 +  }
19115  
19116    . = ALIGN(4096);
19117  
19118 @@ -67,7 +71,7 @@ SECTIONS
19119  
19120    #include "asm/common.lds.S"
19121  
19122 -  .data.init : { *(.data.init) }
19123 +  init.data : { *(.init.data) }
19124  
19125    /* Ensure the __preinit_array_start label is properly aligned.  We
19126       could instead move the label definition inside the section, but
19127 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
19128 +++ 25/arch/um/include/irq_kern.h       2003-10-05 00:34:32.000000000 -0700
19129 @@ -0,0 +1,28 @@
19130 +/* 
19131 + * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
19132 + * Licensed under the GPL
19133 + */
19134 +
19135 +#ifndef __IRQ_KERN_H__
19136 +#define __IRQ_KERN_H__
19137 +
19138 +#include "linux/interrupt.h"
19139 +
19140 +extern int um_request_irq(unsigned int irq, int fd, int type,
19141 +                         irqreturn_t (*handler)(int, void *, 
19142 +                                                struct pt_regs *),
19143 +                         unsigned long irqflags,  const char * devname,
19144 +                         void *dev_id);
19145 +
19146 +#endif
19147 +
19148 +/*
19149 + * Overrides for Emacs so that we follow Linus's tabbing style.
19150 + * Emacs will notice this stuff at the end of the file and automatically
19151 + * adjust the settings for this buffer only.  This must remain at the end
19152 + * of the file.
19153 + * ---------------------------------------------------------------------------
19154 + * Local variables:
19155 + * c-file-style: "linux"
19156 + * End:
19157 + */
19158 --- linux-2.6.0-test6/arch/um/include/kern_util.h       2003-06-14 12:18:07.000000000 -0700
19159 +++ 25/arch/um/include/kern_util.h      2003-10-05 00:34:32.000000000 -0700
19160 @@ -63,10 +63,9 @@ extern void init_flush_vm(void);
19161  extern void *syscall_sp(void *t);
19162  extern void syscall_trace(void);
19163  extern int hz(void);
19164 -extern void idle_timer(void);
19165 +extern void uml_idle_timer(void);
19166  extern unsigned int do_IRQ(int irq, union uml_pt_regs *regs);
19167  extern int external_pid(void *t);
19168 -extern int pid_to_processor_id(int pid);
19169  extern void boot_timer_handler(int sig);
19170  extern void interrupt_end(void);
19171  extern void initial_thread_cb(void (*proc)(void *), void *arg);
19172 @@ -90,9 +89,7 @@ extern int remove_gdb(void);
19173  extern char *uml_strdup(char *string);
19174  extern void unprotect_kernel_mem(void);
19175  extern void protect_kernel_mem(void);
19176 -extern void set_kmem_end(unsigned long);
19177  extern void uml_cleanup(void);
19178 -extern int pid_to_processor_id(int pid);
19179  extern void set_current(void *t);
19180  extern void lock_signalled_task(void *t);
19181  extern void IPI_handler(int cpu);
19182 @@ -101,7 +98,9 @@ extern void *get_init_task(void);
19183  extern int clear_user_proc(void *buf, int size);
19184  extern int copy_to_user_proc(void *to, void *from, int size);
19185  extern int copy_from_user_proc(void *to, void *from, int size);
19186 +extern int strlen_user_proc(char *str);
19187  extern void bus_handler(int sig, union uml_pt_regs *regs);
19188 +extern void winch(int sig, union uml_pt_regs *regs);
19189  extern long execute_syscall(void *r);
19190  extern int smp_sigio_handler(void);
19191  extern void *get_current(void);
19192 --- linux-2.6.0-test6/arch/um/include/line.h    2003-06-14 12:18:29.000000000 -0700
19193 +++ 25/arch/um/include/line.h   2003-10-05 00:34:32.000000000 -0700
19194 @@ -9,12 +9,14 @@
19195  #include "linux/list.h"
19196  #include "linux/workqueue.h"
19197  #include "linux/tty.h"
19198 +#include "linux/interrupt.h"
19199  #include "asm/semaphore.h"
19200  #include "chan_user.h"
19201  #include "mconsole_kern.h"
19202  
19203  struct line_driver {
19204         char *name;
19205 +       char *device_name;
19206         char *devfs_name;
19207         short major;
19208         short minor_start;
19209 @@ -67,8 +69,9 @@ struct lines {
19210  
19211  #define LINES_INIT(n) {  num :         n }
19212  
19213 -extern void line_interrupt(int irq, void *data, struct pt_regs *unused);
19214 -extern void line_write_interrupt(int irq, void *data, struct pt_regs *unused);
19215 +extern irqreturn_t line_interrupt(int irq, void *data, struct pt_regs *unused);
19216 +extern irqreturn_t line_write_interrupt(int irq, void *data, 
19217 +                                       struct pt_regs *unused);
19218  extern void line_close(struct line *lines, struct tty_struct *tty);
19219  extern int line_open(struct line *lines, struct tty_struct *tty, 
19220                      struct chan_opts *opts);
19221 --- linux-2.6.0-test6/arch/um/include/mconsole.h        2003-06-14 12:18:08.000000000 -0700
19222 +++ 25/arch/um/include/mconsole.h       2003-10-05 00:34:32.000000000 -0700
19223 @@ -77,6 +77,7 @@ extern void mconsole_sysrq(struct mc_req
19224  extern void mconsole_cad(struct mc_request *req);
19225  extern void mconsole_stop(struct mc_request *req);
19226  extern void mconsole_go(struct mc_request *req);
19227 +extern void mconsole_log(struct mc_request *req);
19228  
19229  extern int mconsole_get_request(int fd, struct mc_request *req);
19230  extern int mconsole_notify(char *sock_name, int type, const void *data, 
19231 --- linux-2.6.0-test6/arch/um/include/mem.h     2003-06-14 12:18:51.000000000 -0700
19232 +++ 25/arch/um/include/mem.h    2003-10-05 00:34:32.000000000 -0700
19233 @@ -13,7 +13,6 @@ struct vm_reserved {
19234  };
19235  
19236  extern void set_usable_vm(unsigned long start, unsigned long end);
19237 -extern void set_kmem_end(unsigned long new);
19238  
19239  #endif
19240  
19241 --- linux-2.6.0-test6/arch/um/include/mem_user.h        2003-06-14 12:18:25.000000000 -0700
19242 +++ 25/arch/um/include/mem_user.h       2003-10-05 00:34:32.000000000 -0700
19243 @@ -51,9 +51,6 @@ extern unsigned long task_size;
19244  
19245  extern int init_mem_user(void);
19246  extern int create_mem_file(unsigned long len);
19247 -extern void setup_range(int fd, char *driver, unsigned long start,
19248 -                       unsigned long pfn, unsigned long total, int need_vm, 
19249 -                       struct mem_region *region, void *reserved);
19250  extern void setup_memory(void *entry);
19251  extern unsigned long find_iomem(char *driver, unsigned long *len_out);
19252  extern int init_maps(struct mem_region *region);
19253 --- linux-2.6.0-test6/arch/um/include/os.h      2003-06-14 12:18:02.000000000 -0700
19254 +++ 25/arch/um/include/os.h     2003-10-05 00:34:32.000000000 -0700
19255 @@ -103,10 +103,11 @@ extern int os_accept_connection(int fd);
19256  extern int os_shutdown_socket(int fd, int r, int w);
19257  extern void os_close_file(int fd);
19258  extern int os_rcv_fd(int fd, int *helper_pid_out);
19259 -extern int create_unix_socket(char *file, int len);
19260 +extern int create_unix_socket(char *file, int len, int close_on_exec);
19261  extern int os_connect_socket(char *name);
19262  extern int os_file_type(char *file);
19263  extern int os_file_mode(char *file, struct openflags *mode_out);
19264 +extern int os_lock_file(int fd, int excl);
19265  
19266  extern unsigned long os_process_pc(int pid);
19267  extern int os_process_parent(int pid);
19268 @@ -120,6 +121,7 @@ extern int os_map_memory(void *virt, int
19269  extern int os_protect_memory(void *addr, unsigned long len, 
19270                              int r, int w, int x);
19271  extern int os_unmap_memory(void *addr, int len);
19272 +extern void os_flush_stdout(void);
19273  
19274  #endif
19275  
19276 --- linux-2.6.0-test6/arch/um/include/sysdep-i386/sigcontext.h  2003-06-14 12:18:28.000000000 -0700
19277 +++ 25/arch/um/include/sysdep-i386/sigcontext.h 2003-10-05 00:34:32.000000000 -0700
19278 @@ -28,8 +28,8 @@
19279   */
19280  #define SC_START_SYSCALL(sc) do SC_EAX(sc) = -ENOSYS; while(0)
19281  
19282 -/* These are General Protection and Page Fault */
19283 -#define SEGV_IS_FIXABLE(trap) ((trap == 13) || (trap == 14))
19284 +/* This is Page Fault */
19285 +#define SEGV_IS_FIXABLE(trap) (trap == 14)
19286  
19287  #define SC_SEGV_IS_FIXABLE(sc) (SEGV_IS_FIXABLE(SC_TRAPNO(sc)))
19288  
19289 --- linux-2.6.0-test6/arch/um/include/ubd_user.h        2003-06-14 12:18:22.000000000 -0700
19290 +++ 25/arch/um/include/ubd_user.h       2003-10-05 00:34:32.000000000 -0700
19291 @@ -39,7 +39,6 @@ extern int read_ubd_fs(int fd, void *buf
19292  extern int write_ubd_fs(int fd, char *buffer, int len);
19293  extern int start_io_thread(unsigned long sp, int *fds_out);
19294  extern void do_io(struct io_thread_req *req);
19295 -extern int ubd_is_dir(char *file);
19296  
19297  static inline int ubd_test_bit(__u64 bit, unsigned char *data)
19298  {
19299 --- linux-2.6.0-test6/arch/um/include/user.h    2003-06-14 12:17:57.000000000 -0700
19300 +++ 25/arch/um/include/user.h   2003-10-05 00:34:32.000000000 -0700
19301 @@ -14,7 +14,7 @@ extern void *um_kmalloc_atomic(int size)
19302  extern void kfree(void *ptr);
19303  extern int in_aton(char *str);
19304  extern int open_gdb_chan(void);
19305 -
19306 +extern int strlcpy(char *, const char *, int);
19307  #endif
19308  
19309  /*
19310 --- linux-2.6.0-test6/arch/um/include/user_util.h       2003-06-14 12:17:58.000000000 -0700
19311 +++ 25/arch/um/include/user_util.h      2003-10-05 00:34:32.000000000 -0700
19312 @@ -59,7 +59,6 @@ extern int wait_for_stop(int pid, int si
19313  extern void *add_signal_handler(int sig, void (*handler)(int));
19314  extern int start_fork_tramp(void *arg, unsigned long temp_stack, 
19315                             int clone_flags, int (*tramp)(void *));
19316 -extern int clone_and_wait(int (*fn)(void *), void *arg, void *sp, int flags);
19317  extern int linux_main(int argc, char **argv);
19318  extern void set_cmdline(char *cmd);
19319  extern void input_cb(void (*proc)(void *), void *arg, int arg_len);
19320 @@ -90,7 +89,8 @@ extern int arch_handle_signal(int sig, u
19321  extern int arch_fixup(unsigned long address, void *sc_ptr);
19322  extern void forward_pending_sigio(int target);
19323  extern int can_do_skas(void);
19324
19325 +extern void arch_init_thread(void);
19326 +
19327  #endif
19328  
19329  /*
19330 --- linux-2.6.0-test6/arch/um/Kconfig   2003-08-08 22:55:11.000000000 -0700
19331 +++ 25/arch/um/Kconfig  2003-10-05 00:34:32.000000000 -0700
19332 @@ -61,6 +61,20 @@ config MODE_SKAS
19333  
19334  config NET
19335         bool "Networking support"
19336 +       help
19337 +       Unless you really know what you are doing, you should say Y here.
19338 +       The reason is that some programs need kernel networking support even
19339 +       when running on a stand-alone machine that isn't connected to any
19340 +       other computer. If you are upgrading from an older kernel, you
19341 +       should consider updating your networking tools too because changes
19342 +       in the kernel and the tools often go hand in hand. The tools are
19343 +       contained in the package net-tools, the location and version number
19344 +       of which are given in Documentation/Changes.
19345 +
19346 +       For a general introduction to Linux networking, it is highly
19347 +       recommended to read the NET-HOWTO, available from
19348 +       <http://www.tldp.org/docs.html#howto>.
19349 +
19350  
19351  source "fs/Kconfig.binfmt"
19352  
19353 @@ -105,6 +119,16 @@ config MCONSOLE
19354  config MAGIC_SYSRQ
19355         bool "Magic SysRq key"
19356         depends on MCONSOLE
19357 +       help
19358 +       If you say Y here, you will have some control over the system even
19359 +       if the system crashes for example during kernel debugging (e.g., you
19360 +       will be able to flush the buffer cache to disk, reboot the system
19361 +       immediately or dump some status information). This is accomplished
19362 +       by pressing various keys while holding SysRq (Alt+PrintScreen). It
19363 +       also works on a serial console (on PC hardware at least), if you
19364 +       send a BREAK and then within 5 seconds a command keypress. The
19365 +       keys are documented in Documentation/sysrq.txt. Don't say Y
19366 +       unless you really know what this hack does.
19367  
19368  config HOST_2G_2G
19369         bool "2G/2G host address space split"
19370 @@ -239,6 +263,10 @@ config FRAME_POINTER
19371  config PT_PROXY
19372         bool "Enable ptrace proxy"
19373         depends on XTERM_CHAN && DEBUG_INFO
19374 +       help
19375 +       This option enables a debugging interface which allows gdb to debug
19376 +       the kernel without needing to actually attach to kernel threads.
19377 +       If you want to do kernel debugging, say Y here; otherwise say N.
19378  
19379  config GPROF
19380         bool "Enable gprof support"
19381 --- linux-2.6.0-test6/arch/um/Kconfig_block     2003-06-14 12:18:25.000000000 -0700
19382 +++ 25/arch/um/Kconfig_block    2003-10-05 00:34:32.000000000 -0700
19383 @@ -29,6 +29,20 @@ config BLK_DEV_UBD_SYNC
19384          wise choice too.  In all other cases (for example, if you're just
19385          playing around with User-Mode Linux) you can choose N.
19386  
19387 +# Turn this back on when the driver actually works
19388 +#
19389 +#config BLK_DEV_COW
19390 +#      tristate "COW block device"
19391 +#      help
19392 +#      This is a layered driver which sits above two other block devices.
19393 +#      One is read-only, and the other is a read-write layer which stores
19394 +#      all changes.  This provides the illusion that the read-only layer
19395 +#      can be mounted read-write and changed.
19396 +
19397 +config BLK_DEV_COW_COMMON
19398 +       bool
19399 +       default BLK_DEV_COW || BLK_DEV_UBD
19400 +
19401  config BLK_DEV_LOOP
19402         tristate "Loopback device support"
19403  
19404 --- linux-2.6.0-test6/arch/um/Kconfig_net       2003-06-14 12:18:23.000000000 -0700
19405 +++ 25/arch/um/Kconfig_net      2003-10-05 00:34:32.000000000 -0700
19406 @@ -1,5 +1,5 @@
19407  
19408 -menu "Network Devices"
19409 +menu "UML Network Devices"
19410         depends on NET
19411  
19412  # UML virtual driver
19413 @@ -176,73 +176,5 @@ config UML_NET_SLIRP
19414         
19415          Startup example: "eth0=slirp,FE:FD:01:02:03:04,/usr/local/bin/slirp"
19416  
19417 -
19418 -# Below are hardware-independent drivers mirrored from
19419 -# drivers/net/Config.in. It would be nice if Linux
19420 -# had HW independent drivers separated from the other
19421 -# but it does not. Until then each non-ISA/PCI arch
19422 -# needs to provide it's own menu of network drivers
19423 -config DUMMY
19424 -       tristate "Dummy net driver support"
19425 -
19426 -config BONDING
19427 -       tristate "Bonding driver support"
19428 -
19429 -config EQUALIZER
19430 -       tristate "EQL (serial line load balancing) support"
19431 -
19432 -config TUN
19433 -       tristate "Universal TUN/TAP device driver support"
19434 -
19435 -config ETHERTAP
19436 -       tristate "Ethertap network tap (OBSOLETE)"
19437 -       depends on EXPERIMENTAL && NETLINK
19438 -
19439 -config PPP
19440 -       tristate "PPP (point-to-point protocol) support"
19441 -
19442 -config PPP_MULTILINK
19443 -       bool "PPP multilink support (EXPERIMENTAL)"
19444 -       depends on PPP && EXPERIMENTAL
19445 -
19446 -config PPP_FILTER
19447 -       bool "PPP filtering"
19448 -       depends on PPP && FILTER
19449 -
19450 -config PPP_ASYNC
19451 -       tristate "PPP support for async serial ports"
19452 -       depends on PPP
19453 -
19454 -config PPP_SYNC_TTY
19455 -       tristate "PPP support for sync tty ports"
19456 -       depends on PPP
19457 -
19458 -config PPP_DEFLATE
19459 -       tristate "PPP Deflate compression"
19460 -       depends on PPP
19461 -
19462 -config PPP_BSDCOMP
19463 -       tristate "PPP BSD-Compress compression"
19464 -       depends on PPP
19465 -
19466 -config PPPOE
19467 -       tristate "PPP over Ethernet (EXPERIMENTAL)"
19468 -       depends on PPP && EXPERIMENTAL
19469 -
19470 -config SLIP
19471 -       tristate "SLIP (serial line) support"
19472 -
19473 -config SLIP_COMPRESSED
19474 -       bool "CSLIP compressed headers"
19475 -       depends on SLIP=y
19476 -
19477 -config SLIP_SMART
19478 -       bool "Keepalive and linefill"
19479 -       depends on SLIP=y
19480 -
19481 -config SLIP_MODE_SLIP6
19482 -       bool "Six bit SLIP encapsulation"
19483 -       depends on SLIP=y
19484 -
19485  endmenu
19486  
19487 --- linux-2.6.0-test6/arch/um/kernel/config.c.in        2003-06-14 12:18:28.000000000 -0700
19488 +++ 25/arch/um/kernel/config.c.in       2003-10-05 00:34:32.000000000 -0700
19489 @@ -7,9 +7,7 @@
19490  #include <stdlib.h>
19491  #include "init.h"
19492  
19493 -static __initdata char *config = "
19494 -CONFIG
19495 -";
19496 +static __initdata char *config = "CONFIG";
19497  
19498  static int __init print_config(char *line, int *add)
19499  {
19500 --- linux-2.6.0-test6/arch/um/kernel/init_task.c        2003-06-14 12:18:51.000000000 -0700
19501 +++ 25/arch/um/kernel/init_task.c       2003-10-05 00:34:32.000000000 -0700
19502 @@ -17,6 +17,7 @@ static struct fs_struct init_fs = INIT_F
19503  struct mm_struct init_mm = INIT_MM(init_mm);
19504  static struct files_struct init_files = INIT_FILES;
19505  static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
19506 +static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
19507  
19508  /*
19509   * Initial task structure.
19510 @@ -38,26 +39,12 @@ union thread_union init_thread_union 
19511  __attribute__((__section__(".data.init_task"))) = 
19512  { INIT_THREAD_INFO(init_task) };
19513  
19514 -struct task_struct *alloc_task_struct(void)
19515 -{
19516 -       return((struct task_struct *) 
19517 -              __get_free_pages(GFP_KERNEL, CONFIG_KERNEL_STACK_ORDER));
19518 -}
19519 -
19520  void unprotect_stack(unsigned long stack)
19521  {
19522         protect_memory(stack, (1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE, 
19523                        1, 1, 0, 1);
19524  }
19525  
19526 -void free_task_struct(struct task_struct *task)
19527 -{
19528 -       /* free_pages decrements the page counter and only actually frees
19529 -        * the pages if they are now not accessed by anything.
19530 -        */
19531 -       free_pages((unsigned long) task, CONFIG_KERNEL_STACK_ORDER);
19532 -}
19533 -
19534  /*
19535   * Overrides for Emacs so that we follow Linus's tabbing style.
19536   * Emacs will notice this stuff at the end of the file and automatically
19537 --- linux-2.6.0-test6/arch/um/kernel/irq.c      2003-08-22 19:23:40.000000000 -0700
19538 +++ 25/arch/um/kernel/irq.c     2003-10-05 00:34:32.000000000 -0700
19539 @@ -28,6 +28,7 @@
19540  #include "user_util.h"
19541  #include "kern_util.h"
19542  #include "irq_user.h"
19543 +#include "irq_kern.h"
19544  
19545  static void register_irq_proc (unsigned int irq);
19546  
19547 @@ -82,65 +83,52 @@ struct hw_interrupt_type no_irq_type = {
19548         end_none
19549  };
19550  
19551 -/* Not changed */
19552 -volatile unsigned long irq_err_count;
19553 -
19554  /*
19555   * Generic, controller-independent functions:
19556   */
19557  
19558 -int get_irq_list(char *buf)
19559 +int show_interrupts(struct seq_file *p, void *v)
19560  {
19561         int i, j;
19562 -       unsigned long flags;
19563         struct irqaction * action;
19564 -       char *p = buf;
19565 +       unsigned long flags;
19566  
19567 -       p += sprintf(p, "           ");
19568 -       for (j=0; j<num_online_cpus(); j++)
19569 -               p += sprintf(p, "CPU%d       ",j);
19570 -       *p++ = '\n';
19571 +       seq_printf(p, "           ");
19572 +       for (j=0; j<NR_CPUS; j++)
19573 +               if (cpu_online(j))
19574 +                       seq_printf(p, "CPU%d       ",j);
19575 +       seq_putc(p, '\n');
19576  
19577         for (i = 0 ; i < NR_IRQS ; i++) {
19578                 spin_lock_irqsave(&irq_desc[i].lock, flags);
19579                 action = irq_desc[i].action;
19580                 if (!action) 
19581 -                       goto end;
19582 -               p += sprintf(p, "%3d: ",i);
19583 +                       goto skip;
19584 +               seq_printf(p, "%3d: ",i);
19585  #ifndef CONFIG_SMP
19586 -               p += sprintf(p, "%10u ", kstat_irqs(i));
19587 +               seq_printf(p, "%10u ", kstat_irqs(i));
19588  #else
19589 -               for (j = 0; j < num_online_cpus(); j++)
19590 -                       p += sprintf(p, "%10u ",
19591 -                               kstat_cpu(cpu_logical_map(j)).irqs[i]);
19592 +               for (j = 0; j < NR_CPUS; j++)
19593 +                       if (cpu_online(j))
19594 +                               seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
19595  #endif
19596 -               p += sprintf(p, " %14s", irq_desc[i].handler->typename);
19597 -               p += sprintf(p, "  %s", action->name);
19598 +               seq_printf(p, " %14s", irq_desc[i].handler->typename);
19599 +               seq_printf(p, "  %s", action->name);
19600  
19601                 for (action=action->next; action; action = action->next)
19602 -                       p += sprintf(p, ", %s", action->name);
19603 -               *p++ = '\n';
19604 -       end:
19605 +                       seq_printf(p, ", %s", action->name);
19606 +
19607 +               seq_putc(p, '\n');
19608 +skip:
19609                 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
19610         }
19611 -       p += sprintf(p, "\n");
19612 -#ifdef notdef
19613 -#ifdef CONFIG_SMP
19614 -       p += sprintf(p, "LOC: ");
19615 -       for (j = 0; j < num_online_cpus(); j++)
19616 -               p += sprintf(p, "%10u ",
19617 -                       apic_timer_irqs[cpu_logical_map(j)]);
19618 -       p += sprintf(p, "\n");
19619 -#endif
19620 -#endif
19621 -       p += sprintf(p, "ERR: %10lu\n", irq_err_count);
19622 -       return p - buf;
19623 -}
19624 -
19625 +       seq_printf(p, "NMI: ");
19626 +       for (j = 0; j < NR_CPUS; j++)
19627 +               if (cpu_online(j))
19628 +                       seq_printf(p, "%10u ", nmi_count(j));
19629 +       seq_putc(p, '\n');
19630  
19631 -int show_interrupts(struct seq_file *p, void *v)
19632 -{
19633 -       return(0);
19634 +       return 0;
19635  }
19636  
19637  /*
19638 @@ -281,13 +269,12 @@ unsigned int do_IRQ(int irq, union uml_p
19639          * 0 return value means that this irq is already being
19640          * handled by some other CPU. (or is disabled)
19641          */
19642 -       int cpu = smp_processor_id();
19643         irq_desc_t *desc = irq_desc + irq;
19644         struct irqaction * action;
19645         unsigned int status;
19646  
19647         irq_enter();
19648 -       kstat_cpu(cpu).irqs[irq]++;
19649 +       kstat_this_cpu.irqs[irq]++;
19650         spin_lock(&desc->lock);
19651         desc->handler->ack(irq);
19652         /*
19653 @@ -384,7 +371,7 @@ out:
19654   */
19655   
19656  int request_irq(unsigned int irq,
19657 -               void (*handler)(int, void *, struct pt_regs *),
19658 +               irqreturn_t (*handler)(int, void *, struct pt_regs *),
19659                 unsigned long irqflags, 
19660                 const char * devname,
19661                 void *dev_id)
19662 @@ -430,15 +417,19 @@ int request_irq(unsigned int irq,
19663  }
19664  
19665  int um_request_irq(unsigned int irq, int fd, int type,
19666 -                  void (*handler)(int, void *, struct pt_regs *),
19667 +                  irqreturn_t (*handler)(int, void *, struct pt_regs *),
19668                    unsigned long irqflags, const char * devname,
19669                    void *dev_id)
19670  {
19671 -       int retval;
19672 +       int err;
19673  
19674 -       retval = request_irq(irq, handler, irqflags, devname, dev_id);
19675 -       if(retval) return(retval);
19676 -       return(activate_fd(irq, fd, type, dev_id));
19677 +       err = request_irq(irq, handler, irqflags, devname, dev_id);
19678 +       if(err) 
19679 +               return(err);
19680 +
19681 +       if(fd != -1)
19682 +               err = activate_fd(irq, fd, type, dev_id);
19683 +       return(err);
19684  }
19685  
19686  /* this was setup_x86_irq but it seems pretty generic */
19687 @@ -654,7 +645,7 @@ static int prof_cpu_mask_read_proc (char
19688                 return -EINVAL;
19689         tmp = *mask;
19690         for (k = 0; k < sizeof(cpumask_t)/sizeof(u16); ++k) {
19691 -               int j = sprintf(page, "%04hx", cpus_coerce(tmp));
19692 +               int j = sprintf(page, "%04hx", (short) cpus_coerce(tmp));
19693                 len += j;
19694                 page += j;
19695                 cpus_shift_right(tmp, tmp, 16);
19696 --- linux-2.6.0-test6/arch/um/kernel/Makefile   2003-08-22 19:23:40.000000000 -0700
19697 +++ 25/arch/um/kernel/Makefile  2003-10-05 00:34:32.000000000 -0700
19698 @@ -21,6 +21,8 @@ obj-$(CONFIG_TTY_LOG) += tty_log.o
19699  obj-$(CONFIG_MODE_TT) += tt/
19700  obj-$(CONFIG_MODE_SKAS) += skas/
19701  
19702 +clean-files    := config.c
19703 +
19704  user-objs-$(CONFIG_TTY_LOG) += tty_log.o
19705  
19706  USER_OBJS := $(filter %_user.o,$(obj-y))  $(user-objs-y) config.o helper.o \
19707 @@ -45,17 +47,13 @@ $(USER_OBJS) : %.o: %.c
19708  $(obj)/frame.o: $(src)/frame.c
19709         $(CC) $(CFLAGS_$(notdir $@)) -c -o $@ $<
19710  
19711 -QUOTE = 'my $$config=`cat $(TOPDIR)/.config`; $$config =~ s/"/\\"/g ; while(<STDIN>) { $$_ =~ s/CONFIG/$$config/; print $$_ }'
19712 +QUOTE = 'my $$config=`cat $(TOPDIR)/.config`; $$config =~ s/"/\\"/g ; $$config =~ s/\n/\\n"\n"/g ; while(<STDIN>) { $$_ =~ s/CONFIG/$$config/; print $$_ }'
19713  
19714  $(obj)/config.c : $(src)/config.c.in $(TOPDIR)/.config
19715         $(PERL) -e $(QUOTE) < $(src)/config.c.in > $@
19716  
19717  $(obj)/config.o : $(obj)/config.c
19718  
19719 -clean:
19720 -       rm -f config.c
19721 -       for dir in $(subdir-y) ; do $(MAKE) -C $$dir clean; done
19722 -
19723  modules:
19724  
19725  fastdep:
19726 --- linux-2.6.0-test6/arch/um/kernel/mem.c      2003-06-14 12:18:08.000000000 -0700
19727 +++ 25/arch/um/kernel/mem.c     2003-10-05 00:34:32.000000000 -0700
19728 @@ -119,11 +119,6 @@ unsigned long get_kmem_end(void)
19729         return(kmem_top);
19730  }
19731  
19732 -void set_kmem_end(unsigned long new)
19733 -{
19734 -       kmem_top = new;
19735 -}
19736 -
19737  #ifdef CONFIG_HIGHMEM
19738  /* Changed during early boot */
19739  pte_t *kmap_pte;
19740 @@ -218,7 +213,7 @@ static int setup_one_range(int fd, char 
19741                 if(regions[i] == NULL) break;           
19742         }
19743         if(i == NREGIONS){
19744 -               printk("setup_range : no free regions\n");
19745 +               printk("setup_one_range : no free regions\n");
19746                 i = -1;
19747                 goto out;
19748         }
19749 @@ -227,7 +222,9 @@ static int setup_one_range(int fd, char 
19750                 fd = create_mem_file(len);
19751  
19752         if(region == NULL){
19753 -               region = alloc_bootmem_low_pages(sizeof(*region));
19754 +               if(kmalloc_ok)
19755 +                       region = kmalloc(sizeof(*region), GFP_KERNEL);
19756 +               else region = alloc_bootmem_low_pages(sizeof(*region));
19757                 if(region == NULL)
19758                         panic("Failed to allocating mem_region");
19759         }
19760 @@ -528,9 +525,9 @@ int nregions(void)
19761         return(NREGIONS);
19762  }
19763  
19764 -void setup_range(int fd, char *driver, unsigned long start, unsigned long pfn,
19765 -                unsigned long len, int need_vm, struct mem_region *region, 
19766 -                void *reserved)
19767 +static void setup_range(int fd, char *driver, unsigned long start, 
19768 +                       unsigned long pfn, unsigned long len, int need_vm, 
19769 +                       struct mem_region *region, void *reserved)
19770  {
19771         int i, cur;
19772  
19773 --- linux-2.6.0-test6/arch/um/kernel/mem_user.c 2003-06-14 12:18:22.000000000 -0700
19774 +++ 25/arch/um/kernel/mem_user.c        2003-10-05 00:34:32.000000000 -0700
19775 @@ -111,6 +111,11 @@ int setup_region(struct mem_region *regi
19776                 offset = 0;
19777         }
19778  
19779 +       if(offset >= region->len){
19780 +               printf("%ld bytes of physical memory is insufficient\n",
19781 +                      region->len);
19782 +               exit(1);
19783 +       }
19784         loc = mmap(start, region->len - offset, PROT_READ | PROT_WRITE, 
19785                    MAP_SHARED | MAP_FIXED, region->fd, offset);
19786         if(loc != start){
19787 @@ -122,26 +127,26 @@ int setup_region(struct mem_region *regi
19788  
19789  static int __init parse_iomem(char *str, int *add)
19790  {
19791 -       struct stat buf;
19792 +       struct stat64 buf;
19793         char *file, *driver;
19794         int fd;
19795  
19796         driver = str;
19797         file = strchr(str,',');
19798         if(file == NULL){
19799 -               printk("parse_iomem : failed to parse iomem\n");
19800 +               printf("parse_iomem : failed to parse iomem\n");
19801                 return(1);
19802         }
19803         *file = '\0';
19804         file++;
19805         fd = os_open_file(file, of_rdwr(OPENFLAGS()), 0);
19806         if(fd < 0){
19807 -               printk("parse_iomem - Couldn't open io file, errno = %d\n", 
19808 +               printf("parse_iomem - Couldn't open io file, errno = %d\n", 
19809                        errno);
19810                 return(1);
19811         }
19812 -       if(fstat(fd, &buf) < 0) {
19813 -               printk("parse_iomem - cannot fstat file, errno = %d\n", errno);
19814 +       if(fstat64(fd, &buf) < 0) {
19815 +               printf("parse_iomem - cannot fstat file, errno = %d\n", errno);
19816                 return(1);
19817         }
19818         add_iomem(driver, fd, buf.st_size);
19819 --- linux-2.6.0-test6/arch/um/kernel/process.c  2003-06-14 12:18:32.000000000 -0700
19820 +++ 25/arch/um/kernel/process.c 2003-10-05 00:34:32.000000000 -0700
19821 @@ -72,7 +72,6 @@ void init_new_thread_signals(int altstac
19822                     SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
19823         set_handler(SIGUSR2, (__sighandler_t) sig_handler, 
19824                     SA_NOMASK | flags, -1);
19825 -       (void) CHOOSE_MODE(signal(SIGCHLD, SIG_IGN), (void *) 0);
19826         signal(SIGHUP, SIG_IGN);
19827  
19828         init_irq_signals(altstack);
19829 @@ -127,7 +126,8 @@ int start_fork_tramp(void *thread_arg, u
19830         if(err < 0) panic("Waiting for outer trampoline failed - errno = %d", 
19831                           errno);
19832         if(!WIFSIGNALED(status) || (WTERMSIG(status) != SIGKILL))
19833 -               panic("outer trampoline didn't exit with SIGKILL");
19834 +               panic("outer trampoline didn't exit with SIGKILL, "
19835 +                     "status = %d", status);
19836  
19837         return(arg.pid);
19838  }
19839 --- linux-2.6.0-test6/arch/um/kernel/process_kern.c     2003-07-10 18:50:30.000000000 -0700
19840 +++ 25/arch/um/kernel/process_kern.c    2003-10-05 00:34:32.000000000 -0700
19841 @@ -52,17 +52,12 @@ struct cpu_task cpu_tasks[NR_CPUS] = { [
19842  
19843  struct task_struct *get_task(int pid, int require)
19844  {
19845 -        struct task_struct *task, *ret;
19846 +        struct task_struct *ret;
19847  
19848 -        ret = NULL;
19849          read_lock(&tasklist_lock);
19850 -        for_each_process(task){
19851 -                if(task->pid == pid){
19852 -                        ret = task;
19853 -                        break;
19854 -                }
19855 -        }
19856 +       ret = find_task_by_pid(pid);
19857          read_unlock(&tasklist_lock);
19858 +
19859          if(require && (ret == NULL)) panic("get_task couldn't find a task\n");
19860          return(ret);
19861  }
19862 @@ -103,13 +98,14 @@ unsigned long alloc_stack(int order, int
19863  
19864  int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
19865  {
19866 -       struct task_struct *p;
19867 +       int pid;
19868  
19869         current->thread.request.u.thread.proc = fn;
19870         current->thread.request.u.thread.arg = arg;
19871 -       p = do_fork(CLONE_VM | flags, 0, NULL, 0, NULL, NULL);
19872 -       if(IS_ERR(p)) panic("do_fork failed in kernel_thread");
19873 -       return(p->pid);
19874 +       pid = do_fork(CLONE_VM | flags, 0, NULL, 0, NULL, NULL);
19875 +       if(pid < 0)
19876 +               panic("do_fork failed in kernel_thread, errno = %d", pid);
19877 +       return(pid);
19878  }
19879  
19880  void switch_mm(struct mm_struct *prev, struct mm_struct *next, 
19881 @@ -129,7 +125,7 @@ void set_current(void *t)
19882                 { external_pid(task), task });
19883  }
19884  
19885 -void *switch_to(void *prev, void *next, void *last)
19886 +void *_switch_to(void *prev, void *next, void *last)
19887  {
19888         return(CHOOSE_MODE(switch_to_tt(prev, next), 
19889                            switch_to_skas(prev, next)));
19890 @@ -149,7 +145,7 @@ void release_thread(struct task_struct *
19891  void exit_thread(void)
19892  {
19893         CHOOSE_MODE(exit_thread_tt(), exit_thread_skas());
19894 -       unprotect_stack((unsigned long) current->thread_info);
19895 +       unprotect_stack((unsigned long) current_thread);
19896  }
19897   
19898  void *get_current(void)
19899 @@ -157,6 +153,10 @@ void *get_current(void)
19900         return(current);
19901  }
19902  
19903 +void prepare_to_copy(struct task_struct *tsk)
19904 +{
19905 +}
19906 +
19907  int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
19908                 unsigned long stack_top, struct task_struct * p, 
19909                 struct pt_regs *regs)
19910 @@ -190,7 +190,7 @@ int current_pid(void)
19911  
19912  void default_idle(void)
19913  {
19914 -       idle_timer();
19915 +       uml_idle_timer();
19916  
19917         atomic_inc(&init_mm.mm_count);
19918         current->mm = &init_mm;
19919 @@ -363,10 +363,15 @@ int clear_user_proc(void *buf, int size)
19920         return(clear_user(buf, size));
19921  }
19922  
19923 +int strlen_user_proc(char *str)
19924 +{
19925 +       return(strlen_user(str));
19926 +}
19927 +
19928  int smp_sigio_handler(void)
19929  {
19930  #ifdef CONFIG_SMP
19931 -       int cpu = current->thread_info->cpu;
19932 +       int cpu = current_thread->cpu;
19933         IPI_handler(cpu);
19934         if(cpu != 0)
19935                 return(1);
19936 @@ -381,7 +386,7 @@ int um_in_interrupt(void)
19937  
19938  int cpu(void)
19939  {
19940 -       return(current->thread_info->cpu);
19941 +       return(current_thread->cpu);
19942  }
19943  
19944  /*
19945 --- linux-2.6.0-test6/arch/um/kernel/ptrace.c   2003-06-14 12:17:58.000000000 -0700
19946 +++ 25/arch/um/kernel/ptrace.c  2003-10-05 00:34:32.000000000 -0700
19947 @@ -311,11 +311,8 @@ void syscall_trace(void)
19948  
19949         /* the 0x80 provides a way for the tracing parent to distinguish
19950            between a syscall stop and SIGTRAP delivery */
19951 -       current->exit_code = SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
19952 -                                       ? 0x80 : 0);
19953 -       current->state = TASK_STOPPED;
19954 -       notify_parent(current, SIGCHLD);
19955 -       schedule();
19956 +       ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
19957 +                                ? 0x80 : 0));
19958  
19959         /*
19960          * this isn't the same as continuing with a signal, but it will do
19961 --- linux-2.6.0-test6/arch/um/kernel/sigio_kern.c       2003-06-14 12:18:04.000000000 -0700
19962 +++ 25/arch/um/kernel/sigio_kern.c      2003-10-05 00:34:32.000000000 -0700
19963 @@ -6,18 +6,21 @@
19964  #include "linux/kernel.h"
19965  #include "linux/list.h"
19966  #include "linux/slab.h"
19967 -#include "asm/irq.h"
19968 +#include "linux/signal.h"
19969 +#include "linux/interrupt.h"
19970  #include "init.h"
19971  #include "sigio.h"
19972  #include "irq_user.h"
19973 +#include "irq_kern.h"
19974  
19975  /* Protected by sigio_lock() called from write_sigio_workaround */
19976  static int sigio_irq_fd = -1;
19977  
19978 -void sigio_interrupt(int irq, void *data, struct pt_regs *unused)
19979 +irqreturn_t sigio_interrupt(int irq, void *data, struct pt_regs *unused)
19980  {
19981         read_sigio_fd(sigio_irq_fd);
19982         reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ);
19983 +       return(IRQ_HANDLED);
19984  }
19985  
19986  int write_sigio_irq(int fd)
19987 --- linux-2.6.0-test6/arch/um/kernel/signal_kern.c      2003-06-14 12:18:23.000000000 -0700
19988 +++ 25/arch/um/kernel/signal_kern.c     2003-10-05 00:34:32.000000000 -0700
19989 @@ -36,7 +36,7 @@ static void force_segv(int sig)
19990         if(sig == SIGSEGV){
19991                 struct k_sigaction *ka;
19992  
19993 -               ka = &current->sig->action[SIGSEGV - 1];
19994 +               ka = &current->sighand->action[SIGSEGV - 1];
19995                 ka->sa.sa_handler = SIG_DFL;
19996         }
19997         force_sig(SIGSEGV, current);
19998 @@ -142,7 +142,7 @@ static int kern_do_signal(struct pt_regs
19999                 return(0);
20000  
20001         /* Whee!  Actually deliver the signal.  */
20002 -       ka = &current->sig->action[sig -1 ];
20003 +       ka = &current->sighand->action[sig -1 ];
20004         err = handle_signal(regs, sig, ka, &info, oldset, error);
20005         if(!err) return(1);
20006  
20007 @@ -201,7 +201,7 @@ int sys_sigsuspend(int history0, int his
20008         }
20009  }
20010  
20011 -int sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize)
20012 +int sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize)
20013  {
20014         sigset_t saveset, newset;
20015  
20016 @@ -227,6 +227,42 @@ int sys_rt_sigsuspend(sigset_t *unewset,
20017         }
20018  }
20019  
20020 +int sys_sigaction(int sig, const struct old_sigaction __user *act,
20021 +                        struct old_sigaction __user *oact)
20022 +{
20023 +       struct k_sigaction new_ka, old_ka;
20024 +       int ret;
20025 +
20026 +       if (act) {
20027 +               old_sigset_t mask;
20028 +               if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
20029 +                   __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
20030 +                   __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
20031 +                       return -EFAULT;
20032 +               __get_user(new_ka.sa.sa_flags, &act->sa_flags);
20033 +               __get_user(mask, &act->sa_mask);
20034 +               siginitset(&new_ka.sa.sa_mask, mask);
20035 +       }
20036 +
20037 +       ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
20038 +
20039 +       if (!ret && oact) {
20040 +               if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
20041 +                   __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
20042 +                   __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
20043 +                       return -EFAULT;
20044 +               __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
20045 +               __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
20046 +       }
20047 +
20048 +       return ret;
20049 +}
20050 +
20051 +int sys_sigaltstack(const stack_t *uss, stack_t *uoss)
20052 +{
20053 +       return(do_sigaltstack(uss, uoss, PT_REGS_SP(&current->thread.regs)));
20054 +}
20055 +
20056  static int copy_sc_from_user(struct pt_regs *to, void *from, 
20057                              struct arch_frame_data *arch)
20058  {
20059 @@ -239,8 +275,8 @@ static int copy_sc_from_user(struct pt_r
20060  
20061  int sys_sigreturn(struct pt_regs regs)
20062  {
20063 -       void *sc = sp_to_sc(PT_REGS_SP(&current->thread.regs));
20064 -       void *mask = sp_to_mask(PT_REGS_SP(&current->thread.regs));
20065 +       void __user *sc = sp_to_sc(PT_REGS_SP(&current->thread.regs));
20066 +       void __user *mask = sp_to_mask(PT_REGS_SP(&current->thread.regs));
20067         int sig_size = (_NSIG_WORDS - 1) * sizeof(unsigned long);
20068  
20069         spin_lock_irq(&current->sighand->siglock);
20070 @@ -257,7 +293,8 @@ int sys_sigreturn(struct pt_regs regs)
20071  
20072  int sys_rt_sigreturn(struct pt_regs regs)
20073  {
20074 -       struct ucontext *uc = sp_to_uc(PT_REGS_SP(&current->thread.regs));
20075 +       unsigned long sp = PT_REGS_SP(&current->thread.regs);
20076 +       struct ucontext __user *uc = sp_to_uc(sp);
20077         void *fp;
20078         int sig_size = _NSIG_WORDS * sizeof(unsigned long);
20079  
20080 --- linux-2.6.0-test6/arch/um/kernel/skas/include/mode.h        2003-06-14 12:18:22.000000000 -0700
20081 +++ 25/arch/um/kernel/skas/include/mode.h       2003-10-05 00:34:32.000000000 -0700
20082 @@ -20,6 +20,7 @@ extern void sig_handler_common_skas(int 
20083  extern void halt_skas(void);
20084  extern void reboot_skas(void);
20085  extern void kill_off_processes_skas(void);
20086 +extern int is_skas_winch(int pid, int fd, void *data);
20087  
20088  #endif
20089  
20090 --- linux-2.6.0-test6/arch/um/kernel/skas/include/uaccess.h     2003-06-14 12:18:08.000000000 -0700
20091 +++ 25/arch/um/kernel/skas/include/uaccess.h    2003-10-05 00:34:32.000000000 -0700
20092 @@ -19,7 +19,7 @@
20093  #define access_ok_skas(type, addr, size) \
20094         ((segment_eq(get_fs(), KERNEL_DS)) || \
20095          (((unsigned long) (addr) < TASK_SIZE) && \
20096 -         ((unsigned long) (addr) + (size) < TASK_SIZE)))
20097 +         ((unsigned long) (addr) + (size) <= TASK_SIZE)))
20098  
20099  static inline int verify_area_skas(int type, const void * addr, 
20100                                    unsigned long size)
20101 --- linux-2.6.0-test6/arch/um/kernel/skas/Makefile      2003-06-14 12:18:06.000000000 -0700
20102 +++ 25/arch/um/kernel/skas/Makefile     2003-10-05 00:34:32.000000000 -0700
20103 @@ -7,18 +7,22 @@ obj-y = exec_kern.o exec_user.o mem.o me
20104         process_kern.o syscall_kern.o syscall_user.o time.o tlb.o trap_user.o \
20105         sys-$(SUBARCH)/
20106  
20107 +host-progs     := util/mk_ptregs
20108 +clean-files    := include/skas_ptregs.h
20109 +
20110  USER_OBJS = $(filter %_user.o,$(obj-y)) process.o time.o
20111  USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
20112  
20113 -include/skas_ptregs.h : util/mk_ptregs
20114 -       util/mk_ptregs > $@
20115 -
20116 -util/mk_ptregs :
20117 -       $(MAKE) -C util
20118 +$(TOPDIR)/arch/um/include/skas_ptregs.h : $(src)/util/mk_ptregs
20119 +       @echo -n '  Generating $@'
20120 +       @$< > $@.tmp
20121 +       @if [ -r $@ ] && cmp -s $@ $@.tmp; then \
20122 +               echo ' (unchanged)'; \
20123 +               rm -f $@.tmp; \
20124 +       else \
20125 +               echo ' (updated)'; \
20126 +               mv -f $@.tmp $@; \
20127 +       fi
20128  
20129  $(USER_OBJS) : %.o: %.c
20130         $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
20131 -
20132 -clean :
20133 -       $(MAKE) -C util clean
20134 -       $(RM) -f include/skas_ptregs.h
20135 --- linux-2.6.0-test6/arch/um/kernel/skas/process.c     2003-06-14 12:18:34.000000000 -0700
20136 +++ 25/arch/um/kernel/skas/process.c    2003-10-05 00:34:32.000000000 -0700
20137 @@ -4,6 +4,7 @@
20138   */
20139  
20140  #include <stdlib.h>
20141 +#include <unistd.h>
20142  #include <errno.h>
20143  #include <signal.h>
20144  #include <setjmp.h>
20145 @@ -24,6 +25,16 @@
20146  #include "os.h"
20147  #include "proc_mm.h"
20148  #include "skas_ptrace.h"
20149 +#include "chan_user.h"
20150 +
20151 +int is_skas_winch(int pid, int fd, void *data)
20152 +{
20153 +       if(pid != getpid())
20154 +               return(0);
20155 +
20156 +       register_winch_irq(-1, fd, -1, data);
20157 +       return(1);
20158 +}
20159  
20160  unsigned long exec_regs[FRAME_SIZE];
20161  unsigned long exec_fp_regs[HOST_FP_SIZE];
20162 @@ -48,11 +59,11 @@ static void handle_trap(int pid, union u
20163         int err, syscall_nr, status;
20164  
20165         syscall_nr = PT_SYSCALL_NR(regs->skas.regs);
20166 +       UPT_SYSCALL_NR(regs) = syscall_nr;
20167         if(syscall_nr < 1){
20168                 relay_signal(SIGTRAP, regs);
20169                 return;
20170         }
20171 -       UPT_SYSCALL_NR(regs) = syscall_nr;
20172  
20173         err = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET, __NR_getpid);
20174         if(err < 0)
20175 @@ -72,8 +83,6 @@ static void handle_trap(int pid, union u
20176         handle_syscall(regs);
20177  }
20178  
20179 -int userspace_pid;
20180 -
20181  static int userspace_tramp(void *arg)
20182  {
20183         init_new_thread_signals(0);
20184 @@ -83,6 +92,8 @@ static int userspace_tramp(void *arg)
20185         return(0);
20186  }
20187  
20188 +int userspace_pid;
20189 +
20190  void start_userspace(void)
20191  {
20192         void *stack;
20193 @@ -149,6 +160,7 @@ void userspace(union uml_pt_regs *regs)
20194                         case SIGILL:
20195                         case SIGBUS:
20196                         case SIGFPE:
20197 +                       case SIGWINCH:
20198                                 user_signal(WSTOPSIG(status), regs);
20199                                 break;
20200                         default:
20201 @@ -328,7 +340,8 @@ void reboot_skas(void)
20202  int new_mm(int from)
20203  {
20204         struct proc_mm_op copy;
20205 -       int n, fd = os_open_file("/proc/mm", of_write(OPENFLAGS()), 0);
20206 +       int n, fd = os_open_file("/proc/mm", 
20207 +                                of_cloexec(of_write(OPENFLAGS())), 0);
20208  
20209         if(fd < 0)
20210                 return(-errno);
20211 @@ -342,6 +355,7 @@ int new_mm(int from)
20212                         printk("new_mm : /proc/mm copy_segments failed, "
20213                                "errno = %d\n", errno);
20214         }
20215 +
20216         return(fd);
20217  }
20218  
20219 --- linux-2.6.0-test6/arch/um/kernel/skas/process_kern.c        2003-08-22 19:23:40.000000000 -0700
20220 +++ 25/arch/um/kernel/skas/process_kern.c       2003-10-05 00:34:32.000000000 -0700
20221 @@ -61,9 +61,8 @@ void new_thread_handler(int sig)
20222         thread_wait(&current->thread.mode.skas.switch_buf, 
20223                     current->thread.mode.skas.fork_buf);
20224  
20225 -#ifdef CONFIG_SMP
20226 -       schedule_tail(NULL);
20227 -#endif
20228 +       if(current->thread.prev_sched != NULL)
20229 +               schedule_tail(current->thread.prev_sched);
20230         current->thread.prev_sched = NULL;
20231  
20232         n = run_kernel_thread(fn, arg, &current->thread.exec_buf);
20233 @@ -93,9 +92,8 @@ void fork_handler(int sig)
20234                     current->thread.mode.skas.fork_buf);
20235         
20236         force_flush_all();
20237 -#ifdef CONFIG_SMP
20238 -       schedule_tail(current->thread.prev_sched);
20239 -#endif
20240 +       if(current->thread.prev_sched != NULL)
20241 +               schedule_tail(current->thread.prev_sched);
20242         current->thread.prev_sched = NULL;
20243         unblock_signals();
20244  
20245 @@ -136,7 +134,7 @@ int copy_thread_skas(int nr, unsigned lo
20246  
20247  void init_idle_skas(void)
20248  {
20249 -       cpu_tasks[current->thread_info->cpu].pid = os_getpid();
20250 +       cpu_tasks[current_thread->cpu].pid = os_getpid();
20251         default_idle();
20252  }
20253  
20254 @@ -164,7 +162,7 @@ int start_uml_skas(void)
20255         capture_signal_stack();
20256  
20257         init_new_thread_signals(1);
20258 -       idle_timer();
20259 +       uml_idle_timer();
20260  
20261         init_task.thread.request.u.thread.proc = start_kernel_proc;
20262         init_task.thread.request.u.thread.arg = NULL;
20263 --- linux-2.6.0-test6/arch/um/kernel/skas/util/mk_ptregs.c      2003-06-14 12:18:08.000000000 -0700
20264 +++ 25/arch/um/kernel/skas/util/mk_ptregs.c     2003-10-05 00:34:32.000000000 -0700
20265 @@ -1,3 +1,4 @@
20266 +#include <stdio.h>
20267  #include <asm/ptrace.h>
20268  #include <asm/user.h>
20269  
20270 --- linux-2.6.0-test6/arch/um/kernel/smp.c      2003-08-22 19:23:40.000000000 -0700
20271 +++ 25/arch/um/kernel/smp.c     2003-10-05 00:34:32.000000000 -0700
20272 @@ -22,7 +22,7 @@
20273  #include "os.h"
20274  
20275  /* CPU online map, set by smp_boot_cpus */
20276 -unsigned long cpu_online_map = cpumask_of_cpu(0);
20277 +unsigned long cpu_online_map = CPU_MASK_NONE;
20278  
20279  /* Per CPU bogomips and other parameters
20280   * The only piece used here is the ipi pipe, which is set before SMP is
20281 @@ -97,15 +97,15 @@ void smp_send_stop(void)
20282  
20283         printk(KERN_INFO "Stopping all CPUs...");
20284         for(i = 0; i < num_online_cpus(); i++){
20285 -               if(i == current->thread_info->cpu)
20286 +               if(i == current_thread->cpu)
20287                         continue;
20288                 write(cpu_data[i].ipi_pipe[1], "S", 1);
20289         }
20290         printk("done\n");
20291  }
20292  
20293 -static cpumask_t smp_commenced_mask;
20294 -static cpumask_t smp_callin_map = CPU_MASK_NONE;
20295 +static cpumask_t smp_commenced_mask = CPU_MASK_NONE;
20296 +static cpumask_t cpu_callin_map = CPU_MASK_NONE;
20297  
20298  static int idle_proc(void *cpup)
20299  {
20300 @@ -120,12 +120,12 @@ static int idle_proc(void *cpup)
20301                      current->thread.mode.tt.extern_pid);
20302   
20303         wmb();
20304 -       if (cpu_test_and_set(cpu, &smp_callin_map)) {
20305 +       if (cpu_test_and_set(cpu, cpu_callin_map)) {
20306                 printk("huh, CPU#%d already present??\n", cpu);
20307                 BUG();
20308         }
20309  
20310 -       while (!cpu_isset(cpu, &smp_commenced_mask))
20311 +       while (!cpu_isset(cpu, smp_commenced_mask))
20312                 cpu_relax();
20313  
20314         cpu_set(cpu, cpu_online_map);
20315 @@ -140,8 +140,11 @@ static struct task_struct *idle_thread(i
20316  
20317          current->thread.request.u.thread.proc = idle_proc;
20318          current->thread.request.u.thread.arg = (void *) cpu;
20319 -       new_task = do_fork(CLONE_VM | CLONE_IDLETASK, 0, NULL, 0, NULL, NULL);
20320 -       if(IS_ERR(new_task)) panic("do_fork failed in idle_thread");
20321 +       new_task = copy_process(CLONE_VM | CLONE_IDLETASK, 0, NULL, 0, NULL, 
20322 +                               NULL);
20323 +       if(IS_ERR(new_task)) 
20324 +               panic("copy_process failed in idle_thread, error = %ld",
20325 +                     PTR_ERR(new_task));
20326  
20327         cpu_tasks[cpu] = ((struct cpu_task) 
20328                           { .pid =      new_task->thread.mode.tt.extern_pid,
20329 @@ -150,6 +153,7 @@ static struct task_struct *idle_thread(i
20330         CHOOSE_MODE(write(new_task->thread.mode.tt.switch_pipe[1], &c, 
20331                           sizeof(c)),
20332                     ({ panic("skas mode doesn't support SMP"); }));
20333 +       wake_up_forked_process(new_task);
20334         return(new_task);
20335  }
20336  
20337 @@ -157,15 +161,16 @@ void smp_prepare_cpus(unsigned int maxcp
20338  {
20339         struct task_struct *idle;
20340         unsigned long waittime;
20341 -       int err, cpu;
20342 +       int err, cpu, me = smp_processor_id();
20343  
20344 -       cpu_set(0, cpu_online_map);
20345 -       cpu_set(0, smp_callin_map);
20346 +       cpu_clear(me, cpu_online_map);
20347 +       cpu_set(me, cpu_online_map);
20348 +       cpu_set(me, cpu_callin_map);
20349  
20350 -       err = os_pipe(cpu_data[0].ipi_pipe, 1, 1);
20351 +       err = os_pipe(cpu_data[me].ipi_pipe, 1, 1);
20352         if(err) panic("CPU#0 failed to create IPI pipe, errno = %d", -err);
20353  
20354 -       activate_ipi(cpu_data[0].ipi_pipe[0], 
20355 +       activate_ipi(cpu_data[me].ipi_pipe[0], 
20356                      current->thread.mode.tt.extern_pid);
20357  
20358         for(cpu = 1; cpu < ncpus; cpu++){
20359 @@ -177,10 +182,10 @@ void smp_prepare_cpus(unsigned int maxcp
20360                 unhash_process(idle);
20361  
20362                 waittime = 200000000;
20363 -               while (waittime-- && !cpu_isset(cpu, smp_callin_map))
20364 +               while (waittime-- && !cpu_isset(cpu, cpu_callin_map))
20365                         cpu_relax();
20366  
20367 -               if (cpu_isset(cpu, smp_callin_map))
20368 +               if (cpu_isset(cpu, cpu_callin_map))
20369                         printk("done\n");
20370                 else printk("failed\n");
20371         }
20372 @@ -270,7 +275,7 @@ int smp_call_function(void (*_func)(void
20373         info = _info;
20374  
20375         for (i=0;i<NR_CPUS;i++)
20376 -               if((i != current->thread_info->cpu) && 
20377 +               if((i != current_thread->cpu) && 
20378                    cpu_isset(i, cpu_online_map))
20379                         write(cpu_data[i].ipi_pipe[1], "C", 1);
20380  
20381 --- linux-2.6.0-test6/arch/um/kernel/syscall_kern.c     2003-06-14 12:18:28.000000000 -0700
20382 +++ 25/arch/um/kernel/syscall_kern.c    2003-10-05 00:34:32.000000000 -0700
20383 @@ -35,39 +35,40 @@ long um_mount(char * dev_name, char * di
20384  
20385  long sys_fork(void)
20386  {
20387 -       struct task_struct *p;
20388 +       long ret;
20389  
20390         current->thread.forking = 1;
20391 -        p = do_fork(SIGCHLD, 0, NULL, 0, NULL, NULL);
20392 +        ret = do_fork(SIGCHLD, 0, NULL, 0, NULL, NULL);
20393         current->thread.forking = 0;
20394 -       return(IS_ERR(p) ? PTR_ERR(p) : p->pid);
20395 +       return(ret);
20396  }
20397  
20398 -long sys_clone(unsigned long clone_flags, unsigned long newsp)
20399 +long sys_clone(unsigned long clone_flags, unsigned long newsp, 
20400 +              int *parent_tid, int *child_tid)
20401  {
20402 -       struct task_struct *p;
20403 +       long ret;
20404  
20405         current->thread.forking = 1;
20406 -       p = do_fork(clone_flags, newsp, NULL, 0, NULL, NULL);
20407 +       ret = do_fork(clone_flags, newsp, NULL, 0, parent_tid, child_tid);
20408         current->thread.forking = 0;
20409 -       return(IS_ERR(p) ? PTR_ERR(p) : p->pid);
20410 +       return(ret);
20411  }
20412  
20413  long sys_vfork(void)
20414  {
20415 -       struct task_struct *p;
20416 +       long ret;
20417  
20418         current->thread.forking = 1;
20419 -       p = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, NULL, 0, NULL, NULL);
20420 +       ret = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, NULL, 0, NULL, 
20421 +                     NULL);
20422         current->thread.forking = 0;
20423 -       return(IS_ERR(p) ? PTR_ERR(p) : p->pid);
20424 +       return(ret);
20425  }
20426  
20427  /* common code for old and new mmaps */
20428 -static inline long do_mmap2(
20429 -       unsigned long addr, unsigned long len,
20430 -       unsigned long prot, unsigned long flags,
20431 -       unsigned long fd, unsigned long pgoff)
20432 +long do_mmap2(struct mm_struct *mm, unsigned long addr, unsigned long len,
20433 +             unsigned long prot, unsigned long flags, unsigned long fd,
20434 +             unsigned long pgoff)
20435  {
20436         int error = -EBADF;
20437         struct file * file = NULL;
20438 @@ -93,7 +94,7 @@ long sys_mmap2(unsigned long addr, unsig
20439                unsigned long prot, unsigned long flags,
20440                unsigned long fd, unsigned long pgoff)
20441  {
20442 -       return do_mmap2(addr, len, prot, flags, fd, pgoff);
20443 +       return do_mmap2(current->mm, addr, len, prot, flags, fd, pgoff);
20444  }
20445  
20446  /*
20447 @@ -120,7 +121,8 @@ int old_mmap(unsigned long addr, unsigne
20448         if (offset & ~PAGE_MASK)
20449                 goto out;
20450  
20451 -       err = do_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
20452 +       err = do_mmap2(current->mm, addr, len, prot, flags, fd, 
20453 +                      offset >> PAGE_SHIFT);
20454   out:
20455         return err;
20456  }
20457 @@ -141,37 +143,6 @@ int sys_pipe(unsigned long * fildes)
20458          return error;
20459  }
20460  
20461 -int sys_sigaction(int sig, const struct old_sigaction *act,
20462 -                        struct old_sigaction *oact)
20463 -{
20464 -       struct k_sigaction new_ka, old_ka;
20465 -       int ret;
20466 -
20467 -       if (act) {
20468 -               old_sigset_t mask;
20469 -               if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
20470 -                   __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
20471 -                   __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
20472 -                       return -EFAULT;
20473 -               __get_user(new_ka.sa.sa_flags, &act->sa_flags);
20474 -               __get_user(mask, &act->sa_mask);
20475 -               siginitset(&new_ka.sa.sa_mask, mask);
20476 -       }
20477 -
20478 -       ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
20479 -
20480 -       if (!ret && oact) {
20481 -               if (verify_area(VERIFY_WRITE, oact, sizeof(*oact)) ||
20482 -                   __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
20483 -                   __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
20484 -                       return -EFAULT;
20485 -               __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
20486 -               __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
20487 -       }
20488 -
20489 -       return ret;
20490 -}
20491 -
20492  /*
20493   * sys_ipc() is the de-multiplexer for the SysV IPC calls..
20494   *
20495 @@ -253,7 +224,7 @@ int sys_ipc (uint call, int first, int s
20496                 return sys_shmctl (first, second,
20497                                    (struct shmid_ds *) ptr);
20498         default:
20499 -               return -EINVAL;
20500 +               return -ENOSYS;
20501         }
20502  }
20503  
20504 @@ -302,11 +273,6 @@ int sys_olduname(struct oldold_utsname *
20505         return error;
20506  }
20507  
20508 -int sys_sigaltstack(const stack_t *uss, stack_t *uoss)
20509 -{
20510 -       return(do_sigaltstack(uss, uoss, PT_REGS_SP(&current->thread.regs)));
20511 -}
20512 -
20513  long execute_syscall(void *r)
20514  {
20515         return(CHOOSE_MODE_PROC(execute_syscall_tt, execute_syscall_skas, r));
20516 --- linux-2.6.0-test6/arch/um/kernel/sys_call_table.c   2003-06-14 12:18:30.000000000 -0700
20517 +++ 25/arch/um/kernel/sys_call_table.c  2003-10-05 00:34:32.000000000 -0700
20518 @@ -219,15 +219,30 @@ extern syscall_handler_t sys_getdents64;
20519  extern syscall_handler_t sys_gettid;
20520  extern syscall_handler_t sys_readahead;
20521  extern syscall_handler_t sys_tkill;
20522 +extern syscall_handler_t sys_setxattr;
20523 +extern syscall_handler_t sys_lsetxattr;
20524 +extern syscall_handler_t sys_fsetxattr;
20525 +extern syscall_handler_t sys_getxattr;
20526 +extern syscall_handler_t sys_lgetxattr;
20527 +extern syscall_handler_t sys_fgetxattr;
20528 +extern syscall_handler_t sys_listxattr;
20529 +extern syscall_handler_t sys_llistxattr;
20530 +extern syscall_handler_t sys_flistxattr;
20531 +extern syscall_handler_t sys_removexattr;
20532 +extern syscall_handler_t sys_lremovexattr;
20533 +extern syscall_handler_t sys_fremovexattr;
20534  extern syscall_handler_t sys_sendfile64;
20535  extern syscall_handler_t sys_futex;
20536  extern syscall_handler_t sys_sched_setaffinity;
20537  extern syscall_handler_t sys_sched_getaffinity;
20538 +extern syscall_handler_t sys_set_thread_area;
20539 +extern syscall_handler_t sys_get_thread_area;
20540  extern syscall_handler_t sys_io_setup;
20541  extern syscall_handler_t sys_io_destroy;
20542  extern syscall_handler_t sys_io_getevents;
20543  extern syscall_handler_t sys_io_submit;
20544  extern syscall_handler_t sys_io_cancel;
20545 +extern syscall_handler_t sys_fadvise64;
20546  extern syscall_handler_t sys_exit_group;
20547  extern syscall_handler_t sys_lookup_dcookie;
20548  extern syscall_handler_t sys_epoll_create;
20549 @@ -235,6 +250,20 @@ extern syscall_handler_t sys_epoll_ctl;
20550  extern syscall_handler_t sys_epoll_wait;
20551  extern syscall_handler_t sys_remap_file_pages;
20552  extern syscall_handler_t sys_set_tid_address;
20553 +extern syscall_handler_t sys_timer_create;
20554 +extern syscall_handler_t sys_timer_settime;
20555 +extern syscall_handler_t sys_timer_gettime;
20556 +extern syscall_handler_t sys_timer_getoverrun;
20557 +extern syscall_handler_t sys_timer_delete;
20558 +extern syscall_handler_t sys_clock_settime;
20559 +extern syscall_handler_t sys_clock_gettime;
20560 +extern syscall_handler_t sys_clock_getres;
20561 +extern syscall_handler_t sys_clock_nanosleep;
20562 +extern syscall_handler_t sys_statfs64;
20563 +extern syscall_handler_t sys_fstatfs64;
20564 +extern syscall_handler_t sys_tgkill;
20565 +extern syscall_handler_t sys_utimes;
20566 +extern syscall_handler_t sys_fadvise64_64;
20567  
20568  #ifdef CONFIG_NFSD
20569  #define NFSSERVCTL sys_nfsservctl
20570 @@ -246,7 +275,7 @@ extern syscall_handler_t um_mount;
20571  extern syscall_handler_t um_time;
20572  extern syscall_handler_t um_stime;
20573  
20574 -#define LAST_GENERIC_SYSCALL __NR_set_tid_address
20575 +#define LAST_GENERIC_SYSCALL __NR_fadvise64_64
20576  
20577  #if LAST_GENERIC_SYSCALL > LAST_ARCH_SYSCALL
20578  #define LAST_SYSCALL LAST_GENERIC_SYSCALL
20579 @@ -455,32 +484,37 @@ syscall_handler_t *sys_call_table[] = {
20580         [ __NR_stat64 ] = sys_stat64,
20581         [ __NR_lstat64 ] = sys_lstat64,
20582         [ __NR_fstat64 ] = sys_fstat64,
20583 -       [ __NR_fcntl64 ] = sys_fcntl64,
20584         [ __NR_getdents64 ] = sys_getdents64,
20585 +       [ __NR_fcntl64 ] = sys_fcntl64,
20586 +       [ 223 ] = sys_ni_syscall,
20587         [ __NR_gettid ] = sys_gettid,
20588         [ __NR_readahead ] = sys_readahead,
20589 -       [ __NR_setxattr ] = sys_ni_syscall,
20590 -       [ __NR_lsetxattr ] = sys_ni_syscall,
20591 -       [ __NR_fsetxattr ] = sys_ni_syscall,
20592 -       [ __NR_getxattr ] = sys_ni_syscall,
20593 -       [ __NR_lgetxattr ] = sys_ni_syscall,
20594 -       [ __NR_fgetxattr ] = sys_ni_syscall,
20595 -       [ __NR_listxattr ] = sys_ni_syscall,
20596 -       [ __NR_llistxattr ] = sys_ni_syscall,
20597 -       [ __NR_flistxattr ] = sys_ni_syscall,
20598 -       [ __NR_removexattr ] = sys_ni_syscall,
20599 -       [ __NR_lremovexattr ] = sys_ni_syscall,
20600 -       [ __NR_fremovexattr ] = sys_ni_syscall,
20601 +       [ __NR_setxattr ] = sys_setxattr,
20602 +       [ __NR_lsetxattr ] = sys_lsetxattr,
20603 +       [ __NR_fsetxattr ] = sys_fsetxattr,
20604 +       [ __NR_getxattr ] = sys_getxattr,
20605 +       [ __NR_lgetxattr ] = sys_lgetxattr,
20606 +       [ __NR_fgetxattr ] = sys_fgetxattr,
20607 +       [ __NR_listxattr ] = sys_listxattr,
20608 +       [ __NR_llistxattr ] = sys_llistxattr,
20609 +       [ __NR_flistxattr ] = sys_flistxattr,
20610 +       [ __NR_removexattr ] = sys_removexattr,
20611 +       [ __NR_lremovexattr ] = sys_lremovexattr,
20612 +       [ __NR_fremovexattr ] = sys_fremovexattr,
20613         [ __NR_tkill ] = sys_tkill,
20614         [ __NR_sendfile64 ] = sys_sendfile64,
20615         [ __NR_futex ] = sys_futex,
20616         [ __NR_sched_setaffinity ] = sys_sched_setaffinity,
20617         [ __NR_sched_getaffinity ] = sys_sched_getaffinity,
20618 +       [ __NR_set_thread_area ] = sys_ni_syscall,
20619 +       [ __NR_get_thread_area ] = sys_ni_syscall,
20620         [ __NR_io_setup ] = sys_io_setup,
20621         [ __NR_io_destroy ] = sys_io_destroy,
20622         [ __NR_io_getevents ] = sys_io_getevents,
20623         [ __NR_io_submit ] = sys_io_submit,
20624         [ __NR_io_cancel ] = sys_io_cancel,
20625 +       [ __NR_fadvise64 ] = sys_fadvise64,
20626 +       [ 251 ] = sys_ni_syscall,
20627         [ __NR_exit_group ] = sys_exit_group,
20628         [ __NR_lookup_dcookie ] = sys_lookup_dcookie,
20629         [ __NR_epoll_create ] = sys_epoll_create,
20630 @@ -488,6 +522,20 @@ syscall_handler_t *sys_call_table[] = {
20631         [ __NR_epoll_wait ] = sys_epoll_wait,
20632          [ __NR_remap_file_pages ] = sys_remap_file_pages,
20633          [ __NR_set_tid_address ] = sys_set_tid_address,
20634 +       [ __NR_timer_create ] = sys_timer_create,
20635 +       [ __NR_timer_settime ] = sys_timer_settime,
20636 +       [ __NR_timer_gettime ] = sys_timer_gettime,
20637 +       [ __NR_timer_getoverrun ] = sys_timer_getoverrun,
20638 +       [ __NR_timer_delete ] = sys_timer_delete,
20639 +       [ __NR_clock_settime ] = sys_clock_settime,
20640 +       [ __NR_clock_gettime ] = sys_clock_gettime,
20641 +       [ __NR_clock_getres ] = sys_clock_getres,
20642 +       [ __NR_clock_nanosleep ] = sys_clock_nanosleep,
20643 +       [ __NR_statfs64 ] = sys_statfs64,
20644 +       [ __NR_fstatfs64 ] = sys_fstatfs64,
20645 +       [ __NR_tgkill ] = sys_tgkill,
20646 +       [ __NR_utimes ] = sys_utimes,
20647 +       [ __NR_fadvise64_64 ] = sys_fadvise64_64,
20648  
20649         ARCH_SYSCALLS
20650         [ LAST_SYSCALL + 1 ... NR_syscalls ] = 
20651 --- linux-2.6.0-test6/arch/um/kernel/sysrq.c    2003-06-14 12:18:07.000000000 -0700
20652 +++ 25/arch/um/kernel/sysrq.c   2003-10-05 00:34:32.000000000 -0700
20653 @@ -53,6 +53,14 @@ void show_trace_task(struct task_struct 
20654         show_trace((unsigned long *)esp);
20655  }
20656  
20657 +void show_stack(struct task_struct *task, unsigned long *sp)
20658 +{
20659 +       if(task)
20660 +               show_trace_task(task);
20661 +       else
20662 +               show_trace(sp);
20663 +}
20664 +
20665  /*
20666   * Overrides for Emacs so that we follow Linus's tabbing style.
20667   * Emacs will notice this stuff at the end of the file and automatically
20668 --- linux-2.6.0-test6/arch/um/kernel/time.c     2003-06-16 22:32:20.000000000 -0700
20669 +++ 25/arch/um/kernel/time.c    2003-10-05 00:34:32.000000000 -0700
20670 @@ -15,12 +15,16 @@
20671  #include "process.h"
20672  #include "signal_user.h"
20673  #include "time_user.h"
20674 +#include "kern_constants.h"
20675  
20676  extern struct timeval xtime;
20677  
20678 +struct timeval local_offset = { 0, 0 };
20679 +
20680  void timer(void)
20681  {
20682         gettimeofday(&xtime, NULL);
20683 +       timeradd(&xtime, &local_offset, &xtime);
20684  }
20685  
20686  void set_interval(int timer_type)
20687 @@ -65,7 +69,7 @@ void switch_timers(int to_real)
20688                        errno);
20689  }
20690  
20691 -void idle_timer(void)
20692 +void uml_idle_timer(void)
20693  {
20694         if(signal(SIGVTALRM, SIG_IGN) == SIG_ERR)
20695                 panic("Couldn't unset SIGVTALRM handler");
20696 @@ -82,8 +86,6 @@ void time_init(void)
20697         set_interval(ITIMER_VIRTUAL);
20698  }
20699  
20700 -struct timeval local_offset = { 0, 0 };
20701 -
20702  void do_gettimeofday(struct timeval *tv)
20703  {
20704         unsigned long flags;
20705 @@ -100,7 +102,7 @@ int do_settimeofday(struct timespec *tv)
20706         unsigned long flags;
20707         struct timeval tv_in;
20708  
20709 -       if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
20710 +       if ((unsigned long) tv->tv_nsec >= UM_NSEC_PER_SEC)
20711                 return -EINVAL;
20712  
20713         tv_in.tv_sec = tv->tv_sec;
20714 @@ -110,6 +112,8 @@ int do_settimeofday(struct timespec *tv)
20715         gettimeofday(&now, NULL);
20716         timersub(&tv_in, &now, &local_offset);
20717         time_unlock(flags);
20718 +
20719 +       return(0);
20720  }
20721  
20722  void idle_sleep(int secs)
20723 --- linux-2.6.0-test6/arch/um/kernel/time_kern.c        2003-06-14 12:18:24.000000000 -0700
20724 +++ 25/arch/um/kernel/time_kern.c       2003-10-05 00:34:32.000000000 -0700
20725 @@ -38,7 +38,7 @@ int __attribute__ ((__section__ (".unpro
20726  
20727  void timer_irq(union uml_pt_regs *regs)
20728  {
20729 -       int cpu = current->thread_info->cpu, ticks = missed_ticks[cpu];
20730 +       int cpu = current_thread->cpu, ticks = missed_ticks[cpu];
20731  
20732          if(!timer_irq_inited) return;
20733         missed_ticks[cpu] = 0;
20734 @@ -55,12 +55,13 @@ void boot_timer_handler(int sig)
20735         do_timer(&regs);
20736  }
20737  
20738 -void um_timer(int irq, void *dev, struct pt_regs *regs)
20739 +irqreturn_t um_timer(int irq, void *dev, struct pt_regs *regs)
20740  {
20741         do_timer(regs);
20742 -       write_seqlock(&xtime_lock);
20743 +       write_seqlock_irq(&xtime_lock);
20744         timer();
20745 -       write_sequnlock(&xtime_lock);
20746 +       write_sequnlock_irq(&xtime_lock);
20747 +       return(IRQ_HANDLED);
20748  }
20749  
20750  long um_time(int * tloc)
20751 @@ -78,12 +79,12 @@ long um_time(int * tloc)
20752  long um_stime(int * tptr)
20753  {
20754         int value;
20755 -       struct timeval new;
20756 +       struct timespec new;
20757  
20758         if (get_user(value, tptr))
20759                  return -EFAULT;
20760         new.tv_sec = value;
20761 -       new.tv_usec = 0;
20762 +       new.tv_nsec = 0;
20763         do_settimeofday(&new);
20764         return 0;
20765  }
20766 @@ -122,9 +123,11 @@ void __const_udelay(um_udelay_t usecs)
20767  void timer_handler(int sig, union uml_pt_regs *regs)
20768  {
20769  #ifdef CONFIG_SMP
20770 +       local_irq_disable();
20771         update_process_times(user_context(UPT_SP(regs)));
20772 +       local_irq_enable();
20773  #endif
20774 -       if(current->thread_info->cpu == 0)
20775 +       if(current_thread->cpu == 0)
20776                 timer_irq(regs);
20777  }
20778  
20779 --- linux-2.6.0-test6/arch/um/kernel/trap_kern.c        2003-06-14 12:17:57.000000000 -0700
20780 +++ 25/arch/um/kernel/trap_kern.c       2003-10-05 00:34:32.000000000 -0700
20781 @@ -16,6 +16,7 @@
20782  #include "asm/tlbflush.h"
20783  #include "asm/a.out.h"
20784  #include "asm/current.h"
20785 +#include "asm/irq.h"
20786  #include "user_util.h"
20787  #include "kern_util.h"
20788  #include "kern.h"
20789 @@ -51,7 +52,7 @@ int handle_page_fault(unsigned long addr
20790         if(is_write && !(vma->vm_flags & VM_WRITE)) 
20791                 goto out;
20792         page = address & PAGE_MASK;
20793 -       if(page == (unsigned long) current->thread_info + PAGE_SIZE)
20794 +       if(page == (unsigned long) current_thread + PAGE_SIZE)
20795                 panic("Kernel stack overflow");
20796         pgd = pgd_offset(mm, page);
20797         pmd = pmd_offset(pgd, page);
20798 @@ -180,6 +181,11 @@ void bus_handler(int sig, union uml_pt_r
20799         else relay_signal(sig, regs);
20800  }
20801  
20802 +void winch(int sig, union uml_pt_regs *regs)
20803 +{
20804 +       do_IRQ(WINCH_IRQ, regs);
20805 +}
20806 +
20807  void trap_init(void)
20808  {
20809  }
20810 --- linux-2.6.0-test6/arch/um/kernel/trap_user.c        2003-06-14 12:18:09.000000000 -0700
20811 +++ 25/arch/um/kernel/trap_user.c       2003-10-05 00:34:32.000000000 -0700
20812 @@ -82,6 +82,8 @@ struct signal_info sig_info[] = {
20813                      .is_irq            = 0 },
20814         [ SIGILL ] { .handler           = relay_signal,
20815                      .is_irq            = 0 },
20816 +       [ SIGWINCH ] { .handler         = winch,
20817 +                      .is_irq          = 1 },
20818         [ SIGBUS ] { .handler           = bus_handler,
20819                      .is_irq            = 0 },
20820         [ SIGSEGV] { .handler           = segv_handler,
20821 --- linux-2.6.0-test6/arch/um/kernel/tt/exec_kern.c     2003-06-14 12:17:59.000000000 -0700
20822 +++ 25/arch/um/kernel/tt/exec_kern.c    2003-10-05 00:34:32.000000000 -0700
20823 @@ -47,17 +47,17 @@ void flush_thread_tt(void)
20824                 do_exit(SIGKILL);
20825         }
20826  
20827 -       if(current->thread_info->cpu == 0)
20828 +       if(current_thread->cpu == 0)
20829                 forward_interrupts(new_pid);
20830         current->thread.request.op = OP_EXEC;
20831         current->thread.request.u.exec.pid = new_pid;
20832 -       unprotect_stack((unsigned long) current->thread_info);
20833 +       unprotect_stack((unsigned long) current_thread);
20834         os_usr1_process(os_getpid());
20835  
20836         enable_timer();
20837         free_page(stack);
20838         protect_memory(uml_reserved, high_physmem - uml_reserved, 1, 1, 0, 1);
20839 -       task_protections((unsigned long) current->thread_info);
20840 +       task_protections((unsigned long) current_thread);
20841         force_flush_all();
20842         unblock_signals();
20843  }
20844 --- linux-2.6.0-test6/arch/um/kernel/tt/include/uaccess.h       2003-06-14 12:18:24.000000000 -0700
20845 +++ 25/arch/um/kernel/tt/include/uaccess.h      2003-10-05 00:34:32.000000000 -0700
20846 @@ -46,18 +46,20 @@ extern int __do_copy_from_user(void *to,
20847  
20848  static inline int copy_from_user_tt(void *to, const void *from, int n)
20849  {
20850 -       return(access_ok_tt(VERIFY_READ, from, n) ?
20851 -              __do_copy_from_user(to, from, n, 
20852 -                                  &current->thread.fault_addr,
20853 -                                  &current->thread.fault_catcher) : n);
20854 +       if(!access_ok_tt(VERIFY_READ, from, n)) 
20855 +               return(n);
20856 +
20857 +       return(__do_copy_from_user(to, from, n, &current->thread.fault_addr,
20858 +                                  &current->thread.fault_catcher));
20859  }
20860  
20861  static inline int copy_to_user_tt(void *to, const void *from, int n)
20862  {
20863 -       return(access_ok_tt(VERIFY_WRITE, to, n) ?
20864 -              __do_copy_to_user(to, from, n, 
20865 -                                  &current->thread.fault_addr,
20866 -                                  &current->thread.fault_catcher) : n);
20867 +       if(!access_ok_tt(VERIFY_WRITE, to, n))
20868 +               return(n);
20869 +               
20870 +       return(__do_copy_to_user(to, from, n, &current->thread.fault_addr,
20871 +                                &current->thread.fault_catcher));
20872  }
20873  
20874  extern int __do_strncpy_from_user(char *dst, const char *src, size_t n,
20875 @@ -67,7 +69,9 @@ static inline int strncpy_from_user_tt(c
20876  {
20877         int n;
20878  
20879 -       if(!access_ok_tt(VERIFY_READ, src, 1)) return(-EFAULT);
20880 +       if(!access_ok_tt(VERIFY_READ, src, 1)) 
20881 +               return(-EFAULT);
20882 +
20883         n = __do_strncpy_from_user(dst, src, count, 
20884                                    &current->thread.fault_addr,
20885                                    &current->thread.fault_catcher);
20886 @@ -87,10 +91,11 @@ static inline int __clear_user_tt(void *
20887  
20888  static inline int clear_user_tt(void *mem, int len)
20889  {
20890 -       return(access_ok_tt(VERIFY_WRITE, mem, len) ? 
20891 -              __do_clear_user(mem, len, 
20892 -                              &current->thread.fault_addr,
20893 -                              &current->thread.fault_catcher) : len);
20894 +       if(!access_ok_tt(VERIFY_WRITE, mem, len))
20895 +               return(len);
20896 +
20897 +       return(__do_clear_user(mem, len, &current->thread.fault_addr,
20898 +                              &current->thread.fault_catcher));
20899  }
20900  
20901  extern int __do_strnlen_user(const char *str, unsigned long n,
20902 --- linux-2.6.0-test6/arch/um/kernel/tt/process_kern.c  2003-08-22 19:23:40.000000000 -0700
20903 +++ 25/arch/um/kernel/tt/process_kern.c 2003-10-05 00:34:32.000000000 -0700
20904 @@ -104,7 +104,10 @@ void *switch_to_tt(void *prev, void *nex
20905  
20906  void release_thread_tt(struct task_struct *task)
20907  {
20908 -       os_kill_process(task->thread.mode.tt.extern_pid, 0);
20909 +       int pid = task->thread.mode.tt.extern_pid;
20910 +
20911 +       if(os_getpid() != pid)
20912 +               os_kill_process(pid, 0);
20913  }
20914  
20915  void exit_thread_tt(void)
20916 @@ -125,27 +128,27 @@ static void new_thread_handler(int sig)
20917         UPT_SC(&current->thread.regs.regs) = (void *) (&sig + 1);
20918         suspend_new_thread(current->thread.mode.tt.switch_pipe[0]);
20919  
20920 -       block_signals();
20921 +       force_flush_all();
20922 +       if(current->thread.prev_sched != NULL)
20923 +               schedule_tail(current->thread.prev_sched);
20924 +       current->thread.prev_sched = NULL;
20925 +
20926         init_new_thread_signals(1);
20927 -#ifdef CONFIG_SMP
20928 -       schedule_tail(current->thread.prev_sched);
20929 -#endif
20930         enable_timer();
20931         free_page(current->thread.temp_stack);
20932         set_cmdline("(kernel thread)");
20933 -       force_flush_all();
20934  
20935 -       current->thread.prev_sched = NULL;
20936         change_sig(SIGUSR1, 1);
20937         change_sig(SIGVTALRM, 1);
20938         change_sig(SIGPROF, 1);
20939 -       unblock_signals();
20940 +       local_irq_enable();
20941         if(!run_kernel_thread(fn, arg, &current->thread.exec_buf))
20942                 do_exit(0);
20943  }
20944  
20945  static int new_thread_proc(void *stack)
20946  {
20947 +       local_irq_disable();
20948         init_new_thread_stack(stack, new_thread_handler);
20949         os_usr1_process(os_getpid());
20950         return(0);
20951 @@ -165,35 +168,32 @@ void finish_fork_handler(int sig)
20952         UPT_SC(&current->thread.regs.regs) = (void *) (&sig + 1);
20953         suspend_new_thread(current->thread.mode.tt.switch_pipe[0]);
20954  
20955 -#ifdef CONFIG_SMP      
20956 -       schedule_tail(NULL);
20957 -#endif
20958 +       force_flush_all();
20959 +       if(current->thread.prev_sched != NULL)
20960 +               schedule_tail(current->thread.prev_sched);
20961 +       current->thread.prev_sched = NULL;
20962 +
20963         enable_timer();
20964         change_sig(SIGVTALRM, 1);
20965         local_irq_enable();
20966 -       force_flush_all();
20967         if(current->mm != current->parent->mm)
20968                 protect_memory(uml_reserved, high_physmem - uml_reserved, 1, 
20969                                1, 0, 1);
20970 -       task_protections((unsigned long) current->thread_info);
20971 -
20972 -       current->thread.prev_sched = NULL;
20973 +       task_protections((unsigned long) current_thread);
20974  
20975         free_page(current->thread.temp_stack);
20976 +       local_irq_disable();
20977         change_sig(SIGUSR1, 0);
20978         set_user_mode(current);
20979  }
20980  
20981 -static int sigusr1 = SIGUSR1;
20982 -
20983  int fork_tramp(void *stack)
20984  {
20985 -       int sig = sigusr1;
20986 -
20987         local_irq_disable();
20988 +       arch_init_thread();
20989         init_new_thread_stack(stack, finish_fork_handler);
20990  
20991 -       kill(os_getpid(), sig);
20992 +       os_usr1_process(os_getpid());
20993         return(0);
20994  }
20995  
20996 @@ -377,8 +377,8 @@ static void mprotect_kernel_mem(int w)
20997  
20998         pages = (1 << CONFIG_KERNEL_STACK_ORDER);
20999  
21000 -       start = (unsigned long) current->thread_info + PAGE_SIZE;
21001 -       end = (unsigned long) current + PAGE_SIZE * pages;
21002 +       start = (unsigned long) current_thread + PAGE_SIZE;
21003 +       end = (unsigned long) current_thread + PAGE_SIZE * pages;
21004         protect_memory(uml_reserved, start - uml_reserved, 1, w, 1, 1);
21005         protect_memory(end, high_physmem - end, 1, w, 1, 1);
21006  
21007 --- linux-2.6.0-test6/arch/um/kernel/tt/ptproxy/proxy.c 2003-06-14 12:18:23.000000000 -0700
21008 +++ 25/arch/um/kernel/tt/ptproxy/proxy.c        2003-10-05 00:34:32.000000000 -0700
21009 @@ -293,10 +293,10 @@ void fake_child_exit(void)
21010  }
21011  
21012  char gdb_init_string[] = 
21013 -"att 1
21014 -b panic
21015 -b stop
21016 -handle SIGWINCH nostop noprint pass
21017 +"att 1 \n\
21018 +b panic \n\
21019 +b stop \n\
21020 +handle SIGWINCH nostop noprint pass \n\
21021  ";
21022  
21023  int start_debugger(char *prog, int startup, int stop, int *fd_out)
21024 --- linux-2.6.0-test6/arch/um/kernel/tt/tracer.c        2003-06-14 12:17:56.000000000 -0700
21025 +++ 25/arch/um/kernel/tt/tracer.c       2003-10-05 00:34:32.000000000 -0700
21026 @@ -39,7 +39,7 @@ int is_tracer_winch(int pid, int fd, voi
21027                 return(0);
21028  
21029         register_winch_irq(tracer_winch[0], fd, -1, data);
21030 -       return(0);
21031 +       return(1);
21032  }
21033  
21034  static void tracer_winch_handler(int sig)
21035 @@ -401,7 +401,7 @@ static int __init uml_debug_setup(char *
21036                 
21037                 if(!strcmp(line, "go")) debug_stop = 0;
21038                 else if(!strcmp(line, "parent")) debug_parent = 1;
21039 -               else printk("Unknown debug option : '%s'\n", line);
21040 +               else printf("Unknown debug option : '%s'\n", line);
21041  
21042                 line = next;
21043         }
21044 --- linux-2.6.0-test6/arch/um/kernel/tt/uaccess_user.c  2003-06-14 12:18:06.000000000 -0700
21045 +++ 25/arch/um/kernel/tt/uaccess_user.c 2003-10-05 00:34:32.000000000 -0700
21046 @@ -8,15 +8,20 @@
21047  #include <string.h>
21048  #include "user_util.h"
21049  #include "uml_uaccess.h"
21050 +#include "task.h"
21051 +#include "kern_util.h"
21052  
21053  int __do_copy_from_user(void *to, const void *from, int n,
21054                         void **fault_addr, void **fault_catcher)
21055  {
21056 +       struct tt_regs save = TASK_REGS(get_current())->tt;
21057         unsigned long fault;
21058         int faulted;
21059  
21060         fault = __do_user_copy(to, from, n, fault_addr, fault_catcher,
21061                                __do_copy, &faulted);
21062 +       TASK_REGS(get_current())->tt = save;
21063 +
21064         if(!faulted) return(0);
21065         else return(n - (fault - (unsigned long) from));
21066  }
21067 @@ -29,11 +34,14 @@ static void __do_strncpy(void *dst, cons
21068  int __do_strncpy_from_user(char *dst, const char *src, unsigned long count,
21069                            void **fault_addr, void **fault_catcher)
21070  {
21071 +       struct tt_regs save = TASK_REGS(get_current())->tt;
21072         unsigned long fault;
21073         int faulted;
21074  
21075         fault = __do_user_copy(dst, src, count, fault_addr, fault_catcher,
21076                                __do_strncpy, &faulted);
21077 +       TASK_REGS(get_current())->tt = save;
21078 +
21079         if(!faulted) return(strlen(dst));
21080         else return(-1);
21081  }
21082 @@ -46,11 +54,14 @@ static void __do_clear(void *to, const v
21083  int __do_clear_user(void *mem, unsigned long len,
21084                     void **fault_addr, void **fault_catcher)
21085  {
21086 +       struct tt_regs save = TASK_REGS(get_current())->tt;
21087         unsigned long fault;
21088         int faulted;
21089  
21090         fault = __do_user_copy(mem, NULL, len, fault_addr, fault_catcher,
21091                                __do_clear, &faulted);
21092 +       TASK_REGS(get_current())->tt = save;
21093 +
21094         if(!faulted) return(0);
21095         else return(len - (fault - (unsigned long) mem));
21096  }
21097 @@ -58,6 +69,7 @@ int __do_clear_user(void *mem, unsigned 
21098  int __do_strnlen_user(const char *str, unsigned long n,
21099                       void **fault_addr, void **fault_catcher)
21100  {
21101 +       struct tt_regs save = TASK_REGS(get_current())->tt;
21102         int ret;
21103         unsigned long *faddrp = (unsigned long *)fault_addr;
21104         jmp_buf jbuf;
21105 @@ -71,6 +83,8 @@ int __do_strnlen_user(const char *str, u
21106         }
21107         *fault_addr = NULL;
21108         *fault_catcher = NULL;
21109 +
21110 +       TASK_REGS(get_current())->tt = save;
21111         return ret;
21112  }
21113  
21114 --- linux-2.6.0-test6/arch/um/kernel/um_arch.c  2003-08-22 19:23:40.000000000 -0700
21115 +++ 25/arch/um/kernel/um_arch.c 2003-10-05 00:34:32.000000000 -0700
21116 @@ -38,13 +38,18 @@
21117  #include "mode_kern.h"
21118  #include "mode.h"
21119  
21120 -#define DEFAULT_COMMAND_LINE "root=6200"
21121 +#define DEFAULT_COMMAND_LINE "root=ubd0"
21122  
21123  struct cpuinfo_um boot_cpu_data = { 
21124         .loops_per_jiffy        = 0,
21125         .ipi_pipe               = { -1, -1 }
21126  };
21127  
21128 +/* Placeholder to make UML link until the vsyscall stuff is actually 
21129 + * implemented
21130 + */
21131 +void *__kernel_vsyscall;
21132 +
21133  unsigned long thread_saved_pc(struct task_struct *task)
21134  {
21135         return(os_process_pc(CHOOSE_MODE_PROC(thread_pid_tt, thread_pid_skas,
21136 @@ -61,10 +66,14 @@ static int show_cpuinfo(struct seq_file 
21137                 return 0;
21138  #endif
21139  
21140 -       seq_printf(m, "bogomips\t: %lu.%02lu\n",
21141 +       seq_printf(m, "processor\t: %d\n", index);
21142 +       seq_printf(m, "vendor_id\t: User Mode Linux\n");
21143 +       seq_printf(m, "model name\t: UML\n");
21144 +       seq_printf(m, "mode\t\t: %s\n", CHOOSE_MODE("tt", "skas"));
21145 +       seq_printf(m, "host\t\t: %s\n", host_info);
21146 +       seq_printf(m, "bogomips\t: %lu.%02lu\n\n",
21147                    loops_per_jiffy/(500000/HZ),
21148                    (loops_per_jiffy/(5000/HZ)) % 100);
21149 -       seq_printf(m, "host\t\t: %s\n", host_info);
21150  
21151         return(0);
21152  }
21153 @@ -134,12 +143,12 @@ void set_cmdline(char *cmd)
21154         if(umid != NULL){
21155                 snprintf(argv1_begin, 
21156                          (argv1_end - argv1_begin) * sizeof(*ptr), 
21157 -                        "(%s)", umid);
21158 +                        "(%s) ", umid);
21159                 ptr = &argv1_begin[strlen(argv1_begin)];
21160         }
21161         else ptr = argv1_begin;
21162  
21163 -       snprintf(ptr, (argv1_end - ptr) * sizeof(*ptr), " [%s]", cmd);
21164 +       snprintf(ptr, (argv1_end - ptr) * sizeof(*ptr), "[%s]", cmd);
21165         memset(argv1_begin + strlen(argv1_begin), '\0', 
21166                argv1_end - argv1_begin - strlen(argv1_begin));
21167  #endif
21168 @@ -179,7 +188,7 @@ __uml_setup("root=", uml_root_setup,
21169  static int __init uml_ncpus_setup(char *line, int *add)
21170  {
21171         if (!sscanf(line, "%d", &ncpus)) {
21172 -               printk("Couldn't parse [%s]\n", line);
21173 +               printf("Couldn't parse [%s]\n", line);
21174                 return -1;
21175         }
21176  
21177 @@ -210,7 +219,7 @@ static int __init mode_tt_setup(char *li
21178  
21179  static int __init mode_tt_setup(char *line, int *add)
21180  {
21181 -       printk("CONFIG_MODE_TT disabled - 'mode=tt' ignored\n");
21182 +       printf("CONFIG_MODE_TT disabled - 'mode=tt' ignored\n");
21183         return(0);
21184  }
21185  
21186 @@ -221,7 +230,7 @@ static int __init mode_tt_setup(char *li
21187  
21188  static int __init mode_tt_setup(char *line, int *add)
21189  {
21190 -       printk("CONFIG_MODE_SKAS disabled - 'mode=tt' redundant\n");
21191 +       printf("CONFIG_MODE_SKAS disabled - 'mode=tt' redundant\n");
21192         return(0);
21193  }
21194  
21195 @@ -369,6 +378,7 @@ int linux_main(int argc, char **argv)
21196                 2 * PAGE_SIZE;
21197  
21198         task_protections((unsigned long) &init_thread_info);
21199 +       os_flush_stdout();
21200  
21201         return(CHOOSE_MODE(start_uml_tt(), start_uml_skas()));
21202  }
21203 --- linux-2.6.0-test6/arch/um/kernel/umid.c     2003-06-14 12:18:34.000000000 -0700
21204 +++ 25/arch/um/kernel/umid.c    2003-10-05 00:34:32.000000000 -0700
21205 @@ -33,18 +33,19 @@ static char *uml_dir = UML_DIR;
21206  static int umid_is_random = 1;
21207  static int umid_inited = 0;
21208  
21209 -static int make_umid(void);
21210 +static int make_umid(int (*printer)(const char *fmt, ...));
21211  
21212 -static int __init set_umid(char *name, int is_random)
21213 +static int __init set_umid(char *name, int is_random, 
21214 +                          int (*printer)(const char *fmt, ...))
21215  {
21216         if(umid_inited){
21217 -               printk("Unique machine name can't be set twice\n");
21218 +               (*printer)("Unique machine name can't be set twice\n");
21219                 return(-1);
21220         }
21221  
21222         if(strlen(name) > UMID_LEN - 1)
21223 -               printk("Unique machine name is being truncated to %s "
21224 -                      "characters\n", UMID_LEN);
21225 +               (*printer)("Unique machine name is being truncated to %s "
21226 +                          "characters\n", UMID_LEN);
21227         strlcpy(umid, name, sizeof(umid));
21228  
21229         umid_is_random = is_random;
21230 @@ -54,7 +55,7 @@ static int __init set_umid(char *name, i
21231  
21232  static int __init set_umid_arg(char *name, int *add)
21233  {
21234 -       return(set_umid(name, 0));
21235 +       return(set_umid(name, 0, printf));
21236  }
21237  
21238  __uml_setup("umid=", set_umid_arg,
21239 @@ -67,7 +68,7 @@ int __init umid_file_name(char *name, ch
21240  {
21241         int n;
21242  
21243 -       if(!umid_inited && make_umid()) return(-1);
21244 +       if(!umid_inited && make_umid(printk)) return(-1);
21245  
21246         n = strlen(uml_dir) + strlen(umid) + strlen(name) + 1;
21247         if(n > len){
21248 @@ -92,14 +93,14 @@ static int __init create_pid_file(void)
21249         fd = os_open_file(file, of_create(of_excl(of_rdwr(OPENFLAGS()))), 
21250                           0644);
21251         if(fd < 0){
21252 -               printk("Open of machine pid file \"%s\" failed - "
21253 +               printf("Open of machine pid file \"%s\" failed - "
21254                        "errno = %d\n", file, -fd);
21255                 return 0;
21256         }
21257  
21258         sprintf(pid, "%d\n", os_getpid());
21259         if(write(fd, pid, strlen(pid)) != strlen(pid))
21260 -               printk("Write of pid file failed - errno = %d\n", errno);
21261 +               printf("Write of pid file failed - errno = %d\n", errno);
21262         close(fd);
21263         return 0;
21264  }
21265 @@ -197,7 +198,7 @@ static int __init set_uml_dir(char *name
21266         if((strlen(name) > 0) && (name[strlen(name) - 1] != '/')){
21267                 uml_dir = malloc(strlen(name) + 1);
21268                 if(uml_dir == NULL){
21269 -                       printk("Failed to malloc uml_dir - error = %d\n",
21270 +                       printf("Failed to malloc uml_dir - error = %d\n",
21271                                errno);
21272                         uml_dir = name;
21273                         return(0);
21274 @@ -217,7 +218,7 @@ static int __init make_uml_dir(void)
21275                 char *home = getenv("HOME");
21276  
21277                 if(home == NULL){
21278 -                       printk("make_uml_dir : no value in environment for "
21279 +                       printf("make_uml_dir : no value in environment for "
21280                                "$HOME\n");
21281                         exit(1);
21282                 }
21283 @@ -239,25 +240,25 @@ static int __init make_uml_dir(void)
21284         strcpy(uml_dir, dir);
21285         
21286         if((mkdir(uml_dir, 0777) < 0) && (errno != EEXIST)){
21287 -               printk("Failed to mkdir %s - errno = %i\n", uml_dir, errno);
21288 +               printf("Failed to mkdir %s - errno = %i\n", uml_dir, errno);
21289                 return(-1);
21290         }
21291         return 0;
21292  }
21293  
21294 -static int __init make_umid(void)
21295 +static int __init make_umid(int (*printer)(const char *fmt, ...))
21296  {
21297         int fd, err;
21298         char tmp[strlen(uml_dir) + UMID_LEN + 1];
21299  
21300         strlcpy(tmp, uml_dir, sizeof(tmp));
21301  
21302 -       if(*umid == 0){
21303 +       if(!umid_inited){
21304                 strcat(tmp, "XXXXXX");
21305                 fd = mkstemp(tmp);
21306                 if(fd < 0){
21307 -                       printk("make_umid - mkstemp failed, errno = %d\n",
21308 -                              errno);
21309 +                       (*printer)("make_umid - mkstemp failed, errno = %d\n",
21310 +                                  errno);
21311                         return(1);
21312                 }
21313  
21314 @@ -267,7 +268,7 @@ static int __init make_umid(void)
21315                  * for directories.
21316                  */
21317                 unlink(tmp);
21318 -               set_umid(&tmp[strlen(uml_dir)], 1);
21319 +               set_umid(&tmp[strlen(uml_dir)], 1, printer);
21320         }
21321         
21322         sprintf(tmp, "%s%s", uml_dir, umid);
21323 @@ -275,14 +276,14 @@ static int __init make_umid(void)
21324         if((err = mkdir(tmp, 0777)) < 0){
21325                 if(errno == EEXIST){
21326                         if(not_dead_yet(tmp)){
21327 -                               printk("umid '%s' is in use\n", umid);
21328 +                               (*printer)("umid '%s' is in use\n", umid);
21329                                 return(-1);
21330                         }
21331                         err = mkdir(tmp, 0777);
21332                 }
21333         }
21334         if(err < 0){
21335 -               printk("Failed to create %s - errno = %d\n", umid, errno);
21336 +               (*printer)("Failed to create %s - errno = %d\n", umid, errno);
21337                 return(-1);
21338         }
21339  
21340 @@ -295,7 +296,13 @@ __uml_setup("uml_dir=", set_uml_dir,
21341  );
21342  
21343  __uml_postsetup(make_uml_dir);
21344 -__uml_postsetup(make_umid);
21345 +
21346 +static int __init make_umid_setup(void)
21347 +{
21348 +       return(make_umid(printf));
21349 +}
21350 +
21351 +__uml_postsetup(make_umid_setup);
21352  __uml_postsetup(create_pid_file);
21353  
21354  /*
21355 --- linux-2.6.0-test6/arch/um/kernel/user_util.c        2003-06-14 12:17:59.000000000 -0700
21356 +++ 25/arch/um/kernel/user_util.c       2003-10-05 00:34:32.000000000 -0700
21357 @@ -119,17 +119,6 @@ int wait_for_stop(int pid, int sig, int 
21358         }
21359  }
21360  
21361 -int clone_and_wait(int (*fn)(void *), void *arg, void *sp, int flags)
21362 -{
21363 -       int pid;
21364 -
21365 -       pid = clone(fn, sp, flags, arg);
21366 -       if(pid < 0) return(-1);
21367 -       wait_for_stop(pid, SIGSTOP, PTRACE_CONT, NULL);
21368 -       ptrace(PTRACE_CONT, pid, 0, 0);
21369 -       return(pid);
21370 -}
21371 -
21372  int raw(int fd, int complain)
21373  {
21374         struct termios tt;
21375 --- linux-2.6.0-test6/arch/um/Makefile  2003-08-08 22:55:11.000000000 -0700
21376 +++ 25/arch/um/Makefile 2003-10-05 00:34:32.000000000 -0700
21377 @@ -24,15 +24,17 @@ core-y                      += $(ARCH_DIR)/kernel/           \
21378  # Have to precede the include because the included Makefiles reference them.
21379  SYMLINK_HEADERS = include/asm-um/archparam.h include/asm-um/system.h \
21380         include/asm-um/sigcontext.h include/asm-um/processor.h \
21381 -       include/asm-um/ptrace.h include/asm-um/arch-signal.h
21382 +       include/asm-um/ptrace.h include/asm-um/arch-signal.h \
21383 +       include/asm-um/module.h
21384  
21385  ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \
21386         $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h
21387  
21388  GEN_HEADERS += $(ARCH_DIR)/include/task.h $(ARCH_DIR)/include/kern_constants.h
21389  
21390 -include $(ARCH_DIR)/Makefile-$(SUBARCH)
21391 -include $(ARCH_DIR)/Makefile-os-$(OS)
21392 +.PHONY: sys_prepare
21393 +sys_prepare:
21394 +       @:
21395  
21396  MAKEFILE-$(CONFIG_MODE_TT) += Makefile-tt
21397  MAKEFILE-$(CONFIG_MODE_SKAS) += Makefile-skas
21398 @@ -41,6 +43,9 @@ ifneq ($(MAKEFILE-y),)
21399    include $(addprefix $(ARCH_DIR)/,$(MAKEFILE-y))
21400  endif
21401  
21402 +include $(ARCH_DIR)/Makefile-$(SUBARCH)
21403 +include $(ARCH_DIR)/Makefile-os-$(OS)
21404 +
21405  EXTRAVERSION := $(EXTRAVERSION)-1um
21406  
21407  ARCH_INCLUDE = -I$(ARCH_DIR)/include
21408 @@ -52,14 +57,14 @@ ARCH_INCLUDE = -I$(ARCH_DIR)/include
21409  
21410  CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
21411         -D_LARGEFILE64_SOURCE $(ARCH_INCLUDE) -Derrno=kernel_errno \
21412 -       $(MODE_INCLUDE)
21413 +       -Dsigprocmask=kernel_sigprocmask $(MODE_INCLUDE)
21414  
21415  LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
21416  
21417  SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
21418  
21419  ifeq ($(CONFIG_MODE_SKAS), y)
21420 -$(SYS_HEADERS) : $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h
21421 +$(SYS_HEADERS) : $(TOPDIR)/$(ARCH_DIR)/include/skas_ptregs.h
21422  endif
21423  
21424  include/linux/version.h: arch/$(ARCH)/Makefile
21425 @@ -98,17 +103,17 @@ CPP_MODE_TT := $(shell [ "$(CONFIG_MODE_
21426  CONFIG_KERNEL_STACK_ORDER ?= 2
21427  STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] )
21428  
21429 -AFLAGS_vmlinux.lds.o = -U$(SUBARCH) \
21430 +AFLAGS_vmlinux.lds.o = $(shell echo -U$(SUBARCH) \
21431         -DSTART=$$(($(TOP_ADDR) - $(SIZE))) -DELF_ARCH=$(ELF_ARCH) \
21432         -DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE_TT) \
21433 -       -DKERNEL_STACK_SIZE=$(STACK_SIZE)
21434 +       -DKERNEL_STACK_SIZE=$(STACK_SIZE))
21435  
21436 -AFLAGS_$(LD_SCRIPT-y:.s=).o = $(AFLAGS_vmlinux.lds.o) -P -C -Uum
21437 +export AFLAGS_$(LD_SCRIPT-y:.s=).o = $(AFLAGS_vmlinux.lds.o) -P -C -Uum
21438  
21439  LD_SCRIPT-y := $(ARCH_DIR)/$(LD_SCRIPT-y)
21440  
21441 -$(LD_SCRIPT-y) : $(LD_SCRIPT-y:.s=.S) scripts FORCE
21442 -       $(call if_changed_dep,as_s_S)
21443 +#$(LD_SCRIPT-y) : $(LD_SCRIPT-y:.s=.S) scripts FORCE
21444 +#      $(call if_changed_dep,as_s_S)
21445  
21446  linux: vmlinux $(LD_SCRIPT-y)
21447         $(CC) -Wl,-T,$(LD_SCRIPT-y) $(LINK-y) $(LINK_WRAPS) \
21448 @@ -116,6 +121,7 @@ linux: vmlinux $(LD_SCRIPT-y)
21449  
21450  USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
21451  USER_CFLAGS := $(patsubst -Derrno=kernel_errno,,$(USER_CFLAGS))
21452 +USER_CFLAGS := $(patsubst -Dsigprocmask=kernel_sigprocmask,,$(USER_CFLAGS))
21453  USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
21454         $(MODE_INCLUDE)
21455  
21456 @@ -123,9 +129,10 @@ USER_CFLAGS := $(patsubst -D__KERNEL__,,
21457  USER_CFLAGS += -D_GNU_SOURCE
21458  
21459  CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/uml.lds.s \
21460 -       $(ARCH_DIR)/dyn_link.ld.s $(GEN_HEADERS)
21461 +       $(ARCH_DIR)/dyn_link.ld.s $(ARCH_DIR)/include/uml-config.h \
21462 +       $(GEN_HEADERS)
21463  
21464 -$(ARCH_DIR)/main.o: $(ARCH_DIR)/main.c
21465 +$(ARCH_DIR)/main.o: $(ARCH_DIR)/main.c sys_prepare
21466         $(CC) $(USER_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
21467  
21468  archmrproper:
21469 @@ -161,19 +168,23 @@ $(ARCH_DIR)/include/sysdep:
21470  $(ARCH_DIR)/os:
21471         cd $(ARCH_DIR) && ln -sf os-$(OS) os
21472  
21473 -$(ARCH_DIR)/include/uml-config.h :
21474 +$(ARCH_DIR)/include/uml-config.h : $(TOPDIR)/include/linux/autoconf.h
21475         sed 's/ CONFIG/ UML_CONFIG/' $(TOPDIR)/include/linux/autoconf.h > $@
21476  
21477 +filechk_$(ARCH_DIR)/include/task.h := $(ARCH_DIR)/util/mk_task
21478 +
21479  $(ARCH_DIR)/include/task.h : $(ARCH_DIR)/util/mk_task
21480 -       $< > $@
21481 +       $(call filechk,$@)
21482 +
21483 +filechk_$(ARCH_DIR)/include/kern_constants.h := $(ARCH_DIR)/util/mk_constants
21484  
21485  $(ARCH_DIR)/include/kern_constants.h : $(ARCH_DIR)/util/mk_constants
21486 -       $< > $@
21487 +       $(call filechk,$@)
21488  
21489 -$(ARCH_DIR)/util/mk_task : $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h \
21490 -       $(ARCH_DIR)/util FORCE ;
21491 +$(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants : $(ARCH_DIR)/util \
21492 +       sys_prepare FORCE ;
21493  
21494  $(ARCH_DIR)/util: FORCE
21495 -       @$(call descend,$@,)
21496 +       $(MAKE) -f scripts/Makefile.build obj=$@
21497  
21498 -export SUBARCH USER_CFLAGS OS
21499 +export SUBARCH USER_CFLAGS OS 
21500 --- linux-2.6.0-test6/arch/um/Makefile-i386     2003-06-14 12:18:29.000000000 -0700
21501 +++ 25/arch/um/Makefile-i386    2003-10-05 00:34:32.000000000 -0700
21502 @@ -16,22 +16,28 @@ SYS_UTIL_DIR        := $(ARCH_DIR)/sys-i386/uti
21503  
21504  SYS_HEADERS = $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h
21505  
21506 +sys_prepare: $(SYS_DIR)/sc.h
21507 +
21508  prepare: $(SYS_HEADERS)
21509  
21510 +filechk_$(SYS_DIR)/sc.h := $(SYS_UTIL_DIR)/mk_sc
21511 +
21512  $(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc
21513 -       $< > $@
21514 +       $(call filechk,$@)
21515 +
21516 +filechk_$(SYS_DIR)/thread.h := $(SYS_UTIL_DIR)/mk_thread 
21517  
21518  $(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread 
21519 -       $< > $@
21520 +       $(call filechk,$@)
21521  
21522 -$(SYS_UTIL_DIR)/mk_sc: FORCE ; 
21523 -       @$(call descend,$(SYS_UTIL_DIR),$@)
21524 +$(SYS_UTIL_DIR)/mk_sc: scripts/fixdep include/config/MARKER FORCE ; 
21525 +       +@$(call descend,$(SYS_UTIL_DIR),$@)
21526  
21527 -$(SYS_UTIL_DIR)/mk_thread: $(ARCH_SYMLINKS) $(GEN_HEADERS) FORCE ; 
21528 -       @$(call descend,$(SYS_UTIL_DIR),$@)
21529 +$(SYS_UTIL_DIR)/mk_thread: $(ARCH_SYMLINKS) $(GEN_HEADERS) sys_prepare FORCE ; 
21530 +       +@$(call descend,$(SYS_UTIL_DIR),$@)
21531  
21532  $(SYS_UTIL_DIR): include/asm FORCE
21533 -       @$(call descend,$@,)
21534 +       +@$(call descend,$@,)
21535  
21536  sysclean :
21537         rm -f $(SYS_HEADERS)
21538 --- linux-2.6.0-test6/arch/um/Makefile-skas     2003-06-14 12:18:09.000000000 -0700
21539 +++ 25/arch/um/Makefile-skas    2003-10-05 00:34:32.000000000 -0700
21540 @@ -14,7 +14,7 @@ MODE_INCLUDE += -I$(TOPDIR)/$(ARCH_DIR)/
21541  LINK_SKAS = -Wl,-rpath,/lib 
21542  LD_SCRIPT_SKAS = dyn.lds.s
21543  
21544 -GEN_HEADERS += $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h
21545 +GEN_HEADERS += $(TOPDIR)/$(ARCH_DIR)/include/skas_ptregs.h
21546  
21547 -$(ARCH_DIR)/kernel/skas/include/skas_ptregs.h :
21548 -       $(MAKE) -C $(ARCH_DIR)/kernel/skas include/skas_ptregs.h
21549 +$(TOPDIR)/$(ARCH_DIR)/include/skas_ptregs.h :
21550 +       $(call descend,$(ARCH_DIR)/kernel/skas,$@)
21551 --- linux-2.6.0-test6/arch/um/os-Linux/drivers/tuntap_user.c    2003-06-14 12:18:51.000000000 -0700
21552 +++ 25/arch/um/os-Linux/drivers/tuntap_user.c   2003-10-05 00:34:32.000000000 -0700
21553 @@ -142,7 +142,7 @@ static int tuntap_open(void *data)
21554                         return(-errno);
21555                 }
21556                 memset(&ifr, 0, sizeof(ifr));
21557 -               ifr.ifr_flags = IFF_TAP;
21558 +               ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
21559                 strlcpy(ifr.ifr_name, pri->dev_name, sizeof(ifr.ifr_name));
21560                 if(ioctl(pri->fd, TUNSETIFF, (void *) &ifr) < 0){
21561                         printk("TUNSETIFF failed, errno = %d", errno);
21562 --- linux-2.6.0-test6/arch/um/os-Linux/file.c   2003-06-14 12:18:51.000000000 -0700
21563 +++ 25/arch/um/os-Linux/file.c  2003-10-05 00:34:32.000000000 -0700
21564 @@ -315,7 +315,7 @@ int os_rcv_fd(int fd, int *helper_pid_ou
21565         return(new);
21566  }
21567  
21568 -int create_unix_socket(char *file, int len)
21569 +int create_unix_socket(char *file, int len, int close_on_exec)
21570  {
21571         struct sockaddr_un addr;
21572         int sock, err;
21573 @@ -327,6 +327,10 @@ int create_unix_socket(char *file, int l
21574                 return(-errno);
21575         }
21576  
21577 +       if(close_on_exec && fcntl(sock, F_SETFD, 1) < 0)
21578 +               printk("create_unix_socket : Setting FD_CLOEXEC failed, "
21579 +                      "errno = %d", errno);
21580 +
21581         addr.sun_family = AF_UNIX;
21582  
21583         /* XXX Be more careful about overflow */
21584 @@ -342,6 +346,37 @@ int create_unix_socket(char *file, int l
21585         return(sock);
21586  }
21587  
21588 +void os_flush_stdout(void)
21589 +{
21590 +       fflush(stdout);
21591 +}
21592 +
21593 +int os_lock_file(int fd, int excl)
21594 +{
21595 +       int type = excl ? F_WRLCK : F_RDLCK;
21596 +       struct flock lock = ((struct flock) { .l_type   = type,
21597 +                                             .l_whence = SEEK_SET,
21598 +                                             .l_start  = 0,
21599 +                                             .l_len    = 0 } );
21600 +       int err, save;
21601 +
21602 +       err = fcntl(fd, F_SETLK, &lock);
21603 +       if(!err)
21604 +               goto out;
21605 +
21606 +       save = -errno;
21607 +       err = fcntl(fd, F_GETLK, &lock);
21608 +       if(err){
21609 +               err = -errno;
21610 +               goto out;
21611 +       }
21612 +       
21613 +       printk("F_SETLK failed, file already locked by pid %d\n", lock.l_pid);
21614 +       err = save;
21615 + out:
21616 +       return(err);
21617 +}
21618 +
21619  /*
21620   * Overrides for Emacs so that we follow Linus's tabbing style.
21621   * Emacs will notice this stuff at the end of the file and automatically
21622 --- linux-2.6.0-test6/arch/um/sys-i386/bugs.c   2003-06-14 12:18:29.000000000 -0700
21623 +++ 25/arch/um/sys-i386/bugs.c  2003-10-05 00:34:32.000000000 -0700
21624 @@ -8,6 +8,7 @@
21625  #include <errno.h>
21626  #include <string.h>
21627  #include <sys/signal.h>
21628 +#include <asm/ldt.h>
21629  #include "kern_util.h"
21630  #include "user.h"
21631  #include "sysdep/ptrace.h"
21632 @@ -16,8 +17,8 @@
21633  #define MAXTOKEN 64
21634  
21635  /* Set during early boot */
21636 -int cpu_has_cmov = 1;
21637 -int cpu_has_xmm = 0;
21638 +int host_has_cmov = 1;
21639 +int host_has_xmm = 0;
21640  
21641  static char token(int fd, char *buf, int len, char stop)
21642  {
21643 @@ -104,6 +105,25 @@ static int check_cpu_feature(char *featu
21644         return(1);
21645  }
21646  
21647 +static void disable_lcall(void)
21648 +{
21649 +       struct modify_ldt_ldt_s ldt;
21650 +       int err;
21651 +
21652 +       bzero(&ldt, sizeof(ldt));
21653 +       ldt.entry_number = 7;
21654 +       ldt.base_addr = 0;
21655 +       ldt.limit = 0;
21656 +       err = modify_ldt(1, &ldt, sizeof(ldt));
21657 +       if(err)
21658 +               printk("Failed to disable lcall7 - errno = %d\n", errno);
21659 +}
21660 +
21661 +void arch_init_thread(void)
21662 +{
21663 +       disable_lcall();
21664 +}
21665 +
21666  void arch_check_bugs(void)
21667  {
21668         int have_it;
21669 @@ -113,8 +133,8 @@ void arch_check_bugs(void)
21670                        "checks\n");
21671                 return;
21672         }
21673 -       if(check_cpu_feature("cmov", &have_it)) cpu_has_cmov = have_it;
21674 -       if(check_cpu_feature("xmm", &have_it)) cpu_has_xmm = have_it;
21675 +       if(check_cpu_feature("cmov", &have_it)) host_has_cmov = have_it;
21676 +       if(check_cpu_feature("xmm", &have_it)) host_has_xmm = have_it;
21677  }
21678  
21679  int arch_handle_signal(int sig, union uml_pt_regs *regs)
21680 @@ -130,18 +150,18 @@ int arch_handle_signal(int sig, union um
21681         if((*((char *) ip) != 0x0f) || ((*((char *) (ip + 1)) & 0xf0) != 0x40))
21682                 return(0);
21683  
21684 -       if(cpu_has_cmov == 0)
21685 +       if(host_has_cmov == 0)
21686                 panic("SIGILL caused by cmov, which this processor doesn't "
21687                       "implement, boot a filesystem compiled for older "
21688                       "processors");
21689 -       else if(cpu_has_cmov == 1)
21690 +       else if(host_has_cmov == 1)
21691                 panic("SIGILL caused by cmov, which this processor claims to "
21692                       "implement");
21693 -       else if(cpu_has_cmov == -1)
21694 +       else if(host_has_cmov == -1)
21695                 panic("SIGILL caused by cmov, couldn't tell if this processor "
21696                       "implements it, boot a filesystem compiled for older "
21697                       "processors");
21698 -       else panic("Bad value for cpu_has_cmov (%d)", cpu_has_cmov);
21699 +       else panic("Bad value for host_has_cmov (%d)", host_has_cmov);
21700         return(0);
21701  }
21702  
21703 --- linux-2.6.0-test6/arch/um/sys-i386/Makefile 2003-06-14 12:17:59.000000000 -0700
21704 +++ 25/arch/um/sys-i386/Makefile        2003-10-05 00:34:32.000000000 -0700
21705 @@ -1,7 +1,8 @@
21706 -obj-y = bugs.o checksum.o extable.o fault.o ksyms.o ldt.o module.o \
21707 -       ptrace.o ptrace_user.o semaphore.o sigcontext.o syscalls.o sysrq.o
21708 +obj-y = bugs.o checksum.o extable.o fault.o ksyms.o ldt.o ptrace.o \
21709 +       ptrace_user.o semaphore.o sigcontext.o syscalls.o sysrq.o
21710  
21711  obj-$(CONFIG_HIGHMEM) += highmem.o
21712 +obj-$(CONFIG_MODULES) += module.o
21713  
21714  USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o
21715  USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
21716 @@ -9,6 +10,8 @@ USER_OBJS := $(foreach file,$(USER_OBJS)
21717  SYMLINKS = semaphore.c highmem.c module.c
21718  SYMLINKS := $(foreach f,$(SYMLINKS),$(src)/$f)
21719  
21720 +clean-files := $(SYMLINKS)
21721 +
21722  semaphore.c-dir = kernel
21723  highmem.c-dir = mm
21724  module.c-dir = kernel
21725 @@ -24,8 +27,7 @@ $(USER_OBJS) : %.o: %.c
21726  $(SYMLINKS): 
21727         $(call make_link,$@)
21728  
21729 -clean:
21730 -       $(MAKE) -C util clean
21731 +subdir- := util
21732  
21733  fastdep:
21734  
21735 --- linux-2.6.0-test6/arch/um/uml.lds.S 2003-06-14 12:18:09.000000000 -0700
21736 +++ 25/arch/um/uml.lds.S        2003-10-05 00:34:32.000000000 -0700
21737 @@ -26,7 +26,11 @@ SECTIONS
21738    . = ALIGN(4096);             /* Init code and data */
21739    _stext = .;
21740    __init_begin = .;
21741 -  .text.init : { *(.text.init) }
21742 +  .init.text : { 
21743 +       _sinittext = .;
21744 +       *(.init.text)
21745 +       _einittext = .;
21746 +  }
21747    . = ALIGN(4096);
21748    .text      :
21749    {
21750 @@ -38,7 +42,7 @@ SECTIONS
21751  
21752    #include "asm/common.lds.S"
21753  
21754 -  .data.init : { *(.data.init) }
21755 +  init.data : { *(init.data) }
21756    .data    :
21757    {
21758      . = ALIGN(KERNEL_STACK_SIZE);              /* init_task */
21759 --- linux-2.6.0-test6/arch/um/util/mk_constants_kern.c  2003-06-14 12:17:57.000000000 -0700
21760 +++ 25/arch/um/util/mk_constants_kern.c 2003-10-05 00:34:32.000000000 -0700
21761 @@ -1,5 +1,6 @@
21762  #include "linux/kernel.h"
21763  #include "linux/stringify.h"
21764 +#include "linux/time.h"
21765  #include "asm/page.h"
21766  
21767  extern void print_head(void);
21768 @@ -11,6 +12,7 @@ int main(int argc, char **argv)
21769  {
21770    print_head();
21771    print_constant_int("UM_KERN_PAGE_SIZE", PAGE_SIZE);
21772 +
21773    print_constant_str("UM_KERN_EMERG", KERN_EMERG);
21774    print_constant_str("UM_KERN_ALERT", KERN_ALERT);
21775    print_constant_str("UM_KERN_CRIT", KERN_CRIT);
21776 @@ -19,6 +21,8 @@ int main(int argc, char **argv)
21777    print_constant_str("UM_KERN_NOTICE", KERN_NOTICE);
21778    print_constant_str("UM_KERN_INFO", KERN_INFO);
21779    print_constant_str("UM_KERN_DEBUG", KERN_DEBUG);
21780 +
21781 +  print_constant_int("UM_NSEC_PER_SEC", NSEC_PER_SEC);
21782    print_tail();
21783    return(0);
21784  }
21785 --- linux-2.6.0-test6/arch/x86_64/boot/compressed/head.S        2003-06-26 22:07:24.000000000 -0700
21786 +++ 25/arch/x86_64/boot/compressed/head.S       2003-10-05 00:33:43.000000000 -0700
21787 @@ -26,6 +26,7 @@
21788  .code32
21789  .text
21790  
21791 +#define IN_BOOTLOADER
21792  #include <linux/linkage.h>
21793  #include <asm/segment.h>
21794  
21795 --- linux-2.6.0-test6/arch/x86_64/boot/compressed/misc.c        2003-09-27 18:57:44.000000000 -0700
21796 +++ 25/arch/x86_64/boot/compressed/misc.c       2003-10-05 00:33:43.000000000 -0700
21797 @@ -9,6 +9,7 @@
21798   * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
21799   */
21800  
21801 +#define IN_BOOTLOADER
21802  #include "miscsetup.h"
21803  #include <asm/io.h>
21804  
21805 --- linux-2.6.0-test6/arch/x86_64/ia32/ia32_binfmt.c    2003-08-22 19:23:40.000000000 -0700
21806 +++ 25/arch/x86_64/ia32/ia32_binfmt.c   2003-10-05 00:33:23.000000000 -0700
21807 @@ -82,9 +82,12 @@ do {                                                                       \
21808         int i;                                                                \
21809         Elf32_Off ofs = 0;                                                    \
21810         for (i = 0; i < VSYSCALL32_EHDR->e_phnum; ++i) {                      \
21811 -               struct elf_phdr phdr = vsyscall_phdrs[i];                     \
21812 +               struct elf32_phdr phdr = vsyscall_phdrs[i];                   \
21813                 if (phdr.p_type == PT_LOAD) {                                 \
21814 +                       BUG_ON(ofs != 0);                                     \
21815                         ofs = phdr.p_offset = offset;                         \
21816 +                       phdr.p_memsz = PAGE_ALIGN(phdr.p_memsz);              \
21817 +                       phdr.p_filesz = phdr.p_memsz;                         \
21818                         offset += phdr.p_filesz;                              \
21819                 }                                                             \
21820                 else                                                          \
21821 @@ -99,10 +102,10 @@ do {                                                                             \
21822                 (const struct elf32_phdr *) (VSYSCALL32_BASE                  \
21823                                            + VSYSCALL32_EHDR->e_phoff);       \
21824         int i;                                                                \
21825 -       for (i = 0; i < VSYSCALL32_EHDR->e_phnum; ++i) {                      \
21826 +       for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) {                        \
21827                 if (vsyscall_phdrs[i].p_type == PT_LOAD)                      \
21828                         DUMP_WRITE((void *) (u64) vsyscall_phdrs[i].p_vaddr,          \
21829 -                                  vsyscall_phdrs[i].p_filesz);               \
21830 +                                  PAGE_ALIGN(vsyscall_phdrs[i].p_memsz));    \
21831         }                                                                     \
21832  } while (0)
21833  
21834 --- linux-2.6.0-test6/arch/x86_64/ia32/ia32_ioctl.c     2003-09-27 18:57:44.000000000 -0700
21835 +++ 25/arch/x86_64/ia32/ia32_ioctl.c    2003-10-05 00:34:44.000000000 -0700
21836 @@ -38,87 +38,6 @@ static int tiocgdev(unsigned fd, unsigne
21837         return put_user(new_encode_dev(tty_devnum(real_tty)), ptr); 
21838  } 
21839  
21840 -
21841 -struct raw32_config_request 
21842 -{
21843 -       compat_int_t    raw_minor;
21844 -       __u64   block_major;
21845 -       __u64   block_minor;
21846 -} __attribute__((packed));
21847 -
21848 -static int raw_ioctl(unsigned fd, unsigned cmd,  void *ptr) 
21849 -{ 
21850 -       int ret;
21851 -       switch (cmd) { 
21852 -       case RAW_SETBIND:
21853 -       case RAW_GETBIND: {
21854 -               struct raw_config_request req; 
21855 -               struct raw32_config_request *user_req = ptr;
21856 -               mm_segment_t oldfs = get_fs(); 
21857 -
21858 -               if (get_user(req.raw_minor, &user_req->raw_minor) ||
21859 -                   get_user(req.block_major, &user_req->block_major) ||
21860 -                   get_user(req.block_minor, &user_req->block_minor))
21861 -                       return -EFAULT;
21862 -               set_fs(KERNEL_DS); 
21863 -               ret = sys_ioctl(fd,cmd,(unsigned long)&req); 
21864 -               set_fs(oldfs); 
21865 -               break;
21866 -       }
21867 -       default:
21868 -               ret = sys_ioctl(fd,cmd,(unsigned long)ptr);
21869 -               break;
21870 -       } 
21871 -       return ret;             
21872 -} 
21873 -
21874 -
21875 -#define REISERFS_IOC_UNPACK32               _IOW(0xCD,1,int)
21876 -
21877 -static int reiserfs_ioctl32(unsigned fd, unsigned cmd, unsigned long ptr) 
21878 -{ 
21879 -       if (cmd == REISERFS_IOC_UNPACK32) 
21880 -               cmd = REISERFS_IOC_UNPACK; 
21881 -       return sys_ioctl(fd,cmd,ptr); 
21882 -} 
21883 -
21884 -struct dirent32 {
21885 -       compat_int_t    d_ino;
21886 -       compat_off_t    d_off;
21887 -       unsigned short  d_reclen;
21888 -       char            d_name[256]; /* We must not include limits.h! */
21889 -};
21890 -
21891 -#define        VFAT_IOCTL_READDIR_BOTH32       _IOR('r', 1, struct dirent32 [2])
21892 -#define        VFAT_IOCTL_READDIR_SHORT32      _IOR('r', 2, struct dirent32 [2])
21893 -
21894 -static int put_dirent32(struct dirent *src, struct dirent32 *dst)
21895 -{
21896 -       int ret; 
21897 -       ret = put_user(src->d_ino, &dst->d_ino); 
21898 -       ret |= __put_user(src->d_off, &dst->d_off); 
21899 -       ret |= __put_user(src->d_reclen, &dst->d_reclen); 
21900 -       if (__copy_to_user(&dst->d_name, src->d_name, src->d_reclen))
21901 -               ret |= -EFAULT;
21902 -       return ret;
21903 -} 
21904 -
21905 -static int vfat_ioctl32(unsigned fd, unsigned cmd,  void *ptr) 
21906 -{
21907 -       int ret;
21908 -       mm_segment_t oldfs = get_fs();
21909 -       struct dirent d[2]; 
21910 -
21911 -       set_fs(KERNEL_DS);
21912 -       ret = sys_ioctl(fd,cmd,(unsigned long)&d); 
21913 -       set_fs(oldfs); 
21914 -       if (!ret) { 
21915 -               ret |= put_dirent32(&d[0], (struct dirent32 *)ptr); 
21916 -               ret |= put_dirent32(&d[1], ((struct dirent32 *)ptr) + 1); 
21917 -       }
21918 -       return ret; 
21919 -} 
21920 -
21921  #define RTC_IRQP_READ32        _IOR('p', 0x0b, unsigned int)    /* Read IRQ rate   */
21922  #define RTC_IRQP_SET32 _IOW('p', 0x0c, unsigned int)    /* Set IRQ rate    */
21923  #define RTC_EPOCH_READ32       _IOR('p', 0x0d, unsigned)        /* Read epoch      */
21924 @@ -158,436 +77,6 @@ static int rtc32_ioctl(unsigned fd, unsi
21925         return sys_ioctl(fd,cmd,arg); 
21926  } 
21927  
21928 -struct serial_struct32 {
21929 -       compat_int_t    type;
21930 -       compat_int_t    line;
21931 -       compat_uint_t   port;
21932 -       compat_int_t    irq;
21933 -       compat_int_t    flags;
21934 -       compat_int_t    xmit_fifo_size;
21935 -       compat_int_t    custom_divisor;
21936 -       compat_int_t    baud_base;
21937 -       unsigned short  close_delay;
21938 -       char    io_type;
21939 -       char    reserved_char[1];
21940 -       compat_int_t    hub6;
21941 -       unsigned short  closing_wait; /* time to wait before closing */
21942 -       unsigned short  closing_wait2; /* no longer used... */
21943 -       compat_uint_t   iomem_base;
21944 -       unsigned short  iomem_reg_shift;
21945 -       unsigned int    port_high;
21946 -       compat_int_t    reserved[1];
21947 -};
21948 -
21949 -static int serial_struct_ioctl(unsigned fd, unsigned cmd,  void *ptr) 
21950 -{
21951 -       typedef struct serial_struct SS;
21952 -       struct serial_struct32 *ss32 = ptr; 
21953 -       int err;
21954 -       struct serial_struct ss; 
21955 -       mm_segment_t oldseg = get_fs(); 
21956 -       if (cmd == TIOCSSERIAL) { 
21957 -               if (copy_from_user(&ss, ss32, sizeof(struct serial_struct32)))
21958 -                       return -EFAULT;
21959 -               memmove(&ss.iomem_reg_shift, ((char*)&ss.iomem_base)+4, 
21960 -                       sizeof(SS)-offsetof(SS,iomem_reg_shift)); 
21961 -               ss.iomem_base = (void *)((unsigned long)ss.iomem_base & 0xffffffff);
21962 -       }
21963 -       set_fs(KERNEL_DS);
21964 -               err = sys_ioctl(fd,cmd,(unsigned long)(&ss)); 
21965 -       set_fs(oldseg);
21966 -       if (cmd == TIOCGSERIAL && err >= 0) { 
21967 -               if (__copy_to_user(ss32,&ss,offsetof(SS,iomem_base)) ||
21968 -                   __put_user((unsigned long)ss.iomem_base  >> 32 ? 
21969 -                              0xffffffff : (unsigned)(unsigned long)ss.iomem_base,
21970 -                              &ss32->iomem_base) ||
21971 -                   __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
21972 -                   __put_user(ss.port_high, &ss32->port_high))
21973 -                       return -EFAULT;
21974 -       } 
21975 -       return err;     
21976 -}
21977 -
21978 -
21979 -
21980 -struct usbdevfs_ctrltransfer32 {
21981 -       u8 bRequestType;
21982 -       u8 bRequest;
21983 -       u16 wValue;
21984 -       u16 wIndex;
21985 -       u16 wLength;
21986 -       u32 timeout;  /* in milliseconds */
21987 -       compat_caddr_t data;
21988 -};
21989 -
21990 -#define USBDEVFS_CONTROL32           _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
21991 -
21992 -static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
21993 -{
21994 -       struct usbdevfs_ctrltransfer kctrl;
21995 -       struct usbdevfs_ctrltransfer32 *uctrl;
21996 -       mm_segment_t old_fs;
21997 -       __u32 udata;
21998 -       void *uptr, *kptr;
21999 -       int err;
22000 -
22001 -       uctrl = (struct usbdevfs_ctrltransfer32 *) arg;
22002 -
22003 -       if (copy_from_user(&kctrl, uctrl,
22004 -                          (sizeof(struct usbdevfs_ctrltransfer) -
22005 -                           sizeof(void *))))
22006 -               return -EFAULT;
22007 -
22008 -       if (get_user(udata, &uctrl->data))
22009 -               return -EFAULT;
22010 -       uptr = compat_ptr(udata);
22011 -
22012 -       /* In usbdevice_fs, it limits the control buffer to a page,
22013 -        * for simplicity so do we.
22014 -        */
22015 -       if (!uptr || kctrl.wLength > PAGE_SIZE)
22016 -               return -EINVAL;
22017 -
22018 -       kptr = (void *)__get_free_page(GFP_KERNEL);
22019 -
22020 -       if ((kctrl.bRequestType & 0x80) == 0) {
22021 -               err = -EFAULT;
22022 -               if (copy_from_user(kptr, uptr, kctrl.wLength))
22023 -                       goto out;
22024 -       }
22025 -
22026 -       kctrl.data = kptr;
22027 -
22028 -       old_fs = get_fs();
22029 -       set_fs(KERNEL_DS);
22030 -       err = sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)&kctrl);
22031 -       set_fs(old_fs);
22032 -
22033 -       if (err >= 0 &&
22034 -           ((kctrl.bRequestType & 0x80) != 0)) {
22035 -               if (copy_to_user(uptr, kptr, kctrl.wLength))
22036 -                       err = -EFAULT;
22037 -       }
22038 -
22039 -out:
22040 -       free_page((unsigned long) kptr);
22041 -       return err;
22042 -}
22043 -
22044 -struct usbdevfs_bulktransfer32 {
22045 -       compat_uint_t ep;
22046 -       compat_uint_t len;
22047 -       compat_uint_t timeout; /* in milliseconds */
22048 -       compat_caddr_t data;
22049 -};
22050 -
22051 -#define USBDEVFS_BULK32              _IOWR('U', 2, struct usbdevfs_bulktransfer32)
22052 -
22053 -static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
22054 -{
22055 -       struct usbdevfs_bulktransfer kbulk;
22056 -       struct usbdevfs_bulktransfer32 *ubulk;
22057 -       mm_segment_t old_fs;
22058 -       __u32 udata;
22059 -       void *uptr, *kptr;
22060 -       int err;
22061 -
22062 -       ubulk = (struct usbdevfs_bulktransfer32 *) arg;
22063 -
22064 -       if (get_user(kbulk.ep, &ubulk->ep) ||
22065 -           get_user(kbulk.len, &ubulk->len) ||
22066 -           get_user(kbulk.timeout, &ubulk->timeout) ||
22067 -           get_user(udata, &ubulk->data))
22068 -               return -EFAULT;
22069 -
22070 -       uptr = compat_ptr(udata);
22071 -
22072 -       /* In usbdevice_fs, it limits the control buffer to a page,
22073 -        * for simplicity so do we.
22074 -        */
22075 -       if (!uptr || kbulk.len > PAGE_SIZE)
22076 -               return -EINVAL;
22077 -
22078 -       kptr = (void *) __get_free_page(GFP_KERNEL);
22079 -
22080 -       if ((kbulk.ep & 0x80) == 0) {
22081 -               err = -EFAULT;
22082 -               if (copy_from_user(kptr, uptr, kbulk.len))
22083 -                       goto out;
22084 -       }
22085 -
22086 -       kbulk.data = kptr;
22087 -
22088 -       old_fs = get_fs();
22089 -       set_fs(KERNEL_DS);
22090 -       err = sys_ioctl(fd, USBDEVFS_BULK, (unsigned long) &kbulk);
22091 -       set_fs(old_fs);
22092 -
22093 -       if (err >= 0 &&
22094 -           ((kbulk.ep & 0x80) != 0)) {
22095 -               if (copy_to_user(uptr, kptr, kbulk.len))
22096 -                       err = -EFAULT;
22097 -       }
22098 -
22099 -out:
22100 -       free_page((unsigned long) kptr);
22101 -       return err;
22102 -}
22103 -
22104 -/* This needs more work before we can enable it.  Unfortunately
22105 - * because of the fancy asynchronous way URB status/error is written
22106 - * back to userspace, we'll need to fiddle with USB devio internals
22107 - * and/or reimplement entirely the frontend of it ourselves. -DaveM
22108 - *
22109 - * The issue is:
22110 - *
22111 - *     When an URB is submitted via usbdevicefs it is put onto an
22112 - *     asynchronous queue.  When the URB completes, it may be reaped
22113 - *     via another ioctl.  During this reaping the status is written
22114 - *     back to userspace along with the length of the transfer.
22115 - *
22116 - *     We must translate into 64-bit kernel types so we pass in a kernel
22117 - *     space copy of the usbdevfs_urb structure.  This would mean that we
22118 - *     must do something to deal with the async entry reaping.  First we
22119 - *     have to deal somehow with this transitory memory we've allocated.
22120 - *     This is problematic since there are many call sites from which the
22121 - *     async entries can be destroyed (and thus when we'd need to free up
22122 - *     this kernel memory).  One of which is the close() op of usbdevicefs.
22123 - *     To handle that we'd need to make our own file_operations struct which
22124 - *     overrides usbdevicefs's release op with our own which runs usbdevicefs's
22125 - *     real release op then frees up the kernel memory.
22126 - *
22127 - *     But how to keep track of these kernel buffers?  We'd need to either
22128 - *     keep track of them in some table _or_ know about usbdevicefs internals
22129 - *     (ie. the exact layout of its file private, which is actually defined
22130 - *     in linux/usbdevice_fs.h, the layout of the async queues are private to
22131 - *     devio.c)
22132 - *
22133 - * There is one possible other solution I considered, also involving knowledge
22134 - * of usbdevicefs internals:
22135 - *
22136 - *     After an URB is submitted, we "fix up" the address back to the user
22137 - *     space one.  This would work if the status/length fields written back
22138 - *     by the async URB completion lines up perfectly in the 32-bit type with
22139 - *     the 64-bit kernel type.  Unfortunately, it does not because the iso
22140 - *     frame descriptors, at the end of the struct, can be written back.
22141 - *
22142 - * I think we'll just need to simply duplicate the devio URB engine here.
22143 - */
22144 -#if 0
22145 -struct usbdevfs_urb32 {
22146 -       unsigned char type;
22147 -       unsigned char endpoint;
22148 -       compat_int_t status;
22149 -       compat_uint_t flags;
22150 -       compat_caddr_t buffer;
22151 -       compat_int_t buffer_length;
22152 -       compat_int_t actual_length;
22153 -       compat_int_t start_frame;
22154 -       compat_int_t number_of_packets;
22155 -       compat_int_t error_count;
22156 -       compat_uint_t signr;
22157 -       compat_caddr_t usercontext; /* unused */
22158 -       struct usbdevfs_iso_packet_desc iso_frame_desc[0];
22159 -};
22160 -
22161 -#define USBDEVFS_SUBMITURB32       _IOR('U', 10, struct usbdevfs_urb32)
22162 -
22163 -static int get_urb32(struct usbdevfs_urb *kurb,
22164 -                    struct usbdevfs_urb32 *uurb)
22165 -{
22166 -       if (get_user(kurb->type, &uurb->type) ||
22167 -           __get_user(kurb->endpoint, &uurb->endpoint) ||
22168 -           __get_user(kurb->status, &uurb->status) ||
22169 -           __get_user(kurb->flags, &uurb->flags) ||
22170 -           __get_user(kurb->buffer_length, &uurb->buffer_length) ||
22171 -           __get_user(kurb->actual_length, &uurb->actual_length) ||
22172 -           __get_user(kurb->start_frame, &uurb->start_frame) ||
22173 -           __get_user(kurb->number_of_packets, &uurb->number_of_packets) ||
22174 -           __get_user(kurb->error_count, &uurb->error_count) ||
22175 -           __get_user(kurb->signr, &uurb->signr))
22176 -               return -EFAULT;
22177 -
22178 -       kurb->usercontext = 0; /* unused currently */
22179 -
22180 -       return 0;
22181 -}
22182 -
22183 -/* Just put back the values which usbdevfs actually changes. */
22184 -static int put_urb32(struct usbdevfs_urb *kurb,
22185 -                    struct usbdevfs_urb32 *uurb)
22186 -{
22187 -       if (put_user(kurb->status, &uurb->status) ||
22188 -           __put_user(kurb->actual_length, &uurb->actual_length) ||
22189 -           __put_user(kurb->error_count, &uurb->error_count))
22190 -               return -EFAULT;
22191 -
22192 -       if (kurb->number_of_packets != 0) {
22193 -               int i;
22194 -
22195 -               for (i = 0; i < kurb->number_of_packets; i++) {
22196 -                       if (__put_user(kurb->iso_frame_desc[i].actual_length,
22197 -                                      &uurb->iso_frame_desc[i].actual_length) ||
22198 -                           __put_user(kurb->iso_frame_desc[i].status,
22199 -                                      &uurb->iso_frame_desc[i].status))
22200 -                               return -EFAULT;
22201 -               }
22202 -       }
22203 -
22204 -       return 0;
22205 -}
22206 -
22207 -static int get_urb32_isoframes(struct usbdevfs_urb *kurb,
22208 -                              struct usbdevfs_urb32 *uurb)
22209 -{
22210 -       unsigned int totlen;
22211 -       int i;
22212 -
22213 -       if (kurb->type != USBDEVFS_URB_TYPE_ISO) {
22214 -               kurb->number_of_packets = 0;
22215 -               return 0;
22216 -       }
22217 -
22218 -       if (kurb->number_of_packets < 1 ||
22219 -           kurb->number_of_packets > 128)
22220 -               return -EINVAL;
22221 -
22222 -       if (copy_from_user(&kurb->iso_frame_desc[0],
22223 -                          &uurb->iso_frame_desc[0],
22224 -                          sizeof(struct usbdevfs_iso_packet_desc) *
22225 -                          kurb->number_of_packets))
22226 -               return -EFAULT;
22227 -
22228 -       totlen = 0;
22229 -       for (i = 0; i < kurb->number_of_packets; i++) {
22230 -               unsigned int this_len;
22231 -
22232 -               this_len = kurb->iso_frame_desc[i].length;
22233 -               if (this_len > 1023)
22234 -                       return -EINVAL;
22235 -
22236 -               totlen += this_len;
22237 -       }
22238 -
22239 -       if (totlen > 32768)
22240 -               return -EINVAL;
22241 -
22242 -       kurb->buffer_length = totlen;
22243 -
22244 -       return 0;
22245 -}
22246 -
22247 -static int do_usbdevfs_urb(unsigned int fd, unsigned int cmd, unsigned long arg)
22248 -{
22249 -       struct usbdevfs_urb *kurb;
22250 -       struct usbdevfs_urb32 *uurb;
22251 -       mm_segment_t old_fs;
22252 -       __u32 udata;
22253 -       void *uptr, *kptr;
22254 -       unsigned int buflen;
22255 -       int err;
22256 -
22257 -       uurb = (struct usbdevfs_urb32 *) arg;
22258 -
22259 -       err = -ENOMEM;
22260 -       kurb = kmalloc(sizeof(struct usbdevfs_urb) +
22261 -                      (sizeof(struct usbdevfs_iso_packet_desc) * 128),
22262 -                      GFP_KERNEL);
22263 -       if (!kurb)
22264 -               goto out;
22265 -
22266 -       err = -EFAULT;
22267 -       if (get_urb32(kurb, uurb))
22268 -               goto out;
22269 -
22270 -       err = get_urb32_isoframes(kurb, uurb);
22271 -       if (err)
22272 -               goto out;
22273 -
22274 -       err = -EFAULT;
22275 -       if (__get_user(udata, &uurb->buffer))
22276 -               goto out;
22277 -       uptr = compat_ptr(udata);
22278 -
22279 -       buflen = kurb->buffer_length;
22280 -       err = verify_area(VERIFY_WRITE, uptr, buflen);
22281 -       if (err) 
22282 -               goto out;
22283 -
22284 -
22285 -       old_fs = get_fs();
22286 -       set_fs(KERNEL_DS);
22287 -       err = sys_ioctl(fd, USBDEVFS_SUBMITURB, (unsigned long) kurb);
22288 -       set_fs(old_fs);
22289 -
22290 -       if (err >= 0) {
22291 -               /* RED-PEN Shit, this doesn't work for async URBs :-( XXX */
22292 -               if (put_urb32(kurb, uurb)) {
22293 -                       err = -EFAULT;
22294 -               }
22295 -       }
22296 -
22297 -out:
22298 -       kfree(kurb);
22299 -       return err;
22300 -}
22301 -#endif
22302 -
22303 -#define USBDEVFS_REAPURB32         _IOW('U', 12, u32)
22304 -#define USBDEVFS_REAPURBNDELAY32   _IOW('U', 13, u32)
22305 -
22306 -static int do_usbdevfs_reapurb(unsigned int fd, unsigned int cmd, unsigned long arg)
22307 -{
22308 -       mm_segment_t old_fs;
22309 -       void *kptr;
22310 -       int err;
22311 -
22312 -       old_fs = get_fs();
22313 -       set_fs(KERNEL_DS);
22314 -       err = sys_ioctl(fd,
22315 -                       (cmd == USBDEVFS_REAPURB32 ?
22316 -                        USBDEVFS_REAPURB :
22317 -                        USBDEVFS_REAPURBNDELAY),
22318 -                       (unsigned long) &kptr);
22319 -       set_fs(old_fs);
22320 -
22321 -       if (err >= 0 &&
22322 -           put_user((u32)(u64)kptr, (u32 *)arg))
22323 -               err = -EFAULT;
22324 -
22325 -       return err;
22326 -}
22327 -
22328 -struct usbdevfs_disconnectsignal32 {
22329 -       compat_int_t signr;
22330 -       compat_caddr_t context;
22331 -};
22332 -
22333 -#define USBDEVFS_DISCSIGNAL32      _IOR('U', 14, struct usbdevfs_disconnectsignal32)
22334 -
22335 -static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
22336 -{
22337 -       struct usbdevfs_disconnectsignal kdis;
22338 -       struct usbdevfs_disconnectsignal32 *udis;
22339 -       mm_segment_t old_fs;
22340 -       u32 uctx;
22341 -       int err;
22342 -
22343 -       udis = (struct usbdevfs_disconnectsignal32 *) arg;
22344 -
22345 -       if (get_user(kdis.signr, &udis->signr) ||
22346 -           __get_user(uctx, &udis->context))
22347 -               return -EFAULT;
22348 -
22349 -       kdis.context = (void *) (long)uctx;
22350 -
22351 -       old_fs = get_fs();
22352 -       set_fs(KERNEL_DS);
22353 -       err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
22354 -       set_fs(old_fs);
22355 -
22356 -       return err;
22357 -}
22358  /* /proc/mtrr ioctls */
22359  
22360  
22361 @@ -726,27 +215,12 @@ COMPATIBLE_IOCTL(FIOQSIZE)
22362  
22363  /* And these ioctls need translation */
22364  HANDLE_IOCTL(TIOCGDEV, tiocgdev)
22365 -HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl)
22366 -HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl)
22367 -/* Raw devices */
22368 -HANDLE_IOCTL(RAW_SETBIND, raw_ioctl)
22369  /* realtime device */
22370  HANDLE_IOCTL(RTC_IRQP_READ,  rtc32_ioctl)
22371  HANDLE_IOCTL(RTC_IRQP_READ32,rtc32_ioctl)
22372  HANDLE_IOCTL(RTC_IRQP_SET32, rtc32_ioctl)
22373  HANDLE_IOCTL(RTC_EPOCH_READ32, rtc32_ioctl)
22374  HANDLE_IOCTL(RTC_EPOCH_SET32, rtc32_ioctl)
22375 -HANDLE_IOCTL(REISERFS_IOC_UNPACK32, reiserfs_ioctl32)
22376 -/* VFAT */
22377 -HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32)
22378 -HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32, vfat_ioctl32)
22379 -
22380 -HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
22381 -HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
22382 -/*HANDLE_IOCTL(USBDEVFS_SUBMITURB32, do_usbdevfs_urb)*/
22383 -HANDLE_IOCTL(USBDEVFS_REAPURB32, do_usbdevfs_reapurb)
22384 -HANDLE_IOCTL(USBDEVFS_REAPURBNDELAY32, do_usbdevfs_reapurb)
22385 -HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
22386  /* take care of sizeof(sizeof()) breakage */
22387  /* mtrr */
22388  HANDLE_IOCTL(MTRRIOC32_ADD_ENTRY, mtrr_ioctl32)
22389 --- linux-2.6.0-test6/arch/x86_64/kernel/i387.c 2003-06-14 12:18:05.000000000 -0700
22390 +++ 25/arch/x86_64/kernel/i387.c        2003-10-05 00:33:23.000000000 -0700
22391 @@ -138,12 +138,3 @@ int dump_task_fpu(struct task_struct *ts
22392  }
22393         return fpvalid;
22394  }
22395 -
22396 -#ifdef CONFIG_SMP
22397 -void dump_smp_unlazy_fpu(void)
22398 -{
22399 -       unlazy_fpu(current);
22400 -       return;
22401 -}
22402 -#endif
22403 -
22404 --- linux-2.6.0-test6/arch/x86_64/mm/ioremap.c  2003-06-14 12:18:34.000000000 -0700
22405 +++ 25/arch/x86_64/mm/ioremap.c 2003-10-05 00:33:23.000000000 -0700
22406 @@ -159,7 +159,7 @@ void * __ioremap(unsigned long phys_addr
22407         if (!area)
22408                 return NULL;
22409         addr = area->addr;
22410 -       if (remap_area_pages(VMALLOC_VMADDR(addr), phys_addr, size, flags)) {
22411 +       if (remap_area_pages((unsigned long) addr, phys_addr, size, flags)) {
22412                 vunmap(addr);
22413                 return NULL;
22414         }
22415 --- linux-2.6.0-test6/CREDITS   2003-09-27 18:57:43.000000000 -0700
22416 +++ 25/CREDITS  2003-10-05 00:33:23.000000000 -0700
22417 @@ -1459,6 +1459,13 @@ S: Ballinagard
22418  S: Roscommon
22419  S: Ireland
22420  
22421 +N: Michael Hunold
22422 +E: michael@mihu.de
22423 +W: http://www.mihu.de/linux/
22424 +D: Generic saa7146 video4linux-2 driver core,
22425 +D: Driver for the "Multimedia eXtension Board", "dpc7146",
22426 +D: "Hexium Orion", "Hexium Gemini"
22427 +
22428  N: Miguel de Icaza Amozurrutia
22429  E: miguel@nuclecu.unam.mx
22430  D: Linux/SPARC team, Midnight Commander maintainer
22431 --- linux-2.6.0-test6/Documentation/cachetlb.txt        2003-06-14 12:18:07.000000000 -0700
22432 +++ 25/Documentation/cachetlb.txt       2003-10-05 00:33:23.000000000 -0700
22433 @@ -59,9 +59,9 @@ changes occur:
22434         address translations from the TLB.  After running, this
22435         interface must make sure that any previous page table
22436         modifications for the address space 'vma->vm_mm' in the range
22437 -       'start' to 'end' will be visible to the cpu.  That is, after
22438 +       'start' to 'end-1' will be visible to the cpu.  That is, after
22439         running, here will be no entries in the TLB for 'mm' for
22440 -       virtual addresses in the range 'start' to 'end'.
22441 +       virtual addresses in the range 'start' to 'end-1'.
22442  
22443         The "vma" is the backing store being used for the region.
22444         Primarily, this is used for munmap() type operations.
22445 @@ -100,7 +100,7 @@ changes occur:
22446                            unsigned long start, unsigned long end)
22447  
22448     The software page tables for address space 'mm' for virtual
22449 -   addresses in the range 'start' to 'end' are being torn down.
22450 +   addresses in the range 'start' to 'end-1' are being torn down.
22451  
22452     Some platforms cache the lowest level of the software page tables
22453     in a linear virtually mapped array, to make TLB miss processing
22454 @@ -165,15 +165,7 @@ and have no dependency on translation in
22455  
22456  Here are the routines, one by one:
22457  
22458 -1) void flush_cache_all(void)
22459 -
22460 -       The most severe flush of all.  After this interface runs,
22461 -       the entire cpu cache is flushed.
22462 -
22463 -       This is usually invoked when the kernel page tables are
22464 -       changed, since such translations are "global" in nature.
22465 -
22466 -2) void flush_cache_mm(struct mm_struct *mm)
22467 +1) void flush_cache_mm(struct mm_struct *mm)
22468  
22469         This interface flushes an entire user address space from
22470         the caches.  That is, after running, there will be no cache
22471 @@ -183,13 +175,13 @@ Here are the routines, one by one:
22472         page table operations such as what happens during
22473         fork, exit, and exec.
22474  
22475 -3) void flush_cache_range(struct vm_area_struct *vma,
22476 +2) void flush_cache_range(struct vm_area_struct *vma,
22477                           unsigned long start, unsigned long end)
22478  
22479         Here we are flushing a specific range of (user) virtual
22480         addresses from the cache.  After running, there will be no
22481         entries in the cache for 'vma->vm_mm' for virtual addresses in
22482 -       the range 'start' to 'end'.
22483 +       the range 'start' to 'end-1'.
22484  
22485         The "vma" is the backing store being used for the region.
22486         Primarily, this is used for munmap() type operations.
22487 @@ -200,7 +192,7 @@ Here are the routines, one by one:
22488         call flush_cache_page (see below) for each entry which may be
22489         modified.
22490  
22491 -4) void flush_cache_page(struct vm_area_struct *vma, unsigned long addr)
22492 +3) void flush_cache_page(struct vm_area_struct *vma, unsigned long addr)
22493  
22494         This time we need to remove a PAGE_SIZE sized range
22495         from the cache.  The 'vma' is the backing structure used by
22496 @@ -215,6 +207,30 @@ Here are the routines, one by one:
22497  
22498         This is used primarily during fault processing.
22499  
22500 +4) void flush_cache_kmaps(void)
22501 +
22502 +       This routine need only be implemented if the platform utilizes
22503 +       highmem.  It will be called right before all of the kmaps
22504 +       are invalidated.
22505 +
22506 +       After running, there will be no entries in the cache for
22507 +       the kernel virtual address range PKMAP_ADDR(0) to
22508 +       PKMAP_ADDR(LAST_PKMAP).
22509 +
22510 +       This routing should be implemented in asm/highmem.h
22511 +
22512 +5) void flush_cache_vmap(unsigned long start, unsigned long end)
22513 +   void flush_cache_vunmap(unsigned long start, unsigned long end)
22514 +
22515 +       Here in these two interfaces we are flushing a specific range
22516 +       of (kernel) virtual addresses from the cache.  After running,
22517 +       there will be no entries in the cache for the kernel address
22518 +       space for virtual addresses in the range 'start' to 'end-1'.
22519 +
22520 +       The first of these two routines is invoked after map_vm_area()
22521 +       has installed the page table entries.  The second is invoked
22522 +       before unmap_vm_area() deletes the page table entries.
22523 +
22524  There exists another whole class of cpu cache issues which currently
22525  require a whole different set of interfaces to handle properly.
22526  The biggest problem is that of virtual aliasing in the data cache
22527 @@ -317,6 +333,26 @@ maps this page at its virtual address.
22528                         dirty.  Again, see sparc64 for examples of how
22529                         to deal with this.
22530  
22531 +  void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
22532 +                         unsigned long user_vaddr,
22533 +                         void *dst, void *src, int len)
22534 +  void copy_from_user_page(struct vm_area_struct *vma, struct page *page,
22535 +                           unsigned long user_vaddr,
22536 +                           void *dst, void *src, int len)
22537 +       When the kernel needs to copy arbitrary data in and out
22538 +       of arbitrary user pages (f.e. for ptrace()) it will use
22539 +       these two routines.
22540 +
22541 +       The page has been kmap()'d, and flush_cache_page() has
22542 +       just been called for the user mapping of this page (if
22543 +       necessary).
22544 +
22545 +       Any necessary cache flushing or other coherency operations
22546 +       that need to occur should happen here.  If the processor's
22547 +       instruction cache does not snoop cpu stores, it is very
22548 +       likely that you will need to flush the instruction cache
22549 +       for copy_to_user_page().
22550 +
22551    void flush_icache_range(unsigned long start, unsigned long end)
22552         When the kernel stores into addresses that it will execute
22553         out of (eg when loading modules), this function is called.
22554 @@ -324,17 +360,6 @@ maps this page at its virtual address.
22555         If the icache does not snoop stores then this routine will need
22556         to flush it.
22557  
22558 -  void flush_icache_user_range(struct vm_area_struct *vma,
22559 -                       struct page *page, unsigned long addr, int len)
22560 -       This is called when the kernel stores into addresses that are
22561 -       part of the address space of a user process (which may be some
22562 -       other process than the current process).  The addr argument
22563 -       gives the virtual address in that process's address space,
22564 -       page is the page which is being modified, and len indicates
22565 -       how many bytes have been modified.  The modified region must
22566 -       not cross a page boundary.  Currently this is only called from
22567 -       kernel/ptrace.c.
22568 -
22569    void flush_icache_page(struct vm_area_struct *vma, struct page *page)
22570         All the functionality of flush_icache_page can be implemented in
22571         flush_dcache_page and update_mmu_cache. In 2.7 the hope is to
22572 --- linux-2.6.0-test6/Documentation/cpu-freq/user-guide.txt     2003-08-08 22:55:10.000000000 -0700
22573 +++ 25/Documentation/cpu-freq/user-guide.txt    2003-10-05 00:33:23.000000000 -0700
22574 @@ -57,6 +57,8 @@ AMD mobile K6-2+
22575  AMD mobile K6-3+
22576  AMD mobile Duron
22577  AMD mobile Athlon
22578 +AMD Opteron
22579 +AMD Athlon 64
22580  Cyrix Media GXm
22581  Intel mobile PIII and Intel mobile PIII-M on certain chipsets
22582  Intel Pentium 4, Intel Xeon
22583 --- linux-2.6.0-test6/Documentation/crypto/api-intro.txt        2003-08-22 19:23:39.000000000 -0700
22584 +++ 25/Documentation/crypto/api-intro.txt       2003-10-05 00:33:23.000000000 -0700
22585 @@ -126,7 +126,7 @@ might already be working on.
22586  BUGS
22587  
22588  Send bug reports to:
22589 -James Morris <jmorris@intercode.com.au>
22590 +James Morris <jmorris@redhat.com>
22591  Cc: David S. Miller <davem@redhat.com>
22592  
22593  
22594 @@ -220,5 +220,5 @@ CAST5 algorithm contributors:
22595  Generic scatterwalk code by Adam J. Richter <adam@yggdrasil.com>
22596  
22597  Please send any credits updates or corrections to:
22598 -James Morris <jmorris@intercode.com.au>
22599 +James Morris <jmorris@redhat.com>
22600  
22601 --- linux-2.6.0-test6/Documentation/DocBook/kernel-api.tmpl     2003-09-27 18:57:43.000000000 -0700
22602 +++ 25/Documentation/DocBook/kernel-api.tmpl    2003-10-05 00:33:23.000000000 -0700
22603 @@ -318,6 +318,5 @@ X!Idrivers/video/console/fonts.c
22604  <!-- Needs ksyms to list additional exported symbols, but no specific doc.
22605       docproc do not care about sgml commants.
22606  !Dkernel/ksyms.c
22607 -!Dnet/netsyms.c
22608  -->
22609  </book>
22610 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
22611 +++ 25/Documentation/fb/neofb.txt       2003-10-05 00:34:22.000000000 -0700
22612 @@ -0,0 +1,27 @@
22613 +the neofb framebuffer driver supports the following Neomagic chipsets:
22614 +
22615 +NM2070 MagicGraph 128
22616 +NM2090 MagicGraph 128V
22617 +NM2093 MagicGraph 128ZV
22618 +NM2097 MagicGraph 128ZV+
22619 +NM2160 MagicGraph 128XD
22620 +NM2200 MagicGraph 256AV
22621 +NM2230 MagicGraph 256AV+
22622 +NM2360 MagicGraph 256ZX
22623 +NM2380 MagicGraph 256XL+
22624 +
22625 +with the following options:
22626 +
22627 +disabled       Disable this driver's initialization.
22628 +internal       Enable output on internal LCD Display.
22629 +external       Enable output on external CRT.
22630 +nostretch      Disable stretching of modes smaller than LCD.
22631 +nopciburst     Disable PCI burst mode.
22632 +libretto       Force Libretto 100/110 800x480 LCD.
22633 +picturebook    Force Picturebook 1024x480 LCD.
22634 +
22635 +at the boot prompt:
22636 +       video=neofb:picturebook
22637 +
22638 +as a module:
22639 +       modprobe neofb picturebook=1
22640 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
22641 +++ 25/Documentation/i386/kgdb/andthen  2003-10-05 00:33:38.000000000 -0700
22642 @@ -0,0 +1,100 @@
22643 +
22644 +define set_andthen
22645 +       set var $thp=0
22646 +       set var $thp=(struct kgdb_and_then_struct *)&kgdb_data[0]
22647 +       set var $at_size = (sizeof kgdb_data)/(sizeof *$thp)
22648 +       set var $at_oc=kgdb_and_then_count
22649 +       set var $at_cc=$at_oc
22650 +end
22651 +
22652 +define andthen_next
22653 +       set var $at_cc=$arg0
22654 +end
22655 +
22656 +define andthen
22657 +       andthen_set_edge
22658 +       if ($at_cc >= $at_oc)
22659 +               printf "Outside window.  Window size is %d\n",($at_oc-$at_low)
22660 +       else
22661 +               printf "%d: ",$at_cc
22662 +               output *($thp+($at_cc++ % $at_size ))
22663 +               printf "\n"
22664 +       end
22665 +end
22666 +define andthen_set_edge
22667 +       set var $at_oc=kgdb_and_then_count
22668 +       set var $at_low = $at_oc - $at_size
22669 +       if ($at_low < 0 )
22670 +               set var $at_low = 0
22671 +       end
22672 +       if (( $at_cc > $at_oc) || ($at_cc < $at_low))
22673 +               printf "Count outside of window, setting count to "
22674 +               if ($at_cc >= $at_oc)
22675 +                       set var $at_cc = $at_oc
22676 +               else
22677 +                       set var $at_cc = $at_low
22678 +               end
22679 +               printf "%d\n",$at_cc
22680 +       end
22681 +end
22682 +
22683 +define beforethat
22684 +       andthen_set_edge
22685 +       if ($at_cc <= $at_low)
22686 +               printf "Outside window.  Window size is %d\n",($at_oc-$at_low)
22687 +       else
22688 +               printf "%d: ",$at_cc-1
22689 +               output *($thp+(--$at_cc % $at_size ))
22690 +               printf "\n"
22691 +       end
22692 +end
22693 +
22694 +document andthen_next
22695 +       andthen_next <count>
22696 +       .       sets the number of the event to display next. If this event
22697 +       .       is not in the event pool, either andthen or beforethat will
22698 +       .       correct it to the nearest event pool edge.  The event pool
22699 +       .       ends at the last event recorded and begins <number of events>
22700 +       .       prior to that.  If beforethat is used next, it will display
22701 +       .       event <count> -1.
22702 +.
22703 +       andthen commands are: set_andthen, andthen_next, andthen and beforethat
22704 +end
22705 +
22706 +
22707 +document andthen
22708 +       andthen
22709 +.      displays the next event in the list.  <set_andthen> sets up to display
22710 +.      the oldest saved event first.
22711 +.      <count> (optional) count of the event to display.
22712 +.      note the number of events saved is specified at configure time.
22713 +.      if events are saved between calls to andthen the index will change
22714 +.      but the displayed event will be the next one (unless the event buffer
22715 +.      is overrun).
22716 +.
22717 +.      andthen commands are: set_andthen, andthen_next, andthen and beforethat
22718 +end
22719 +
22720 +document set_andthen
22721 +       set_andthen
22722 +.      sets up to use the <andthen> and <beforethat> commands.
22723 +.              if you have defined your own struct, use the above and
22724 +.              then enter the following:
22725 +.              p $thp=(struct kgdb_and_then_structX *)&kgdb_data[0]
22726 +.              where <kgdb_and_then_structX> is the name of your structure.
22727 +.
22728 +.      andthen commands are: set_andthen, andthen_next, andthen and beforethat
22729 +end
22730 +
22731 +document beforethat
22732 +       beforethat
22733 +.      displays the next prior event in the list. <set_andthen> sets up to
22734 +.      display the last occuring event first.
22735 +.
22736 +.      note the number of events saved is specified at configure time.
22737 +.      if events are saved between calls to beforethat the index will change
22738 +.      but the displayed event will be the next one (unless the event buffer
22739 +.      is overrun).
22740 +.
22741 +.      andthen commands are: set_andthen, andthen_next, andthen and beforethat
22742 +end
22743 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
22744 +++ 25/Documentation/i386/kgdb/debug-nmi.txt    2003-10-05 00:33:38.000000000 -0700
22745 @@ -0,0 +1,37 @@
22746 +Subject: Debugging with NMI
22747 +Date: Mon, 12 Jul 1999 11:28:31 -0500
22748 +From: David Grothe <dave@gcom.com>
22749 +Organization: Gcom, Inc
22750 +To: David Grothe <dave@gcom.com>
22751 +
22752 +Kernel hackers:
22753 +
22754 +Maybe this is old hat, but it is new to me --
22755 +
22756 +On an ISA bus machine, if you short out the A1 and B1 pins of an ISA
22757 +slot you will generate an NMI to the CPU.  This interrupts even a
22758 +machine that is hung in a loop with interrupts disabled.  Used in
22759 +conjunction with kgdb <
22760 +ftp://ftp.gcom.com/pub/linux/src/kgdb-2.3.35/kgdb-2.3.35.tgz > you can
22761 +gain debugger control of a machine that is hung in the kernel!  Even
22762 +without kgdb the kernel will print a stack trace so you can find out
22763 +where it was hung.
22764 +
22765 +The A1/B1 pins are directly opposite one another and the farthest pins
22766 +towards the bracket end of the ISA bus socket.  You can stick a paper
22767 +clip or multi-meter probe between them to short them out.
22768 +
22769 +I had a spare ISA bus to PC104 bus adapter around.  The PC104 end of the
22770 +board consists of two rows of wire wrap pins.  So I wired a push button
22771 +between the A1/B1 pins and now have an ISA board that I can stick into
22772 +any ISA bus slot for debugger entry.
22773 +
22774 +Microsoft has a circuit diagram of a PCI card at
22775 +http://www.microsoft.com/hwdev/DEBUGGING/DMPSW.HTM.  If you want to
22776 +build one you will have to mail them and ask for the PAL equations.
22777 +Nobody makes one comercially.
22778 +
22779 +[THIS TIP COMES WITH NO WARRANTY WHATSOEVER.  It works for me, but if
22780 +your machine catches fire, it is your problem, not mine.]
22781 +
22782 +-- Dave (the kgdb guy)
22783 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
22784 +++ 25/Documentation/i386/kgdb/gdb-globals.txt  2003-10-05 00:33:38.000000000 -0700
22785 @@ -0,0 +1,71 @@
22786 +Sender: akale@veritas.com
22787 +Date: Fri, 23 Jun 2000 19:26:35 +0530
22788 +From: "Amit S. Kale" <akale@veritas.com>
22789 +Organization: Veritas Software (India)
22790 +To: Dave Grothe <dave@gcom.com>, linux-kernel@vger.rutgers.edu
22791 +CC: David Milburn <dmilburn@wirespeed.com>,
22792 +        "Edouard G. Parmelan" <Edouard.Parmelan@quadratec.fr>,
22793 +        ezannoni@cygnus.com, Keith Owens <kaos@ocs.com.au>
22794 +Subject: Re: Module debugging using kgdb
22795 +
22796 +Dave Grothe wrote:
22797 +>
22798 +> Amit:
22799 +>
22800 +> There is a 2.4.0 version of kgdb on our ftp site:
22801 +> ftp://ftp.gcom.com/pub/linux/src/kgdb.  I mirrored your version of gdb
22802 +> and loadmodule.sh there.
22803 +>
22804 +> Have a look at the README file and see if I go it right.  If not, send
22805 +> me some corrections and I will update it.
22806 +>
22807 +> Does your version of gdb solve the global variable problem?
22808 +
22809 +Yes.
22810 +Thanks to Elena Zanoni, gdb (developement version) can now calculate
22811 +correctly addresses  of dynamically loaded object files. I have not been
22812 +following gdb developement for sometime and am not sure when symbol
22813 +address calculation fix is going to appear in a gdb stable version.
22814 +
22815 +Elena, any idea when the fix will make it to a prebuilt gdb from a
22816 +redhat release?
22817 +
22818 +For the time being I have built a gdb developement version. It can be
22819 +used for module debugging with loadmodule.sh script.
22820 +
22821 +The problem with calculating of module addresses with previous versions
22822 +of gdb was as follows:
22823 +gdb did not use base address of a section while calculating address of
22824 +a symbol in the section in an object file loaded via 'add-symbol-file'.
22825 +It used address of .text segment instead. Due to this addresses of
22826 +symbols in .data, .bss etc. (e.g. global variables) were calculated incorrectly.
22827 +
22828 +Above mentioned fix allow gdb to use base address of a segment while
22829 +calculating address of a symbol in it. It adds a parameter '-s' to
22830 +'add-symbol-file' command for specifying base address of a segment.
22831 +
22832 +loadmodule.sh script works as follows.
22833 +
22834 +1. Copy a module file to target machine.
22835 +2. Load the module on the target machine using insmod with -m parameter.
22836 +insmod produces a module load map which contains base addresses of all
22837 +sections in the module and addresses of symbols in the module file.
22838 +3. Find all sections and their base addresses in the module from
22839 +the module map.
22840 +4. Generate a script that loads the module file. The script uses
22841 +'add-symbol-file' and specifies address of text segment followed by
22842 +addresses of all segments in the module.
22843 +
22844 +Here is an example gdb script produced by loadmodule.sh script.
22845 +
22846 +add-symbol-file foo 0xd082c060 -s .text.lock 0xd08cbfb5
22847 +-s .fixup 0xd08cfbdf -s .rodata 0xd08cfde0 -s __ex_table 0xd08e3b38
22848 +-s .data 0xd08e3d00 -s .bss 0xd08ec8c0 -s __ksymtab 0xd08ee838
22849 +
22850 +With this command gdb can calculate addresses of symbols in ANY segment
22851 +in a module file.
22852 +
22853 +Regards.
22854 +--
22855 +Amit Kale
22856 +Veritas Software ( http://www.veritas.com )
22857 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
22858 +++ 25/Documentation/i386/kgdb/gdbinit  2003-10-05 00:33:38.000000000 -0700
22859 @@ -0,0 +1,14 @@
22860 +shell echo -e "\003" >/dev/ttyS0
22861 +set remotebaud 38400
22862 +target remote /dev/ttyS0
22863 +define si
22864 +stepi
22865 +printf "EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n", $eax, $ebx, $ecx, $edx
22866 +printf "ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n", $esi, $edi, $ebp, $esp
22867 +x/i $eip
22868 +end
22869 +define ni
22870 +nexti
22871 +printf "EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n", $eax, $ebx, $ecx, $edx
22872 +printf "ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n", $esi, $edi, $ebp, $esp
22873 +x/i $eip
22874 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
22875 +++ 25/Documentation/i386/kgdb/gdbinit.hw       2003-10-05 00:33:38.000000000 -0700
22876 @@ -0,0 +1,117 @@
22877 +
22878 +#Using ia-32 hardware breakpoints.
22879 +#
22880 +#4 hardware breakpoints are available in ia-32 processors. These breakpoints
22881 +#do not need code modification. They are set using debug registers.
22882 +#
22883 +#Each hardware breakpoint can be of one of the
22884 +#three types: execution, write, access.
22885 +#1. An Execution breakpoint is triggered when code at the breakpoint address is
22886 +#executed.
22887 +#2. A write breakpoint ( aka watchpoints ) is triggered when memory location
22888 +#at the breakpoint address is written.
22889 +#3. An access breakpoint is triggered when memory location at the breakpoint
22890 +#address is either read or written.
22891 +#
22892 +#As hardware breakpoints are available in limited number, use software
22893 +#breakpoints ( br command in gdb ) instead of execution hardware breakpoints.
22894 +#
22895 +#Length of an access or a write breakpoint defines length of the datatype to
22896 +#be watched. Length is 1 for char, 2 short , 3 int.
22897 +#
22898 +#For placing execution, write and access breakpoints, use commands
22899 +#hwebrk, hwwbrk, hwabrk
22900 +#To remove a breakpoint use hwrmbrk command.
22901 +#
22902 +#These commands take following types of arguments. For arguments associated
22903 +#with each command, use help command.
22904 +#1. breakpointno: 0 to 3
22905 +#2. length: 1 to 3
22906 +#3. address: Memory location in hex ( without 0x ) e.g c015e9bc
22907 +#
22908 +#Use the command exinfo to find which hardware breakpoint occured.
22909 +
22910 +#hwebrk breakpointno address
22911 +define hwebrk
22912 +       maintenance packet Y$arg0,0,0,$arg1
22913 +end
22914 +document hwebrk
22915 +       hwebrk <breakpointno> <address>
22916 +       Places a hardware execution breakpoint
22917 +       <breakpointno> = 0 - 3
22918 +       <address> = Hex digits without leading "0x".
22919 +end
22920 +
22921 +#hwwbrk breakpointno length address
22922 +define hwwbrk
22923 +       maintenance packet Y$arg0,1,$arg1,$arg2
22924 +end
22925 +document hwwbrk
22926 +       hwwbrk <breakpointno> <length> <address>
22927 +       Places a hardware write breakpoint
22928 +       <breakpointno> = 0 - 3
22929 +       <length> = 1 (1 byte), 2 (2 byte), 3 (4 byte)
22930 +       <address> = Hex digits without leading "0x".
22931 +end
22932 +
22933 +#hwabrk breakpointno length address
22934 +define hwabrk
22935 +       maintenance packet Y$arg0,1,$arg1,$arg2
22936 +end
22937 +document hwabrk
22938 +       hwabrk <breakpointno> <length> <address>
22939 +       Places a hardware access breakpoint
22940 +       <breakpointno> = 0 - 3
22941 +       <length> = 1 (1 byte), 2 (2 byte), 3 (4 byte)
22942 +       <address> = Hex digits without leading "0x".
22943 +end
22944 +
22945 +#hwrmbrk breakpointno
22946 +define hwrmbrk
22947 +       maintenance packet y$arg0
22948 +end
22949 +document hwrmbrk
22950 +       hwrmbrk <breakpointno>
22951 +       <breakpointno> = 0 - 3
22952 +       Removes a hardware breakpoint
22953 +end
22954 +
22955 +define reboot
22956 +        maintenance packet r
22957 +end
22958 +#exinfo
22959 +define exinfo
22960 +       maintenance packet qE
22961 +end
22962 +document exinfo
22963 +       exinfo
22964 +       Gives information about a breakpoint.
22965 +end
22966 +define get_th
22967 +       p $th=(struct thread_info *)((int)$esp & ~8191)
22968 +end
22969 +document get_th
22970 +       get_tu
22971 +       Gets and prints the current thread_info pointer, Defines th to be it.
22972 +end
22973 +define get_cu
22974 +       p $cu=((struct thread_info *)((int)$esp & ~8191))->task
22975 +end
22976 +document get_cu
22977 +       get_cu
22978 +       Gets and print the "current" value.  Defines $cu to be it.
22979 +end
22980 +define int_off
22981 +       set var $flags=$eflags
22982 +       set $eflags=$eflags&~0x200
22983 +       end
22984 +define int_on
22985 +       set var $eflags|=$flags&0x200
22986 +       end
22987 +document int_off
22988 +       saves the current interrupt state and clears the processor interrupt
22989 +       flag.  Use int_on to restore the saved flag.
22990 +end
22991 +document int_on
22992 +       Restores the interrupt flag saved by int_off.
22993 +end
22994 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
22995 +++ 25/Documentation/i386/kgdb/gdbinit-modules  2003-10-05 00:33:38.000000000 -0700
22996 @@ -0,0 +1,146 @@
22997 +#
22998 +# Usefull GDB user-command to debug Linux Kernel Modules with gdbstub.
22999 +#
23000 +# This don't work for Linux-2.0 or older.
23001 +#
23002 +# Author Edouard G. Parmelan <Edouard.Parmelan@quadratec.fr>
23003 +#
23004 +#
23005 +# Fri Apr 30 20:33:29 CEST 1999
23006 +#   First public release.
23007 +#
23008 +#   Major cleanup after experiment Linux-2.0 kernel without success.
23009 +#   Symbols of a module are not in the correct order, I can't explain
23010 +#   why :(
23011 +#
23012 +# Fri Mar 19 15:41:40 CET 1999
23013 +#   Initial version.
23014 +#
23015 +# Thu Jan  6 16:29:03 CST 2000
23016 +#   A little fixing by Dave Grothe <dave@gcom.com>
23017 +#
23018 +# Mon Jun 19 09:33:13 CDT 2000
23019 +#   Alignment changes from Edouard Parmelan
23020 +#
23021 +# The basic idea is to find where insmod load the module and inform
23022 +# GDB to load the symbol table of the module with the GDB command
23023 +# ``add-symbol-file <object> <address>''.
23024 +#
23025 +# The Linux kernel holds the list of all loaded modules in module_list,
23026 +# this list end with &kernel_module (exactly with module->next == NULL,
23027 +# but the last module is not a real module).
23028 +#
23029 +# Insmod allocates the struct module before the object file.  Since
23030 +# Linux-2.1, this structure contain his size.  The real address of
23031 +# the object file is then (char*)module + module->size_of_struct.
23032 +#
23033 +# You can use three user functions ``mod-list'', ``mod-print-symbols''
23034 +# and ``add-module-symbols''.
23035 +#
23036 +# mod-list list all loaded modules with the format:
23037 +#    <module-address> <module-name>
23038 +#
23039 +# As soon as you have found the address of your module, you can
23040 +# print its exported symbols (mod-print-symbols) or inform GDB to add
23041 +# symbols from your module file (mod-add-symbols).
23042 +#
23043 +# The argument that you give to mod-print-symbols or mod-add-symbols
23044 +# is the <module-address> from the mod-list command.
23045 +#
23046 +# When using the mod-add-symbols command you must also give the full
23047 +# pathname of the modules object code file.
23048 +#
23049 +# The command mod-add-lis is an example of how to make this easier.
23050 +# You can edit this macro to contain the path name of your own
23051 +# favorite module and then use it as a shorthand to load it.  You
23052 +# still need the module-address, however.
23053 +#
23054 +# The internal function ``mod-validate'' set the GDB variable $mod
23055 +# as a ``struct module*'' if the kernel known the module otherwise
23056 +# $mod is set to NULL.  This ensure to not add symbols for a wrong
23057 +# address.
23058 +#
23059 +# Have a nice hacking day !
23060 +#
23061 +#
23062 +define mod-list
23063 +    set $mod = (struct module*)module_list
23064 +    # the last module is the kernel, ignore it
23065 +    while $mod != &kernel_module
23066 +       printf "%p\t%s\n", (long)$mod, ($mod)->name
23067 +       set $mod = $mod->next
23068 +    end
23069 +end
23070 +document mod-list
23071 +List all modules in the form: <module-address> <module-name>
23072 +Use the <module-address> as the argument for the other
23073 +mod-commands: mod-print-symbols, mod-add-symbols.
23074 +end
23075 +
23076 +define mod-validate
23077 +    set $mod = (struct module*)module_list
23078 +    while ($mod != $arg0) && ($mod != &kernel_module)
23079 +       set $mod = $mod->next
23080 +    end
23081 +    if $mod == &kernel_module
23082 +       set $mod = 0
23083 +       printf "%p is not a module\n", $arg0
23084 +    end
23085 +end
23086 +document mod-validate
23087 +mod-validate <module-address>
23088 +Internal user-command used to validate the module parameter.
23089 +If <module> is a real loaded module, set $mod to it otherwise set $mod to 0.
23090 +end
23091 +
23092 +
23093 +define mod-print-symbols
23094 +    mod-validate $arg0
23095 +    if $mod != 0
23096 +       set $i = 0
23097 +       while $i < $mod->nsyms
23098 +           set $sym = $mod->syms[$i]
23099 +           printf "%p\t%s\n", $sym->value, $sym->name
23100 +           set $i = $i + 1
23101 +       end
23102 +    end
23103 +end
23104 +document mod-print-symbols
23105 +mod-print-symbols <module-address>
23106 +Print all exported symbols of the module.  see mod-list
23107 +end
23108 +
23109 +
23110 +define mod-add-symbols-align
23111 +    mod-validate $arg0
23112 +    if $mod != 0
23113 +       set $mod_base = ($mod->size_of_struct + (long)$mod)
23114 +       if ($arg2 != 0) && (($mod_base & ($arg2 - 1)) != 0)
23115 +           set $mod_base = ($mod_base | ($arg2 - 1)) + 1
23116 +       end
23117 +       add-symbol-file $arg1 $mod_base
23118 +    end
23119 +end
23120 +document mod-add-symbols-align
23121 +mod-add-symbols-align <module-address> <object file path name> <align>
23122 +Load the symbols table of the module from the object file where
23123 +first section aligment is <align>.
23124 +To retreive alignment, use `objdump -h <object file path name>'.
23125 +end
23126 +
23127 +define mod-add-symbols
23128 +    mod-add-symbols-align $arg0 $arg1 sizeof(long)
23129 +end
23130 +document mod-add-symbols
23131 +mod-add-symbols <module-address> <object file path name>
23132 +Load the symbols table of the module from the object file.
23133 +Default alignment is 4.  See mod-add-symbols-align.
23134 +end
23135 +
23136 +define mod-add-lis
23137 +    mod-add-symbols-align $arg0 /usr/src/LiS/streams.o 16
23138 +end
23139 +document mod-add-lis
23140 +mod-add-lis <module-address>
23141 +Does mod-add-symbols <module-address> /usr/src/LiS/streams.o
23142 +end
23143 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
23144 +++ 25/Documentation/i386/kgdb/kgdbeth.txt      2003-10-05 00:33:46.000000000 -0700
23145 @@ -0,0 +1,118 @@
23146 +KGDB over ethernet
23147 +==================
23148 +
23149 +Authors
23150 +-------
23151 +
23152 +Robert Walsh <rjwalsh@durables.org>  (2.6 port)
23153 +wangdi <wangdi@clusterfs.com>        (2.6 port)
23154 +San Mehat                            (original 2.4 code)
23155 +
23156 +
23157 +Introduction
23158 +------------
23159 +
23160 +KGDB supports debugging over ethernet.  Only a limited set of ethernet
23161 +devices are supported right now, but adding support for new devices
23162 +should not be too complicated.  See "New Devices" below for details.
23163 +
23164 +
23165 +Terminology
23166 +-----------
23167 +
23168 +This document uses the following terms:
23169 +
23170 +  TARGET: the machine being debugged.
23171 +  HOST:   the machine running gdb.
23172 +
23173 +
23174 +Usage
23175 +-----
23176 +
23177 +You need to use the following command-line options on the TARGET kernel:
23178 +
23179 +  gdbeth=DEVICENUM
23180 +  gdbeth_remoteip=HOSTIPADDR
23181 +  gdbeth_remotemac=REMOTEMAC
23182 +  gdbeth_localmac=LOCALMAC
23183 +
23184 +kgdbeth=DEVICENUM sets the ethernet device number to listen on for
23185 +debugging packets.  e.g. kgdbeth=0 listens on eth0.
23186 +
23187 +kgdbeth_remoteip=HOSTIPADDR sets the IP address of the HOST machine.
23188 +Only packets originating from this IP address will be accepted by the
23189 +debugger.  e.g. kgdbeth_remoteip=192.168.2.2
23190 +
23191 +kgdbeth_remotemac=REMOTEMAC sets the ethernet address of the HOST machine.
23192 +e.g. kgdbeth_remotemac=00:07:70:12:4E:F5
23193 +
23194 +kgdbeth_localmac=LOCALMAC sets the ethernet address of the TARGET machine.
23195 +e.g. kgdbeth_localmac=00:10:9F:18:21:3C
23196 +
23197 +You can also set the following command-line option on the TARGET kernel:
23198 +
23199 +  kgdbeth_listenport=PORT
23200 +
23201 +kgdbeth_listenport sets the UDP port to listen on for gdb debugging
23202 +packets.  The default value is "6443".  e.g. kgdbeth_listenport=7654
23203 +causes the kernel to listen on UDP port 7654 for debugging packets.
23204 +
23205 +On the HOST side, run gdb as normal and use a remote UDP host as the
23206 +target:
23207 +
23208 +   % gdb ./vmlinux
23209 +   GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
23210 +   Copyright 2003 Free Software Foundation, Inc.
23211 +   GDB is free software, covered by the GNU General Public License, and you are
23212 +   welcome to change it and/or distribute copies of it under certain conditions.
23213 +   Type "show copying" to see the conditions.
23214 +   There is absolutely no warranty for GDB.  Type "show warranty" for details.
23215 +   This GDB was configured as "i386-redhat-linux-gnu"...
23216 +   (gdb) target remote udp:HOSTNAME:6443
23217 +
23218 +You can now continue as if you were debugging over a serial line.
23219 +
23220 +Observations
23221 +------------
23222 +
23223 +I've used this with NFS and various other network applications (ssh,
23224 +etc.) and it's doesn't appear to interfere with their operation in
23225 +any way.  It doesn't seem to effect the NIC it uses - i.e. you don't
23226 +need a dedicated NIC for this.
23227 +
23228 +Limitations
23229 +-----------
23230 +
23231 +In the inital release of this code you _must_ break into the system with the
23232 +debugger by hand, early after boot, as described above.
23233 +
23234 +Otherwise, the first time the kernel tries to enter the debugger (say, via an
23235 +oops or a BUG), the kgdb stub will doublefault and die because things aren't
23236 +fully set up yet.
23237 +
23238 +Supported devices
23239 +-----------------
23240 +
23241 +Right now, the following drivers are supported:
23242 +
23243 +  e100 driver (drivers/net/e100/*)
23244 +  3c59x driver (drivers/net/3c59x.c)
23245 +
23246 +
23247 +New devices
23248 +-----------
23249 +
23250 +Supporting a new device is straightforward.  Just add a "poll" routine to
23251 +the driver and hook it into the poll_controller field in the netdevice
23252 +structure.  For an example, look in drivers/net/3c59x.c and search
23253 +for CONFIG_KGDB (two places.)
23254 +
23255 +The poll routine is usually quite simple - it's usually enough to just
23256 +disable interrupts, call the device's interrupt routine and re-enable
23257 +interrupts again.
23258 +
23259 +
23260 +Bug reports
23261 +-----------
23262 +
23263 +Send bug reports to Robert Walsh <rjwalsh@durables.org>.
23264 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
23265 +++ 25/Documentation/i386/kgdb/kgdb.txt 2003-10-05 00:33:38.000000000 -0700
23266 @@ -0,0 +1,775 @@
23267 +Last edit: <20030806.1637.12>
23268 +This file has information specific to the i386 kgdb option.  Other
23269 +platforms with the kgdb option may behave in a similar fashion.
23270 +
23271 +New features:
23272 +============
23273 +20030806.1557.37
23274 +This version was made against the 2.6.0-test2 kernel. We have made the
23275 +following changes:
23276 +
23277 +- The getthread() code in the stub calls find_task_by_pid().  It fails
23278 +  if we are early in the bring up such that the pid arrays have yet to
23279 +  be allocated.  We have added a line to kernel/pid.c to make
23280 +  "kgdb_pid_init_done" true once the arrays are allocated.  This way the
23281 +  getthread() code knows not to call.  This is only used by the thread
23282 +  debugging stuff and threads will not yet exist at this point in the
23283 +  boot.
23284 +
23285 +- For some reason, gdb was not asking for a new thread list when the
23286 +  "info thread" command was given.  We changed to the newer version of
23287 +  the thread info command and gdb now seems to ask when needed.  Result,
23288 +  we now get all threads in the thread list.
23289 +
23290 +- We now respond to the ThreadExtraInfo request from gdb with the thread
23291 +  name from task_struct .comm.  This then appears in the thread list.
23292 +  Thoughts on additional options for this are welcome.  Things such as
23293 +  "has BKL" and "Preempted" come to mind.  I think we could have a flag
23294 +  word that could enable different bits of info here.
23295 +
23296 +- We now honor, sort of, the C and S commands.  These are continue and
23297 +  single set after delivering a signal.  We ignore the signal and do the
23298 +  requested action.  This only happens when we told gdb that a signal
23299 +  was the reason for entry, which is only done on memory faults.  The
23300 +  result is that you can now continue into the Oops.
23301 +
23302 +- We changed the -g to -gdwarf-2.  This seems to be the same as -ggdb,
23303 +  but it is more exact on what language to use.
23304 +
23305 +- We added two dwarf2 include files and a bit of code at the end of
23306 +  entry.S.  This does not yet work, so it is disabled.  Still we want to
23307 +  keep track of the code and "maybe" someone out there can fix it.
23308 +
23309 +- Randy Dunlap sent some fix ups for this file which are now merged.
23310 +
23311 +- Hugh Dickins sent a fix to a bit of code in traps.c that prevents a
23312 +  compiler warning if CONFIG_KGDB is off (now who would do that :).
23313 +
23314 +- Andrew Morton sent a fix for the serial driver which is now merged.
23315 +
23316 +- Andrew also sent a change to the stub around the cpu managment code
23317 +  which is also merged.
23318 +
23319 +- Andrew also sent a patch to make "f" as well as "g" work as SysRq
23320 +  commands to enter kgdb, merged.
23321 +
23322 +- If CONFIG_KGDB and CONFIG_DEBUG_SPINLOCKS are both set we added a
23323 +  "who" field to the spinlock data struct.  This is filled with
23324 +  "current" when ever the spinlock suceeds.  Useful if you want to know
23325 +  who has the lock.
23326 +
23327 +_ And last, but not least, we fixed the "get_cu" macro to properly get
23328 +  the current value of "current".
23329 +
23330 +New features:
23331 +============
23332 +20030505.1827.27
23333 +We are starting to align with the sourceforge version, at least in
23334 +commands.  To this end, the boot command string to start kgdb at
23335 +boot time has been changed from "kgdb" to "gdb".
23336 +
23337 +Andrew Morton sent a couple of patches which are now included as follows:
23338 +1.) We now return a flag to the interrupt handler.
23339 +2.) We no longer use smp_num_cpus (a conflict with the lock meter).
23340 +3.) And from William Lee Irwin III <wli@holomorphy.com> code to make
23341 +    sure high-mem is set up before we attempt to register our interrupt
23342 +    handler.
23343 +We now include asm/kgdb.h from config.h so you will most likely never
23344 +have to include it.  It also 'NULLS' the kgdb macros you might have in
23345 +your code when CONFIG_KGDB is not defined.  This allows you to just
23346 +turn off CONFIG_KGDB to turn off all the kgdb_ts() calls and such.
23347 +This include is conditioned on the machine being an x86 so as to not
23348 +mess with other archs.
23349 +
23350 +20020801.1129.03
23351 +This is currently the version for the 2.4.18 (and beyond?) kernel.
23352 +
23353 +We have several new "features" beginning with this version:
23354 +
23355 +1.) Kgdb now syncs the "other" CPUs with a cross-CPU NMI.  No more
23356 +    waiting and it will pull that guy out of an IRQ off spin lock :)
23357 +
23358 +2.) We doctored up the code that tells where a task is waiting and
23359 +    included it so that the "info thread" command will show a bit more
23360 +    than "schedule()".  Try it...
23361 +
23362 +3.) Added the ability to call a function from gdb.  All the standard gdb
23363 +    issues apply, i.e. if you hit a breakpoint in the function, you are
23364 +    not allowed to call another (gdb limitation, not kgdb).  To help
23365 +    this capability we added a memory allocation function.  Gdb does not
23366 +    return this memory (it is used for strings that you pass to that function
23367 +    you are calling from gdb) so we fixed up a way to allow you to
23368 +    manually return the memory (see below).
23369 +
23370 +4.) Kgdb time stamps (kgdb_ts()) are enhanced to expand what was the
23371 +    interrupt flag to now also include the preemption count and the
23372 +    "in_interrupt" info.  The flag is now called "with_pif" to indicate
23373 +    the order, preempt_count, in_interrupt, flag.  The preempt_count is
23374 +    shifted left by 4 bits so you can read the count in hex by dropping
23375 +    the low order digit.  In_interrupt is in bit 1, and the flag is in
23376 +    bit 0.
23377 +
23378 +5.) The command: "p kgdb_info" is now expanded and prints something
23379 +    like:
23380 +(gdb) p kgdb_info
23381 +$2 = {used_malloc = 0, called_from = 0xc0107506, entry_tsc = 67468627259,
23382 +  errcode = 0, vector = 3, print_debug_info = 0, hold_on_sstep = 1,
23383 +  cpus_waiting = {{task = 0xc027a000, pid = 32768, hold = 0,
23384 +      regs = 0xc027bf84}, {task = 0x0, pid = 0, hold = 0, regs = 0x0}}}
23385 +
23386 +    Things to note here: a.) used_malloc is the amount of memory that
23387 +    has been malloc'ed to do calls from gdb.  You can reclaim this
23388 +    memory like this: "p kgdb_info.used_malloc=0" Cool, huh?  b.)
23389 +    cpus_waiting is now "sized" by the number of CPUs you enter at
23390 +    configure time in the kgdb configure section.  This is NOT used
23391 +    anywhere else in the system, but it is "nice" here.  c.)  The task's
23392 +    "pid" is now in the structure.  This is the pid you will need to use
23393 +    to decode to the thread id to get gdb to look at that thread.
23394 +    Remember that the "info thread" command prints a list of threads
23395 +    wherein it numbers each thread with its reference number followed
23396 +    by the thread's pid.  Note that the per-CPU idle threads actually
23397 +    have pids of 0 (yes, there is more than one pid 0 in an SMP system).
23398 +    To avoid confusion, kgdb numbers these threads with numbers beyond
23399 +    the MAX_PID.  That is why you see 32768 and above.
23400 +
23401 +6.) A subtle change, we now provide the complete register set for tasks
23402 +    that are active on the other CPUs.  This allows better trace back on
23403 +    those tasks.
23404 +
23405 +    And, let's mention what we could not fix.  Back-trace from all but the
23406 +    thread that we trapped will, most likely, have a bogus entry in it.
23407 +    The problem is that gdb does not recognize the entry code for
23408 +    functions that use "current" near (at all?) the entry.  The compiler
23409 +    is putting the "current" decode as the first two instructions of the
23410 +    function where gdb expects to find %ebp changing code.  Back trace
23411 +    also has trouble with interrupt frames.  I am talking with Daniel
23412 +    Jacobowitz about some way to fix this, but don't hold your breath.
23413 +
23414 +20011220.0050.35
23415 +Major enhancement with this version is the ability to hold one or more
23416 +CPUs in an SMP system while allowing the others to continue.  Also, by
23417 +default only the current CPU is enabled on single-step commands (please
23418 +note that gdb issues single-step commands at times other than when you
23419 +use the si command).
23420 +
23421 +Another change is to collect some useful information in
23422 +a global structure called "kgdb_info".  You should be able to just:
23423 +
23424 +p kgdb_info
23425 +
23426 +although I have seen cases where the first time this is done gdb just
23427 +prints the first member but prints the whole structure if you then enter
23428 +CR (carriage return or enter).  This also works:
23429 +
23430 +p *&kgdb_info
23431 +
23432 +Here is a sample:
23433 +(gdb) p kgdb_info
23434 +$4 = {called_from = 0xc010732c, entry_tsc = 32804123790856, errcode = 0,
23435 +  vector = 3, print_debug_info = 0}
23436 +
23437 +"Called_from" is the return address from the current entry into kgdb.
23438 +Sometimes it is useful to know why you are in kgdb, for example, was
23439 +it an NMI or a real breakpoint?  The simple way to interrogate this
23440 +return address is:
23441 +
23442 +l *0xc010732c
23443 +
23444 +which will print the surrounding few lines of source code.
23445 +
23446 +"Entry_tsc" is the CPU TSC on entry to kgdb (useful to compare to the
23447 +kgdb_ts entries).
23448 +
23449 +"errcode" and "vector" are other entry parameters which may be helpful on
23450 +some traps.
23451 +
23452 +"print_debug_info" is the internal debugging kgdb print enable flag.  Yes,
23453 +you can modify it.
23454 +
23455 +In SMP systems kgdb_info also includes the "cpus_waiting" structure and
23456 +"hold_on_step":
23457 +
23458 +(gdb) p kgdb_info
23459 +$7 = {called_from = 0xc0112739, entry_tsc = 1034936624074, errcode = 0,
23460 +  vector = 2, print_debug_info = 0, hold_on_sstep = 1, cpus_waiting = {{
23461 +      task = 0x0, hold = 0, regs = 0x0}, {task = 0xc71b8000, hold = 0,
23462 +      regs = 0xc71b9f70}, {task = 0x0, hold = 0, regs = 0x0}, {task = 0x0,
23463 +      hold = 0, regs = 0x0}, {task = 0x0, hold = 0, regs = 0x0}, {task = 0x0,
23464 +      hold = 0, regs = 0x0}, {task = 0x0, hold = 0, regs = 0x0}, {task = 0x0,
23465 +      hold = 0, regs = 0x0}}}
23466 +
23467 +"Cpus_waiting" has an entry for each CPU other than the current one that
23468 +has been stopped.  Each entry contains the task_struct address for that
23469 +CPU, the address of the regs for that task and a hold flag.  All these
23470 +have the proper typing so that, for example:
23471 +
23472 +p *kgdb_info.cpus_waiting[1].regs
23473 +
23474 +will print the registers for CPU 1.
23475 +
23476 +"Hold_on_sstep" is a new feature with this version and comes up set or
23477 +true.  What this means is that whenever kgdb is asked to single-step all
23478 +other CPUs are held (i.e. not allowed to execute).  The flag applies to
23479 +all but the current CPU and, again, can be changed:
23480 +
23481 +p kgdb_info.hold_on_sstep=0
23482 +
23483 +restores the old behavior of letting all CPUs run during single-stepping.
23484 +
23485 +Likewise, each CPU has a "hold" flag, which if set, locks that CPU out
23486 +of execution.  Note that this has some risk in cases where the CPUs need
23487 +to communicate with each other.  If kgdb finds no CPU available on exit,
23488 +it will push a message thru gdb and stay in kgdb.  Note that it is legal
23489 +to hold the current CPU as long as at least one CPU can execute.
23490 +
23491 +20010621.1117.09
23492 +This version implements an event queue.  Events are signaled by calling
23493 +a function in the kgdb stub and may be examined from gdb.  See EVENTS
23494 +below for details.  This version also tightens up the interrupt and SMP
23495 +handling to not allow interrupts on the way to kgdb from a breakpoint
23496 +trap.  It is fine to allow these interrupts for user code, but not
23497 +system debugging.
23498 +
23499 +Version
23500 +=======
23501 +
23502 +This version of the kgdb package was developed and tested on
23503 +kernel version 2.4.16.  It will not install on any earlier kernels.
23504 +It is possible that it will continue to work on later versions
23505 +of 2.4 and then versions of 2.5 (I hope).
23506 +
23507 +
23508 +Debugging Setup
23509 +===============
23510 +
23511 +Designate one machine as the "development" machine.  This is the
23512 +machine on which you run your compiles and which has your source
23513 +code for the kernel.  Designate a second machine as the "target"
23514 +machine.  This is the machine that will run your experimental
23515 +kernel.
23516 +
23517 +The two machines will be connected together via a serial line out
23518 +one or the other of the COM ports of the PC.  You will need the
23519 +appropriate modem eliminator (null modem) cable(s) for this.
23520 +
23521 +Decide on which tty port you want the machines to communicate, then
23522 +connect them up back-to-back using the null modem cable.  COM1 is
23523 +/dev/ttyS0 and COM2 is /dev/ttyS1. You should test this connection
23524 +with the two machines prior to trying to debug a kernel.  Once you
23525 +have it working, on the TARGET machine, enter:
23526 +
23527 +setserial /dev/ttyS0 (or what ever tty you are using)
23528 +
23529 +and record the port address and the IRQ number.
23530 +
23531 +On the DEVELOPMENT machine you need to apply the patch for the kgdb
23532 +hooks.  You have probably already done that if you are reading this
23533 +file.
23534 +
23535 +On your DEVELOPMENT machine, go to your kernel source directory and do
23536 +"make Xconfig" where X is one of "x", "menu", or "".  If you are
23537 +configuring in the standard serial driver, it must not be a module.
23538 +Either yes or no is ok, but making the serial driver a module means it
23539 +will initialize after kgdb has set up the UART interrupt code and may
23540 +cause a failure of the control-C option discussed below.  The configure
23541 +question for the serial driver is under the "Character devices" heading
23542 +and is:
23543 +
23544 +"Standard/generic (8250/16550 and compatible UARTs) serial support"
23545 +
23546 +Go down to the kernel debugging menu item and open it up.  Enable the
23547 +kernel kgdb stub code by selecting that item.  You can also choose to
23548 +turn on the "-ggdb -O1" compile options.  The -ggdb causes the compiler
23549 +to put more debug info (like local symbols) in the object file.  On the
23550 +i386 -g and -ggdb are the same so this option just reduces to "O1".  The
23551 +-O1 reduces the optimization level.  This may be helpful in some cases,
23552 +be aware, however, that this may also mask the problem you are looking
23553 +for.
23554 +
23555 +The baud rate.  Default is 115200.  What ever you choose be sure that
23556 +the host machine is set to the same speed.  I recommend the default.
23557 +
23558 +The port.  This is the I/O address of the serial UART that you should
23559 +have gotten using setserial as described above.  The standard COM1 port
23560 +(3f8) using IRQ 4 is default.  COM2 is 2f8 which by convention uses IRQ
23561 +3.
23562 +
23563 +The port IRQ (see above).
23564 +
23565 +Stack overflow test.  This option makes a minor change in the trap,
23566 +system call and interrupt code to detect stack overflow and transfer
23567 +control to kgdb if it happens.  (Some platforms have this in the
23568 +baseline code, but the i386 does not.)
23569 +
23570 +You can also configure the system to recognize the boot option
23571 +"console=kgdb" which if given will cause all console output during
23572 +booting to be put thru gdb as well as other consoles.  This option
23573 +requires that gdb and kgdb be connected prior to sending console output
23574 +so, if they are not, a breakpoint is executed to force the connection.
23575 +This will happen before any kernel output (it is going thru gdb, right),
23576 +and will stall the boot until the connection is made.
23577 +
23578 +You can also configure in a patch to SysRq to enable the kGdb SysRq.
23579 +This request generates a breakpoint.  Since the serial port IRQ line is
23580 +set up after any serial drivers, it is possible that this command will
23581 +work when the control-C will not.
23582 +
23583 +Save and exit the Xconfig program.  Then do "make clean" , "make dep"
23584 +and "make bzImage" (or whatever target you want to make).  This gets the
23585 +kernel compiled with the "-g" option set -- necessary for debugging.
23586 +
23587 +You have just built the kernel on your DEVELOPMENT machine that you
23588 +intend to run on your TARGET machine.
23589 +
23590 +To install this new kernel, use the following installation procedure.
23591 +Remember, you are on the DEVELOPMENT machine patching the kernel source
23592 +for the kernel that you intend to run on the TARGET machine.
23593 +
23594 +Copy this kernel to your target machine using your usual procedures.  I
23595 +usually arrange to copy development:
23596 +/usr/src/linux/arch/i386/boot/bzImage to /vmlinuz on the TARGET machine
23597 +via a LAN based NFS access.  That is, I run the cp command on the target
23598 +and copy from the development machine via the LAN.  Run Lilo (see "man
23599 +lilo" for details on how to set this up) on the new kernel on the target
23600 +machine so that it will boot!  Then boot the kernel on the target
23601 +machine.
23602 +
23603 +On the DEVELOPMENT machine, create a file called .gdbinit in the
23604 +directory /usr/src/linux.  An example .gdbinit file looks like this:
23605 +
23606 +shell echo -e "\003" >/dev/ttyS0
23607 +set remotebaud 38400 (or what ever speed you have chosen)
23608 +target remote /dev/ttyS0
23609 +
23610 +
23611 +Change the "echo" and "target" definition so that it specifies the tty
23612 +port that you intend to use.  Change the "remotebaud" definition to
23613 +match the data rate that you are going to use for the com line.
23614 +
23615 +You are now ready to try it out.
23616 +
23617 +Boot your target machine with "kgdb" in the boot command i.e. something
23618 +like:
23619 +
23620 +lilo> test kgdb
23621 +
23622 +or if you also want console output thru gdb:
23623 +
23624 +lilo> test kgdb console=kgdb
23625 +
23626 +You should see the lilo message saying it has loaded the kernel and then
23627 +all output stops.  The kgdb stub is trying to connect with gdb.  Start
23628 +gdb something like this:
23629 +
23630 +
23631 +On your DEVELOPMENT machine, cd /usr/src/linux and enter "gdb vmlinux".
23632 +When gdb gets the symbols loaded it will read your .gdbinit file and, if
23633 +everything is working correctly, you should see gdb print out a few
23634 +lines indicating that a breakpoint has been taken.  It will actually
23635 +show a line of code in the target kernel inside the kgdb activation
23636 +code.
23637 +
23638 +The gdb interaction should look something like this:
23639 +
23640 +    linux-dev:/usr/src/linux# gdb vmlinux
23641 +    GDB is free software and you are welcome to distribute copies of it
23642 +     under certain conditions; type "show copying" to see the conditions.
23643 +    There is absolutely no warranty for GDB; type "show warranty" for details.
23644 +    GDB 4.15.1 (i486-slackware-linux),
23645 +    Copyright 1995 Free Software Foundation, Inc...
23646 +    breakpoint () at i386-stub.c:750
23647 +    750     }
23648 +    (gdb)
23649 +
23650 +You can now use whatever gdb commands you like to set breakpoints.
23651 +Enter "continue" to start your target machine executing again.  At this
23652 +point the target system will run at full speed until it encounters
23653 +your breakpoint or gets a segment violation in the kernel, or whatever.
23654 +
23655 +If you have the kgdb console enabled when you continue, gdb will print
23656 +out all the console messages.
23657 +
23658 +The above example caused a breakpoint relatively early in the boot
23659 +process.  For the i386 kgdb it is possible to code a break instruction
23660 +as the first C-language point in init/main.c, i.e. as the first instruction
23661 +in start_kernel().  This could be done as follows:
23662 +
23663 +#include <asm/kgdb.h>
23664 +        breakpoint();
23665 +
23666 +This breakpoint() is really a function that sets up the breakpoint and
23667 +single-step hardware trap cells and then executes a breakpoint.  Any
23668 +early hard coded breakpoint will need to use this function.  Once the
23669 +trap cells are set up they need not be set again, but doing it again
23670 +does not hurt anything, so you don't need to be concerned about which
23671 +breakpoint is hit first.  Once the trap cells are set up (and the kernel
23672 +sets them up in due course even if breakpoint() is never called) the
23673 +macro:
23674 +
23675 +BREAKPOINT;
23676 +
23677 +will generate an inline breakpoint.  This may be more useful as it stops
23678 +the processor at the instruction instead of in a function a step removed
23679 +from the location of interest.  In either case <asm/kgdb.h> must be
23680 +included to define both breakpoint() and BREAKPOINT.
23681 +
23682 +Triggering kgdbstub at other times
23683 +==================================
23684 +
23685 +Often you don't need to enter the debugger until much later in the boot
23686 +or even after the machine has been running for some time.  Once the
23687 +kernel is booted and interrupts are on, you can force the system to
23688 +enter the debugger by sending a control-C to the debug port. This is
23689 +what the first line of the recommended .gdbinit file does.  This allows
23690 +you to start gdb any time after the system is up as well as when the
23691 +system is already at a breakpoint.  (In the case where the system is
23692 +already at a breakpoint the control-C is not needed, however, it will
23693 +be ignored by the target so no harm is done.  Also note the the echo
23694 +command assumes that the port speed is already set.  This will be true
23695 +once gdb has connected, but it is best to set the port speed before you
23696 +run gdb.)
23697 +
23698 +Another simple way to do this is to put the following file in you ~/bin
23699 +directory:
23700 +
23701 +#!/bin/bash
23702 +echo  -e "\003"  > /dev/ttyS0
23703 +
23704 +Here, the ttyS0 should be replaced with what ever port you are using.
23705 +The "\003" is control-C.  Once you are connected with gdb, you can enter
23706 +control-C at the command prompt.
23707 +
23708 +An alternative way to get control to the debugger is to enable the kGdb
23709 +SysRq command.  Then you would enter Alt-SysRq-g (all three keys at the
23710 +same time, but push them down in the order given).  To refresh your
23711 +memory of the available SysRq commands try Alt-SysRq-=.  Actually any
23712 +undefined command could replace the "=", but I like to KNOW that what I
23713 +am pushing will never be defined.
23714 +
23715 +Debugging hints
23716 +===============
23717 +
23718 +You can break into the target machine at any time from the development
23719 +machine by typing ^C (see above paragraph).  If the target machine has
23720 +interrupts enabled this will stop it in the kernel and enter the
23721 +debugger.
23722 +
23723 +There is unfortunately no way of breaking into the kernel if it is
23724 +in a loop with interrupts disabled, so if this happens to you then
23725 +you need to place exploratory breakpoints or printk's into the kernel
23726 +to find out where it is looping.  The exploratory breakpoints can be
23727 +entered either thru gdb or hard coded into the source.  This is very
23728 +handy if you do something like:
23729 +
23730 +if (<it hurts>) BREAKPOINT;
23731 +
23732 +
23733 +There is a copy of an e-mail in the Documentation/i386/kgdb/ directory
23734 +(debug-nmi.txt) which describes how to create an NMI on an ISA bus
23735 +machine using a paper clip.  I have a sophisticated version of this made
23736 +by wiring a push button switch into a PC104/ISA bus adapter card.  The
23737 +adapter card nicely furnishes wire wrap pins for all the ISA bus
23738 +signals.
23739 +
23740 +When you are done debugging the kernel on the target machine it is a
23741 +good idea to leave it in a running state.  This makes reboots faster,
23742 +bypassing the fsck.  So do a gdb "continue" as the last gdb command if
23743 +this is possible.  To terminate gdb itself on the development machine
23744 +and leave the target machine running, first clear all breakpoints and
23745 +continue, then type ^Z to suspend gdb and then kill it with "kill %1" or
23746 +something similar.
23747 +
23748 +If gdbstub Does Not Work
23749 +========================
23750 +
23751 +If it doesn't work, you will have to troubleshoot it.  Do the easy
23752 +things first like double checking your cabling and data rates.  You
23753 +might try some non-kernel based programs to see if the back-to-back
23754 +connection works properly.  Just something simple like cat /etc/hosts
23755 +>/dev/ttyS0 on one machine and cat /dev/ttyS0 on the other will tell you
23756 +if you can send data from one machine to the other.  Make sure it works
23757 +in both directions.  There is no point in tearing out your hair in the
23758 +kernel if the line doesn't work.
23759 +
23760 +All of the real action takes place in the file
23761 +/usr/src/linux/arch/i386/kernel/kgdb_stub.c.  That is the code on the target
23762 +machine that interacts with gdb on the development machine.  In gdb you can
23763 +turn on a debug switch with the following command:
23764 +
23765 +       set remotedebug
23766 +
23767 +This will print out the protocol messages that gdb is exchanging with
23768 +the target machine.
23769 +
23770 +Another place to look is /usr/src/arch/i386/lib/kgdb_serial.c. This is
23771 +the code that talks to the serial port on the target side.  There might
23772 +be a problem there.  In particular there is a section of this code that
23773 +tests the UART which will tell you what UART you have if you define
23774 +"PRNT" (just remove "_off" from the #define PRNT_off).  To view this
23775 +report you will need to boot the system without any beakpoints.  This
23776 +allows the kernel to run to the point where it calls kgdb to set up
23777 +interrupts.  At this time kgdb will test the UART and print out the type
23778 +it finds.  (You need to wait so that the printks are actually being
23779 +printed.  Early in the boot they are cached, waiting for the console to
23780 +be enabled.  Also, if kgdb is entered thru a breakpoint it is possible
23781 +to cause a dead lock by calling printk when the console is locked.  The
23782 +stub thus avoids doing printks from breakpoints, especially in the
23783 +serial code.)  At this time, if the UART fails to do the expected thing,
23784 +kgdb will print out (using printk) information on what failed.  (These
23785 +messages will be buried in all the other boot up messages.  Look for
23786 +lines that start with "gdb_hook_interrupt:".  You may want to use dmesg
23787 +once the system is up to view the log.  If this fails or if you still
23788 +don't connect, review your answers for the port address.  Use:
23789 +
23790 +setserial /dev/ttyS0
23791 +
23792 +to get the current port and IRQ information.  This command will also
23793 +tell you what the system found for the UART type. The stub recognizes
23794 +the following UART types:
23795 +
23796 +16450, 16550, and 16550A
23797 +
23798 +If you are really desperate you can use printk debugging in the
23799 +kgdbstub code in the target kernel until you get it working.  In particular,
23800 +there is a global variable in /usr/src/linux/arch/i386/kernel/kgdb_stub.c
23801 +named "remote_debug".  Compile your kernel with this set to 1, rather
23802 +than 0 and the debug stub will print out lots of stuff as it does
23803 +what it does.  Likewise there are debug printks in the kgdb_serial.c
23804 +code that can be turned on with simple changes in the macro defines.
23805 +
23806 +
23807 +Debugging Loadable Modules
23808 +==========================
23809 +
23810 +This technique comes courtesy of Edouard Parmelan
23811 +<Edouard.Parmelan@quadratec.fr>
23812 +
23813 +When you run gdb, enter the command
23814 +
23815 +source gdbinit-modules
23816 +
23817 +This will read in a file of gdb macros that was installed in your
23818 +kernel source directory when kgdb was installed.  This file implements
23819 +the following commands:
23820 +
23821 +mod-list
23822 +    Lists the loaded modules in the form <module-address> <module-name>
23823 +
23824 +mod-print-symbols <module-address>
23825 +    Prints all the symbols in the indicated module.
23826 +
23827 +mod-add-symbols <module-address> <object-file-path-name>
23828 +    Loads the symbols from the object file and associates them
23829 +    with the indicated module.
23830 +
23831 +After you have loaded the module that you want to debug, use the command
23832 +mod-list to find the <module-address> of your module.  Then use that
23833 +address in the mod-add-symbols command to load your module's symbols.
23834 +From that point onward you can debug your module as if it were a part
23835 +of the kernel.
23836 +
23837 +The file gdbinit-modules also contains a command named mod-add-lis as
23838 +an example of how to construct a command of your own to load your
23839 +favorite module.  The idea is to "can" the pathname of the module
23840 +in the command so you don't have to type so much.
23841 +
23842 +Threads
23843 +=======
23844 +
23845 +Each process in a target machine is seen as a gdb thread. gdb thread
23846 +related commands (info threads, thread n) can be used.
23847 +
23848 +ia-32 hardware breakpoints
23849 +==========================
23850 +
23851 +kgdb stub contains support for hardware breakpoints using debugging features
23852 +of ia-32(x86) processors. These breakpoints do not need code modification.
23853 +They use debugging registers. 4 hardware breakpoints are available in ia-32
23854 +processors.
23855 +
23856 +Each hardware breakpoint can be of one of the following three types.
23857 +
23858 +1. Execution breakpoint - An Execution breakpoint is triggered when code
23859 +       at the breakpoint address is executed.
23860 +
23861 +       As limited number of hardware breakpoints are available, it is
23862 +       advisable to use software breakpoints ( break command ) instead
23863 +       of execution hardware breakpoints, unless modification of code
23864 +       is to be avoided.
23865 +
23866 +2. Write breakpoint - A write breakpoint is triggered when memory
23867 +       location at the breakpoint address is written.
23868 +
23869 +       A write or can be placed for data of variable length. Length of
23870 +       a write breakpoint indicates length of the datatype to be
23871 +       watched. Length is 1 for 1 byte data , 2 for 2 byte data, 3 for
23872 +       4 byte data.
23873 +
23874 +3. Access breakpoint - An access breakpoint is triggered when memory
23875 +       location at the breakpoint address is either read or written.
23876 +
23877 +       Access breakpoints also have lengths similar to write breakpoints.
23878 +
23879 +IO breakpoints in ia-32 are not supported.
23880 +
23881 +Since gdb stub at present does not use the protocol used by gdb for hardware
23882 +breakpoints, hardware breakpoints are accessed through gdb macros. gdb macros
23883 +for hardware breakpoints are described below.
23884 +
23885 +hwebrk - Places an execution breakpoint
23886 +       hwebrk breakpointno address
23887 +hwwbrk - Places a write breakpoint
23888 +       hwwbrk breakpointno length address
23889 +hwabrk - Places an access breakpoint
23890 +       hwabrk breakpointno length address
23891 +hwrmbrk        - Removes a breakpoint
23892 +       hwrmbrk breakpointno
23893 +exinfo - Tells whether a software or hardware breakpoint has occurred.
23894 +       Prints number of the hardware breakpoint if a hardware breakpoint has
23895 +       occurred.
23896 +
23897 +Arguments required by these commands are as follows
23898 +breakpointno   - 0 to 3
23899 +length         - 1 to 3
23900 +address                - Memory location in hex digits ( without 0x ) e.g c015e9bc
23901 +
23902 +SMP support
23903 +==========
23904 +
23905 +When a breakpoint occurs or user issues a break ( Ctrl + C ) to gdb
23906 +client, all the processors are forced to enter the debugger. Current
23907 +thread corresponds to the thread running on the processor where
23908 +breakpoint occurred.  Threads running on other processor(s) appear
23909 +similar to other non-running threads in the 'info threads' output.
23910 +Within the kgdb stub there is a structure "waiting_cpus" in which kgdb
23911 +records the values of "current" and "regs" for each CPU other than the
23912 +one that hit the breakpoint.  "current" is a pointer to the task
23913 +structure for the task that CPU is running, while "regs" points to the
23914 +saved registers for the task.  This structure can be examined with the
23915 +gdb "p" command.
23916 +
23917 +ia-32 hardware debugging registers on all processors are set to same
23918 +values.  Hence any hardware breakpoints may occur on any processor.
23919 +
23920 +gdb troubleshooting
23921 +===================
23922 +
23923 +1. gdb hangs
23924 +Kill it. restart gdb. Connect to target machine.
23925 +
23926 +2. gdb cannot connect to target machine (after killing a gdb and
23927 +restarting another) If the target machine was not inside debugger when
23928 +you killed gdb, gdb cannot connect because the target machine won't
23929 +respond.  In this case echo "Ctrl+C"(ASCII 3) to the serial line.
23930 +e.g. echo -e "\003" > /dev/ttyS1
23931 +This forces that target machine into the debugger, after which you
23932 +can connect.
23933 +
23934 +3. gdb cannot connect even after echoing Ctrl+C into serial line
23935 +Try changing serial line settings min to 1 and time to 0
23936 +e.g. stty min 1 time 0 < /dev/ttyS1
23937 +Try echoing again
23938 +
23939 +Check serial line speed and set it to correct value if required
23940 +e.g. stty ispeed 115200 ospeed 115200 < /dev/ttyS1
23941 +
23942 +EVENTS
23943 +======
23944 +
23945 +Ever want to know the order of things happening?  Which CPU did what and
23946 +when?  How did the spinlock get the way it is?  Then events are for
23947 +you.  Events are defined by calls to an event collection interface and
23948 +saved for later examination.  In this case, kgdb events are saved by a
23949 +very fast bit of code in kgdb which is fully SMP and interrupt protected
23950 +and they are examined by using gdb to display them.  Kgdb keeps only
23951 +the last N events, where N must be a power of two and is defined at
23952 +configure time.
23953 +
23954 +
23955 +Events are signaled to kgdb by calling:
23956 +
23957 +kgdb_ts(data0,data1)
23958 +
23959 +For each call kgdb records each call in an array along with other info.
23960 +Here is the array definition:
23961 +
23962 +struct kgdb_and_then_struct {
23963 +#ifdef CONFIG_SMP
23964 +       int     on_cpu;
23965 +#endif
23966 +       long long at_time;
23967 +       int     from_ln;
23968 +       char    * in_src;
23969 +       void    *from;
23970 +        int     with_if;
23971 +       int     data0;
23972 +       int     data1;
23973 +};
23974 +
23975 +For SMP machines the CPU is recorded, for all machines the TSC is
23976 +recorded (gets a time stamp) as well as the line number and source file
23977 +the call was made from.  The address of the (from), the "if" (interrupt
23978 +flag) and the two data items are also recorded.  The macro kgdb_ts casts
23979 +the types to int, so you can put any 32-bit values here.  There is a
23980 +configure option to select the number of events you want to keep.  A
23981 +nice number might be 128, but you can keep up to 1024 if you want.  The
23982 +number must be a power of two.  An "andthen" macro library is provided
23983 +for gdb to help you look at these events.  It is also possible to define
23984 +a different structure for the event storage and cast the data to this
23985 +structure.  For example the following structure is defined in kgdb:
23986 +
23987 +struct kgdb_and_then_struct2 {
23988 +#ifdef CONFIG_SMP
23989 +       int     on_cpu;
23990 +#endif
23991 +       long long at_time;
23992 +       int     from_ln;
23993 +       char    * in_src;
23994 +       void    *from;
23995 +        int     with_if;
23996 +       struct task_struct *t1;
23997 +       struct task_struct *t2;
23998 +};
23999 +
24000 +If you use this for display, the data elements will be displayed as
24001 +pointers to task_struct entries.  You may want to define your own
24002 +structure to use in casting.  You should only change the last two items
24003 +and you must keep the structure size the same.  Kgdb will handle these
24004 +as 32-bit ints, but within that constraint you can define a structure to
24005 +cast to any 32-bit quantity.  This need only be available to gdb and is
24006 +only used for casting in the display code.
24007 +
24008 +Final Items
24009 +===========
24010 +
24011 +I picked up this code from Amit S. Kale and enhanced it.
24012 +
24013 +If you make some really cool modification to this stuff, or if you
24014 +fix a bug, please let me know.
24015 +
24016 +George Anzinger
24017 +<george@mvista.com>
24018 +
24019 +Amit S. Kale
24020 +<akale@veritas.com>
24021 +
24022 +(First kgdb by David Grothe <dave@gcom.com>)
24023 +
24024 +(modified by Tigran Aivazian <tigran@sco.com>)
24025 +    Putting gdbstub into the kernel config menu.
24026 +
24027 +(modified by Scott Foehner <sfoehner@engr.sgi.com>)
24028 +    Hooks for entering gdbstub at boot time.
24029 +
24030 +(modified by Amit S. Kale <akale@veritas.com>)
24031 +    Threads, ia-32 hw debugging, mp support, console support,
24032 +    nmi watchdog handling.
24033 +
24034 +(modified by George Anzinger <george@mvista.com>)
24035 +    Extended threads to include the idle threads.
24036 +    Enhancements to allow breakpoint() at first C code.
24037 +    Use of module_init() and __setup() to automate the configure.
24038 +    Enhanced the cpu "collection" code to work in early bring-up.
24039 +    Added ability to call functions from gdb
24040 +    Print info thread stuff without going back to schedule()
24041 +    Now collect the "other" cpus with an IPI/ NMI.
24042 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
24043 +++ 25/Documentation/i386/kgdb/loadmodule.sh    2003-10-05 00:33:38.000000000 -0700
24044 @@ -0,0 +1,78 @@
24045 +#/bin/sh
24046 +# This script loads a module on a target machine and generates a gdb script.
24047 +# source generated gdb script to load the module file at appropriate addresses
24048 +# in gdb.
24049 +#
24050 +# Usage:
24051 +# Loading the module on target machine and generating gdb script)
24052 +#      [foo]$ loadmodule.sh <modulename>
24053 +#
24054 +# Loading the module file into gdb
24055 +#      (gdb) source <gdbscriptpath>
24056 +#
24057 +# Modify following variables according to your setup.
24058 +#      TESTMACHINE - Name of the target machine
24059 +#      GDBSCRIPTS - The directory where a gdb script will be generated
24060 +#
24061 +# Author: Amit S. Kale (akale@veritas.com).
24062 +#
24063 +# If you run into problems, please check files pointed to by following
24064 +# variables.
24065 +#      ERRFILE - /tmp/<modulename>.errs contains stderr output of insmod
24066 +#      MAPFILE - /tmp/<modulename>.map contains stdout output of insmod
24067 +#      GDBSCRIPT - $GDBSCRIPTS/load<modulename> gdb script.
24068 +
24069 +TESTMACHINE=foo
24070 +GDBSCRIPTS=/home/bar
24071 +
24072 +if [ $# -lt 1 ] ; then {
24073 +       echo Usage: $0 modulefile
24074 +       exit
24075 +} ; fi
24076 +
24077 +MODULEFILE=$1
24078 +MODULEFILEBASENAME=`basename $1`
24079 +
24080 +if [ $MODULEFILE = $MODULEFILEBASENAME ] ; then {
24081 +       MODULEFILE=`pwd`/$MODULEFILE
24082 +} fi
24083 +
24084 +ERRFILE=/tmp/$MODULEFILEBASENAME.errs
24085 +MAPFILE=/tmp/$MODULEFILEBASENAME.map
24086 +GDBSCRIPT=$GDBSCRIPTS/load$MODULEFILEBASENAME
24087 +
24088 +function findaddr() {
24089 +       local ADDR=0x$(echo "$SEGMENTS" | \
24090 +               grep "$1" | sed 's/^[^ ]*[ ]*[^ ]*[ ]*//' | \
24091 +               sed 's/[ ]*[^ ]*$//')
24092 +       echo $ADDR
24093 +}
24094 +
24095 +function checkerrs() {
24096 +       if [ "`cat $ERRFILE`" != "" ] ; then {
24097 +               cat $ERRFILE
24098 +               exit
24099 +       } fi
24100 +}
24101 +
24102 +#load the module
24103 +echo Copying $MODULEFILE to $TESTMACHINE
24104 +rcp $MODULEFILE root@${TESTMACHINE}:
24105 +
24106 +echo Loading module $MODULEFILE
24107 +rsh -l root $TESTMACHINE  /sbin/insmod -m ./`basename $MODULEFILE` \
24108 +       > $MAPFILE 2> $ERRFILE
24109 +checkerrs
24110 +
24111 +SEGMENTS=`head -n 11 $MAPFILE | tail -n 10`
24112 +TEXTADDR=$(findaddr "\\.text[^.]")
24113 +LOADSTRING="add-symbol-file $MODULEFILE $TEXTADDR"
24114 +SEGADDRS=`echo "$SEGMENTS" | awk '//{
24115 +       if ($1 != ".text" && $1 != ".this" &&
24116 +           $1 != ".kstrtab" && $1 != ".kmodtab") {
24117 +               print " -s " $1 " 0x" $3 " "
24118 +       }
24119 +}'`
24120 +LOADSTRING="$LOADSTRING $SEGADDRS"
24121 +echo Generating script $GDBSCRIPT
24122 +echo $LOADSTRING > $GDBSCRIPT
24123 --- linux-2.6.0-test6/Documentation/ioctl-number.txt    2003-09-08 13:58:55.000000000 -0700
24124 +++ 25/Documentation/ioctl-number.txt   2003-10-05 00:33:23.000000000 -0700
24125 @@ -175,10 +175,6 @@ Code       Seq#    Include File            Comments
24126                                         <mailto:buk@buks.ipn.de>
24127  0xA0   all     linux/sdp/sdp.h         Industrial Device Project
24128                                         <mailto:kenji@bitgate.com>
24129 -0xA2    00-0F   DVD decoder driver      in development:
24130 -                                        <http://linuxtv.org/developer/dvdapi.html>
24131 -0xA3   00-1F   Philips SAA7146 dirver  in development:
24132 -                                       <mailto:Andreas.Beckmann@hamburg.sc.philips.com>
24133  0xA3   80-8F   Port ACL                in development:
24134                                         <mailto:tlewis@mindspring.com>
24135  0xA3   90-9F   linux/dtlk.h
24136 --- linux-2.6.0-test6/Documentation/iostats.txt 2003-06-14 12:18:06.000000000 -0700
24137 +++ 25/Documentation/iostats.txt        2003-10-05 00:33:23.000000000 -0700
24138 @@ -1,22 +1,22 @@
24139  I/O statistics fields
24140  ---------------
24141  
24142 -Last modified 5/15/03
24143 +Last modified Sep 30, 2003
24144  
24145 -In 2.4.20 (and some versions before, with patches), and 2.5.45,
24146 -more extensive disk statistics were introduced to help measure disk
24147 +Since 2.4.20 (and some versions before, with patches), and 2.5.45,
24148 +more extensive disk statistics have been introduced to help measure disk
24149  activity. Tools such as sar and iostat typically interpret these and do
24150  the work for you, but in case you are interested in creating your own
24151  tools, the fields are explained here.
24152  
24153 -In most versions of the 2.4 patch, the information is found as additional
24154 -fields in /proc/partitions.  In 2.5, the same information is found in
24155 -two places: one is in the file /proc/diskstats (appears in 2.5.69 and
24156 -beyond), and the other is within the sysfs file system, which must be
24157 -mounted in order to obtain the information. Throughout this document
24158 -we'll assume that sysfs is mounted on /sys, although of course it may
24159 -be mounted anywhere.  In 2.5, both /proc/diskstats and sysfs use the
24160 -same source for the information and so should not differ.
24161 +In 2.4 now, the information is found as additional fields in
24162 +/proc/partitions.  In 2.6, the same information is found in two
24163 +places: one is in the file /proc/diskstats, and the other is within
24164 +the sysfs file system, which must be mounted in order to obtain
24165 +the information. Throughout this document we'll assume that sysfs
24166 +is mounted on /sys, although of course it may be mounted anywhere.
24167 +Both /proc/diskstats and sysfs use the same source for the information
24168 +and so should not differ.
24169  
24170  Here are examples of these different formats:
24171  
24172 @@ -25,15 +25,15 @@ Here are examples of these different for
24173     3     1    9221278 hda1 35486 0 35496 38030 0 0 0 0 0 38030 38030
24174  
24175  
24176 -2.5 sysfs:
24177 +2.6 sysfs:
24178     446216 784926 9550688 4382310 424847 312726 5922052 19310380 0 3376340 23705160
24179     35486    38030    38030    38030
24180  
24181 -2.5 diskstats:
24182 +2.6 diskstats:
24183     3    0   hda 446216 784926 9550688 4382310 424847 312726 5922052 19310380 0 3376340 23705160
24184     3    1   hda1 35486 38030 38030 38030
24185  
24186 -On 2.4 you might execute "grep 'hda ' /proc/partitions". On 2.5, you have
24187 +On 2.4 you might execute "grep 'hda ' /proc/partitions". On 2.6, you have
24188  a choice of "cat /sys/block/hda/stat" or "grep 'hda ' /proc/diskstats".
24189  The advantage of one over the other is that the sysfs choice works well
24190  if you are watching a known, small set of disks.  /proc/diskstats may
24191 @@ -43,7 +43,7 @@ each snapshot of your disk statistics.
24192  
24193  In 2.4, the statistics fields are those after the device name. In
24194  the above example, the first field of statistics would be 446216.
24195 -By contrast, in 2.5 if you look at /sys/block/hda/stat, you'll
24196 +By contrast, in 2.6 if you look at /sys/block/hda/stat, you'll
24197  find just the eleven fields, beginning with 446216.  If you look at
24198  /proc/diskstats, the eleven fields will be preceded by the major and
24199  minor device numbers, and device name.  Each of these formats provide
24200 @@ -93,35 +93,35 @@ Field 11 -- weighted # of milliseconds s
24201  To avoid introducing performance bottlenecks, no locks are held while
24202  modifying these counters.  This implies that minor inaccuracies may be
24203  introduced when changes collide, so (for instance) adding up all the
24204 -read I/Os issued per partition should equal those made to the disks
24205 -... but due to the lack of locking it may only be very close.
24206 +read I/Os issued per partition should equal those made to the disks ...
24207 +but due to the lack of locking it may only be very close.
24208  
24209 -In release 2.5.65 the 2.5 counters were made per-cpu, which made the lack
24210 -of locking almost a non-issue.  When the statistics are read, the per-cpu
24211 -counters are summed (possibly overflowing the unsigned 32-bit variable
24212 -they are summed to) and the result given to the user.  There is no
24213 -convenient user interface for accessing the per-cpu counters themselves.
24214 +In 2.6, there are counters for each cpu, which made the lack of locking
24215 +almost a non-issue.  When the statistics are read, the per-cpu counters
24216 +are summed (possibly overflowing the unsigned 32-bit variable they are
24217 +summed to) and the result given to the user.  There is no convenient
24218 +user interface for accessing the per-cpu counters themselves.
24219  
24220  Disks vs Partitions
24221  -------------------
24222  
24223 -There were significant changes between 2.4 and 2.5 in the I/O subsystem.
24224 +There were significant changes between 2.4 and 2.6 in the I/O subsystem.
24225  As a result, some statistic information disappeared. The translation from
24226  a disk address relative to a partition to the disk address relative to
24227  the host disk happens much earlier.  All merges and timings now happen
24228  at the disk level rather than at both the disk and partition level as
24229 -in 2.4.  Consequently, you'll see a different statistics output on 2.5 for
24230 +in 2.4.  Consequently, you'll see a different statistics output on 2.6 for
24231  partitions from that for disks.  There are only *four* fields available
24232 -for partitions on 2.5 machines.  This is reflected in the examples above.
24233 +for partitions on 2.6 machines.  This is reflected in the examples above.
24234  
24235  Field  1 -- # of reads issued
24236      This is the total number of reads issued to this partition.
24237  Field  2 -- # of sectors read
24238      This is the total number of sectors requested to be read from this
24239      partition.
24240 -Field  3 -- # of reads issued
24241 +Field  3 -- # of writes issued
24242      This is the total number of writes issued to this partition.
24243 -Field  4 -- # of sectors read
24244 +Field  4 -- # of sectors written
24245      This is the total number of sectors requested to be written to
24246      this partition.
24247  
24248 @@ -135,14 +135,16 @@ a subtle distinction that is probably un
24249  Additional notes
24250  ----------------
24251  
24252 -In 2.5, sysfs is not mounted by default.  Here's the line you'll want
24253 -to add to your /etc/fstab:
24254 +In 2.6, sysfs is not mounted by default.  If your distribution of
24255 +Linux hasn't added it already, here's the line you'll want to add to
24256 +your /etc/fstab:
24257  
24258  none /sys sysfs defaults 0 0
24259  
24260  
24261 -In 2.5, at the same time that disk statistics appeared in sysfs, they were
24262 -removed from /proc/stat.  In 2.4, they appear in both /proc/partitions
24263 -and /proc/stat.
24264 +In 2.6, all disk statistics were removed from /proc/stat.  In 2.4, they
24265 +appear in both /proc/partitions and /proc/stat, although the ones in
24266 +/proc/stat take a very different format from those in /proc/partitions
24267 +(see proc(5), if your system has it.)
24268  
24269  -- ricklind@us.ibm.com
24270 --- linux-2.6.0-test6/Documentation/kernel-parameters.txt       2003-09-27 18:57:43.000000000 -0700
24271 +++ 25/Documentation/kernel-parameters.txt      2003-10-05 00:34:33.000000000 -0700
24272 @@ -460,6 +460,10 @@ running once the system is up.
24273         logibm_irq=     [HW,MOUSE] Logitech Bus Mouse Driver
24274                         Format: <irq>
24275  
24276 +       log_buf_len=n   Sets the size of the printk ring buffer, in bytes.
24277 +                       Format is n, nk, nM.  n must be a power of two.  The
24278 +                       default is set in kernel config.
24279 +
24280         lp=0            [LP]    Specify parallel ports to use, e.g,
24281         lp=port[,port...]       lp=none,parport0 (lp0 not configured, lp1 uses
24282         lp=reset                first parallel port). 'lp=0' disables the
24283 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
24284 +++ 25/Documentation/MSI-HOWTO.txt      2003-10-05 00:36:20.000000000 -0700
24285 @@ -0,0 +1,321 @@
24286 +               The MSI Driver Guide HOWTO
24287 +       Tom L Nguyen tom.l.nguyen@intel.com
24288 +                       10/03/2003
24289 +
24290 +1. About this guide
24291 +
24292 +This guide describes the basics of Message Signaled Interrupts(MSI), the
24293 +advantages of using MSI over traditional interrupt mechanisms, and how
24294 +to enable your driver to use MSI or MSI-X. Also included is a Frequently
24295 +Asked Questions.
24296 +
24297 +2. Copyright 2003 Intel Corporation
24298 +
24299 +3. What is MSI/MSI-X?
24300 +
24301 +Message Signaled Interrupt (MSI), as described in the PCI Local Bus
24302 +Specification Revision 2.3 or latest, is an optional feature, and a
24303 +required feature for PCI Express devices. MSI enables a device function
24304 +to request service by sending an Inbound Memory Write on its PCI bus to
24305 +the FSB as a Message Signal Interrupt transaction. Because MSI is
24306 +generated in the form of a Memory Write, all transaction conditions,
24307 +such as a Retry, Master-Abort, Target-Abort or normal completion, are
24308 +supported.
24309 +
24310 +A PCI device that supports MSI must also support pin IRQ assertion
24311 +interrupt mechanism to provide backward compatibility for systems that
24312 +do not support MSI. In Systems, which support MSI, the bus driver is
24313 +responsible for initializing the message address and message data of
24314 +the device function's MSI/MSI-X capability structure during device
24315 +initial configuration.
24316 +
24317 +An MSI capable device function indicates MSI support by implementing
24318 +the MSI/MSI-X capability structure in its PCI capability list. The
24319 +device function may implement both the MSI capability structure and
24320 +the MSI-X capability structure; however, the bus driver should not
24321 +enable both, but instead enable only the MSI-X capability structure.
24322 +
24323 +The MSI capability structure contains Message Control register,
24324 +Message Address register and Message Data register. These registers
24325 +provide the bus driver control over MSI. The Message Control register
24326 +indicates the MSI capability supported by the device. The Message
24327 +Address register specifies the target address and the Message Data
24328 +register specifies the characteristics of the message. To request
24329 +service, the device function writes the content of the Message Data
24330 +register to the target address. The device and its software driver
24331 +are prohibited from writing to these registers.
24332 +
24333 +The MSI-X capability structure is an optional extension to MSI. It
24334 +uses an independent and separate capability structure. There are
24335 +some key advantages to implementing the MSI-X capability structure
24336 +over the MSI capability structure as described below.
24337 +
24338 +       - Support a larger maximum number of vectors per function.
24339 +
24340 +       - Provide the ability for system software to configure
24341 +       each vector with an independent message address and message
24342 +       data, specified by a table that resides in Memory Space.
24343 +
24344 +        - MSI and MSI-X both support per-vector masking. Per-vector
24345 +       masking is an optional extension of MSI but a required
24346 +       feature for MSI-X. Per-vector masking provides the kernel
24347 +       the ability to mask/unmask MSI when servicing its software
24348 +       interrupt service routing handler. If per-vector masking is
24349 +       not supported, then the device driver should provide the
24350 +       hardware/software synchronization to ensure that the device
24351 +       generates MSI when the driver wants it to do so.
24352 +
24353 +4. Why use MSI?
24354 +
24355 +As a benefit the simplification of board design, MSI allows board
24356 +designers to remove out of band interrupt routing. MSI is another
24357 +step towards a legacy-free environment.
24358 +
24359 +Due to increasing pressure on chipset and processor packages to
24360 +reduce pin count, the need for interrupt pins is expected to
24361 +diminish over time. Devices, due to pin constraints, may implement
24362 +messages to increase performance.
24363 +
24364 +PCI Express endpoints uses INTx emulation (in-band messages) instead
24365 +of IRQ pin assertion. Using INTx emulation requires interrupt
24366 +sharing among devices connected to the same node (PCI bridge) while
24367 +MSI is unique (non-shared) and does not require BIOS configuration
24368 +support. As a result, the PCI Express technology requires MSI
24369 +support for better interrupt performance.
24370 +
24371 +Using MSI enables the device functions to support two or more
24372 +vectors, which can be configure to target different CPU's to
24373 +increase scalability.
24374 +
24375 +5. Configuring a driver to use MSI/MSI-X
24376 +
24377 +By default, the kernel will not enable MSI/MSI-X on all devices that
24378 +support this capability once the patch is installed. A kernel
24379 +configuration option must be selected to enable MSI/MSI-X support.
24380 +
24381 +5.1 Including MSI support into the kernel
24382 +
24383 +To include MSI support into the kernel requires users to patch the
24384 +VECTOR-base patch first and then the MSI patch because the MSI
24385 +support needs VECTOR based scheme. Once these patches are installed,
24386 +setting CONFIG_PCI_USE_VECTOR enables the VECTOR based scheme and
24387 +the option for MSI-capable device drivers to selectively enable MSI
24388 +(using pci_enable_msi as desribed below).
24389 +
24390 +Since the target of the inbound message is the local APIC, providing
24391 +CONFIG_PCI_USE_VECTOR is dependent on whether CONFIG_X86_LOCAL_APIC
24392 +is enabled or not.
24393 +
24394 +int pci_enable_msi(struct pci_dev *)
24395 +
24396 +With this new API, any existing device driver, which like to have
24397 +MSI enabled on its device function, must call this explicitly. A
24398 +successful call will initialize the MSI/MSI-X capability structure
24399 +with ONE vector, regardless of whether the device function is
24400 +capable of supporting multiple messages. This vector replaces the
24401 +pre-assigned dev->irq with a new MSI vector. To avoid the conflict
24402 +of new assigned vector with existing pre-assigned vector requires
24403 +the device driver to call this API before calling request_irq(...).
24404 +
24405 +The below diagram shows the events, which switches the interrupt
24406 +mode on the MSI-capable device function between MSI mode and
24407 +PIN-IRQ assertion mode.
24408 +
24409 +        ------------   pci_enable_msi   ------------------------
24410 +       |            | <=============== |                        |
24411 +       | MSI MODE   |                  | PIN-IRQ ASSERTION MODE |
24412 +       |            | ===============> |                        |
24413 +        ------------   free_irq         ------------------------
24414 +
24415 +5.2 Configuring for MSI support
24416 +
24417 +Due to the non-contiguous fashion in vector assignment of the
24418 +existing Linux kernel, this patch does not support multiple
24419 +messages regardless of the device function is capable of supporting
24420 +more than one vector. The bus driver initializes only entry 0 of
24421 +this capability if pci_enable_msi(...) is called successfully by
24422 +the device driver.
24423 +
24424 +5.3 Configuring for MSI-X support
24425 +
24426 +Both the MSI capability structure and the MSI-X capability structure
24427 +share the same above semantics; however, due to the ability of the
24428 +system software to configure each vector of the MSI-X capability
24429 +structure with an independent message address and message data, the
24430 +non-contiguous fashion in vector assignment of the existing Linux
24431 +kernel has no impact on supporting multiple messages on an MSI-X
24432 +capable device functions. By default, as mentioned above, ONE vector
24433 +should be always allocated to the MSI-X capability structure at
24434 +entry 0. The bus driver does not initialize other entries of the
24435 +MSI-X table.
24436 +
24437 +Note that the PCI subsystem should have full control of a MSI-X
24438 +table that resides in Memory Space. The software device driver
24439 +should not access this table.
24440 +
24441 +To request for additional vectors, the device software driver should
24442 +call function msi_alloc_vectors(). It is recommended that the
24443 +software driver should call this function once during the
24444 +initialization phase of the device driver.
24445 +
24446 +The function msi_alloc_vectors(), once invoked, enables either
24447 +all or nothing, depending on the current availability of vector
24448 +resources. If no vector resources are available, the device function
24449 +still works with ONE vector. If the vector resources are available
24450 +for the number of vectors requested by the driver, this function
24451 +will reconfigure the MSI-X capability structure of the device with
24452 +additional messages, starting from entry 1. To emphasize this
24453 +reason, for example, the device may be capable for supporting the
24454 +maximum of 32 vectors while its software driver usually may request
24455 +4 vectors.
24456 +
24457 +For each vector, after this successful call, the device driver is
24458 +responsible to call other functions like request_irq(), enable_irq(),
24459 +etc. to enable this vector with its corresponding interrupt service
24460 +handler. It is the device driver's choice to have all vectors shared
24461 +the same interrupt service handler or each vector with a unique
24462 +interrupt service handler.
24463 +
24464 +In addition to the function msi_alloc_vectors(), another function
24465 +msi_free_vectors() is provided to allow the software driver to
24466 +release a number of vectors back to the vector resources. Once
24467 +invoked, the PCI subsystem disables (masks) each vector released.
24468 +These vectors are no longer valid for the hardware device and its
24469 +software driver to use. Like free_irq, it recommends that the
24470 +device driver should also call msi_free_vectors to release all
24471 +additional vectors previously requested.
24472 +
24473 +int msi_alloc_vectors(struct pci_dev *dev, int *vector, int nvec)
24474 +
24475 +This API enables the software driver to request the PCI subsystem
24476 +for additional messages. Depending on the number of vectors
24477 +available, the PCI subsystem enables either all or nothing.
24478 +
24479 +Argument dev points to the device (pci_dev) structure.
24480 +Argument vector is a pointer of integer type. The number of
24481 +elements is indicated in argument nvec.
24482 +Argument nvec is an integer indicating the number of messages
24483 +requested.
24484 +A return of zero indicates that the number of allocated vector is
24485 +successfully allocated. Otherwise, indicate resources not
24486 +available.
24487 +
24488 +int msi_free_vectors(struct pci_dev* dev, int *vector, int nvec)
24489 +
24490 +This API enables the software driver to inform the PCI subsystem
24491 +that it is willing to release a number of vectors back to the
24492 +MSI resource pool. Once invoked, the PCI subsystem disables each
24493 +MSI-X entry associated with each vector stored in the argument 2.
24494 +These vectors are no longer valid for the hardware device and
24495 +its software driver to use.
24496 +
24497 +Argument dev points to the device (pci_dev) structure.
24498 +Argument vector is a pointer of integer type. The number of
24499 +elements is indicated in argument nvec.
24500 +Argument nvec is an integer indicating the number of messages
24501 +released.
24502 +A return of zero indicates that the number of allocated vectors
24503 +is successfully released. Otherwise, indicates a failure.
24504 +
24505 +5.4 Hardware requirements for MSI support
24506 +MSI support requires support from both system hardware and
24507 +individual hardware device functions.
24508 +
24509 +5.4.1 System hardware support
24510 +Since the target of MSI address is the local APIC CPU, enabling
24511 +MSI support in Linux kernel is dependent on whether existing
24512 +system hardware supports local APIC. Users should verify their
24513 +system whether it runs when CONFIG_X86_LOCAL_APIC=y.
24514 +
24515 +In SMP environment, CONFIG_X86_LOCAL_APIC is automatically set;
24516 +however, in UP environment, users must manually set
24517 +CONFIG_X86_LOCAL_APIC. Once CONFIG_X86_LOCAL_APIC=y, setting
24518 +CONFIG_PCI_USE_VECTOR enables the VECTOR based scheme and
24519 +the option for MSI-capable device drivers to selectively enable
24520 +MSI (using pci_enable_msi as desribed below).
24521 +
24522 +Note that CONFIG_X86_IO_APIC setting is irrelevant because MSI
24523 +vector is allocated new during runtime and MSI support does not
24524 +depend on BIOS support. This key independency enables MSI support
24525 +on future IOxAPIC free platform.
24526 +
24527 +5.4.2 Device hardware support
24528 +The hardware device function supports MSI by indicating the
24529 +MSI/MSI-X capability structure on its PCI capability list. By
24530 +default, this capability structure will not be initialized by
24531 +the kernel to enable MSI during the system boot. In other words,
24532 +the device function is running on its default pin assertion mode.
24533 +Note that in many cases the hardware supporting MSI have bugs,
24534 +which may result in system hang. The software driver of specific
24535 +MSI-capable hardware is responsible for whether calling
24536 +pci_enable_msi or not. A return of zero indicates the kernel
24537 +successfully initializes the MSI/MSI-X capability structure of the
24538 +device funtion. The device function is now running on MSI mode.
24539 +
24540 +5.5 How to tell whether MSI is enabled on device function
24541 +
24542 +At the driver level, a return of zero from pci_enable_msi(...)
24543 +indicates to the device driver that its device function is
24544 +initialized successfully and ready to run in MSI mode.
24545 +
24546 +At the user level, users can use command 'cat /proc/interrupts'
24547 +to display the vector allocated for the device and its interrupt
24548 +mode, as shown below.
24549 +
24550 +           CPU0       CPU1
24551 +  0:     324639          0    IO-APIC-edge  timer
24552 +  1:       1186          0    IO-APIC-edge  i8042
24553 +  2:          0          0          XT-PIC  cascade
24554 + 12:       2797          0    IO-APIC-edge  i8042
24555 + 14:       6543          0    IO-APIC-edge  ide0
24556 + 15:          1          0    IO-APIC-edge  ide1
24557 +169:          0          0   IO-APIC-level  uhci-hcd
24558 +185:          0          0   IO-APIC-level  uhci-hcd
24559 +193:        138         10         PCI MSI  aic79xx
24560 +201:         30          0         PCI MSI  aic79xx
24561 +225:         30          0   IO-APIC-level  aic7xxx
24562 +233:         30          0   IO-APIC-level  aic7xxx
24563 +NMI:          0          0
24564 +LOC:     324553     325068
24565 +ERR:          0
24566 +MIS:          0
24567 +
24568 +6. FAQ
24569 +
24570 +Q1. Are there any limitations on using the MSI?
24571 +
24572 +A1. If the PCI device supports MSI and conforms to the
24573 +specification and the platform supports the APIC local bus,
24574 +then using MSI should work.
24575 +
24576 +Q2. Will it work on all the Pentium processors (P3, P4, Xeon,
24577 +AMD processors)? In P3 IPI's are transmitted on the APIC local
24578 +bus and in P4 and Xeon they are transmitted on the system
24579 +bus. Are there any implications with this?
24580 +
24581 +A2. MSI support enables a PCI device sending an inbound
24582 +memory write (0xfeexxxxx as target address) on its PCI bus
24583 +directly to the FSB. Since the message address has a
24584 +redirection hint bit cleared, it should work.
24585 +
24586 +Q3. The target address 0xfeexxxxx will be translated by the
24587 +Host Bridge into an interrupt message. Are there any
24588 +limitations on the chipsets such as Intel 8xx, Intel e7xxx,
24589 +or VIA?
24590 +
24591 +A3. If these chipsets support an inbound memory write with
24592 +target address set as 0xfeexxxxx, as conformed to PCI
24593 +specification 2.3 or latest, then it should work.
24594 +
24595 +Q4. From the driver point of view, if the MSI is lost because
24596 +of the errors occur during inbound memory write, then it may
24597 +wait for ever. Is there a mechanism for it to recover?
24598 +
24599 +A4. Since the target of the transaction is an inbound memory
24600 +write, all transaction termination conditions (Retry,
24601 +Master-Abort, Target-Abort, or normal completion) are
24602 +supported. A device sending an MSI must abide by all the PCI
24603 +rules and conditions regarding that inbound memory write. So,
24604 +if a retry is signaled it must retry, etc... We believe that
24605 +the recommendation for Abort is also a retry (refer to PCI
24606 +specification 2.3 or latest).
24607 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
24608 +++ 25/Documentation/must-fix.txt       2003-10-05 00:33:51.000000000 -0700
24609 @@ -0,0 +1,354 @@
24610 +
24611 +Must-fix bugs
24612 +=============
24613 +
24614 +drivers/char/
24615 +~~~~~~~~~~~~~
24616 +
24617 +o TTY locking is broken.
24618 +
24619 +  o see FIXME in do_tty_hangup().  This causes ppp BUGs in local_bh_enable()
24620 +
24621 +  o Other problems: aviro, dipankar, Alan have details.
24622 +
24623 +  o somebody will have to document the tty driver and ldisc API
24624 +
24625 +o Lack of test cases and/or stress tests is a problem.  Contributions and
24626 +  suggestions are sought.
24627 +
24628 +o Lots of drivers are using cli/sti and are broken.
24629 +
24630 +drivers/tty
24631 +~~~~~~~~~~~
24632 +
24633 +o viro: we need to fix refcounting for tty_driver (oopsable race, must fix
24634 +  anyway, hopefully about a week until it's merged) then we can do
24635 +  tty/misc/upper levels of sound.
24636 +
24637 +drivers/block/
24638 +~~~~~~~~~~~~~~
24639 +
24640 +o ideraid hasn't been ported to 2.5 at all yet.
24641 +
24642 +  We need to understand whether the proposed BIO split code will suffice
24643 +  for this.
24644 +
24645 +o CD burning.  There are still a few quirks to solve wrt SG_IO and ide-cd.
24646 +
24647 +  Jens: The basic hang has been solved (double fault in ide-cd), there still
24648 +  seems to be some cases that don't work too well.  Don't really have a
24649 +  handle on those :/
24650 +
24651 +o lmb: Last time I looked at the multipath code (2.5.50 or so) it also
24652 +  looked pretty broken; I plan to port forward the changes we did on 2.4
24653 +  before KS.
24654 +
24655 +drivers/input/
24656 +~~~~~~~~~~~~~~
24657 +
24658 +o rmk: unconverted keyboard/mouse drivers (there's a deadline of 2.6.0
24659 +  currently on these remaining in my/Linus' tree.)
24660 +
24661 +o viro: large absence of locking.
24662 +
24663 +o viro: parport is nearly as bad as that and there the code is more hairy. 
24664 +  IMO parport is more of "figure out what API changes are needed for its
24665 +  users, get them done ASAP, then fix generic layer at leisure"
24666 +
24667 +o (Albert Cahalan) Lots of people (check Google) get this message from the
24668 +  kernel:
24669 +
24670 +  psmouse.c: Lost synchronization, throwing 2 bytes away.
24671 +
24672 +  (the number of bytes will be 1, 2, or 3)
24673 +
24674 +  At work, I get it when there is heavy NFS traffic.  The mouse goes crazy,
24675 +  jumping around and doing random cut-and-paste all over everything.  This
24676 +  is with a decently fast and modern PC.
24677 +
24678 +o There seem to be too many reports of keyboards and mice failing or acting
24679 +  strangely.
24680 +
24681 +
24682 +drivers/misc/
24683 +~~~~~~~~~~~~~
24684 +
24685 +o rmk: UCB1[23]00 drivers, currently sitting in drivers/misc in the ARM
24686 +  tree.  (touchscreen, audio, gpio, type device.)
24687 +
24688 +  These need to be moved out of drivers/misc/ and into real places
24689 +
24690 +o viro: actually, misc.c has a good chance to die.  With cdev-cidr that's
24691 +  trivial.
24692 +
24693 +drivers/net/
24694 +~~~~~~~~~~~~
24695 +
24696 +o rmk: network drivers.  ARM people like to add tonnes of #ifdefs into
24697 +  these to customise them to their hardware platform (eg, chip access
24698 +  methods, addresses, etc.) I cope with this by not integrating them into my
24699 +  tree.  The result is that many ARM platforms can't be built from even my
24700 +  tree without extra patches.  This isn't sane, and has bred a culture of
24701 +  network drivers not being submitted.  I don't see this changing for 2.6
24702 +  though.
24703 +
24704 +drivers/net/irda/
24705 +~~~~~~~~~~~~~~~~~
24706 +
24707 +o dongle drivers need to be converted to sir-dev
24708 +
24709 +o irport need to be converted to sir-kthread
24710 +
24711 +o new drivers (irtty-sir/smsc-ircc2/donauboe) need more testing
24712 +
24713 +o rmk: Refuse IrDA initialisation if sizeof(structures) is incorrect (I'm
24714 +  not sure if we still need this; I think gcc 2.95.3 on ARM shows this
24715 +  problem though.)
24716 +
24717 +drivers/pci/
24718 +~~~~~~~~~~~~
24719 +
24720 +o alan: Some cardbus crashes the system
24721 +
24722 +  (bugzilla, please?)
24723 +
24724 +drivers/pcmcia/
24725 +~~~~~~~~~~~~~~~
24726 +
24727 +o alan: This is a locking disaster.
24728 +
24729 +  (rmk, brodo: in progress)
24730 +
24731 +drivers/pld/
24732 +~~~~~~~~~~~~
24733 +
24734 +o rmk: EPXA (ARM platform) PLD hotswap drivers (drivers/pld)
24735 +
24736 +  (rmk: will work out what to do here.  maybe drivers/arm/)
24737 +
24738 +drivers/video/
24739 +~~~~~~~~~~~~~~
24740 +
24741 +o Lots of drivers don't compile, others do but don't work.
24742 +
24743 +drivers/scsi/
24744 +~~~~~~~~~~~~~
24745 +
24746 +o hch: large parts of the locking are hosed or not existant
24747 +
24748 +  (Mike Anderson, Patrick Mansfield, Badari Pulavarty)
24749 +
24750 +  o shost->my_devices isn't locked down at all
24751 +
24752 +  o there are lots of members of struct Scsi_Host/scsi_device/scsi_cmnd
24753 +    with very unclear locking, many of them probably want to become
24754 +    atomic_t's or bitmaps (for the 1bit bitfields).
24755 +
24756 +  o there's lots of volatile abuse in the scsi code that needs to be
24757 +    thought about.
24758 +
24759 +  o there's some global variables incremented without any locks
24760 +
24761 +o Convert am53c974, dpt_i2o, initio and pci2220i to DMA-mapping
24762 +
24763 +o Make inia100, cpqfc, pci2000 and dc390t compile
24764 +
24765 +o Convert
24766 +
24767 +   wd33c99 based: a2091 a3000 gpv11 mvme174 sgiwd93
24768 +
24769 +   53c7xx based: amiga7xxx bvme6000 mvme16x initio am53c974 pci2000
24770 +   pci2220i dc390t
24771 +
24772 +  To new error handling
24773 +
24774 +  It also might be possible to shift the 53c7xx based drivers over to
24775 +  53c700 which does the new EH stuff, but I don't have the hardware to check
24776 +  such a shift.
24777 +
24778 +  For the non-compiling stuff, I've probably missed a few that just aren't
24779 +  compilable on my platforms, so any updates would be welcome.  Also, are
24780 +  some of our non-compiling or unconverted drivers obsolete?
24781 +
24782 +o rmk: I have a pending todo: I need to put the scsi error handling through
24783 +  a workout on my scsi bus from hell to make sure it does the right thing
24784 +  and doesn't get wedged.
24785 +
24786 +o James B: USB hot-removal crash: "It's a known scsi refcounting issue."
24787 +
24788 +fs/
24789 +~~~
24790 +
24791 +o AIO/direct-IO writes can race with truncate and wreck filesystems.
24792 +  (Badari has a patch)
24793 +
24794 +o hch: devfs: there's a fundamental lookup vs devfsd race that's only
24795 +  fixable by introducing a lookup vs devfs deadlock.  I can't see how this is
24796 +  fixable without getting rid of the current devfsd design.  Mandrake seems
24797 +  to have a workaround for this so this is at least not triggered so easily,
24798 +  but that's not what I'd consider a fix..
24799 +
24800 +o viro: fs/char_dev.c needs removal of aeb stuff and merge of cdev-cidr. 
24801 +  In progress.
24802 +
24803 +o forward-port sct's O_DIRECT fixes (Badari has a patch)
24804 +
24805 +o viro: there is some generic stuff for namei/namespace/super, but that's a
24806 +  slow-merge and can go in 2.6 just fine
24807 +
24808 +o andi: also soft needs to be fixed - there are quite a lot of
24809 +  uninterruptible waits in sunrpc/nfs
24810 +
24811 +o trond: NFS has a mmap-versus-truncate problem
24812 +
24813 +kernel/sched.c
24814 +~~~~~~~~~~~~~~
24815 +
24816 +o Starvation, general interactivity need close monitoring.
24817 +
24818 +kernel/
24819 +~~~~~~~
24820 +
24821 +o Alan: 32bit uid support is *still* broken for process accounting.
24822 +
24823 +  Create a 32bit uid, turn accounting on.  Shock horror it doesn't work
24824 +  because the field is 16bit.  We need an acct structure flag day for 2.6
24825 +  IMHO
24826 +
24827 +  (alan has patch)
24828 +
24829 +o viro: core sysctl code is racy.  And its interaction wiuth sysfs
24830 +
24831 +o (ingo) rwsems (on x86) are limited to 32766 waiting processes.  This
24832 +  means that setting pid_max to above 32K is unsafe :-(
24833 +
24834 +  An option is to use CONFIG_RWSEM_GENERIC_SPINLOCK variant all the time,
24835 +  for all archs, and not inline any part of the ops.
24836 +
24837 +lib/kobject.c
24838 +~~~~~~~~~~~~~
24839 +
24840 +o kobject refcounting (comments from Al Viro):
24841 +
24842 +  _anything_ can grab a temporary reference to kobject.  IOW, if kobject is
24843 +  embedded into something that could be freed - it _MUST_ have a destructor
24844 +  and that destructor _MUST_ be the destructor for containing object.
24845 +
24846 +  Any violation of the above (and we already have a bunch of those) is a
24847 +  user-triggerable memory corruption.
24848 +
24849 +  We can tolerate it for a while in 2.5 (e.g.  during work on susbsystem we
24850 +  can decide to switch to that way of handling objects and have subsystem
24851 +  vulnerable for a while), but all such windows must be closed before 2.6
24852 +  and during 2.6 we can't open them at all.
24853 +
24854 +o All block drivers which control multiple gendisks with a single
24855 +  request_queue are broken, due to one-to-one assumptions in the request
24856 +  queue sysfs hookup.
24857 +
24858 +mm/
24859 +~~~
24860 +
24861 +o GFP_DMA32 (or something like that).  Lots of ideas.  jejb, zaitcev,
24862 +  willy, arjan, wli.
24863 +
24864 +  Specifically, 64-bit systems need to be able to enforce 32-bit addressing
24865 +  limits for device metadata like network cards' ring buffers and SCSI
24866 +  command descriptors.
24867 +
24868 +o access_process_vm() doesn't flush right.  We probably need new flushing
24869 +  primitives to do this (davem?)
24870 +
24871 +
24872 +modules
24873 +~~~~~~~
24874 +
24875 +  (Rusty)
24876 +
24877 +net/
24878 +~~~~
24879 +
24880 +  (davem)
24881 +
24882 +o UDP apps can in theory deadlock, because the ip_append_data path can end
24883 +  up sleeping while the socket lock is held.
24884 +
24885 +  It is OK to sleep with the socket held held, normally.  But in this case
24886 +  the sleep happens while waiting for socket memory/space to become
24887 +  available, if another context needs to take the socket lock to free up the
24888 +  space we could hang.
24889 +
24890 +  I sent a rough patch on how to fix this to Alexey, and he is analyzing
24891 +  the situation.  I expect a final fix from him next week or so.
24892 +
24893 +o Semantics for IPSEC during operations such as TCP connect suck currently.
24894 +
24895 +  When we first try to connect to a destination, we may need to ask the
24896 +  IPSEC key management daemon to resolve the IPSEC routes for us.  For the
24897 +  purposes of what the kernel needs to do, you can think of it like ARP.  We
24898 +  can't send the packet out properly until we resolve the path.
24899 +
24900 +  What happens now for IPSEC is basically this:
24901 +
24902 +  O_NONBLOCK: returns -EAGAIN over and over until route is resolved
24903 +
24904 +  !O_NONBLOCK: Sleeps until route is resolved
24905 +
24906 +  These semantics are total crap.  The solution, which Alexey is working
24907 +  on, is to allow incomplete routes to exist.  These "incomplete" routes
24908 +  merely put the packet onto a "resolution queue", and once the key manager
24909 +  does it's thing we finish the output of the packet.  This is precisely how
24910 +  ARP works.
24911 +
24912 +  I don't know when Alexey will be done with this.
24913 +
24914 +net/*/netfilter/
24915 +~~~~~~~~~~~~~~~~
24916 +
24917 +  (Rusty)
24918 +
24919 +o Rework conntrack hashing.
24920 +
24921 +o Module relationship bogosity fix (trivial, have patch).
24922 +
24923 +sound/
24924 +~~~~~~
24925 +
24926 +o rmk: several OSS drivers for SA11xx-based hardware in need of
24927 +  ALSA-ification and L3 bus support code for these.
24928 +
24929 +o rmk: linux/sound/drivers/mpu401/mpu401.c and
24930 +  linux/sound/drivers/virmidi.c complained about 'errno' at some time in the
24931 +  past, need to confirm whether this is still a problem.
24932 +
24933 +o rmk: need to complete ALSA-ification of the WaveArtist driver for both
24934 +  NetWinder and other stuff (there's some fairly fundamental differences in
24935 +  the way the mixer needs to be handled for the NetWinder.)
24936 +
24937 +
24938 +  (Issues with forward-porting 2.4 bugfixes.)
24939 +  (Killing off OSS is 2.7 material)
24940 +
24941 +
24942 +global
24943 +~~~~~~
24944 +
24945 +o 64-bit dev_t.  Seems almost ready, but it's not really known how much
24946 +  work is still to do.  Patches exist in -mm but with the recent rise of the
24947 +  neo-viro I'm not sure where things are at.
24948 +
24949 +o Lots of 2.4 fixes including some security are not in 2.5
24950 +
24951 +o There are about 60 or 70 security related checks that need doing
24952 +  (copy_user etc) from Stanford tools.  (badari is looking into this, and
24953 +  hollisb)
24954 +
24955 +o A couple of hundred real looking bugzilla bugs
24956 +
24957 +o viro: cdev rework.  Main group is pretty stable and I hope to feed it to
24958 +  Linus RSN.  That's cdev-cidr and ->i_cdev/->i_cindex stuff
24959 +
24960 +o Athlon prefetch oopses sometimes.  It is currently disabled, and needs to
24961 +  be fixed.
24962 +
24963 +
24964 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
24965 +++ 25/Documentation/should-fix.txt     2003-10-05 00:33:52.000000000 -0700
24966 @@ -0,0 +1,611 @@
24967 +Not-ready features and speedups
24968 +===============================
24969 +
24970 +Legend:
24971 +
24972 +PRI1:  We're totally lame if this doesn't get in
24973 +PRI2:  Would be nice
24974 +PRI3:  Not very important
24975 +
24976 +drivers/block/
24977 +~~~~~~~~~~~~~~
24978 +
24979 +o Framework for selecting IO schedulers.  This is the main one really. 
24980 +  Once this is in place we can drop in new schedulers any old time, no risk.
24981 +  Nick Piggin has code for this.
24982 +
24983 +  PRI1
24984 +
24985 +o viro: paride drivers need a big cleanup
24986 +
24987 +  PRI2
24988 +
24989 +drivers/char/rtc/
24990 +~~~~~~~~~~~~~~~~~
24991 +
24992 +o rmk, trini: add support for alarms to the existing generic rtc driver.
24993 +
24994 +  PRI2
24995 +
24996 +console drivers
24997 +~~~~~~~~~~~~~~~
24998 +  (Pavel Machek <pavel@ucw.cz>)
24999 +
25000 +o There are few must-fix bugs in cursor handling.
25001 +
25002 +o Play with gpm selection for a while and your cursor gets corrupted with
25003 +  random dots. Ouch.
25004 +
25005 +device mapper
25006 +~~~~~~~~~~~~~
25007 +
25008 +o ioctl interface cleanup patch is ready (redo the structure layouts)
25009 +
25010 +  PRI1
25011 +
25012 +o A port of the 2.4 snapshot and mirror targets is in progress
25013 +
25014 +  PRI1
25015 +
25016 +o the fs interface to dm needs to be redone.  gregkh was going to work on
25017 +  this.  viro is interested in seeing work thus-far.
25018 +
25019 +  PRI2
25020 +
25021 +drivers/net/wireless/
25022 +~~~~~~~~~~~~~~~~~~~~~
25023 +
25024 +  (Jean Tourrilhes <jt@bougret.hpl.hp.com>)
25025 +
25026 +o get latest orinoco changes from David.
25027 +
25028 +  PRI1
25029 +
25030 +o get the latest airo.c fixes from CVS.  This will hopefully fix problems
25031 +  people have reported on the LKML.
25032 +
25033 +  PRI1
25034 +
25035 +o get HostAP driver in the kernel.  No consolidation of the 802.11
25036 +  management across driver can happen until this one is in (which is probably
25037 +  2.7.X material).  I think Jouni is mostly ready but didn't find time for
25038 +  it.
25039 +
25040 +  PRI2
25041 +
25042 +o get more wireless drivers into the kernel.  The most "integrable" drivers
25043 +  at this point seem the NWN driver, Pavel's Spectrum driver and the Atmel
25044 +  driver.
25045 +
25046 +  PRI1
25047 +
25048 +o The last two drivers mentioned above are held up by firmware issues (see
25049 +  flamewar on LKML a few days ago).  So maybe fixing those firmware issues
25050 +  should be a requirement for 2.6.X, because we can expect more wireless
25051 +  devices to need firmware upload at startup coming to market.
25052 +
25053 +  (in progress?)
25054 +
25055 +  PRI1
25056 +
25057 +drivers/usb/gadget/
25058 +~~~~~~~~~~~~~~~~~~~
25059 +
25060 +o rmk: SA11xx USB client/gadget code (David B has been doing some work on
25061 +  this, and keeps trying to prod me, but unfortunately I haven't had the time
25062 +  to look at his work, sorry David.)
25063 +
25064 +  PRI3
25065 +
25066 +fs/
25067 +~~~
25068 +
25069 +o ext3 and ext2 block allocators have serious failure modes - interleaved
25070 +  allocations.
25071 +
25072 +  PRI3
25073 +
25074 +o Integrate Chris Mason's 2.4 reiserfs ordered data and data journaling
25075 +  patches.  They make reiserfs a lot safer.
25076 +
25077 +  Ordered: PRI2
25078 +  data journalled: PRI3
25079 +
25080 +o (Trond:) Yes: I'm still working on an atomic "open()", i.e.  one
25081 +           where we short-circuit the usual VFS path_walk() + lookup() +
25082 +           permission() + create() + ....  bullsh*t...
25083 +
25084 +           I have several reasons for wanting to do this (all of
25085 +           them related to NFS of course, but much of the reasoning applies
25086 +           to *all* networked file systems).
25087 +
25088 +   1) The above sequence is simply not atomic on *any* networked
25089 +      filesystem.
25090 +
25091 +   2) It introduces a sh*tload of completely unnecessary RPC calls (why
25092 +      do a 'permission' RPC call when the server is in *any* case going to
25093 +      tell you whether or not this operations is allowed.  Why do a
25094 +      'lookup()' when the 'create()' call can be made to tell you whether or
25095 +      not a file already exists).
25096 +
25097 +   3) It is incompatible with some operations: the current create()
25098 +      doesn't pass an 'EXCLUSIVE' flag down to the filesystems.
25099 +
25100 +   4) (NFS specific?) open() has very different cache consistency
25101 +      requirements when compared to most other VFS operations.
25102 +
25103 +   I'd very much like for something like Peter Braam's 'lookup with
25104 +   intent' or (better yet) for a proper dentry->open() to be integrated with
25105 +   path_walk()/open_namei().  I'm still working on the latter (Peter has
25106 +   already completed the lookup with intent stuff).
25107 +
25108 +   (All this is in progress, see http://www.fys.uio.no/~trondmy/src)
25109 +
25110 +   (Is awaiting Pater Braam's intent patches.  Applicable to CIFS)
25111 +
25112 +   PRI2 (?)
25113 +
25114 +o (Chuck Lever <cel@citi.umich.edu>): NFS O_DIRECT support must be
25115 +  completed.  The best approach is to fall back to something like the 2.4 NFS
25116 +  O_DIRECT support, which issues RPCs synchronously and uses the RPC
25117 +  completion mechanism to wait for I/O completion.
25118 +
25119 +  PRI2
25120 +
25121 +o viro: cleaning up options-parsers in filesystems.  (patch exists, needs
25122 +  porting).
25123 +
25124 +  PRI2
25125 +
25126 +o aio: fs IO isn't async at present.  suparna has restart patches, they're
25127 +  in -mm.  Need to get Ben to review/comment.
25128 +
25129 +  PRI1.
25130 +
25131 +o drepper: various filesystems use ->pid wrongly
25132 +
25133 +kernel/
25134 +~~~~~~~
25135 +
25136 +o rusty: Zippel's Reference count simplification.  Tricky code, but cuts
25137 +  about 120 lines from module.c.  Patch exists, needs stressing.
25138 +
25139 +  PRI3
25140 +
25141 +o rusty: Fix module-failed-init races by starting module "disabled".  Patch
25142 +  exists, requires some subsystems (ie.  add_partition) to explicitly say
25143 +  "make module live now".  Without patch we are no worse off than 2.4 etc.  
25144 +
25145 +  PRI1
25146 +
25147 +o Integrate userspace irq balancing daemon.
25148 +
25149 +  PRI2
25150 +
25151 +o kexec.  Seems to work, was in -mm.
25152 +
25153 +  PRI3
25154 +
25155 +o rmk: lib/inflate.c must not use static variables (causes these to be
25156 +  referenced via GOTOFF relocations in PIC decompressor.  We have a PIC
25157 +  decompressor to avoid having to hard code a per platform zImage link
25158 +  address into the makefiles.)
25159 +
25160 +  PRI2
25161 +
25162 +o klibc merge?
25163 +
25164 +  PRI2
25165 +
25166 +mm/
25167 +~~~
25168 +
25169 +o objrmap: concerns over page reclaim performance at high sharing levels,
25170 +  and interoperation with nonlinear mappings is hairy.
25171 +
25172 +o oxymoron's async write-error-handling patch
25173 +
25174 +  PRI1
25175 +
25176 +o dropbehind for large files
25177 +
25178 +  PRI2
25179 +
25180 +net/
25181 +~~~~
25182 +
25183 +  (davem)
25184 +
25185 +o Real serious use of IPSEC is hampered by lack of MPLS support.  MPLS is a
25186 +  switching technology that works by switching based upon fixed length labels
25187 +  prepended to packets.  Many people use this and IPSEC to implement VPNs
25188 +  over public networks, it is also used for things like traffic engineering.
25189 +
25190 +  A good reference site is:
25191 +
25192 +       http://www.mplsrc.com/
25193 +
25194 +  Anyways, an existing (crappy) implementation exists.  I've almost
25195 +  completed a rewrite, I should have something in the tree next week.
25196 +
25197 +  PRI1
25198 +
25199 +o Sometimes we generate IP fragments when it truly isn't necessary.
25200 +
25201 +  The way IP fragmentation is specified, each fragment must be modulo 8
25202 +  bytes in length.  So suppose the device has an MTU that is not 0 modulo 8,
25203 +  ethernet even classifies in this way.  1500 == (8 * 187) + 4
25204 +
25205 +  Our IP fragmenting engine can fragment on packets that are sized within
25206 +  the last modulo 8 bytes of the MTU.  This happens in obscure cases, but it
25207 +  does happen.
25208 +
25209 +  I've proposed a fix to Alexey, whereby very late in the output path we
25210 +  check the packet, if we fragmented but the data length would fit into the
25211 +  MTU we unfragment the packet.
25212 +
25213 +  This is low priority, because technically it creates suboptimal behavior
25214 +  rather than mis-operation.
25215 +
25216 +  PRI1
25217 +
25218 +net/*/netfilter/
25219 +~~~~~~~~~~~~~~~~
25220 +
25221 +o Lots of misc. cleanups, which are happening slowly.
25222 +
25223 +  PRI2
25224 +
25225 +power management
25226 +~~~~~~~~~~~~~~~~
25227 +
25228 +o PM code in mainline is currently b0rked. Fixes in -mm
25229 +
25230 +  PRI1
25231 +
25232 +o Pat and Pavel disagree over swsusp. Need to sort that out.
25233 +
25234 +  PRI2
25235 +
25236 +o Frame buffer restore codepaths (that requires some deep PCI magic)
25237 +
25238 +  PRI2
25239 +
25240 +o XFree86 hooks
25241 +
25242 +  PRI2
25243 +
25244 +o AGP restoration
25245 +
25246 +  PRI2
25247 +
25248 +o DRI restoration
25249 +
25250 +  (davej/Alan: not super-critical, can crash laptop on restore.  davej
25251 +  looking into it.)
25252 +
25253 +  PRI2
25254 +
25255 +o IDE suspend/resume without races (Ben is looking at this a little)
25256 +
25257 +  PRI2
25258 +
25259 +o Pat: There are already CPU device structures; MTRRs should be a
25260 +  dynamically registered interface of CPUs, which implies there needs
25261 +  to be some other glue to know that there are MTRRs that need to be
25262 +  saved/restored.
25263 +
25264 +  PRI1
25265 +
25266 +global
25267 +~~~~~~
25268 +
25269 +o We need a kernel side API for reporting error events to userspace (could
25270 +  be async to 2.6 itself)
25271 +
25272 +  (Prototype core based on netlink exists)
25273 +
25274 +  PRI2
25275 +
25276 +o Kai: Introduce a sane, easy and standard way to build external modules
25277 +  - make clean and make modules_install are both broken
25278 +
25279 +  PRI2
25280 +
25281 +drivers
25282 +~~~~~~~
25283 +
25284 +o Alan: Cardbus/PCMCIA requires all Russell's stuff is merged to do
25285 +  multiheader right and so on
25286 +
25287 +  PRI1
25288 +
25289 +drivers/acpi/
25290 +~~~~~~~~~~~~~
25291 +
25292 +o Fix acpi for all newer IBM Thinkpads see
25293 +  http://bugme.osdl.org/show_bug.cgi?id=1038 for more information
25294 +
25295 +o alan: VIA APIC stuff is one bit of this, there are also some other
25296 +  reports that were caused by ACPI not setting level v edge trigger some
25297 +  times
25298 +
25299 +  PRI1
25300 +
25301 +o mochel: it seems the acpi irq routing code could use a serious rewrite.
25302 +
25303 +  grover: The problem is the ACPI irq routing code is trying to piggyback
25304 +  on the existing MPS-specific data structures, and it's generally a hack. 
25305 +  So yes mochel is right, but it is also purging MPS-ities from common code
25306 +  as well.  I've done some preliminary work in this area and it doesn't seem
25307 +  to break anything (yet) but a rewrite in this area imho should not be
25308 +  rushed out the door.  And, I think the above bugs can be fixed w/o the
25309 +  rewrite.
25310 +
25311 +  PRI2
25312 +
25313 +o mochel: ACPI suspend doesn't work.  Important, not cricital.  Pat is
25314 +  working it.
25315 +
25316 +  PRI2
25317 +
25318 +drivers/block/
25319 +~~~~~~~~~~~~~~
25320 +
25321 +o Floppy is almost unusably buggy still
25322 +
25323 +  akpm: we need more people to test & report.
25324 +
25325 +  alan: "Floppy has worked for me since the patches that went in 2.5.69-ac
25326 +  and I think -bk somewhere"
25327 +
25328 +  PRI1
25329 +
25330 +drivers/char/
25331 +~~~~~~~~~~~~~
25332 +
25333 +
25334 +drivers/ide/
25335 +~~~~~~~~~~~~
25336 +
25337 +  (Alan)
25338 +
25339 +o IDE PIO has occasional unexplained PIO disk eating reports
25340 +
25341 +  PRI1
25342 +
25343 +o IDE has multiple zillions of races/hangs in 2.5 still
25344 +
25345 +  PRI1
25346 +
25347 +o IDE scsi needs rewriting
25348 +
25349 +  PRI2
25350 +
25351 +o IDE needs significant reworking to handle Simplex right
25352 +
25353 +  PRI2
25354 +
25355 +o IDE hotplug handling for 2.5 is completely broken still
25356 +
25357 +  PRI2
25358 +
25359 +o There are lots of other IDE bugs that wont go away until the taskfile
25360 +  stuff is included, the locking bugs that allow any user to hang the IDE
25361 +  layer in 2.5, and some other updates are forward ported.  (esp.  HPT372N).
25362 +
25363 +  PRI1
25364 +
25365 +drivers/isdn/
25366 +~~~~~~~~~~~~~
25367 +
25368 +  (Kai, rmk)
25369 +
25370 +o isdn_tty locking is completely broken (cli() and friends)
25371 +
25372 +  PRI2
25373 +
25374 +o fix other drivers
25375 +
25376 +  PRI2
25377 +
25378 +o lots more cleanups, adaption to recent APIs etc
25379 +
25380 +  PRI3
25381 +
25382 +o fixup tty-based ISDN drivers which provide TIOCM* ioctls (see my recent
25383 +  3-set patch for serial stuff)
25384 +
25385 +  Alternatively, we could re-introduce the fallback to driver ioctl parsing
25386 +  for these if not enough drivers get updated.
25387 +
25388 +  PRI3
25389 +
25390 +drivers/net/
25391 +~~~~~~~~~~~~
25392 +
25393 +o davej: Either Wireless network drivers or PCMCIA broke somewhen.  A
25394 +  configuration that worked fine under 2.4 doesn't receive any packets.  Need
25395 +  to look into this more to make sure I don't have any misconfiguration that
25396 +  just 'happened to work' under 2.4
25397 +
25398 +  PRI1
25399 +
25400 +drivers/scsi/
25401 +~~~~~~~~~~~~~
25402 +
25403 +o jejb: qlogic -
25404 +
25405 +  o Merge the feral driver.  It covers all qlogic chips: 1020 all the way
25406 +    up to 23xxx. http://linux-scsi.bkbits.net/scsi-isp-2.5
25407 +
25408 +  o qla2xxx: only for FC chips.  Has significant build issues.  hch
25409 +    promises to send me a "must fix" list for this.
25410 +    http://linux-scsi.bkbits.net/scsi-qla2xxx-2.5
25411 +
25412 +  PRI2
25413 +
25414 +arch/i386/
25415 +~~~~~~~~~~
25416 +
25417 +o Also PC9800 merge needs finishing to the point we want for 2.6 (not all).
25418 +
25419 +  PRI3
25420 +
25421 +o davej: PAT support (for mtrr exhaustion w/ AGP)
25422 +
25423 +  PRI2
25424 +
25425 +o 2.5.x won't boot on some 440GX
25426 +
25427 +  alan: Problem understood now, feasible fix in 2.4/2.4-ac.  (440GX has two
25428 +  IRQ routers, we use the $PIR table with the PIIX, but the 440GX doesnt use
25429 +  the PIIX for its IRQ routing).  Fall back to BIOS for 440GX works and Intel
25430 +  concurs.
25431 +
25432 +  PRI1
25433 +
25434 +o 2.5.x doesn't handle VIA APIC right yet.
25435 +
25436 +  1. We must write the PCI_INTERRUPT_LINE
25437 +
25438 +  2. We have quirk handlers that seem to trash it.
25439 +
25440 +  PRI1
25441 +
25442 +o ACPI needs the relax patches merging to work on lots of laptops
25443 +
25444 +  alan: ACPI relax stuff is in 2.4-ac, compaq workaround is in next -ac
25445 +  coming.  These seem to deliver the goods - toshibas now work a treat.  Some
25446 +  other relax bits are being discussed (assume local0 starts 0 etc) and
25447 +  progress looks great.  This can occur before 2.6 or during.
25448 +
25449 +  PRI1
25450 +
25451 +o ECC driver questions are not yet sorted (DaveJ is working on this) (Dan
25452 +  Hollis)
25453 +
25454 +  alan: ECC - I have some test bits from Dan's stuff - they need no kernel
25455 +  core changes for most platforms.  That means we can treat it as a random
25456 +  driver merge.
25457 +
25458 +  PRI3
25459 +
25460 +o alan: 2.4 has some fixes for tsc handling bugs.  One where some bioses in
25461 +  SMM mode mess up our toggle on the time high/low or mangle the counter and
25462 +  one where a few chips need religious use of _p for timer access and we
25463 +  don't do that.  This is forward porting little bits of fixup.
25464 +
25465 +  ACPI HZ stuff we can't trap - a lot of ACPI is implemented as outb's
25466 +  triggering SMM traps
25467 +
25468 +  PRI1
25469 +
25470 +arch/x86_64/
25471 +~~~~~~~~~~~~
25472 +
25473 +  (Andi)
25474 +
25475 +o time handling is broken. Need to move up 2.4 time.c code.
25476 +
25477 +  PRI1
25478 +
25479 +o NMI watchdog seems to tick too fast
25480 +
25481 +  PRI2
25482 +
25483 +o not very well tested. probably more bugs lurking.
25484 +
25485 +  PRI1
25486 +
25487 +o need to coredump 64bit vsyscall code with dwarf2
25488 +
25489 +  PRI2
25490 +
25491 +o Consider merging of Erich Focht's very clean and simple homenode NUMA
25492 +  scheduler (I have my own in 2.4, but Erich's 2.5 version is much cleaner)
25493 +
25494 +  PRI2
25495 +  
25496 +o Consider port of the Simple NUMA API from 2.4/homenode.
25497 +
25498 +  PRI3
25499 +
25500 +o move 64bit signal trampolines into vsyscall code and add dwarf2 for it.
25501 +  (in progress)
25502 +
25503 +  PRI1
25504 +
25505 +o describe kernel assembly with dwarf2 annotations for kgdb
25506 +
25507 +  PRI3
25508 +
25509 +arch/alpha/
25510 +~~~~~~~~~~~
25511 +
25512 +o rth: Ptrace writes are broken.  This means we can't (reliably) set
25513 +  breakpoints or modify variables from gdb.
25514 +
25515 +  PRI1
25516 +
25517 +arch/arm/
25518 +~~~~~~~~~
25519 +
25520 +o rmk: missing raw keyboard translation tables for all ARM machines. 
25521 +  Haven't even looked into this at all.  This could be messy since there
25522 +  isn't an ARM architecture standard.  I'm presently hoping that it won't be
25523 +  an issue.  If it does, I guess we'll see drivers/char/keyboard.c explode.
25524 +
25525 +  PRI2
25526 +
25527 +arch/others/
25528 +~~~~~~~~~~~~
25529 +
25530 +o SH needs resyncing, as do some other ports. SH64 needs merging.
25531 +  No impact on mainstream platforms hopefully.
25532 +
25533 +  PRI2
25534 +
25535 +arch/s390/
25536 +~~~~~~~~~
25537 +
25538 +o A nastly memory management problem causes random crashes.  These appear
25539 +  to be fixed/hidden by the objrmap patch, more investigation is needed.
25540 +
25541 +  PRI1
25542 +
25543 +drivers/s390/
25544 +~~~~~~~~~~~~~
25545 +
25546 +o Early userspace and 64 bit dev_t will allow the removal of most of
25547 +  dasd_devmap.c and dasd_genhd.c.
25548 +
25549 +  PRI2
25550 +
25551 +o The 3270 console driver needs to be replaced with a working one
25552 +  (prototype is there, needs to be finished).
25553 +
25554 +  PRI2
25555 +
25556 +o Minor interface changes are pending in cio/ when the z990 machines are
25557 +  out.
25558 +
25559 +  PRI2
25560 +
25561 +o Jan Glauber is working on a fix for the timer issues related to running
25562 +  on virtualized CPUs (wall-clock vs.  cpu time).
25563 +
25564 +  PRI1
25565 +
25566 +o a block device driver for ramdisks shared among virtual machines
25567 +
25568 +  PRI3
25569 +
25570 +o driver for crypto hardware
25571 +
25572 +  PRI3
25573 +
25574 +o 'claw' network device driver
25575 +
25576 +  PRI3
25577 +
25578 --- linux-2.6.0-test6/Documentation/zorro.txt   2003-07-27 12:14:38.000000000 -0700
25579 +++ 25/Documentation/zorro.txt  2003-10-05 00:33:23.000000000 -0700
25580 @@ -2,7 +2,7 @@
25581                 ----------------------------------------
25582  
25583  Written by Geert Uytterhoeven <geert@linux-m68k.org>
25584 -Last revised: February 27, 2000
25585 +Last revised: September 5, 2003
25586  
25587  
25588  1. Introduction
25589 @@ -75,7 +75,7 @@ they are CPU physical addresses as well.
25590  The treatment of these regions depends on the type of Zorro space:
25591  
25592    - Zorro II address space is always mapped and does not have to be mapped
25593 -    explicitly using ioremap().
25594 +    explicitly using z_ioremap().
25595      
25596      Conversion from bus/physical Zorro II addresses to kernel virtual addresses
25597      and vice versa is done using:
25598 @@ -83,22 +83,20 @@ The treatment of these regions depends o
25599         virt_addr = ZTWO_VADDR(bus_addr);
25600         bus_addr = ZTWO_PADDR(virt_addr);
25601  
25602 -  - Zorro III address space must be mapped explicitly using ioremap() first
25603 +  - Zorro III address space must be mapped explicitly using z_ioremap() first
25604      before it can be accessed:
25605   
25606 -       virt_addr = ioremap(bus_addr, size);
25607 +       virt_addr = z_ioremap(bus_addr, size);
25608         ...
25609 -       iounmap(virt_addr);
25610 +       z_iounmap(virt_addr);
25611  
25612  
25613  5. References
25614  -------------
25615  
25616  linux/include/linux/zorro.h
25617 -linux/include/linux/ioport.h
25618 -linux/include/asm-m68k/io.h
25619 -linux/include/asm-m68k/amigahw.h
25620 -linux/include/asm-ppc/io.h
25621 +linux/include/asm-{m68k,ppc}/zorro.h
25622 +linux/include/linux/zorro_ids.h
25623  linux/drivers/zorro
25624  /proc/bus/zorro
25625  
25626 --- linux-2.6.0-test6/drivers/acorn/block/fd1772.c      2003-09-08 13:58:56.000000000 -0700
25627 +++ 25/drivers/acorn/block/fd1772.c     2003-10-05 00:34:00.000000000 -0700
25628 @@ -365,13 +365,12 @@ static void finish_fdc_done(int dummy);
25629  static void floppy_off(unsigned int nr);
25630  static void setup_req_params(int drive);
25631  static void redo_fd_request(void);
25632 -static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int
25633 +static int fd_ioctl(struct block_device *bdev, struct file *filp, unsigned int
25634                     cmd, unsigned long param);
25635  static void fd_probe(int drive);
25636  static int fd_test_drive_present(int drive);
25637  static void config_types(void);
25638 -static int floppy_open(struct inode *inode, struct file *filp);
25639 -static int floppy_release(struct inode *inode, struct file *filp);
25640 +static int floppy_open(struct block_device *bdev, struct file *filp);
25641  static void do_fd_request(request_queue_t *);
25642  
25643  /************************* End of Prototypes **************************/
25644 @@ -1309,11 +1308,9 @@ static int invalidate_drive(struct block
25645         return 0;
25646  }
25647  
25648 -static int fd_ioctl(struct inode *inode, struct file *filp,
25649 +static int fd_ioctl(struct block_device *bdev, struct file *filp,
25650                     unsigned int cmd, unsigned long param)
25651  {
25652 -       struct block_device *bdev = inode->i_bdev;
25653 -
25654         switch (cmd) {
25655         case FDFMTEND:
25656         case FDFLUSH:
25657 @@ -1453,10 +1450,11 @@ static void config_types(void)
25658   * drive with different device numbers.
25659   */
25660  
25661 -static int floppy_open(struct inode *inode, struct file *filp)
25662 +static int floppy_open(struct block_device *bdev, struct file *filp)
25663  {
25664 -       int drive = iminor(inode) & 3;
25665 -       int type =  iminor(inode) >> 2;
25666 +       struct archy_floppy_struct *p = bdev->bd_disk->private_data;
25667 +       int drive = p - unit;
25668 +       int type =  MINOR(bdev->bd_dev) >> 2;
25669         int old_dev = fd_device[drive];
25670  
25671         if (fd_ref[drive] && old_dev != type)
25672 @@ -1476,10 +1474,13 @@ static int floppy_open(struct inode *ino
25673                 return 0;
25674  
25675         if (filp->f_mode & 3) {
25676 -               check_disk_change(inode->i_bdev);
25677 +               check_disk_change(bdev);
25678                 if (filp->f_mode & 2) {
25679 -                       if (unit[drive].wpstat) {
25680 -                               floppy_release(inode, filp);
25681 +                       if (p->wpstat) {
25682 +                               if (fd_ref[drive] < 0)
25683 +                                       fd_ref[drive] = 0;
25684 +                               else
25685 +                                       fd_ref[drive]--;
25686                                 return -EROFS;
25687                         }
25688                 }
25689 @@ -1487,10 +1488,10 @@ static int floppy_open(struct inode *ino
25690         return 0;
25691  }
25692  
25693 -
25694 -static int floppy_release(struct inode *inode, struct file *filp)
25695 +static int floppy_release(struct gendisk *disk)
25696  {
25697 -       int drive = iminor(inode) & 3;
25698 +       struct archy_floppy_struct *p = disk->private_data;
25699 +       int drive = p - unit;
25700  
25701         if (fd_ref[drive] < 0)
25702                 fd_ref[drive] = 0;
25703 --- linux-2.6.0-test6/drivers/acorn/block/mfmhd.c       2003-08-08 22:55:11.000000000 -0700
25704 +++ 25/drivers/acorn/block/mfmhd.c      2003-10-05 00:33:54.000000000 -0700
25705 @@ -1153,9 +1153,9 @@ static int mfm_initdrives(void)
25706   * The 'front' end of the mfm driver follows...
25707   */
25708  
25709 -static int mfm_ioctl(struct inode *inode, struct file *file, u_int cmd, u_long arg)
25710 +static int mfm_ioctl(struct block_device *bdev, struct file *file, u_int cmd, u_long arg)
25711  {
25712 -       struct mfm_info *p = inode->i_bdev->bd_disk->private_data;
25713 +       struct mfm_info *p = bdev->bd_disk->private_data;
25714         struct hd_geometry *geo = (struct hd_geometry *) arg;
25715         if (cmd != HDIO_GETGEO)
25716                 return -EINVAL;
25717 @@ -1167,7 +1167,7 @@ static int mfm_ioctl(struct inode *inode
25718                 return -EFAULT;
25719         if (put_user (p->cylinders, &geo->cylinders))
25720                 return -EFAULT;
25721 -       if (put_user (get_start_sect(inode->i_bdev), &geo->start))
25722 +       if (put_user (get_start_sect(bdev), &geo->start))
25723                 return -EFAULT;
25724         return 0;
25725  }
25726 --- linux-2.6.0-test6/drivers/acpi/asus_acpi.c  2003-06-22 12:04:44.000000000 -0700
25727 +++ 25/drivers/acpi/asus_acpi.c 2003-10-05 00:33:23.000000000 -0700
25728 @@ -26,13 +26,17 @@
25729   *  Johann Wiesner - Small compile fixes
25730   *  John Belmonte  - ACPI code for Toshiba laptop was a good starting point.
25731   *
25732 - *  TODO
25733 + *  TODO:
25734   *  add Fn key status
25735 - *  Add mode selection on module loading (parameter) -> still necessary ?
25736 + *  Add mode selection on module loading (parameter) -> still necessary?
25737   *  Complete display switching -- may require dirty hacks?
25738 - *
25739   */
25740  
25741 +#include <linux/config.h>
25742 +#if defined (CONFIG_MODVERSIONS) && !defined (MODVERSIONS) && defined (MODULE)
25743 +#include <linux/modversions.h>
25744 +#endif
25745 +
25746  #include <linux/kernel.h>
25747  #include <linux/module.h>
25748  #include <linux/init.h>
25749 @@ -41,7 +45,7 @@
25750  #include <acpi/acpi_drivers.h>
25751  #include <acpi/acpi_bus.h>
25752  
25753 -#define ASUS_ACPI_VERSION "0.24a"
25754 +#define ASUS_ACPI_VERSION "0.26"
25755  
25756  #define PROC_ASUS       "asus" //the directory
25757  #define PROC_MLED       "mled"
25758 @@ -110,20 +114,24 @@ struct asus_hotk {
25759         struct model_data *methods;     //methods available on the laptop
25760         u8 brightness;                  //brighness level
25761         enum {
25762 -               L2X = 0,        //L200D -> TODO check Q11 (Fn+F8)
25763 -                               //         Calling this method simply hang the
25764 +               A1X=0,          //A1340D, A1300F
25765 +               A2X,            //A2500H
25766 +               D1X,            //D1
25767 +               L1X,            //L1400B
25768 +               L2X,            //L2000D -> TODO check Q11 (Fn+F8)
25769 +                               //         Calling this method simply hangs the
25770                                 //         computer, ISMI method hangs the laptop.
25771 -               L3X,            //L3C
25772                 L3D,            //L3400D
25773 +               L3X,            //L3C
25774 +               L5X,            //L5C TODO this model seems to have one more
25775 +                               //         LED, add support
25776                 M2X,            //M2400E
25777 +               M3N,            //M3700N, but also S1300N -> TODO WLED
25778                 S1X,            //S1300A -> TODO special keys do not work ?
25779 -               D1X,            //D1
25780 -               L1X,            //L1400B
25781 -               A1X,            //A1340D, A1300F
25782 -               J1X,            //S200 (J1)
25783 -                               //TODO  A1370D does not seems to have a ATK device 
25784 +               S2X,            //S200 (J1 reported), Victor MP-XP7210
25785 +                               //TODO  A1370D does not seem to have an ATK device 
25786                                 //      L8400 model doesn't have ATK
25787 -               END_MODEL,
25788 +               END_MODEL
25789         } model;                //Models currently supported
25790         u16 event_count[128];   //count for each event TODO make this better
25791  };
25792 @@ -133,7 +141,8 @@ struct asus_hotk {
25793  #define S1X_PREFIX "\\_SB.PCI0.PX40."
25794  #define L1X_PREFIX S1X_PREFIX
25795  #define A1X_PREFIX "\\_SB.PCI0.ISA.EC0."
25796 -#define J1X_PREFIX A1X_PREFIX
25797 +#define S2X_PREFIX A1X_PREFIX
25798 +#define M3N_PREFIX "\\_SB.PCI0.SBRG.EC0."
25799  
25800  static struct model_data model_conf[END_MODEL] = {
25801          /*
25802 @@ -147,33 +156,43 @@ static struct model_data model_conf[END_
25803          * it seems to be a kind of switch, but what for ?
25804          *
25805          */
25806 +       {"A1X", "MLED", "\\MAIL", NULL, NULL, A1X_PREFIX "_Q10", "\\BKLI",
25807 +        A1X_PREFIX "_Q0E", A1X_PREFIX "_Q0F", NULL, NULL, NULL, NULL, NULL},
25808 +
25809 +       {"A2X", "MLED", NULL, "WLED", "\\SG66", "\\Q10", "\\BAOF",
25810 +        "\\Q0E", "\\Q0F", "SPLV", "GPLV", "\\CMOD", "SDSP", "\\INFB"},
25811 +
25812 +       {"D1X", "MLED", NULL, NULL, NULL, "\\Q0D", "\\GP11", 
25813 +        "\\Q0C", "\\Q0B", NULL, NULL, "\\BLVL", "SDSP","\\INFB"},
25814 +
25815 +       {"L1X", "MLED", NULL, "WLED", NULL, L1X_PREFIX "Q10", "\\PNOF", 
25816 +        L1X_PREFIX "Q0F", L1X_PREFIX "Q0E", "SPLV", "GPLV", "\\BRIT", NULL, NULL},
25817 +        
25818         {"L2X", "MLED", "\\SGP6", "WLED", "\\RCP3", "\\Q10", "\\SGP0", 
25819          "\\Q0E", "\\Q0F", NULL, NULL, NULL, "SDSP", "\\INFB"},
25820  
25821 +       {"L3D", "MLED", "\\MALD", "WLED", NULL, "\\Q10", "\\BKLG",
25822 +        "\\Q0E", "\\Q0F", "SPLV", "GPLV", "\\BLVL", "SDSP", "\\INFB"},
25823 +
25824         {"L3X", "MLED", NULL, "WLED", NULL, L3X_PREFIX "_Q10", "\\GL32", 
25825          L3X_PREFIX "_Q0F", L3X_PREFIX "_Q0E", "SPLV", "GPLV", "\\BLVL", "SDSP", 
25826          "\\_SB.PCI0.PCI1.VGAC.NMAP"},
25827  
25828 -       {"L3D", "MLED", "\\MALD", "WLED", NULL, "\\Q10", "\\BKLG",
25829 -        "\\Q0E", "\\Q0F", "SPLV", "GPLV", "\\BLVL", "SDSP", "\\INFB"},
25830 -
25831 +       {"L5X", "MLED", NULL, "WLED", "WRED", "\\Q0D", "\\BAOF", 
25832 +        "\\Q0C","\\Q0B", "SPLV", "GPLV", NULL, "SDSP", "\\INFB"},
25833 +        
25834         {"M2X", "MLED", NULL, "WLED", NULL, "\\Q10", "\\GP06", 
25835          "\\Q0E","\\Q0F", "SPLV", "GPLV", NULL, "SDSP", "\\INFB"},
25836 +
25837 +       {"M3N", "MLED", NULL, "WLED", "\\PO33", M3N_PREFIX "_Q10", "\\BKLT", 
25838 +        M3N_PREFIX "_Q0F", M3N_PREFIX "_Q0E", "SPLV", "GPLV", "\\LBTN", "SDSP", 
25839 +        "\\ADVG"},
25840         
25841         {"S1X", "MLED", "\\EMLE", "WLED", NULL, S1X_PREFIX "Q10", "\\PNOF", 
25842          S1X_PREFIX "Q0F", S1X_PREFIX "Q0E", "SPLV", "GPLV", "\\BRIT", NULL, NULL},
25843         
25844 -       {"D1X", "MLED", NULL, NULL, NULL, "\\Q0D", "\\GP11", 
25845 -        "\\Q0C", "\\Q0B", NULL, NULL, "\\BLVL", "SDSP","\\INFB"},
25846 -
25847 -       {"L1X", "MLED", NULL, "WLED", NULL, L1X_PREFIX "Q10", "\\PNOF", 
25848 -        L1X_PREFIX "Q0F", L1X_PREFIX "Q0E", "SPLV", "GPLV", "\\BRIT", NULL, NULL},
25849 -
25850 -       {"A1X", "MLED", "\\MAIL", NULL, NULL, A1X_PREFIX "_Q10", "\\BKLI",
25851 -        A1X_PREFIX "_Q0E", A1X_PREFIX "_Q0F", NULL, NULL, NULL, NULL, NULL},
25852 -
25853 -       {"J1X", "MLED", "\\MAIL", NULL, NULL, J1X_PREFIX "_Q10", "\\BKLI",
25854 -        J1X_PREFIX "_Q0B", J1X_PREFIX "_Q0A", NULL, NULL, NULL, NULL, NULL}
25855 +       {"S2X", "MLED", "\\MAIL", NULL, NULL, S2X_PREFIX "_Q10", "\\BKLI",
25856 +        S2X_PREFIX "_Q0B", S2X_PREFIX "_Q0A", NULL, NULL, NULL, NULL, NULL}
25857  };
25858  
25859  /* procdir we use */
25860 @@ -234,7 +253,7 @@ static int read_acpi_int(acpi_handle han
25861         output.length = sizeof(out_obj);
25862         output.pointer = &out_obj;
25863  
25864 -       status = acpi_evaluate_object(handle, (char*) method, NULL, &output);
25865 +       status = acpi_evaluate_object(handle, (char *) method, NULL, &output);
25866         *val = out_obj.integer.value;
25867         return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER);
25868  }
25869 @@ -249,6 +268,7 @@ proc_read_info(char *page, char **start,
25870                 void *data)
25871  {
25872         int len = 0;
25873 +       int sfun;
25874         struct asus_hotk *hotk = (struct asus_hotk *) data;
25875         char buf[16];           //enough for all info
25876         /*
25877 @@ -257,28 +277,27 @@ proc_read_info(char *page, char **start,
25878          */
25879  
25880         len += sprintf(page, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n");
25881 -       len +=
25882 -           sprintf(page + len, "Model reference    : %s\n",
25883 -                   hotk->methods->name);
25884 +       len += sprintf(page + len, "Model reference    : %s\n", 
25885 +                      hotk->methods->name);
25886 +       if(read_acpi_int(hotk->handle, "SFUN", &sfun))
25887 +               len += sprintf(page + len, "SFUN value         : 0x%04x\n", sfun);
25888         if (asus_info) {
25889 -               snprintf(buf, 5, "%s", asus_info->signature);
25890 -               len += sprintf(page + len, "ACPI signature     : %s\n", buf);
25891                 snprintf(buf, 16, "%d", asus_info->length);
25892 -               len += sprintf(page + len, "Table length       : %s\n", buf);
25893 -               snprintf(buf, 16, "%d", asus_info->revision);
25894 -               len += sprintf(page + len, "ACPI minor version : %s\n", buf);
25895 +               len += sprintf(page + len, "DSDT length        : %s\n", buf);
25896                 snprintf(buf, 16, "%d", asus_info->checksum);
25897 -               len += sprintf(page + len, "Checksum           : %s\n", buf);
25898 +               len += sprintf(page + len, "DSDT checksum      : %s\n", buf);
25899 +               snprintf(buf, 16, "%d", asus_info->revision);
25900 +               len += sprintf(page + len, "DSDT revision      : %s\n", buf);
25901                 snprintf(buf, 7, "%s", asus_info->oem_id);
25902 -               len += sprintf(page + len, "OEM identification : %s\n", buf);
25903 +               len += sprintf(page + len, "OEM id             : %s\n", buf);
25904                 snprintf(buf, 9, "%s", asus_info->oem_table_id);
25905                 len += sprintf(page + len, "OEM table id       : %s\n", buf);
25906                 snprintf(buf, 16, "%x", asus_info->oem_revision);
25907 -               len += sprintf(page + len, "OEM rev number     : 0x%s\n", buf);
25908 +               len += sprintf(page + len, "OEM revision       : 0x%s\n", buf);
25909                 snprintf(buf, 5, "%s", asus_info->asl_compiler_id);
25910 -               len += sprintf(page + len, "ASL comp vendor ID : %s\n", buf);
25911 +               len += sprintf(page + len, "ASL comp vendor id : %s\n", buf);
25912                 snprintf(buf, 16, "%x", asus_info->asl_compiler_revision);
25913 -               len += sprintf(page + len, "ASL comp rev number: 0x%s\n", buf);
25914 +               len += sprintf(page + len, "ASL comp revision  : 0x%s\n", buf);
25915         }
25916  
25917         return len;
25918 @@ -304,7 +323,7 @@ proc_read_mled(char *page, char **start,
25919                                   &led_status))
25920                         len =  sprintf(page, "%d\n", led_status);
25921                 else
25922 -                       printk(KERN_NOTICE "Asus ACPI: Error reading MLED "
25923 +                       printk(KERN_WARNING "Asus ACPI: Error reading MLED "
25924                                "status\n");
25925         } else {
25926                 len = sprintf(page, "%d\n", (hotk->status & MLED_ON) ? 1 : 0);
25927 @@ -334,7 +353,7 @@ proc_write_mled(struct file *file, const
25928         /* We don't have to check mt_mled exists if we are here :) */
25929         if (!write_acpi_int(hotk->handle, hotk->methods->mt_mled, led_out,
25930                             NULL))
25931 -               printk(KERN_NOTICE "Asus ACPI: MLED write failed\n");
25932 +               printk(KERN_WARNING "Asus ACPI: MLED write failed\n");
25933  
25934  
25935  
25936 @@ -355,11 +374,11 @@ proc_read_wled(char *page, char **start,
25937         int led_status;
25938  
25939         if (hotk->methods->wled_status) {
25940 -               if (read_acpi_int(NULL, hotk->methods->mled_status, 
25941 +               if (read_acpi_int(NULL, hotk->methods->wled_status, 
25942                                   &led_status))
25943                         len = sprintf(page, "%d\n", led_status);
25944                 else
25945 -                       printk(KERN_NOTICE "Asus ACPI: Error reading WLED "
25946 +                       printk(KERN_WARNING "Asus ACPI: Error reading WLED "
25947                                "status\n");
25948         } else {
25949                 len = sprintf(page, "%d\n", (hotk->status & WLED_ON) ? 1 : 0);
25950 @@ -386,7 +405,7 @@ proc_write_wled(struct file *file, const
25951         /* We don't have to check if mt_wled exists if we are here :) */
25952         if (!write_acpi_int(hotk->handle, hotk->methods->mt_wled, led_out,
25953                             NULL))
25954 -               printk(KERN_NOTICE "Asus ACPI: WLED write failed\n");
25955 +               printk(KERN_WARNING "Asus ACPI: WLED write failed\n");
25956  
25957  
25958         return count;
25959 @@ -399,7 +418,7 @@ static int get_lcd_state(struct asus_hot
25960  
25961         /* We don't have to check anything, if we are here */
25962         if (!read_acpi_int(NULL, hotk->methods->lcd_status, &lcd))
25963 -               printk(KERN_NOTICE "Asus ACPI: Error reading LCD status\n");
25964 +               printk(KERN_WARNING "Asus ACPI: Error reading LCD status\n");
25965         
25966         if (hotk->model == L2X)
25967                 lcd = ~lcd;
25968 @@ -438,7 +457,7 @@ proc_write_lcd(struct file *file, const 
25969                     acpi_evaluate_object(NULL, hotk->methods->mt_lcd_switch,
25970                                          NULL, NULL);
25971                 if (ACPI_FAILURE(status))
25972 -                       printk(KERN_NOTICE "Asus ACPI: Error switching LCD\n");
25973 +                       printk(KERN_WARNING "Asus ACPI: Error switching LCD\n");
25974         }
25975  
25976         return count;
25977 @@ -452,15 +471,15 @@ static void set_brightness(int value, st
25978  {
25979         acpi_status status = 0;
25980  
25981 -       /* ATKD laptop */
25982 +       /* SPLV laptop */
25983         if(hotk->methods->brightness_set) {
25984                 if (!write_acpi_int(hotk->handle, hotk->methods->brightness_set, 
25985                                     value, NULL))
25986 -                       printk(KERN_NOTICE "Asus ACPI: Error changing brightness\n");
25987 +                       printk(KERN_WARNING "Asus ACPI: Error changing brightness\n");
25988                 return;
25989         }
25990  
25991 -       /* HOTK laptop if we are here, act as appropriate */
25992 +       /* No SPLV method if we are here, act as appropriate */
25993         value -= hotk->brightness;
25994         while (value != 0) {
25995                 status = acpi_evaluate_object(NULL, (value > 0) ? 
25996 @@ -469,7 +488,7 @@ static void set_brightness(int value, st
25997                                               NULL, NULL);
25998                 (value > 0) ? value-- : value++;
25999                 if (ACPI_FAILURE(status))
26000 -                       printk(KERN_NOTICE "Asus ACPI: Error changing brightness\n");
26001 +                       printk(KERN_WARNING "Asus ACPI: Error changing brightness\n");
26002         }
26003         return;
26004  }
26005 @@ -478,15 +497,15 @@ static int read_brightness(struct asus_h
26006  {
26007         int value;
26008         
26009 -       if(hotk->methods->brightness_get) { /* ATKD laptop */
26010 +       if(hotk->methods->brightness_get) { /* SPLV/GPLV laptop */
26011                 if (!read_acpi_int(hotk->handle, hotk->methods->brightness_get, 
26012                                    &value))
26013 -                       printk(KERN_NOTICE "Asus ACPI: Error reading brightness\n");
26014 +                       printk(KERN_WARNING "Asus ACPI: Error reading brightness\n");
26015         } else if (hotk->methods->brightness_status) { /* For D1 for example */
26016                 if (!read_acpi_int(NULL, hotk->methods->brightness_status, 
26017                                    &value))
26018 -                       printk(KERN_NOTICE "Asus ACPI: Error reading brightness\n");
26019 -       } else /* HOTK laptop */
26020 +                       printk(KERN_WARNING "Asus ACPI: Error reading brightness\n");
26021 +       } else /* No GPLV method */
26022                 value = hotk->brightness;
26023         return value;
26024  }
26025 @@ -512,7 +531,7 @@ proc_write_brn(struct file *file, const 
26026                         /* 0 <= value <= 15 */
26027                 set_brightness(value, hotk);
26028         } else {
26029 -               printk(KERN_NOTICE "Asus ACPI: Error reading user input\n");
26030 +               printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
26031         }
26032  
26033         return count;
26034 @@ -523,7 +542,7 @@ static void set_display(int value, struc
26035         /* no sanity check needed for now */
26036         if (!write_acpi_int(hotk->handle, hotk->methods->display_set, 
26037                             value, NULL))
26038 -               printk(KERN_NOTICE "Asus ACPI: Error setting display\n");
26039 +               printk(KERN_WARNING "Asus ACPI: Error setting display\n");
26040         return;
26041  }
26042  
26043 @@ -540,12 +559,12 @@ proc_read_disp(char *page, char **start,
26044         struct asus_hotk *hotk = (struct asus_hotk *) data;
26045         
26046         if (!read_acpi_int(hotk->handle, hotk->methods->display_get, &value))
26047 -               printk(KERN_NOTICE "Asus ACPI: Error reading display status\n");
26048 +               printk(KERN_WARNING "Asus ACPI: Error reading display status\n");
26049         return sprintf(page, "%d\n", value);
26050  }
26051  
26052  /*
26053 - * Preliminary support for display switching. As of now: 0x01 should activate 
26054 + * Experimental support for display switching. As of now: 0x01 should activate 
26055   * the LCD output, 0x02 should do for CRT, and 0x04 for TV-Out. Any combination 
26056   * (bitwise) of these will suffice. I never actually tested 3 displays hooked up 
26057   * simultaneously, so be warned.
26058 @@ -562,13 +581,13 @@ proc_write_disp(struct file *file, const
26059         if (sscanf(buffer, "%d", &value) == 1)
26060                 set_display(value, hotk);
26061         else {
26062 -               printk(KERN_NOTICE "Asus ACPI: Error reading user input\n");
26063 +               printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
26064         }
26065  
26066         return count;
26067  }
26068  
26069 -static int asus_hotk_add_fs(struct acpi_device *device)
26070 +static int __init asus_hotk_add_fs(struct acpi_device *device)
26071  {
26072         struct proc_dir_entry *proc;
26073         struct asus_hotk *hotk = acpi_driver_data(device);
26074 @@ -582,7 +601,7 @@ static int asus_hotk_add_fs(struct acpi_
26075  
26076         if ((asus_uid == 0) && (asus_gid == 0)){
26077                 mode = S_IFREG | S_IRUGO | S_IWUGO;
26078 -       }else{
26079 +       } else {
26080                 mode = S_IFREG | S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP;
26081         }
26082  
26083 @@ -598,7 +617,7 @@ static int asus_hotk_add_fs(struct acpi_
26084                 proc->uid = asus_uid;
26085                 proc->gid = asus_gid;;
26086         } else {
26087 -               printk(KERN_NOTICE "  Unable to create " PROC_INFOS
26088 +               printk(KERN_WARNING "  Unable to create " PROC_INFOS
26089                        " fs entry\n");
26090         }
26091  
26092 @@ -612,7 +631,7 @@ static int asus_hotk_add_fs(struct acpi_
26093                         proc->uid = asus_uid;
26094                         proc->gid = asus_gid;;
26095                 } else {
26096 -                       printk(KERN_NOTICE "  Unable to create " PROC_WLED
26097 +                       printk(KERN_WARNING "  Unable to create " PROC_WLED
26098                                " fs entry\n");
26099                 }
26100         }
26101 @@ -627,7 +646,7 @@ static int asus_hotk_add_fs(struct acpi_
26102                         proc->uid = asus_uid;
26103                         proc->gid = asus_gid;;
26104                 } else {
26105 -                       printk(KERN_NOTICE "  Unable to create " PROC_MLED
26106 +                       printk(KERN_WARNING "  Unable to create " PROC_MLED
26107                                " fs entry\n");
26108                 }
26109         }
26110 @@ -646,7 +665,7 @@ static int asus_hotk_add_fs(struct acpi_
26111                         proc->uid = asus_uid;
26112                         proc->gid = asus_gid;;
26113                 } else {
26114 -                       printk(KERN_NOTICE "  Unable to create " PROC_LCD
26115 +                       printk(KERN_WARNING "  Unable to create " PROC_LCD
26116                                " fs entry\n");
26117                 }
26118         }
26119 @@ -662,7 +681,7 @@ static int asus_hotk_add_fs(struct acpi_
26120                         proc->uid = asus_uid;
26121                         proc->gid = asus_gid;;
26122                 } else {
26123 -                       printk(KERN_NOTICE "  Unable to create " PROC_BRN
26124 +                       printk(KERN_WARNING "  Unable to create " PROC_BRN
26125                                " fs entry\n");
26126                 }
26127         }
26128 @@ -677,19 +696,19 @@ static int asus_hotk_add_fs(struct acpi_
26129                         proc->uid = asus_uid;
26130                         proc->gid = asus_gid;;
26131                 } else {
26132 -                       printk(KERN_NOTICE "  Unable to create " PROC_DISP
26133 +                       printk(KERN_WARNING "  Unable to create " PROC_DISP
26134                                " fs entry\n");
26135                 }
26136         }
26137  
26138 -       return (AE_OK);
26139 +       return 0;
26140  }
26141  
26142  
26143  static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
26144  {
26145         /* TODO Find a better way to handle events count. Here, in data, we receive
26146 -        * the hotk, so we can make anything !!
26147 +        * the hotk, so we can do anything!
26148          */
26149         struct asus_hotk *hotk = (struct asus_hotk *) data;
26150  
26151 @@ -712,19 +731,40 @@ static void asus_hotk_notify(acpi_handle
26152   * This function is used to initialize the hotk with right values. In this
26153   * method, we can make all the detection we want, and modify the hotk struct
26154   */
26155 -static int asus_hotk_get_info(struct asus_hotk *hotk)
26156 +static int __init asus_hotk_get_info(struct asus_hotk *hotk)
26157  {
26158         struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
26159 +       struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL };
26160         union acpi_object *model = NULL;
26161 +       int bsts_result;
26162 +       acpi_status status;
26163  
26164 -       /* 
26165 -        * We have to write 0 on init this far for all ASUS models
26166 +       /*
26167 +        * Get DSDT headers early enough to allow for differentiating between 
26168 +        * models, but late enough to allow acpi_bus_register_driver() to fail 
26169 +        * before doing anything ACPI-specific. Should we encounter a machine,
26170 +        * which needs special handling (i.e. its hotkey device has a different
26171 +        * HID), this bit will be moved. A global variable asus_info contains
26172 +        * the DSDT header.
26173          */
26174 +       status = acpi_get_table(ACPI_TABLE_DSDT, 1, &dsdt);
26175 +       if (ACPI_FAILURE(status))
26176 +               printk(KERN_WARNING "  Couldn't get the DSDT table header\n");
26177 +       else
26178 +               asus_info = (struct acpi_table_header *) dsdt.pointer;
26179 +
26180 +       /* We have to write 0 on init this far for all ASUS models */
26181         if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) {
26182 -               printk(KERN_NOTICE "  Hotkey initialization failed\n");
26183 +               printk(KERN_ERR "  Hotkey initialization failed\n");
26184                 return -ENODEV;
26185         }
26186  
26187 +       /* For testing purposes */
26188 +       if (!read_acpi_int(hotk->handle, "BSTS", &bsts_result))
26189 +               printk(KERN_WARNING "  Error calling BSTS\n");
26190 +       else if (bsts_result)
26191 +               printk(KERN_NOTICE "  BSTS called, 0x%02x returned\n", bsts_result);
26192 +
26193         /*
26194          * Here, we also use asus_info to make decision. For example, on INIT
26195          * method, S1X and L1X models both reports to be L84F, but they don't
26196 @@ -749,26 +789,34 @@ static int asus_hotk_get_info(struct asu
26197                 hotk->model = L3X;
26198         else if (strncmp(model->string.pointer, "M2", 2) == 0)
26199                 hotk->model = M2X;
26200 +       else if (strncmp(model->string.pointer, "M3N", 3) == 0 ||
26201 +                strncmp(model->string.pointer, "S1N", 3) == 0)
26202 +               hotk->model = M3N; /* S1300N is similar enough */
26203         else if (strncmp(model->string.pointer, "L2", 2) == 0)
26204                 hotk->model = L2X;
26205 -       else if (strncmp(model->string.pointer, "L8", 2) == 0)
26206 +       else if (strncmp(model->string.pointer, "L8", 2) == 0) {
26207                 /* S1300A reports L84F, but L1400B too */
26208 -               if (strncmp(asus_info->oem_table_id, "L1", 2) == 0)
26209 -                       hotk->model = L1X;
26210 -               else
26211 +               if (asus_info) {
26212 +                       if (strncmp(asus_info->oem_table_id, "L1", 2) == 0)
26213 +                               hotk->model = L1X;
26214 +               } else
26215                         hotk->model = S1X;
26216 +       }
26217         else if (strncmp(model->string.pointer, "D1", 2) == 0)
26218                 hotk->model = D1X;
26219         else if (strncmp(model->string.pointer, "A1", 2) == 0)
26220                 hotk->model = A1X;
26221 +       else if (strncmp(model->string.pointer, "A2", 2) == 0)
26222 +               hotk->model = A2X;
26223         else if (strncmp(model->string.pointer, "J1", 2) == 0)
26224 -               hotk->model = J1X;
26225 -
26226 +               hotk->model = S2X;
26227 +       else if (strncmp(model->string.pointer, "L5", 2) == 0)
26228 +               hotk->model = L5X;
26229  
26230         if (hotk->model == END_MODEL) {
26231                 /* By default use the same values, as I don't know others */
26232 -               printk("unsupported, trying default values, contact the "
26233 -                      "developers\n");
26234 +               printk("unsupported, trying default values, supply the "
26235 +                      "developers with your DSDT\n");
26236                 hotk->model = L2X;
26237         } else {
26238                 printk("supported\n");
26239 @@ -783,7 +831,7 @@ static int asus_hotk_get_info(struct asu
26240  
26241  
26242  
26243 -static int asus_hotk_check(struct asus_hotk *hotk)
26244 +static int __init asus_hotk_check(struct asus_hotk *hotk)
26245  {
26246         int result = 0;
26247  
26248 @@ -797,7 +845,7 @@ static int asus_hotk_check(struct asus_h
26249         if (hotk->device->status.present) {
26250                 result = asus_hotk_get_info(hotk);
26251         } else {
26252 -               printk(KERN_NOTICE "  Hotkey device not present, aborting\n");
26253 +               printk(KERN_ERR "  Hotkey device not present, aborting\n");
26254                 return(-EINVAL);
26255         }
26256  
26257 @@ -806,7 +854,7 @@ static int asus_hotk_check(struct asus_h
26258  
26259  
26260  
26261 -static int asus_hotk_add(struct acpi_device *device)
26262 +static int __init asus_hotk_add(struct acpi_device *device)
26263  {
26264         struct asus_hotk *hotk = NULL;
26265         acpi_status status = AE_OK;
26266 @@ -815,6 +863,9 @@ static int asus_hotk_add(struct acpi_dev
26267         if (!device)
26268                 return(-EINVAL);
26269  
26270 +       printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n",
26271 +              ASUS_ACPI_VERSION);
26272 +
26273         hotk =
26274             (struct asus_hotk *) kmalloc(sizeof(struct asus_hotk), GFP_KERNEL);
26275         if (!hotk)
26276 @@ -842,25 +893,23 @@ static int asus_hotk_add(struct acpi_dev
26277          */
26278         status = acpi_install_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY,
26279                                              asus_hotk_notify, hotk);
26280 -       if (ACPI_FAILURE(status)) {
26281 -               printk(KERN_NOTICE
26282 -                      "  Error installing notify handler\n");
26283 -       } else {
26284 -               printk(KERN_DEBUG
26285 -                      "  Notify Handler installed successfully\n");
26286 -       }
26287 +       if (ACPI_FAILURE(status))
26288 +               printk(KERN_ERR "  Error installing notify handler\n");
26289  
26290 -       /* For HOTK laptops: init the hotk->brightness value */
26291 +       /* For laptops without GPLV: init the hotk->brightness value */
26292         if ((!hotk->methods->brightness_get) && (!hotk->methods->brightness_status) &&
26293             (hotk->methods->brightness_up && hotk->methods->brightness_down)) {
26294                 status = acpi_evaluate_object(NULL, hotk->methods->brightness_down,
26295                                               NULL, NULL);
26296                 if (ACPI_FAILURE(status))
26297 -                       printk(KERN_NOTICE "  Error changing brightness\n");
26298 -               status = acpi_evaluate_object(NULL, hotk->methods->brightness_up,
26299 -                                             NULL, NULL);
26300 -               if (ACPI_FAILURE(status))
26301 -                       printk(KERN_NOTICE "  Error changing brightness\n");
26302 +                       printk(KERN_WARNING "  Error changing brightness\n");
26303 +               else {
26304 +                       status = acpi_evaluate_object(NULL, hotk->methods->brightness_up,
26305 +                                                     NULL, NULL);
26306 +                       if (ACPI_FAILURE(status))
26307 +                               printk(KERN_WARNING "  Strange, error changing" 
26308 +                                      " brightness\n");
26309 +               }
26310         }
26311  
26312        end:
26313 @@ -887,7 +936,7 @@ static int asus_hotk_remove(struct acpi_
26314         status = acpi_remove_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY,
26315                                             asus_hotk_notify);
26316         if (ACPI_FAILURE(status))
26317 -               printk(KERN_NOTICE "Error removing notify handler\n");
26318 +               printk(KERN_ERR "Asus ACPI: Error removing notify handler\n");
26319  
26320         kfree(hotk);
26321  
26322 @@ -899,35 +948,17 @@ static int asus_hotk_remove(struct acpi_
26323  
26324  static int __init asus_acpi_init(void)
26325  {
26326 -       int result = 0;
26327 -       acpi_status status = 0;
26328 -       struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL };
26329 -
26330 -       printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n",
26331 -              ASUS_ACPI_VERSION);
26332 -       /*
26333 -        * Here is the code to know the model we are running on. We need to
26334 -        * know this before calling the acpi_bus_register_driver function, in
26335 -        * case the HID for the laptop we are running on is different from
26336 -        * ACPI_HOTK_HID, which I have never seen yet :)
26337 -        * 
26338 -        * This information is then available in the global var asus_info
26339 -        */
26340 -       status = acpi_get_table(ACPI_TABLE_DSDT, 1, &dsdt);
26341 -       if (ACPI_FAILURE(status)) {
26342 -               printk(KERN_NOTICE "  Couldn't get the DSDT table header\n");
26343 -       } else {
26344 -               asus_info = (struct acpi_table_header *) dsdt.pointer;
26345 -       }
26346 +       int result;
26347  
26348         asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir);
26349 -       if (!asus_proc_dir)
26350 +       if (!asus_proc_dir) {
26351 +               printk(KERN_ERR "Asus ACPI: Unable to create /proc entry");
26352                 return(-ENODEV);
26353 +       }
26354         asus_proc_dir->owner = THIS_MODULE;
26355  
26356         result = acpi_bus_register_driver(&asus_hotk_driver);
26357         if (result < 0) {
26358 -               printk(KERN_NOTICE "  Error registering " ACPI_HOTK_NAME " \n");
26359                 remove_proc_entry(PROC_ASUS, acpi_root_dir);
26360                 return(-ENODEV);
26361         }
26362 --- linux-2.6.0-test6/drivers/acpi/bus.c        2003-08-22 19:23:40.000000000 -0700
26363 +++ 25/drivers/acpi/bus.c       2003-10-05 00:33:23.000000000 -0700
26364 @@ -634,8 +634,7 @@ acpi_bus_init (void)
26365          * the EC parameters out of that.
26366          */
26367         status = acpi_ec_ecdt_probe();
26368 -       if (ACPI_FAILURE(status))
26369 -               goto error1;
26370 +       /* Ignore result. Not having an ECDT is not fatal. */
26371  #endif
26372  
26373         status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
26374 --- linux-2.6.0-test6/drivers/acpi/dispatcher/dsfield.c 2003-06-14 12:18:25.000000000 -0700
26375 +++ 25/drivers/acpi/dispatcher/dsfield.c        2003-10-05 00:33:23.000000000 -0700
26376 @@ -105,27 +105,33 @@ acpi_ds_create_buffer_field (
26377                 return_ACPI_STATUS (AE_AML_NO_OPERAND);
26378         }
26379  
26380 -       /*
26381 -        * During the load phase, we want to enter the name of the field into
26382 -        * the namespace.  During the execute phase (when we evaluate the size
26383 -        * operand), we want to lookup the name
26384 -        */
26385 -       if (walk_state->parse_flags & ACPI_PARSE_EXECUTE) {
26386 -               flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE;
26387 +       if (walk_state->deferred_node) {
26388 +               node = walk_state->deferred_node;
26389 +               status = AE_OK;
26390         }
26391         else {
26392 -               flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND;
26393 -       }
26394 +               /*
26395 +                * During the load phase, we want to enter the name of the field into
26396 +                * the namespace.  During the execute phase (when we evaluate the size
26397 +                * operand), we want to lookup the name
26398 +                */
26399 +               if (walk_state->parse_flags & ACPI_PARSE_EXECUTE) {
26400 +                       flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE;
26401 +               }
26402 +               else {
26403 +                       flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND;
26404 +               }
26405  
26406 -       /*
26407 -        * Enter the name_string into the namespace
26408 -        */
26409 -       status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string,
26410 -                        ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1,
26411 -                        flags, walk_state, &(node));
26412 -       if (ACPI_FAILURE (status)) {
26413 -               ACPI_REPORT_NSERROR (arg->common.value.string, status);
26414 -               return_ACPI_STATUS (status);
26415 +               /*
26416 +                * Enter the name_string into the namespace
26417 +                */
26418 +               status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string,
26419 +                                ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1,
26420 +                                flags, walk_state, &(node));
26421 +               if (ACPI_FAILURE (status)) {
26422 +                       ACPI_REPORT_NSERROR (arg->common.value.string, status);
26423 +                       return_ACPI_STATUS (status);
26424 +               }
26425         }
26426  
26427         /* We could put the returned object (Node) on the object stack for later, but
26428 --- linux-2.6.0-test6/drivers/acpi/dispatcher/dsinit.c  2003-06-14 12:18:34.000000000 -0700
26429 +++ 25/drivers/acpi/dispatcher/dsinit.c 2003-10-05 00:33:23.000000000 -0700
26430 @@ -135,7 +135,7 @@ acpi_ds_init_one_object (
26431                 }
26432  
26433                 /*
26434 -                * Always parse methods to detect errors, we may delete
26435 +                * Always parse methods to detect errors, we will delete
26436                  * the parse tree below
26437                  */
26438                 status = acpi_ds_parse_method (obj_handle);
26439 @@ -150,7 +150,7 @@ acpi_ds_init_one_object (
26440                 }
26441  
26442                 /*
26443 -                * Delete the parse tree.  We simple re-parse the method
26444 +                * Delete the parse tree.  We simply re-parse the method
26445                  * for every execution since there isn't much overhead
26446                  */
26447                 acpi_ns_delete_namespace_subtree (obj_handle);
26448 --- linux-2.6.0-test6/drivers/acpi/dispatcher/dsopcode.c        2003-06-14 12:18:30.000000000 -0700
26449 +++ 25/drivers/acpi/dispatcher/dsopcode.c       2003-10-05 00:33:23.000000000 -0700
26450 @@ -65,7 +65,7 @@
26451   *
26452   * RETURN:      Status.
26453   *
26454 - * DESCRIPTION: Late execution of region or field arguments
26455 + * DESCRIPTION: Late (deferred) execution of region or field arguments
26456   *
26457   ****************************************************************************/
26458  
26459 @@ -111,7 +111,10 @@ acpi_ds_execute_arguments (
26460                 return_ACPI_STATUS (status);
26461         }
26462  
26463 +       /* Mark this parse as a deferred opcode */
26464 +
26465         walk_state->parse_flags = ACPI_PARSE_DEFERRED_OP;
26466 +       walk_state->deferred_node = node;
26467  
26468         /* Pass1: Parse the entire declaration */
26469  
26470 @@ -128,7 +131,7 @@ acpi_ds_execute_arguments (
26471         arg->common.node = node;
26472         acpi_ps_delete_parse_tree (op);
26473  
26474 -       /* Evaluate the address and length arguments for the Buffer Field */
26475 +       /* Evaluate the deferred arguments */
26476  
26477         op = acpi_ps_alloc_op (AML_INT_EVAL_SUBTREE_OP);
26478         if (!op) {
26479 @@ -144,6 +147,8 @@ acpi_ds_execute_arguments (
26480                 return_ACPI_STATUS (AE_NO_MEMORY);
26481         }
26482  
26483 +       /* Execute the opcode and arguments */
26484 +
26485         status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start,
26486                           aml_length, NULL, NULL, 3);
26487         if (ACPI_FAILURE (status)) {
26488 @@ -151,6 +156,9 @@ acpi_ds_execute_arguments (
26489                 return_ACPI_STATUS (status);
26490         }
26491  
26492 +       /* Mark this execution as a deferred opcode */
26493 +
26494 +       walk_state->deferred_node = node;
26495         status = acpi_ps_parse_aml (walk_state);
26496         acpi_ps_delete_parse_tree (op);
26497         return_ACPI_STATUS (status);
26498 @@ -192,7 +200,7 @@ acpi_ds_get_buffer_field_arguments (
26499         node = obj_desc->buffer_field.node;
26500  
26501         ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (ACPI_TYPE_BUFFER_FIELD, node, NULL));
26502 -       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] buffer_field JIT Init\n",
26503 +       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] buffer_field Arg Init\n",
26504                 node->name.ascii));
26505  
26506         /* Execute the AML code for the term_arg arguments */
26507 @@ -207,7 +215,7 @@ acpi_ds_get_buffer_field_arguments (
26508   *
26509   * FUNCTION:    acpi_ds_get_buffer_arguments
26510   *
26511 - * PARAMETERS:  obj_desc        - A valid Bufferobject
26512 + * PARAMETERS:  obj_desc        - A valid Buffer object
26513   *
26514   * RETURN:      Status.
26515   *
26516 @@ -240,7 +248,7 @@ acpi_ds_get_buffer_arguments (
26517                 return_ACPI_STATUS (AE_AML_INTERNAL);
26518         }
26519  
26520 -       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer JIT Init\n"));
26521 +       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n"));
26522  
26523         /* Execute the AML code for the term_arg arguments */
26524  
26525 @@ -254,7 +262,7 @@ acpi_ds_get_buffer_arguments (
26526   *
26527   * FUNCTION:    acpi_ds_get_package_arguments
26528   *
26529 - * PARAMETERS:  obj_desc        - A valid Packageobject
26530 + * PARAMETERS:  obj_desc        - A valid Package object
26531   *
26532   * RETURN:      Status.
26533   *
26534 @@ -287,7 +295,7 @@ acpi_ds_get_package_arguments (
26535                 return_ACPI_STATUS (AE_AML_INTERNAL);
26536         }
26537  
26538 -       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package JIT Init\n"));
26539 +       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n"));
26540  
26541         /* Execute the AML code for the term_arg arguments */
26542  
26543 @@ -335,11 +343,12 @@ acpi_ds_get_region_arguments (
26544  
26545         node = obj_desc->region.node;
26546  
26547 -       ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (ACPI_TYPE_REGION, node, NULL));
26548 +       ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_REGION, node, NULL));
26549  
26550 -       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] op_region Init at AML %p\n",
26551 +       ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] op_region Arg Init at AML %p\n",
26552                 node->name.ascii, extra_desc->extra.aml_start));
26553  
26554 +       /* Execute the argument AML */
26555  
26556         status = acpi_ds_execute_arguments (node, acpi_ns_get_parent_node (node),
26557                          extra_desc->extra.aml_length, extra_desc->extra.aml_start);
26558 @@ -505,14 +514,16 @@ acpi_ds_init_buffer_field (
26559                 goto cleanup;
26560         }
26561  
26562 -
26563         /* Entire field must fit within the current length of the buffer */
26564  
26565         if ((bit_offset + bit_count) >
26566                 (8 * (u32) buffer_desc->buffer.length)) {
26567                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
26568 -                       "Field size %d exceeds Buffer size %d (bits)\n",
26569 -                        bit_offset + bit_count, 8 * (u32) buffer_desc->buffer.length));
26570 +                       "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n",
26571 +                       ((struct acpi_namespace_node *) result_desc)->name.ascii,
26572 +                        bit_offset + bit_count,
26573 +                        buffer_desc->buffer.node->name.ascii,
26574 +                        8 * (u32) buffer_desc->buffer.length));
26575                 status = AE_AML_BUFFER_LIMIT;
26576                 goto cleanup;
26577         }
26578 --- linux-2.6.0-test6/drivers/acpi/dispatcher/dsutils.c 2003-06-14 12:18:09.000000000 -0700
26579 +++ 25/drivers/acpi/dispatcher/dsutils.c        2003-10-05 00:33:23.000000000 -0700
26580 @@ -53,6 +53,7 @@
26581  #define _COMPONENT          ACPI_DISPATCHER
26582          ACPI_MODULE_NAME    ("dsutils")
26583  
26584 +
26585  #ifndef ACPI_NO_METHOD_EXECUTION
26586  
26587  /*******************************************************************************
26588 @@ -196,7 +197,6 @@ result_not_used:
26589                         acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op));
26590  
26591         return_VALUE (FALSE);
26592 -
26593  }
26594  
26595  
26596 @@ -239,7 +239,6 @@ acpi_ds_delete_result_if_not_used (
26597                 return_VOID;
26598         }
26599  
26600 -
26601         if (!acpi_ds_is_result_used (op, walk_state)) {
26602                 /*
26603                  * Must pop the result stack (obj_desc should be equal to result_obj)
26604 @@ -389,61 +388,77 @@ acpi_ds_create_operand (
26605                  * in name_string
26606                  */
26607  
26608 +
26609                 /*
26610 -                * Differentiate between a namespace "create" operation
26611 -                * versus a "lookup" operation (IMODE_LOAD_PASS2 vs.
26612 -                * IMODE_EXECUTE) in order to support the creation of
26613 -                * namespace objects during the execution of control methods.
26614 +                * Special handling for buffer_field declarations. This is a deferred
26615 +                * opcode that unfortunately defines the field name as the last
26616 +                * parameter instead of the first.  We get here when we are performing
26617 +                * the deferred execution, so the actual name of the field is already
26618 +                * in the namespace.  We don't want to attempt to look it up again
26619 +                * because we may be executing in a different scope than where the
26620 +                * actual opcode exists.
26621                  */
26622 -               parent_op = arg->common.parent;
26623 -               op_info = acpi_ps_get_opcode_info (parent_op->common.aml_opcode);
26624 -               if ((op_info->flags & AML_NSNODE) &&
26625 -                       (parent_op->common.aml_opcode != AML_INT_METHODCALL_OP) &&
26626 -                       (parent_op->common.aml_opcode != AML_REGION_OP) &&
26627 -                       (parent_op->common.aml_opcode != AML_INT_NAMEPATH_OP)) {
26628 -                       /* Enter name into namespace if not found */
26629 -
26630 -                       interpreter_mode = ACPI_IMODE_LOAD_PASS2;
26631 +               if ((walk_state->deferred_node) &&
26632 +                       (walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD) &&
26633 +                       (arg_index != 0)) {
26634 +                       obj_desc = ACPI_CAST_PTR (union acpi_operand_object, walk_state->deferred_node);
26635 +                       status = AE_OK;
26636                 }
26637 +               else    /* All other opcodes */ {
26638 +                       /*
26639 +                        * Differentiate between a namespace "create" operation
26640 +                        * versus a "lookup" operation (IMODE_LOAD_PASS2 vs.
26641 +                        * IMODE_EXECUTE) in order to support the creation of
26642 +                        * namespace objects during the execution of control methods.
26643 +                        */
26644 +                       parent_op = arg->common.parent;
26645 +                       op_info = acpi_ps_get_opcode_info (parent_op->common.aml_opcode);
26646 +                       if ((op_info->flags & AML_NSNODE) &&
26647 +                               (parent_op->common.aml_opcode != AML_INT_METHODCALL_OP) &&
26648 +                               (parent_op->common.aml_opcode != AML_REGION_OP) &&
26649 +                               (parent_op->common.aml_opcode != AML_INT_NAMEPATH_OP)) {
26650 +                               /* Enter name into namespace if not found */
26651  
26652 -               else {
26653 -                       /* Return a failure if name not found */
26654 -
26655 -                       interpreter_mode = ACPI_IMODE_EXECUTE;
26656 -               }
26657 +                               interpreter_mode = ACPI_IMODE_LOAD_PASS2;
26658 +                       }
26659 +                       else {
26660 +                               /* Return a failure if name not found */
26661  
26662 -               status = acpi_ns_lookup (walk_state->scope_info, name_string,
26663 -                                ACPI_TYPE_ANY, interpreter_mode,
26664 -                                ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
26665 -                                walk_state,
26666 -                                ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &obj_desc));
26667 -               /*
26668 -                * The only case where we pass through (ignore) a NOT_FOUND
26669 -                * error is for the cond_ref_of opcode.
26670 -                */
26671 -               if (status == AE_NOT_FOUND) {
26672 -                       if (parent_op->common.aml_opcode == AML_COND_REF_OF_OP) {
26673 -                               /*
26674 -                                * For the Conditional Reference op, it's OK if
26675 -                                * the name is not found;  We just need a way to
26676 -                                * indicate this to the interpreter, set the
26677 -                                * object to the root
26678 -                                */
26679 -                               obj_desc = ACPI_CAST_PTR (union acpi_operand_object, acpi_gbl_root_node);
26680 -                               status = AE_OK;
26681 +                               interpreter_mode = ACPI_IMODE_EXECUTE;
26682                         }
26683  
26684 -                       else {
26685 -                               /*
26686 -                                * We just plain didn't find it -- which is a
26687 -                                * very serious error at this point
26688 -                                */
26689 -                               status = AE_AML_NAME_NOT_FOUND;
26690 +                       status = acpi_ns_lookup (walk_state->scope_info, name_string,
26691 +                                        ACPI_TYPE_ANY, interpreter_mode,
26692 +                                        ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
26693 +                                        walk_state,
26694 +                                        ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &obj_desc));
26695 +                       /*
26696 +                        * The only case where we pass through (ignore) a NOT_FOUND
26697 +                        * error is for the cond_ref_of opcode.
26698 +                        */
26699 +                       if (status == AE_NOT_FOUND) {
26700 +                               if (parent_op->common.aml_opcode == AML_COND_REF_OF_OP) {
26701 +                                       /*
26702 +                                        * For the Conditional Reference op, it's OK if
26703 +                                        * the name is not found;  We just need a way to
26704 +                                        * indicate this to the interpreter, set the
26705 +                                        * object to the root
26706 +                                        */
26707 +                                       obj_desc = ACPI_CAST_PTR (union acpi_operand_object, acpi_gbl_root_node);
26708 +                                       status = AE_OK;
26709 +                               }
26710 +                               else {
26711 +                                       /*
26712 +                                        * We just plain didn't find it -- which is a
26713 +                                        * very serious error at this point
26714 +                                        */
26715 +                                       status = AE_AML_NAME_NOT_FOUND;
26716 +                               }
26717                         }
26718 -               }
26719  
26720 -               if (ACPI_FAILURE (status)) {
26721 -                       ACPI_REPORT_NSERROR (name_string, status);
26722 +                       if (ACPI_FAILURE (status)) {
26723 +                               ACPI_REPORT_NSERROR (name_string, status);
26724 +                       }
26725                 }
26726  
26727                 /* Free the namestring created above */
26728 @@ -464,8 +479,6 @@ acpi_ds_create_operand (
26729                 }
26730                 ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
26731         }
26732 -
26733 -
26734         else {
26735                 /* Check for null name case */
26736  
26737 @@ -480,7 +493,6 @@ acpi_ds_create_operand (
26738  
26739                         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Null namepath: Arg=%p\n", arg));
26740                 }
26741 -
26742                 else {
26743                         opcode = arg->common.aml_opcode;
26744                 }
26745 --- linux-2.6.0-test6/drivers/acpi/dispatcher/dswload.c 2003-06-14 12:17:57.000000000 -0700
26746 +++ 25/drivers/acpi/dispatcher/dswload.c        2003-10-05 00:33:23.000000000 -0700
26747 @@ -248,6 +248,14 @@ acpi_ds_load1_begin_op (
26748                  *       buffer_field, or Package), the name of the object is already
26749                  *       in the namespace.
26750                  */
26751 +               if (walk_state->deferred_node) {
26752 +                       /* This name is already in the namespace, get the node */
26753 +
26754 +                       node = walk_state->deferred_node;
26755 +                       status = AE_OK;
26756 +                       break;
26757 +               }
26758 +
26759                 flags = ACPI_NS_NO_UPSEARCH;
26760                 if ((walk_state->opcode != AML_SCOPE_OP) &&
26761                         (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) {
26762 @@ -589,7 +597,17 @@ acpi_ds_load2_begin_op (
26763                  * Enter the named type into the internal namespace.  We enter the name
26764                  * as we go downward in the parse tree.  Any necessary subobjects that involve
26765                  * arguments to the opcode must be created as we go back up the parse tree later.
26766 +                *
26767 +                * Note: Name may already exist if we are executing a deferred opcode.
26768                  */
26769 +               if (walk_state->deferred_node) {
26770 +                       /* This name is already in the namespace, get the node */
26771 +
26772 +                       node = walk_state->deferred_node;
26773 +                       status = AE_OK;
26774 +                       break;
26775 +               }
26776 +
26777                 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
26778                                   ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, walk_state, &(node));
26779                 break;
26780 --- linux-2.6.0-test6/drivers/acpi/dispatcher/dswscope.c        2003-06-14 12:18:51.000000000 -0700
26781 +++ 25/drivers/acpi/dispatcher/dswscope.c       2003-10-05 00:33:23.000000000 -0700
26782 @@ -121,10 +121,9 @@ acpi_ds_scope_stack_push (
26783         /* Make sure object type is valid */
26784  
26785         if (!acpi_ut_valid_object_type (type)) {
26786 -               ACPI_REPORT_WARNING (("ds_scope_stack_push: type code out of range\n"));
26787 +               ACPI_REPORT_WARNING (("ds_scope_stack_push: Invalid object type: 0x%X\n", type));
26788         }
26789  
26790 -
26791         /* Allocate a new scope object */
26792  
26793         scope_info = acpi_ut_create_generic_state ();
26794 @@ -146,13 +145,13 @@ acpi_ds_scope_stack_push (
26795         old_scope_info = walk_state->scope_info;
26796         if (old_scope_info) {
26797                 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
26798 -                       "[%4.4s] (%10s)",
26799 +                       "[%4.4s] (%s)",
26800                         old_scope_info->scope.node->name.ascii,
26801                         acpi_ut_get_type_name (old_scope_info->common.value)));
26802         }
26803         else {
26804                 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
26805 -                       "[\\___] (%10s)", "ROOT"));
26806 +                       "[\\___] (%s)", "ROOT"));
26807         }
26808  
26809         ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
26810 @@ -163,7 +162,6 @@ acpi_ds_scope_stack_push (
26811         /* Push new scope object onto stack */
26812  
26813         acpi_ut_push_generic_state (&walk_state->scope_info, scope_info);
26814 -
26815         return_ACPI_STATUS (AE_OK);
26816  }
26817  
26818 @@ -207,7 +205,7 @@ acpi_ds_scope_stack_pop (
26819         walk_state->scope_depth--;
26820  
26821         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
26822 -               "[%.2d] Popped scope [%4.4s] (%10s), New scope -> ",
26823 +               "[%.2d] Popped scope [%4.4s] (%s), New scope -> ",
26824                 (u32) walk_state->scope_depth,
26825                 scope_info->scope.node->name.ascii,
26826                 acpi_ut_get_type_name (scope_info->common.value)));
26827 @@ -225,7 +223,6 @@ acpi_ds_scope_stack_pop (
26828         }
26829  
26830         acpi_ut_delete_generic_state (scope_info);
26831 -
26832         return_ACPI_STATUS (AE_OK);
26833  }
26834  
26835 --- linux-2.6.0-test6/drivers/acpi/dispatcher/dswstate.c        2003-06-14 12:18:32.000000000 -0700
26836 +++ 25/drivers/acpi/dispatcher/dswstate.c       2003-10-05 00:33:23.000000000 -0700
26837 @@ -56,11 +56,12 @@
26838   * FUNCTION:    acpi_ds_result_insert
26839   *
26840   * PARAMETERS:  Object              - Object to push
26841 + *              Index               - Where to insert the object
26842   *              walk_state          - Current Walk state
26843   *
26844   * RETURN:      Status
26845   *
26846 - * DESCRIPTION: Push an object onto this walk's result stack
26847 + * DESCRIPTION: Insert an object onto this walk's result stack
26848   *
26849   ******************************************************************************/
26850  
26851 @@ -114,6 +115,7 @@ acpi_ds_result_insert (
26852   * FUNCTION:    acpi_ds_result_remove
26853   *
26854   * PARAMETERS:  Object              - Where to return the popped object
26855 + *              Index               - Where to extract the object
26856   *              walk_state          - Current Walk state
26857   *
26858   * RETURN:      Status
26859 @@ -233,6 +235,7 @@ acpi_ds_result_pop (
26860         return (AE_AML_NO_RETURN_VALUE);
26861  }
26862  
26863 +
26864  /*******************************************************************************
26865   *
26866   * FUNCTION:    acpi_ds_result_pop_from_bottom
26867 @@ -295,7 +298,6 @@ acpi_ds_result_pop_from_bottom (
26868                 *object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL",
26869                 state, walk_state));
26870  
26871 -
26872         return (AE_OK);
26873  }
26874  
26875 @@ -358,8 +360,7 @@ acpi_ds_result_push (
26876   *
26877   * FUNCTION:    acpi_ds_result_stack_push
26878   *
26879 - * PARAMETERS:  Object              - Object to push
26880 - *              walk_state          - Current Walk state
26881 + * PARAMETERS:  walk_state          - Current Walk state
26882   *
26883   * RETURN:      Status
26884   *
26885 @@ -420,7 +421,6 @@ acpi_ds_result_stack_pop (
26886                 return (AE_AML_NO_OPERAND);
26887         }
26888  
26889 -
26890         state = acpi_ut_pop_generic_state (&walk_state->results);
26891  
26892         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
26893 @@ -572,6 +572,7 @@ acpi_ds_obj_stack_pop_object (
26894  }
26895  #endif
26896  
26897 +
26898  /*******************************************************************************
26899   *
26900   * FUNCTION:    acpi_ds_obj_stack_pop
26901 @@ -641,6 +642,7 @@ acpi_ds_obj_stack_pop_and_delete (
26902         u32                             i;
26903         union acpi_operand_object       *obj_desc;
26904  
26905 +
26906         ACPI_FUNCTION_NAME ("ds_obj_stack_pop_and_delete");
26907  
26908  
26909 @@ -883,8 +885,15 @@ acpi_ds_create_walk_state (
26910   * FUNCTION:    acpi_ds_init_aml_walk
26911   *
26912   * PARAMETERS:  walk_state      - New state to be initialized
26913 + *              Op              - Current parse op
26914 + *              method_node     - Control method NS node, if any
26915 + *              aml_start       - Start of AML
26916 + *              aml_length      - Length of AML
26917 + *              Params          - Method args, if any
26918 + *              return_obj_desc - Where to store a return object, if any
26919 + *              pass_number     - 1, 2, or 3
26920   *
26921 - * RETURN:      None
26922 + * RETURN:      Status
26923   *
26924   * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk
26925   *
26926 @@ -927,9 +936,9 @@ acpi_ds_init_aml_walk (
26927  
26928         if (method_node) {
26929                 walk_state->parser_state.start_node = method_node;
26930 -               walk_state->walk_type               = ACPI_WALK_METHOD;
26931 -               walk_state->method_node             = method_node;
26932 -               walk_state->method_desc             = acpi_ns_get_attached_object (method_node);
26933 +               walk_state->walk_type            = ACPI_WALK_METHOD;
26934 +               walk_state->method_node          = method_node;
26935 +               walk_state->method_desc          = acpi_ns_get_attached_object (method_node);
26936  
26937                 /* Push start scope on scope stack and make it current  */
26938  
26939 @@ -956,6 +965,7 @@ acpi_ds_init_aml_walk (
26940                 while (extra_op && !extra_op->common.node) {
26941                         extra_op = extra_op->common.parent;
26942                 }
26943 +
26944                 if (!extra_op) {
26945                         parser_state->start_node = NULL;
26946                 }
26947 @@ -1014,7 +1024,7 @@ acpi_ds_delete_walk_state (
26948                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", walk_state));
26949         }
26950  
26951 -   /* Always must free any linked control states */
26952 +       /* Always must free any linked control states */
26953  
26954         while (walk_state->control_state) {
26955                 state = walk_state->control_state;
26956 --- linux-2.6.0-test6/drivers/acpi/ec.c 2003-06-14 12:18:22.000000000 -0700
26957 +++ 25/drivers/acpi/ec.c        2003-10-05 00:33:24.000000000 -0700
26958 @@ -32,7 +32,7 @@
26959  #include <asm/io.h>
26960  #include <acpi/acpi_bus.h>
26961  #include <acpi/acpi_drivers.h>
26962 -
26963 +#include <acpi/actypes.h>
26964  
26965  #define _COMPONENT             ACPI_EC_COMPONENT
26966  ACPI_MODULE_NAME               ("acpi_ec")
26967 @@ -412,7 +412,10 @@ acpi_ec_space_setup (
26968          * The EC object is in the handler context and is needed
26969          * when calling the acpi_ec_space_handler.
26970          */
26971 -       *return_context = handler_context;
26972 +       if(function == ACPI_REGION_DEACTIVATE) 
26973 +               *return_context = NULL;
26974 +       else 
26975 +               *return_context = handler_context;
26976  
26977         return AE_OK;
26978  }
26979 --- linux-2.6.0-test6/drivers/acpi/events/evregion.c    2003-06-14 12:18:25.000000000 -0700
26980 +++ 25/drivers/acpi/events/evregion.c   2003-10-05 00:33:24.000000000 -0700
26981 @@ -382,7 +382,7 @@ acpi_ev_detach_region(
26982         union acpi_operand_object       *obj_desc;
26983         union acpi_operand_object       **last_obj_ptr;
26984         acpi_adr_space_setup            region_setup;
26985 -       void                            *region_context;
26986 +       void                            **region_context;
26987         union acpi_operand_object       *region_obj2;
26988         acpi_status                     status;
26989  
26990 @@ -394,7 +394,7 @@ acpi_ev_detach_region(
26991         if (!region_obj2) {
26992                 return_VOID;
26993         }
26994 -       region_context = region_obj2->extra.region_context;
26995 +       region_context = &region_obj2->extra.region_context;
26996  
26997         /* Get the address handler from the region object */
26998  
26999 @@ -450,7 +450,7 @@ acpi_ev_detach_region(
27000  
27001                         region_setup = handler_obj->address_space.setup;
27002                         status = region_setup (region_obj, ACPI_REGION_DEACTIVATE,
27003 -                                         handler_obj->address_space.context, &region_context);
27004 +                                         handler_obj->address_space.context, region_context);
27005  
27006                         /* Init routine may fail, Just ignore errors */
27007  
27008 --- linux-2.6.0-test6/drivers/acpi/executer/excreate.c  2003-06-14 12:18:34.000000000 -0700
27009 +++ 25/drivers/acpi/executer/excreate.c 2003-10-05 00:33:24.000000000 -0700
27010 @@ -286,7 +286,7 @@ acpi_ex_create_region (
27011         ACPI_FUNCTION_TRACE ("ex_create_region");
27012  
27013  
27014 -       /* Get the Node from the object stack  */
27015 +       /* Get the Namespace Node */
27016  
27017         node = walk_state->op->common.node;
27018  
27019 @@ -311,7 +311,6 @@ acpi_ex_create_region (
27020         ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n",
27021                           acpi_ut_get_region_name (region_space), region_space));
27022  
27023 -
27024         /* Create the region descriptor */
27025  
27026         obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_REGION);
27027 @@ -375,6 +374,7 @@ acpi_ex_create_table_region (
27028  
27029         ACPI_FUNCTION_TRACE ("ex_create_table_region");
27030  
27031 +
27032         /* Get the Node from the object stack  */
27033  
27034         node = walk_state->op->common.node;
27035 @@ -392,7 +392,6 @@ acpi_ex_create_table_region (
27036         status = acpi_tb_find_table (operand[1]->string.pointer,
27037                            operand[2]->string.pointer,
27038                            operand[3]->string.pointer, &table);
27039 -
27040         if (ACPI_FAILURE (status)) {
27041                 return_ACPI_STATUS (status);
27042         }
27043 @@ -489,7 +488,6 @@ acpi_ex_create_processor (
27044         status = acpi_ns_attach_object ((struct acpi_namespace_node *) operand[0],
27045                           obj_desc, ACPI_TYPE_PROCESSOR);
27046  
27047 -
27048         /* Remove local reference to the object */
27049  
27050         acpi_ut_remove_reference (obj_desc);
27051 @@ -540,7 +538,6 @@ acpi_ex_create_power_resource (
27052         status = acpi_ns_attach_object ((struct acpi_namespace_node *) operand[0],
27053                           obj_desc, ACPI_TYPE_POWER);
27054  
27055 -
27056         /* Remove local reference to the object */
27057  
27058         acpi_ut_remove_reference (obj_desc);
27059 @@ -609,7 +606,6 @@ acpi_ex_create_method (
27060                 obj_desc->method.concurrency = (u8)
27061                                   (((method_flags & METHOD_FLAGS_SYNCH_LEVEL) >> 4) + 1);
27062         }
27063 -
27064         else {
27065                 obj_desc->method.concurrency = INFINITE_CONCURRENCY;
27066         }
27067 --- linux-2.6.0-test6/drivers/acpi/executer/exfldio.c   2003-06-14 12:18:06.000000000 -0700
27068 +++ 25/drivers/acpi/executer/exfldio.c  2003-10-05 00:33:24.000000000 -0700
27069 @@ -139,7 +139,41 @@ acpi_ex_setup_region (
27070                         field_datum_byte_offset, obj_desc->common_field.access_byte_width,
27071                         rgn_desc->region.node->name.ascii, rgn_desc->region.length));
27072  
27073 -               return_ACPI_STATUS (AE_AML_REGION_LIMIT);
27074 +               #ifdef CONFIG_ACPI_RELAXED_AML
27075 +               {
27076 +                       /*
27077 +                        * Allow access to the field if it is within the region size
27078 +                        * rounded up to a multiple of the access byte width.  This
27079 +                        * overcomes "off-by-one" programming errors in the AML often
27080 +                        * found in Toshiba laptops.  These errors were allowed by
27081 +                        * the Microsoft ASL compiler.
27082 +                        */
27083 +                       u32 rounded_length = ACPI_ROUND_UP(rgn_desc->region.length,
27084 +                                                                       obj_desc->common_field.access_byte_width);
27085 +
27086 +                       if (rounded_length < (obj_desc->common_field.base_byte_offset
27087 +                                               + field_datum_byte_offset
27088 +                                               + obj_desc->common_field.access_byte_width)) {
27089 +                               return_ACPI_STATUS (AE_AML_REGION_LIMIT);
27090 +                       } else {
27091 +                               static int      warn_once = 1;
27092 +                               if (warn_once) {
27093 +                                       // Could also associate a flag with each field, and
27094 +                                       // warn once for each field.
27095 +                                       ACPI_REPORT_WARNING((
27096 +                                               "The ACPI AML in your computer contains errors, "
27097 +                                               "please nag the manufacturer to correct it.\n"));
27098 +                                       ACPI_REPORT_WARNING((
27099 +                                               "Allowing relaxed access to fields; "
27100 +                                               "turn on CONFIG_ACPI_DEBUG for details.\n"));
27101 +                                       warn_once = 0;
27102 +                               }
27103 +                               return_ACPI_STATUS (AE_OK);
27104 +                       }
27105 +               }
27106 +               #else
27107 +                       return_ACPI_STATUS (AE_AML_REGION_LIMIT);
27108 +               #endif
27109         }
27110  
27111         return_ACPI_STATUS (AE_OK);
27112 --- linux-2.6.0-test6/drivers/acpi/Kconfig      2003-09-27 18:57:44.000000000 -0700
27113 +++ 25/drivers/acpi/Kconfig     2003-10-05 00:36:23.000000000 -0700
27114 @@ -3,34 +3,14 @@
27115  #
27116  
27117  menu "ACPI (Advanced Configuration and Power Interface) Support"
27118 -
27119 -config ACPI_HT
27120 -       bool "ACPI Processor Enumeration for HT"
27121 -       depends on X86
27122 -       default y
27123 -       ---help---
27124 -         ACPI enumerates both logical (a.k.a. Hyper-Threaded -- HT)
27125 -         and physical processors.  It is designed to obsolete several older
27126 -         specifications, including the MultiProcessor Specification (MPS),
27127 -         which supported only physical processors.
27128 -
27129 -         CONFIG_ACPI_HT includes the minimal ACPI boot-time code
27130 -         necessary to enumerate logical processors and enable HT.
27131 -
27132 -         CONFIG_ACPI includes CONFIG_ACPI_HT, plus IO APIC enumeration,
27133 -         and the hooks to run the ACPI AML interpreter for run-time events.
27134 -
27135 -         When CONFIG_ACPI is selected, the command-line option "acpi=ht"
27136 -         is available to run just the ACPI boot-time code -- just as if
27137 -         only CONFIG_ACPI_HT were selected.
27138 -
27139 -         Note that "acpi=off" can be used to disable all ACPI code in the kernel.
27140 -
27141 -config ACPI
27142 -       bool "Full ACPI Support"
27143         depends on !X86_VISWS
27144         depends on !IA64_HP_SIM
27145 -       depends on IA64 || (X86 || ACPI_HT)
27146 +       depends on IA64 || X86
27147 +
27148 +config ACPI
27149 +       bool "ACPI Support"
27150 +       depends on IA64 || X86
27151 +
27152         default y
27153         ---help---
27154           Advanced Configuration and Power Interface (ACPI) support for 
27155 @@ -62,12 +42,19 @@ config ACPI
27156  
27157  config ACPI_BOOT
27158         bool
27159 -       depends on ACPI || ACPI_HT
27160 +       depends on ACPI || X86_HT
27161 +       default y
27162 +
27163 +config ACPI_INTERPRETER
27164 +       bool
27165 +       depends on ACPI
27166 +       depends on !IA64_SGI_SN
27167         default y
27168  
27169  config ACPI_SLEEP
27170         bool "Sleep States (EXPERIMENTAL)"
27171         depends on X86 && ACPI
27172 +       depends on ACPI_INTERPRETER
27173         depends on EXPERIMENTAL && PM
27174         default y
27175         ---help---
27176 @@ -93,7 +80,8 @@ config ACPI_SLEEP_PROC_FS
27177  
27178  config ACPI_AC
27179         tristate "AC Adapter"
27180 -       depends on X86 && ACPI
27181 +       depends on X86
27182 +       depends on ACPI_INTERPRETER
27183         default m
27184         help
27185           This driver adds support for the AC Adapter object, which indicates
27186 @@ -102,7 +90,8 @@ config ACPI_AC
27187  
27188  config ACPI_BATTERY
27189         tristate "Battery"
27190 -       depends on X86 && ACPI
27191 +       depends on X86
27192 +       depends on ACPI_INTERPRETER
27193         default m
27194         help
27195           This driver adds support for battery information through
27196 @@ -111,7 +100,7 @@ config ACPI_BATTERY
27197  
27198  config ACPI_BUTTON
27199         tristate "Button"
27200 -       depends on ACPI
27201 +       depends on ACPI_INTERPRETER
27202         depends on !IA64_SGI_SN
27203         default m
27204         help
27205 @@ -123,7 +112,7 @@ config ACPI_BUTTON
27206  
27207  config ACPI_FAN
27208         tristate "Fan"
27209 -       depends on ACPI
27210 +       depends on ACPI_INTERPRETER
27211         depends on !IA64_SGI_SN
27212         default m
27213         help
27214 @@ -132,7 +121,7 @@ config ACPI_FAN
27215  
27216  config ACPI_PROCESSOR
27217         tristate "Processor"
27218 -       depends on ACPI
27219 +       depends on ACPI_INTERPRETER
27220         depends on !IA64_SGI_SN
27221         default m
27222         help
27223 @@ -152,14 +141,15 @@ config ACPI_THERMAL
27224  
27225  config ACPI_NUMA
27226         bool "NUMA support"
27227 -       depends on ACPI
27228 +       depends on ACPI_INTERPRETER
27229         depends on NUMA
27230         depends on !X86_64
27231         default y if IA64_GENERIC || IA64_SGI_SN2
27232  
27233  config ACPI_ASUS
27234          tristate "ASUS/Medion Laptop Extras"
27235 -        depends on X86 && ACPI
27236 +       depends on X86
27237 +       depends on ACPI_INTERPRETER
27238         default m
27239          ---help---
27240            This driver provides support for extra features of ACPI-compatible
27241 @@ -170,6 +160,9 @@ config ACPI_ASUS
27242            display brightness and output, switching the LCD backlight on and off,
27243            and most importantly, allows you to blink those fancy LEDs intended
27244            for reporting mail and wireless status.
27245 +
27246 +         Note: display switching code is currently considered EXPERIMENTAL,
27247 +         toying with these values may even lock your machine.
27248            
27249            All settings are changed via /proc/acpi/asus directory entries. Owner
27250            and group for these entries can be set with asus_uid and asus_gid
27251 @@ -185,7 +178,8 @@ config ACPI_ASUS
27252            
27253  config ACPI_TOSHIBA
27254         tristate "Toshiba Laptop Extras"
27255 -       depends on X86 && ACPI
27256 +       depends on X86
27257 +       depends on ACPI_INTERPRETER
27258         default m
27259         ---help---
27260           This driver adds support for access to certain system settings
27261 @@ -212,7 +206,7 @@ config ACPI_TOSHIBA
27262  
27263  config ACPI_DEBUG
27264         bool "Debug Statements"
27265 -       depends on ACPI
27266 +       depends on ACPI_INTERPRETER
27267         depends on !IA64_SGI_SN
27268         default n
27269         help
27270 @@ -222,19 +216,14 @@ config ACPI_DEBUG
27271  
27272  config ACPI_BUS
27273         bool
27274 -       depends on ACPI
27275 -       depends on !IA64_SGI_SN
27276 -       default y
27277 -
27278 -config ACPI_INTERPRETER
27279 -       bool
27280 -       depends on ACPI
27281 +       depends on ACPI_INTERPRETER
27282         depends on !IA64_SGI_SN
27283         default y
27284  
27285  config ACPI_EC
27286         bool
27287 -       depends on X86 && ACPI
27288 +       depends on X86
27289 +       depends on ACPI_INTERPRETER
27290         default y
27291         help
27292           This driver is required on some systems for the proper operation of
27293 @@ -243,19 +232,19 @@ config ACPI_EC
27294  
27295  config ACPI_POWER
27296         bool
27297 -       depends on ACPI
27298 +       depends on ACPI_INTERPRETER
27299         depends on !IA64_SGI_SN
27300         default y
27301  
27302  config ACPI_PCI
27303         bool
27304 -       depends on ACPI
27305 +       depends on ACPI_INTERPRETER
27306         depends on !IA64_SGI_SN
27307         default PCI
27308  
27309  config ACPI_SYSTEM
27310         bool
27311 -       depends on ACPI
27312 +       depends on ACPI_INTERPRETER
27313         depends on !IA64_SGI_SN
27314         default y
27315         help
27316 @@ -263,10 +252,28 @@ config ACPI_SYSTEM
27317           dump your ACPI DSDT table using /proc/acpi/dsdt.
27318  
27319  config ACPI_EFI
27320 -       bool
27321 -       depends on ACPI
27322 -       depends on IA64
27323 -       default y
27324 +       bool "Obtain RSDP from EFI Configuration Table"
27325 +       depends on ACPI_INTERPRETER
27326 +       depends on IA64 || X86
27327 +       default n
27328 +       help
27329 +          On EFI Systems the RSDP pointer is passed to the kernel via
27330 +          the EFI Configuration Table.  On Itanium systems this is
27331 +          standard and required.  For IA-32, systems that have
27332 +          EFI firmware should leave this enabled.  Platforms with
27333 +          traditional legacy BIOS should disable this option.
27334 +
27335 +config ACPI_RELAXED_AML
27336 +       bool "Relaxed AML"
27337 +       depends on ACPI_INTERPRETER
27338 +       depends on !IA64_SGI_SN
27339 +       default n
27340 +       help
27341 +         If you say `Y' here, the ACPI interpreter will relax its checking
27342 +         for valid AML and will ignore some AML mistakes, such as off-by-one
27343 +         errors in region sizes.  Some laptops may require this option.  In
27344 +         particular, many Toshiba laptops require this for correct operation
27345 +         of the AC module.
27346  
27347  endmenu
27348  
27349 --- linux-2.6.0-test6/drivers/acpi/Makefile     2003-08-22 19:23:40.000000000 -0700
27350 +++ 25/drivers/acpi/Makefile    2003-10-05 00:33:23.000000000 -0700
27351 @@ -18,7 +18,7 @@ obj-$(CONFIG_ACPI)            := acpi_ksyms.o 
27352  # ACPI Boot-Time Table Parsing
27353  #
27354  obj-$(CONFIG_ACPI_BOOT)                += tables.o
27355 -obj-$(CONFIG_ACPI)             += blacklist.o
27356 +obj-$(CONFIG_ACPI_INTERPRETER) += blacklist.o
27357  
27358  #
27359  # ACPI Core Subsystem (Interpreter)
27360 --- linux-2.6.0-test6/drivers/acpi/namespace/nsdump.c   2003-06-14 12:18:33.000000000 -0700
27361 +++ 25/drivers/acpi/namespace/nsdump.c  2003-10-05 00:33:24.000000000 -0700
27362 @@ -234,7 +234,7 @@ acpi_ns_dump_one_object (
27363  
27364                 case ACPI_TYPE_DEVICE:
27365  
27366 -                       acpi_os_printf ("Notify object: %p", obj_desc);
27367 +                       acpi_os_printf ("Notify Object: %p\n", obj_desc);
27368                         break;
27369  
27370  
27371 @@ -371,7 +371,7 @@ acpi_ns_dump_one_object (
27372                 case ACPI_TYPE_LOCAL_BANK_FIELD:
27373                 case ACPI_TYPE_LOCAL_INDEX_FIELD:
27374  
27375 -                       acpi_os_printf (" Off %.2X Len %.2X Acc %.2hd\n",
27376 +                       acpi_os_printf ("Off %.2X Len %.2X Acc %.2hd\n",
27377                                         (obj_desc->common_field.base_byte_offset * 8)
27378                                                 + obj_desc->common_field.start_field_bit_offset,
27379                                         obj_desc->common_field.bit_length,
27380 --- linux-2.6.0-test6/drivers/acpi/namespace/nssearch.c 2003-06-14 12:18:34.000000000 -0700
27381 +++ 25/drivers/acpi/namespace/nssearch.c        2003-10-05 00:33:24.000000000 -0700
27382 @@ -96,7 +96,7 @@ acpi_ns_search_node (
27383  
27384                 scope_name = acpi_ns_get_external_pathname (node);
27385                 if (scope_name) {
27386 -                       ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching %s [%p] For %4.4s (%s)\n",
27387 +                       ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching %s (%p) For [%4.4s] (%s)\n",
27388                                 scope_name, node, (char *) &target_name, acpi_ut_get_type_name (type)));
27389  
27390                         ACPI_MEM_FREE (scope_name);
27391 @@ -117,9 +117,9 @@ acpi_ns_search_node (
27392                          * Found matching entry.
27393                          */
27394                         ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
27395 -                               "Name %4.4s Type [%s] found in scope [%4.4s] %p\n",
27396 +                               "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n",
27397                                 (char *) &target_name, acpi_ut_get_type_name (next_node->type),
27398 -                               next_node->name.ascii, next_node));
27399 +                               next_node, node->name.ascii, node));
27400  
27401                         *return_node = next_node;
27402                         return_ACPI_STATUS (AE_OK);
27403 @@ -143,7 +143,7 @@ acpi_ns_search_node (
27404         /* Searched entire namespace level, not found */
27405  
27406         ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
27407 -               "Name %4.4s Type [%s] not found in search in scope [%4.4s] %p first child %p\n",
27408 +               "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n",
27409                 (char *) &target_name, acpi_ut_get_type_name (type),
27410                 node->name.ascii, node, node->child));
27411  
27412 --- linux-2.6.0-test6/drivers/acpi/namespace/nsutils.c  2003-06-14 12:18:21.000000000 -0700
27413 +++ 25/drivers/acpi/namespace/nsutils.c 2003-10-05 00:33:24.000000000 -0700
27414 @@ -175,6 +175,11 @@ acpi_ns_print_node_pathname (
27415         acpi_status                     status;
27416  
27417  
27418 +       if (!node) {
27419 +               acpi_os_printf ("[NULL NAME]");
27420 +               return;
27421 +       }
27422 +
27423         /* Convert handle to a full pathname and print it (with supplied message) */
27424  
27425         buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
27426 @@ -470,11 +475,11 @@ acpi_ns_build_internal_name (
27427         *result = 0;
27428  
27429         if (info->fully_qualified) {
27430 -               ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "returning [%p] (abs) \"\\%s\"\n",
27431 +               ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n",
27432                         internal_name, internal_name));
27433         }
27434         else {
27435 -               ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "returning [%p] (rel) \"%s\"\n",
27436 +               ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n",
27437                         internal_name, internal_name));
27438         }
27439  
27440 --- linux-2.6.0-test6/drivers/acpi/osl.c        2003-08-22 19:23:40.000000000 -0700
27441 +++ 25/drivers/acpi/osl.c       2003-10-05 00:36:22.000000000 -0700
27442 @@ -43,7 +43,6 @@
27443  
27444  #ifdef CONFIG_ACPI_EFI
27445  #include <linux/efi.h>
27446 -u64 efi_mem_attributes (u64 phys_addr);
27447  #endif
27448  
27449  
27450 --- linux-2.6.0-test6/drivers/acpi/parser/psparse.c     2003-06-14 12:17:59.000000000 -0700
27451 +++ 25/drivers/acpi/parser/psparse.c    2003-10-05 00:33:24.000000000 -0700
27452 @@ -437,7 +437,6 @@ acpi_ps_parse_loop (
27453                 return_ACPI_STATUS (AE_BAD_PARAMETER);
27454         }
27455  
27456 -
27457         parser_state = &walk_state->parser_state;
27458         walk_state->arg_types = 0;
27459  
27460 @@ -705,10 +704,9 @@ acpi_ps_parse_loop (
27461                                 walk_state->arg_types = 0;
27462                                 break;
27463  
27464 -
27465                         default:
27466  
27467 -                               /* Op is not a constant or string, append each argument */
27468 +                               /* Op is not a constant or string, append each argument to the Op */
27469  
27470                                 while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) &&
27471                                                 !walk_state->arg_count) {
27472 @@ -727,23 +725,23 @@ acpi_ps_parse_loop (
27473                                         INCREMENT_ARG_LIST (walk_state->arg_types);
27474                                 }
27475  
27476 +                               /* Special processing for certain opcodes */
27477 +
27478                                 switch (op->common.aml_opcode) {
27479                                 case AML_METHOD_OP:
27480  
27481 -                                       /* For a method, save the length and address of the body */
27482 -
27483                                         /*
27484 -                                        * Skip parsing of control method or opregion body,
27485 +                                        * Skip parsing of control method
27486                                          * because we don't have enough info in the first pass
27487 -                                        * to parse them correctly.
27488 +                                        * to parse it correctly.
27489 +                                        *
27490 +                                        * Save the length and address of the body
27491                                          */
27492                                         op->named.data   = parser_state->aml;
27493                                         op->named.length = (u32) (parser_state->pkg_end - parser_state->aml);
27494 -                                       /*
27495 -                                        * Skip body of method.  For op_regions, we must continue
27496 -                                        * parsing because the opregion is not a standalone
27497 -                                        * package (We don't know where the end is).
27498 -                                        */
27499 +
27500 +                                       /* Skip body of method */
27501 +
27502                                         parser_state->aml   = parser_state->pkg_end;
27503                                         walk_state->arg_count = 0;
27504                                         break;
27505 @@ -756,15 +754,15 @@ acpi_ps_parse_loop (
27506                                                 (op->common.parent->common.aml_opcode == AML_NAME_OP) &&
27507                                                 (walk_state->descending_callback != acpi_ds_exec_begin_op)) {
27508                                                 /*
27509 -                                                * Skip parsing of
27510 +                                                * Skip parsing of Buffers and Packages
27511                                                  * because we don't have enough info in the first pass
27512                                                  * to parse them correctly.
27513                                                  */
27514                                                 op->named.data   = aml_op_start;
27515                                                 op->named.length = (u32) (parser_state->pkg_end - aml_op_start);
27516 -                                               /*
27517 -                                                * Skip body
27518 -                                                */
27519 +
27520 +                                               /* Skip body */
27521 +
27522                                                 parser_state->aml   = parser_state->pkg_end;
27523                                                 walk_state->arg_count = 0;
27524                                         }
27525 @@ -778,6 +776,7 @@ acpi_ps_parse_loop (
27526                                         break;
27527  
27528                                 default:
27529 +
27530                                         /* No action for all other opcodes */
27531                                         break;
27532                                 }
27533 --- linux-2.6.0-test6/drivers/acpi/pci_irq.c    2003-08-22 19:23:40.000000000 -0700
27534 +++ 25/drivers/acpi/pci_irq.c   2003-10-05 00:36:20.000000000 -0700
27535 @@ -71,6 +71,9 @@ acpi_pci_irq_find_prt_entry (
27536  
27537         ACPI_FUNCTION_TRACE("acpi_pci_irq_find_prt_entry");
27538  
27539 +       if (!acpi_prt.count)
27540 +               return_PTR(NULL);
27541 +
27542         /*
27543          * Parse through all PRT entries looking for a match on the specified
27544          * PCI device's segment, bus, device, and pin (don't care about func).
27545 @@ -234,7 +237,7 @@ acpi_pci_irq_add_prt (
27546                            PCI Interrupt Routing Support
27547     -------------------------------------------------------------------------- */
27548  
27549 -static int
27550 +int
27551  acpi_pci_irq_lookup (struct pci_bus *bus, int device, int pin)
27552  {
27553         struct acpi_prt_entry   *entry = NULL;
27554 --- linux-2.6.0-test6/drivers/acpi/pci_link.c   2003-09-08 13:58:56.000000000 -0700
27555 +++ 25/drivers/acpi/pci_link.c  2003-10-05 00:33:24.000000000 -0700
27556 @@ -220,7 +220,6 @@ acpi_pci_link_check_current (
27557         return AE_CTRL_TERMINATE;
27558  }
27559  
27560 -
27561  static int
27562  acpi_pci_link_get_current (
27563         struct acpi_pci_link    *link)
27564 @@ -279,6 +278,28 @@ end:
27565         return_VALUE(result);
27566  }
27567  
27568 +static int
27569 +acpi_pci_link_try_get_current (
27570 +       struct acpi_pci_link *link,
27571 +       int irq)
27572 +{
27573 +       int result;
27574 +
27575 +       ACPI_FUNCTION_TRACE("acpi_pci_link_try_get_current");
27576 +
27577 +       result = acpi_pci_link_get_current(link);
27578 +       if (result && link->irq.active) {
27579 +               return_VALUE(result);
27580 +       }
27581 +
27582 +       if (!link->irq.active) {
27583 +               ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No active IRQ resource found\n"));
27584 +               printk(KERN_WARNING "_CRS returns NULL! Using IRQ %d for device (%s [%s]).\n", irq, acpi_device_name(link->device), acpi_device_bid(link->device));
27585 +               link->irq.active = irq;
27586 +       }
27587 +       
27588 +       return 0;
27589 +}
27590  
27591  static int
27592  acpi_pci_link_set (
27593 @@ -294,6 +315,7 @@ acpi_pci_link_set (
27594         struct acpi_buffer      buffer = {sizeof(resource)+1, &resource};
27595         int                     i = 0;
27596         int                     valid = 0;
27597 +       int                     resource_type = 0;
27598  
27599         ACPI_FUNCTION_TRACE("acpi_pci_link_set");
27600  
27601 @@ -317,20 +339,32 @@ acpi_pci_link_set (
27602                 }
27603         }
27604  
27605 +       /* If IRQ<=15, first try with a "normal" IRQ descriptor. If that fails, try with
27606 +        * an extended one */
27607 +       if (irq <= 15) {
27608 +               resource_type = ACPI_RSTYPE_IRQ;
27609 +       } else {
27610 +               resource_type = ACPI_RSTYPE_EXT_IRQ;
27611 +       }
27612 +
27613 +retry_programming:
27614 +   
27615         memset(&resource, 0, sizeof(resource));
27616  
27617         /* NOTE: PCI interrupts are always level / active_low / shared. But not all
27618            interrupts > 15 are PCI interrupts. Rely on the ACPI IRQ definition for 
27619            parameters */
27620 -       if (irq <= 15) {
27621 +       switch(resource_type) {
27622 +       case ACPI_RSTYPE_IRQ:
27623                 resource.res.id = ACPI_RSTYPE_IRQ;
27624                 resource.res.length = sizeof(struct acpi_resource);
27625                 resource.res.data.irq.edge_level = link->irq.edge_level;
27626                 resource.res.data.irq.active_high_low = link->irq.active_high_low;
27627                 resource.res.data.irq.number_of_interrupts = 1;
27628                 resource.res.data.irq.interrupts[0] = irq;
27629 -       }
27630 -       else {
27631 +               break;
27632 +          
27633 +       case ACPI_RSTYPE_EXT_IRQ:
27634                 resource.res.id = ACPI_RSTYPE_EXT_IRQ;
27635                 resource.res.length = sizeof(struct acpi_resource);
27636                 resource.res.data.extended_irq.producer_consumer = ACPI_CONSUMER;
27637 @@ -339,11 +373,21 @@ acpi_pci_link_set (
27638                 resource.res.data.extended_irq.number_of_interrupts = 1;
27639                 resource.res.data.extended_irq.interrupts[0] = irq;
27640                 /* ignore resource_source, it's optional */
27641 +               break;
27642         }
27643         resource.end.id = ACPI_RSTYPE_END_TAG;
27644  
27645         /* Attempt to set the resource */
27646         status = acpi_set_current_resources(link->handle, &buffer);
27647 +
27648 +       /* if we failed and IRQ <= 15, try again with an extended descriptor */
27649 +       if (ACPI_FAILURE(status) && (resource_type == ACPI_RSTYPE_IRQ)) {
27650 +                resource_type = ACPI_RSTYPE_EXT_IRQ;
27651 +                printk(PREFIX "Retrying with extended IRQ descriptor\n");
27652 +                goto retry_programming;
27653 +       }
27654 +  
27655 +       /* check for total failure */
27656         if (ACPI_FAILURE(status)) {
27657                 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SRS\n"));
27658                 return_VALUE(-ENODEV);
27659 @@ -361,7 +405,7 @@ acpi_pci_link_set (
27660         }
27661  
27662         /* Make sure the active IRQ is the one we requested. */
27663 -       result = acpi_pci_link_get_current(link);
27664 +       result = acpi_pci_link_try_get_current(link, irq);
27665         if (result) {
27666                 return_VALUE(result);
27667         }
27668 @@ -456,16 +500,16 @@ static int acpi_pci_link_allocate(struct
27669                 irq = link->irq.active;
27670         } else {
27671                 irq = link->irq.possible[0];
27672 -       }
27673  
27674 -               /* 
27675 -                * Select the best IRQ.  This is done in reverse to promote 
27676 +               /*
27677 +                * Select the best IRQ.  This is done in reverse to promote
27678                  * the use of IRQs 9, 10, 11, and >15.
27679                  */
27680                 for (i=(link->irq.possible_count-1); i>0; i--) {
27681                         if (acpi_irq_penalty[irq] > acpi_irq_penalty[link->irq.possible[i]])
27682                                 irq = link->irq.possible[i];
27683                 }
27684 +       }
27685  
27686         /* Attempt to enable the link device at this IRQ. */
27687         if (acpi_pci_link_set(link, irq)) {
27688 @@ -574,10 +618,6 @@ acpi_pci_link_add (
27689                 else
27690                         printk(" %d", link->irq.possible[i]);
27691         }
27692 -       if (!link->irq.active)
27693 -               printk(", disabled");
27694 -       else if (!found)
27695 -               printk(", enabled at IRQ %d", link->irq.active);
27696         printk(")\n");
27697  
27698         /* TBD: Acquire/release lock */
27699 --- linux-2.6.0-test6/drivers/acpi/tables.c     2003-08-22 19:23:40.000000000 -0700
27700 +++ 25/drivers/acpi/tables.c    2003-10-05 00:33:24.000000000 -0700
27701 @@ -69,7 +69,8 @@ struct acpi_table_sdt {
27702  
27703  static unsigned long           sdt_pa;         /* Physical Address */
27704  static unsigned long           sdt_count;      /* Table count */
27705 -static struct acpi_table_sdt   *sdt_entry;
27706 +
27707 +static struct acpi_table_sdt   sdt_entry[ACPI_MAX_TABLES];
27708  
27709  void
27710  acpi_table_print (
27711 @@ -418,12 +419,6 @@ acpi_table_get_sdt (
27712                         sdt_count = ACPI_MAX_TABLES;
27713                 }
27714  
27715 -               sdt_entry = alloc_bootmem(sdt_count * sizeof(struct acpi_table_sdt));
27716 -               if (!sdt_entry) {
27717 -                       printk(KERN_ERR "ACPI: Could not allocate mem for SDT entries!\n");
27718 -                       return -ENOMEM;
27719 -               }
27720 -
27721                 for (i = 0; i < sdt_count; i++)
27722                         sdt_entry[i].pa = (unsigned long) mapped_xsdt->entry[i];
27723         }
27724 @@ -470,12 +465,6 @@ acpi_table_get_sdt (
27725                         sdt_count = ACPI_MAX_TABLES;
27726                 }
27727  
27728 -               sdt_entry = alloc_bootmem(sdt_count * sizeof(struct acpi_table_sdt));
27729 -               if (!sdt_entry) {
27730 -                       printk(KERN_ERR "ACPI: Could not allocate mem for SDT entries!\n");
27731 -                       return -ENOMEM;
27732 -               }
27733 -
27734                 for (i = 0; i < sdt_count; i++)
27735                         sdt_entry[i].pa = (unsigned long) mapped_rsdt->entry[i];
27736         }
27737 --- linux-2.6.0-test6/drivers/acpi/toshiba_acpi.c       2003-08-22 19:23:40.000000000 -0700
27738 +++ 25/drivers/acpi/toshiba_acpi.c      2003-10-05 00:33:24.000000000 -0700
27739 @@ -41,7 +41,6 @@
27740  #include <linux/init.h>
27741  #include <linux/types.h>
27742  #include <linux/proc_fs.h>
27743 -#include <linux/version.h>
27744  
27745  #include <acpi/acpi_drivers.h>
27746  
27747 --- linux-2.6.0-test6/drivers/acpi/utilities/utdelete.c 2003-06-14 12:18:20.000000000 -0700
27748 +++ 25/drivers/acpi/utilities/utdelete.c        2003-10-05 00:34:43.000000000 -0700
27749 @@ -417,6 +417,8 @@ acpi_ut_update_object_reference (
27750         union acpi_generic_state         *state_list = NULL;
27751         union acpi_generic_state         *state;
27752  
27753 +       union acpi_operand_object        *tmp;
27754 +
27755  
27756         ACPI_FUNCTION_TRACE_PTR ("ut_update_object_reference", object);
27757  
27758 @@ -448,8 +450,15 @@ acpi_ut_update_object_reference (
27759                 switch (ACPI_GET_OBJECT_TYPE (object)) {
27760                 case ACPI_TYPE_DEVICE:
27761  
27762 -                       acpi_ut_update_ref_count (object->device.system_notify, action);
27763 -                       acpi_ut_update_ref_count (object->device.device_notify, action);
27764 +                       tmp = object->device.system_notify;
27765 +                       if(tmp && tmp->common.reference_count<=1 && action == REF_DECREMENT)
27766 +                               object->device.system_notify = NULL;
27767 +                       acpi_ut_update_ref_count (tmp, action);
27768 +
27769 +                       tmp = object->device.device_notify;
27770 +                       if(tmp && tmp->common.reference_count <=1 && action == REF_DECREMENT)
27771 +                               object->device.device_notify = NULL;
27772 +                       acpi_ut_update_ref_count (tmp, action);
27773                         break;
27774  
27775  
27776 @@ -467,6 +476,9 @@ acpi_ut_update_object_reference (
27777                                  */
27778                                 status = acpi_ut_create_update_state_and_push (
27779                                                  object->package.elements[i], action, &state_list);
27780 +                               tmp = object->package.elements[i];
27781 +                               if(tmp && tmp->common.reference_count<=1  && action == REF_DECREMENT) /*reference count didn't refresh now*/
27782 +                                       object->package.elements[i] = NULL;
27783                                 if (ACPI_FAILURE (status)) {
27784                                         goto error_exit;
27785                                 }
27786 @@ -478,6 +490,9 @@ acpi_ut_update_object_reference (
27787  
27788                         status = acpi_ut_create_update_state_and_push (
27789                                          object->buffer_field.buffer_obj, action, &state_list);
27790 +                       tmp = object->buffer_field.buffer_obj;
27791 +                       if( tmp && tmp->common.reference_count <=1  && action == REF_DECREMENT)/*reference count didn't refresh now*/
27792 +                               object->buffer_field.buffer_obj = NULL;
27793                         if (ACPI_FAILURE (status)) {
27794                                 goto error_exit;
27795                         }
27796 @@ -491,6 +506,9 @@ acpi_ut_update_object_reference (
27797                         if (ACPI_FAILURE (status)) {
27798                                 goto error_exit;
27799                         }
27800 +                       tmp = object->field.region_obj;
27801 +                       if( tmp && tmp->common.reference_count <=1  && action == REF_DECREMENT)/*reference count didn't refresh now*/
27802 +                               object->field.region_obj = NULL;
27803                    break;
27804  
27805  
27806 @@ -501,12 +519,18 @@ acpi_ut_update_object_reference (
27807                         if (ACPI_FAILURE (status)) {
27808                                 goto error_exit;
27809                         }
27810 +                       tmp = object->bank_field.bank_obj;
27811 +                       if( tmp && tmp->common.reference_count <=1  && action == REF_DECREMENT)/*reference count didn't refresh now*/
27812 +                               object->bank_field.bank_obj = NULL;
27813  
27814                         status = acpi_ut_create_update_state_and_push (
27815                                          object->bank_field.region_obj, action, &state_list);
27816                         if (ACPI_FAILURE (status)) {
27817                                 goto error_exit;
27818                         }
27819 +                       tmp = object->bank_field.region_obj;
27820 +                       if( tmp && tmp->common.reference_count <=1  && action == REF_DECREMENT)/*reference count didn't refresh now*/
27821 +                               object->bank_field.region_obj = NULL;
27822                         break;
27823  
27824  
27825 @@ -517,12 +541,18 @@ acpi_ut_update_object_reference (
27826                         if (ACPI_FAILURE (status)) {
27827                                 goto error_exit;
27828                         }
27829 +                       tmp = object->index_field.index_obj;
27830 +                       if( tmp && tmp->common.reference_count <=1  && action == REF_DECREMENT)/*reference count didn't refresh now*/
27831 +                               object->index_field.index_obj = NULL;
27832  
27833                         status = acpi_ut_create_update_state_and_push (
27834                                          object->index_field.data_obj, action, &state_list);
27835                         if (ACPI_FAILURE (status)) {
27836                                 goto error_exit;
27837                         }
27838 +                       tmp = object->index_field.data_obj;
27839 +                       if( tmp && tmp->common.reference_count <=1  && action == REF_DECREMENT)/*reference count didn't refresh now*/
27840 +                               object->index_field.data_obj = NULL;
27841                         break;
27842  
27843  
27844 --- linux-2.6.0-test6/drivers/block/acsi.c      2003-09-27 18:57:44.000000000 -0700
27845 +++ 25/drivers/block/acsi.c     2003-10-05 00:34:00.000000000 -0700
27846 @@ -63,6 +63,7 @@ typedef void Scsi_Device; /* hack to avo
27847  #include <linux/hdreg.h> /* for HDIO_GETGEO */
27848  #include <linux/blkpg.h>
27849  #include <linux/buffer_head.h>
27850 +#include <linux/blkdev.h>
27851  
27852  #include <asm/setup.h>
27853  #include <asm/pgtable.h>
27854 @@ -346,7 +347,7 @@ struct acsi_error {
27855  static int acsicmd_dma( const char *cmd, char *buffer, int blocks, int
27856                          rwflag, int enable);
27857  static int acsi_reqsense( char *buffer, int targ, int lun);
27858 -static void acsi_print_error(const unsigned char *errblk, int struct acsi_info_struct *aip);
27859 +static void acsi_print_error(const unsigned char *errblk, struct acsi_info_struct *aip);
27860  static irqreturn_t acsi_interrupt (int irq, void *data, struct pt_regs *fp);
27861  static void unexpected_acsi_interrupt( void );
27862  static void bad_rw_intr( void );
27863 @@ -358,10 +359,9 @@ static void copy_from_acsibuffer( void )
27864  static void do_end_requests( void );
27865  static void do_acsi_request( request_queue_t * );
27866  static void redo_acsi_request( void );
27867 -static int acsi_ioctl( struct inode *inode, struct file *file, unsigned int
27868 +static int acsi_ioctl(struct block_device *bdev, struct file *file, unsigned int
27869                         cmd, unsigned long arg );
27870 -static int acsi_open( struct inode * inode, struct file * filp );
27871 -static int acsi_release( struct inode * inode, struct file * file );
27872 +static int acsi_open(struct block_device *bdev, struct file *filp);
27873  static void acsi_prevent_removal(struct acsi_info_struct *aip, int flag );
27874  static int acsi_change_blk_size( int target, int lun);
27875  static int acsi_mode_sense( int target, int lun, SENSE_DATA *sd );
27876 @@ -1080,10 +1080,10 @@ static void redo_acsi_request( void )
27877   ***********************************************************************/
27878  
27879  
27880 -static int acsi_ioctl( struct inode *inode, struct file *file,
27881 -                                          unsigned int cmd, unsigned long arg )
27882 +static int acsi_ioctl(struct block_device *bdev, struct file *file,
27883 +                     unsigned int cmd, unsigned long arg )
27884  {
27885 -       struct gendisk *disk = inode->i_bdev->bd_disk;
27886 +       struct gendisk *disk = bdev->bd_disk;
27887         struct acsi_info_struct *aip = disk->private_data;
27888         switch (cmd) {
27889           case HDIO_GETGEO:
27890 @@ -1095,7 +1095,7 @@ static int acsi_ioctl( struct inode *ino
27891             put_user( 64, &geo->heads );
27892             put_user( 32, &geo->sectors );
27893             put_user( aip->size >> 11, &geo->cylinders );
27894 -               put_user(get_start_sect(inode->i_bdev), &geo->start);
27895 +               put_user(get_start_sect(bdev), &geo->start);
27896                 return 0;
27897           }
27898           case SCSI_IOCTL_GET_IDLUN:
27899 @@ -1125,16 +1125,16 @@ static int acsi_ioctl( struct inode *ino
27900   *
27901   */
27902  
27903 -static int acsi_open( struct inode * inode, struct file * filp )
27904 +static int acsi_open(struct block_device *bdev, struct file *filp)
27905  {
27906 -       struct gendisk *disk = inode->i_bdev->bd_disk;
27907 +       struct gendisk *disk = bdev->bd_disk;
27908         struct acsi_info_struct *aip = disk->private_data;
27909  
27910         if (aip->access_count == 0 && aip->removable) {
27911  #if 0
27912                 aip->changed = 1;       /* safety first */
27913  #endif
27914 -               check_disk_change( inode->i_bdev );
27915 +               check_disk_change(bdev);
27916                 if (aip->changed)       /* revalidate was not successful (no medium) */
27917                         return -ENXIO;
27918                 acsi_prevent_removal(aip, 1);
27919 @@ -1142,10 +1142,11 @@ static int acsi_open( struct inode * ino
27920         aip->access_count++;
27921  
27922         if (filp && filp->f_mode) {
27923 -               check_disk_change( inode->i_bdev );
27924 +               check_disk_change(bdev);
27925                 if (filp->f_mode & 2) {
27926                         if (aip->read_only) {
27927 -                               acsi_release( inode, filp );
27928 +                               if (--aip->access_count == 0 && aip->removable)
27929 +                                       acsi_prevent_removal(aip, 0);
27930                                 return -EROFS;
27931                         }
27932                 }
27933 @@ -1159,9 +1160,8 @@ static int acsi_open( struct inode * ino
27934   * be forgotten about...
27935   */
27936  
27937 -static int acsi_release( struct inode * inode, struct file * file )
27938 +static int acsi_release(struct gendisk *disk)
27939  {
27940 -       struct gendisk *disk = inode->i_bdev->bd_disk;
27941         struct acsi_info_struct *aip = disk->private_data;
27942         if (--aip->access_count == 0 && aip->removable)
27943                 acsi_prevent_removal(aip, 0);
27944 @@ -1327,8 +1327,6 @@ static int acsi_mode_sense( int target, 
27945   ********************************************************************/
27946  
27947  
27948 -extern struct block_device_operations acsi_fops;
27949 -
27950  static struct gendisk *acsi_gendisk[MAX_DEV];
27951  
27952  #define MAX_SCSI_DEVICE_CODE 10
27953 --- linux-2.6.0-test6/drivers/block/amiflop.c   2003-09-08 13:58:56.000000000 -0700
27954 +++ 25/drivers/block/amiflop.c  2003-10-05 00:34:00.000000000 -0700
27955 @@ -1434,10 +1434,11 @@ static void do_fd_request(request_queue_
27956         redo_fd_request();
27957  }
27958  
27959 -static int fd_ioctl(struct inode *inode, struct file *filp,
27960 +static int fd_ioctl(struct block_device *bdev, struct file *filp,
27961                     unsigned int cmd, unsigned long param)
27962  {
27963 -       int drive = iminor(inode) & 3;
27964 +       struct amiga_floppy_struct *floppy = bdev->bd_disk->private_data;
27965 +       int drive = floppy - unit;
27966         static struct floppy_struct getprm;
27967  
27968         switch(cmd){
27969 @@ -1459,7 +1460,7 @@ static int fd_ioctl(struct inode *inode,
27970                         rel_fdc();
27971                         return -EBUSY;
27972                 }
27973 -               fsync_bdev(inode->i_bdev);
27974 +               fsync_bdev(bdev);
27975                 if (fd_motor_on(drive) == 0) {
27976                         rel_fdc();
27977                         return -ENODEV;
27978 @@ -1488,7 +1489,7 @@ static int fd_ioctl(struct inode *inode,
27979                 break;
27980         case FDFMTEND:
27981                 floppy_off(drive);
27982 -               invalidate_bdev(inode->i_bdev, 0);
27983 +               invalidate_bdev(bdev, 0);
27984                 break;
27985         case FDGETPRM:
27986                 memset((void *)&getprm, 0, sizeof (getprm));
27987 @@ -1559,10 +1560,11 @@ static void fd_probe(int dev)
27988   * /dev/PS0 etc), and disallows simultaneous access to the same
27989   * drive with different device numbers.
27990   */
27991 -static int floppy_open(struct inode *inode, struct file *filp)
27992 +static int floppy_open(struct block_device *bdev, struct file *filp)
27993  {
27994 -       int drive = iminor(inode) & 3;
27995 -       int system =  (iminor(inode) & 4) >> 2;
27996 +       struct amiga_floppy_struct *p = bdev->bd_disk->private_data;
27997 +       int drive = p - unit;
27998 +       int system =  (MINOR(bdev->bd_dev) & 4) >> 2;
27999         int old_dev;
28000         unsigned long flags;
28001  
28002 @@ -1572,7 +1574,7 @@ static int floppy_open(struct inode *ino
28003                 return -EBUSY;
28004  
28005         if (filp && filp->f_mode & 3) {
28006 -               check_disk_change(inode->i_bdev);
28007 +               check_disk_change(bdev);
28008                 if (filp->f_mode & 2 ) {
28009                         int wrprot;
28010  
28011 @@ -1607,9 +1609,10 @@ static int floppy_open(struct inode *ino
28012         return 0;
28013  }
28014  
28015 -static int floppy_release(struct inode * inode, struct file * filp)
28016 +static int floppy_release(struct gendisk *disk)
28017  {
28018 -       int drive = iminor(inode) & 3;
28019 +       struct amiga_floppy_struct *p = disk->private_data;
28020 +       int drive = p - unit;
28021  
28022         if (unit[drive].dirty == 1) {
28023                 del_timer (flush_track_timer + drive);
28024 --- linux-2.6.0-test6/drivers/block/as-iosched.c        2003-09-27 18:57:44.000000000 -0700
28025 +++ 25/drivers/block/as-iosched.c       2003-10-05 00:36:08.000000000 -0700
28026 @@ -174,12 +174,14 @@ static kmem_cache_t *arq_pool;
28027   * IO Context helper functions
28028   */
28029  /* Debug */
28030 -static atomic_t nr_as_io_requests = ATOMIC_INIT(0);
28031 +extern atomic_t global_nr_requests;
28032 +static atomic_t nr_as_io_contexts = ATOMIC_INIT(0);
28033  
28034  /* Called to deallocate the as_io_context */
28035  static void free_as_io_context(struct as_io_context *aic)
28036  {
28037 -       atomic_dec(&nr_as_io_requests);
28038 +       WARN_ON(atomic_read(&nr_as_io_contexts) == 0);
28039 +       atomic_dec(&nr_as_io_contexts);
28040         kfree(aic);
28041  }
28042  
28043 @@ -195,7 +197,9 @@ static struct as_io_context *alloc_as_io
28044  
28045         ret = kmalloc(sizeof(*ret), GFP_ATOMIC);
28046         if (ret) {
28047 -               atomic_inc(&nr_as_io_requests);
28048 +               atomic_inc(&nr_as_io_contexts);
28049 +               WARN_ON(atomic_read(&nr_as_io_contexts) ==
28050 +                       1 + nr_threads + atomic_read(&global_nr_requests));
28051                 ret->dtor = free_as_io_context;
28052                 ret->exit = exit_as_io_context;
28053                 ret->state = 1 << AS_TASK_RUNNING;
28054 @@ -914,6 +918,8 @@ static void as_completed_request(request
28055         struct as_rq *arq = RQ_DATA(rq);
28056         struct as_io_context *aic;
28057  
28058 +       WARN_ON(!list_empty(&rq->queuelist));
28059 +
28060         if (unlikely(arq->state != AS_RQ_DISPATCHED))
28061                 return;
28062  
28063 @@ -926,6 +932,7 @@ static void as_completed_request(request
28064                 if (ad->batch_data_dir == REQ_SYNC)
28065                         ad->new_batch = 1;
28066         }
28067 +       WARN_ON(ad->nr_dispatched == 0);
28068         ad->nr_dispatched--;
28069  
28070         /*
28071 @@ -1140,8 +1147,6 @@ static void as_move_to_dispatch(struct a
28072         /*
28073          * take it off the sort and fifo list, add to dispatch queue
28074          */
28075 -       as_remove_queued_request(ad->q, rq);
28076 -
28077         insert = ad->dispatch->prev;
28078  
28079         while (!list_empty(&rq->queuelist)) {
28080 @@ -1159,6 +1164,7 @@ static void as_move_to_dispatch(struct a
28081                 ad->nr_dispatched++;
28082         }
28083  
28084 +       as_remove_queued_request(ad->q, rq);
28085         list_add(&rq->queuelist, insert);
28086         if (arq->io_context && arq->io_context->aic)
28087                 atomic_inc(&arq->io_context->aic->nr_dispatched);
28088 @@ -1325,12 +1331,27 @@ static struct request *as_next_request(r
28089  static inline void
28090  as_add_aliased_request(struct as_data *ad, struct as_rq *arq, struct as_rq *alias)
28091  {
28092 +       struct request  *req = arq->request;
28093 +       struct list_head *insert = alias->request->queuelist.prev;
28094 +
28095 +       /*
28096 +        * Transfer list of aliases
28097 +        */
28098 +       while (!list_empty(&req->queuelist)) {
28099 +               struct request *__rq = list_entry_rq(req->queuelist.next);
28100 +               struct as_rq *__arq = RQ_DATA(__rq);
28101 +
28102 +               list_move_tail(&__rq->queuelist, &alias->request->queuelist);
28103 +
28104 +               WARN_ON(__arq->state != AS_RQ_QUEUED);
28105 +       }
28106 +
28107         /*
28108          * Another request with the same start sector on the rbtree.
28109          * Link this request to that sector. They are untangled in
28110          * as_move_to_dispatch
28111          */
28112 -       list_add_tail(&arq->request->queuelist, &alias->request->queuelist);
28113 +       list_add(&arq->request->queuelist, insert);
28114  
28115         /*
28116          * Don't want to have to handle merges.
28117 @@ -1390,9 +1411,6 @@ static void as_add_request(struct as_dat
28118                 }
28119         }
28120  
28121 -
28122 -
28123 -
28124         arq->state = AS_RQ_QUEUED;
28125  }
28126  
28127 @@ -1596,7 +1614,8 @@ static void as_merged_request(request_qu
28128                  */
28129         }
28130  
28131 -       q->last_merge = req;
28132 +       if (arq->on_hash)
28133 +               q->last_merge = req;
28134  }
28135  
28136  static void
28137 --- linux-2.6.0-test6/drivers/block/ataflop.c   2003-09-08 13:58:56.000000000 -0700
28138 +++ 25/drivers/block/ataflop.c  2003-10-05 00:34:00.000000000 -0700
28139 @@ -364,13 +364,12 @@ static void finish_fdc_done( int dummy )
28140  static __inline__ void copy_buffer( void *from, void *to);
28141  static void setup_req_params( int drive );
28142  static void redo_fd_request( void);
28143 -static int fd_ioctl( struct inode *inode, struct file *filp, unsigned int
28144 +static int fd_ioctl(struct block_device *bdev, struct file *filp, unsigned int
28145                       cmd, unsigned long param);
28146  static void fd_probe( int drive );
28147  static int fd_test_drive_present( int drive );
28148  static void config_types( void );
28149 -static int floppy_open( struct inode *inode, struct file *filp );
28150 -static int floppy_release( struct inode * inode, struct file * filp );
28151 +static int floppy_open(struct block_device *bdev, struct file *filp );
28152  
28153  /************************* End of Prototypes **************************/
28154  
28155 @@ -1496,10 +1495,10 @@ void do_fd_request(request_queue_t * q)
28156         atari_enable_irq( IRQ_MFP_FDC );
28157  }
28158  
28159 -static int fd_ioctl(struct inode *inode, struct file *filp,
28160 +static int fd_ioctl(struct block_device *bdev, struct file *filp,
28161                     unsigned int cmd, unsigned long param)
28162  {
28163 -       struct gendisk *disk = inode->i_bdev->bd_disk;
28164 +       struct gendisk *disk = bdev->bd_disk;
28165         struct atari_floppy_struct *floppy = disk->private_data;
28166         int drive = floppy - unit;
28167         int type = floppy->type;
28168 @@ -1673,7 +1672,7 @@ static int fd_ioctl(struct inode *inode,
28169                 /* invalidate the buffer track to force a reread */
28170                 BufferDrive = -1;
28171                 set_bit(drive, &fake_change);
28172 -               check_disk_change(inode->i_bdev);
28173 +               check_disk_change(bdev);
28174                 return 0;
28175         default:
28176                 return -EINVAL;
28177 @@ -1816,10 +1815,10 @@ static void __init config_types( void )
28178   * drive with different device numbers.
28179   */
28180  
28181 -static int floppy_open( struct inode *inode, struct file *filp )
28182 +static int floppy_open(struct block_device *bdev, struct file *filp )
28183  {
28184 -       struct atari_floppy_struct *p = inode->i_bdev->bd_disk->private_data;
28185 -       int type  = iminor(inode) >> 2;
28186 +       struct atari_floppy_struct *p = bdev->bd_disk->private_data;
28187 +       int type  = MINOR(bdev->bd_dev) >> 2;
28188  
28189         DPRINT(("fd_open: type=%d\n",type));
28190         if (p->ref && p->type != type)
28191 @@ -1839,14 +1838,13 @@ static int floppy_open( struct inode *in
28192                 return 0;
28193  
28194         if (filp->f_mode & 3) {
28195 -               check_disk_change(inode->i_bdev);
28196 +               check_disk_change(bdev);
28197                 if (filp->f_mode & 2) {
28198                         if (p->wpstat) {
28199                                 if (p->ref < 0)
28200                                         p->ref = 0;
28201                                 else
28202                                         p->ref--;
28203 -                               floppy_release(inode, filp);
28204                                 return -EROFS;
28205                         }
28206                 }
28207 @@ -1855,9 +1853,9 @@ static int floppy_open( struct inode *in
28208  }
28209  
28210  
28211 -static int floppy_release( struct inode * inode, struct file * filp )
28212 +static int floppy_release(struct gendisk *disk)
28213  {
28214 -       struct atari_floppy_struct *p = inode->i_bdev->bd_disk->private_data;
28215 +       struct atari_floppy_struct *p = disk->private_data;
28216         if (p->ref < 0)
28217                 p->ref = 0;
28218         else if (!p->ref--) {
28219 --- linux-2.6.0-test6/drivers/block/cciss.c     2003-09-27 18:57:44.000000000 -0700
28220 +++ 25/drivers/block/cciss.c    2003-10-05 00:34:00.000000000 -0700
28221 @@ -111,12 +111,10 @@ static struct board_type products[] = {
28222  
28223  static ctlr_info_t *hba[MAX_CTLR];
28224  
28225 -static struct proc_dir_entry *proc_cciss;
28226 -
28227  static void do_cciss_request(request_queue_t *q);
28228 -static int cciss_open(struct inode *inode, struct file *filep);
28229 -static int cciss_release(struct inode *inode, struct file *filep);
28230 -static int cciss_ioctl(struct inode *inode, struct file *filep, 
28231 +static int cciss_open(struct block_device *bdev, struct file *filep);
28232 +static int cciss_release(struct gendisk *disk);
28233 +static int cciss_ioctl(struct block_device *bdev, struct file *filep, 
28234                 unsigned int cmd, unsigned long arg);
28235  
28236  static int revalidate_allvol(ctlr_info_t *host);
28237 @@ -137,8 +135,6 @@ static int cciss_proc_get_info(char *buf
28238                 int length, int *eof, void *data);
28239  static void cciss_procinit(int i);
28240  #else
28241 -static int cciss_proc_get_info(char *buffer, char **start, off_t offset, 
28242 -               int length, int *eof, void *data) { return 0;}
28243  static void cciss_procinit(int i) {}
28244  #endif /* CONFIG_PROC_FS */
28245  
28246 @@ -156,6 +152,9 @@ static struct block_device_operations cc
28247   * Report information about this controller.
28248   */
28249  #ifdef CONFIG_PROC_FS
28250 +
28251 +static struct proc_dir_entry *proc_cciss;
28252 +
28253  static int cciss_proc_get_info(char *buffer, char **start, off_t offset, 
28254                 int length, int *eof, void *data)
28255  {
28256 @@ -363,13 +362,13 @@ static inline drive_info_struct *get_drv
28257  /*
28258   * Open.  Make sure the device is really there.
28259   */
28260 -static int cciss_open(struct inode *inode, struct file *filep)
28261 +static int cciss_open(struct block_device *bdev, struct file *filep)
28262  {
28263 -       ctlr_info_t *host = get_host(inode->i_bdev->bd_disk);
28264 -       drive_info_struct *drv = get_drv(inode->i_bdev->bd_disk);
28265 +       ctlr_info_t *host = get_host(bdev->bd_disk);
28266 +       drive_info_struct *drv = get_drv(bdev->bd_disk);
28267  
28268  #ifdef CCISS_DEBUG
28269 -       printk(KERN_DEBUG "cciss_open %s\n", inode->i_bdev->bd_disk->disk_name);
28270 +       printk(KERN_DEBUG "cciss_open %s\n", bdev->bd_disk->disk_name);
28271  #endif /* CCISS_DEBUG */ 
28272  
28273         /*
28274 @@ -379,7 +378,7 @@ static int cciss_open(struct inode *inod
28275          * for "raw controller".
28276          */
28277         if (drv->nr_blocks == 0) {
28278 -               if (iminor(inode) != 0)
28279 +               if (bdev != bdev->bd_contains || drv != host->drv)
28280                         return -ENXIO;
28281                 if (!capable(CAP_SYS_ADMIN))
28282                         return -EPERM;
28283 @@ -391,13 +390,13 @@ static int cciss_open(struct inode *inod
28284  /*
28285   * Close.  Sync first.
28286   */
28287 -static int cciss_release(struct inode *inode, struct file *filep)
28288 +static int cciss_release(struct gendisk *disk)
28289  {
28290 -       ctlr_info_t *host = get_host(inode->i_bdev->bd_disk);
28291 -       drive_info_struct *drv = get_drv(inode->i_bdev->bd_disk);
28292 +       ctlr_info_t *host = get_host(disk);
28293 +       drive_info_struct *drv = get_drv(disk);
28294  
28295  #ifdef CCISS_DEBUG
28296 -       printk(KERN_DEBUG "cciss_release %s\n", inode->i_bdev->bd_disk->disk_name);
28297 +       printk(KERN_DEBUG "cciss_release %s\n", disk->disk_name);
28298  #endif /* CCISS_DEBUG */
28299  
28300         drv->usage_count--;
28301 @@ -408,10 +407,9 @@ static int cciss_release(struct inode *i
28302  /*
28303   * ioctl 
28304   */
28305 -static int cciss_ioctl(struct inode *inode, struct file *filep, 
28306 +static int cciss_ioctl(struct block_device *bdev, struct file *filep, 
28307                 unsigned int cmd, unsigned long arg)
28308  {
28309 -       struct block_device *bdev = inode->i_bdev;
28310         struct gendisk *disk = bdev->bd_disk;
28311         ctlr_info_t *host = get_host(disk);
28312         drive_info_struct *drv = get_drv(disk);
28313 @@ -434,7 +432,7 @@ static int cciss_ioctl(struct inode *ino
28314                          driver_geo.sectors = 0x3f;
28315                          driver_geo.cylinders = (int)drv->nr_blocks / (0xff*0x3f);
28316                  }
28317 -                driver_geo.start= get_start_sect(inode->i_bdev);
28318 +                driver_geo.start= get_start_sect(bdev);
28319                  if (copy_to_user((void *) arg, &driver_geo,
28320                                  sizeof( struct hd_geometry)))
28321                          return  -EFAULT;
28322 @@ -636,9 +634,11 @@ static int cciss_ioctl(struct inode *ino
28323                 {       
28324                         return -EINVAL;
28325                 } 
28326 +#if 0 /* 'buf_size' member is 16-bits, and always smaller than kmalloc limit */
28327                 /* Check kmalloc limits */
28328                 if(iocommand.buf_size > 128000)
28329                         return -EINVAL;
28330 +#endif
28331                 if(iocommand.buf_size > 0)
28332                 {
28333                         buff =  kmalloc(iocommand.buf_size, GFP_KERNEL);
28334 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
28335 +++ 25/drivers/block/cfq-iosched.c      2003-10-05 00:34:17.000000000 -0700
28336 @@ -0,0 +1,707 @@
28337 +/*
28338 + *  linux/drivers/block/cfq-iosched.c
28339 + *
28340 + *  CFQ, or complete fairness queueing, disk scheduler.
28341 + *
28342 + *  Based on ideas from a previously unfinished io
28343 + *  scheduler (round robin per-process disk scheduling) and Andrea Arcangeli.
28344 + *
28345 + *  Copyright (C) 2003 Jens Axboe <axboe@suse.de>
28346 + */
28347 +#include <linux/kernel.h>
28348 +#include <linux/fs.h>
28349 +#include <linux/blkdev.h>
28350 +#include <linux/elevator.h>
28351 +#include <linux/bio.h>
28352 +#include <linux/config.h>
28353 +#include <linux/module.h>
28354 +#include <linux/slab.h>
28355 +#include <linux/init.h>
28356 +#include <linux/compiler.h>
28357 +#include <linux/hash.h>
28358 +#include <linux/rbtree.h>
28359 +#include <linux/mempool.h>
28360 +
28361 +/*
28362 + * tunables
28363 + */
28364 +static int cfq_quantum = 4;
28365 +static int cfq_queued = 8;
28366 +
28367 +#define CFQ_QHASH_SHIFT                6
28368 +#define CFQ_QHASH_ENTRIES      (1 << CFQ_QHASH_SHIFT)
28369 +#define list_entry_qhash(entry)        list_entry((entry), struct cfq_queue, cfq_hash)
28370 +
28371 +#define CFQ_MHASH_SHIFT                8
28372 +#define CFQ_MHASH_BLOCK(sec)   ((sec) >> 3)
28373 +#define CFQ_MHASH_ENTRIES      (1 << CFQ_MHASH_SHIFT)
28374 +#define CFQ_MHASH_FN(sec)      (hash_long(CFQ_MHASH_BLOCK((sec)),CFQ_MHASH_SHIFT))
28375 +#define ON_MHASH(crq)          !list_empty(&(crq)->hash)
28376 +#define rq_hash_key(rq)                ((rq)->sector + (rq)->nr_sectors)
28377 +#define list_entry_hash(ptr)   list_entry((ptr), struct cfq_rq, hash)
28378 +
28379 +#define list_entry_cfqq(ptr)   list_entry((ptr), struct cfq_queue, cfq_list)
28380 +
28381 +#define RQ_DATA(rq)            ((struct cfq_rq *) (rq)->elevator_private)
28382 +
28383 +static kmem_cache_t *crq_pool;
28384 +static kmem_cache_t *cfq_pool;
28385 +static mempool_t *cfq_mpool;
28386 +
28387 +struct cfq_data {
28388 +       struct list_head rr_list;
28389 +       struct list_head *dispatch;
28390 +       struct list_head *cfq_hash;
28391 +
28392 +       struct list_head *crq_hash;
28393 +
28394 +       unsigned int busy_queues;
28395 +       unsigned int max_queued;
28396 +
28397 +       mempool_t *crq_pool;
28398 +};
28399 +
28400 +struct cfq_queue {
28401 +       struct list_head cfq_hash;
28402 +       struct list_head cfq_list;
28403 +       struct rb_root sort_list;
28404 +       int pid;
28405 +       int queued[2];
28406 +#if 0
28407 +       /*
28408 +        * with a simple addition like this, we can do io priorities. almost.
28409 +        * does need a split request free list, too.
28410 +        */
28411 +       int io_prio
28412 +#endif
28413 +};
28414 +
28415 +struct cfq_rq {
28416 +       struct rb_node rb_node;
28417 +       sector_t rb_key;
28418 +
28419 +       struct request *request;
28420 +
28421 +       struct cfq_queue *cfq_queue;
28422 +
28423 +       struct list_head hash;
28424 +};
28425 +
28426 +static void cfq_put_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq);
28427 +static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *cfqd, int pid);
28428 +static void cfq_dispatch_sort(struct list_head *head, struct cfq_rq *crq);
28429 +
28430 +/*
28431 + * lots of deadline iosched dupes, can be abstracted later...
28432 + */
28433 +static inline void __cfq_del_crq_hash(struct cfq_rq *crq)
28434 +{
28435 +       list_del_init(&crq->hash);
28436 +}
28437 +
28438 +static inline void cfq_del_crq_hash(struct cfq_rq *crq)
28439 +{
28440 +       if (ON_MHASH(crq))
28441 +               __cfq_del_crq_hash(crq);
28442 +}
28443 +
28444 +static void cfq_remove_merge_hints(request_queue_t *q, struct cfq_rq *crq)
28445 +{
28446 +       cfq_del_crq_hash(crq);
28447 +
28448 +       if (q->last_merge == crq->request)
28449 +               q->last_merge = NULL;
28450 +}
28451 +
28452 +static inline void cfq_add_crq_hash(struct cfq_data *cfqd, struct cfq_rq *crq)
28453 +{
28454 +       struct request *rq = crq->request;
28455 +
28456 +       BUG_ON(ON_MHASH(crq));
28457 +
28458 +       list_add(&crq->hash, &cfqd->crq_hash[CFQ_MHASH_FN(rq_hash_key(rq))]);
28459 +}
28460 +
28461 +static struct request *cfq_find_rq_hash(struct cfq_data *cfqd, sector_t offset)
28462 +{
28463 +       struct list_head *hash_list = &cfqd->crq_hash[CFQ_MHASH_FN(offset)];
28464 +       struct list_head *entry, *next = hash_list->next;
28465 +
28466 +       while ((entry = next) != hash_list) {
28467 +               struct cfq_rq *crq = list_entry_hash(entry);
28468 +               struct request *__rq = crq->request;
28469 +
28470 +               next = entry->next;
28471 +
28472 +               BUG_ON(!ON_MHASH(crq));
28473 +
28474 +               if (!rq_mergeable(__rq)) {
28475 +                       __cfq_del_crq_hash(crq);
28476 +                       continue;
28477 +               }
28478 +
28479 +               if (rq_hash_key(__rq) == offset)
28480 +                       return __rq;
28481 +       }
28482 +
28483 +       return NULL;
28484 +}
28485 +
28486 +/*
28487 + * rb tree support functions
28488 + */
28489 +#define RB_NONE                (2)
28490 +#define RB_EMPTY(node) ((node)->rb_node == NULL)
28491 +#define RB_CLEAR(node) ((node)->rb_color = RB_NONE)
28492 +#define RB_CLEAR_ROOT(root)    ((root)->rb_node = NULL)
28493 +#define ON_RB(node)    ((node)->rb_color != RB_NONE)
28494 +#define rb_entry_crq(node)     rb_entry((node), struct cfq_rq, rb_node)
28495 +#define rq_rb_key(rq)          (rq)->sector
28496 +
28497 +static inline void cfq_del_crq_rb(struct cfq_queue *cfqq, struct cfq_rq *crq)
28498 +{
28499 +       if (ON_RB(&crq->rb_node)) {
28500 +               cfqq->queued[rq_data_dir(crq->request)]--;
28501 +               rb_erase(&crq->rb_node, &cfqq->sort_list);
28502 +               crq->cfq_queue = NULL;
28503 +       }
28504 +}
28505 +
28506 +static struct cfq_rq *
28507 +__cfq_add_crq_rb(struct cfq_queue *cfqq, struct cfq_rq *crq)
28508 +{
28509 +       struct rb_node **p = &cfqq->sort_list.rb_node;
28510 +       struct rb_node *parent = NULL;
28511 +       struct cfq_rq *__crq;
28512 +
28513 +       while (*p) {
28514 +               parent = *p;
28515 +               __crq = rb_entry_crq(parent);
28516 +
28517 +               if (crq->rb_key < __crq->rb_key)
28518 +                       p = &(*p)->rb_left;
28519 +               else if (crq->rb_key > __crq->rb_key)
28520 +                       p = &(*p)->rb_right;
28521 +               else
28522 +                       return __crq;
28523 +       }
28524 +
28525 +       rb_link_node(&crq->rb_node, parent, p);
28526 +       return 0;
28527 +}
28528 +
28529 +static void
28530 +cfq_add_crq_rb(struct cfq_data *cfqd, struct cfq_queue *cfqq,struct cfq_rq *crq)
28531 +{
28532 +       struct request *rq = crq->request;
28533 +       struct cfq_rq *__alias;
28534 +
28535 +       crq->rb_key = rq_rb_key(rq);
28536 +       cfqq->queued[rq_data_dir(rq)]++;
28537 +retry:
28538 +       __alias = __cfq_add_crq_rb(cfqq, crq);
28539 +       if (!__alias) {
28540 +               rb_insert_color(&crq->rb_node, &cfqq->sort_list);
28541 +               crq->cfq_queue = cfqq;
28542 +               return;
28543 +       }
28544 +
28545 +       cfq_del_crq_rb(cfqq, __alias);
28546 +       cfq_dispatch_sort(cfqd->dispatch, __alias);
28547 +       goto retry;
28548 +}
28549 +
28550 +static struct request *
28551 +cfq_find_rq_rb(struct cfq_data *cfqd, sector_t sector)
28552 +{
28553 +       struct cfq_queue *cfqq = cfq_find_cfq_hash(cfqd, current->tgid);
28554 +       struct rb_node *n;
28555 +
28556 +       if (!cfqq)
28557 +               goto out;
28558 +
28559 +       n = cfqq->sort_list.rb_node;
28560 +       while (n) {
28561 +               struct cfq_rq *crq = rb_entry_crq(n);
28562 +
28563 +               if (sector < crq->rb_key)
28564 +                       n = n->rb_left;
28565 +               else if (sector > crq->rb_key)
28566 +                       n = n->rb_right;
28567 +               else
28568 +                       return crq->request;
28569 +       }
28570 +
28571 +out:
28572 +       return NULL;
28573 +}
28574 +
28575 +static void cfq_remove_request(request_queue_t *q, struct request *rq)
28576 +{
28577 +       struct cfq_data *cfqd = q->elevator.elevator_data;
28578 +       struct cfq_rq *crq = RQ_DATA(rq);
28579 +
28580 +       if (crq) {
28581 +               struct cfq_queue *cfqq = crq->cfq_queue;
28582 +
28583 +               cfq_remove_merge_hints(q, crq);
28584 +               list_del_init(&rq->queuelist);
28585 +
28586 +               if (cfqq) {
28587 +                       cfq_del_crq_rb(cfqq, crq);
28588 +
28589 +                       if (RB_EMPTY(&cfqq->sort_list))
28590 +                               cfq_put_queue(cfqd, cfqq);
28591 +               }
28592 +       }
28593 +}
28594 +
28595 +static int
28596 +cfq_merge(request_queue_t *q, struct request **req, struct bio *bio)
28597 +{
28598 +       struct cfq_data *cfqd = q->elevator.elevator_data;
28599 +       struct request *__rq;
28600 +       int ret;
28601 +
28602 +       ret = elv_try_last_merge(q, bio);
28603 +       if (ret != ELEVATOR_NO_MERGE) {
28604 +               __rq = q->last_merge;
28605 +               goto out_insert;
28606 +       }
28607 +
28608 +       __rq = cfq_find_rq_hash(cfqd, bio->bi_sector);
28609 +       if (__rq) {
28610 +               BUG_ON(__rq->sector + __rq->nr_sectors != bio->bi_sector);
28611 +
28612 +               if (elv_rq_merge_ok(__rq, bio)) {
28613 +                       ret = ELEVATOR_BACK_MERGE;
28614 +                       goto out;
28615 +               }
28616 +       }
28617 +
28618 +       __rq = cfq_find_rq_rb(cfqd, bio->bi_sector + bio_sectors(bio));
28619 +       if (__rq) {
28620 +               if (elv_rq_merge_ok(__rq, bio)) {
28621 +                       ret = ELEVATOR_FRONT_MERGE;
28622 +                       goto out;
28623 +               }
28624 +       }
28625 +
28626 +       return ELEVATOR_NO_MERGE;
28627 +out:
28628 +       q->last_merge = __rq;
28629 +out_insert:
28630 +       *req = __rq;
28631 +       return ret;
28632 +}
28633 +
28634 +static void cfq_merged_request(request_queue_t *q, struct request *req)
28635 +{
28636 +       struct cfq_data *cfqd = q->elevator.elevator_data;
28637 +       struct cfq_rq *crq = RQ_DATA(req);
28638 +
28639 +       cfq_del_crq_hash(crq);
28640 +       cfq_add_crq_hash(cfqd, crq);
28641 +
28642 +       if (ON_RB(&crq->rb_node) && (rq_rb_key(req) != crq->rb_key)) {
28643 +               struct cfq_queue *cfqq = crq->cfq_queue;
28644 +
28645 +               cfq_del_crq_rb(cfqq, crq);
28646 +               cfq_add_crq_rb(cfqd, cfqq, crq);
28647 +       }
28648 +
28649 +       q->last_merge = req;
28650 +}
28651 +
28652 +static void
28653 +cfq_merged_requests(request_queue_t *q, struct request *req,
28654 +                   struct request *next)
28655 +{
28656 +       cfq_merged_request(q, req);
28657 +       cfq_remove_request(q, next);
28658 +}
28659 +
28660 +static void cfq_dispatch_sort(struct list_head *head, struct cfq_rq *crq)
28661 +{
28662 +       struct list_head *entry = head;
28663 +       struct request *__rq;
28664 +
28665 +       if (!list_empty(head)) {
28666 +               __rq = list_entry_rq(head->next);
28667 +
28668 +               if (crq->request->sector < __rq->sector) {
28669 +                       entry = head->prev;
28670 +                       goto link;
28671 +               }
28672 +       }
28673 +
28674 +       while ((entry = entry->prev) != head) {
28675 +               __rq = list_entry_rq(entry);
28676 +
28677 +               if (crq->request->sector <= __rq->sector)
28678 +                       break;
28679 +       }
28680 +
28681 +link:
28682 +       list_add_tail(&crq->request->queuelist, entry);
28683 +}
28684 +
28685 +static inline void
28686 +__cfq_dispatch_requests(request_queue_t *q, struct cfq_data *cfqd,
28687 +                       struct cfq_queue *cfqq)
28688 +{
28689 +       struct cfq_rq *crq = rb_entry_crq(rb_first(&cfqq->sort_list));
28690 +
28691 +       cfq_del_crq_rb(cfqq, crq);
28692 +       cfq_remove_merge_hints(q, crq);
28693 +       cfq_dispatch_sort(cfqd->dispatch, crq);
28694 +}
28695 +
28696 +static int cfq_dispatch_requests(request_queue_t *q, struct cfq_data *cfqd)
28697 +{
28698 +       struct cfq_queue *cfqq;
28699 +       struct list_head *entry, *tmp;
28700 +       int ret, queued, good_queues;
28701 +
28702 +       if (list_empty(&cfqd->rr_list))
28703 +               return 0;
28704 +
28705 +       queued = ret = 0;
28706 +restart:
28707 +       good_queues = 0;
28708 +       list_for_each_safe(entry, tmp, &cfqd->rr_list) {
28709 +               cfqq = list_entry_cfqq(cfqd->rr_list.next);
28710 +
28711 +               BUG_ON(RB_EMPTY(&cfqq->sort_list));
28712 +
28713 +               __cfq_dispatch_requests(q, cfqd, cfqq);
28714 +
28715 +               if (RB_EMPTY(&cfqq->sort_list))
28716 +                       cfq_put_queue(cfqd, cfqq);
28717 +               else
28718 +                       good_queues++;
28719 +
28720 +               queued++;
28721 +               ret = 1;
28722 +       }
28723 +
28724 +       if ((queued < cfq_quantum) && good_queues)
28725 +               goto restart;
28726 +
28727 +       return ret;
28728 +}
28729 +
28730 +static struct request *cfq_next_request(request_queue_t *q)
28731 +{
28732 +       struct cfq_data *cfqd = q->elevator.elevator_data;
28733 +       struct request *rq;
28734 +
28735 +       if (!list_empty(cfqd->dispatch)) {
28736 +               struct cfq_rq *crq;
28737 +dispatch:
28738 +               rq = list_entry_rq(cfqd->dispatch->next);
28739 +
28740 +               BUG_ON(q->last_merge == rq);
28741 +               crq = RQ_DATA(rq);
28742 +               if (crq)
28743 +                       BUG_ON(ON_MHASH(crq));
28744 +
28745 +               return rq;
28746 +       }
28747 +
28748 +       if (cfq_dispatch_requests(q, cfqd))
28749 +               goto dispatch;
28750 +
28751 +       return NULL;
28752 +}
28753 +
28754 +static inline struct cfq_queue *
28755 +__cfq_find_cfq_hash(struct cfq_data *cfqd, int pid, const int hashval)
28756 +{
28757 +       struct list_head *hash_list = &cfqd->cfq_hash[hashval];
28758 +       struct list_head *entry;
28759 +
28760 +       list_for_each(entry, hash_list) {
28761 +               struct cfq_queue *__cfqq = list_entry_qhash(entry);
28762 +
28763 +               if (__cfqq->pid == pid)
28764 +                       return __cfqq;
28765 +       }
28766 +
28767 +       return NULL;
28768 +}
28769 +
28770 +static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *cfqd, int pid)
28771 +{
28772 +       const int hashval = hash_long(current->tgid, CFQ_QHASH_SHIFT);
28773 +
28774 +       return __cfq_find_cfq_hash(cfqd, pid, hashval);
28775 +}
28776 +
28777 +static void cfq_put_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq)
28778 +{
28779 +       cfqd->busy_queues--;
28780 +       list_del(&cfqq->cfq_list);
28781 +       list_del(&cfqq->cfq_hash);
28782 +       mempool_free(cfqq, cfq_mpool);
28783 +}
28784 +
28785 +static struct cfq_queue *cfq_get_queue(struct cfq_data *cfqd, int pid)
28786 +{
28787 +       const int hashval = hash_long(current->tgid, CFQ_QHASH_SHIFT);
28788 +       struct cfq_queue *cfqq = __cfq_find_cfq_hash(cfqd, pid, hashval);
28789 +
28790 +       if (!cfqq) {
28791 +               cfqq = mempool_alloc(cfq_mpool, GFP_NOIO);
28792 +
28793 +               INIT_LIST_HEAD(&cfqq->cfq_hash);
28794 +               INIT_LIST_HEAD(&cfqq->cfq_list);
28795 +               RB_CLEAR_ROOT(&cfqq->sort_list);
28796 +
28797 +               cfqq->pid = pid;
28798 +               cfqq->queued[0] = cfqq->queued[1] = 0;
28799 +               list_add(&cfqq->cfq_hash, &cfqd->cfq_hash[hashval]);
28800 +       }
28801 +
28802 +       return cfqq;
28803 +}
28804 +
28805 +static void cfq_enqueue(struct cfq_data *cfqd, struct cfq_rq *crq)
28806 +{
28807 +       struct cfq_queue *cfqq;
28808 +
28809 +       cfqq = cfq_get_queue(cfqd, current->tgid);
28810 +
28811 +       cfq_add_crq_rb(cfqd, cfqq, crq);
28812 +
28813 +       if (list_empty(&cfqq->cfq_list)) {
28814 +               list_add(&cfqq->cfq_list, &cfqd->rr_list);
28815 +               cfqd->busy_queues++;
28816 +       }
28817 +}
28818 +
28819 +static void
28820 +cfq_insert_request(request_queue_t *q, struct request *rq, int where)
28821 +{
28822 +       struct cfq_data *cfqd = q->elevator.elevator_data;
28823 +       struct cfq_rq *crq = RQ_DATA(rq);
28824 +
28825 +       switch (where) {
28826 +               case ELEVATOR_INSERT_BACK:
28827 +                       while (cfq_dispatch_requests(q, cfqd))
28828 +                               ;
28829 +                       list_add_tail(&rq->queuelist, cfqd->dispatch);
28830 +                       break;
28831 +               case ELEVATOR_INSERT_FRONT:
28832 +                       list_add(&rq->queuelist, cfqd->dispatch);
28833 +                       break;
28834 +               case ELEVATOR_INSERT_SORT:
28835 +                       BUG_ON(!blk_fs_request(rq));
28836 +                       cfq_enqueue(cfqd, crq);
28837 +                       break;
28838 +               default:
28839 +                       printk("%s: bad insert point %d\n", __FUNCTION__,where);
28840 +                       return;
28841 +       }
28842 +
28843 +       if (rq_mergeable(rq)) {
28844 +               cfq_add_crq_hash(cfqd, crq);
28845 +
28846 +               if (!q->last_merge)
28847 +                       q->last_merge = rq;
28848 +       }
28849 +}
28850 +
28851 +static int cfq_queue_empty(request_queue_t *q)
28852 +{
28853 +       struct cfq_data *cfqd = q->elevator.elevator_data;
28854 +
28855 +       if (list_empty(cfqd->dispatch) && list_empty(&cfqd->rr_list))
28856 +               return 1;
28857 +
28858 +       return 0;
28859 +}
28860 +
28861 +static struct request *
28862 +cfq_former_request(request_queue_t *q, struct request *rq)
28863 +{
28864 +       struct cfq_rq *crq = RQ_DATA(rq);
28865 +       struct rb_node *rbprev = rb_prev(&crq->rb_node);
28866 +
28867 +       if (rbprev)
28868 +               return rb_entry_crq(rbprev)->request;
28869 +
28870 +       return NULL;
28871 +}
28872 +
28873 +static struct request *
28874 +cfq_latter_request(request_queue_t *q, struct request *rq)
28875 +{
28876 +       struct cfq_rq *crq = RQ_DATA(rq);
28877 +       struct rb_node *rbnext = rb_next(&crq->rb_node);
28878 +
28879 +       if (rbnext)
28880 +               return rb_entry_crq(rbnext)->request;
28881 +
28882 +       return NULL;
28883 +}
28884 +
28885 +static int cfq_may_queue(request_queue_t *q, int rw)
28886 +{
28887 +       struct cfq_data *cfqd = q->elevator.elevator_data;
28888 +       struct cfq_queue *cfqq;
28889 +       int ret = 1;
28890 +
28891 +       if (!cfqd->busy_queues)
28892 +               goto out;
28893 +
28894 +       cfqq = cfq_find_cfq_hash(cfqd, current->tgid);
28895 +       if (cfqq) {
28896 +               int limit = (q->nr_requests - cfq_queued) / cfqd->busy_queues;
28897 +
28898 +               if (limit < 3)
28899 +                       limit = 3;
28900 +               else if (limit > cfqd->max_queued)
28901 +                       limit = cfqd->max_queued;
28902 +
28903 +               if (cfqq->queued[rw] > limit)
28904 +                       ret = 0;
28905 +       }
28906 +out:
28907 +       return ret;
28908 +}
28909 +
28910 +static void cfq_put_request(request_queue_t *q, struct request *rq)
28911 +{
28912 +       struct cfq_data *cfqd = q->elevator.elevator_data;
28913 +       struct cfq_rq *crq = RQ_DATA(rq);
28914 +
28915 +       if (crq) {
28916 +               BUG_ON(q->last_merge == rq);
28917 +               BUG_ON(ON_MHASH(crq));
28918 +
28919 +               mempool_free(crq, cfqd->crq_pool);
28920 +               rq->elevator_private = NULL;
28921 +       }
28922 +}
28923 +
28924 +static int cfq_set_request(request_queue_t *q, struct request *rq, int gfp_mask)
28925 +{
28926 +       struct cfq_data *cfqd = q->elevator.elevator_data;
28927 +       struct cfq_rq *crq = mempool_alloc(cfqd->crq_pool, gfp_mask);
28928 +
28929 +       if (crq) {
28930 +               RB_CLEAR(&crq->rb_node);
28931 +               crq->request = rq;
28932 +               crq->cfq_queue = NULL;
28933 +               INIT_LIST_HEAD(&crq->hash);
28934 +               rq->elevator_private = crq;
28935 +               return 0;
28936 +       }
28937 +
28938 +       return 1;
28939 +}
28940 +
28941 +static void cfq_exit(request_queue_t *q, elevator_t *e)
28942 +{
28943 +       struct cfq_data *cfqd = e->elevator_data;
28944 +
28945 +       e->elevator_data = NULL;
28946 +       mempool_destroy(cfqd->crq_pool);
28947 +       kfree(cfqd->crq_hash);
28948 +       kfree(cfqd->cfq_hash);
28949 +       kfree(cfqd);
28950 +}
28951 +
28952 +static int cfq_init(request_queue_t *q, elevator_t *e)
28953 +{
28954 +       struct cfq_data *cfqd;
28955 +       int i;
28956 +
28957 +       cfqd = kmalloc(sizeof(*cfqd), GFP_KERNEL);
28958 +       if (!cfqd)
28959 +               return -ENOMEM;
28960 +
28961 +       memset(cfqd, 0, sizeof(*cfqd));
28962 +       INIT_LIST_HEAD(&cfqd->rr_list);
28963 +
28964 +       cfqd->crq_hash = kmalloc(sizeof(struct list_head) * CFQ_MHASH_ENTRIES, GFP_KERNEL);
28965 +       if (!cfqd->crq_hash)
28966 +               goto out_crqhash;
28967 +
28968 +       cfqd->cfq_hash = kmalloc(sizeof(struct list_head) * CFQ_QHASH_ENTRIES, GFP_KERNEL);
28969 +       if (!cfqd->cfq_hash)
28970 +               goto out_cfqhash;
28971 +
28972 +       cfqd->crq_pool = mempool_create(BLKDEV_MIN_RQ, mempool_alloc_slab, mempool_free_slab, crq_pool);
28973 +       if (!cfqd->crq_pool)
28974 +               goto out_crqpool;
28975 +
28976 +       for (i = 0; i < CFQ_MHASH_ENTRIES; i++)
28977 +               INIT_LIST_HEAD(&cfqd->crq_hash[i]);
28978 +       for (i = 0; i < CFQ_QHASH_ENTRIES; i++)
28979 +               INIT_LIST_HEAD(&cfqd->cfq_hash[i]);
28980 +
28981 +       cfqd->dispatch = &q->queue_head;
28982 +       e->elevator_data = cfqd;
28983 +
28984 +       /*
28985 +        * just set it to some high value, we want anyone to be able to queue
28986 +        * some requests. fairness is handled differently
28987 +        */
28988 +       cfqd->max_queued = q->nr_requests;
28989 +       q->nr_requests = 8192;
28990 +
28991 +       return 0;
28992 +out_crqpool:
28993 +       kfree(cfqd->cfq_hash);
28994 +out_cfqhash:
28995 +       kfree(cfqd->crq_hash);
28996 +out_crqhash:
28997 +       kfree(cfqd);
28998 +       return -ENOMEM;
28999 +}
29000 +
29001 +static int __init cfq_slab_setup(void)
29002 +{
29003 +       crq_pool = kmem_cache_create("crq_pool", sizeof(struct cfq_rq), 0, 0,
29004 +                                       NULL, NULL);
29005 +
29006 +       if (!crq_pool)
29007 +               panic("cfq_iosched: can't init crq pool\n");
29008 +
29009 +       cfq_pool = kmem_cache_create("cfq_pool", sizeof(struct cfq_queue), 0, 0,
29010 +                                       NULL, NULL);
29011 +
29012 +       if (!cfq_pool)
29013 +               panic("cfq_iosched: can't init cfq pool\n");
29014 +
29015 +       cfq_mpool = mempool_create(64, mempool_alloc_slab, mempool_free_slab, cfq_pool);
29016 +
29017 +       if (!cfq_mpool)
29018 +               panic("cfq_iosched: can't init cfq mpool\n");
29019 +
29020 +       return 0;
29021 +}
29022 +
29023 +subsys_initcall(cfq_slab_setup);
29024 +
29025 +elevator_t iosched_cfq = {
29026 +       .elevator_name =                "cfq",
29027 +       .elevator_merge_fn =            cfq_merge,
29028 +       .elevator_merged_fn =           cfq_merged_request,
29029 +       .elevator_merge_req_fn =        cfq_merged_requests,
29030 +       .elevator_next_req_fn =         cfq_next_request,
29031 +       .elevator_add_req_fn =          cfq_insert_request,
29032 +       .elevator_remove_req_fn =       cfq_remove_request,
29033 +       .elevator_queue_empty_fn =      cfq_queue_empty,
29034 +       .elevator_former_req_fn =       cfq_former_request,
29035 +       .elevator_latter_req_fn =       cfq_latter_request,
29036 +       .elevator_set_req_fn =          cfq_set_request,
29037 +       .elevator_put_req_fn =          cfq_put_request,
29038 +       .elevator_may_queue_fn =        cfq_may_queue,
29039 +       .elevator_init_fn =             cfq_init,
29040 +       .elevator_exit_fn =             cfq_exit,
29041 +};
29042 +
29043 +EXPORT_SYMBOL(iosched_cfq);
29044 --- linux-2.6.0-test6/drivers/block/cpqarray.c  2003-09-08 13:58:56.000000000 -0700
29045 +++ 25/drivers/block/cpqarray.c 2003-10-05 00:34:00.000000000 -0700
29046 @@ -99,8 +99,6 @@ static struct board_type products[] = {
29047  
29048  static struct gendisk *ida_gendisk[MAX_CTLR][NWD];
29049  
29050 -static struct proc_dir_entry *proc_array;
29051 -
29052  /* Debug... */
29053  #define DBG(s) do { s } while(0)
29054  /* Debug (general info)... */
29055 @@ -130,9 +128,9 @@ static int sendcmd(
29056         unsigned int blkcnt,
29057         unsigned int log_unit );
29058  
29059 -static int ida_open(struct inode *inode, struct file *filep);
29060 -static int ida_release(struct inode *inode, struct file *filep);
29061 -static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg);
29062 +static int ida_open(struct block_device *bdev, struct file *filep);
29063 +static int ida_release(struct gendisk *disk);
29064 +static int ida_ioctl(struct block_device *bdev, struct file *filep, unsigned int cmd, unsigned long arg);
29065  static int ida_ctlr_ioctl(ctlr_info_t *h, int dsk, ida_ioctl_t *io);
29066  
29067  static void do_ida_request(request_queue_t *q);
29068 @@ -153,8 +151,6 @@ static void ida_procinit(int i);
29069  static int ida_proc_get_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data);
29070  #else
29071  static void ida_procinit(int i) {}
29072 -static int ida_proc_get_info(char *buffer, char **start, off_t offset,
29073 -                            int length, int *eof, void *data) { return 0;}
29074  #endif
29075  
29076  static inline drv_info_t *get_drv(struct gendisk *disk)
29077 @@ -179,6 +175,8 @@ static struct block_device_operations id
29078  
29079  #ifdef CONFIG_PROC_FS
29080  
29081 +static struct proc_dir_entry *proc_array;
29082 +
29083  /*
29084   * Get us a file in /proc/array that says something about each controller.
29085   * Create /proc/array if it doesn't exist yet.
29086 @@ -717,12 +715,12 @@ DBGINFO(
29087  /*
29088   * Open.  Make sure the device is really there.
29089   */
29090 -static int ida_open(struct inode *inode, struct file *filep)
29091 +static int ida_open(struct block_device *bdev, struct file *filep)
29092  {
29093 -       drv_info_t *drv = get_drv(inode->i_bdev->bd_disk);
29094 -       ctlr_info_t *host = get_host(inode->i_bdev->bd_disk);
29095 +       drv_info_t *drv = get_drv(bdev->bd_disk);
29096 +       ctlr_info_t *host = get_host(bdev->bd_disk);
29097  
29098 -       DBGINFO(printk("ida_open %s\n", inode->i_bdev->bd_disk->disk_name));
29099 +       DBGINFO(printk("ida_open %s\n", bdev->bd_disk->disk_name));
29100         /*
29101          * Root is allowed to open raw volume zero even if it's not configured
29102          * so array config can still work.  I don't think I really like this,
29103 @@ -742,9 +740,9 @@ static int ida_open(struct inode *inode,
29104  /*
29105   * Close.  Sync first.
29106   */
29107 -static int ida_release(struct inode *inode, struct file *filep)
29108 +static int ida_release(struct gendisk *disk)
29109  {
29110 -       ctlr_info_t *host = get_host(inode->i_bdev->bd_disk);
29111 +       ctlr_info_t *host = get_host(disk);
29112         host->usage_count--;
29113         return 0;
29114  }
29115 @@ -1024,10 +1022,10 @@ static void ida_timer(unsigned long tdat
29116   *  ida_ioctl does some miscellaneous stuff like reporting drive geometry,
29117   *  setting readahead and submitting commands from userspace to the controller.
29118   */
29119 -static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg)
29120 +static int ida_ioctl(struct block_device *bdev, struct file *filep, unsigned int cmd, unsigned long arg)
29121  {
29122 -       drv_info_t *drv = get_drv(inode->i_bdev->bd_disk);
29123 -       ctlr_info_t *host = get_host(inode->i_bdev->bd_disk);
29124 +       drv_info_t *drv = get_drv(bdev->bd_disk);
29125 +       ctlr_info_t *host = get_host(bdev->bd_disk);
29126         int error;
29127         int diskinfo[4];
29128         struct hd_geometry *geo = (struct hd_geometry *)arg;
29129 @@ -1048,7 +1046,7 @@ static int ida_ioctl(struct inode *inode
29130                 put_user(diskinfo[0], &geo->heads);
29131                 put_user(diskinfo[1], &geo->sectors);
29132                 put_user(diskinfo[2], &geo->cylinders);
29133 -               put_user(get_start_sect(inode->i_bdev), &geo->start);
29134 +               put_user(get_start_sect(bdev), &geo->start);
29135                 return 0;
29136         case IDAGETDRVINFO:
29137                 if (copy_to_user(&io->c.drv, drv, sizeof(drv_info_t)))
29138 @@ -1078,7 +1076,7 @@ out_passthru:
29139                 put_user(host->ctlr_sig, (int*)arg);
29140                 return 0;
29141         case IDAREVALIDATEVOLS:
29142 -               if (iminor(inode) != 0)
29143 +               if (bdev != bdev->bd_contains || drv != host->drv)
29144                         return -ENXIO;
29145                 return revalidate_allvol(host);
29146         case IDADRIVERVERSION:
29147 --- linux-2.6.0-test6/drivers/block/DAC960.c    2003-09-27 18:57:44.000000000 -0700
29148 +++ 25/drivers/block/DAC960.c   2003-10-05 00:33:58.000000000 -0700
29149 @@ -67,9 +67,9 @@ static long disk_size(DAC960_Controller_
29150         }
29151  }
29152  
29153 -static int DAC960_open(struct inode *inode, struct file *file)
29154 +static int DAC960_open(struct block_device *bdev, struct file *file)
29155  {
29156 -       struct gendisk *disk = inode->i_bdev->bd_disk;
29157 +       struct gendisk *disk = bdev->bd_disk;
29158         DAC960_Controller_T *p = disk->queue->queuedata;
29159         int drive_nr = (long)disk->private_data;
29160  
29161 @@ -84,17 +84,17 @@ static int DAC960_open(struct inode *ino
29162                         return -ENXIO;
29163         }
29164  
29165 -       check_disk_change(inode->i_bdev);
29166 +       check_disk_change(bdev);
29167  
29168         if (!get_capacity(p->disks[drive_nr]))
29169                 return -ENXIO;
29170         return 0;
29171  }
29172  
29173 -static int DAC960_ioctl(struct inode *inode, struct file *file,
29174 +static int DAC960_ioctl(struct block_device *bdev, struct file *file,
29175                         unsigned int cmd, unsigned long arg)
29176  {
29177 -       struct gendisk *disk = inode->i_bdev->bd_disk;
29178 +       struct gendisk *disk = bdev->bd_disk;
29179         DAC960_Controller_T *p = disk->queue->queuedata;
29180         int drive_nr = (long)disk->private_data;
29181         struct hd_geometry g, *loc = (struct hd_geometry *)arg;
29182 @@ -128,7 +128,7 @@ static int DAC960_ioctl(struct inode *in
29183                 g.cylinders = i->ConfigurableDeviceSize / (g.heads * g.sectors);
29184         }
29185         
29186 -       g.start = get_start_sect(inode->i_bdev);
29187 +       g.start = get_start_sect(bdev);
29188  
29189         return copy_to_user(loc, &g, sizeof g) ? -EFAULT : 0; 
29190  }
29191 --- linux-2.6.0-test6/drivers/block/floppy98.c  2003-09-08 13:58:56.000000000 -0700
29192 +++ 25/drivers/block/floppy98.c 2003-10-05 00:34:01.000000000 -0700
29193 @@ -3484,14 +3484,14 @@ static int get_floppy_geometry(int drive
29194         return 0;
29195  }
29196  
29197 -static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
29198 +static int fd_ioctl(struct block_device *bdev, struct file *filp, unsigned int cmd,
29199                     unsigned long param)
29200  {
29201  #define FD_IOCTL_ALLOWED ((filp) && (filp)->private_data)
29202  #define OUT(c,x) case c: outparam = (const char *) (x); break
29203  #define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0
29204  
29205 -       int drive = (long)inode->i_bdev->bd_disk->private_data;
29206 +       int drive = (long)bdev->bd_disk->private_data;
29207         int i, type = ITYPE(UDRS->fd_device);
29208         int ret;
29209         int size;
29210 @@ -3566,11 +3566,11 @@ static int fd_ioctl(struct inode *inode,
29211                         current_type[drive] = NULL;
29212                         floppy_sizes[drive] = MAX_DISK_SIZE << 1;
29213                         UDRS->keep_data = 0;
29214 -                       return invalidate_drive(inode->i_bdev);
29215 +                       return invalidate_drive(bdev);
29216                 case FDSETPRM:
29217                 case FDDEFPRM:
29218                         return set_geometry(cmd, & inparam.g,
29219 -                                           drive, type, inode->i_bdev);
29220 +                                           drive, type, bdev);
29221                 case FDGETPRM:
29222                         ECALL(get_floppy_geometry(drive, type, 
29223                                                   (struct floppy_struct**)
29224 @@ -3625,7 +3625,7 @@ static int fd_ioctl(struct inode *inode,
29225                 case FDFMTEND:
29226                 case FDFLUSH:
29227                         LOCK_FDC(drive,1);
29228 -                       return invalidate_drive(inode->i_bdev);
29229 +                       return invalidate_drive(bdev);
29230  
29231                 case FDSETEMSGTRESH:
29232                         UDP->max_errors.reporting =
29233 @@ -3735,9 +3735,9 @@ static void __init config_types(void)
29234                 printk("\n");
29235  }
29236  
29237 -static int floppy_release(struct inode * inode, struct file * filp)
29238 +static int floppy_release(struct gendisk *disk)
29239  {
29240 -       int drive = (long)inode->i_bdev->bd_disk->private_data;
29241 +       int drive = (long)disk->private_data;
29242  
29243         down(&open_lock);
29244         if (UDRS->fd_ref < 0)
29245 @@ -3758,11 +3758,10 @@ static int floppy_release(struct inode *
29246   * /dev/PS0 etc), and disallows simultaneous access to the same
29247   * drive with different device numbers.
29248   */
29249 -#define RETERR(x) do{floppy_release(inode,filp); return -(x);}while(0)
29250  
29251 -static int floppy_open(struct inode * inode, struct file * filp)
29252 +static int floppy_open(struct block_device *bdev, struct file *filp)
29253  {
29254 -       int drive = (long)inode->i_bdev->bd_disk->private_data;
29255 +       int drive = (long)bdev->bd_disk->private_data;
29256         int old_dev;
29257         int try;
29258         int res = -EBUSY;
29259 @@ -3789,7 +3788,7 @@ static int floppy_open(struct inode * in
29260  
29261         down(&open_lock);
29262         old_dev = UDRS->fd_device;
29263 -       if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev)
29264 +       if (opened_bdev[drive] && opened_bdev[drive] != bdev)
29265                 goto out2;
29266  
29267         if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)){
29268 @@ -3809,7 +3808,7 @@ static int floppy_open(struct inode * in
29269         else
29270                 UDRS->fd_ref++;
29271  
29272 -       opened_bdev[drive] = inode->i_bdev;
29273 +       opened_bdev[drive] = bdev;
29274  
29275         res = -ENXIO;
29276  
29277 @@ -3844,9 +3843,9 @@ static int floppy_open(struct inode * in
29278                 }
29279         }
29280  
29281 -       UDRS->fd_device = iminor(inode);
29282 -       set_capacity(disks[drive], floppy_sizes[iminor(inode)]);
29283 -       if (old_dev != -1 && old_dev != iminor(inode)) {
29284 +       UDRS->fd_device = MINOR(bdev->bd_dev);
29285 +       set_capacity(disks[drive], floppy_sizes[MINOR(bdev->bd_dev)]);
29286 +       if (old_dev != -1 && old_dev != MINOR(bdev->bd_dev)) {
29287                 if (buffer_drive == drive)
29288                         buffer_track = -1;
29289         }
29290 @@ -3859,8 +3858,7 @@ static int floppy_open(struct inode * in
29291         /* Allow ioctls if we have write-permissions even if read-only open.
29292          * Needed so that programs such as fdrawcmd still can work on write
29293          * protected disks */
29294 -       if ((filp->f_mode & 2) || 
29295 -           (inode->i_sb && (permission(inode,2) == 0)))
29296 +       if ((filp->f_mode & 2) || permission(filp->f_dentry->d_inode,2) == 0)
29297             filp->private_data = (void*) 8;
29298  
29299         if (UFDCS->rawcmd == 1)
29300 @@ -3873,7 +3871,7 @@ static int floppy_open(struct inode * in
29301         if (!(filp->f_flags & O_NDELAY)) {
29302                 if (filp->f_mode & 3) {
29303                         UDRS->last_checked = 0;
29304 -                       check_disk_change(inode->i_bdev);
29305 +                       check_disk_change(bdev);
29306                         if (UTESTF(FD_DISK_CHANGED))
29307                                 goto out;
29308                 }
29309 --- linux-2.6.0-test6/drivers/block/floppy.c    2003-09-27 18:57:44.000000000 -0700
29310 +++ 25/drivers/block/floppy.c   2003-10-05 00:34:01.000000000 -0700
29311 @@ -3456,14 +3456,14 @@ static int get_floppy_geometry(int drive
29312         return 0;
29313  }
29314  
29315 -static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
29316 +static int fd_ioctl(struct block_device *bdev, struct file *filp, unsigned int cmd,
29317                     unsigned long param)
29318  {
29319  #define FD_IOCTL_ALLOWED ((filp) && (filp)->private_data)
29320  #define OUT(c,x) case c: outparam = (const char *) (x); break
29321  #define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0
29322  
29323 -       int drive = (long)inode->i_bdev->bd_disk->private_data;
29324 +       int drive = (long)bdev->bd_disk->private_data;
29325         int i, type = ITYPE(UDRS->fd_device);
29326         int ret;
29327         int size;
29328 @@ -3539,11 +3539,11 @@ static int fd_ioctl(struct inode *inode,
29329                         current_type[drive] = NULL;
29330                         floppy_sizes[drive] = MAX_DISK_SIZE << 1;
29331                         UDRS->keep_data = 0;
29332 -                       return invalidate_drive(inode->i_bdev);
29333 +                       return invalidate_drive(bdev);
29334                 case FDSETPRM:
29335                 case FDDEFPRM:
29336                         return set_geometry(cmd, & inparam.g,
29337 -                                           drive, type, inode->i_bdev);
29338 +                                           drive, type, bdev);
29339                 case FDGETPRM:
29340                         ECALL(get_floppy_geometry(drive, type, 
29341                                                   (struct floppy_struct**)
29342 @@ -3574,7 +3574,7 @@ static int fd_ioctl(struct inode *inode,
29343                 case FDFMTEND:
29344                 case FDFLUSH:
29345                         LOCK_FDC(drive,1);
29346 -                       return invalidate_drive(inode->i_bdev);
29347 +                       return invalidate_drive(bdev);
29348  
29349                 case FDSETEMSGTRESH:
29350                         UDP->max_errors.reporting =
29351 @@ -3685,9 +3685,9 @@ static void __init config_types(void)
29352                 printk("\n");
29353  }
29354  
29355 -static int floppy_release(struct inode * inode, struct file * filp)
29356 +static int floppy_release(struct gendisk *disk)
29357  {
29358 -       int drive = (long)inode->i_bdev->bd_disk->private_data;
29359 +       int drive = (long)disk->private_data;
29360  
29361         down(&open_lock);
29362         if (UDRS->fd_ref < 0)
29363 @@ -3708,9 +3708,9 @@ static int floppy_release(struct inode *
29364   * /dev/PS0 etc), and disallows simultaneous access to the same
29365   * drive with different device numbers.
29366   */
29367 -static int floppy_open(struct inode * inode, struct file * filp)
29368 +static int floppy_open(struct block_device *bdev, struct file * filp)
29369  {
29370 -       int drive = (long)inode->i_bdev->bd_disk->private_data;
29371 +       int drive = (long)bdev->bd_disk->private_data;
29372         int old_dev;
29373         int try;
29374         int res = -EBUSY;
29375 @@ -3719,7 +3719,7 @@ static int floppy_open(struct inode * in
29376         filp->private_data = (void*) 0;
29377         down(&open_lock);
29378         old_dev = UDRS->fd_device;
29379 -       if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev)
29380 +       if (opened_bdev[drive] && opened_bdev[drive] != bdev)
29381                 goto out2;
29382  
29383         if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)){
29384 @@ -3739,7 +3739,7 @@ static int floppy_open(struct inode * in
29385         else
29386                 UDRS->fd_ref++;
29387  
29388 -       opened_bdev[drive] = inode->i_bdev;
29389 +       opened_bdev[drive] = bdev;
29390  
29391         res = -ENXIO;
29392  
29393 @@ -3774,9 +3774,9 @@ static int floppy_open(struct inode * in
29394                 }
29395         }
29396  
29397 -       UDRS->fd_device = iminor(inode);
29398 -       set_capacity(disks[drive], floppy_sizes[iminor(inode)]);
29399 -       if (old_dev != -1 && old_dev != iminor(inode)) {
29400 +       UDRS->fd_device = MINOR(bdev->bd_dev);
29401 +       set_capacity(disks[drive], floppy_sizes[MINOR(bdev->bd_dev)]);
29402 +       if (old_dev != -1 && old_dev != MINOR(bdev->bd_dev)) {
29403                 if (buffer_drive == drive)
29404                         buffer_track = -1;
29405         }
29406 @@ -3784,8 +3784,7 @@ static int floppy_open(struct inode * in
29407         /* Allow ioctls if we have write-permissions even if read-only open.
29408          * Needed so that programs such as fdrawcmd still can work on write
29409          * protected disks */
29410 -       if ((filp->f_mode & 2) || 
29411 -           (inode->i_sb && (permission(inode,2, NULL) == 0)))
29412 +       if ((filp->f_mode & 2) || permission(filp->f_dentry->d_inode,2,NULL) == 0)
29413             filp->private_data = (void*) 8;
29414  
29415         if (UFDCS->rawcmd == 1)
29416 @@ -3794,7 +3793,7 @@ static int floppy_open(struct inode * in
29417         if (!(filp->f_flags & O_NDELAY)) {
29418                 if (filp->f_mode & 3) {
29419                         UDRS->last_checked = 0;
29420 -                       check_disk_change(inode->i_bdev);
29421 +                       check_disk_change(bdev);
29422                         if (UTESTF(FD_DISK_CHANGED))
29423                                 goto out;
29424                 }
29425 --- linux-2.6.0-test6/drivers/block/initrd.c    2003-06-14 12:18:51.000000000 -0700
29426 +++ /dev/null   2002-08-30 16:31:37.000000000 -0700
29427 @@ -1,100 +0,0 @@
29428 -
29429 -#include <linux/blkdev.h>
29430 -#include <linux/genhd.h>
29431 -#include <linux/initrd.h>
29432 -#include <linux/init.h>
29433 -#include <linux/major.h>
29434 -#include <linux/module.h>
29435 -#include <linux/spinlock.h>
29436 -#include <asm/uaccess.h>
29437 -
29438 -
29439 -unsigned long initrd_start, initrd_end;
29440 -int initrd_below_start_ok;
29441 -
29442 -static int initrd_users;
29443 -static spinlock_t initrd_users_lock = SPIN_LOCK_UNLOCKED;
29444 -
29445 -static struct gendisk *initrd_disk;
29446 -
29447 -static ssize_t initrd_read(struct file *file, char *buf,
29448 -                          size_t count, loff_t *ppos)
29449 -{
29450 -       int left = initrd_end - initrd_start - *ppos;
29451 -
29452 -       if (count > left)
29453 -               count = left;
29454 -       if (count == 0)
29455 -               return 0;
29456 -       if (copy_to_user(buf, (char *)initrd_start + *ppos, count))
29457 -               return -EFAULT;
29458 -
29459 -       *ppos += count;
29460 -       return count;
29461 -}
29462 -
29463 -static int initrd_release(struct inode *inode,struct file *file)
29464 -{
29465 -
29466 -       blkdev_put(inode->i_bdev, BDEV_FILE);
29467 -
29468 -       spin_lock(&initrd_users_lock);
29469 -       if (!--initrd_users) {
29470 -               spin_unlock(&initrd_users_lock);
29471 -               del_gendisk(initrd_disk);
29472 -               free_initrd_mem(initrd_start, initrd_end);
29473 -               initrd_start = 0;
29474 -       } else
29475 -               spin_unlock(&initrd_users_lock);
29476 -
29477 -       return 0;
29478 -}
29479 -
29480 -static struct file_operations initrd_fops = {
29481 -       .read =         initrd_read,
29482 -       .release =      initrd_release,
29483 -};
29484 -
29485 -static int initrd_open(struct inode *inode, struct file *filp)
29486 -{
29487 -       if (!initrd_start) 
29488 -               return -ENODEV;
29489 -
29490 -       spin_lock(&initrd_users_lock);
29491 -       initrd_users++;
29492 -       spin_unlock(&initrd_users_lock);
29493 -
29494 -       filp->f_op = &initrd_fops;
29495 -       return 0;
29496 -}
29497 -
29498 -static struct block_device_operations initrd_bdops = {
29499 -       .owner =        THIS_MODULE,
29500 -       .open =         initrd_open,
29501 -};
29502 -
29503 -static int __init initrd_init(void)
29504 -{
29505 -       initrd_disk = alloc_disk(1);
29506 -       if (!initrd_disk)
29507 -               return -ENOMEM;
29508 -
29509 -       initrd_disk->major = RAMDISK_MAJOR;
29510 -       initrd_disk->first_minor = INITRD_MINOR;
29511 -       initrd_disk->fops = &initrd_bdops;      
29512 -
29513 -       sprintf(initrd_disk->disk_name, "initrd");
29514 -       sprintf(initrd_disk->devfs_name, "rd/initrd");
29515 -
29516 -       set_capacity(initrd_disk, (initrd_end-initrd_start+511) >> 9);
29517 -       add_disk(initrd_disk);
29518 -       return 0;
29519 -}
29520 -
29521 -static void __exit initrd_exit(void)
29522 -{
29523 -       put_disk(initrd_disk);
29524 -}
29525 -
29526 -module_init(initrd_init);
29527 -module_exit(initrd_exit);
29528 --- linux-2.6.0-test6/drivers/block/ioctl.c     2003-09-08 13:58:56.000000000 -0700
29529 +++ 25/drivers/block/ioctl.c    2003-10-05 00:34:11.000000000 -0700
29530 @@ -132,10 +132,9 @@ static int put_u64(unsigned long arg, u6
29531         return put_user(val, (u64 *)arg);
29532  }
29533  
29534 -int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd,
29535 +int blkdev_ioctl(struct block_device *bdev, struct file *file, unsigned cmd,
29536                         unsigned long arg)
29537  {
29538 -       struct block_device *bdev = inode->i_bdev;
29539         struct gendisk *disk = bdev->bd_disk;
29540         struct backing_dev_info *bdi;
29541         int holder;
29542 @@ -194,7 +193,7 @@ int blkdev_ioctl(struct inode *inode, st
29543                 if (!capable(CAP_SYS_ADMIN))
29544                         return -EACCES;
29545                 if (disk->fops->ioctl) {
29546 -                       ret = disk->fops->ioctl(inode, file, cmd, arg);
29547 +                       ret = disk->fops->ioctl(bdev, file, cmd, arg);
29548                         if (ret != -EINVAL)
29549                                 return ret;
29550                 }
29551 @@ -203,7 +202,7 @@ int blkdev_ioctl(struct inode *inode, st
29552                 return 0;
29553         case BLKROSET:
29554                 if (disk->fops->ioctl) {
29555 -                       ret = disk->fops->ioctl(inode, file, cmd, arg);
29556 +                       ret = disk->fops->ioctl(bdev, file, cmd, arg);
29557                         if (ret != -EINVAL)
29558                                 return ret;
29559                 }
29560 @@ -215,7 +214,7 @@ int blkdev_ioctl(struct inode *inode, st
29561                 return 0;
29562         default:
29563                 if (disk->fops->ioctl)
29564 -                       return disk->fops->ioctl(inode, file, cmd, arg);
29565 +                       return disk->fops->ioctl(bdev, file, cmd, arg);
29566         }
29567         return -ENOTTY;
29568  }
29569 --- linux-2.6.0-test6/drivers/block/Kconfig     2003-09-27 18:57:44.000000000 -0700
29570 +++ 25/drivers/block/Kconfig    2003-10-05 00:33:24.000000000 -0700
29571 @@ -6,7 +6,7 @@ menu "Block devices"
29572  
29573  config BLK_DEV_FD
29574         tristate "Normal floppy disk support"
29575 -       depends on !X86_PC9800 && !ARCH_S390
29576 +       depends on ISA || M68 || SPARC64
29577         ---help---
29578           If you want to use the floppy disk drive(s) of your PC under Linux,
29579           say Y. Information about this driver, especially important for IBM
29580 @@ -35,7 +35,7 @@ config BLK_DEV_FD98
29581  
29582  config BLK_DEV_SWIM_IOP
29583         bool "Macintosh IIfx/Quadra 900/Quadra 950 floppy support (EXPERIMENTAL)"
29584 -       depends on MAC && EXPERIMENTAL
29585 +       depends on MAC && EXPERIMENTAL && BROKEN
29586         help
29587           Say Y here to support the SWIM (Super Woz Integrated Machine) IOP
29588           floppy controller on the Macintosh IIfx and Quadra 900/950.
29589 @@ -63,7 +63,7 @@ config AMIGA_Z2RAM
29590  
29591  config ATARI_ACSI
29592         tristate "Atari ACSI support"
29593 -       depends on ATARI
29594 +       depends on ATARI && BROKEN
29595         ---help---
29596           This enables support for the Atari ACSI interface. The driver
29597           supports hard disks and CD-ROMs, which have 512-byte sectors, or can
29598 --- linux-2.6.0-test6/drivers/block/Kconfig.iosched     2003-08-22 19:23:40.000000000 -0700
29599 +++ 25/drivers/block/Kconfig.iosched    2003-10-05 00:34:17.000000000 -0700
29600 @@ -27,3 +27,10 @@ config IOSCHED_DEADLINE
29601           a disk at any one time, its behaviour is almost identical to the
29602           anticipatory I/O scheduler and so is a good choice.
29603  
29604 +config IOSCHED_CFQ
29605 +       bool "CFQ I/O scheduler" if EMBEDDED
29606 +       default y
29607 +       ---help---
29608 +         The CFQ I/O scheduler tries to distribute bandwidth equally
29609 +         among all processes in the system. It should provide a fair
29610 +         working environment, suitable for desktop systems.
29611 --- linux-2.6.0-test6/drivers/block/ll_rw_blk.c 2003-09-27 18:57:44.000000000 -0700
29612 +++ 25/drivers/block/ll_rw_blk.c        2003-10-05 00:36:58.000000000 -0700
29613 @@ -119,7 +119,7 @@ static void set_queue_congested(request_
29614  
29615  /**
29616   * blk_get_backing_dev_info - get the address of a queue's backing_dev_info
29617 - * @dev:       device
29618 + * @bdev:      device
29619   *
29620   * Locates the passed device's request queue and returns the address of its
29621   * backing_dev_info
29622 @@ -414,8 +414,8 @@ void blk_queue_segment_boundary(request_
29623  
29624  /**
29625   * blk_queue_dma_alignment - set dma length and memory alignment
29626 - * @q:  the request queue for the device
29627 - * @dma_mask:  alignment mask
29628 + * @q:     the request queue for the device
29629 + * @mask:  alignment mask
29630   *
29631   * description:
29632   *    set required memory and length aligment for direct dma transactions.
29633 @@ -1152,7 +1152,7 @@ void blk_stop_queue(request_queue_t *q)
29634  
29635  /**
29636   * blk_run_queue - run a single device queue
29637 - * @q  The queue to run
29638 + * @q: The queue to run
29639   */
29640  void blk_run_queue(struct request_queue *q)
29641  {
29642 @@ -1257,6 +1257,8 @@ static elevator_t *chosen_elevator =
29643         &iosched_as;
29644  #elif defined(CONFIG_IOSCHED_DEADLINE)
29645         &iosched_deadline;
29646 +#elif defined(CONFIG_IOSCHED_CFQ)
29647 +       &iosched_cfq;
29648  #elif defined(CONFIG_IOSCHED_NOOP)
29649         &elevator_noop;
29650  #else
29651 @@ -1275,6 +1277,10 @@ static int __init elevator_setup(char *s
29652         if (!strcmp(str, "as"))
29653                 chosen_elevator = &iosched_as;
29654  #endif
29655 +#ifdef CONFIG_IOSCHED_CFQ
29656 +       if (!strcmp(str, "cfq"))
29657 +               chosen_elevator = &iosched_cfq;
29658 +#endif
29659  #ifdef CONFIG_IOSCHED_NOOP
29660         if (!strcmp(str, "noop"))
29661                 chosen_elevator = &elevator_noop;
29662 @@ -1459,6 +1465,8 @@ static void freed_request(request_queue_
29663         }
29664  }
29665  
29666 +atomic_t global_nr_requests = ATOMIC_INIT(0);
29667 +
29668  #define blkdev_free_rq(list) list_entry((list)->next, struct request, queuelist)
29669  /*
29670   * Get a free request, queue_lock must not be held
29671 @@ -1536,6 +1544,8 @@ static struct request *get_request(reque
29672         rq->data = NULL;
29673         rq->sense = NULL;
29674  
29675 +       atomic_inc(&global_nr_requests);
29676 +
29677  out:
29678         put_io_context(ioc);
29679         return rq;
29680 @@ -1766,6 +1776,9 @@ void __blk_put_request(request_queue_t *
29681  
29682                 blk_free_request(q, req);
29683                 freed_request(q, rw);
29684 +
29685 +               WARN_ON(atomic_read(&global_nr_requests) == 0);
29686 +               atomic_dec(&global_nr_requests);
29687         }
29688  }
29689  
29690 @@ -1787,25 +1800,50 @@ void blk_put_request(struct request *req
29691  }
29692  
29693  /**
29694 - * blk_congestion_wait - wait for a queue to become uncongested
29695 + * blk_congestion_wait_wq - wait for a queue to become uncongested,
29696   * @rw: READ or WRITE
29697   * @timeout: timeout in jiffies
29698 + * @wait : wait queue entry to use for waiting or async notification
29699 + * (NULL defaults to synchronous behaviour)
29700   *
29701   * Waits for up to @timeout jiffies for a queue (any queue) to exit congestion.
29702   * If no queues are congested then just wait for the next request to be
29703   * returned.
29704 + *
29705 + * If the wait queue parameter specifies an async i/o callback,
29706 + * then instead of blocking, just register the callback on the wait
29707 + * queue for async notification when the queue gets uncongested.
29708   */
29709 -void blk_congestion_wait(int rw, long timeout)
29710 +int blk_congestion_wait_wq(int rw, long timeout, wait_queue_t *wait)
29711  {
29712 -       DEFINE_WAIT(wait);
29713         wait_queue_head_t *wqh = &congestion_wqh[rw];
29714 +       DEFINE_WAIT(local_wait);
29715 +
29716 +       if (!wait)
29717 +               wait = &local_wait;
29718  
29719         blk_run_queues();
29720 -       prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE);
29721 +       prepare_to_wait(wqh, wait, TASK_UNINTERRUPTIBLE);
29722 +       if (!is_sync_wait(wait)) {
29723 +               /*
29724 +                * if we've queued an async wait queue
29725 +                * callback do not block; just tell the
29726 +                * caller to return and retry later when
29727 +                * the callback is notified
29728 +                */
29729 +               return -EIOCBRETRY;
29730 +       }
29731         io_schedule_timeout(timeout);
29732 -       finish_wait(wqh, &wait);
29733 +       finish_wait(wqh, wait);
29734 +       return 0;
29735  }
29736  
29737 +void blk_congestion_wait(int rw, long timeout)
29738 +{
29739 +       blk_congestion_wait_wq(rw, timeout, NULL);
29740 +}
29741 +
29742 +
29743  /*
29744   * Has to be called with the request spinlock acquired
29745   */
29746 @@ -2592,6 +2630,7 @@ void put_io_context(struct io_context *i
29747                 if (ioc->aic && ioc->aic->dtor)
29748                         ioc->aic->dtor(ioc->aic);
29749                 kfree(ioc);
29750 +               WARN_ON(atomic_read(&nr_io_contexts) == 0);
29751                 atomic_dec(&nr_io_contexts);
29752         }
29753  }
29754 @@ -2634,6 +2673,9 @@ struct io_context *get_io_context(int gf
29755                 ret = kmalloc(sizeof(*ret), GFP_ATOMIC);
29756                 if (ret) {
29757                         atomic_inc(&nr_io_contexts);
29758 +                       WARN_ON(atomic_read(&nr_io_contexts) ==
29759 +                               1 + nr_threads + atomic_read(&global_nr_requests));
29760 +
29761                         atomic_set(&ret->refcount, 1);
29762                         ret->pid = tsk->pid;
29763                         ret->last_waited = jiffies; /* doesn't matter... */
29764 --- linux-2.6.0-test6/drivers/block/loop.c      2003-09-27 18:57:44.000000000 -0700
29765 +++ 25/drivers/block/loop.c     2003-10-05 00:34:11.000000000 -0700
29766 @@ -140,8 +140,7 @@ figure_loop_size(struct loop_device *lo)
29767         sector_t x;
29768  
29769         /* Compute loopsize in bytes */
29770 -       size = i_size_read(lo->lo_backing_file->f_dentry->
29771 -                               d_inode->i_mapping->host);
29772 +       size = i_size_read(lo->lo_backing_file->f_mapping->host);
29773         offset = lo->lo_offset;
29774         loopsize = size - offset;
29775         if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize)
29776 @@ -175,7 +174,7 @@ static int
29777  do_lo_send(struct loop_device *lo, struct bio_vec *bvec, int bsize, loff_t pos)
29778  {
29779         struct file *file = lo->lo_backing_file; /* kudos to NFsckingS */
29780 -       struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
29781 +       struct address_space *mapping = file->f_mapping;
29782         struct address_space_operations *aops = mapping->a_ops;
29783         struct page *page;
29784         char *kaddr, *data;
29785 @@ -660,6 +659,7 @@ static int loop_set_fd(struct loop_devic
29786         struct file     *file;
29787         struct inode    *inode;
29788         struct block_device *lo_device = NULL;
29789 +       struct address_space *mapping;
29790         unsigned lo_blocksize;
29791         int             lo_flags = 0;
29792         int             error;
29793 @@ -676,14 +676,16 @@ static int loop_set_fd(struct loop_devic
29794         if (!file)
29795                 goto out;
29796  
29797 -       error = -EINVAL;
29798 -       inode = file->f_dentry->d_inode;
29799 +       mapping = file->f_mapping;
29800 +       inode = mapping->host;
29801  
29802         if (!(file->f_mode & FMODE_WRITE))
29803                 lo_flags |= LO_FLAGS_READ_ONLY;
29804  
29805 +       error = -EINVAL;
29806 +
29807         if (S_ISBLK(inode->i_mode)) {
29808 -               lo_device = inode->i_bdev;
29809 +               lo_device = I_BDEV(inode);
29810                 if (lo_device == bdev) {
29811                         error = -EBUSY;
29812                         goto out;
29813 @@ -692,7 +694,7 @@ static int loop_set_fd(struct loop_devic
29814                 if (bdev_read_only(lo_device))
29815                         lo_flags |= LO_FLAGS_READ_ONLY;
29816         } else if (S_ISREG(inode->i_mode)) {
29817 -               struct address_space_operations *aops = inode->i_mapping->a_ops;
29818 +               struct address_space_operations *aops = mapping->a_ops;
29819                 /*
29820                  * If we can't read - sorry. If we only can't write - well,
29821                  * it's going to be read-only.
29822 @@ -728,9 +730,8 @@ static int loop_set_fd(struct loop_devic
29823                 fput(file);
29824                 goto out_putf;
29825         }
29826 -       lo->old_gfp_mask = mapping_gfp_mask(inode->i_mapping);
29827 -       mapping_set_gfp_mask(inode->i_mapping,
29828 -                            lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
29829 +       lo->old_gfp_mask = mapping_gfp_mask(mapping);
29830 +       mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
29831  
29832         set_blocksize(bdev, lo_blocksize);
29833  
29834 @@ -846,7 +847,7 @@ static int loop_clr_fd(struct loop_devic
29835         memset(lo->lo_file_name, 0, LO_NAME_SIZE);
29836         invalidate_bdev(bdev, 0);
29837         set_capacity(disks[lo->lo_number], 0);
29838 -       mapping_set_gfp_mask(filp->f_dentry->d_inode->i_mapping, gfp);
29839 +       mapping_set_gfp_mask(filp->f_mapping, gfp);
29840         lo->lo_state = Lo_unbound;
29841         fput(filp);
29842         /* This is safe: open() is still holding a reference. */
29843 @@ -1056,19 +1057,19 @@ loop_get_status64(struct loop_device *lo
29844         return err;
29845  }
29846  
29847 -static int lo_ioctl(struct inode * inode, struct file * file,
29848 +static int lo_ioctl(struct block_device *bdev, struct file *file,
29849         unsigned int cmd, unsigned long arg)
29850  {
29851 -       struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
29852 +       struct loop_device *lo = bdev->bd_disk->private_data;
29853         int err;
29854  
29855         down(&lo->lo_ctl_mutex);
29856         switch (cmd) {
29857         case LOOP_SET_FD:
29858 -               err = loop_set_fd(lo, file, inode->i_bdev, arg);
29859 +               err = loop_set_fd(lo, file, bdev, arg);
29860                 break;
29861         case LOOP_CLR_FD:
29862 -               err = loop_clr_fd(lo, inode->i_bdev);
29863 +               err = loop_clr_fd(lo, bdev);
29864                 break;
29865         case LOOP_SET_STATUS:
29866                 err = loop_set_status_old(lo, (struct loop_info *) arg);
29867 @@ -1089,9 +1090,9 @@ static int lo_ioctl(struct inode * inode
29868         return err;
29869  }
29870  
29871 -static int lo_open(struct inode *inode, struct file *file)
29872 +static int lo_open(struct block_device *bdev, struct file *file)
29873  {
29874 -       struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
29875 +       struct loop_device *lo = bdev->bd_disk->private_data;
29876  
29877         down(&lo->lo_ctl_mutex);
29878         lo->lo_refcnt++;
29879 @@ -1100,9 +1101,9 @@ static int lo_open(struct inode *inode, 
29880         return 0;
29881  }
29882  
29883 -static int lo_release(struct inode *inode, struct file *file)
29884 +static int lo_release(struct gendisk *disk)
29885  {
29886 -       struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
29887 +       struct loop_device *lo = disk->private_data;
29888  
29889         down(&lo->lo_ctl_mutex);
29890         --lo->lo_refcnt;
29891 --- linux-2.6.0-test6/drivers/block/Makefile    2003-08-22 19:23:40.000000000 -0700
29892 +++ 25/drivers/block/Makefile   2003-10-05 00:34:17.000000000 -0700
29893 @@ -18,6 +18,7 @@ obj-y := elevator.o ll_rw_blk.o ioctl.o 
29894  obj-$(CONFIG_IOSCHED_NOOP)     += noop-iosched.o
29895  obj-$(CONFIG_IOSCHED_AS)       += as-iosched.o
29896  obj-$(CONFIG_IOSCHED_DEADLINE) += deadline-iosched.o
29897 +obj-$(CONFIG_IOSCHED_CFQ)      += cfq-iosched.o
29898  obj-$(CONFIG_MAC_FLOPPY)       += swim3.o
29899  obj-$(CONFIG_BLK_DEV_FD)       += floppy.o
29900  obj-$(CONFIG_BLK_DEV_FD98)     += floppy98.o
29901 @@ -28,7 +29,6 @@ obj-$(CONFIG_ATARI_ACSI)      += acsi.o
29902  obj-$(CONFIG_ATARI_SLM)                += acsi_slm.o
29903  obj-$(CONFIG_AMIGA_Z2RAM)      += z2ram.o
29904  obj-$(CONFIG_BLK_DEV_RAM)      += rd.o
29905 -obj-$(CONFIG_BLK_DEV_INITRD)   += initrd.o
29906  obj-$(CONFIG_BLK_DEV_LOOP)     += loop.o
29907  obj-$(CONFIG_BLK_DEV_PS2)      += ps2esdi.o
29908  obj-$(CONFIG_BLK_DEV_XD)       += xd.o
29909 --- linux-2.6.0-test6/drivers/block/nbd.c       2003-08-22 19:23:40.000000000 -0700
29910 +++ 25/drivers/block/nbd.c      2003-10-05 00:33:54.000000000 -0700
29911 @@ -535,10 +535,10 @@ static void do_nbd_request(request_queue
29912         return;
29913  }
29914  
29915 -static int nbd_ioctl(struct inode *inode, struct file *file,
29916 +static int nbd_ioctl(struct block_device *bdev, struct file *file,
29917                      unsigned int cmd, unsigned long arg)
29918  {
29919 -       struct nbd_device *lo = inode->i_bdev->bd_disk->private_data;
29920 +       struct nbd_device *lo = bdev->bd_disk->private_data;
29921         int error;
29922         struct request sreq ;
29923  
29924 @@ -593,7 +593,7 @@ static int nbd_ioctl(struct inode *inode
29925                 error = -EINVAL;
29926                 file = fget(arg);
29927                 if (file) {
29928 -                       inode = file->f_dentry->d_inode;
29929 +                       struct inode *inode = file->f_dentry->d_inode;
29930                         if (inode->i_sock) {
29931                                 lo->file = file;
29932                                 lo->sock = SOCKET_I(inode);
29933 @@ -606,20 +606,20 @@ static int nbd_ioctl(struct inode *inode
29934         case NBD_SET_BLKSIZE:
29935                 lo->blksize = arg;
29936                 lo->bytesize &= ~(lo->blksize-1);
29937 -               inode->i_bdev->bd_inode->i_size = lo->bytesize;
29938 -               set_blocksize(inode->i_bdev, lo->blksize);
29939 +               bdev->bd_inode->i_size = lo->bytesize;
29940 +               set_blocksize(bdev, lo->blksize);
29941                 set_capacity(lo->disk, lo->bytesize >> 9);
29942                 return 0;
29943         case NBD_SET_SIZE:
29944                 lo->bytesize = arg & ~(lo->blksize-1);
29945 -               inode->i_bdev->bd_inode->i_size = lo->bytesize;
29946 -               set_blocksize(inode->i_bdev, lo->blksize);
29947 +               bdev->bd_inode->i_size = lo->bytesize;
29948 +               set_blocksize(bdev, lo->blksize);
29949                 set_capacity(lo->disk, lo->bytesize >> 9);
29950                 return 0;
29951         case NBD_SET_SIZE_BLOCKS:
29952                 lo->bytesize = ((u64) arg) * lo->blksize;
29953 -               inode->i_bdev->bd_inode->i_size = lo->bytesize;
29954 -               set_blocksize(inode->i_bdev, lo->blksize);
29955 +               bdev->bd_inode->i_size = lo->bytesize;
29956 +               set_blocksize(bdev, lo->blksize);
29957                 set_capacity(lo->disk, lo->bytesize >> 9);
29958                 return 0;
29959         case NBD_DO_IT:
29960 @@ -664,11 +664,11 @@ static int nbd_ioctl(struct inode *inode
29961         case NBD_PRINT_DEBUG:
29962  #ifdef PARANOIA
29963                 printk(KERN_INFO "%s: next = %p, prev = %p. Global: in %d, out %d\n",
29964 -                       inode->i_bdev->bd_disk->disk_name, lo->queue_head.next,
29965 +                       bdev->bd_disk->disk_name, lo->queue_head.next,
29966                         lo->queue_head.prev, requests_in, requests_out);
29967  #else
29968                 printk(KERN_INFO "%s: next = %p, prev = %p\n",
29969 -                       inode->i_bdev->bd_disk->disk_name,
29970 +                       bdev->bd_disk->disk_name,
29971                         lo->queue_head.next, lo->queue_head.prev);
29972  #endif
29973                 return 0;
29974 --- linux-2.6.0-test6/drivers/block/paride/pcd.c        2003-08-08 22:55:11.000000000 -0700
29975 +++ 25/drivers/block/paride/pcd.c       2003-10-05 00:34:01.000000000 -0700
29976 @@ -243,23 +243,23 @@ static int pcd_warned;            /* Have we logge
29977  
29978  /* kernel glue structures */
29979  
29980 -static int pcd_block_open(struct inode *inode, struct file *file)
29981 +static int pcd_block_open(struct block_device *bdev, struct file *file)
29982  {
29983 -       struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data;
29984 -       return cdrom_open(&cd->info, inode, file);
29985 +       struct pcd_unit *cd = bdev->bd_disk->private_data;
29986 +       return cdrom_open(&cd->info, bdev, file);
29987  }
29988  
29989 -static int pcd_block_release(struct inode *inode, struct file *file)
29990 +static int pcd_block_release(struct gendisk *disk)
29991  {
29992 -       struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data;
29993 -       return cdrom_release(&cd->info, file);
29994 +       struct pcd_unit *cd = disk->private_data;
29995 +       return cdrom_release(&cd->info);
29996  }
29997  
29998 -static int pcd_block_ioctl(struct inode *inode, struct file *file,
29999 +static int pcd_block_ioctl(struct block_device *bdev, struct file *file,
30000                                 unsigned cmd, unsigned long arg)
30001  {
30002 -       struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data;
30003 -       return cdrom_ioctl(&cd->info, inode, cmd, arg);
30004 +       struct pcd_unit *cd = bdev->bd_disk->private_data;
30005 +       return cdrom_ioctl(&cd->info, bdev, cmd, arg);
30006  }
30007  
30008  static int pcd_block_media_changed(struct gendisk *disk)
30009 --- linux-2.6.0-test6/drivers/block/paride/pd.c 2003-09-08 13:58:56.000000000 -0700
30010 +++ 25/drivers/block/paride/pd.c        2003-10-05 00:34:01.000000000 -0700
30011 @@ -236,11 +236,11 @@ MODULE_PARM(drive3, "1-8i");
30012  #define IDE_EJECT              0xed
30013  
30014  void pd_setup(char *str, int *ints);
30015 -static int pd_open(struct inode *inode, struct file *file);
30016 +static int pd_open(struct block_device *bdev, struct file *file);
30017  static void do_pd_request(request_queue_t * q);
30018 -static int pd_ioctl(struct inode *inode, struct file *file,
30019 +static int pd_ioctl(struct block_device *bdev, struct file *file,
30020                     unsigned int cmd, unsigned long arg);
30021 -static int pd_release(struct inode *inode, struct file *file);
30022 +static int pd_release(struct gendisk *disk);
30023  static int pd_revalidate(struct gendisk *p);
30024  static int pd_detect(void);
30025  static void do_pd_read(void);
30026 @@ -304,8 +304,6 @@ static char *pd_errs[17] = { "ERR", "IND
30027  
30028  /* kernel glue structures */
30029  
30030 -extern struct block_device_operations pd_fops;
30031 -
30032  static struct block_device_operations pd_fops = {
30033         .owner          = THIS_MODULE,
30034         .open           = pd_open,
30035 @@ -337,9 +335,9 @@ static void pd_init_units(void)
30036         }
30037  }
30038  
30039 -static int pd_open(struct inode *inode, struct file *file)
30040 +static int pd_open(struct block_device *bdev, struct file *file)
30041  {
30042 -       struct pd_unit *disk = inode->i_bdev->bd_disk->private_data;
30043 +       struct pd_unit *disk = bdev->bd_disk->private_data;
30044  
30045         disk->access++;
30046  
30047 @@ -350,10 +348,10 @@ static int pd_open(struct inode *inode, 
30048         return 0;
30049  }
30050  
30051 -static int pd_ioctl(struct inode *inode, struct file *file,
30052 +static int pd_ioctl(struct block_device *bdev, struct file *file,
30053          unsigned int cmd, unsigned long arg)
30054  {
30055 -       struct pd_unit *disk = inode->i_bdev->bd_disk->private_data;
30056 +       struct pd_unit *disk = bdev->bd_disk->private_data;
30057         struct hd_geometry *geo = (struct hd_geometry *) arg;
30058         struct hd_geometry g;
30059  
30060 @@ -372,7 +370,7 @@ static int pd_ioctl(struct inode *inode,
30061                         g.sectors = disk->sectors;
30062                         g.cylinders = disk->cylinders;
30063                 }
30064 -               g.start = get_start_sect(inode->i_bdev);
30065 +               g.start = get_start_sect(bdev);
30066                 if (copy_to_user(geo, &g, sizeof(struct hd_geometry)))
30067                         return -EFAULT;
30068                 return 0;
30069 @@ -381,9 +379,9 @@ static int pd_ioctl(struct inode *inode,
30070         }
30071  }
30072  
30073 -static int pd_release(struct inode *inode, struct file *file)
30074 +static int pd_release(struct gendisk *p)
30075  {
30076 -       struct pd_unit *disk = inode->i_bdev->bd_disk->private_data;
30077 +       struct pd_unit *disk = p->private_data;
30078  
30079         if (!--disk->access && disk->removable)
30080                 pd_doorlock(disk, IDE_DOORUNLOCK);
30081 --- linux-2.6.0-test6/drivers/block/paride/pf.c 2003-08-08 22:55:11.000000000 -0700
30082 +++ 25/drivers/block/paride/pf.c        2003-10-05 00:34:01.000000000 -0700
30083 @@ -222,12 +222,12 @@ MODULE_PARM(drive3, "1-7i");
30084  #define ATAPI_READ_10          0x28
30085  #define ATAPI_WRITE_10         0x2a
30086  
30087 -static int pf_open(struct inode *inode, struct file *file);
30088 +static int pf_open(struct block_device *bdev, struct file *file);
30089  static void do_pf_request(request_queue_t * q);
30090 -static int pf_ioctl(struct inode *inode, struct file *file,
30091 +static int pf_ioctl(struct block_device *bdev, struct file *file,
30092                     unsigned int cmd, unsigned long arg);
30093  
30094 -static int pf_release(struct inode *inode, struct file *file);
30095 +static int pf_release(struct gendisk *disk);
30096  
30097  static int pf_detect(void);
30098  static void do_pf_read(void);
30099 @@ -315,9 +315,9 @@ void pf_init_units(void)
30100         }
30101  }
30102  
30103 -static int pf_open(struct inode *inode, struct file *file)
30104 +static int pf_open(struct block_device *bdev, struct file *file)
30105  {
30106 -       struct pf_unit *pf = inode->i_bdev->bd_disk->private_data;
30107 +       struct pf_unit *pf = bdev->bd_disk->private_data;
30108  
30109         pf_identify(pf);
30110  
30111 @@ -334,9 +334,9 @@ static int pf_open(struct inode *inode, 
30112         return 0;
30113  }
30114  
30115 -static int pf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
30116 +static int pf_ioctl(struct block_device *bdev, struct file *file, unsigned int cmd, unsigned long arg)
30117  {
30118 -       struct pf_unit *pf = inode->i_bdev->bd_disk->private_data;
30119 +       struct pf_unit *pf = bdev->bd_disk->private_data;
30120         struct hd_geometry *geo = (struct hd_geometry *) arg;
30121         struct hd_geometry g;
30122         sector_t capacity;
30123 @@ -365,9 +365,9 @@ static int pf_ioctl(struct inode *inode,
30124         return 0;
30125  }
30126  
30127 -static int pf_release(struct inode *inode, struct file *file)
30128 +static int pf_release(struct gendisk *disk)
30129  {
30130 -       struct pf_unit *pf = inode->i_bdev->bd_disk->private_data;
30131 +       struct pf_unit *pf = disk->private_data;
30132  
30133         if (pf->access <= 0)
30134                 return -EINVAL;
30135 --- linux-2.6.0-test6/drivers/block/ps2esdi.c   2003-09-27 18:57:44.000000000 -0700
30136 +++ 25/drivers/block/ps2esdi.c  2003-10-05 00:33:54.000000000 -0700
30137 @@ -39,7 +39,7 @@
30138  #include <linux/genhd.h>
30139  #include <linux/ps2esdi.h>
30140  #include <linux/blkdev.h>
30141 -#include <linux/mca.h>
30142 +#include <linux/mca-legacy.h>
30143  #include <linux/init.h>
30144  #include <linux/ioport.h>
30145  #include <linux/module.h>
30146 @@ -81,7 +81,7 @@ static void (*current_int_handler) (u_in
30147  static void ps2esdi_normal_interrupt_handler(u_int);
30148  static void ps2esdi_initial_reset_int_handler(u_int);
30149  static void ps2esdi_geometry_int_handler(u_int);
30150 -static int ps2esdi_ioctl(struct inode *inode, struct file *file,
30151 +static int ps2esdi_ioctl(struct block_device *bdev, struct file *file,
30152                          u_int cmd, u_long arg);
30153  
30154  static int ps2esdi_read_status_words(int num_words, int max_words, u_short * buffer);
30155 @@ -1059,10 +1059,10 @@ static void dump_cmd_complete_status(u_i
30156  
30157  }
30158  
30159 -static int ps2esdi_ioctl(struct inode *inode,
30160 +static int ps2esdi_ioctl(struct block_device *bdev,
30161                          struct file *file, u_int cmd, u_long arg)
30162  {
30163 -       struct ps2esdi_i_struct *p = inode->i_bdev->bd_disk->private_data;
30164 +       struct ps2esdi_i_struct *p = bdev->bd_disk->private_data;
30165         struct ps2esdi_geometry *geometry = (struct ps2esdi_geometry *) arg;
30166         int err;
30167  
30168 @@ -1073,7 +1073,7 @@ static int ps2esdi_ioctl(struct inode *i
30169         put_user(p->head, (char *) &geometry->heads);
30170         put_user(p->sect, (char *) &geometry->sectors);
30171         put_user(p->cyl, (short *) &geometry->cylinders);
30172 -       put_user(get_start_sect(inode->i_bdev), (long *) &geometry->start);
30173 +       put_user(get_start_sect(bdev), (long *) &geometry->start);
30174         return 0;
30175  }
30176  
30177 --- linux-2.6.0-test6/drivers/block/rd.c        2003-09-08 13:58:56.000000000 -0700
30178 +++ 25/drivers/block/rd.c       2003-10-05 00:34:30.000000000 -0700
30179 @@ -1,15 +1,15 @@
30180  /*
30181   * ramdisk.c - Multiple RAM disk driver - gzip-loading version - v. 0.8 beta.
30182 - * 
30183 - * (C) Chad Page, Theodore Ts'o, et. al, 1995. 
30184 + *
30185 + * (C) Chad Page, Theodore Ts'o, et. al, 1995.
30186   *
30187   * This RAM disk is designed to have filesystems created on it and mounted
30188 - * just like a regular floppy disk.  
30189 - *  
30190 + * just like a regular floppy disk.
30191 + *
30192   * It also does something suggested by Linus: use the buffer cache as the
30193   * RAM disk data.  This makes it possible to dynamically allocate the RAM disk
30194 - * buffer - with some consequences I have to deal with as I write this. 
30195 - * 
30196 + * buffer - with some consequences I have to deal with as I write this.
30197 + *
30198   * This code is based on the original ramdisk.c, written mostly by
30199   * Theodore Ts'o (TYT) in 1991.  The code was largely rewritten by
30200   * Chad Page to use the buffer cache to store the RAM disk data in
30201 @@ -33,7 +33,7 @@
30202   *
30203   *  Added initrd: Werner Almesberger & Hans Lermen, Feb '96
30204   *
30205 - * 4/25/96 : Made RAM disk size a parameter (default is now 4 MB) 
30206 + * 4/25/96 : Made RAM disk size a parameter (default is now 4 MB)
30207   *             - Chad Page
30208   *
30209   * Add support for fs images split across >1 disk, Paul Gortmaker, Mar '98
30210 @@ -60,7 +60,7 @@
30211  #include <asm/uaccess.h>
30212  
30213  /* The RAM disk size is now a parameter */
30214 -#define NUM_RAMDISKS 16                /* This cannot be overridden (yet) */ 
30215 +#define NUM_RAMDISKS 16                /* This cannot be overridden (yet) */
30216  
30217  /* Various static variables go here.  Most are used only in the RAM disk code.
30218   */
30219 @@ -73,7 +73,7 @@ static struct request_queue *rd_queue[NU
30220   * Parameters for the boot-loading of the RAM disk.  These are set by
30221   * init/main.c (from arguments to the kernel command line) or from the
30222   * architecture-specific setup routine (from the stored boot sector
30223 - * information). 
30224 + * information).
30225   */
30226  int rd_size = CONFIG_BLK_DEV_RAM_SIZE;         /* Size of the RAM disks */
30227  /*
30228 @@ -94,7 +94,7 @@ int rd_blocksize = BLOCK_SIZE;                        /* bloc
30229   *               2000 Transmeta Corp.
30230   * aops copied from ramfs.
30231   */
30232 -static int ramdisk_readpage(struct file *file, struct page * page)
30233 +static int ramdisk_readpage(struct file *file, struct page *page)
30234  {
30235         if (!PageUptodate(page)) {
30236                 void *kaddr = kmap_atomic(page, KM_USER0);
30237 @@ -108,7 +108,8 @@ static int ramdisk_readpage(struct file 
30238         return 0;
30239  }
30240  
30241 -static int ramdisk_prepare_write(struct file *file, struct page *page, unsigned offset, unsigned to)
30242 +static int ramdisk_prepare_write(struct file *file, struct page *page,
30243 +                               unsigned offset, unsigned to)
30244  {
30245         if (!PageUptodate(page)) {
30246                 void *kaddr = kmap_atomic(page, KM_USER0);
30247 @@ -122,7 +123,8 @@ static int ramdisk_prepare_write(struct 
30248         return 0;
30249  }
30250  
30251 -static int ramdisk_commit_write(struct file *file, struct page *page, unsigned offset, unsigned to)
30252 +static int ramdisk_commit_write(struct file *file, struct page *page,
30253 +                               unsigned offset, unsigned to)
30254  {
30255         return 0;
30256  }
30257 @@ -212,7 +214,7 @@ static int rd_blkdev_pagecache_IO(int rw
30258   * 19-JAN-1998  Richard Gooch <rgooch@atnf.csiro.au>  Added devfs support
30259   *
30260   */
30261 -static int rd_make_request(request_queue_t * q, struct bio *bio)
30262 +static int rd_make_request(request_queue_t *q, struct bio *bio)
30263  {
30264         struct block_device *bdev = bio->bi_bdev;
30265         struct address_space * mapping = bdev->bd_inode->i_mapping;
30266 @@ -242,17 +244,19 @@ fail:
30267         return 0;
30268  } 
30269  
30270 -static int rd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
30271 +static int rd_ioctl(struct block_device *bdev, struct file *file,
30272 +                       unsigned int cmd, unsigned long arg)
30273  {
30274         int error;
30275 -       struct block_device *bdev = inode->i_bdev;
30276  
30277         if (cmd != BLKFLSBUF)
30278                 return -EINVAL;
30279  
30280 -       /* special: we want to release the ramdisk memory,
30281 -          it's not like with the other blockdevices where
30282 -          this ioctl only flushes away the buffer cache. */
30283 +       /*
30284 +        * special: we want to release the ramdisk memory, it's not like with
30285 +        * the other blockdevices where this ioctl only flushes away the buffer
30286 +        * cache
30287 +        */
30288         error = -EBUSY;
30289         down(&bdev->bd_sem);
30290         if (bdev->bd_openers <= 2) {
30291 @@ -268,16 +272,15 @@ static struct backing_dev_info rd_backin
30292         .memory_backed  = 1,    /* Does not contribute to dirty memory */
30293  };
30294  
30295 -static int rd_open(struct inode * inode, struct file * filp)
30296 +static int rd_open(struct block_device *bdev, struct file *filp)
30297  {
30298 -       unsigned unit = iminor(inode);
30299 +       unsigned unit = MINOR(bdev->bd_dev);
30300  
30301         /*
30302          * Immunize device against invalidate_buffers() and prune_icache().
30303          */
30304         if (rd_bdev[unit] == NULL) {
30305 -               struct block_device *bdev = inode->i_bdev;
30306 -               inode = igrab(bdev->bd_inode);
30307 +               struct inode *inode = igrab(bdev->bd_inode);
30308                 rd_bdev[unit] = bdev;
30309                 bdev->bd_openers++;
30310                 bdev->bd_block_size = rd_blocksize;
30311 @@ -295,12 +298,14 @@ static struct block_device_operations rd
30312         .ioctl =        rd_ioctl,
30313  };
30314  
30315 -/* Before freeing the module, invalidate all of the protected buffers! */
30316 -static void __exit rd_cleanup (void)
30317 +/*
30318 + * Before freeing the module, invalidate all of the protected buffers!
30319 + */
30320 +static void __exit rd_cleanup(void)
30321  {
30322         int i;
30323  
30324 -       for (i = 0 ; i < NUM_RAMDISKS; i++) {
30325 +       for (i = 0; i < NUM_RAMDISKS; i++) {
30326                 struct block_device *bdev = rd_bdev[i];
30327                 rd_bdev[i] = NULL;
30328                 if (bdev) {
30329 @@ -311,17 +316,19 @@ static void __exit rd_cleanup (void)
30330                 put_disk(rd_disks[i]);
30331         }
30332         devfs_remove("rd");
30333 -       unregister_blkdev(RAMDISK_MAJOR, "ramdisk" );
30334 +       unregister_blkdev(RAMDISK_MAJOR, "ramdisk");
30335  }
30336  
30337 -/* This is the registration and initialization section of the RAM disk driver */
30338 -static int __init rd_init (void)
30339 +/*
30340 + * This is the registration and initialization section of the RAM disk driver
30341 + */
30342 +static int __init rd_init(void)
30343  {
30344         int i;
30345         int err = -ENOMEM;
30346  
30347         if (rd_blocksize > PAGE_SIZE || rd_blocksize < 512 ||
30348 -           (rd_blocksize & (rd_blocksize-1))) {
30349 +                       (rd_blocksize & (rd_blocksize-1))) {
30350                 printk("RAMDISK: wrong blocksize %d, reverting to defaults\n",
30351                        rd_blocksize);
30352                 rd_blocksize = BLOCK_SIZE;
30353 @@ -362,8 +369,8 @@ static int __init rd_init (void)
30354  
30355         /* rd_size is given in kB */
30356         printk("RAMDISK driver initialized: "
30357 -              "%d RAM disks of %dK size %d blocksize\n",
30358 -              NUM_RAMDISKS, rd_size, rd_blocksize);
30359 +               "%d RAM disks of %dK size %d blocksize\n",
30360 +               NUM_RAMDISKS, rd_size, rd_blocksize);
30361  
30362         return 0;
30363  out_queue:
30364 --- linux-2.6.0-test6/drivers/block/scsi_ioctl.c        2003-09-08 13:58:56.000000000 -0700
30365 +++ 25/drivers/block/scsi_ioctl.c       2003-10-05 00:36:48.000000000 -0700
30366 @@ -25,6 +25,7 @@
30367  #include <linux/cdrom.h>
30368  #include <linux/slab.h>
30369  #include <linux/bio.h>
30370 +#include <linux/times.h>
30371  #include <asm/uaccess.h>
30372  
30373  #include <scsi/scsi.h>
30374 @@ -140,40 +141,36 @@ static int sg_emulated_host(request_queu
30375  }
30376  
30377  static int sg_io(request_queue_t *q, struct block_device *bdev,
30378 -                struct sg_io_hdr *uptr)
30379 +                struct sg_io_hdr *hdr)
30380  {
30381         unsigned long start_time;
30382         int reading, writing;
30383 -       struct sg_io_hdr hdr;
30384         struct request *rq;
30385         struct bio *bio;
30386         char sense[SCSI_SENSE_BUFFERSIZE];
30387         void *buffer;
30388  
30389 -       if (copy_from_user(&hdr, uptr, sizeof(*uptr)))
30390 -               return -EFAULT;
30391 -
30392 -       if (hdr.interface_id != 'S')
30393 +       if (hdr->interface_id != 'S')
30394                 return -EINVAL;
30395 -       if (hdr.cmd_len > sizeof(rq->cmd))
30396 +       if (hdr->cmd_len > sizeof(rq->cmd))
30397                 return -EINVAL;
30398  
30399         /*
30400          * we'll do that later
30401          */
30402 -       if (hdr.iovec_count)
30403 +       if (hdr->iovec_count)
30404                 return -EOPNOTSUPP;
30405  
30406 -       if (hdr.dxfer_len > (q->max_sectors << 9))
30407 +       if (hdr->dxfer_len > (q->max_sectors << 9))
30408                 return -EIO;
30409  
30410         reading = writing = 0;
30411         buffer = NULL;
30412         bio = NULL;
30413 -       if (hdr.dxfer_len) {
30414 -               unsigned int bytes = (hdr.dxfer_len + 511) & ~511;
30415 +       if (hdr->dxfer_len) {
30416 +               unsigned int bytes = (hdr->dxfer_len + 511) & ~511;
30417  
30418 -               switch (hdr.dxfer_direction) {
30419 +               switch (hdr->dxfer_direction) {
30420                 default:
30421                         return -EINVAL;
30422                 case SG_DXFER_TO_FROM_DEV:
30423 @@ -191,8 +188,8 @@ static int sg_io(request_queue_t *q, str
30424                  * first try to map it into a bio. reading from device will
30425                  * be a write to vm.
30426                  */
30427 -               bio = bio_map_user(bdev, (unsigned long) hdr.dxferp,
30428 -                                  hdr.dxfer_len, reading);
30429 +               bio = bio_map_user(bdev, (unsigned long) hdr->dxferp,
30430 +                                  hdr->dxfer_len, reading);
30431  
30432                 /*
30433                  * if bio setup failed, fall back to slow approach
30434 @@ -203,11 +200,11 @@ static int sg_io(request_queue_t *q, str
30435                                 return -ENOMEM;
30436  
30437                         if (writing) {
30438 -                               if (copy_from_user(buffer, hdr.dxferp,
30439 -                                                  hdr.dxfer_len))
30440 +                               if (copy_from_user(buffer, hdr->dxferp,
30441 +                                                  hdr->dxfer_len))
30442                                         goto out_buffer;
30443                         } else
30444 -                               memset(buffer, 0, hdr.dxfer_len);
30445 +                               memset(buffer, 0, hdr->dxfer_len);
30446                 }
30447         }
30448  
30449 @@ -216,11 +213,10 @@ static int sg_io(request_queue_t *q, str
30450         /*
30451          * fill in request structure
30452          */
30453 -       rq->cmd_len = hdr.cmd_len;
30454 -       if (copy_from_user(rq->cmd, hdr.cmdp, hdr.cmd_len))
30455 -               goto out_request;
30456 -       if (sizeof(rq->cmd) != hdr.cmd_len)
30457 -               memset(rq->cmd + hdr.cmd_len, 0, sizeof(rq->cmd) - hdr.cmd_len);
30458 +       rq->cmd_len = hdr->cmd_len;
30459 +       memcpy(rq->cmd, hdr->cmdp, hdr->cmd_len);
30460 +       if (sizeof(rq->cmd) != hdr->cmd_len)
30461 +               memset(rq->cmd + hdr->cmd_len, 0, sizeof(rq->cmd) - hdr->cmd_len);
30462  
30463         memset(sense, 0, sizeof(sense));
30464         rq->sense = sense;
30465 @@ -234,9 +230,9 @@ static int sg_io(request_queue_t *q, str
30466                 blk_rq_bio_prep(q, rq, bio);
30467  
30468         rq->data = buffer;
30469 -       rq->data_len = hdr.dxfer_len;
30470 +       rq->data_len = hdr->dxfer_len;
30471  
30472 -       rq->timeout = (hdr.timeout * HZ) / 1000;
30473 +       rq->timeout = (hdr->timeout * HZ) / 1000;
30474         if (!rq->timeout)
30475                 rq->timeout = q->sg_timeout;
30476         if (!rq->timeout)
30477 @@ -254,33 +250,30 @@ static int sg_io(request_queue_t *q, str
30478                 bio_unmap_user(bio, reading);
30479  
30480         /* write to all output members */
30481 -       hdr.status = rq->errors;        
30482 -       hdr.masked_status = (hdr.status >> 1) & 0x1f;
30483 -       hdr.msg_status = 0;
30484 -       hdr.host_status = 0;
30485 -       hdr.driver_status = 0;
30486 -       hdr.info = 0;
30487 -       if (hdr.masked_status || hdr.host_status || hdr.driver_status)
30488 -               hdr.info |= SG_INFO_CHECK;
30489 -       hdr.resid = rq->data_len;
30490 -       hdr.duration = ((jiffies - start_time) * 1000) / HZ;
30491 -       hdr.sb_len_wr = 0;
30492 +       hdr->status = rq->errors;       
30493 +       hdr->masked_status = (hdr->status >> 1) & 0x1f;
30494 +       hdr->msg_status = 0;
30495 +       hdr->host_status = 0;
30496 +       hdr->driver_status = 0;
30497 +       hdr->info = 0;
30498 +       if (hdr->masked_status || hdr->host_status || hdr->driver_status)
30499 +               hdr->info |= SG_INFO_CHECK;
30500 +       hdr->resid = rq->data_len;
30501 +       hdr->duration = ((jiffies - start_time) * 1000) / HZ;
30502 +       hdr->sb_len_wr = 0;
30503  
30504 -       if (rq->sense_len && hdr.sbp) {
30505 -               int len = min((unsigned int) hdr.mx_sb_len, rq->sense_len);
30506 +       if (rq->sense_len && hdr->sbp) {
30507 +               int len = min((unsigned int) hdr->mx_sb_len, rq->sense_len);
30508  
30509 -               if (!copy_to_user(hdr.sbp, rq->sense, len))
30510 -                       hdr.sb_len_wr = len;
30511 +               if (!copy_to_user(hdr->sbp, rq->sense, len))
30512 +                       hdr->sb_len_wr = len;
30513         }
30514  
30515         blk_put_request(rq);
30516  
30517 -       if (copy_to_user(uptr, &hdr, sizeof(*uptr)))
30518 -               goto out_buffer;
30519 -
30520         if (buffer) {
30521                 if (reading)
30522 -                       if (copy_to_user(hdr.dxferp, buffer, hdr.dxfer_len))
30523 +                       if (copy_to_user(hdr->dxferp, buffer, hdr->dxfer_len))
30524                                 goto out_buffer;
30525  
30526                 kfree(buffer);
30527 @@ -289,8 +282,6 @@ static int sg_io(request_queue_t *q, str
30528         /* may not have succeeded, but output values written to control
30529          * structure (struct sg_io_hdr).  */
30530         return 0;
30531 -out_request:
30532 -       blk_put_request(rq);
30533  out_buffer:
30534         kfree(buffer);
30535         return -EFAULT;
30536 @@ -319,7 +310,7 @@ static int sg_scsi_ioctl(request_queue_t
30537                 return -EFAULT;
30538         if (in_len > PAGE_SIZE || out_len > PAGE_SIZE)
30539                 return -EINVAL;
30540 -       if (get_user(opcode, sic->data))
30541 +       if (get_user(opcode, (int *)sic->data))
30542                 return -EFAULT;
30543  
30544         bytes = max(in_len, out_len);
30545 @@ -437,9 +428,71 @@ int scsi_cmd_ioctl(struct block_device *
30546                 case SG_EMULATED_HOST:
30547                         err = sg_emulated_host(q, (int *) arg);
30548                         break;
30549 -               case SG_IO:
30550 -                       err = sg_io(q, bdev, (struct sg_io_hdr *) arg);
30551 +               case SG_IO: {
30552 +                       struct sg_io_hdr hdr;
30553 +
30554 +                       if (copy_from_user(&hdr, (struct sg_io_hdr *) arg, sizeof(hdr))) {
30555 +                               err = -EFAULT;
30556 +                               break;
30557 +                       }
30558 +                       err = sg_io(q, bdev, &hdr);
30559 +                       if (copy_to_user((struct sg_io_hdr *) arg, &hdr, sizeof(hdr)))
30560 +                               err = -EFAULT;
30561                         break;
30562 +               }
30563 +               case CDROM_SEND_PACKET: {
30564 +                       struct cdrom_generic_command cgc;
30565 +                       struct sg_io_hdr hdr;
30566 +
30567 +                       if (copy_from_user(&cgc, (struct cdrom_generic_command *) arg, sizeof(cgc))) {
30568 +                               err = -EFAULT;
30569 +                               break;
30570 +                       }
30571 +                       cgc.timeout = clock_t_to_jiffies(cgc.timeout);
30572 +                       memset(&hdr, 0, sizeof(hdr));
30573 +                       hdr.interface_id = 'S';
30574 +                       hdr.cmd_len = sizeof(cgc.cmd);
30575 +                       hdr.dxfer_len = cgc.buflen;
30576 +                       err = 0;
30577 +                       switch (cgc.data_direction) {
30578 +                               case CGC_DATA_UNKNOWN:
30579 +                                       hdr.dxfer_direction = SG_DXFER_UNKNOWN;
30580 +                                       break;
30581 +                               case CGC_DATA_WRITE:
30582 +                                       hdr.dxfer_direction = SG_DXFER_TO_DEV;
30583 +                                       break;
30584 +                               case CGC_DATA_READ:
30585 +                                       hdr.dxfer_direction = SG_DXFER_FROM_DEV;
30586 +                                       break;
30587 +                               case CGC_DATA_NONE:
30588 +                                       hdr.dxfer_direction = SG_DXFER_NONE;
30589 +                                       break;
30590 +                               default:
30591 +                                       err = -EINVAL;
30592 +                       }
30593 +                       if (err)
30594 +                               break;
30595 +
30596 +                       hdr.dxferp = cgc.buffer;
30597 +                       hdr.sbp = (char *) cgc.sense;
30598 +                       if (hdr.sbp)
30599 +                               hdr.mx_sb_len = sizeof(struct request_sense);
30600 +                       hdr.timeout = cgc.timeout;
30601 +                       hdr.cmdp = cgc.cmd;
30602 +                       hdr.cmd_len = sizeof(cgc.cmd);
30603 +                       err = sg_io(q, bdev, &hdr);
30604 +
30605 +                       if (hdr.status)
30606 +                               err = -EIO;
30607 +
30608 +                       cgc.stat = err;
30609 +                       cgc.buflen = hdr.resid;
30610 +                       if (copy_to_user((struct cdrom_generic_command *) arg, &cgc, sizeof(cgc)))
30611 +                               err = -EFAULT;
30612 +
30613 +                       break;
30614 +               }
30615 +
30616                 /*
30617                  * old junk scsi send command ioctl
30618                  */
30619 --- linux-2.6.0-test6/drivers/block/swim3.c     2003-08-08 22:55:11.000000000 -0700
30620 +++ 25/drivers/block/swim3.c    2003-10-05 00:34:01.000000000 -0700
30621 @@ -239,10 +239,9 @@ static int grab_drive(struct floppy_stat
30622                       int interruptible);
30623  static void release_drive(struct floppy_state *fs);
30624  static int fd_eject(struct floppy_state *fs);
30625 -static int floppy_ioctl(struct inode *inode, struct file *filp,
30626 +static int floppy_ioctl(struct block_device *bdev, struct file *filp,
30627                         unsigned int cmd, unsigned long param);
30628 -static int floppy_open(struct inode *inode, struct file *filp);
30629 -static int floppy_release(struct inode *inode, struct file *filp);
30630 +static int floppy_open(struct block_device *bdev, struct file *filp);
30631  static int floppy_check_change(struct gendisk *disk);
30632  static int floppy_revalidate(struct gendisk *disk);
30633  static int swim3_add_device(struct device_node *swims);
30634 @@ -811,10 +810,10 @@ static int fd_eject(struct floppy_state 
30635  static struct floppy_struct floppy_type =
30636         { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL };    /*  7 1.44MB 3.5"   */
30637  
30638 -static int floppy_ioctl(struct inode *inode, struct file *filp,
30639 +static int floppy_ioctl(struct block_device *bdev, struct file *filp,
30640                         unsigned int cmd, unsigned long param)
30641  {
30642 -       struct floppy_state *fs = inode->i_bdev->bd_disk->private_data;
30643 +       struct floppy_state *fs = bdev->bd_disk->private_data;
30644         int err;
30645                 
30646         if ((cmd & 0x80) && !capable(CAP_SYS_ADMIN))
30647 @@ -838,9 +837,9 @@ static int floppy_ioctl(struct inode *in
30648         return -ENOTTY;
30649  }
30650  
30651 -static int floppy_open(struct inode *inode, struct file *filp)
30652 +static int floppy_open(struct block_device *bdev, struct file *filp)
30653  {
30654 -       struct floppy_state *fs = inode->i_bdev->bd_disk->private_data;
30655 +       struct floppy_state *fs = bdev->bd_disk->private_data;
30656         volatile struct swim3 *sw = fs->swim3;
30657         int n, err = 0;
30658  
30659 @@ -876,7 +875,7 @@ static int floppy_open(struct inode *ino
30660  
30661         if (err == 0 && (filp->f_flags & O_NDELAY) == 0
30662             && (filp->f_mode & 3)) {
30663 -               check_disk_change(inode->i_bdev);
30664 +               check_disk_change(bdev);
30665                 if (fs->ejected)
30666                         err = -ENXIO;
30667         }
30668 @@ -904,9 +903,9 @@ static int floppy_open(struct inode *ino
30669         return 0;
30670  }
30671  
30672 -static int floppy_release(struct inode *inode, struct file *filp)
30673 +static int floppy_release(struct gendisk *disk)
30674  {
30675 -       struct floppy_state *fs = inode->i_bdev->bd_disk->private_data;
30676 +       struct floppy_state *fs = disk->private_data;
30677         volatile struct swim3 *sw = fs->swim3;
30678         if (fs->ref_count > 0 && --fs->ref_count == 0) {
30679                 swim3_action(fs, MOTOR_OFF);
30680 --- linux-2.6.0-test6/drivers/block/swim_iop.c  2003-08-08 22:55:11.000000000 -0700
30681 +++ 25/drivers/block/swim_iop.c 2003-10-05 00:34:01.000000000 -0700
30682 @@ -31,6 +31,7 @@
30683  #include <linux/delay.h>
30684  #include <linux/fd.h>
30685  #include <linux/ioctl.h>
30686 +#include <linux/blkdev.h>
30687  #include <asm/io.h>
30688  #include <asm/uaccess.h>
30689  #include <asm/mac_iop.h>
30690 @@ -97,10 +98,10 @@ static void swimiop_receive(struct iop_m
30691  static void swimiop_status_update(int, struct swim_drvstatus *);
30692  static int swimiop_eject(struct floppy_state *fs);
30693  
30694 -static int floppy_ioctl(struct inode *inode, struct file *filp,
30695 +static int floppy_ioctl(struct block_device *bdev, struct file *filp,
30696                         unsigned int cmd, unsigned long param);
30697 -static int floppy_open(struct inode *inode, struct file *filp);
30698 -static int floppy_release(struct inode *inode, struct file *filp);
30699 +static int floppy_open(struct block_device *bdev, struct file *filp);
30700 +static int floppy_release(struct gendisk *disk);
30701  static int floppy_check_change(struct gendisk *disk);
30702  static int floppy_revalidate(struct gendisk *disk);
30703  static int grab_drive(struct floppy_state *fs, enum swim_state state,
30704 @@ -347,10 +348,10 @@ static int swimiop_eject(struct floppy_s
30705  static struct floppy_struct floppy_type =
30706         { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL };    /*  7 1.44MB 3.5"   */
30707  
30708 -static int floppy_ioctl(struct inode *inode, struct file *filp,
30709 +static int floppy_ioctl(struct block_device *bdev, struct file *filp,
30710                         unsigned int cmd, unsigned long param)
30711  {
30712 -       struct floppy_state *fs = inode->i_bdev->bd_disk->private_data;
30713 +       struct floppy_state *fs = bdev->bd_disk->private_data;
30714         int err;
30715  
30716         if ((cmd & 0x80) && !capable(CAP_SYS_ADMIN))
30717 @@ -371,15 +372,15 @@ static int floppy_ioctl(struct inode *in
30718         return -ENOTTY;
30719  }
30720  
30721 -static int floppy_open(struct inode *inode, struct file *filp)
30722 +static int floppy_open(struct block_device *bdev, struct file *filp)
30723  {
30724 -       struct floppy_state *fs = inode->i_bdev->bd_disk->private_data;
30725 +       struct floppy_state *fs = bdev->bd_disk->private_data;
30726  
30727         if (fs->ref_count == -1 || filp->f_flags & O_EXCL)
30728                 return -EBUSY;
30729  
30730         if ((filp->f_flags & O_NDELAY) == 0 && (filp->f_mode & 3)) {
30731 -               check_disk_change(inode->i_bdev);
30732 +               check_disk_change(bdev);
30733                 if (fs->ejected)
30734                         return -ENXIO;
30735         }
30736 @@ -395,9 +396,9 @@ static int floppy_open(struct inode *ino
30737         return 0;
30738  }
30739  
30740 -static int floppy_release(struct inode *inode, struct file *filp)
30741 +static int floppy_release(struct gendisk *disk)
30742  {
30743 -       struct floppy_state *fs = inode->i_bdev->bd_disk->private_data;
30744 +       struct floppy_state *fs = disk->private_data;
30745         if (fs->ref_count > 0)
30746                 fs->ref_count--;
30747         return 0;
30748 --- linux-2.6.0-test6/drivers/block/umem.c      2003-09-27 18:57:44.000000000 -0700
30749 +++ 25/drivers/block/umem.c     2003-10-05 00:33:58.000000000 -0700
30750 @@ -153,7 +153,6 @@ struct cardinfo {
30751  };
30752  
30753  static struct cardinfo cards[MM_MAXCARDS];
30754 -static struct block_device_operations mm_fops;
30755  static struct timer_list battery_timer;
30756  
30757  static int num_cards = 0;
30758 @@ -818,10 +817,10 @@ static int mm_revalidate(struct gendisk 
30759  --                            mm_ioctl
30760  -----------------------------------------------------------------------------------
30761  */
30762 -static int mm_ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg)
30763 +static int mm_ioctl(struct block_device *bdev, struct file *f, unsigned int cmd, unsigned long arg)
30764  {
30765         if (cmd == HDIO_GETGEO) {
30766 -               struct cardinfo *card = i->i_bdev->bd_disk->private_data;
30767 +               struct cardinfo *card = bdev->bd_disk->private_data;
30768                 int size = card->mm_size * (1024 / MM_HARDSECT);
30769                 struct hd_geometry geo;
30770                 /*
30771 @@ -831,7 +830,7 @@ static int mm_ioctl(struct inode *i, str
30772                  */
30773                 geo.heads     = 64;
30774                 geo.sectors   = 32;
30775 -               geo.start     = get_start_sect(i->i_bdev);
30776 +               geo.start     = get_start_sect(bdev);
30777                 geo.cylinders = size / (geo.heads * geo.sectors);
30778  
30779                 if (copy_to_user((void *) arg, &geo, sizeof(geo)))
30780 --- linux-2.6.0-test6/drivers/block/xd.c        2003-09-27 18:57:44.000000000 -0700
30781 +++ 25/drivers/block/xd.c       2003-10-05 00:33:54.000000000 -0700
30782 @@ -322,9 +322,9 @@ static void do_xd_request (request_queue
30783  }
30784  
30785  /* xd_ioctl: handle device ioctl's */
30786 -static int xd_ioctl (struct inode *inode,struct file *file,u_int cmd,u_long arg)
30787 +static int xd_ioctl (struct block_device *bdev,struct file *file,u_int cmd,u_long arg)
30788  {
30789 -       XD_INFO *p = inode->i_bdev->bd_disk->private_data;
30790 +       XD_INFO *p = bdev->bd_disk->private_data;
30791  
30792         switch (cmd) {
30793                 case HDIO_GETGEO:
30794 @@ -334,7 +334,7 @@ static int xd_ioctl (struct inode *inode
30795                         g.heads = p->heads;
30796                         g.sectors = p->sectors;
30797                         g.cylinders = p->cylinders;
30798 -                       g.start = get_start_sect(inode->i_bdev);
30799 +                       g.start = get_start_sect(bdev);
30800                         return copy_to_user(geometry, &g, sizeof g) ? -EFAULT : 0;
30801                 }
30802                 case HDIO_SET_DMA:
30803 --- linux-2.6.0-test6/drivers/block/xd.h        2003-06-14 12:18:30.000000000 -0700
30804 +++ 25/drivers/block/xd.h       2003-10-05 00:33:54.000000000 -0700
30805 @@ -105,7 +105,7 @@ static u_char xd_detect (u_char *control
30806  static u_char xd_initdrives (void (*init_drive)(u_char drive));
30807  
30808  static void do_xd_request (request_queue_t * q);
30809 -static int xd_ioctl (struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg);
30810 +static int xd_ioctl (struct block_device *bdev,struct file *file,unsigned int cmd,unsigned long arg);
30811  static int xd_readwrite (u_char operation,XD_INFO *disk,char *buffer,u_int block,u_int count);
30812  static void xd_recalibrate (u_char drive);
30813  
30814 --- linux-2.6.0-test6/drivers/block/z2ram.c     2003-09-27 18:57:44.000000000 -0700
30815 +++ 25/drivers/block/z2ram.c    2003-10-05 00:34:01.000000000 -0700
30816 @@ -67,7 +67,6 @@ static int current_device   = -1;
30817  
30818  static spinlock_t z2ram_lock = SPIN_LOCK_UNLOCKED;
30819  
30820 -static struct block_device_operations z2_fops;
30821  static struct gendisk *z2ram_gendisk;
30822  
30823  static void do_z2_request(request_queue_t *q)
30824 @@ -141,7 +140,7 @@ get_chipram( void )
30825  }
30826  
30827  static int
30828 -z2_open( struct inode *inode, struct file *filp )
30829 +z2_open( struct block_device *bdev, struct file *filp )
30830  {
30831      int device;
30832      int max_z2_map = ( Z2RAM_SIZE / Z2RAM_CHUNKSIZE ) *
30833 @@ -150,7 +149,7 @@ z2_open( struct inode *inode, struct fil
30834         sizeof( z2ram_map[0] );
30835      int rc = -ENOMEM;
30836  
30837 -    device = iminor(inode);
30838 +    device = MINOR(bdev->bd_dev);
30839  
30840      if ( current_device != -1 && current_device != device )
30841      {
30842 @@ -301,8 +300,7 @@ err_out:
30843      return rc;
30844  }
30845  
30846 -static int
30847 -z2_release( struct inode *inode, struct file *filp )
30848 +static int z2_release(struct gendisk *disk)
30849  {
30850      if ( current_device == -1 )
30851         return 0;     
30852 --- linux-2.6.0-test6/drivers/cdrom/aztcd.c     2003-09-08 13:58:56.000000000 -0700
30853 +++ 25/drivers/cdrom/aztcd.c    2003-10-05 00:34:01.000000000 -0700
30854 @@ -330,10 +330,10 @@ static int aztGetToc(int multi);
30855  
30856  /* Kernel Interface Functions */
30857  static int check_aztcd_media_change(struct gendisk *disk);
30858 -static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
30859 +static int aztcd_ioctl(struct block_device *bdev, struct file *fp, unsigned int cmd,
30860                        unsigned long arg);
30861 -static int aztcd_open(struct inode *ip, struct file *fp);
30862 -static int aztcd_release(struct inode *inode, struct file *file);
30863 +static int aztcd_open(struct block_device *bdev, struct file *fp);
30864 +static int aztcd_release(struct gendisk *disk);
30865  
30866  static struct block_device_operations azt_fops = {
30867         .owner          = THIS_MODULE,
30868 @@ -1153,7 +1153,7 @@ static int check_aztcd_media_change(stru
30869  /*
30870   * Kernel IO-controls
30871  */
30872 -static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
30873 +static int aztcd_ioctl(struct block_device *bdev, struct file *fp, unsigned int cmd,
30874                        unsigned long arg)
30875  {
30876         int i;
30877 @@ -1171,8 +1171,6 @@ static int aztcd_ioctl(struct inode *ip,
30878                cmd, jiffies);
30879         printk("aztcd Status %x\n", getAztStatus());
30880  #endif
30881 -       if (!ip)
30882 -               RETURNM("aztcd_ioctl 1", -EINVAL);
30883         if (getAztStatus() < 0)
30884                 RETURNM("aztcd_ioctl 2", -EIO);
30885         if ((!aztTocUpToDate) || (aztDiskChanged)) {
30886 @@ -1624,7 +1622,7 @@ static void azt_invalidate_buffers(void)
30887  /*
30888   * Open the device special file.  Check that a disk is in.
30889   */
30890 -static int aztcd_open(struct inode *ip, struct file *fp)
30891 +static int aztcd_open(struct block_device *bdev, struct file *fp)
30892  {
30893         int st;
30894  
30895 @@ -1673,12 +1671,11 @@ static int aztcd_open(struct inode *ip, 
30896  /*
30897   * On close, we flush all azt blocks from the buffer cache.
30898   */
30899 -static int aztcd_release(struct inode *inode, struct file *file)
30900 +static int aztcd_release(struct gendisk *disk)
30901  {
30902  #ifdef AZT_DEBUG
30903         printk("aztcd: executing aztcd_release\n");
30904 -       printk("inode: %p, device: %s    file: %p\n", inode,
30905 -              inode->i_bdev->bd_disk->disk_name, file);
30906 +       printk("disk: %p, device: %s\n", disk, disk->disk_name);
30907  #endif
30908         if (!--azt_open_count) {
30909                 azt_invalidate_buffers();
30910 --- linux-2.6.0-test6/drivers/cdrom/cdrom.c     2003-09-27 18:57:44.000000000 -0700
30911 +++ 25/drivers/cdrom/cdrom.c    2003-10-05 00:33:59.000000000 -0700
30912 @@ -367,6 +367,7 @@ int register_cdrom(struct cdrom_device_i
30913         ENSURE(generic_packet, CDC_GENERIC_PACKET);
30914         cdi->mc_flags = 0;
30915         cdo->n_minors = 0;
30916 +       cdi->for_data = 0;
30917          cdi->options = CDO_USE_FFLAGS;
30918         
30919         if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
30920 @@ -416,7 +417,7 @@ int unregister_cdrom(struct cdrom_device
30921   * is in their own interest: device control becomes a lot easier
30922   * this way.
30923   */
30924 -int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp)
30925 +int cdrom_open(struct cdrom_device_info *cdi, struct block_device *bdev, struct file *fp)
30926  {
30927         int ret;
30928  
30929 @@ -437,7 +438,7 @@ int cdrom_open(struct cdrom_device_info 
30930         cdinfo(CD_OPEN, "Use count for \"/dev/%s\" now %d\n", cdi->name, cdi->use_count);
30931         /* Do this on open.  Don't wait for mount, because they might
30932             not be mounting, but opening with O_NONBLOCK */
30933 -       check_disk_change(ip->i_bdev);
30934 +       check_disk_change(bdev);
30935         return ret;
30936  }
30937  
30938 @@ -530,6 +531,7 @@ int open_for_data(struct cdrom_device_in
30939                         cdinfo(CD_OPEN, "door locked.\n");
30940         }
30941         cdinfo(CD_OPEN, "device opened successfully.\n"); 
30942 +       cdi->for_data = 1;
30943         return ret;
30944  
30945         /* Something failed.  Try to unlock the drive, because some drivers
30946 @@ -605,30 +607,29 @@ int check_for_audio_disc(struct cdrom_de
30947  
30948  
30949  /* Admittedly, the logic below could be performed in a nicer way. */
30950 -int cdrom_release(struct cdrom_device_info *cdi, struct file *fp)
30951 +int cdrom_release(struct cdrom_device_info *cdi)
30952  {
30953         struct cdrom_device_ops *cdo = cdi->ops;
30954 -       int opened_for_data;
30955  
30956         cdinfo(CD_CLOSE, "entering cdrom_release\n"); 
30957  
30958         if (cdi->use_count > 0)
30959                 cdi->use_count--;
30960 -       if (cdi->use_count == 0)
30961 -               cdinfo(CD_CLOSE, "Use count for \"/dev/%s\" now zero\n", cdi->name);
30962 -       if (cdi->use_count == 0 &&
30963 -           cdo->capability & CDC_LOCK && !keeplocked) {
30964 +       if (cdi->use_count) {
30965 +               cdo->release(cdi);
30966 +               return 0;
30967 +       }
30968 +               
30969 +       cdinfo(CD_CLOSE, "Use count for \"/dev/%s\" now zero\n", cdi->name);
30970 +       if (cdo->capability & CDC_LOCK && !keeplocked) {
30971                 cdinfo(CD_CLOSE, "Unlocking door!\n");
30972                 cdo->lock_door(cdi, 0);
30973         }
30974 -       opened_for_data = !(cdi->options & CDO_USE_FFLAGS) ||
30975 -               !(fp && fp->f_flags & O_NONBLOCK);
30976         cdo->release(cdi);
30977 -       if (cdi->use_count == 0) {      /* last process that closes dev*/
30978 -               if (opened_for_data &&
30979 -                   cdi->options & CDO_AUTO_EJECT && CDROM_CAN(CDC_OPEN_TRAY))
30980 -                       cdo->tray_move(cdi, 1);
30981 -       }
30982 +       if (cdi->for_data &&
30983 +           cdi->options & CDO_AUTO_EJECT && CDROM_CAN(CDC_OPEN_TRAY))
30984 +               cdo->tray_move(cdi, 1);
30985 +       cdi->for_data = 0;
30986         return 0;
30987  }
30988  
30989 @@ -1433,14 +1434,14 @@ static int cdrom_read_block(struct cdrom
30990   * these days. ATAPI / SCSI specific code now mainly resides in
30991   * mmc_ioct().
30992   */
30993 -int cdrom_ioctl(struct cdrom_device_info *cdi, struct inode *ip,
30994 +int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev,
30995                 unsigned int cmd, unsigned long arg)
30996  {
30997         struct cdrom_device_ops *cdo = cdi->ops;
30998         int ret;
30999  
31000         /* Try the generic SCSI command ioctl's first.. */
31001 -       ret = scsi_cmd_ioctl(ip->i_bdev, cmd, arg);
31002 +       ret = scsi_cmd_ioctl(bdev, cmd, arg);
31003         if (ret != -ENOTTY)
31004                 return ret;
31005  
31006 @@ -1593,7 +1594,7 @@ int cdrom_ioctl(struct cdrom_device_info
31007                 cdinfo(CD_DO_IOCTL, "entering CDROM_RESET\n");
31008                 if (!CDROM_CAN(CDC_RESET))
31009                         return -ENOSYS;
31010 -               invalidate_bdev(ip->i_bdev, 0);
31011 +               invalidate_bdev(bdev, 0);
31012                 return cdo->reset(cdi);
31013                 }
31014  
31015 @@ -1856,57 +1857,6 @@ static int cdrom_switch_blocksize(struct
31016         return cdo->generic_packet(cdi, &cgc);
31017  }
31018  
31019 -static int cdrom_do_cmd(struct cdrom_device_info *cdi,
31020 -                       struct cdrom_generic_command *cgc)
31021 -{
31022 -       struct request_sense *usense, sense;
31023 -       unsigned char *ubuf;
31024 -       int ret;
31025 -
31026 -       if (cgc->data_direction == CGC_DATA_UNKNOWN)
31027 -               return -EINVAL;
31028 -
31029 -       if (cgc->buflen < 0 || cgc->buflen >= 131072)
31030 -               return -EINVAL;
31031 -
31032 -       usense = cgc->sense;
31033 -       cgc->sense = &sense;
31034 -       if (usense && !access_ok(VERIFY_WRITE, usense, sizeof(*usense))) {
31035 -               return -EFAULT;
31036 -       }
31037 -
31038 -       ubuf = cgc->buffer;
31039 -       if (cgc->data_direction == CGC_DATA_READ ||
31040 -           cgc->data_direction == CGC_DATA_WRITE) {
31041 -               cgc->buffer = kmalloc(cgc->buflen, GFP_KERNEL);
31042 -               if (cgc->buffer == NULL)
31043 -                       return -ENOMEM;
31044 -       }
31045 -
31046 -
31047 -       if (cgc->data_direction == CGC_DATA_READ) {
31048 -               if (!access_ok(VERIFY_READ, ubuf, cgc->buflen)) {
31049 -                       kfree(cgc->buffer);
31050 -                       return -EFAULT;
31051 -               }
31052 -       } else if (cgc->data_direction == CGC_DATA_WRITE) {
31053 -               if (copy_from_user(cgc->buffer, ubuf, cgc->buflen)) {
31054 -                       kfree(cgc->buffer);
31055 -                       return -EFAULT;
31056 -               }
31057 -       }
31058 -
31059 -       ret = cdi->ops->generic_packet(cdi, cgc);
31060 -       __copy_to_user(usense, cgc->sense, sizeof(*usense));
31061 -       if (!ret && cgc->data_direction == CGC_DATA_READ)
31062 -               __copy_to_user(ubuf, cgc->buffer, cgc->buflen);
31063 -       if (cgc->data_direction == CGC_DATA_READ ||
31064 -           cgc->data_direction == CGC_DATA_WRITE) {
31065 -               kfree(cgc->buffer);
31066 -       }
31067 -       return ret;
31068 -}
31069 -
31070  static int mmc_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
31071                      unsigned long arg)
31072  {              
31073 @@ -2176,14 +2126,6 @@ static int mmc_ioctl(struct cdrom_device
31074                 return 0;
31075                 }
31076  
31077 -       case CDROM_SEND_PACKET: {
31078 -               if (!CDROM_CAN(CDC_GENERIC_PACKET))
31079 -                       return -ENOSYS;
31080 -               cdinfo(CD_DO_IOCTL, "entering CDROM_SEND_PACKET\n"); 
31081 -               IOCTL_IN(arg, struct cdrom_generic_command, cgc);
31082 -               cgc.timeout = clock_t_to_jiffies(cgc.timeout);
31083 -               return cdrom_do_cmd(cdi, &cgc);
31084 -               }
31085         case CDROM_NEXT_WRITABLE: {
31086                 long next = 0;
31087                 cdinfo(CD_DO_IOCTL, "entering CDROM_NEXT_WRITABLE\n"); 
31088 --- linux-2.6.0-test6/drivers/cdrom/cdu31a.c    2003-09-08 13:58:56.000000000 -0700
31089 +++ 25/drivers/cdrom/cdu31a.c   2003-10-05 00:34:01.000000000 -0700
31090 @@ -3167,20 +3167,20 @@ static struct cdrom_device_info scd_info
31091         .name           = "cdu31a"
31092  };
31093  
31094 -static int scd_block_open(struct inode *inode, struct file *file)
31095 +static int scd_block_open(struct block_device *bdev, struct file *file)
31096  {
31097 -       return cdrom_open(&scd_info, inode, file);
31098 +       return cdrom_open(&scd_info, bdev, file);
31099  }
31100  
31101 -static int scd_block_release(struct inode *inode, struct file *file)
31102 +static int scd_block_release(struct gendisk *disk)
31103  {
31104 -       return cdrom_release(&scd_info, file);
31105 +       return cdrom_release(&scd_info);
31106  }
31107  
31108 -static int scd_block_ioctl(struct inode *inode, struct file *file,
31109 +static int scd_block_ioctl(struct block_device *bdev, struct file *file,
31110                                 unsigned cmd, unsigned long arg)
31111  {
31112 -       return cdrom_ioctl(&scd_info, inode, cmd, arg);
31113 +       return cdrom_ioctl(&scd_info, bdev, cmd, arg);
31114  }
31115  
31116  static int scd_block_media_changed(struct gendisk *disk)
31117 --- linux-2.6.0-test6/drivers/cdrom/cm206.c     2003-09-08 13:58:56.000000000 -0700
31118 +++ 25/drivers/cdrom/cm206.c    2003-10-05 00:34:01.000000000 -0700
31119 @@ -1350,20 +1350,20 @@ static struct cdrom_device_info cm206_in
31120         .name           = "cm206",
31121  };
31122  
31123 -static int cm206_block_open(struct inode *inode, struct file *file)
31124 +static int cm206_block_open(struct block_device *bdev, struct file *file)
31125  {
31126 -       return cdrom_open(&cm206_info, inode, file);
31127 +       return cdrom_open(&cm206_info, bdev, file);
31128  }
31129  
31130 -static int cm206_block_release(struct inode *inode, struct file *file)
31131 +static int cm206_block_release(struct gendisk *disk)
31132  {
31133 -       return cdrom_release(&cm206_info, file);
31134 +       return cdrom_release(&cm206_info);
31135  }
31136  
31137 -static int cm206_block_ioctl(struct inode *inode, struct file *file,
31138 +static int cm206_block_ioctl(struct block_device *bdev, struct file *file,
31139                                 unsigned cmd, unsigned long arg)
31140  {
31141 -       return cdrom_ioctl(&cm206_info, inode, cmd, arg);
31142 +       return cdrom_ioctl(&cm206_info, bdev, cmd, arg);
31143  }
31144  
31145  static int cm206_block_media_changed(struct gendisk *disk)
31146 --- linux-2.6.0-test6/drivers/cdrom/gscd.c      2003-09-27 18:57:44.000000000 -0700
31147 +++ 25/drivers/cdrom/gscd.c     2003-10-05 00:34:01.000000000 -0700
31148 @@ -91,10 +91,10 @@ static void gscd_bin2bcd(unsigned char *
31149  /* Schnittstellen zum Kern/FS */
31150  
31151  static void __do_gscd_request(unsigned long dummy);
31152 -static int gscd_ioctl(struct inode *, struct file *, unsigned int,
31153 +static int gscd_ioctl(struct block_device *, struct file *, unsigned int,
31154                       unsigned long);
31155 -static int gscd_open(struct inode *, struct file *);
31156 -static int gscd_release(struct inode *, struct file *);
31157 +static int gscd_open(struct block_device *, struct file *);
31158 +static int gscd_release(struct gendisk *disk);
31159  static int check_gscd_med_chg(struct gendisk *disk);
31160  
31161  /*      GoldStar Funktionen    */
31162 @@ -190,8 +190,8 @@ __setup("gscd=", gscd_setup);
31163  
31164  #endif
31165  
31166 -static int gscd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
31167 -                     unsigned long arg)
31168 +static int gscd_ioctl(struct block_device *bdev, struct file *fp,
31169 +                       unsigned int cmd, unsigned long arg)
31170  {
31171         unsigned char to_do[10];
31172         unsigned char dummy;
31173 @@ -338,7 +338,7 @@ static void gscd_read_cmd(struct request
31174   * Open the device special file.  Check that a disk is in.
31175   */
31176  
31177 -static int gscd_open(struct inode *ip, struct file *fp)
31178 +static int gscd_open(struct block_device *bdev, struct file *fp)
31179  {
31180         int st;
31181  
31182 @@ -368,7 +368,7 @@ static int gscd_open(struct inode *ip, s
31183   * On close, we flush all gscd blocks from the buffer cache.
31184   */
31185  
31186 -static int gscd_release(struct inode *inode, struct file *file)
31187 +static int gscd_release(struct gendisk *disk)
31188  {
31189  
31190  #ifdef GSCD_DEBUG
31191 --- linux-2.6.0-test6/drivers/cdrom/mcd.c       2003-09-08 13:58:56.000000000 -0700
31192 +++ 25/drivers/cdrom/mcd.c      2003-10-05 00:34:01.000000000 -0700
31193 @@ -214,20 +214,20 @@ static struct cdrom_device_info mcd_info
31194         .name           = "mcd",
31195  };
31196  
31197 -static int mcd_block_open(struct inode *inode, struct file *file)
31198 +static int mcd_block_open(struct block_device *bdev, struct file *file)
31199  {
31200 -       return cdrom_open(&mcd_info, inode, file);
31201 +       return cdrom_open(&mcd_info, bdev, file);
31202  }
31203  
31204 -static int mcd_block_release(struct inode *inode, struct file *file)
31205 +static int mcd_block_release(struct gendisk *disk)
31206  {
31207 -       return cdrom_release(&mcd_info, file);
31208 +       return cdrom_release(&mcd_info);
31209  }
31210  
31211 -static int mcd_block_ioctl(struct inode *inode, struct file *file,
31212 +static int mcd_block_ioctl(struct block_device *bdev, struct file *file,
31213                                 unsigned cmd, unsigned long arg)
31214  {
31215 -       return cdrom_ioctl(&mcd_info, inode, cmd, arg);
31216 +       return cdrom_ioctl(&mcd_info, bdev, cmd, arg);
31217  }
31218  
31219  static int mcd_block_media_changed(struct gendisk *disk)
31220 --- linux-2.6.0-test6/drivers/cdrom/mcdx.c      2003-09-08 13:58:56.000000000 -0700
31221 +++ 25/drivers/cdrom/mcdx.c     2003-10-05 00:34:01.000000000 -0700
31222 @@ -221,23 +221,23 @@ struct s_drive_stuff {
31223  int mcdx_init(void);
31224  void do_mcdx_request(request_queue_t * q);
31225  
31226 -static int mcdx_block_open(struct inode *inode, struct file *file)
31227 +static int mcdx_block_open(struct block_device *bdev, struct file *file)
31228  {
31229 -       struct s_drive_stuff *p = inode->i_bdev->bd_disk->private_data;
31230 -       return cdrom_open(&p->info, inode, file);
31231 +       struct s_drive_stuff *p = bdev->bd_disk->private_data;
31232 +       return cdrom_open(&p->info, bdev, file);
31233  }
31234  
31235 -static int mcdx_block_release(struct inode *inode, struct file *file)
31236 +static int mcdx_block_release(struct gendisk *disk)
31237  {
31238 -       struct s_drive_stuff *p = inode->i_bdev->bd_disk->private_data;
31239 -       return cdrom_release(&p->info, file);
31240 +       struct s_drive_stuff *p = disk->private_data;
31241 +       return cdrom_release(&p->info);
31242  }
31243  
31244 -static int mcdx_block_ioctl(struct inode *inode, struct file *file,
31245 +static int mcdx_block_ioctl(struct block_device *bdev, struct file *file,
31246                                 unsigned cmd, unsigned long arg)
31247  {
31248 -       struct s_drive_stuff *p = inode->i_bdev->bd_disk->private_data;
31249 -       return cdrom_ioctl(&p->info, inode, cmd, arg);
31250 +       struct s_drive_stuff *p = bdev->bd_disk->private_data;
31251 +       return cdrom_ioctl(&p->info, bdev, cmd, arg);
31252  }
31253  
31254  static int mcdx_block_media_changed(struct gendisk *disk)
31255 --- linux-2.6.0-test6/drivers/cdrom/optcd.c     2003-09-08 13:58:56.000000000 -0700
31256 +++ 25/drivers/cdrom/optcd.c    2003-10-05 00:34:01.000000000 -0700
31257 @@ -1713,16 +1713,13 @@ static int cdromreset(void)
31258  /* VFS calls */
31259  
31260  
31261 -static int opt_ioctl(struct inode *ip, struct file *fp,
31262 +static int opt_ioctl(struct block_device *bdev, struct file *fp,
31263                       unsigned int cmd, unsigned long arg)
31264  {
31265         int status, err, retval = 0;
31266  
31267         DEBUG((DEBUG_VFS, "starting opt_ioctl"));
31268  
31269 -       if (!ip)
31270 -               return -EINVAL;
31271 -
31272         if (cmd == CDROMRESET)
31273                 return cdromreset();
31274  
31275 @@ -1844,7 +1841,7 @@ static int opt_ioctl(struct inode *ip, s
31276  static int open_count = 0;
31277  
31278  /* Open device special file; check that a disk is in. */
31279 -static int opt_open(struct inode *ip, struct file *fp)
31280 +static int opt_open(struct block_device *bdev, struct file *fp)
31281  {
31282         DEBUG((DEBUG_VFS, "starting opt_open"));
31283  
31284 @@ -1904,13 +1901,12 @@ err_out:
31285  
31286  
31287  /* Release device special file; flush all blocks from the buffer cache */
31288 -static int opt_release(struct inode *ip, struct file *fp)
31289 +static int opt_release(struct gendisk *disk)
31290  {
31291         int status;
31292  
31293         DEBUG((DEBUG_VFS, "executing opt_release"));
31294 -       DEBUG((DEBUG_VFS, "inode: %p, device: %s, file: %p\n",
31295 -               ip, ip->i_bdev->bd_disk->disk_name, fp));
31296 +       DEBUG((DEBUG_VFS, "disk: %p, device: %s\n", disk, disk->disk_name));
31297  
31298         if (!--open_count) {
31299                 toc_uptodate = 0;
31300 --- linux-2.6.0-test6/drivers/cdrom/sbpcd.c     2003-09-08 13:58:56.000000000 -0700
31301 +++ 25/drivers/cdrom/sbpcd.c    2003-10-05 00:34:01.000000000 -0700
31302 @@ -363,7 +363,6 @@
31303  
31304  #include <linux/module.h>
31305  
31306 -#include <linux/version.h>
31307  #include <linux/errno.h>
31308  #include <linux/sched.h>
31309  #include <linux/mm.h>
31310 @@ -5357,23 +5356,23 @@ static int sbp_data(struct request *req)
31311  }
31312  /*==========================================================================*/
31313  
31314 -static int sbpcd_block_open(struct inode *inode, struct file *file)
31315 +static int sbpcd_block_open(struct block_device *bdev, struct file *file)
31316  {
31317 -       struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data;
31318 -       return cdrom_open(p->sbpcd_infop, inode, file);
31319 +       struct sbpcd_drive *p = bdev->bd_disk->private_data;
31320 +       return cdrom_open(p->sbpcd_infop, bdev, file);
31321  }
31322  
31323 -static int sbpcd_block_release(struct inode *inode, struct file *file)
31324 +static int sbpcd_block_release(struct gendisk *disk)
31325  {
31326 -       struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data;
31327 -       return cdrom_release(p->sbpcd_infop, file);
31328 +       struct sbpcd_drive *p = disk->private_data;
31329 +       return cdrom_release(p->sbpcd_infop);
31330  }
31331  
31332 -static int sbpcd_block_ioctl(struct inode *inode, struct file *file,
31333 +static int sbpcd_block_ioctl(struct block_device *bdev, struct file *file,
31334                                 unsigned cmd, unsigned long arg)
31335  {
31336 -       struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data;
31337 -       return cdrom_ioctl(p->sbpcd_infop, inode, cmd, arg);
31338 +       struct sbpcd_drive *p = bdev->bd_disk->private_data;
31339 +       return cdrom_ioctl(p->sbpcd_infop, bdev, cmd, arg);
31340  }
31341  
31342  static int sbpcd_block_media_changed(struct gendisk *disk)
31343 --- linux-2.6.0-test6/drivers/cdrom/sjcd.c      2003-09-08 13:58:56.000000000 -0700
31344 +++ 25/drivers/cdrom/sjcd.c     2003-10-05 00:34:01.000000000 -0700
31345 @@ -713,16 +713,13 @@ static int sjcd_tray_open(void)
31346  /*
31347   * Do some user commands.
31348   */
31349 -static int sjcd_ioctl(struct inode *ip, struct file *fp,
31350 +static int sjcd_ioctl(struct block_device *bdev, struct file *fp,
31351                       unsigned int cmd, unsigned long arg)
31352  {
31353  #if defined( SJCD_TRACE )
31354         printk("SJCD:ioctl\n");
31355  #endif
31356  
31357 -       if (ip == NULL)
31358 -               return (-EINVAL);
31359 -
31360         sjcd_get_status();
31361         if (!sjcd_status_valid)
31362                 return (-EIO);
31363 @@ -1522,7 +1519,7 @@ static void do_sjcd_request(request_queu
31364  /*
31365   * Open the device special file. Check disk is in.
31366   */
31367 -static int sjcd_open(struct inode *ip, struct file *fp)
31368 +static int sjcd_open(struct block_device *bdev, struct file *fp)
31369  {
31370         /*
31371          * Check the presence of device.
31372 @@ -1607,7 +1604,7 @@ static int sjcd_open(struct inode *ip, s
31373  /*
31374   * On close, we flush all sjcd blocks from the buffer cache.
31375   */
31376 -static int sjcd_release(struct inode *inode, struct file *file)
31377 +static int sjcd_release(struct gendisk *disk)
31378  {
31379         int s;
31380  
31381 --- linux-2.6.0-test6/drivers/cdrom/sonycd535.c 2003-09-27 18:57:44.000000000 -0700
31382 +++ 25/drivers/cdrom/sonycd535.c        2003-10-05 00:34:01.000000000 -0700
31383 @@ -201,7 +201,7 @@
31384  
31385  static int read_subcode(void);
31386  static void sony_get_toc(void);
31387 -static int cdu_open(struct inode *inode, struct file *filp);
31388 +static int cdu_open(struct block_device *bdev, struct file *filp);
31389  static inline unsigned int int_to_bcd(unsigned int val);
31390  static unsigned int bcd_to_int(unsigned int bcd);
31391  static int do_sony_cmd(Byte * cmd, int nCmd, Byte status[2],
31392 @@ -1061,7 +1061,7 @@ sony_get_subchnl_info(long arg)
31393   * The big ugly ioctl handler.
31394   */
31395  static int
31396 -cdu_ioctl(struct inode *inode,
31397 +cdu_ioctl(struct block_device *bdev,
31398                   struct file *file,
31399                   unsigned int cmd,
31400                   unsigned long arg)
31401 @@ -1363,9 +1363,7 @@ cdu_ioctl(struct inode *inode,
31402   * Open the drive for operations.  Spin the drive up and read the table of
31403   * contents if these have not already been done.
31404   */
31405 -static int
31406 -cdu_open(struct inode *inode,
31407 -                struct file *filp)
31408 +static int cdu_open(struct block_device *bdev, struct file *filp)
31409  {
31410         Byte status[2], cmd_buff[2];
31411  
31412 @@ -1388,7 +1386,7 @@ cdu_open(struct inode *inode,
31413                 sony_inuse = 0;
31414                 return -EIO;
31415         }
31416 -       check_disk_change(inode->i_bdev);
31417 +       check_disk_change(bdev);
31418         sony_usage++;
31419  
31420  #ifdef LOCK_DOORS
31421 @@ -1405,9 +1403,7 @@ cdu_open(struct inode *inode,
31422   * Close the drive.  Spin it down if no task is using it.  The spin
31423   * down will fail if playing audio, so audio play is OK.
31424   */
31425 -static int
31426 -cdu_release(struct inode *inode,
31427 -                       struct file *filp)
31428 +static int cdu_release(struct gendisk *disk)
31429  {
31430         Byte status[2], cmd_no;
31431  
31432 --- linux-2.6.0-test6/drivers/char/agp/amd64-agp.c      2003-09-27 18:57:44.000000000 -0700
31433 +++ 25/drivers/char/agp/amd64-agp.c     2003-10-05 00:33:24.000000000 -0700
31434 @@ -91,9 +91,9 @@ static int amd64_insert_memory(struct ag
31435         for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
31436                 tmp = agp_bridge->driver->mask_memory(mem->memory[i], mem->type);
31437  
31438 -               BUG_ON(tmp & 0xffffff0000000ffc);
31439 -               pte = (tmp & 0x000000ff00000000) >> 28;
31440 -               pte |=(tmp & 0x00000000fffff000);
31441 +               BUG_ON(tmp & 0xffffff0000000ffcULL);
31442 +               pte = (tmp & 0x000000ff00000000ULL) >> 28;
31443 +               pte |=(tmp & 0x00000000fffff000ULL);
31444                 pte |= GPTE_VALID | GPTE_COHERENT;
31445  
31446                 agp_bridge->gatt_table[j] = pte;
31447 --- linux-2.6.0-test6/drivers/char/agp/via-agp.c        2003-09-27 18:57:44.000000000 -0700
31448 +++ 25/drivers/char/agp/via-agp.c       2003-10-05 00:33:24.000000000 -0700
31449 @@ -251,6 +251,11 @@ static struct agp_device_ids via_agp_dev
31450                 .chipset_name   = "Pro 266",
31451         },
31452  
31453 +       {
31454 +               .device_id      = PCI_DEVICE_ID_VIA_XN266,
31455 +               .chipset_name   = "Apollo Pro266",
31456 +       },
31457 +
31458         /* VT8361 */
31459         {
31460                 .device_id      = PCI_DEVICE_ID_VIA_8361,
31461 --- linux-2.6.0-test6/drivers/char/amiserial.c  2003-07-27 12:14:38.000000000 -0700
31462 +++ 25/drivers/char/amiserial.c 2003-10-05 00:33:24.000000000 -0700
31463 @@ -32,7 +32,6 @@
31464   */
31465  
31466  #include <linux/config.h>
31467 -#include <linux/version.h>
31468  
31469  #undef SERIAL_PARANOIA_CHECK
31470  #define SERIAL_DO_RESTART
31471 --- linux-2.6.0-test6/drivers/char/cyclades.c   2003-09-27 18:57:44.000000000 -0700
31472 +++ 25/drivers/char/cyclades.c  2003-10-05 00:33:24.000000000 -0700
31473 @@ -670,7 +670,6 @@ static char rcsid[] =
31474  #include <linux/types.h>
31475  #include <linux/kernel.h>
31476  #include <linux/pci.h>
31477 -#include <linux/version.h>
31478  
31479  #include <linux/stat.h>
31480  #include <linux/proc_fs.h>
31481 --- linux-2.6.0-test6/drivers/char/dsp56k.c     2003-09-08 13:58:57.000000000 -0700
31482 +++ 25/drivers/char/dsp56k.c    2003-10-05 00:33:24.000000000 -0700
31483 @@ -24,7 +24,6 @@
31484   */
31485  
31486  #include <linux/module.h>
31487 -#include <linux/version.h>
31488  #include <linux/slab.h>        /* for kmalloc() and kfree() */
31489  #include <linux/sched.h>       /* for struct wait_queue etc */
31490  #include <linux/major.h>
31491 --- linux-2.6.0-test6/drivers/char/dtlk.c       2003-09-08 13:58:57.000000000 -0700
31492 +++ 25/drivers/char/dtlk.c      2003-10-05 00:33:24.000000000 -0700
31493 @@ -48,7 +48,6 @@
31494   */
31495  
31496  #include <linux/module.h>
31497 -#include <linux/version.h>
31498  
31499  #define KERNEL
31500  #include <linux/types.h>
31501 --- linux-2.6.0-test6/drivers/char/dz.c 2003-06-14 12:17:57.000000000 -0700
31502 +++ 25/drivers/char/dz.c        2003-10-05 00:33:24.000000000 -0700
31503 @@ -23,7 +23,6 @@ Qua Jun 27 15:02:26 BRT 2001
31504  
31505  /* #define DEBUG_DZ 1 */
31506  
31507 -#include <linux/version.h>
31508  #include <linux/module.h>
31509  
31510  #include <linux/config.h>
31511 --- linux-2.6.0-test6/drivers/char/ftape/compressor/zftape-compress.c   2003-06-14 12:18:32.000000000 -0700
31512 +++ 25/drivers/char/ftape/compressor/zftape-compress.c  2003-10-05 00:33:24.000000000 -0700
31513 @@ -31,6 +31,7 @@
31514   char zftc_rev[] = "$Revision: 1.5 $";
31515   char zftc_dat[] = "$Date: 2004/02/23 23:37:02 $";
31516  
31517 +#include <linux/version.h>
31518  #include <linux/errno.h>
31519  #include <linux/mm.h>
31520  #include <linux/module.h>
31521 --- linux-2.6.0-test6/drivers/char/ftape/lowlevel/fdc-io.c      2003-09-08 13:58:57.000000000 -0700
31522 +++ 25/drivers/char/ftape/lowlevel/fdc-io.c     2003-10-05 00:33:24.000000000 -0700
31523 @@ -30,7 +30,6 @@
31524  #include <linux/errno.h>
31525  #include <linux/sched.h>
31526  #include <linux/ioport.h>
31527 -#include <linux/version.h>
31528  #include <linux/interrupt.h>
31529  #include <asm/system.h>
31530  #include <asm/io.h>
31531 --- linux-2.6.0-test6/drivers/char/generic_serial.c     2003-09-08 13:58:57.000000000 -0700
31532 +++ 25/drivers/char/generic_serial.c    2003-10-05 00:33:24.000000000 -0700
31533 @@ -348,7 +348,7 @@ int gs_real_chars_in_buffer(struct tty_s
31534  static int gs_wait_tx_flushed (void * ptr, int timeout) 
31535  {
31536         struct gs_port *port = ptr;
31537 -       long end_jiffies;
31538 +       unsigned long end_jiffies;
31539         int jiffies_to_transmit, charsleft = 0, rv = 0;
31540         int rcib;
31541  
31542 --- linux-2.6.0-test6/drivers/char/i8k.c        2003-06-14 12:18:01.000000000 -0700
31543 +++ 25/drivers/char/i8k.c       2003-10-05 00:33:24.000000000 -0700
31544 @@ -17,7 +17,6 @@
31545   */
31546  
31547  #include <linux/module.h>
31548 -#include <linux/version.h>
31549  #include <linux/types.h>
31550  #include <linux/init.h>
31551  #include <linux/proc_fs.h>
31552 --- linux-2.6.0-test6/drivers/char/ip2/i2os.h   2003-07-27 12:14:38.000000000 -0700
31553 +++ 25/drivers/char/ip2/i2os.h  2003-10-05 00:33:24.000000000 -0700
31554 @@ -25,7 +25,6 @@
31555  
31556  #include "ip2types.h"
31557  #include <asm/io.h>  /* For inb, etc */
31558 -#include <linux/version.h>
31559  
31560  //------------------------------------
31561  // Defines for I/O instructions:
31562 --- linux-2.6.0-test6/drivers/char/ip2main.c    2003-09-08 13:58:57.000000000 -0700
31563 +++ 25/drivers/char/ip2main.c   2003-10-05 00:33:24.000000000 -0700
31564 @@ -84,8 +84,6 @@
31565  /************/
31566  #include <linux/config.h>
31567  
31568 -#include <linux/version.h>
31569 -
31570  #include <linux/ctype.h>
31571  #include <linux/string.h>
31572  #include <linux/fcntl.h>
31573 --- linux-2.6.0-test6/drivers/char/isicom.c     2003-08-22 19:23:40.000000000 -0700
31574 +++ 25/drivers/char/isicom.c    2003-10-05 00:33:24.000000000 -0700
31575 @@ -38,7 +38,6 @@
31576   */
31577  
31578  #include <linux/module.h>
31579 -#include <linux/version.h>
31580  #include <linux/kernel.h>
31581  #include <linux/tty.h>
31582  #include <linux/termios.h>
31583 --- linux-2.6.0-test6/drivers/char/istallion.c  2003-09-27 18:57:44.000000000 -0700
31584 +++ 25/drivers/char/istallion.c 2003-10-05 00:33:24.000000000 -0700
31585 @@ -35,7 +35,6 @@
31586  #include <linux/serial.h>
31587  #include <linux/cdk.h>
31588  #include <linux/comstats.h>
31589 -#include <linux/version.h>
31590  #include <linux/istallion.h>
31591  #include <linux/ioport.h>
31592  #include <linux/delay.h>
31593 --- linux-2.6.0-test6/drivers/char/Kconfig      2003-09-27 18:57:44.000000000 -0700
31594 +++ 25/drivers/char/Kconfig     2003-10-05 00:33:24.000000000 -0700
31595 @@ -954,6 +954,15 @@ config RAW_DRIVER
31596           Once bound, I/O against /dev/raw/rawN uses efficient zero-copy I/O. 
31597           See the raw(8) manpage for more details.
31598  
31599 +config MAX_RAW_DEVS
31600 +       int "Maximum number of RAW devices to support (1-8192)"
31601 +       depends on RAW_DRIVER
31602 +       default "256"
31603 +       help
31604 +         The maximum number of RAW devices that are supported.
31605 +         Default is 256. Increase this number in case you need lots of
31606 +         raw devices.
31607 +
31608  config HANGCHECK_TIMER
31609         tristate "Hangcheck timer"
31610         depends on X86_64 || X86
31611 --- linux-2.6.0-test6/drivers/char/keyboard.c   2003-09-27 18:57:44.000000000 -0700
31612 +++ 25/drivers/char/keyboard.c  2003-10-05 00:33:38.000000000 -0700
31613 @@ -1052,6 +1052,9 @@ void kbd_keycode(unsigned int keycode, i
31614         }
31615         if (sysrq_down && down && !rep) {
31616                 handle_sysrq(kbd_sysrq_xlate[keycode], regs, tty);
31617 +#ifdef CONFIG_KGDB_SYSRQ
31618 +                sysrq_down = 0;        /* in case we miss the "up" event */
31619 +#endif
31620                 return;
31621         }
31622  #endif
31623 --- linux-2.6.0-test6/drivers/char/lp_old98.c   2003-09-08 13:58:57.000000000 -0700
31624 +++ 25/drivers/char/lp_old98.c  2003-10-05 00:33:24.000000000 -0700
31625 @@ -23,7 +23,6 @@
31626  #include <linux/fcntl.h>
31627  #include <linux/delay.h>
31628  #include <linux/console.h>
31629 -#include <linux/version.h>
31630  #include <linux/fs.h>
31631  
31632  #include <asm/io.h>
31633 --- linux-2.6.0-test6/drivers/char/mem.c        2003-09-27 18:57:44.000000000 -0700
31634 +++ 25/drivers/char/mem.c       2003-10-05 00:36:19.000000000 -0700
31635 @@ -40,6 +40,7 @@ extern void fbmem_init(void);
31636  extern void tapechar_init(void);
31637  #endif
31638  
31639 +#ifdef pgprot_noncached
31640  /*
31641   * Architectures vary in how they handle caching for addresses
31642   * outside of main memory.
31643 @@ -65,19 +66,21 @@ static inline int uncached_access(struct
31644           && addr >= __pa(high_memory);
31645  #elif defined(CONFIG_IA64)
31646         /*
31647 -        * On ia64, we ignore O_SYNC because we cannot tolerate memory attribute aliases.
31648 +        * On ia64, we ignore O_SYNC because we cannot tolerate memory
31649 +        * attribute aliases.
31650          */
31651         return !(efi_mem_attributes(addr) & EFI_MEMORY_WB);
31652  #else
31653         /*
31654 -        * Accessing memory above the top the kernel knows about or through a file pointer
31655 -        * that was marked O_SYNC will be done non-cached.
31656 +        * Accessing memory above the top the kernel knows about or through a
31657 +        * file pointer that was marked O_SYNC will be done non-cached.
31658          */
31659         if (file->f_flags & O_SYNC)
31660                 return 1;
31661         return addr >= __pa(high_memory);
31662  #endif
31663  }
31664 +#endif         /* pgprot_noncached */
31665  
31666  static ssize_t do_write_mem(struct file * file, void *p, unsigned long realp,
31667                             const char * buf, size_t count, loff_t *ppos)
31668 @@ -159,28 +162,24 @@ static ssize_t write_mem(struct file * f
31669         return do_write_mem(file, __va(p), p, buf, count, ppos);
31670  }
31671  
31672 -static int mmap_mem(struct file * file, struct vm_area_struct * vma)
31673 +static int mmap_mem(struct file *file, struct vm_area_struct *vma)
31674  {
31675         unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
31676 -       int uncached;
31677  
31678 -       uncached = uncached_access(file, offset);
31679  #ifdef pgprot_noncached
31680 -       if (uncached)
31681 +       if (uncached_access(file, offset))
31682                 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
31683  #endif
31684  
31685 -       /* Don't try to swap out physical pages.. */
31686 -       vma->vm_flags |= VM_RESERVED;
31687 -
31688         /*
31689 -        * Don't dump addresses that are not real memory to a core file.
31690 +        * Don't try to swap out physical pages..
31691 +        * And treat /dev/mem mappings as "IO" regions: they may not
31692 +        * describe valid pageframes.
31693          */
31694 -       if (uncached)
31695 -               vma->vm_flags |= VM_IO;
31696 +       vma->vm_flags |= VM_RESERVED|VM_IO;
31697  
31698 -       if (remap_page_range(vma, vma->vm_start, offset, vma->vm_end-vma->vm_start,
31699 -                            vma->vm_page_prot))
31700 +       if (remap_page_range(vma, vma->vm_start, offset,
31701 +                       vma->vm_end-vma->vm_start, vma->vm_page_prot))
31702                 return -EAGAIN;
31703         return 0;
31704  }
31705 --- linux-2.6.0-test6/drivers/char/misc.c       2003-09-27 18:57:44.000000000 -0700
31706 +++ 25/drivers/char/misc.c      2003-10-05 00:33:24.000000000 -0700
31707 @@ -157,12 +157,11 @@ static int misc_open(struct inode * inod
31708                 list_for_each_entry(c, &misc_list, list) {
31709                         if (c->minor == minor) {
31710                                 new_fops = fops_get(c->fops);
31711 -                               if (!new_fops)
31712 -                                       goto fail;
31713                                 break;
31714                         }
31715                 }
31716 -               goto fail;
31717 +               if (!new_fops)
31718 +                       goto fail;
31719         }
31720  
31721         err = 0;
31722 --- linux-2.6.0-test6/drivers/char/moxa.c       2003-09-27 18:57:44.000000000 -0700
31723 +++ 25/drivers/char/moxa.c      2003-10-05 00:33:24.000000000 -0700
31724 @@ -32,7 +32,6 @@
31725  #include <linux/config.h>
31726  #include <linux/module.h>
31727  #include <linux/types.h>
31728 -#include <linux/version.h>
31729  #include <linux/mm.h>
31730  #include <linux/ioport.h>
31731  #include <linux/errno.h>
31732 --- linux-2.6.0-test6/drivers/char/mxser.c      2003-08-08 22:55:11.000000000 -0700
31733 +++ 25/drivers/char/mxser.c     2003-10-05 00:33:24.000000000 -0700
31734 @@ -39,7 +39,6 @@
31735  
31736  #include <linux/config.h>
31737  #include <linux/module.h>
31738 -#include <linux/version.h>
31739  #include <linux/errno.h>
31740  #include <linux/signal.h>
31741  #include <linux/sched.h>
31742 --- linux-2.6.0-test6/drivers/char/n_tty.c      2003-09-27 18:57:44.000000000 -0700
31743 +++ 25/drivers/char/n_tty.c     2003-10-05 00:36:15.000000000 -0700
31744 @@ -974,7 +974,8 @@ do_it_again:
31745         /* NOTE: not yet done after every sleep pending a thorough
31746            check of the logic of this change. -- jlc */
31747         /* don't stop on /dev/console */
31748 -       if (file->f_op->write != redirected_tty_write && current->tty == tty) {
31749 +       if (file->f_op->write != redirected_tty_write &&
31750 +                       process_tty(current) == tty) {
31751                 if (tty->pgrp <= 0)
31752                         printk("read_chan: tty->pgrp <= 0!\n");
31753                 else if (process_group(current) != tty->pgrp) {
31754 --- linux-2.6.0-test6/drivers/char/pcmcia/synclink_cs.c 2003-09-27 18:57:44.000000000 -0700
31755 +++ 25/drivers/char/pcmcia/synclink_cs.c        2003-10-05 00:33:24.000000000 -0700
31756 @@ -37,7 +37,6 @@
31757  
31758  #include <linux/config.h>      
31759  #include <linux/module.h>
31760 -#include <linux/version.h>
31761  #include <linux/errno.h>
31762  #include <linux/signal.h>
31763  #include <linux/sched.h>
31764 --- linux-2.6.0-test6/drivers/char/pcxx.c       2003-09-27 18:57:44.000000000 -0700
31765 +++ 25/drivers/char/pcxx.c      2003-10-05 00:33:24.000000000 -0700
31766 @@ -65,7 +65,6 @@
31767  #include <linux/tty_driver.h>
31768  #include <linux/slab.h>
31769  #include <linux/init.h>
31770 -#include <linux/version.h>
31771  
31772  #ifndef MODULE
31773  #include <linux/ctype.h> /* We only need it for parsing the "digi="-line */
31774 --- linux-2.6.0-test6/drivers/char/random.c     2003-09-27 18:57:44.000000000 -0700
31775 +++ 25/drivers/char/random.c    2003-10-05 00:33:24.000000000 -0700
31776 @@ -1735,7 +1735,7 @@ random_ioctl(struct inode * inode, struc
31777                 tmp = kmalloc(size * sizeof(__u32), GFP_KERNEL);
31778  
31779                 if (!tmp)
31780 -                       return -EFAULT;
31781 +                       return -ENOMEM;
31782  
31783                 spin_lock_irqsave(&random_state->lock, flags);
31784                 ent_count = random_state->entropy_count;
31785 --- linux-2.6.0-test6/drivers/char/raw.c        2003-09-08 13:58:57.000000000 -0700
31786 +++ 25/drivers/char/raw.c       2003-10-05 00:34:12.000000000 -0700
31787 @@ -20,8 +20,6 @@
31788  
31789  #include <asm/uaccess.h>
31790  
31791 -#define MAX_RAW_MINORS 256
31792 -
31793  struct raw_device_data {
31794         struct block_device *binding;
31795         int inuse;
31796 @@ -76,9 +74,8 @@ static int raw_open(struct inode *inode,
31797                         goto out;
31798                 }
31799                 filp->f_flags |= O_DIRECT;
31800 -               if (++raw_devices[minor].inuse == 1)
31801 -                       filp->f_dentry->d_inode->i_mapping =
31802 -                               bdev->bd_inode->i_mapping;
31803 +               filp->f_mapping = bdev->bd_inode->i_mapping;
31804 +               raw_devices[minor].inuse++;
31805         }
31806         filp->private_data = bdev;
31807  out:
31808 @@ -97,11 +94,7 @@ static int raw_release(struct inode *ino
31809  
31810         down(&raw_mutex);
31811         bdev = raw_devices[minor].binding;
31812 -       if (--raw_devices[minor].inuse == 0) {
31813 -               /* Here  inode->i_mapping == bdev->bd_inode->i_mapping  */
31814 -               inode->i_mapping = &inode->i_data;
31815 -               inode->i_mapping->backing_dev_info = &default_backing_dev_info;
31816 -       }
31817 +       --raw_devices[minor].inuse;
31818         up(&raw_mutex);
31819  
31820         bd_release(bdev);
31821 --- linux-2.6.0-test6/drivers/char/rio/rio_linux.c      2003-09-27 18:57:44.000000000 -0700
31822 +++ 25/drivers/char/rio/rio_linux.c     2003-10-05 00:33:24.000000000 -0700
31823 @@ -53,7 +53,6 @@
31824  #include <linux/fcntl.h>
31825  #include <linux/major.h>
31826  #include <linux/delay.h>
31827 -#include <linux/version.h>
31828  #include <linux/pci.h>
31829  #include <linux/slab.h>
31830  #include <linux/miscdevice.h>
31831 --- linux-2.6.0-test6/drivers/char/rocket.c     2003-09-27 18:57:44.000000000 -0700
31832 +++ 25/drivers/char/rocket.c    2003-10-05 00:36:15.000000000 -0700
31833 @@ -85,11 +85,9 @@
31834  #include <linux/string.h>
31835  #include <linux/fcntl.h>
31836  #include <linux/ptrace.h>
31837 -#include <linux/major.h>
31838  #include <linux/ioport.h>
31839  #include <linux/delay.h>
31840  #include <linux/wait.h>
31841 -#include <linux/delay.h>
31842  #include <linux/pci.h>
31843  #include <asm/uaccess.h>
31844  #include <asm/atomic.h>
31845 @@ -955,7 +953,7 @@ static int rp_open(struct tty_struct *tt
31846         /*
31847          * Info->count is now 1; so it's safe to sleep now.
31848          */
31849 -       info->session = current->session;
31850 +       info->session = process_session(current);
31851         info->pgrp = process_group(current);
31852  
31853         if ((info->flags & ROCKET_INITIALIZED) == 0) {
31854 --- linux-2.6.0-test6/drivers/char/ser_a2232.c  2003-09-27 18:57:44.000000000 -0700
31855 +++ 25/drivers/char/ser_a2232.c 2003-10-05 00:33:24.000000000 -0700
31856 @@ -703,7 +703,7 @@ static int a2232_init_drivers(void)
31857         a2232_driver->name = "ttyY";
31858         a2232_driver->major = A2232_NORMAL_MAJOR;
31859         a2232_driver->type = TTY_DRIVER_TYPE_SERIAL;
31860 -       a2232_driver->subtype = SERIAL_TTY_NORMAL;
31861 +       a2232_driver->subtype = SERIAL_TYPE_NORMAL;
31862         a2232_driver->init_termios = tty_std_termios;
31863         a2232_driver->init_termios.c_cflag =
31864                 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
31865 --- linux-2.6.0-test6/drivers/char/serial167.c  2003-09-27 18:57:44.000000000 -0700
31866 +++ 25/drivers/char/serial167.c 2003-10-05 00:33:24.000000000 -0700
31867 @@ -70,7 +70,6 @@
31868  #include <linux/types.h>
31869  #include <linux/kernel.h>
31870  
31871 -#include <linux/version.h>
31872  #include <asm/uaccess.h>
31873  #include <linux/init.h>
31874  
31875 --- linux-2.6.0-test6/drivers/char/stallion.c   2003-09-08 13:58:57.000000000 -0700
31876 +++ 25/drivers/char/stallion.c  2003-10-05 00:33:24.000000000 -0700
31877 @@ -28,7 +28,6 @@
31878  
31879  #include <linux/config.h>
31880  #include <linux/module.h>
31881 -#include <linux/version.h> /* for linux/stallion.h */
31882  #include <linux/slab.h>
31883  #include <linux/interrupt.h>
31884  #include <linux/tty.h>
31885 --- linux-2.6.0-test6/drivers/char/sx.c 2003-09-27 18:57:44.000000000 -0700
31886 +++ 25/drivers/char/sx.c        2003-10-05 00:33:24.000000000 -0700
31887 @@ -240,7 +240,6 @@
31888  #include "sxwindow.h"
31889  
31890  #include <linux/generic_serial.h>
31891 -#include <asm/uaccess.h>
31892  #include "sx.h"
31893  
31894  
31895 --- linux-2.6.0-test6/drivers/char/sysrq.c      2003-09-27 18:57:44.000000000 -0700
31896 +++ 25/drivers/char/sysrq.c     2003-10-05 00:33:38.000000000 -0700
31897 @@ -35,6 +35,25 @@
31898  #include <linux/spinlock.h>
31899  
31900  #include <asm/ptrace.h>
31901 +#ifdef CONFIG_KGDB_SYSRQ
31902 +
31903 +#define  GDB_OP &kgdb_op
31904 +static void kgdb_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty)
31905 +{
31906 +       printk("kgdb sysrq\n");
31907 +       breakpoint();
31908 +}
31909 +
31910 +static struct sysrq_key_op kgdb_op = {
31911 +       .handler        = kgdb_sysrq,
31912 +       .help_msg       = "kGdb|Fgdb",
31913 +       .action_msg     = "Debug breakpoint\n",
31914 +};
31915 +
31916 +#else
31917 +#define  GDB_OP NULL
31918 +#endif
31919 +
31920  
31921  extern void reset_vc(unsigned int);
31922  
31923 @@ -238,8 +257,8 @@ static struct sysrq_key_op *sysrq_key_ta
31924  /* c */ NULL,
31925  /* d */        NULL,
31926  /* e */        &sysrq_term_op,
31927 -/* f */        NULL,
31928 -/* g */        NULL,
31929 +/* f */        GDB_OP,
31930 +/* g */        GDB_OP,
31931  /* h */        NULL,
31932  /* i */        &sysrq_kill_op,
31933  /* j */        NULL,
31934 --- linux-2.6.0-test6/drivers/char/toshiba.c    2003-06-14 12:18:34.000000000 -0700
31935 +++ 25/drivers/char/toshiba.c   2003-10-05 00:33:24.000000000 -0700
31936 @@ -57,7 +57,6 @@
31937  #define TOSH_DEBUG 0
31938  
31939  #include <linux/module.h>
31940 -#include <linux/version.h>
31941  #include <linux/kernel.h>
31942  #include <linux/sched.h>
31943  #include <linux/types.h>
31944 @@ -85,7 +84,6 @@ static int tosh_fn = 0;
31945  MODULE_PARM(tosh_fn, "i");
31946  
31947  
31948 -static int tosh_get_info(char *, char **, off_t, int);
31949  static int tosh_ioctl(struct inode *, struct file *, unsigned int,
31950         unsigned long);
31951  
31952 @@ -104,6 +102,7 @@ static struct miscdevice tosh_device = {
31953  /*
31954   * Read the Fn key status
31955   */
31956 +#ifdef CONFIG_PROC_FS
31957  static int tosh_fn_status(void)
31958  {
31959          unsigned char scan;
31960 @@ -120,6 +119,7 @@ static int tosh_fn_status(void)
31961  
31962          return (int) scan;
31963  }
31964 +#endif
31965  
31966  
31967  /*
31968 @@ -291,6 +291,7 @@ static int tosh_ioctl(struct inode *ip, 
31969  /*
31970   * Print the information for /proc/toshiba
31971   */
31972 +#ifdef CONFIG_PROC_FS
31973  int tosh_get_info(char *buffer, char **start, off_t fpos, int length)
31974  {
31975         char *temp;
31976 @@ -319,6 +320,7 @@ int tosh_get_info(char *buffer, char **s
31977  
31978         return temp-buffer;
31979  }
31980 +#endif
31981  
31982  
31983  /*
31984 --- linux-2.6.0-test6/drivers/char/tty_io.c     2003-09-27 18:57:44.000000000 -0700
31985 +++ 25/drivers/char/tty_io.c    2003-10-05 00:36:15.000000000 -0700
31986 @@ -314,7 +314,7 @@ struct tty_driver *get_tty_driver(dev_t 
31987   */
31988  int tty_check_change(struct tty_struct * tty)
31989  {
31990 -       if (current->tty != tty)
31991 +       if (process_tty(current) != tty)
31992                 return 0;
31993         if (tty->pgrp <= 0) {
31994                 printk(KERN_WARNING "tty_check_change: tty->pgrp <= 0!\n");
31995 @@ -481,14 +481,14 @@ void do_tty_hangup(void *data)
31996         if (tty->session > 0) {
31997                 struct list_head *l;
31998                 for_each_task_pid(tty->session, PIDTYPE_SID, p, l, pid) {
31999 -                       if (p->tty == tty)
32000 -                               p->tty = NULL;
32001 -                       if (!p->leader)
32002 +                       if (process_tty(p) == tty)
32003 +                               p->signal->tty = NULL;
32004 +                       if (!process_session_leader(p))
32005                                 continue;
32006                         send_group_sig_info(SIGHUP, SEND_SIG_PRIV, p);
32007                         send_group_sig_info(SIGCONT, SEND_SIG_PRIV, p);
32008                         if (tty->pgrp > 0)
32009 -                               p->tty_old_pgrp = tty->pgrp;
32010 +                               p->signal->tty_old_pgrp = tty->pgrp;
32011                 }
32012         }
32013         read_unlock(&tasklist_lock);
32014 @@ -565,15 +565,15 @@ void disassociate_ctty(int on_exit)
32015  
32016         lock_kernel();
32017  
32018 -       tty = current->tty;
32019 +       tty = process_tty(current);
32020         if (tty) {
32021                 tty_pgrp = tty->pgrp;
32022                 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY)
32023                         tty_vhangup(tty);
32024         } else {
32025 -               if (current->tty_old_pgrp) {
32026 -                       kill_pg(current->tty_old_pgrp, SIGHUP, on_exit);
32027 -                       kill_pg(current->tty_old_pgrp, SIGCONT, on_exit);
32028 +               if (current->signal->tty_old_pgrp) {
32029 +                       kill_pg(current->signal->tty_old_pgrp, SIGHUP, on_exit);
32030 +                       kill_pg(current->signal->tty_old_pgrp, SIGCONT, on_exit);
32031                 }
32032                 unlock_kernel();        
32033                 return;
32034 @@ -584,13 +584,13 @@ void disassociate_ctty(int on_exit)
32035                         kill_pg(tty_pgrp, SIGCONT, on_exit);
32036         }
32037  
32038 -       current->tty_old_pgrp = 0;
32039 +       current->signal->tty_old_pgrp = 0;
32040         tty->session = 0;
32041         tty->pgrp = -1;
32042  
32043         read_lock(&tasklist_lock);
32044 -       for_each_task_pid(current->session, PIDTYPE_SID, p, l, pid)
32045 -               p->tty = NULL;
32046 +       for_each_task_pid(process_session(current), PIDTYPE_SID, p, l, pid)
32047 +               p->signal->tty = NULL;
32048         read_unlock(&tasklist_lock);
32049         unlock_kernel();
32050  }
32051 @@ -1218,10 +1218,10 @@ static void release_dev(struct file * fi
32052  
32053                 read_lock(&tasklist_lock);
32054                 for_each_task_pid(tty->session, PIDTYPE_SID, p, l, pid)
32055 -                       p->tty = NULL;
32056 +                       p->signal->tty = NULL;
32057                 if (o_tty)
32058                         for_each_task_pid(o_tty->session, PIDTYPE_SID, p,l, pid)
32059 -                               p->tty = NULL;
32060 +                               p->signal->tty = NULL;
32061                 read_unlock(&tasklist_lock);
32062         }
32063  
32064 @@ -1292,10 +1292,10 @@ static int tty_open(struct inode * inode
32065  retry_open:
32066         noctty = filp->f_flags & O_NOCTTY;
32067         if (device == MKDEV(TTYAUX_MAJOR,0)) {
32068 -               if (!current->tty)
32069 +               if (!process_tty(current))
32070                         return -ENXIO;
32071 -               driver = current->tty->driver;
32072 -               index = current->tty->index;
32073 +               driver = process_tty(current)->driver;
32074 +               index = process_tty(current)->index;
32075                 filp->f_flags |= O_NONBLOCK; /* Don't let /dev/tty block */
32076                 /* noctty = 1; */
32077                 goto got_driver;
32078 @@ -1389,15 +1389,13 @@ got_driver:
32079                         filp->f_op = &tty_fops;
32080                 goto retry_open;
32081         }
32082 -       if (!noctty &&
32083 -           current->leader &&
32084 -           !current->tty &&
32085 -           tty->session == 0) {
32086 +       if (!noctty && process_session_leader(current) &&
32087 +                       !process_tty(current) && tty->session == 0) {
32088                 task_lock(current);
32089 -               current->tty = tty;
32090 +               current->signal->tty = tty;
32091                 task_unlock(current);
32092 -               current->tty_old_pgrp = 0;
32093 -               tty->session = current->session;
32094 +               current->signal->tty_old_pgrp = 0;
32095 +               tty->session = process_session(current);
32096                 tty->pgrp = process_group(current);
32097         }
32098         return 0;
32099 @@ -1455,7 +1453,7 @@ static int tiocsti(struct tty_struct *tt
32100  {
32101         char ch, mbz = 0;
32102  
32103 -       if ((current->tty != tty) && !capable(CAP_SYS_ADMIN))
32104 +       if ((process_tty(current) != tty) && !capable(CAP_SYS_ADMIN))
32105                 return -EPERM;
32106         if (get_user(ch, arg))
32107                 return -EFAULT;
32108 @@ -1541,14 +1539,14 @@ static int tiocsctty(struct tty_struct *
32109         struct pid *pid;
32110         task_t *p;
32111  
32112 -       if (current->leader &&
32113 -           (current->session == tty->session))
32114 +       if (process_session_leader(current) &&
32115 +                       (process_session(current) == tty->session))
32116                 return 0;
32117         /*
32118          * The process must be a session leader and
32119          * not have a controlling tty already.
32120          */
32121 -       if (!current->leader || current->tty)
32122 +       if (!process_session_leader(current) || process_tty(current))
32123                 return -EPERM;
32124         if (tty->session > 0) {
32125                 /*
32126 @@ -1562,16 +1560,16 @@ static int tiocsctty(struct tty_struct *
32127  
32128                         read_lock(&tasklist_lock);
32129                         for_each_task_pid(tty->session, PIDTYPE_SID, p, l, pid)
32130 -                               p->tty = NULL;
32131 +                               p->signal->tty = NULL;
32132                         read_unlock(&tasklist_lock);
32133                 } else
32134                         return -EPERM;
32135         }
32136         task_lock(current);
32137 -       current->tty = tty;
32138 +       current->signal->tty = tty;
32139         task_unlock(current);
32140 -       current->tty_old_pgrp = 0;
32141 -       tty->session = current->session;
32142 +       current->signal->tty_old_pgrp = 0;
32143 +       tty->session = process_session(current);
32144         tty->pgrp = process_group(current);
32145         return 0;
32146  }
32147 @@ -1582,12 +1580,13 @@ static int tiocgpgrp(struct tty_struct *
32148          * (tty == real_tty) is a cheap way of
32149          * testing if the tty is NOT a master pty.
32150          */
32151 -       if (tty == real_tty && current->tty != real_tty)
32152 +       if (tty == real_tty && process_tty(current) != real_tty)
32153                 return -ENOTTY;
32154         return put_user(real_tty->pgrp, arg);
32155  }
32156  
32157 -static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t *arg)
32158 +static int tiocspgrp(struct tty_struct *tty,
32159 +                       struct tty_struct *real_tty, pid_t *arg)
32160  {
32161         pid_t pgrp;
32162         int retval = tty_check_change(real_tty);
32163 @@ -1596,15 +1595,14 @@ static int tiocspgrp(struct tty_struct *
32164                 return -ENOTTY;
32165         if (retval)
32166                 return retval;
32167 -       if (!current->tty ||
32168 -           (current->tty != real_tty) ||
32169 -           (real_tty->session != current->session))
32170 +       if (!process_tty(current) || (process_tty(current) != real_tty) ||
32171 +                       (real_tty->session != process_session(current)))
32172                 return -ENOTTY;
32173         if (get_user(pgrp, (pid_t *) arg))
32174                 return -EFAULT;
32175         if (pgrp < 0)
32176                 return -EINVAL;
32177 -       if (session_of_pgrp(pgrp) != current->session)
32178 +       if (session_of_pgrp(pgrp) != process_session(current))
32179                 return -EPERM;
32180         real_tty->pgrp = pgrp;
32181         return 0;
32182 @@ -1616,7 +1614,7 @@ static int tiocgsid(struct tty_struct *t
32183          * (tty == real_tty) is a cheap way of
32184          * testing if the tty is NOT a master pty.
32185         */
32186 -       if (tty == real_tty && current->tty != real_tty)
32187 +       if (tty == real_tty && process_tty(current) != real_tty)
32188                 return -ENOTTY;
32189         if (real_tty->session <= 0)
32190                 return -ENOTTY;
32191 @@ -1774,12 +1772,12 @@ int tty_ioctl(struct inode * inode, stru
32192                         clear_bit(TTY_EXCLUSIVE, &tty->flags);
32193                         return 0;
32194                 case TIOCNOTTY:
32195 -                       if (current->tty != tty)
32196 +                       if (process_tty(current) != tty)
32197                                 return -ENOTTY;
32198 -                       if (current->leader)
32199 +                       if (process_session_leader(current))
32200                                 disassociate_ctty(0);
32201                         task_lock(current);
32202 -                       current->tty = NULL;
32203 +                       current->signal->tty = NULL;
32204                         task_unlock(current);
32205                         return 0;
32206                 case TIOCSCTTY:
32207 @@ -1883,10 +1881,10 @@ static void __do_SAK(void *arg)
32208                 tty->driver->flush_buffer(tty);
32209         read_lock(&tasklist_lock);
32210         for_each_task_pid(session, PIDTYPE_SID, p, l, pid) {
32211 -               if (p->tty == tty || session > 0) {
32212 +               if (process_tty(p) == tty || session > 0) {
32213                         printk(KERN_NOTICE "SAK: killed process %d"
32214 -                           " (%s): p->session==tty->session\n",
32215 -                           p->pid, p->comm);
32216 +                               " (%s): process_session(p)==tty->session\n",
32217 +                               p->pid, p->comm);
32218                         send_sig(SIGKILL, p, 1);
32219                         continue;
32220                 }
32221 --- linux-2.6.0-test6/drivers/char/vme_scc.c    2003-09-27 18:57:44.000000000 -0700
32222 +++ 25/drivers/char/vme_scc.c   2003-10-05 00:33:24.000000000 -0700
32223 @@ -29,7 +29,6 @@
32224  #include <linux/fcntl.h>
32225  #include <linux/major.h>
32226  #include <linux/delay.h>
32227 -#include <linux/version.h>
32228  #include <linux/slab.h>
32229  #include <linux/miscdevice.h>
32230  #include <linux/console.h>
32231 --- linux-2.6.0-test6/drivers/char/vt.c 2003-09-08 13:58:57.000000000 -0700
32232 +++ 25/drivers/char/vt.c        2003-10-05 00:36:15.000000000 -0700
32233 @@ -2226,7 +2226,7 @@ int tioclinux(struct tty_struct *tty, un
32234  
32235         if (tty->driver->type != TTY_DRIVER_TYPE_CONSOLE)
32236                 return -EINVAL;
32237 -       if (current->tty != tty && !capable(CAP_SYS_ADMIN))
32238 +       if (process_tty(current) != tty && !capable(CAP_SYS_ADMIN))
32239                 return -EPERM;
32240         if (get_user(type, (char *)arg))
32241                 return -EFAULT;
32242 --- linux-2.6.0-test6/drivers/char/vt_ioctl.c   2003-08-22 19:23:40.000000000 -0700
32243 +++ 25/drivers/char/vt_ioctl.c  2003-10-05 00:36:15.000000000 -0700
32244 @@ -380,7 +380,7 @@ int vt_ioctl(struct tty_struct *tty, str
32245          * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.
32246          */
32247         perm = 0;
32248 -       if (current->tty == tty || capable(CAP_SYS_TTY_CONFIG))
32249 +       if (process_tty(current) == tty || capable(CAP_SYS_TTY_CONFIG))
32250                 perm = 1;
32251   
32252         kbd = kbd_table + console;
32253 @@ -1188,4 +1188,3 @@ void change_console(unsigned int new_con
32254  
32255         complete_change_console(new_console);
32256  }
32257 -
32258 --- linux-2.6.0-test6/drivers/char/watchdog/amd7xx_tco.c        2003-09-27 18:57:44.000000000 -0700
32259 +++ 25/drivers/char/watchdog/amd7xx_tco.c       2003-10-05 00:33:24.000000000 -0700
32260 @@ -19,13 +19,11 @@
32261  
32262  #include <linux/config.h>
32263  #include <linux/module.h>
32264 -#include <linux/version.h>
32265  #include <linux/kernel.h>
32266  #include <linux/miscdevice.h>
32267  #include <linux/watchdog.h>
32268  #include <linux/ioport.h>
32269  #include <linux/spinlock.h>
32270 -#include <linux/ioport.h>
32271  #include <asm/semaphore.h>
32272  #include <asm/io.h>
32273  #include <asm/uaccess.h>
32274 --- linux-2.6.0-test6/drivers/cpufreq/cpufreq.c 2003-09-27 18:57:44.000000000 -0700
32275 +++ 25/drivers/cpufreq/cpufreq.c        2003-10-05 00:36:14.000000000 -0700
32276 @@ -449,6 +449,9 @@ static int cpufreq_remove_dev (struct sy
32277         if (!kobject_get(&data->kobj))
32278                 return -EFAULT;
32279  
32280 +       if (cpufreq_driver->target)
32281 +               __cpufreq_governor(data, CPUFREQ_GOV_STOP);
32282 +
32283         kobject_unregister(&data->kobj);
32284  
32285         kobject_put(&data->kobj);
32286 @@ -459,9 +462,6 @@ static int cpufreq_remove_dev (struct sy
32287          */
32288         wait_for_completion(&data->kobj_unregister);
32289  
32290 -       if (cpufreq_driver->target)
32291 -               __cpufreq_governor(data, CPUFREQ_GOV_STOP);
32292 -
32293         if (cpufreq_driver->exit)
32294                 cpufreq_driver->exit(data);
32295  
32296 --- linux-2.6.0-test6/drivers/eisa/eisa-bus.c   2003-09-27 18:57:44.000000000 -0700
32297 +++ 25/drivers/eisa/eisa-bus.c  2003-10-05 00:36:11.000000000 -0700
32298 @@ -33,23 +33,22 @@ static struct eisa_device_info __initdat
32299  #endif
32300  
32301  #define EISA_MAX_FORCED_DEV 16
32302 -#define EISA_FORCED_OFFSET  2
32303  
32304 -static int enable_dev[EISA_MAX_FORCED_DEV + EISA_FORCED_OFFSET]  = { 1, EISA_MAX_FORCED_DEV, };
32305 -static int disable_dev[EISA_MAX_FORCED_DEV + EISA_FORCED_OFFSET] = { 1, EISA_MAX_FORCED_DEV, };
32306 +static int enable_dev[EISA_MAX_FORCED_DEV];
32307 +static int enable_dev_count;
32308 +static int disable_dev[EISA_MAX_FORCED_DEV];
32309 +static int disable_dev_count;
32310  
32311  static int is_forced_dev (int *forced_tab,
32312 +                         int forced_count,
32313                           struct eisa_root_device *root,
32314                           struct eisa_device *edev)
32315  {
32316         int i, x;
32317  
32318 -       for (i = 0; i < EISA_MAX_FORCED_DEV; i++) {
32319 -               if (!forced_tab[EISA_FORCED_OFFSET + i])
32320 -                       return 0;
32321 -
32322 +       for (i = 0; i < forced_count; i++) {
32323                 x = (root->bus_nr << 8) | edev->slot;
32324 -               if (forced_tab[EISA_FORCED_OFFSET + i] == x)
32325 +               if (forced_tab[i] == x)
32326                         return 1;
32327         }
32328  
32329 @@ -198,10 +197,10 @@ static int __init eisa_init_device (stru
32330  #endif
32331         }
32332  
32333 -       if (is_forced_dev (enable_dev, root, edev))
32334 +       if (is_forced_dev (enable_dev, enable_dev_count, root, edev))
32335                 edev->state = EISA_CONFIG_ENABLED | EISA_CONFIG_FORCED;
32336         
32337 -       if (is_forced_dev (disable_dev, root, edev))
32338 +       if (is_forced_dev (disable_dev, disable_dev_count, root, edev))
32339                 edev->state = EISA_CONFIG_FORCED;
32340  
32341         return 0;
32342 @@ -418,20 +417,13 @@ static int __init eisa_init (void)
32343         return 0;
32344  }
32345  
32346 -/* Couldn't use intarray with checking on... :-( */
32347 -#undef  param_check_intarray
32348 -#define param_check_intarray(name, p)
32349 -
32350 -module_param(enable_dev,  intarray, 0444);
32351 -module_param(disable_dev, intarray, 0444);
32352 +module_param_array(enable_dev, int, enable_dev_count, 0444);
32353 +module_param_array(disable_dev, int, disable_dev_count, 0444);
32354  
32355  postcore_initcall (eisa_init);
32356  
32357 -#ifndef CONFIG_EISA_ALWAYS
32358 -int EISA_bus;
32359 -EXPORT_SYMBOL(EISA_bus);
32360 -#endif
32361 -
32362 +int EISA_bus;          /* for legacy drivers */
32363 +EXPORT_SYMBOL (EISA_bus);
32364  EXPORT_SYMBOL (eisa_bus_type);
32365  EXPORT_SYMBOL (eisa_driver_register);
32366  EXPORT_SYMBOL (eisa_driver_unregister);
32367 --- linux-2.6.0-test6/drivers/i2c/busses/Kconfig        2003-09-27 18:57:44.000000000 -0700
32368 +++ 25/drivers/i2c/busses/Kconfig       2003-10-05 00:33:24.000000000 -0700
32369 @@ -285,7 +285,7 @@ config I2C_VELLEMAN
32370           will be called i2c-velleman.
32371  
32372  config I2C_VIA
32373 -       tristate "VIA 82C58B"
32374 +       tristate "VIA 82C586B"
32375         depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
32376         help
32377  
32378 --- linux-2.6.0-test6/drivers/i2c/i2c-sensor.c  2003-09-27 18:57:44.000000000 -0700
32379 +++ 25/drivers/i2c/i2c-sensor.c 2003-10-05 00:33:24.000000000 -0700
32380 @@ -133,7 +133,7 @@ int i2c_detect(struct i2c_adapter *adapt
32381                      i += 2) {
32382                         if (((adapter_id == address_data->probe[i]) ||
32383                              ((address_data->
32384 -                              probe[i] == ANY_I2C_BUS) & !is_isa))
32385 +                              probe[i] == ANY_I2C_BUS) && !is_isa))
32386                             && (addr == address_data->probe[i + 1])) {
32387                                 dev_dbg(&adapter->dev, "found probe parameter for adapter %d, addr %04x\n", adapter_id, addr);
32388                                 found = 1;
32389 @@ -141,7 +141,7 @@ int i2c_detect(struct i2c_adapter *adapt
32390                 }
32391                 for (i = 0; !found && (address_data->probe_range[i] != I2C_CLIENT_END); i += 3) {
32392                         if ( ((adapter_id == address_data->probe_range[i]) ||
32393 -                             ((address_data->probe_range[i] == ANY_I2C_BUS) & !is_isa)) &&
32394 +                             ((address_data->probe_range[i] == ANY_I2C_BUS) && !is_isa)) &&
32395                              (addr >= address_data->probe_range[i + 1]) &&
32396                              (addr <= address_data->probe_range[i + 2])) {
32397                                 found = 1;
32398 --- linux-2.6.0-test6/drivers/ide/ide.c 2003-09-08 13:58:57.000000000 -0700
32399 +++ 25/drivers/ide/ide.c        2003-10-05 00:33:58.000000000 -0700
32400 @@ -457,7 +457,7 @@ void ide_probe_module (void)
32401  
32402  EXPORT_SYMBOL(ide_probe_module);
32403  
32404 -static int ide_open (struct inode * inode, struct file * filp)
32405 +static int ide_open (struct block_device *bdev, struct file * filp)
32406  {
32407         return -ENXIO;
32408  }
32409 @@ -1800,27 +1800,26 @@ static int __init match_parm (char *s, c
32410  
32411  #ifdef CONFIG_BLK_DEV_PDC4030
32412  static int __initdata probe_pdc4030;
32413 -extern void init_pdc4030(void);
32414  #endif
32415  #ifdef CONFIG_BLK_DEV_ALI14XX
32416  static int __initdata probe_ali14xx;
32417 -extern void init_ali14xx(void);
32418 +extern int ali14xx_init(void);
32419  #endif
32420  #ifdef CONFIG_BLK_DEV_UMC8672
32421  static int __initdata probe_umc8672;
32422 -extern void init_umc8672(void);
32423 +extern int umc8672_init(void);
32424  #endif
32425  #ifdef CONFIG_BLK_DEV_DTC2278
32426  static int __initdata probe_dtc2278;
32427 -extern void init_dtc2278(void);
32428 +extern int dtc2278_init(void);
32429  #endif
32430  #ifdef CONFIG_BLK_DEV_HT6560B
32431  static int __initdata probe_ht6560b;
32432 -extern void init_ht6560b(void);
32433 +extern int ht6560b_init(void);
32434  #endif
32435  #ifdef CONFIG_BLK_DEV_QD65XX
32436  static int __initdata probe_qd65xx;
32437 -extern void init_qd65xx(void);
32438 +extern int qd65xx_init(void);
32439  #endif
32440  
32441  static int __initdata is_chipset_set[MAX_HWIFS];
32442 @@ -2238,8 +2237,9 @@ static void __init probe_for_hwifs (void
32443  #endif /* CONFIG_BLK_DEV_CMD640 */
32444  #ifdef CONFIG_BLK_DEV_PDC4030
32445         {
32446 -               extern int ide_probe_for_pdc4030(void);
32447 -               (void) ide_probe_for_pdc4030();
32448 +               extern int pdc4030_init(void);
32449 +               if (probe_pdc4030)
32450 +                       (void)pdc4030_init();
32451         }
32452  #endif /* CONFIG_BLK_DEV_PDC4030 */
32453  #ifdef CONFIG_BLK_DEV_IDE_PMAC
32454 @@ -2595,29 +2595,25 @@ int __init ide_init (void)
32455  
32456         init_ide_data();
32457  
32458 -#ifdef CONFIG_BLK_DEV_PDC4030
32459 -       if (probe_pdc4030)
32460 -               init_pdc4030();
32461 -#endif
32462  #ifdef CONFIG_BLK_DEV_ALI14XX
32463         if (probe_ali14xx)
32464 -               init_ali14xx();
32465 +               (void)ali14xx_init();
32466  #endif
32467  #ifdef CONFIG_BLK_DEV_UMC8672
32468         if (probe_umc8672)
32469 -               init_umc8672();
32470 +               (void)umc8672_init();
32471  #endif
32472  #ifdef CONFIG_BLK_DEV_DTC2278
32473         if (probe_dtc2278)
32474 -               init_dtc2278();
32475 +               (void)dtc2278_init();
32476  #endif
32477  #ifdef CONFIG_BLK_DEV_HT6560B
32478         if (probe_ht6560b)
32479 -               init_ht6560b();
32480 +               (void)ht6560b_init();
32481  #endif
32482  #ifdef CONFIG_BLK_DEV_QD65XX
32483         if (probe_qd65xx)
32484 -               init_qd65xx();
32485 +               (void)qd65xx_init();
32486  #endif
32487  
32488         initializing = 1;
32489 --- linux-2.6.0-test6/drivers/ide/ide-cd.c      2003-09-27 18:57:44.000000000 -0700
32490 +++ 25/drivers/ide/ide-cd.c     2003-10-05 00:34:01.000000000 -0700
32491 @@ -3331,39 +3331,38 @@ static ide_driver_t ide_cdrom_driver = {
32492         .complete_power_step    = ide_cdrom_complete_power_step,
32493  };
32494  
32495 -static int idecd_open(struct inode * inode, struct file * file)
32496 +static int idecd_open(struct block_device *bdev, struct file * file)
32497  {
32498 -       ide_drive_t *drive = inode->i_bdev->bd_disk->private_data;
32499 +       ide_drive_t *drive = bdev->bd_disk->private_data;
32500         struct cdrom_info *info = drive->driver_data;
32501         int rc = -ENOMEM;
32502         drive->usage++;
32503  
32504         if (!info->buffer)
32505                 info->buffer = (char *) kmalloc(SECTOR_BUFFER_SIZE, GFP_KERNEL);
32506 -        if (!info->buffer || (rc = cdrom_open(&info->devinfo, inode, file)))
32507 +        if (!info->buffer || (rc = cdrom_open(&info->devinfo, bdev, file)))
32508                 drive->usage--;
32509         return rc;
32510  }
32511  
32512 -static int idecd_release(struct inode * inode, struct file * file)
32513 +static int idecd_release(struct gendisk *disk)
32514  {
32515 -       ide_drive_t *drive = inode->i_bdev->bd_disk->private_data;
32516 +       ide_drive_t *drive = disk->private_data;
32517         struct cdrom_info *info = drive->driver_data;
32518  
32519 -       cdrom_release (&info->devinfo, file);
32520 +       cdrom_release(&info->devinfo);
32521         drive->usage--;
32522         return 0;
32523  }
32524  
32525 -static int idecd_ioctl (struct inode *inode, struct file *file,
32526 +static int idecd_ioctl (struct block_device *bdev, struct file *file,
32527                         unsigned int cmd, unsigned long arg)
32528  {
32529 -       struct block_device *bdev = inode->i_bdev;
32530         ide_drive_t *drive = bdev->bd_disk->private_data;
32531         int err = generic_ide_ioctl(bdev, cmd, arg);
32532         if (err == -EINVAL) {
32533                 struct cdrom_info *info = drive->driver_data;
32534 -               err = cdrom_ioctl(&info->devinfo, inode, cmd, arg);
32535 +               err = cdrom_ioctl(&info->devinfo, bdev, cmd, arg);
32536         }
32537         return err;
32538  }
32539 --- linux-2.6.0-test6/drivers/ide/ide-disk.c    2003-09-08 13:58:57.000000000 -0700
32540 +++ 25/drivers/ide/ide-disk.c   2003-10-05 00:34:01.000000000 -0700
32541 @@ -1734,9 +1734,9 @@ static ide_driver_t idedisk_driver = {
32542         .complete_power_step    = idedisk_complete_power_step,
32543  };
32544  
32545 -static int idedisk_open(struct inode *inode, struct file *filp)
32546 +static int idedisk_open(struct block_device *bdev, struct file *filp)
32547  {
32548 -       ide_drive_t *drive = inode->i_bdev->bd_disk->private_data;
32549 +       ide_drive_t *drive = bdev->bd_disk->private_data;
32550         drive->usage++;
32551         if (drive->removable && drive->usage == 1) {
32552                 ide_task_t args;
32553 @@ -1744,7 +1744,7 @@ static int idedisk_open(struct inode *in
32554                 memset(&args, 0, sizeof(ide_task_t));
32555                 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_DOORLOCK;
32556                 args.command_type = ide_cmd_type_parser(&args);
32557 -               check_disk_change(inode->i_bdev);
32558 +               check_disk_change(bdev);
32559                 /*
32560                  * Ignore the return code from door_lock,
32561                  * since the open() has already succeeded,
32562 @@ -1782,9 +1782,9 @@ static int ide_cacheflush_p(ide_drive_t 
32563         return 0;
32564  }
32565  
32566 -static int idedisk_release(struct inode *inode, struct file *filp)
32567 +static int idedisk_release(struct gendisk *disk)
32568  {
32569 -       ide_drive_t *drive = inode->i_bdev->bd_disk->private_data;
32570 +       ide_drive_t *drive = disk->private_data;
32571         if (drive->removable && drive->usage == 1) {
32572                 ide_task_t args;
32573                 memset(&args, 0, sizeof(ide_task_t));
32574 @@ -1798,10 +1798,9 @@ static int idedisk_release(struct inode 
32575         return 0;
32576  }
32577  
32578 -static int idedisk_ioctl(struct inode *inode, struct file *file,
32579 +static int idedisk_ioctl(struct block_device *bdev, struct file *file,
32580                         unsigned int cmd, unsigned long arg)
32581  {
32582 -       struct block_device *bdev = inode->i_bdev;
32583         return generic_ide_ioctl(bdev, cmd, arg);
32584  }
32585  
32586 --- linux-2.6.0-test6/drivers/ide/ide-floppy.c  2003-09-08 13:58:57.000000000 -0700
32587 +++ 25/drivers/ide/ide-floppy.c 2003-10-05 00:34:01.000000000 -0700
32588 @@ -156,7 +156,6 @@ typedef struct idefloppy_packet_command_
32589         int request_transfer;                   /* Bytes to transfer */
32590         int actually_transferred;               /* Bytes actually transferred */
32591         int buffer_size;                        /* Size of our data buffer */
32592 -       char *b_data;                           /* Pointer which runs on the buffers */
32593         int b_count;                            /* Missing/Available data on the current buffer */
32594         struct request *rq;                     /* The corresponding request */
32595         u8 *buffer;                             /* Data buffer */
32596 @@ -515,9 +514,6 @@ typedef struct {
32597         u8              reserved[4];
32598  } idefloppy_mode_parameter_header_t;
32599  
32600 -#define IDEFLOPPY_MIN(a,b)     ((a)<(b) ? (a):(b))
32601 -#define        IDEFLOPPY_MAX(a,b)      ((a)>(b) ? (a):(b))
32602 -
32603  /*
32604   *     Too bad. The drive wants to send us data which we are not ready to accept.
32605   *     Just throw it away.
32606 @@ -575,59 +571,68 @@ static int idefloppy_do_end_request(ide_
32607  static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, unsigned int bcount)
32608  {
32609         struct request *rq = pc->rq;
32610 -       struct bio *bio = rq->bio;
32611 -       int count;
32612 +       struct bio_vec *bvec;
32613 +       struct bio *bio;
32614 +       unsigned long flags;
32615 +       char *data;
32616 +       int count, i, done = 0;
32617 +
32618 +       rq_for_each_bio(bio, rq) {
32619 +               bio_for_each_segment(bvec, bio, i) {
32620 +                       if (!bcount)
32621 +                               break;
32622 +
32623 +                       count = min(bvec->bv_len, bcount);
32624 +
32625 +                       data = bvec_kmap_irq(bvec, &flags);
32626 +                       atapi_input_bytes(drive, data, count);
32627 +                       bvec_kunmap_irq(data, &flags);
32628  
32629 -       while (bcount) {
32630 -               if (pc->b_count == bio->bi_size) {
32631 -                       rq->sector += rq->current_nr_sectors;
32632 -                       rq->nr_sectors -= rq->current_nr_sectors;
32633 -                       idefloppy_do_end_request(drive, 1, 0);
32634 -                       if ((bio = rq->bio) != NULL)
32635 -                               pc->b_count = 0;
32636 -               }
32637 -               if (bio == NULL) {
32638 -                       printk(KERN_ERR "%s: bio == NULL in "
32639 -                               "idefloppy_input_buffers, bcount == %d\n",
32640 -                               drive->name, bcount);
32641 -                       idefloppy_discard_data(drive, bcount);
32642 -                       return;
32643 -               }
32644 -               count = IDEFLOPPY_MIN(bio->bi_size - pc->b_count, bcount);
32645 -               atapi_input_bytes(drive, bio_data(bio) + pc->b_count, count);
32646 -               bcount -= count;
32647 -               pc->b_count += count;
32648 +                       bcount -= count;
32649 +                       pc->b_count += count;
32650 +                       done += count;
32651 +               }
32652 +       }
32653 +
32654 +       idefloppy_do_end_request(drive, 1, done >> 9);
32655 +
32656 +       if (bcount) {
32657 +               printk(KERN_ERR "%s: leftover data in idefloppy_input_buffers, bcount == %d\n", drive->name, bcount);
32658 +               idefloppy_discard_data(drive, bcount);
32659         }
32660  }
32661  
32662  static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, unsigned int bcount)
32663  {
32664         struct request *rq = pc->rq;
32665 -       struct bio *bio = rq->bio;
32666 -       int count;
32667 -       
32668 -       while (bcount) {
32669 -               if (!pc->b_count) {
32670 -                       rq->sector += rq->current_nr_sectors;
32671 -                       rq->nr_sectors -= rq->current_nr_sectors;
32672 -                       idefloppy_do_end_request(drive, 1, 0);
32673 -                       if ((bio = rq->bio) != NULL) {
32674 -                               pc->b_data = bio_data(bio);
32675 -                               pc->b_count = bio->bi_size;
32676 -                       }
32677 +       struct bio *bio;
32678 +       struct bio_vec *bvec;
32679 +       unsigned long flags;
32680 +       int count, i, done = 0;
32681 +       char *data;
32682 +
32683 +       rq_for_each_bio(bio, rq) {
32684 +               bio_for_each_segment(bvec, bio, i) {
32685 +                       if (!bcount)
32686 +                               break;
32687 +
32688 +                       count = min(bvec->bv_len, bcount);
32689 +
32690 +                       data = bvec_kmap_irq(bvec, &flags);
32691 +                       atapi_output_bytes(drive, data, count);
32692 +                       bvec_kunmap_irq(data, &flags);
32693 +
32694 +                       bcount -= count;
32695 +                       pc->b_count += count;
32696 +                       done += count;
32697                 }
32698 -               if (bio == NULL) {
32699 -                       printk(KERN_ERR "%s: bio == NULL in "
32700 -                               "idefloppy_output_buffers, bcount == %d\n",
32701 -                               drive->name, bcount);
32702 -                       idefloppy_write_zeros(drive, bcount);
32703 -                       return;
32704 -               }
32705 -               count = IDEFLOPPY_MIN(pc->b_count, bcount);
32706 -               atapi_output_bytes(drive, pc->b_data, count);
32707 -               bcount -= count;
32708 -               pc->b_data += count;
32709 -               pc->b_count -= count;
32710 +       }
32711 +
32712 +       idefloppy_do_end_request(drive, 1, done >> 9);
32713 +
32714 +       if (bcount) {
32715 +               printk(KERN_ERR "%s: leftover data in idefloppy_output_buffers, bcount == %d\n", drive->name, bcount);
32716 +               idefloppy_write_zeros(drive, bcount);
32717         }
32718  }
32719  
32720 @@ -732,8 +737,6 @@ static void idefloppy_init_pc (idefloppy
32721         pc->request_transfer = 0;
32722         pc->buffer = pc->pc_buffer;
32723         pc->buffer_size = IDEFLOPPY_PC_BUFFER_SIZE;
32724 -       pc->b_data = NULL;
32725 -//     pc->bio = NULL;
32726         pc->callback = &idefloppy_pc_callback;
32727  }
32728  
32729 @@ -1199,7 +1202,6 @@ static void idefloppy_create_rw_cmd (ide
32730         put_unaligned(htonl(block), (unsigned int *) &pc->c[2]);
32731         pc->callback = &idefloppy_rw_callback;
32732         pc->rq = rq;
32733 -       pc->b_data = rq->buffer;
32734         pc->b_count = cmd == READ ? 0 : rq->bio->bi_size;
32735         if (rq->flags & REQ_RW)
32736                 set_bit(PC_WRITING, &pc->flags);
32737 @@ -1864,9 +1866,9 @@ static ide_driver_t idefloppy_driver = {
32738         .drives                 = LIST_HEAD_INIT(idefloppy_driver.drives),
32739  };
32740  
32741 -static int idefloppy_open(struct inode *inode, struct file *filp)
32742 +static int idefloppy_open(struct block_device *bdev, struct file *filp)
32743  {
32744 -       ide_drive_t *drive = inode->i_bdev->bd_disk->private_data;
32745 +       ide_drive_t *drive = bdev->bd_disk->private_data;
32746         idefloppy_floppy_t *floppy = drive->driver_data;
32747         idefloppy_pc_t pc;
32748  
32749 @@ -1906,7 +1908,7 @@ static int idefloppy_open(struct inode *
32750                         idefloppy_create_prevent_cmd(&pc, 1);
32751                         (void) idefloppy_queue_pc_tail(drive, &pc);
32752                 }
32753 -               check_disk_change(inode->i_bdev);
32754 +               check_disk_change(bdev);
32755         } else if (test_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags)) {
32756                 drive->usage--;
32757                 return -EBUSY;
32758 @@ -1914,9 +1916,9 @@ static int idefloppy_open(struct inode *
32759         return 0;
32760  }
32761  
32762 -static int idefloppy_release(struct inode *inode, struct file *filp)
32763 +static int idefloppy_release(struct gendisk *disk)
32764  {
32765 -       ide_drive_t *drive = inode->i_bdev->bd_disk->private_data;
32766 +       ide_drive_t *drive = disk->private_data;
32767         idefloppy_pc_t pc;
32768         
32769         debug_log(KERN_INFO "Reached idefloppy_release\n");
32770 @@ -1936,10 +1938,9 @@ static int idefloppy_release(struct inod
32771         return 0;
32772  }
32773  
32774 -static int idefloppy_ioctl(struct inode *inode, struct file *file,
32775 +static int idefloppy_ioctl(struct block_device *bdev, struct file *file,
32776                         unsigned int cmd, unsigned long arg)
32777  {
32778 -       struct block_device *bdev = inode->i_bdev;
32779         ide_drive_t *drive = bdev->bd_disk->private_data;
32780         idefloppy_floppy_t *floppy = drive->driver_data;
32781         int err = generic_ide_ioctl(bdev, cmd, arg);
32782 --- linux-2.6.0-test6/drivers/ide/ide-proc.c    2003-06-14 12:18:22.000000000 -0700
32783 +++ 25/drivers/ide/ide-proc.c   2003-10-05 00:33:24.000000000 -0700
32784 @@ -522,7 +522,8 @@ int proc_ide_write_settings
32785                         if (*p != ':')
32786                                 goto parse_error;
32787                         len = IDE_MIN(p - start, MAX_LEN);
32788 -                       strlcpy(name, start, IDE_MIN(len, MAX_LEN));
32789 +                       strncpy(name, start, IDE_MIN(len, MAX_LEN));
32790 +                       name[len] = 0;
32791  
32792                         if (n > 0) {
32793                                 --n;
32794 --- linux-2.6.0-test6/drivers/ide/ide-tape.c    2003-09-08 13:58:57.000000000 -0700
32795 +++ 25/drivers/ide/ide-tape.c   2003-10-05 00:34:01.000000000 -0700
32796 @@ -6338,24 +6338,23 @@ static struct file_operations idetape_fo
32797         .release        = idetape_chrdev_release,
32798  };
32799  
32800 -static int idetape_open(struct inode *inode, struct file *filp)
32801 +static int idetape_open(struct block_device *bdev, struct file *filp)
32802  {
32803 -       ide_drive_t *drive = inode->i_bdev->bd_disk->private_data;
32804 +       ide_drive_t *drive = bdev->bd_disk->private_data;
32805         drive->usage++;
32806         return 0;
32807  }
32808  
32809 -static int idetape_release(struct inode *inode, struct file *filp)
32810 +static int idetape_release(struct gendisk *disk)
32811  {
32812 -       ide_drive_t *drive = inode->i_bdev->bd_disk->private_data;
32813 +       ide_drive_t *drive = disk->private_data;
32814         drive->usage--;
32815         return 0;
32816  }
32817  
32818 -static int idetape_ioctl(struct inode *inode, struct file *file,
32819 +static int idetape_ioctl(struct block_device *bdev, struct file *file,
32820                         unsigned int cmd, unsigned long arg)
32821  {
32822 -       struct block_device *bdev = inode->i_bdev;
32823         ide_drive_t *drive = bdev->bd_disk->private_data;
32824         int err = generic_ide_ioctl(bdev, cmd, arg);
32825         if (err == -EINVAL)
32826 --- linux-2.6.0-test6/drivers/ide/Kconfig       2003-09-27 18:57:44.000000000 -0700
32827 +++ 25/drivers/ide/Kconfig      2003-10-05 00:36:28.000000000 -0700
32828 @@ -740,6 +740,13 @@ config BLK_DEV_SVWKS
32829           This driver adds PIO/(U)DMA support for the ServerWorks OSB4/CSB5
32830           chipsets.
32831  
32832 +config BLK_DEV_SGIIOC4
32833 +       tristate "Silicon Graphics IOC4 chipset support"
32834 +       help
32835 +         This driver adds PIO & MultiMode DMA-2 support for the SGI IOC4
32836 +         chipset.  Please say Y here, if you have an Altix System from
32837 +         Silicon Graphics Inc.
32838 +
32839  config BLK_DEV_SIIMAGE
32840         tristate "Silicon Image chipset support"
32841         help
32842 --- linux-2.6.0-test6/drivers/ide/legacy/ali14xx.c      2003-09-08 13:58:57.000000000 -0700
32843 +++ 25/drivers/ide/legacy/ali14xx.c     2003-10-05 00:33:24.000000000 -0700
32844 @@ -198,22 +198,12 @@ static int __init initRegisters (void) {
32845         return t;
32846  }
32847  
32848 -int __init probe_ali14xx (void)
32849 +static int __init ali14xx_probe(void)
32850  {
32851 -       /* auto-detect IDE controller port */
32852 -       if (!findPort()) {
32853 -               printk(KERN_ERR "ali14xx: not found.\n");
32854 -               return 1;
32855 -       }
32856 +       ide_hwif_t *hwif, *mate;
32857  
32858 -       printk(KERN_DEBUG "ali14xx: base= 0x%03x, regOn = 0x%02x.\n", basePort, regOn);
32859 -       ide_hwifs[0].chipset = ide_ali14xx;
32860 -       ide_hwifs[1].chipset = ide_ali14xx;
32861 -       ide_hwifs[0].tuneproc = &ali14xx_tune_drive;
32862 -       ide_hwifs[1].tuneproc = &ali14xx_tune_drive;
32863 -       ide_hwifs[0].mate = &ide_hwifs[1];
32864 -       ide_hwifs[1].mate = &ide_hwifs[0];
32865 -       ide_hwifs[1].channel = 1;
32866 +       printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n",
32867 +                         basePort, regOn);
32868  
32869         /* initialize controller registers */
32870         if (!initRegisters()) {
32871 @@ -221,74 +211,59 @@ int __init probe_ali14xx (void)
32872                 return 1;
32873         }
32874  
32875 -       probe_hwif_init(&ide_hwifs[0]);
32876 -       probe_hwif_init(&ide_hwifs[1]);
32877 +       hwif = &ide_hwifs[0];
32878 +       mate = &ide_hwifs[1];
32879  
32880 -       return 0;
32881 -}
32882 +       hwif->chipset = ide_ali14xx;
32883 +       hwif->tuneproc = &ali14xx_tune_drive;
32884 +       hwif->mate = mate;
32885 +
32886 +       mate->chipset = ide_ali14xx;
32887 +       mate->tuneproc = &ali14xx_tune_drive;
32888 +       mate->mate = hwif;
32889 +       mate->channel = 1;
32890  
32891 -static void ali14xx_release (void)
32892 -{
32893 -       if (ide_hwifs[0].chipset != ide_ali14xx &&
32894 -           ide_hwifs[1].chipset != ide_ali14xx)
32895 -               return;
32896 +       probe_hwif_init(hwif);
32897 +       probe_hwif_init(mate);
32898  
32899 -       ide_hwifs[0].chipset = ide_unknown;
32900 -       ide_hwifs[1].chipset = ide_unknown;
32901 -       ide_hwifs[0].tuneproc = NULL;
32902 -       ide_hwifs[1].tuneproc = NULL;
32903 -       ide_hwifs[0].mate = NULL;
32904 -       ide_hwifs[1].mate = NULL;
32905 +       return 0;
32906  }
32907  
32908 -#ifndef MODULE
32909 -/*
32910 - * init_ali14xx:
32911 - *
32912 - * called by ide.c when parsing command line
32913 - */
32914 -
32915 -void __init init_ali14xx (void)
32916 +/* Can be called directly from ide.c. */
32917 +int __init ali14xx_init(void)
32918  {
32919         /* auto-detect IDE controller port */
32920 -        if (findPort())
32921 -               if (probe_ali14xx())
32922 -                       goto no_detect;
32923 -       return;
32924 -
32925 -no_detect:
32926 +       if (findPort()) {
32927 +               if (ali14xx_probe())
32928 +                       return -ENODEV;
32929 +               return 0;
32930 +       }
32931         printk(KERN_ERR "ali14xx: not found.\n");
32932 -       ali14xx_release();
32933 +       return -ENODEV;
32934  }
32935  
32936 -#else
32937 -
32938 -MODULE_AUTHOR("see local file");
32939 -MODULE_DESCRIPTION("support of ALI 14XX IDE chipsets");
32940 -MODULE_LICENSE("GPL");
32941 -
32942 -static int __init ali14xx_mod_init(void)
32943 +#ifdef MODULE
32944 +static void __exit ali14xx_release_hwif(ide_hwif_t *hwif)
32945  {
32946 -       /* auto-detect IDE controller port */
32947 -       if (findPort())
32948 -               if (probe_ali14xx()) {
32949 -                       ali14xx_release();
32950 -                       return -ENODEV;
32951 -               }
32952 +       if (hwif->chipset != ide_ali14xx)
32953 +               return;
32954  
32955 -       if (ide_hwifs[0].chipset != ide_ali14xx &&
32956 -           ide_hwifs[1].chipset != ide_ali14xx) {
32957 -               ali14xx_release();
32958 -               return -ENODEV;
32959 -       }
32960 -       return 0;
32961 +       hwif->chipset = ide_unknown;
32962 +       hwif->tuneproc = NULL;
32963 +       hwif->mate = NULL;
32964 +       hwif->channel = 0;
32965  }
32966 -module_init(ali14xx_mod_init);
32967  
32968 -static void __exit ali14xx_mod_exit(void)
32969 +static void __exit ali14xx_exit(void)
32970  {
32971 -       ali14xx_release();
32972 +       ali14xx_release_hwif(&ide_hwifs[0]);
32973 +       ali14xx_release_hwif(&ide_hwifs[1]);
32974  }
32975 -module_exit(ali14xx_mod_exit);
32976 +
32977 +module_init(ali14xx_init);
32978 +module_exit(ali14xx_exit);
32979  #endif
32980  
32981 +MODULE_AUTHOR("see local file");
32982 +MODULE_DESCRIPTION("support of ALI 14XX IDE chipsets");
32983 +MODULE_LICENSE("GPL");
32984 --- linux-2.6.0-test6/drivers/ide/legacy/dtc2278.c      2003-09-08 13:58:57.000000000 -0700
32985 +++ 25/drivers/ide/legacy/dtc2278.c     2003-10-05 00:33:24.000000000 -0700
32986 @@ -95,9 +95,16 @@ static void tune_dtc2278 (ide_drive_t *d
32987         HWIF(drive)->drives[!drive->select.b.unit].io_32bit = 1;
32988  }
32989  
32990 -void __init probe_dtc2278 (void)
32991 +static int __init probe_dtc2278(void)
32992  {
32993         unsigned long flags;
32994 +       ide_hwif_t *hwif, *mate;
32995 +
32996 +       hwif = &ide_hwifs[0];
32997 +       mate = &ide_hwifs[1];
32998 +
32999 +       if (hwif->chipset != ide_unknown || mate->chipset != ide_unknown)
33000 +               return 1;
33001  
33002         local_irq_save(flags);
33003         /*
33004 @@ -117,76 +124,60 @@ void __init probe_dtc2278 (void)
33005  #endif
33006         local_irq_restore(flags);
33007  
33008 -       ide_hwifs[0].serialized = 1;
33009 -       ide_hwifs[1].serialized = 1;
33010 -       ide_hwifs[0].chipset = ide_dtc2278;
33011 -       ide_hwifs[1].chipset = ide_dtc2278;
33012 -       ide_hwifs[0].tuneproc = &tune_dtc2278;
33013 -       ide_hwifs[0].drives[0].no_unmask = 1;
33014 -       ide_hwifs[0].drives[1].no_unmask = 1;
33015 -       ide_hwifs[1].drives[0].no_unmask = 1;
33016 -       ide_hwifs[1].drives[1].no_unmask = 1;
33017 -       ide_hwifs[0].mate = &ide_hwifs[1];
33018 -       ide_hwifs[1].mate = &ide_hwifs[0];
33019 -       ide_hwifs[1].channel = 1;
33020 +       hwif->serialized = 1;
33021 +       hwif->chipset = ide_dtc2278;
33022 +       hwif->tuneproc = &tune_dtc2278;
33023 +       hwif->drives[0].no_unmask = 1;
33024 +       hwif->drives[1].no_unmask = 1;
33025 +       hwif->mate = mate;
33026 +
33027 +       mate->serialized = 1;
33028 +       mate->chipset = ide_dtc2278;
33029 +       mate->drives[0].no_unmask = 1;
33030 +       mate->drives[1].no_unmask = 1;
33031 +       mate->mate = hwif;
33032 +       mate->channel = 1;
33033 +
33034 +       probe_hwif_init(hwif);
33035 +       probe_hwif_init(mate);
33036  
33037 -       probe_hwif_init(&ide_hwifs[0]);
33038 -       probe_hwif_init(&ide_hwifs[1]);
33039 +       return 0;
33040  }
33041  
33042 -static void dtc2278_release (void)
33043 +/* Can be called directly from ide.c. */
33044 +int __init dtc2278_init(void)
33045  {
33046 -       if (ide_hwifs[0].chipset != ide_dtc2278 &&
33047 -           ide_hwifs[1].chipset != ide_dtc2278)
33048 +       if (probe_dtc2278()) {
33049 +               printk(KERN_ERR "dtc2278: ide interfaces already in use!\n");
33050 +               return -EBUSY;
33051 +       }
33052 +       return 0;
33053 +}
33054 +
33055 +#ifdef MODULE
33056 +static void __exit dtc2278_release_hwif(ide_hwif_t *hwif)
33057 +{
33058 +       if (hwif->chipset != ide_dtc2278)
33059                 return;
33060  
33061 -       ide_hwifs[0].serialized = 0;
33062 -       ide_hwifs[1].serialized = 0;
33063 -       ide_hwifs[0].chipset = ide_unknown;
33064 -       ide_hwifs[1].chipset = ide_unknown;
33065 -       ide_hwifs[0].tuneproc = NULL;
33066 -       ide_hwifs[0].drives[0].no_unmask = 0;
33067 -       ide_hwifs[0].drives[1].no_unmask = 0;
33068 -       ide_hwifs[1].drives[0].no_unmask = 0;
33069 -       ide_hwifs[1].drives[1].no_unmask = 0;
33070 -       ide_hwifs[0].mate = NULL;
33071 -       ide_hwifs[1].mate = NULL;
33072 +       hwif->serialized = 0;
33073 +       hwif->chipset = ide_unknown;
33074 +       hwif->tuneproc = NULL;
33075 +       hwif->drives[0].no_unmask = 0;
33076 +       hwif->drives[1].no_unmask = 0;
33077 +       hwif->mate = NULL;
33078  }
33079  
33080 -#ifndef MODULE
33081 -/*
33082 - * init_dtc2278:
33083 - *
33084 - * called by ide.c when parsing command line
33085 - */
33086 -
33087 -void __init init_dtc2278 (void)
33088 +static void __exit dtc2278_exit(void)
33089  {
33090 -       probe_dtc2278();
33091 +       dtc2278_release_hwif(&ide_hwifs[0]);
33092 +       dtc2278_release_hwif(&ide_hwifs[1]);
33093  }
33094  
33095 -#else
33096 +module_init(dtc2278_init);
33097 +module_exit(dtc2278_exit);
33098 +#endif
33099  
33100  MODULE_AUTHOR("See Local File");
33101  MODULE_DESCRIPTION("support of DTC-2278 VLB IDE chipsets");
33102  MODULE_LICENSE("GPL");
33103 -
33104 -static int __init dtc2278_mod_init(void)
33105 -{
33106 -       probe_dtc2278();
33107 -       if (ide_hwifs[0].chipset != ide_dtc2278 &&
33108 -           ide_hwifs[1].chipset != ide_dtc2278) {
33109 -               dtc2278_release();
33110 -               return -ENODEV;
33111 -       }
33112 -       return 0;
33113 -}
33114 -module_init(dtc2278_mod_init);
33115 -
33116 -static void __exit dtc2278_mod_exit(void)
33117 -{
33118 -       dtc2278_release();
33119 -}
33120 -module_exit(dtc2278_mod_exit);
33121 -#endif
33122 -
33123 --- linux-2.6.0-test6/drivers/ide/legacy/hd98.c 2003-08-08 22:55:11.000000000 -0700
33124 +++ 25/drivers/ide/legacy/hd98.c        2003-10-05 00:33:54.000000000 -0700
33125 @@ -652,10 +652,10 @@ static void do_hd_request (request_queue
33126         enable_irq(HD_IRQ);
33127  }
33128  
33129 -static int hd_ioctl(struct inode * inode, struct file * file,
33130 +static int hd_ioctl(struct block_device *bdev, struct file *file,
33131         unsigned int cmd, unsigned long arg)
33132  {
33133 -       struct hd_i_struct *disk = inode->i_bdev->bd_disk->private_data;
33134 +       struct hd_i_struct *disk = bdev->bd_disk->private_data;
33135         struct hd_geometry *loc = (struct hd_geometry *) arg;
33136         struct hd_geometry g; 
33137  
33138 @@ -666,7 +666,7 @@ static int hd_ioctl(struct inode * inode
33139         g.heads = disk->head;
33140         g.sectors = disk->sect;
33141         g.cylinders = disk->cyl;
33142 -       g.start = get_start_sect(inode->i_bdev);
33143 +       g.start = get_start_sect(bdev);
33144         return copy_to_user(loc, &g, sizeof g) ? -EFAULT : 0; 
33145  }
33146  
33147 --- linux-2.6.0-test6/drivers/ide/legacy/hd.c   2003-08-22 19:23:40.000000000 -0700
33148 +++ 25/drivers/ide/legacy/hd.c  2003-10-05 00:33:54.000000000 -0700
33149 @@ -656,10 +656,10 @@ static void do_hd_request (request_queue
33150         enable_irq(HD_IRQ);
33151  }
33152  
33153 -static int hd_ioctl(struct inode * inode, struct file * file,
33154 +static int hd_ioctl(struct block_device *bdev, struct file *file,
33155         unsigned int cmd, unsigned long arg)
33156  {
33157 -       struct hd_i_struct *disk = inode->i_bdev->bd_disk->private_data;
33158 +       struct hd_i_struct *disk = bdev->bd_disk->private_data;
33159         struct hd_geometry *loc = (struct hd_geometry *) arg;
33160         struct hd_geometry g; 
33161  
33162 @@ -670,7 +670,7 @@ static int hd_ioctl(struct inode * inode
33163         g.heads = disk->head;
33164         g.sectors = disk->sect;
33165         g.cylinders = disk->cyl;
33166 -       g.start = get_start_sect(inode->i_bdev);
33167 +       g.start = get_start_sect(bdev);
33168         return copy_to_user(loc, &g, sizeof g) ? -EFAULT : 0; 
33169  }
33170  
33171 --- linux-2.6.0-test6/drivers/ide/legacy/ht6560b.c      2003-09-08 13:58:57.000000000 -0700
33172 +++ 25/drivers/ide/legacy/ht6560b.c     2003-10-05 00:33:24.000000000 -0700
33173 @@ -304,35 +304,16 @@ static void tune_ht6560b (ide_drive_t *d
33174  #endif
33175  }
33176  
33177 -void ht6560b_release (void)
33178 -{
33179 -       if (ide_hwifs[0].chipset != ide_ht6560b &&
33180 -           ide_hwifs[1].chipset != ide_ht6560b)
33181 -                return;
33182 -
33183 -       ide_hwifs[0].chipset = ide_unknown;
33184 -       ide_hwifs[1].chipset = ide_unknown;
33185 -       ide_hwifs[0].tuneproc = NULL;
33186 -       ide_hwifs[1].tuneproc = NULL;
33187 -       ide_hwifs[0].selectproc = NULL;
33188 -       ide_hwifs[1].selectproc = NULL;
33189 -       ide_hwifs[0].serialized = 0;
33190 -       ide_hwifs[1].serialized = 0;
33191 -       ide_hwifs[0].mate = NULL;
33192 -       ide_hwifs[1].mate = NULL;
33193 -
33194 -       ide_hwifs[0].drives[0].drive_data = 0;
33195 -       ide_hwifs[0].drives[1].drive_data = 0;
33196 -       ide_hwifs[1].drives[0].drive_data = 0;
33197 -       ide_hwifs[1].drives[1].drive_data = 0;
33198 -       release_region(HT_CONFIG_PORT, 1);
33199 -}
33200 -
33201 -static int __init ht6560b_mod_init(void)
33202 +/* Can be called directly from ide.c. */
33203 +int __init ht6560b_init(void)
33204  {
33205 +       ide_hwif_t *hwif, *mate;
33206         int t;
33207  
33208 -       if (!request_region(HT_CONFIG_PORT, 1, ide_hwifs[0].name)) {
33209 +       hwif = &ide_hwifs[0];
33210 +       mate = &ide_hwifs[1];
33211 +
33212 +       if (!request_region(HT_CONFIG_PORT, 1, hwif->name)) {
33213                 printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n",
33214                         __FUNCTION__);
33215                 return -ENODEV;
33216 @@ -343,39 +324,33 @@ static int __init ht6560b_mod_init(void)
33217                 goto release_region;
33218         }
33219  
33220 -       ide_hwifs[0].chipset = ide_ht6560b;
33221 -       ide_hwifs[1].chipset = ide_ht6560b;
33222 -       ide_hwifs[0].selectproc = &ht6560b_selectproc;
33223 -       ide_hwifs[1].selectproc = &ht6560b_selectproc;
33224 -       ide_hwifs[0].tuneproc = &tune_ht6560b;
33225 -       ide_hwifs[1].tuneproc = &tune_ht6560b;
33226 -       ide_hwifs[0].serialized = 1;  /* is this needed? */
33227 -       ide_hwifs[1].serialized = 1;  /* is this needed? */
33228 -       ide_hwifs[0].mate = &ide_hwifs[1];
33229 -       ide_hwifs[1].mate = &ide_hwifs[0];
33230 -       ide_hwifs[1].channel = 1;
33231 +       hwif->chipset = ide_ht6560b;
33232 +       hwif->selectproc = &ht6560b_selectproc;
33233 +       hwif->tuneproc = &tune_ht6560b;
33234 +       hwif->serialized = 1;   /* is this needed? */
33235 +       hwif->mate = mate;
33236 +
33237 +       mate->chipset = ide_ht6560b;
33238 +       mate->selectproc = &ht6560b_selectproc;
33239 +       mate->tuneproc = &tune_ht6560b;
33240 +       mate->serialized = 1;   /* is this needed? */
33241 +       mate->mate = hwif;
33242 +       mate->channel = 1;
33243  
33244         /*
33245          * Setting default configurations for drives
33246          */
33247         t = (HT_CONFIG_DEFAULT << 8);
33248         t |= HT_TIMING_DEFAULT;
33249 -       ide_hwifs[0].drives[0].drive_data = t;
33250 -       ide_hwifs[0].drives[1].drive_data = t;
33251 -       t |= (HT_SECONDARY_IF << 8);
33252 -       ide_hwifs[1].drives[0].drive_data = t;
33253 -       ide_hwifs[1].drives[1].drive_data = t;
33254 +       hwif->drives[0].drive_data = t;
33255 +       hwif->drives[1].drive_data = t;
33256  
33257 -       probe_hwif_init(&ide_hwifs[0]);
33258 -       probe_hwif_init(&ide_hwifs[1]);
33259 +       t |= (HT_SECONDARY_IF << 8);
33260 +       mate->drives[0].drive_data = t;
33261 +       mate->drives[1].drive_data = t;
33262  
33263 -#ifdef MODULE
33264 -       if (ide_hwifs[0].chipset != ide_ht6560b &&
33265 -           ide_hwifs[1].chipset != ide_ht6560b) {
33266 -               ht6560b_release();
33267 -               return -ENODEV;
33268 -       }
33269 -#endif
33270 +       probe_hwif_init(hwif);
33271 +       probe_hwif_init(mate);
33272  
33273         return 0;
33274  
33275 @@ -384,24 +359,34 @@ release_region:
33276         return -ENODEV;
33277  }
33278  
33279 -MODULE_AUTHOR("See Local File");
33280 -MODULE_DESCRIPTION("HT-6560B EIDE-controller support");
33281 -MODULE_LICENSE("GPL");
33282 -
33283  #ifdef MODULE
33284 -static void __exit ht6560b_mod_exit(void)
33285 +static void __exit ht6560b_release_hwif(ide_hwif_t *hwif)
33286  {
33287 -        ht6560b_release();
33288 +       if (hwif->chipset != ide_ht6560b)
33289 +               return;
33290 +
33291 +       hwif->chipset = ide_unknown;
33292 +       hwif->tuneproc = NULL;
33293 +       hwif->selectproc = NULL;
33294 +       hwif->serialized = 0;
33295 +       hwif->mate = NULL;
33296 +       hwif->channel = 0;
33297 +
33298 +       hwif->drives[0].drive_data = 0;
33299 +       hwif->drives[1].drive_data = 0;
33300  }
33301  
33302 -module_init(ht6560b_mod_init);
33303 -module_exit(ht6560b_mod_exit);
33304 -#else
33305 -/*
33306 - * called by ide.c when parsing command line
33307 - */
33308 -void __init init_ht6560b (void)
33309 +static void __exit ht6560b_exit(void)
33310  {
33311 -       ht6560b_mod_init();     /* ignore return value */
33312 +       ht6560b_release_hwif(&ide_hwifs[0]);
33313 +       ht6560b_release_hwif(&ide_hwifs[1]);
33314 +       release_region(HT_CONFIG_PORT, 1);
33315  }
33316 +
33317 +module_init(ht6560b_init);
33318 +module_exit(ht6560b_exit);
33319  #endif
33320 +
33321 +MODULE_AUTHOR("See Local File");
33322 +MODULE_DESCRIPTION("HT-6560B EIDE-controller support");
33323 +MODULE_LICENSE("GPL");
33324 --- linux-2.6.0-test6/drivers/ide/legacy/pdc4030.c      2003-09-08 13:58:57.000000000 -0700
33325 +++ 25/drivers/ide/legacy/pdc4030.c     2003-10-05 00:33:24.000000000 -0700
33326 @@ -147,8 +147,6 @@ int pdc4030_identify(ide_drive_t *drive)
33327         return pdc4030_cmd(drive, PROMISE_IDENTIFY);
33328  }
33329  
33330 -int enable_promise_support;
33331 -
33332  /*
33333   * setup_pdc4030()
33334   * Completes the setup of a Promise DC4030 controller card, once found.
33335 @@ -296,33 +294,24 @@ int __init detect_pdc4030(ide_hwif_t *hw
33336         }
33337  }
33338  
33339 -
33340 -int __init ide_probe_for_pdc4030(void)
33341 +int __init pdc4030_init(void)
33342  {
33343         unsigned int    index;
33344         ide_hwif_t      *hwif;
33345  
33346 -#ifndef MODULE
33347 -       if (enable_promise_support == 0)
33348 -               return;
33349 -#endif
33350 -
33351         for (index = 0; index < MAX_HWIFS; index++) {
33352                 hwif = &ide_hwifs[index];
33353                 if (hwif->chipset == ide_unknown && detect_pdc4030(hwif)) {
33354 -#ifndef MODULE
33355 -                       setup_pdc4030(hwif);
33356 -#else
33357 -                       return setup_pdc4030(hwif);
33358 -#endif
33359 +                       if (!setup_pdc4030(hwif))
33360 +                               return -ENODEV;
33361 +                       return 0;
33362                 }
33363         }
33364 -#ifdef MODULE
33365 -       return 0;
33366 -#endif
33367 +       return -ENODEV;
33368  }
33369  
33370 -static void __exit release_pdc4030(ide_hwif_t *hwif, ide_hwif_t *mate)
33371 +#ifdef MODULE
33372 +static void __exit pdc4030_release_hwif(ide_hwif_t *hwif)
33373  {
33374         hwif->chipset = ide_unknown;
33375         hwif->selectproc = NULL;
33376 @@ -333,72 +322,24 @@ static void __exit release_pdc4030(ide_h
33377         hwif->drives[1].keep_settings = 0;
33378         hwif->drives[0].noprobe = 0;
33379         hwif->drives[1].noprobe = 0;
33380 -
33381 -       if (mate != NULL) {
33382 -               mate->chipset = ide_unknown;
33383 -               mate->selectproc = NULL;
33384 -               mate->serialized = 0;
33385 -               mate->drives[0].io_32bit = 0;
33386 -               mate->drives[1].io_32bit = 0;
33387 -               mate->drives[0].keep_settings = 0;
33388 -               mate->drives[1].keep_settings = 0;
33389 -               mate->drives[0].noprobe = 0;
33390 -               mate->drives[1].noprobe = 0;
33391 -       }
33392  }
33393  
33394 -#ifndef MODULE
33395 -/*
33396 - * init_pdc4030:
33397 - *
33398 - * called by ide.c when parsing command line
33399 - */
33400 -
33401 -void __init init_pdc4030(void)
33402 +static void __exit pdc4030_exit(void)
33403  {
33404 -       enable_promise_support = 1;
33405 +       unsigned int index;
33406 +
33407 +       for (index = 0; index < MAX_HWIFS; index++)
33408 +               pdc4030_release_hwif(&ide_hwifs[index]);
33409  }
33410  
33411 -#else
33412 +module_init(pdc4030_init);
33413 +module_exit(pdc4030_exit);
33414 +#endif
33415  
33416  MODULE_AUTHOR("Peter Denison");
33417  MODULE_DESCRIPTION("Support of Promise 4030 VLB series IDE chipsets");
33418  MODULE_LICENSE("GPL");
33419  
33420 -static int __init pdc4030_mod_init(void)
33421 -{
33422 -       if (enable_promise_support == 0)
33423 -               enable_promise_support = 1;
33424 -
33425 -       if (!ide_probe_for_pdc4030())
33426 -               return -ENODEV;
33427 -        return 0;
33428 -}
33429 -module_init(pdc4030_mod_init);
33430 -
33431 -static void __exit pdc4030_mod_exit(void)
33432 -{
33433 -       unsigned int    index;
33434 -       ide_hwif_t      *hwif;
33435 -
33436 -       if (enable_promise_support == 0)
33437 -               return;
33438
33439 -       for (index = 0; index < MAX_HWIFS; index++) {
33440 -               hwif = &ide_hwifs[index];
33441 -               if (hwif->chipset == ide_pdc4030) {
33442 -                       ide_hwif_t *mate = &ide_hwifs[hwif->index+1];
33443 -                       if (mate->chipset == ide_pdc4030)
33444 -                               release_pdc4030(hwif, mate);
33445 -                       else
33446 -                               release_pdc4030(hwif, NULL);
33447 -                }
33448 -        }
33449 -       enable_promise_support = 0;
33450 -}
33451 -module_exit(pdc4030_mod_exit);
33452 -#endif
33453 -
33454  /*
33455   * promise_read_intr() is the handler for disk read/multread interrupts
33456   */
33457 --- linux-2.6.0-test6/drivers/ide/legacy/qd65xx.c       2003-09-08 13:58:57.000000000 -0700
33458 +++ 25/drivers/ide/legacy/qd65xx.c      2003-10-05 00:33:24.000000000 -0700
33459 @@ -338,12 +338,12 @@ static int __init qd_testreg(int port)
33460   * called to setup an ata channel : adjusts attributes & links for tuning
33461   */
33462  
33463 -void __init qd_setup (int unit, int base, int config, unsigned int data0, unsigned int data1, void (*tuneproc) (ide_drive_t *, u8 pio))
33464 +static void __init qd_setup(ide_hwif_t *hwif, int base, int config,
33465 +                           unsigned int data0, unsigned int data1,
33466 +                           void (*tuneproc) (ide_drive_t *, u8 pio))
33467  {
33468 -       ide_hwif_t *hwif = &ide_hwifs[unit];
33469 -
33470         hwif->chipset = ide_qd65xx;
33471 -       hwif->channel = unit;
33472 +       hwif->channel = hwif->index;
33473         hwif->select_data = base;
33474         hwif->config_data = config;
33475         hwif->drives[0].drive_data = data0;
33476 @@ -354,19 +354,20 @@ void __init qd_setup (int unit, int base
33477         probe_hwif_init(hwif);
33478  }
33479  
33480 +#ifdef MODULE
33481  /*
33482   * qd_unsetup:
33483   *
33484   * called to unsetup an ata channel : back to default values, unlinks tuning
33485   */
33486 -static void __exit qd_unsetup (int unit)
33487 +static void __exit qd_unsetup(ide_hwif_t *hwif)
33488  {
33489 -       ide_hwif_t *hwif = &ide_hwifs[unit];
33490         u8 config = hwif->config_data;
33491         int base = hwif->select_data;
33492         void *tuneproc = (void *) hwif->tuneproc;
33493  
33494 -       if (!(hwif->chipset == ide_qd65xx)) return;
33495 +       if (hwif->chipset != ide_qd65xx)
33496 +               return;
33497  
33498         printk(KERN_NOTICE "%s: back to defaults\n", hwif->name);
33499  
33500 @@ -381,13 +382,14 @@ static void __exit qd_unsetup (int unit)
33501                         qd_write_reg(QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0]));
33502                         qd_write_reg(QD6580_DEF_DATA2, QD_TIMREG(&hwif->drives[1]));
33503                 } else {
33504 -                       qd_write_reg(unit?QD6580_DEF_DATA2:QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0]));
33505 +                       qd_write_reg(hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0]));
33506                 }
33507         } else {
33508                 printk(KERN_WARNING "Unknown qd65xx tuning fonction !\n");
33509                 printk(KERN_WARNING "keeping settings !\n");
33510         }
33511  }
33512 +#endif
33513  
33514  /*
33515   * qd_probe:
33516 @@ -396,8 +398,9 @@ static void __exit qd_unsetup (int unit)
33517   * return 1 if another qd may be probed
33518   */
33519  
33520 -int __init qd_probe (int base)
33521 +static int __init qd_probe(int base)
33522  {
33523 +       ide_hwif_t *hwif;
33524         u8 config;
33525         u8 unit;
33526  
33527 @@ -414,9 +417,8 @@ int __init qd_probe (int base)
33528  
33529                 /* qd6500 found */
33530  
33531 -               printk(KERN_NOTICE "%s: qd6500 at %#x\n",
33532 -                       ide_hwifs[unit].name, base);
33533 -               
33534 +               hwif = &ide_hwifs[unit];
33535 +               printk(KERN_NOTICE "%s: qd6500 at %#x\n", hwif->name, base);
33536                 printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n",
33537                         config, QD_ID3);
33538                 
33539 @@ -425,8 +427,8 @@ int __init qd_probe (int base)
33540                         return 1;
33541                 }
33542  
33543 -               qd_setup(unit, base, config, QD6500_DEF_DATA,
33544 -                       QD6500_DEF_DATA, &qd6500_tune_drive);
33545 +               qd_setup(hwif, base, config, QD6500_DEF_DATA, QD6500_DEF_DATA,
33546 +                        &qd6500_tune_drive);
33547                 return 1;
33548         }
33549  
33550 @@ -448,25 +450,31 @@ int __init qd_probe (int base)
33551  
33552                 if (control & QD_CONTR_SEC_DISABLED) {
33553                         /* secondary disabled */
33554 +
33555 +                       hwif = &ide_hwifs[unit];
33556                         printk(KERN_INFO "%s: qd6580: single IDE board\n",
33557 -                                       ide_hwifs[unit].name);
33558 -                       qd_setup(unit, base, config | (control << 8),
33559 -                               QD6580_DEF_DATA, QD6580_DEF_DATA2,
33560 -                               &qd6580_tune_drive);
33561 +                                        hwif->name);
33562 +                       qd_setup(hwif, base, config | (control << 8),
33563 +                                QD6580_DEF_DATA, QD6580_DEF_DATA2,
33564 +                                &qd6580_tune_drive);
33565                         qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT);
33566  
33567                         return 1;
33568                 } else {
33569 +                       ide_hwif_t *mate;
33570 +
33571 +                       hwif = &ide_hwifs[0];
33572 +                       mate = &ide_hwifs[1];
33573                         /* secondary enabled */
33574                         printk(KERN_INFO "%s&%s: qd6580: dual IDE board\n",
33575 -                                       ide_hwifs[0].name,ide_hwifs[1].name);
33576 +                                       hwif->name, mate->name);
33577  
33578 -                       qd_setup(0, base, config | (control << 8),
33579 -                               QD6580_DEF_DATA, QD6580_DEF_DATA,
33580 -                               &qd6580_tune_drive);
33581 -                       qd_setup(1, base, config | (control << 8),
33582 -                               QD6580_DEF_DATA2, QD6580_DEF_DATA2,
33583 -                               &qd6580_tune_drive);
33584 +                       qd_setup(hwif, base, config | (control << 8),
33585 +                                QD6580_DEF_DATA, QD6580_DEF_DATA,
33586 +                                &qd6580_tune_drive);
33587 +                       qd_setup(mate, base, config | (control << 8),
33588 +                                QD6580_DEF_DATA2, QD6580_DEF_DATA2,
33589 +                                &qd6580_tune_drive);
33590                         qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT);
33591  
33592                         return 0; /* no other qd65xx possible */
33593 @@ -476,38 +484,28 @@ int __init qd_probe (int base)
33594         return 1;
33595  }
33596  
33597 -#ifndef MODULE
33598 -/*
33599 - * init_qd65xx:
33600 - *
33601 - * called by ide.c when parsing command line
33602 - */
33603 -
33604 -void __init init_qd65xx (void)
33605 -{
33606 -       if (qd_probe(0x30)) qd_probe(0xb0);
33607 -}
33608 -
33609 -#else
33610 -
33611 -MODULE_AUTHOR("Samuel Thibault");
33612 -MODULE_DESCRIPTION("support of qd65xx vlb ide chipset");
33613 -MODULE_LICENSE("GPL");
33614 -
33615 -static int __init qd65xx_mod_init(void)
33616 +/* Can be called directly from ide.c. */
33617 +int __init qd65xx_init(void)
33618  {
33619 -       if (qd_probe(0x30)) qd_probe(0xb0);
33620 +       if (qd_probe(0x30))
33621 +               qd_probe(0xb0);
33622         if (ide_hwifs[0].chipset != ide_qd65xx &&
33623             ide_hwifs[1].chipset != ide_qd65xx)
33624                 return -ENODEV;
33625         return 0;
33626  }
33627 -module_init(qd65xx_mod_init);
33628  
33629 -static void __exit qd65xx_mod_exit(void)
33630 +#ifdef MODULE
33631 +static void __exit qd65xx_exit(void)
33632  {
33633 -       qd_unsetup(0);
33634 -       qd_unsetup(1);
33635 +       qd_unsetup(&ide_hwifs[0]);
33636 +       qd_unsetup(&ide_hwifs[1]);
33637  }
33638 -module_exit(qd65xx_mod_exit);
33639 +
33640 +module_init(qd65xx_init);
33641 +module_exit(qd65xx_exit);
33642  #endif
33643 +
33644 +MODULE_AUTHOR("Samuel Thibault");
33645 +MODULE_DESCRIPTION("support of qd65xx vlb ide chipset");
33646 +MODULE_LICENSE("GPL");
33647 --- linux-2.6.0-test6/drivers/ide/legacy/umc8672.c      2003-09-08 13:58:57.000000000 -0700
33648 +++ 25/drivers/ide/legacy/umc8672.c     2003-10-05 00:33:24.000000000 -0700
33649 @@ -124,16 +124,16 @@ static void tune_umc (ide_drive_t *drive
33650         spin_unlock_irqrestore(&ide_lock, flags);
33651  }
33652  
33653 -int __init probe_umc8672 (void)
33654 +static int __init umc8672_probe(void)
33655  {
33656         unsigned long flags;
33657 +       ide_hwif_t *hwif, *mate;
33658  
33659 -       local_irq_save(flags);
33660         if (!request_region(0x108, 2, "umc8672")) {
33661 -               local_irq_restore(flags);
33662                 printk(KERN_ERR "umc8672: ports 0x108-0x109 already in use.\n");
33663                 return 1;
33664         }
33665 +       local_irq_save(flags);
33666         outb_p(0x5A,0x108); /* enable umc */
33667         if (in_umc (0xd5) != 0xa0) {
33668                 local_irq_restore(flags);
33669 @@ -146,82 +146,62 @@ int __init probe_umc8672 (void)
33670         umc_set_speeds (current_speeds);
33671         local_irq_restore(flags);
33672  
33673 -       ide_hwifs[0].chipset = ide_umc8672;
33674 -       ide_hwifs[1].chipset = ide_umc8672;
33675 -       ide_hwifs[0].tuneproc = &tune_umc;
33676 -       ide_hwifs[1].tuneproc = &tune_umc;
33677 -       ide_hwifs[0].mate = &ide_hwifs[1];
33678 -       ide_hwifs[1].mate = &ide_hwifs[0];
33679 -       ide_hwifs[1].channel = 1;
33680 +       hwif = &ide_hwifs[0];
33681 +       mate = &ide_hwifs[1];
33682  
33683 -       probe_hwif_init(&ide_hwifs[0]);
33684 -       probe_hwif_init(&ide_hwifs[1]);
33685 +       hwif->chipset = ide_umc8672;
33686 +       hwif->tuneproc = &tune_umc;
33687 +       hwif->mate = mate;
33688 +
33689 +       mate->chipset = ide_umc8672;
33690 +       mate->tuneproc = &tune_umc;
33691 +       mate->mate = hwif;
33692 +       mate->channel = 1;
33693 +
33694 +       probe_hwif_init(hwif);
33695 +       probe_hwif_init(mate);
33696  
33697         return 0;
33698  }
33699  
33700 -static void umc8672_release (void)
33701 +/* Can be called directly from ide.c. */
33702 +int __init umc8672_init(void)
33703  {
33704 -       unsigned long flags;
33705 +       if (umc8672_probe())
33706 +               return -ENODEV;
33707 +       return 0;
33708 +}
33709  
33710 -       local_irq_save(flags);
33711 -       if (ide_hwifs[0].chipset != ide_umc8672 &&
33712 -           ide_hwifs[1].chipset != ide_umc8672) {
33713 -               local_irq_restore(flags);
33714 +#ifdef MODULE
33715 +static void __exit umc8672_release_hwif(ide_hwif_t *hwif)
33716 +{
33717 +       if (hwif->chipset != ide_umc8672)
33718                 return;
33719 -       }
33720  
33721 -       ide_hwifs[0].chipset = ide_unknown;
33722 -       ide_hwifs[1].chipset = ide_unknown;     
33723 -       ide_hwifs[0].tuneproc = NULL;
33724 -       ide_hwifs[1].tuneproc = NULL;
33725 -       ide_hwifs[0].mate = NULL;
33726 -       ide_hwifs[1].mate = NULL;
33727 -       ide_hwifs[0].channel = 0;
33728 -       ide_hwifs[1].channel = 0;
33729 -
33730 -       outb_p(0xa5,0x108); /* disable umc */
33731 -
33732 -       release_region(0x108, 2);
33733 -       local_irq_restore(flags);
33734 +       hwif->chipset = ide_unknown;
33735 +       hwif->tuneproc = NULL;
33736 +       hwif->mate = NULL;
33737 +       hwif->channel = 0;
33738  }
33739  
33740 -#ifndef MODULE
33741 -/*
33742 - * init_umc8672:
33743 - *
33744 - * called by ide.c when parsing command line
33745 - */
33746 -
33747 -void __init init_umc8672 (void)
33748 +static void __exit umc8672_exit(void)
33749  {
33750 -       if (probe_umc8672())
33751 -               printk(KERN_ERR "init_umc8672: umc8672 controller not found.\n");
33752 -}
33753 +       unsigned long flags;
33754  
33755 -#else
33756 +       umc8672_release_hwif(&ide_hwifs[0]);
33757 +       umc8672_release_hwif(&ide_hwifs[1]);
33758  
33759 -MODULE_AUTHOR("Wolfram Podien");
33760 -MODULE_DESCRIPTION("Support for UMC 8672 IDE chipset");
33761 -MODULE_LICENSE("GPL");
33762 +       local_irq_save(flags);
33763 +       outb_p(0xa5, 0x108);    /* disable umc */
33764 +       local_irq_restore(flags);
33765  
33766 -static int __init umc8672_mod_init(void)
33767 -{
33768 -       if (probe_umc8672())
33769 -               return -ENODEV;
33770 -       if (ide_hwifs[0].chipset != ide_umc8672 &&
33771 -           ide_hwifs[1].chipset != ide_umc8672) {
33772 -               umc8672_release();
33773 -               return -ENODEV;
33774 -       }
33775 -       return 0;
33776 +       release_region(0x108, 2);
33777  }
33778 -module_init(umc8672_mod_init);
33779  
33780 -static void __exit umc8672_mod_exit(void)
33781 -{
33782 -        umc8672_release();
33783 -}
33784 -module_exit(umc8672_mod_exit);
33785 +module_init(umc8672_init);
33786 +module_exit(umc8672_exit);
33787  #endif
33788  
33789 +MODULE_AUTHOR("Wolfram Podien");
33790 +MODULE_DESCRIPTION("Support for UMC 8672 IDE chipset");
33791 +MODULE_LICENSE("GPL");
33792 --- linux-2.6.0-test6/drivers/ide/pci/amd74xx.c 2003-08-22 19:23:40.000000000 -0700
33793 +++ 25/drivers/ide/pci/amd74xx.c        2003-10-05 00:33:24.000000000 -0700
33794 @@ -1,5 +1,5 @@
33795  /*
33796 - * Version 2.9
33797 + * Version 2.11
33798   *
33799   * AMD 755/756/766/8111 and nVidia nForce IDE driver for Linux.
33800   *
33801 @@ -65,7 +65,6 @@ static struct amd_ide_chip {
33802  };
33803  
33804  static struct amd_ide_chip *amd_config;
33805 -static unsigned char amd_enabled;
33806  static unsigned int amd_80w;
33807  static unsigned int amd_clock;
33808  
33809 @@ -103,7 +102,7 @@ static int amd74xx_get_info(char *buffer
33810  
33811         amd_print("----------AMD BusMastering IDE Configuration----------------");
33812  
33813 -       amd_print("Driver Version:                     2.9");
33814 +       amd_print("Driver Version:                     2.11");
33815         amd_print("South Bridge:                       %s", pci_name(bmide_dev));
33816  
33817         pci_read_config_byte(dev, PCI_REVISION_ID, &t);
33818 @@ -250,9 +249,6 @@ static int amd_set_drive(ide_drive_t *dr
33819  
33820  static void amd74xx_tune_drive(ide_drive_t *drive, u8 pio)
33821  {
33822 -       if (!((amd_enabled >> HWIF(drive)->channel) & 1))
33823 -               return;
33824 -
33825         if (pio == 255) {
33826                 amd_set_drive(drive, ide_find_best_mode(drive, XFER_PIO | XFER_EPIO));
33827                 return;
33828 @@ -330,9 +326,6 @@ static unsigned int __init init_chipset_
33829                         break;
33830         }
33831  
33832 -       pci_read_config_dword(dev, AMD_IDE_ENABLE, &u);
33833 -       amd_enabled = ((u & 1) ? 2 : 0) | ((u & 2) ? 1 : 0);
33834 -
33835  /*
33836   * Take care of prefetch & postwrite.
33837   */
33838 @@ -408,8 +401,8 @@ static void __init init_hwif_amd74xx(ide
33839          hwif->mwdma_mask = 0x07;
33840          hwif->swdma_mask = 0x07;
33841  
33842 -        if (!(hwif->udma_four))
33843 -                hwif->udma_four = ((amd_enabled & amd_80w) >> hwif->channel) & 1;
33844 +       if (!hwif->udma_four)
33845 +               hwif->udma_four = (amd_80w >> hwif->channel) & 1;
33846          hwif->ide_dma_check = &amd74xx_ide_dma_check;
33847          if (!noautodma)
33848                  hwif->autodma = 1;
33849 @@ -417,16 +410,6 @@ static void __init init_hwif_amd74xx(ide
33850          hwif->drives[1].autodma = hwif->autodma;
33851  }
33852  
33853 -/*
33854 - * We allow the BM-DMA driver only work on enabled interfaces.
33855 - */
33856 -
33857 -static void __init init_dma_amd74xx(ide_hwif_t *hwif, unsigned long dmabase)
33858 -{
33859 -       if ((amd_enabled >> hwif->channel) & 1)
33860 -               ide_setup_dma(hwif, dmabase, 8);
33861 -}
33862 -
33863  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
33864  
33865  static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id)
33866 --- linux-2.6.0-test6/drivers/ide/pci/amd74xx.h 2003-06-14 12:17:57.000000000 -0700
33867 +++ 25/drivers/ide/pci/amd74xx.h        2003-10-05 00:33:24.000000000 -0700
33868 @@ -27,7 +27,6 @@ static ide_pci_host_proc_t amd74xx_procs
33869  
33870  static unsigned int init_chipset_amd74xx(struct pci_dev *, const char *);
33871  static void init_hwif_amd74xx(ide_hwif_t *);
33872 -static void init_dma_amd74xx(ide_hwif_t *, unsigned long);
33873  
33874  static ide_pci_device_t amd74xx_chipsets[] __devinitdata = {
33875         {       /* 0 */
33876 @@ -35,9 +34,7 @@ static ide_pci_device_t amd74xx_chipsets
33877                 .device         = PCI_DEVICE_ID_AMD_COBRA_7401,
33878                 .name           = "AMD7401",
33879                 .init_chipset   = init_chipset_amd74xx,
33880 -               .init_iops      = NULL,
33881                 .init_hwif      = init_hwif_amd74xx,
33882 -               .init_dma       = init_dma_amd74xx,
33883                 .channels       = 2,
33884                 .autodma        = AUTODMA,
33885                 .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
33886 @@ -48,9 +45,7 @@ static ide_pci_device_t amd74xx_chipsets
33887                 .device         = PCI_DEVICE_ID_AMD_VIPER_7409,
33888                 .name           = "AMD7409",
33889                 .init_chipset   = init_chipset_amd74xx,
33890 -               .init_iops      = NULL,
33891                 .init_hwif      = init_hwif_amd74xx,
33892 -               .init_dma       = init_dma_amd74xx,
33893                 .channels       = 2,
33894                 .autodma        = AUTODMA,
33895                 .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
33896 @@ -61,9 +56,7 @@ static ide_pci_device_t amd74xx_chipsets
33897                 .device         = PCI_DEVICE_ID_AMD_VIPER_7411,
33898                 .name           = "AMD7411",
33899                 .init_chipset   = init_chipset_amd74xx,
33900 -               .init_iops      = NULL,
33901                 .init_hwif      = init_hwif_amd74xx,
33902 -               .init_dma       = init_dma_amd74xx,
33903                 .channels       = 2,
33904                 .autodma        = AUTODMA,
33905                 .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
33906 @@ -74,9 +67,7 @@ static ide_pci_device_t amd74xx_chipsets
33907                 .device         = PCI_DEVICE_ID_AMD_OPUS_7441,
33908                 .name           = "AMD7441",
33909                 .init_chipset   = init_chipset_amd74xx,
33910 -               .init_iops      = NULL,
33911                 .init_hwif      = init_hwif_amd74xx,
33912 -               .init_dma       = init_dma_amd74xx,
33913                 .channels       = 2,
33914                 .autodma        = AUTODMA,
33915                 .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
33916 @@ -87,9 +78,7 @@ static ide_pci_device_t amd74xx_chipsets
33917                 .device         = PCI_DEVICE_ID_AMD_8111_IDE,
33918                 .name           = "AMD8111",
33919                 .init_chipset   = init_chipset_amd74xx,
33920 -               .init_iops      = NULL,
33921                 .init_hwif      = init_hwif_amd74xx,
33922 -               .init_dma       = init_dma_amd74xx,
33923                 .autodma        = AUTODMA,
33924                 .channels       = 2,
33925                 .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
33926 @@ -101,9 +90,7 @@ static ide_pci_device_t amd74xx_chipsets
33927                 .device         = PCI_DEVICE_ID_NVIDIA_NFORCE_IDE,
33928                 .name           = "NFORCE",
33929                 .init_chipset   = init_chipset_amd74xx,
33930 -               .init_iops      = NULL,
33931                 .init_hwif      = init_hwif_amd74xx,
33932 -               .init_dma       = init_dma_amd74xx,
33933                 .channels       = 2,
33934                 .autodma        = AUTODMA,
33935                 .enablebits     = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
33936 @@ -115,9 +102,7 @@ static ide_pci_device_t amd74xx_chipsets
33937                 .device         = PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE,
33938                 .name           = "NFORCE2",
33939                 .init_chipset   = init_chipset_amd74xx,
33940 -               .init_iops      = NULL,
33941                 .init_hwif      = init_hwif_amd74xx,
33942 -               .init_dma       = init_dma_amd74xx,
33943                 .channels       = 2,
33944                 .autodma        = AUTODMA,
33945                 .enablebits     = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
33946 --- linux-2.6.0-test6/drivers/ide/pci/cmd64x.c  2003-09-08 13:58:57.000000000 -0700
33947 +++ 25/drivers/ide/pci/cmd64x.c 2003-10-05 00:33:24.000000000 -0700
33948 @@ -742,11 +742,6 @@ static void __init init_hwif_cmd64x (ide
33949         hwif->drives[1].autodma = hwif->autodma;
33950  }
33951  
33952 -static void __init init_dma_cmd64x (ide_hwif_t *hwif, unsigned long dmabase)
33953 -{
33954 -       ide_setup_dma(hwif, dmabase, 8);
33955 -}
33956 -
33957  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
33958  
33959  static int __devinit cmd64x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
33960 --- linux-2.6.0-test6/drivers/ide/pci/cmd64x.h  2003-06-14 12:18:08.000000000 -0700
33961 +++ 25/drivers/ide/pci/cmd64x.h 2003-10-05 00:33:24.000000000 -0700
33962 @@ -81,7 +81,6 @@ static ide_pci_host_proc_t cmd64x_procs[
33963  
33964  static unsigned int init_chipset_cmd64x(struct pci_dev *, const char *);
33965  static void init_hwif_cmd64x(ide_hwif_t *);
33966 -static void init_dma_cmd64x(ide_hwif_t *, unsigned long);
33967  
33968  static ide_pci_device_t cmd64x_chipsets[] __devinitdata = {
33969         {       /* 0 */
33970 @@ -91,7 +90,6 @@ static ide_pci_device_t cmd64x_chipsets[
33971                 .init_chipset   = init_chipset_cmd64x,
33972                 .init_iops      = NULL,
33973                 .init_hwif      = init_hwif_cmd64x,
33974 -               .init_dma       = init_dma_cmd64x,
33975                 .channels       = 2,
33976                 .autodma        = AUTODMA,
33977                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
33978 @@ -104,7 +102,6 @@ static ide_pci_device_t cmd64x_chipsets[
33979                 .init_chipset   = init_chipset_cmd64x,
33980                 .init_iops      = NULL,
33981                 .init_hwif      = init_hwif_cmd64x,
33982 -               .init_dma       = init_dma_cmd64x,
33983                 .channels       = 2,
33984                 .autodma        = AUTODMA,
33985                 .enablebits     = {{0x00,0x00,0x00}, {0x51,0x80,0x80}},
33986 @@ -117,7 +114,6 @@ static ide_pci_device_t cmd64x_chipsets[
33987                 .init_chipset   = init_chipset_cmd64x,
33988                 .init_iops      = NULL,
33989                 .init_hwif      = init_hwif_cmd64x,
33990 -               .init_dma       = init_dma_cmd64x,
33991                 .channels       = 2,
33992                 .autodma        = AUTODMA,
33993                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
33994 @@ -130,7 +126,6 @@ static ide_pci_device_t cmd64x_chipsets[
33995                 .init_chipset   = init_chipset_cmd64x,
33996                 .init_iops      = NULL,
33997                 .init_hwif      = init_hwif_cmd64x,
33998 -               .init_dma       = init_dma_cmd64x,
33999                 .channels       = 2,
34000                 .autodma        = AUTODMA,
34001                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34002 --- linux-2.6.0-test6/drivers/ide/pci/cs5530.c  2003-09-08 13:58:57.000000000 -0700
34003 +++ 25/drivers/ide/pci/cs5530.c 2003-10-05 00:33:24.000000000 -0700
34004 @@ -404,19 +404,6 @@ static void __init init_hwif_cs5530 (ide
34005         hwif->drives[1].autodma = hwif->autodma;
34006  }
34007  
34008 -/**
34009 - *     init_dma_cs5530         -       set up for DMA
34010 - *     @hwif: interface
34011 - *     @dmabase: DMA base address
34012 - *
34013 - *     FIXME: this can go away
34014 - */
34015
34016 -static void __init init_dma_cs5530 (ide_hwif_t *hwif, unsigned long dmabase)
34017 -{
34018 -       ide_setup_dma(hwif, dmabase, 8);
34019 -}
34020 -
34021  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
34022  
34023  
34024 --- linux-2.6.0-test6/drivers/ide/pci/cs5530.h  2003-06-14 12:17:57.000000000 -0700
34025 +++ 25/drivers/ide/pci/cs5530.h 2003-10-05 00:33:24.000000000 -0700
34026 @@ -27,7 +27,6 @@ static ide_pci_host_proc_t cs5530_procs[
34027  
34028  static unsigned int init_chipset_cs5530(struct pci_dev *, const char *);
34029  static void init_hwif_cs5530(ide_hwif_t *);
34030 -static void init_dma_cs5530(ide_hwif_t *, unsigned long);
34031  
34032  static ide_pci_device_t cs5530_chipsets[] __devinitdata = {
34033         {       /* 0 */
34034 @@ -37,7 +36,6 @@ static ide_pci_device_t cs5530_chipsets[
34035                 .init_chipset   = init_chipset_cs5530,
34036                 .init_iops      = NULL,
34037                 .init_hwif      = init_hwif_cs5530,
34038 -               .init_dma       = init_dma_cs5530,
34039                 .channels       = 2,
34040                 .autodma        = AUTODMA,
34041                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34042 --- linux-2.6.0-test6/drivers/ide/pci/generic.c 2003-09-08 13:58:57.000000000 -0700
34043 +++ 25/drivers/ide/pci/generic.c        2003-10-05 00:33:24.000000000 -0700
34044 @@ -72,11 +72,6 @@ static void __init init_hwif_generic (id
34045         hwif->drives[1].autodma = hwif->autodma;
34046  }
34047  
34048 -static void init_dma_generic (ide_hwif_t *hwif, unsigned long dmabase)
34049 -{
34050 -       ide_setup_dma(hwif, dmabase, 8);
34051 -}
34052 -
34053  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
34054  
34055  #if 0
34056 --- linux-2.6.0-test6/drivers/ide/pci/generic.h 2003-09-08 13:58:57.000000000 -0700
34057 +++ 25/drivers/ide/pci/generic.h        2003-10-05 00:33:24.000000000 -0700
34058 @@ -7,7 +7,6 @@
34059  
34060  static unsigned int init_chipset_generic(struct pci_dev *, const char *);
34061  static void init_hwif_generic(ide_hwif_t *);
34062 -static void init_dma_generic(ide_hwif_t *, unsigned long);
34063  
34064  static ide_pci_device_t generic_chipsets[] __devinitdata = {
34065         {       /* 0 */
34066 @@ -17,7 +16,6 @@ static ide_pci_device_t generic_chipsets
34067                 .init_chipset   = init_chipset_generic,
34068                 .init_iops      = NULL,
34069                 .init_hwif      = init_hwif_generic,
34070 -               .init_dma       = init_dma_generic,
34071                 .channels       = 2,
34072                 .autodma        = AUTODMA,
34073                 .enablebits     = {{0x43,0x08,0x08}, {0x47,0x08,0x08}},
34074 @@ -30,7 +28,6 @@ static ide_pci_device_t generic_chipsets
34075                 .init_chipset   = init_chipset_generic,
34076                 .init_iops      = NULL,
34077                 .init_hwif      = init_hwif_generic,
34078 -               .init_dma       = init_dma_generic,
34079                 .channels       = 2,
34080                 .autodma        = AUTODMA,
34081                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34082 @@ -43,7 +40,6 @@ static ide_pci_device_t generic_chipsets
34083                 .init_chipset   = init_chipset_generic,
34084                 .init_iops      = NULL,
34085                 .init_hwif      = init_hwif_generic,
34086 -               .init_dma       = init_dma_generic,
34087                 .channels       = 2,
34088                 .autodma        = AUTODMA,
34089                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34090 @@ -56,7 +52,6 @@ static ide_pci_device_t generic_chipsets
34091                 .init_chipset   = init_chipset_generic,
34092                 .init_iops      = NULL,
34093                 .init_hwif      = init_hwif_generic,
34094 -               .init_dma       = init_dma_generic,
34095                 .channels       = 2,
34096                 .autodma        = NODMA,
34097                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34098 @@ -69,7 +64,6 @@ static ide_pci_device_t generic_chipsets
34099                 .init_chipset   = init_chipset_generic,
34100                 .init_iops      = NULL,
34101                 .init_hwif      = init_hwif_generic,
34102 -               .init_dma       = init_dma_generic,
34103                 .channels       = 2,
34104                 .autodma        = NODMA,
34105                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34106 @@ -82,7 +76,6 @@ static ide_pci_device_t generic_chipsets
34107                 .init_chipset   = init_chipset_generic,
34108                 .init_iops      = NULL,
34109                 .init_hwif      = init_hwif_generic,
34110 -               .init_dma       = init_dma_generic,
34111                 .channels       = 2,
34112                 .autodma        = NODMA,
34113                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34114 @@ -95,7 +88,6 @@ static ide_pci_device_t generic_chipsets
34115                 .init_chipset   = init_chipset_generic,
34116                 .init_iops      = NULL,
34117                 .init_hwif      = init_hwif_generic,
34118 -               .init_dma       = init_dma_generic,
34119                 .channels       = 2,
34120                 .autodma        = AUTODMA,
34121                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34122 @@ -108,7 +100,6 @@ static ide_pci_device_t generic_chipsets
34123                 .init_chipset   = init_chipset_generic,
34124                 .init_iops      = NULL,
34125                 .init_hwif      = init_hwif_generic,
34126 -               .init_dma       = init_dma_generic,
34127                 .channels       = 2,
34128                 .autodma        = NOAUTODMA,
34129                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34130 @@ -121,7 +112,6 @@ static ide_pci_device_t generic_chipsets
34131                 .init_chipset   = init_chipset_generic,
34132                 .init_iops      = NULL,
34133                 .init_hwif      = init_hwif_generic,
34134 -               .init_dma       = init_dma_generic,
34135                 .channels       = 2,
34136                 .autodma        = NOAUTODMA,
34137                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34138 @@ -134,7 +124,6 @@ static ide_pci_device_t generic_chipsets
34139                 .init_chipset   = init_chipset_generic,
34140                 .init_iops      = NULL,
34141                 .init_hwif      = init_hwif_generic,
34142 -               .init_dma       = init_dma_generic,
34143                 .channels       = 2,
34144                 .autodma        = AUTODMA,
34145                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34146 @@ -157,7 +146,6 @@ static ide_pci_device_t unknown_chipset[
34147                 .init_chipset   = init_chipset_generic,
34148                 .init_iops      = NULL,
34149                 .init_hwif      = init_hwif_generic,
34150 -               .init_dma       = init_dma_generic,
34151                 .channels       = 2,
34152                 .autodma        = AUTODMA,
34153                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34154 --- linux-2.6.0-test6/drivers/ide/pci/hpt34x.c  2003-09-08 13:58:57.000000000 -0700
34155 +++ 25/drivers/ide/pci/hpt34x.c 2003-10-05 00:33:24.000000000 -0700
34156 @@ -315,11 +315,6 @@ static void __init init_hwif_hpt34x (ide
34157         hwif->drives[1].autodma = hwif->autodma;
34158  }
34159  
34160 -static void __init init_dma_hpt34x (ide_hwif_t *hwif, unsigned long dmabase)
34161 -{
34162 -       ide_setup_dma(hwif, dmabase, 8);
34163 -}
34164 -
34165  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
34166  
34167  static int __devinit hpt34x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
34168 --- linux-2.6.0-test6/drivers/ide/pci/hpt34x.h  2003-06-14 12:17:56.000000000 -0700
34169 +++ 25/drivers/ide/pci/hpt34x.h 2003-10-05 00:33:24.000000000 -0700
34170 @@ -33,7 +33,6 @@ static ide_pci_host_proc_t hpt34x_procs[
34171  
34172  static unsigned int init_chipset_hpt34x(struct pci_dev *, const char *);
34173  static void init_hwif_hpt34x(ide_hwif_t *);
34174 -static void init_dma_hpt34x(ide_hwif_t *, unsigned long);
34175  
34176  static ide_pci_device_t hpt34x_chipsets[] __devinitdata = {
34177         {       /* 0 */
34178 @@ -43,7 +42,6 @@ static ide_pci_device_t hpt34x_chipsets[
34179                 .init_chipset   = init_chipset_hpt34x,
34180                 .init_iops      = NULL,
34181                 .init_hwif      = init_hwif_hpt34x,
34182 -               .init_dma       = init_dma_hpt34x,
34183                 .channels       = 2,
34184                 .autodma        = NOAUTODMA,
34185                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34186 --- linux-2.6.0-test6/drivers/ide/pci/it8172.c  2003-09-08 13:58:57.000000000 -0700
34187 +++ 25/drivers/ide/pci/it8172.c 2003-10-05 00:33:24.000000000 -0700
34188 @@ -284,11 +284,6 @@ static void __init init_hwif_it8172 (ide
34189         hwif->drives[1].autodma = hwif->autodma;
34190  }
34191  
34192 -static void __init init_dma_it8172 (ide_hwif_t *hwif, unsigned long dmabase)
34193 -{
34194 -       ide_setup_dma(hwif, dmabase, 8);
34195 -}
34196 -
34197  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
34198  
34199  static int __devinit it8172_init_one(struct pci_dev *dev, const struct pci_device_id *id)
34200 --- linux-2.6.0-test6/drivers/ide/pci/it8172.h  2003-06-14 12:18:08.000000000 -0700
34201 +++ 25/drivers/ide/pci/it8172.h 2003-10-05 00:33:24.000000000 -0700
34202 @@ -17,7 +17,6 @@ static int it8172_config_chipset_for_dma
34203  static void init_setup_it8172(struct pci_dev *, ide_pci_device_t *);
34204  static unsigned int init_chipset_it8172(struct pci_dev *, const char *);
34205  static void init_hwif_it8172(ide_hwif_t *);
34206 -static void init_dma_it8172(ide_hwif_t *, unsigned long);
34207  
34208  static ide_pci_device_t it8172_chipsets[] __devinitdata = {
34209         {       /* 0 */
34210 @@ -28,7 +27,6 @@ static ide_pci_device_t it8172_chipsets[
34211                 .init_chipset   = init_chipset_it8172,
34212                 .init_iops      = NULL,
34213                 .init_hwif      = init_hwif_it8172,
34214 -                .init_dma      = init_dma_it8172,
34215                 .channels       = 2,
34216                 .autodma        = AUTODMA,
34217                 .enablebits     = {{0x00,0x00,0x00}, {0x40,0x00,0x01}},
34218 --- linux-2.6.0-test6/drivers/ide/pci/Makefile  2003-06-14 12:17:59.000000000 -0700
34219 +++ 25/drivers/ide/pci/Makefile 2003-10-05 00:36:28.000000000 -0700
34220 @@ -18,10 +18,10 @@ obj-$(CONFIG_BLK_DEV_NS87415)               += ns8741
34221  obj-$(CONFIG_BLK_DEV_OPTI621)          += opti621.o
34222  obj-$(CONFIG_BLK_DEV_PDC202XX_OLD)     += pdc202xx_old.o
34223  obj-$(CONFIG_BLK_DEV_PDC202XX_NEW)     += pdc202xx_new.o
34224 -obj-$(CONFIG_BLK_DEV_PDC_ADMA)         += pdcadma.o ide-adma.o
34225  obj-$(CONFIG_BLK_DEV_PIIX)             += piix.o
34226  obj-$(CONFIG_BLK_DEV_RZ1000)           += rz1000.o
34227  obj-$(CONFIG_BLK_DEV_SVWKS)            += serverworks.o
34228 +obj-$(CONFIG_BLK_DEV_SGIIOC4)          += sgiioc4.o
34229  obj-$(CONFIG_BLK_DEV_SIIMAGE)          += siimage.o
34230  obj-$(CONFIG_BLK_DEV_SIS5513)          += sis5513.o
34231  obj-$(CONFIG_BLK_DEV_SL82C105)         += sl82c105.o
34232 --- linux-2.6.0-test6/drivers/ide/pci/ns87415.c 2003-09-08 13:58:57.000000000 -0700
34233 +++ 25/drivers/ide/pci/ns87415.c        2003-10-05 00:33:24.000000000 -0700
34234 @@ -217,11 +217,6 @@ static void __init init_hwif_ns87415 (id
34235         hwif->drives[1].autodma = hwif->autodma;
34236  }
34237  
34238 -static void __init init_dma_ns87415 (ide_hwif_t *hwif, unsigned long dmabase)
34239 -{
34240 -       ide_setup_dma(hwif, dmabase, 8);
34241 -}
34242 -
34243  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
34244  
34245  static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_device_id *id)
34246 --- linux-2.6.0-test6/drivers/ide/pci/ns87415.h 2003-06-14 12:17:57.000000000 -0700
34247 +++ 25/drivers/ide/pci/ns87415.h        2003-10-05 00:33:24.000000000 -0700
34248 @@ -6,7 +6,6 @@
34249  #include <linux/ide.h>
34250  
34251  static void init_hwif_ns87415(ide_hwif_t *);
34252 -static void init_dma_ns87415(ide_hwif_t *, unsigned long);
34253  
34254  static ide_pci_device_t ns87415_chipsets[] __devinitdata = {
34255         {       /* 0 */
34256 @@ -16,7 +15,6 @@ static ide_pci_device_t ns87415_chipsets
34257                 .init_chipset   = NULL,
34258                 .init_iops      = NULL,
34259                 .init_hwif      = init_hwif_ns87415,
34260 -                .init_dma      = init_dma_ns87415,
34261                 .channels       = 2,
34262                 .autodma        = AUTODMA,
34263                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34264 --- linux-2.6.0-test6/drivers/ide/pci/opti621.c 2003-09-08 13:58:57.000000000 -0700
34265 +++ 25/drivers/ide/pci/opti621.c        2003-10-05 00:33:24.000000000 -0700
34266 @@ -348,11 +348,6 @@ static void __init init_hwif_opti621 (id
34267         hwif->drives[1].autodma = hwif->autodma;
34268  }
34269  
34270 -static void __init init_dma_opti621 (ide_hwif_t *hwif, unsigned long dmabase)
34271 -{
34272 -       ide_setup_dma(hwif, dmabase, 8);
34273 -}
34274 -
34275  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
34276  
34277  static void __init init_setup_opti621 (struct pci_dev *dev, ide_pci_device_t *d)
34278 --- linux-2.6.0-test6/drivers/ide/pci/opti621.h 2003-06-14 12:18:33.000000000 -0700
34279 +++ 25/drivers/ide/pci/opti621.h        2003-10-05 00:33:24.000000000 -0700
34280 @@ -7,7 +7,6 @@
34281  
34282  static void init_setup_opti621(struct pci_dev *, ide_pci_device_t *);
34283  static void init_hwif_opti621(ide_hwif_t *);
34284 -static void init_dma_opti621(ide_hwif_t *, unsigned long);
34285  
34286  static ide_pci_device_t opti621_chipsets[] __devinitdata = {
34287         {       /* 0 */
34288 @@ -18,7 +17,6 @@ static ide_pci_device_t opti621_chipsets
34289                 .init_chipset   = NULL,
34290                 .init_iops      = NULL,
34291                 .init_hwif      = init_hwif_opti621,
34292 -               .init_dma       = init_dma_opti621,
34293                 .channels       = 2,
34294                 .autodma        = AUTODMA,
34295                 .enablebits     = {{0x45,0x80,0x00}, {0x40,0x08,0x00}},
34296 @@ -32,7 +30,6 @@ static ide_pci_device_t opti621_chipsets
34297                 .init_chipset   = NULL,
34298                 .init_iops      = NULL,
34299                 .init_hwif      = init_hwif_opti621,
34300 -                .init_dma      = init_dma_opti621,
34301                 .channels       = 2,
34302                 .autodma        = AUTODMA,
34303                 .enablebits     = {{0x45,0x80,0x00}, {0x40,0x08,0x00}},
34304 --- linux-2.6.0-test6/drivers/ide/pci/pdc202xx_new.c    2003-09-08 13:58:57.000000000 -0700
34305 +++ 25/drivers/ide/pci/pdc202xx_new.c   2003-10-05 00:33:24.000000000 -0700
34306 @@ -563,11 +563,6 @@ static void __init init_hwif_pdc202new (
34307  #endif /* PDC202_DEBUG_CABLE */
34308  }
34309  
34310 -static void __init init_dma_pdc202new (ide_hwif_t *hwif, unsigned long dmabase)
34311 -{
34312 -       ide_setup_dma(hwif, dmabase, 8);
34313 -}
34314 -
34315  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
34316  extern void ide_setup_pci_devices(struct pci_dev *, struct pci_dev *, ide_pci_device_t *);
34317  
34318 --- linux-2.6.0-test6/drivers/ide/pci/pdc202xx_new.h    2003-06-14 12:17:57.000000000 -0700
34319 +++ 25/drivers/ide/pci/pdc202xx_new.h   2003-10-05 00:33:24.000000000 -0700
34320 @@ -188,7 +188,6 @@ static void init_setup_pdc20270(struct p
34321  static void init_setup_pdc20276(struct pci_dev *dev, ide_pci_device_t *d);
34322  static unsigned int init_chipset_pdcnew(struct pci_dev *, const char *);
34323  static void init_hwif_pdc202new(ide_hwif_t *);
34324 -static void init_dma_pdc202new(ide_hwif_t *, unsigned long);
34325  
34326  static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
34327         {       /* 0 */
34328 @@ -199,7 +198,6 @@ static ide_pci_device_t pdcnew_chipsets[
34329                 .init_chipset   = init_chipset_pdcnew,
34330                 .init_iops      = NULL,
34331                 .init_hwif      = init_hwif_pdc202new,
34332 -               .init_dma       = init_dma_pdc202new,
34333                 .channels       = 2,
34334                 .autodma        = AUTODMA,
34335                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34336 @@ -213,7 +211,6 @@ static ide_pci_device_t pdcnew_chipsets[
34337                 .init_chipset   = init_chipset_pdcnew,
34338                 .init_iops      = NULL,
34339                 .init_hwif      = init_hwif_pdc202new,
34340 -               .init_dma       = init_dma_pdc202new,
34341                 .channels       = 2,
34342                 .autodma        = AUTODMA,
34343                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34344 @@ -227,7 +224,6 @@ static ide_pci_device_t pdcnew_chipsets[
34345                 .init_chipset   = init_chipset_pdcnew,
34346                 .init_iops      = NULL,
34347                 .init_hwif      = init_hwif_pdc202new,
34348 -               .init_dma       = init_dma_pdc202new,
34349                 .channels       = 2,
34350                 .autodma        = AUTODMA,
34351  #ifdef CONFIG_PDC202XX_FORCE
34352 @@ -245,7 +241,6 @@ static ide_pci_device_t pdcnew_chipsets[
34353                 .init_chipset   = init_chipset_pdcnew,
34354                 .init_iops      = NULL,
34355                 .init_hwif      = init_hwif_pdc202new,
34356 -               .init_dma       = init_dma_pdc202new,
34357                 .channels       = 2,
34358                 .autodma        = AUTODMA,
34359                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34360 @@ -259,7 +254,6 @@ static ide_pci_device_t pdcnew_chipsets[
34361                 .init_chipset   = init_chipset_pdcnew,
34362                 .init_iops      = NULL,
34363                 .init_hwif      = init_hwif_pdc202new,
34364 -               .init_dma       = init_dma_pdc202new,
34365                 .channels       = 2,
34366                 .autodma        = AUTODMA,
34367                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34368 @@ -273,7 +267,6 @@ static ide_pci_device_t pdcnew_chipsets[
34369                 .init_chipset   = init_chipset_pdcnew,
34370                 .init_iops      = NULL,
34371                 .init_hwif      = init_hwif_pdc202new,
34372 -               .init_dma       = init_dma_pdc202new,
34373                 .channels       = 2,
34374                 .autodma        = AUTODMA,
34375  #ifdef CONFIG_PDC202XX_FORCE
34376 @@ -291,7 +284,6 @@ static ide_pci_device_t pdcnew_chipsets[
34377                 .init_chipset   = init_chipset_pdcnew,
34378                 .init_iops      = NULL,
34379                 .init_hwif      = init_hwif_pdc202new,
34380 -               .init_dma       = init_dma_pdc202new,
34381                 .channels       = 2,
34382                 .autodma        = AUTODMA,
34383                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34384 --- linux-2.6.0-test6/drivers/ide/pci/pdcadma.c 2003-09-08 13:58:57.000000000 -0700
34385 +++ /dev/null   2002-08-30 16:31:37.000000000 -0700
34386 @@ -1,162 +0,0 @@
34387 -/*
34388 - * linux/drivers/ide/pci/pdcadma.c             Version 0.05    Sept 10, 2002
34389 - *
34390 - * Copyright (C) 1999-2000             Andre Hedrick <andre@linux-ide.org>
34391 - * May be copied or modified under the terms of the GNU General Public License
34392 - *
34393 - */
34394 -
34395 -#include <linux/config.h>
34396 -#include <linux/types.h>
34397 -#include <linux/kernel.h>
34398 -#include <linux/delay.h>
34399 -#include <linux/timer.h>
34400 -#include <linux/mm.h>
34401 -#include <linux/ioport.h>
34402 -#include <linux/blkdev.h>
34403 -#include <linux/hdreg.h>
34404 -
34405 -#include <linux/interrupt.h>
34406 -#include <linux/init.h>
34407 -#include <linux/pci.h>
34408 -#include <linux/ide.h>
34409 -
34410 -#include <asm/io.h>
34411 -#include <asm/irq.h>
34412 -
34413 -#include "pdcadma.h"
34414 -
34415 -#if defined(DISPLAY_PDCADMA_TIMINGS) && defined(CONFIG_PROC_FS)
34416 -#include <linux/stat.h>
34417 -#include <linux/proc_fs.h>
34418 -
34419 -static u8 pdcadma_proc = 0;
34420 -#define PDC_MAX_DEVS           5
34421 -static struct pci_dev *pdc_devs[PDC_MAX_DEVS];
34422 -static int n_pdc_devs;
34423 -
34424 -static int pdcadma_get_info (char *buffer, char **addr, off_t offset, int count)
34425 -{
34426 -       char *p = buffer;
34427 -       int i;
34428 -
34429 -       for (i = 0; i < n_pdc_devs; i++) {
34430 -               struct pci_dev *dev     = pdc_devs[i];
34431 -               unsigned long bibma = pci_resource_start(dev, 4);
34432 -
34433 -               p += sprintf(p, "\n                                "
34434 -                       "PDC ADMA %04X Chipset.\n", dev->device);
34435 -               p += sprintf(p, "UDMA\n");
34436 -               p += sprintf(p, "PIO\n");
34437 -
34438 -       }
34439 -       return p-buffer;        /* => must be less than 4k! */
34440 -}
34441 -#endif  /* defined(DISPLAY_PDCADMA_TIMINGS) && defined(CONFIG_PROC_FS) */
34442 -
34443 -/*
34444 - * pdcadma_dma functions() initiates/aborts (U)DMA read/write
34445 - * operations on a drive.
34446 - */
34447 -#if 0
34448 -        int (*ide_dma_read)(ide_drive_t *drive);
34449 -        int (*ide_dma_write)(ide_drive_t *drive);
34450 -        int (*ide_dma_begin)(ide_drive_t *drive);
34451 -        int (*ide_dma_end)(ide_drive_t *drive);
34452 -        int (*ide_dma_check)(ide_drive_t *drive);
34453 -        int (*ide_dma_on)(ide_drive_t *drive);
34454 -        int (*ide_dma_off)(ide_drive_t *drive);
34455 -        int (*ide_dma_off_quietly)(ide_drive_t *drive);
34456 -        int (*ide_dma_test_irq)(ide_drive_t *drive);
34457 -        int (*ide_dma_host_on)(ide_drive_t *drive);
34458 -        int (*ide_dma_host_off)(ide_drive_t *drive);
34459 -        int (*ide_dma_bad_drive)(ide_drive_t *drive);
34460 -        int (*ide_dma_good_drive)(ide_drive_t *drive);
34461 -        int (*ide_dma_count)(ide_drive_t *drive);
34462 -        int (*ide_dma_verbose)(ide_drive_t *drive);
34463 -        int (*ide_dma_retune)(ide_drive_t *drive);
34464 -        int (*ide_dma_lostirq)(ide_drive_t *drive);
34465 -        int (*ide_dma_timeout)(ide_drive_t *drive);
34466 -
34467 -#endif
34468 -
34469 -static unsigned int __init init_chipset_pdcadma (struct pci_dev *dev, const char *name)
34470 -{
34471 -#if defined(DISPLAY_PDCADMA_TIMINGS) && defined(CONFIG_PROC_FS)
34472 -       pdc_devs[n_pdc_devs++] = dev;
34473 -
34474 -       if (!pdcadma_proc) {
34475 -               pdcadma_proc = 1;
34476 -               ide_pci_register_host_proc(&pdcadma_procs[0]);
34477 -       }
34478 -#endif /* DISPLAY_PDCADMA_TIMINGS && CONFIG_PROC_FS */
34479 -       return 0;
34480 -}
34481 -
34482 -static void __init init_hwif_pdcadma (ide_hwif_t *hwif)
34483 -{
34484 -       hwif->autodma = 0;
34485 -       hwif->dma_base = 0;
34486 -
34487 -//     hwif->tuneproc = &pdcadma_tune_drive;
34488 -//     hwif->speedproc = &pdcadma_tune_chipset;
34489 -
34490 -//     if (hwif->dma_base) {
34491 -//             hwif->autodma = 1;
34492 -//     }
34493 -
34494 -       hwif->udma_four = 1;
34495 -
34496 -//     hwif->atapi_dma = 1;
34497 -//     hwif->ultra_mask = 0x7f;
34498 -//     hwif->mwdma_mask = 0x07;
34499 -//     hwif->swdma_mask = 0x07;
34500 -
34501 -}
34502 -
34503 -static void __init init_dma_pdcadma (ide_hwif_t *hwif, unsigned long dmabase)
34504 -{
34505 -#if 0
34506 -       ide_setup_dma(hwif, dmabase, 8);
34507 -#endif
34508 -}
34509 -
34510 -extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
34511 -
34512 -static int __devinit pdcadma_init_one(struct pci_dev *dev, const struct pci_device_id *id)
34513 -{
34514 -       ide_pci_device_t *d = &pdcadma_chipsets[id->driver_data];
34515 -       if (dev->device != d->device)
34516 -               BUG();
34517 -       ide_setup_pci_device(dev, d);
34518 -       MOD_INC_USE_COUNT;
34519 -       return 1;
34520 -}
34521 -
34522 -static struct pci_device_id pdcadma_pci_tbl[] = {
34523 -       { PCI_VENDOR_ID_PDC, PCI_DEVICE_ID_PDC_1841, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
34524 -       { 0, },
34525 -};
34526 -
34527 -static struct pci_driver driver = {
34528 -       .name           = "PDCADMA-IDE",
34529 -       .id_table       = pdcadma_pci_tbl,
34530 -       .probe          = pdcadma_init_one,
34531 -};
34532 -
34533 -static int pdcadma_ide_init(void)
34534 -{
34535 -       return ide_pci_register_driver(&driver);
34536 -}
34537 -
34538 -static void pdcadma_ide_exit(void)
34539 -{
34540 -       ide_pci_unregister_driver(&driver);
34541 -}
34542 -
34543 -module_init(pdcadma_ide_init);
34544 -module_exit(pdcadma_ide_exit);
34545 -
34546 -MODULE_AUTHOR("Andre Hedrick");
34547 -MODULE_DESCRIPTION("PCI driver module for PDCADMA IDE");
34548 -MODULE_LICENSE("GPL");
34549 --- linux-2.6.0-test6/drivers/ide/pci/pdcadma.h 2003-06-14 12:17:56.000000000 -0700
34550 +++ /dev/null   2002-08-30 16:31:37.000000000 -0700
34551 @@ -1,56 +0,0 @@
34552 -#ifndef PDC_ADMA_H
34553 -#define PDC_ADMA_H
34554 -
34555 -#include <linux/config.h>
34556 -#include <linux/pci.h>
34557 -#include <linux/ide.h>
34558 -
34559 -#undef DISPLAY_PDCADMA_TIMINGS
34560 -
34561 -#if defined(DISPLAY_PDCADMA_TIMINGS) && defined(CONFIG_PROC_FS)
34562 -#include <linux/stat.h>
34563 -#include <linux/proc_fs.h>
34564 -
34565 -static u8 pdcadma_proc;
34566 -
34567 -static int pdcadma_get_info(char *, char **, off_t, int);
34568 -
34569 -static ide_pci_host_proc_t pdcadma_procs[] __initdata = {
34570 -       {
34571 -               .name           = "pdcadma",
34572 -               .set            = 1,
34573 -               .get_info       = pdcadma_get_info,
34574 -               .parent         = NULL,
34575 -       },
34576 -};
34577 -#endif  /* defined(DISPLAY_PDCADMA_TIMINGS) && defined(CONFIG_PROC_FS) */
34578 -
34579 -static void init_setup_pdcadma(struct pci_dev *, ide_pci_device_t *);
34580 -static unsigned int init_chipset_pdcadma(struct pci_dev *, const char *);
34581 -static void init_hwif_pdcadma(ide_hwif_t *);
34582 -static void init_dma_pdcadma(ide_hwif_t *, unsigned long);
34583 -
34584 -static ide_pci_device_t pdcadma_chipsets[] __devinitdata = {
34585 -       {       /* 0 */
34586 -               .vendor         = PCI_VENDOR_ID_PDC,
34587 -               .device         = PCI_DEVICE_ID_PDC_1841,
34588 -               .name           = "PDCADMA",
34589 -               .init_setup     = init_setup_pdcadma,
34590 -               .init_chipset   = init_chipset_pdcadma,
34591 -               .init_iops      = NULL,
34592 -               .init_hwif      = init_hwif_pdcadma,
34593 -               .init_dma       = init_dma_pdcadma,
34594 -               .channels       = 2,
34595 -               .autodma        = NODMA,
34596 -               .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34597 -               .bootable       = OFF_BOARD,
34598 -               .extra          = 0,
34599 -       },{
34600 -               .vendor         = 0,
34601 -               .device         = 0,
34602 -               .channels       = 0,
34603 -               .bootable       = EOL,
34604 -       }
34605 -};
34606 -
34607 -#endif /* PDC_ADMA_H */
34608 --- linux-2.6.0-test6/drivers/ide/pci/piix.c    2003-09-08 13:58:57.000000000 -0700
34609 +++ 25/drivers/ide/pci/piix.c   2003-10-05 00:33:24.000000000 -0700
34610 @@ -709,21 +709,6 @@ static void __init init_hwif_piix (ide_h
34611         hwif->drives[0].autodma = hwif->autodma;
34612  }
34613  
34614 -/**
34615 - *     init_dma_piix           -       set up the PIIX DMA
34616 - *     @hwif: IDE interface
34617 - *     @dmabase: DMA PCI base
34618 - *
34619 - *     Set up the DMA on the PIIX controller, providing a DMA base is
34620 - *     available. The PIIX follows the normal specs so we do nothing
34621 - *     magical here.
34622 - */
34623 -
34624 -static void __init init_dma_piix (ide_hwif_t *hwif, unsigned long dmabase)
34625 -{
34626 -       ide_setup_dma(hwif, dmabase, 8);
34627 -}
34628 -
34629  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
34630  
34631  /**
34632 --- linux-2.6.0-test6/drivers/ide/pci/piix.h    2003-06-14 12:18:00.000000000 -0700
34633 +++ 25/drivers/ide/pci/piix.h   2003-10-05 00:33:24.000000000 -0700
34634 @@ -30,8 +30,6 @@ static ide_pci_host_proc_t piix_procs[] 
34635  static void init_setup_piix(struct pci_dev *, ide_pci_device_t *);
34636  static unsigned int __devinit init_chipset_piix(struct pci_dev *, const char *);
34637  static void init_hwif_piix(ide_hwif_t *);
34638 -static void init_dma_piix(ide_hwif_t *, unsigned long);
34639 -
34640  
34641  /*
34642   *     Table of the various PIIX capability blocks
34643 @@ -47,7 +45,6 @@ static ide_pci_device_t piix_pci_info[] 
34644                 .init_chipset   = init_chipset_piix,
34645                 .init_iops      = NULL,
34646                 .init_hwif      = init_hwif_piix,
34647 -               .init_dma       = init_dma_piix,
34648                 .channels       = 2,
34649                 .autodma        = AUTODMA,
34650                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34651 @@ -61,7 +58,6 @@ static ide_pci_device_t piix_pci_info[] 
34652                 .init_chipset   = init_chipset_piix,
34653                 .init_iops      = NULL,
34654                 .init_hwif      = init_hwif_piix,
34655 -               .init_dma       = init_dma_piix,
34656                 .channels       = 2,
34657                 .autodma        = AUTODMA,
34658                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34659 @@ -75,7 +71,6 @@ static ide_pci_device_t piix_pci_info[] 
34660                 .init_chipset   = NULL,
34661                 .init_iops      = NULL,
34662                 .init_hwif      = init_hwif_piix,
34663 -               .init_dma       = NULL,
34664                 .channels       = 2,
34665                 .autodma        = NODMA,
34666                 .enablebits     = {{0x6D,0x80,0x80}, {0x6F,0x80,0x80}},
34667 @@ -89,7 +84,6 @@ static ide_pci_device_t piix_pci_info[] 
34668                 .init_chipset   = init_chipset_piix,
34669                 .init_iops      = NULL,
34670                 .init_hwif      = init_hwif_piix,
34671 -               .init_dma       = init_dma_piix,
34672                 .channels       = 2,
34673                 .autodma        = AUTODMA,
34674                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34675 @@ -103,7 +97,6 @@ static ide_pci_device_t piix_pci_info[] 
34676                 .init_chipset   = init_chipset_piix,
34677                 .init_iops      = NULL,
34678                 .init_hwif      = init_hwif_piix,
34679 -               .init_dma       = init_dma_piix,
34680                 .channels       = 2,
34681                 .autodma        = AUTODMA,
34682                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34683 @@ -117,7 +110,6 @@ static ide_pci_device_t piix_pci_info[] 
34684                 .init_chipset   = init_chipset_piix,
34685                 .init_iops      = NULL,
34686                 .init_hwif      = init_hwif_piix,
34687 -               .init_dma       = init_dma_piix,
34688                 .channels       = 2,
34689                 .autodma        = AUTODMA,
34690                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34691 @@ -131,7 +123,6 @@ static ide_pci_device_t piix_pci_info[] 
34692                 .init_chipset   = init_chipset_piix,
34693                 .init_iops      = NULL,
34694                 .init_hwif      = init_hwif_piix,
34695 -               .init_dma       = init_dma_piix,
34696                 .channels       = 2,
34697                 .autodma        = AUTODMA,
34698                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34699 @@ -145,7 +136,6 @@ static ide_pci_device_t piix_pci_info[] 
34700                 .init_chipset   = init_chipset_piix,
34701                 .init_iops      = NULL,
34702                 .init_hwif      = init_hwif_piix,
34703 -               .init_dma       = init_dma_piix,
34704                 .channels       = 2,
34705                 .autodma        = AUTODMA,
34706                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34707 @@ -159,7 +149,6 @@ static ide_pci_device_t piix_pci_info[] 
34708                 .init_chipset   = init_chipset_piix,
34709                 .init_iops      = NULL,
34710                 .init_hwif      = init_hwif_piix,
34711 -               .init_dma       = init_dma_piix,
34712                 .channels       = 2,
34713                 .autodma        = AUTODMA,
34714                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34715 @@ -173,7 +162,6 @@ static ide_pci_device_t piix_pci_info[] 
34716                 .init_chipset   = init_chipset_piix,
34717                 .init_iops      = NULL,
34718                 .init_hwif      = init_hwif_piix,
34719 -               .init_dma       = init_dma_piix,
34720                 .channels       = 2,
34721                 .autodma        = NOAUTODMA,
34722                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34723 @@ -187,7 +175,6 @@ static ide_pci_device_t piix_pci_info[] 
34724                 .init_chipset   = init_chipset_piix,
34725                 .init_iops      = NULL,
34726                 .init_hwif      = init_hwif_piix,
34727 -               .init_dma       = init_dma_piix,
34728                 .channels       = 2,
34729                 .autodma        = AUTODMA,
34730                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34731 @@ -201,7 +188,6 @@ static ide_pci_device_t piix_pci_info[] 
34732                 .init_chipset   = init_chipset_piix,
34733                 .init_iops      = NULL,
34734                 .init_hwif      = init_hwif_piix,
34735 -               .init_dma       = init_dma_piix,
34736                 .channels       = 2,
34737                 .autodma        = AUTODMA,
34738                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34739 @@ -215,7 +201,6 @@ static ide_pci_device_t piix_pci_info[] 
34740                 .init_chipset   = init_chipset_piix,
34741                 .init_iops      = NULL,
34742                 .init_hwif      = init_hwif_piix,
34743 -               .init_dma       = init_dma_piix,
34744                 .channels       = 2,
34745                 .autodma        = AUTODMA,
34746                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34747 @@ -229,7 +214,6 @@ static ide_pci_device_t piix_pci_info[] 
34748                 .init_chipset   = init_chipset_piix,
34749                 .init_iops      = NULL,
34750                 .init_hwif      = init_hwif_piix,
34751 -               .init_dma       = init_dma_piix,
34752                 .channels       = 2,
34753                 .autodma        = AUTODMA,
34754                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34755 @@ -243,7 +227,6 @@ static ide_pci_device_t piix_pci_info[] 
34756                 .init_chipset   = init_chipset_piix,
34757                 .init_iops      = NULL,
34758                 .init_hwif      = init_hwif_piix,
34759 -               .init_dma       = init_dma_piix,
34760                 .channels       = 2,
34761                 .autodma        = AUTODMA,
34762                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34763 @@ -257,7 +240,6 @@ static ide_pci_device_t piix_pci_info[] 
34764                 .init_chipset   = init_chipset_piix,
34765                 .init_iops      = NULL,
34766                 .init_hwif      = init_hwif_piix,
34767 -               .init_dma       = init_dma_piix,
34768                 .channels       = 2,
34769                 .autodma        = AUTODMA,
34770                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34771 @@ -271,7 +253,6 @@ static ide_pci_device_t piix_pci_info[] 
34772                 .init_chipset   = init_chipset_piix,
34773                 .init_iops      = NULL,
34774                 .init_hwif      = init_hwif_piix,
34775 -               .init_dma       = init_dma_piix,
34776                 .channels       = 2,
34777                 .autodma        = AUTODMA,
34778                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34779 @@ -285,7 +266,6 @@ static ide_pci_device_t piix_pci_info[] 
34780                 .init_chipset   = init_chipset_piix,
34781                 .init_iops      = NULL,
34782                 .init_hwif      = init_hwif_piix,
34783 -               .init_dma       = init_dma_piix,
34784                 .channels       = 2,
34785                 .autodma        = AUTODMA,
34786                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34787 @@ -299,7 +279,6 @@ static ide_pci_device_t piix_pci_info[] 
34788                 .init_chipset   = init_chipset_piix,
34789                 .init_iops      = NULL,
34790                 .init_hwif      = init_hwif_piix,
34791 -               .init_dma       = init_dma_piix,
34792                 .channels       = 2,
34793                 .autodma        = AUTODMA,
34794                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
34795 --- linux-2.6.0-test6/drivers/ide/pci/sc1200.c  2003-09-08 13:58:57.000000000 -0700
34796 +++ 25/drivers/ide/pci/sc1200.c 2003-10-05 00:33:24.000000000 -0700
34797 @@ -396,44 +396,44 @@ typedef struct sc1200_saved_state_s {
34798         __u32           regs[4];
34799  } sc1200_saved_state_t;
34800  
34801 -static int sc1200_save_state (struct pci_dev *dev, u32 state)
34802 +
34803 +static int sc1200_suspend (struct pci_dev *dev, u32 state)
34804  {
34805         ide_hwif_t              *hwif = NULL;
34806  
34807 -printk("SC1200: save_state(%u)\n", state);
34808 -       if (state != 0)
34809 -               return 0;       // we only save state when going from full power to less
34810 -       //
34811 -       // Loop over all interfaces that are part of this PCI device:
34812 -       //
34813 -       while ((hwif = lookup_pci_dev(hwif, dev)) != NULL) {
34814 -               sc1200_saved_state_t    *ss;
34815 -               unsigned int            basereg, r;
34816 -               //
34817 -               // allocate a permanent save area, if not already allocated
34818 -               //
34819 -               ss = (sc1200_saved_state_t *)hwif->config_data;
34820 -               if (ss == NULL) {
34821 -                       ss = kmalloc(sizeof(sc1200_saved_state_t), GFP_KERNEL);
34822 -                       if (ss == NULL)
34823 -                               return -ENOMEM;
34824 -                       (sc1200_saved_state_t *)hwif->config_data = ss;
34825 -               }
34826 -               ss = (sc1200_saved_state_t *)hwif->config_data;
34827 +       printk("SC1200: suspend(%u)\n", state);
34828 +
34829 +       if (state == 0) {
34830 +               // we only save state when going from full power to less
34831 +
34832                 //
34833 -               // Save timing registers:  this may be unnecessary if BIOS also does it
34834 +               // Loop over all interfaces that are part of this PCI device:
34835                 //
34836 -               basereg = hwif->channel ? 0x50 : 0x40;
34837 -               for (r = 0; r < 4; ++r) {
34838 -                       pci_read_config_dword (hwif->pci_dev, basereg + (r<<2), &ss->regs[r]);
34839 +               while ((hwif = lookup_pci_dev(hwif, dev)) != NULL) {
34840 +                       sc1200_saved_state_t    *ss;
34841 +                       unsigned int            basereg, r;
34842 +                       //
34843 +                       // allocate a permanent save area, if not already allocated
34844 +                       //
34845 +                       ss = (sc1200_saved_state_t *)hwif->config_data;
34846 +                       if (ss == NULL) {
34847 +                               ss = kmalloc(sizeof(sc1200_saved_state_t), GFP_KERNEL);
34848 +                               if (ss == NULL)
34849 +                                       return -ENOMEM;
34850 +                               (sc1200_saved_state_t *)hwif->config_data = ss;
34851 +                       }
34852 +                       ss = (sc1200_saved_state_t *)hwif->config_data;
34853 +                       //
34854 +                       // Save timing registers:  this may be unnecessary if 
34855 +                       // BIOS also does it
34856 +                       //
34857 +                       basereg = hwif->channel ? 0x50 : 0x40;
34858 +                       for (r = 0; r < 4; ++r) {
34859 +                               pci_read_config_dword (hwif->pci_dev, basereg + (r<<2), &ss->regs[r]);
34860 +                       }
34861                 }
34862         }
34863 -       return 0;
34864 -}
34865  
34866 -static int sc1200_suspend (struct pci_dev *dev, u32 state)
34867 -{
34868 -       printk("SC1200: suspend(%u)\n", state);
34869         /* You don't need to iterate over disks -- sysfs should have done that for you already */ 
34870  
34871         pci_disable_device(dev);
34872 @@ -545,11 +545,6 @@ static void __init init_hwif_sc1200 (ide
34873          hwif->drives[1].autodma = hwif->autodma;
34874  }
34875  
34876 -static void __init init_dma_sc1200 (ide_hwif_t *hwif, unsigned long dmabase)
34877 -{
34878 -       ide_setup_dma(hwif, dmabase, 8);
34879 -}
34880 -
34881  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
34882  
34883  
34884 @@ -572,7 +567,6 @@ static struct pci_driver driver = {
34885         .name           = "SC1200 IDE",
34886         .id_table       = sc1200_pci_tbl,
34887         .probe          = sc1200_init_one,
34888 -       .save_state     = sc1200_save_state,
34889         .suspend        = sc1200_suspend,
34890         .resume         = sc1200_resume,
34891  };
34892 --- linux-2.6.0-test6/drivers/ide/pci/sc1200.h  2003-06-14 12:18:05.000000000 -0700
34893 +++ 25/drivers/ide/pci/sc1200.h 2003-10-05 00:33:24.000000000 -0700
34894 @@ -27,7 +27,6 @@ static ide_pci_host_proc_t sc1200_procs[
34895  
34896  static unsigned int init_chipset_sc1200(struct pci_dev *, const char *);
34897  static void init_hwif_sc1200(ide_hwif_t *);
34898 -static void init_dma_sc1200(ide_hwif_t *, unsigned long);
34899  
34900  static ide_pci_device_t sc1200_chipsets[] __devinitdata = {
34901         {       /* 0 */
34902 @@ -37,7 +36,6 @@ static ide_pci_device_t sc1200_chipsets[
34903                 .init_chipset   = init_chipset_sc1200,
34904                 .init_iops      = NULL,
34905                 .init_hwif      = init_hwif_sc1200,
34906 -               .init_dma       = init_dma_sc1200,
34907                 .channels       = 2,
34908                 .autodma        = AUTODMA,
34909                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
34910 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
34911 +++ 25/drivers/ide/pci/sgiioc4.c        2003-10-05 00:36:28.000000000 -0700
34912 @@ -0,0 +1,1053 @@
34913 +/*
34914 + * Copyright (c) 2003 Silicon Graphics, Inc.  All Rights Reserved.
34915 + *
34916 + * This program is free software; you can redistribute it and/or modify it
34917 + * under the terms of version 2 of the GNU General Public License
34918 + * as published by the Free Software Foundation.
34919 + *
34920 + * This program is distributed in the hope that it would be useful, but
34921 + * WITHOUT ANY WARRANTY; without even the implied warranty of
34922 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
34923 + *
34924 + * You should have received a copy of the GNU General Public
34925 + * License along with this program; if not, write the Free Software
34926 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
34927 + *
34928 + * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
34929 + * Mountain View, CA  94043, or:
34930 + *
34931 + * http://www.sgi.com
34932 + *
34933 + * For further information regarding this notice, see:
34934 + *
34935 + * http://oss.sgi.com/projects/GenInfo/NoticeExplan
34936 + */
34937 +
34938 +#include <linux/config.h>
34939 +#include <linux/module.h>
34940 +#include <linux/types.h>
34941 +#include <linux/pci.h>
34942 +#include <linux/delay.h>
34943 +#include <linux/hdreg.h>
34944 +#include <linux/init.h>
34945 +#include <linux/kernel.h>
34946 +#include <linux/timer.h>
34947 +#include <linux/mm.h>
34948 +#include <linux/ioport.h>
34949 +#include <linux/blkdev.h>
34950 +#include <asm/io.h>
34951 +
34952 +#define IDE_ARCH_ACK_INTR      1
34953 +#include <linux/ide.h>
34954 +
34955 +/* IOC4 Specific Definitions */
34956 +#define IOC4_CMD_OFFSET                0x100
34957 +#define IOC4_CTRL_OFFSET       0x120
34958 +#define IOC4_DMA_OFFSET                0x140
34959 +#define IOC4_INTR_OFFSET       0x0
34960 +
34961 +#define IOC4_TIMING            0x00
34962 +#define IOC4_DMA_PTR_L         0x01
34963 +#define IOC4_DMA_PTR_H         0x02
34964 +#define IOC4_DMA_ADDR_L                0x03
34965 +#define IOC4_DMA_ADDR_H                0x04
34966 +#define IOC4_BC_DEV            0x05
34967 +#define IOC4_BC_MEM            0x06
34968 +#define        IOC4_DMA_CTRL           0x07
34969 +#define        IOC4_DMA_END_ADDR       0x08
34970 +
34971 +/* Bits in the IOC4 Control/Status Register */
34972 +#define        IOC4_S_DMA_START        0x01
34973 +#define        IOC4_S_DMA_STOP         0x02
34974 +#define        IOC4_S_DMA_DIR          0x04
34975 +#define        IOC4_S_DMA_ACTIVE       0x08
34976 +#define        IOC4_S_DMA_ERROR        0x10
34977 +#define        IOC4_ATA_MEMERR         0x02
34978 +
34979 +/* Read/Write Directions */
34980 +#define        IOC4_DMA_WRITE          0x04
34981 +#define        IOC4_DMA_READ           0x00
34982 +
34983 +/* Interrupt Register Offsets */
34984 +#define IOC4_INTR_REG          0x03
34985 +#define        IOC4_INTR_SET           0x05
34986 +#define        IOC4_INTR_CLEAR         0x07
34987 +
34988 +#define IOC4_IDE_CACHELINE_SIZE        128
34989 +#define IOC4_CMD_CTL_BLK_SIZE  0x20
34990 +#define IOC4_SUPPORTED_FIRMWARE_REV 46
34991 +
34992 +/* Weeds out non-IDE interrupts to the IOC4 */
34993 +#define ide_ack_intr(hwif) ((hwif)->hw.ack_intr ? (hwif)->hw.ack_intr(hwif) : 1)
34994 +
34995 +#define SGIIOC4_MAX_DEVS       32
34996 +
34997 +#if  defined(CONFIG_PROC_FS)
34998 +#include <linux/stat.h>
34999 +#include <linux/proc_fs.h>
35000 +
35001 +static u8 sgiioc4_proc;
35002 +
35003 +static struct pci_dev *sgiioc4_devs[SGIIOC4_MAX_DEVS];
35004 +static int sgiioc4_get_info(char *, char **, off_t, int);
35005 +
35006 +static ide_pci_host_proc_t sgiioc4_procs[] __initdata = {
35007 +       {
35008 +        .name = "sgiioc4",
35009 +        .set = 1,
35010 +        .get_info = sgiioc4_get_info,
35011 +        .parent = NULL,
35012 +        }
35013 +};
35014 +#endif
35015 +
35016 +typedef struct {
35017 +       u32 timing_reg0;
35018 +       u32 timing_reg1;
35019 +       u32 low_mem_ptr;
35020 +       u32 high_mem_ptr;
35021 +       u32 low_mem_addr;
35022 +       u32 high_mem_addr;
35023 +       u32 dev_byte_count;
35024 +       u32 mem_byte_count;
35025 +       u32 status;
35026 +} ioc4_dma_regs_t;
35027 +
35028 +/* Each Physical Region Descriptor Entry size is 16 bytes (2 * 64 bits) */
35029 +/* IOC4 has only 1 IDE channel */
35030 +#define IOC4_PRD_BYTES       16
35031 +#define IOC4_PRD_ENTRIES     (PAGE_SIZE /(4*IOC4_PRD_BYTES))
35032 +
35033 +typedef enum pciio_endian_e {
35034 +       PCIDMA_ENDIAN_BIG,
35035 +       PCIDMA_ENDIAN_LITTLE
35036 +} pciio_endian_t;
35037 +
35038 +static void sgiioc4_init_hwif_ports(hw_regs_t * hw, unsigned long data_port,
35039 +                                   unsigned long ctrl_port,
35040 +                                   unsigned long irq_port);
35041 +static void sgiioc4_ide_setup_pci_device(struct pci_dev *dev,
35042 +                                        ide_pci_device_t * d);
35043 +static void sgiioc4_resetproc(ide_drive_t * drive);
35044 +static void sgiioc4_maskproc(ide_drive_t * drive, int mask);
35045 +static void sgiioc4_configure_for_dma(int dma_direction, ide_drive_t * drive);
35046 +static void __init ide_init_sgiioc4(ide_hwif_t * hwif);
35047 +static void __init ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base);
35048 +static int sgiioc4_checkirq(ide_hwif_t * hwif);
35049 +static int sgiioc4_clearirq(ide_drive_t * drive);
35050 +static int sgiioc4_get_info(char *buffer, char **addr, off_t offset, int count);
35051 +static int sgiioc4_ide_dma_read(ide_drive_t * drive);
35052 +static int sgiioc4_ide_dma_write(ide_drive_t * drive);
35053 +static int sgiioc4_ide_dma_begin(ide_drive_t * drive);
35054 +static int sgiioc4_ide_dma_end(ide_drive_t * drive);
35055 +static int sgiioc4_ide_dma_check(ide_drive_t * drive);
35056 +static int sgiioc4_ide_dma_on(ide_drive_t * drive);
35057 +static int sgiioc4_ide_dma_off(ide_drive_t * drive);
35058 +static int sgiioc4_ide_dma_off_quietly(ide_drive_t * drive);
35059 +static int sgiioc4_ide_dma_test_irq(ide_drive_t * drive);
35060 +static int sgiioc4_ide_dma_host_on(ide_drive_t * drive);
35061 +static int sgiioc4_ide_dma_host_off(ide_drive_t * drive);
35062 +static int sgiioc4_ide_dma_count(ide_drive_t * drive);
35063 +static int sgiioc4_ide_dma_verbose(ide_drive_t * drive);
35064 +static int sgiioc4_ide_dma_lostirq(ide_drive_t * drive);
35065 +static int sgiioc4_ide_dma_timeout(ide_drive_t * drive);
35066 +static int sgiioc4_ide_build_sglist(ide_drive_t * drive, struct request *rq);
35067 +static int sgiioc4_ide_raw_build_sglist(ide_drive_t * drive,
35068 +                                       struct request *rq);
35069 +static u8 sgiioc4_INB(unsigned long port);
35070 +static inline void xide_delay(long ticks);
35071 +static unsigned int sgiioc4_build_dma_table(ide_drive_t * drive,
35072 +                                           struct request *rq, int ddir);
35073 +static unsigned int __init pci_init_sgiioc4(struct pci_dev *dev,
35074 +                                           ide_pci_device_t * d);
35075 +
35076 +static ide_pci_device_t sgiioc4_chipsets[] __devinitdata = {
35077 +       {
35078 +        /* Channel 0 */
35079 +        .vendor = PCI_VENDOR_ID_SGI,
35080 +        .device = PCI_DEVICE_ID_SGI_IOC4,
35081 +        .name = "SGIIOC4",
35082 +        .init_chipset = NULL,
35083 +        .init_iops = NULL,
35084 +        .init_hwif = ide_init_sgiioc4,
35085 +        .init_dma = ide_dma_sgiioc4,
35086 +        .channels = 1,
35087 +        .autodma = AUTODMA,
35088 +        .enablebits = {{0x00, 0x00, 0x00}, {0x00, 0x00, 0x00}},
35089 +        .bootable = ON_BOARD,
35090 +        .extra = 0,
35091 +        }
35092 +};
35093 +
35094 +#ifdef CONFIG_PROC_FS
35095 +static u8 sgiioc4_proc;
35096 +#endif                         /* CONFIG_PROC_FS */
35097 +
35098 +static int n_sgiioc4_devs;
35099 +
35100 +static inline void
35101 +xide_delay(long ticks)
35102 +{
35103 +       if (!ticks)
35104 +               return;
35105 +
35106 +       current->state = TASK_UNINTERRUPTIBLE;
35107 +       schedule_timeout(ticks);
35108 +}
35109 +static void __init
35110 +sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d)
35111 +{
35112 +       unsigned long base = 0, ctl = 0, dma_base = 0, irqport = 0;
35113 +       ide_hwif_t *hwif = NULL;
35114 +       int h = 0;
35115 +
35116 +       /*  Get the CmdBlk and CtrlBlk Base Registers */
35117 +       base = pci_resource_start(dev, 0) + IOC4_CMD_OFFSET;
35118 +       ctl = pci_resource_start(dev, 0) + IOC4_CTRL_OFFSET;
35119 +       irqport = pci_resource_start(dev, 0) + IOC4_INTR_OFFSET;
35120 +       dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET;
35121 +
35122 +       if (!request_region(base, IOC4_CMD_CTL_BLK_SIZE, hwif->name)) {
35123 +               printk(KERN_ERR
35124 +                       "%s : %s -- Warning, Port Addresses "
35125 +                       "0x%p to 0x%p ALREADY in use\n",
35126 +                      __FUNCTION__, hwif->name, (void *) base,
35127 +                      (void *) base + IOC4_CMD_CTL_BLK_SIZE);
35128 +       }
35129 +
35130 +       for (h = 0; h < MAX_HWIFS; ++h) {
35131 +               hwif = &ide_hwifs[h];
35132 +               /* Find an empty HWIF */
35133 +               if (hwif->chipset == ide_unknown)
35134 +                       break;
35135 +       }
35136 +
35137 +       if (hwif->io_ports[IDE_DATA_OFFSET] != base) {
35138 +               /* Initialize the IO registers */
35139 +               sgiioc4_init_hwif_ports(&hwif->hw, base, ctl, irqport);
35140 +               memcpy(hwif->io_ports, hwif->hw.io_ports,
35141 +                      sizeof (hwif->io_ports));
35142 +               hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET];
35143 +       }
35144 +
35145 +       hwif->irq = dev->irq;
35146 +       hwif->chipset = ide_pci;
35147 +       hwif->pci_dev = dev;
35148 +       hwif->channel = 0;      /* Single Channel chip */
35149 +       hwif->cds = (struct ide_pci_device_s *) d;
35150 +       hwif->hw.ack_intr = &sgiioc4_checkirq;  /* MultiFunction Chip */
35151 +       hwif->gendev.parent = &dev->dev;/* setup proper ancestral information */
35152 +
35153 +       /* Initializing chipset IRQ Registers */
35154 +       hwif->OUTL(0x03, irqport + IOC4_INTR_SET * 4);
35155 +
35156 +       (void) ide_init_sgiioc4(hwif);
35157 +
35158 +       if (dma_base)
35159 +               ide_dma_sgiioc4(hwif, dma_base);
35160 +       else
35161 +               printk(KERN_INFO "%s: %s Bus-Master DMA disabled\n",
35162 +                      hwif->name, d->name);
35163 +
35164 +       probe_hwif_init(hwif);
35165 +}
35166 +
35167 +/* This ensures that we can build this for generic kernels without
35168 + * having all the SN2 code sync'd and merged.
35169 + */
35170 +
35171 +pciio_endian_t __attribute__ ((weak)) snia_pciio_endian_set(struct pci_dev
35172 +                                           *pci_dev, pciio_endian_t device_end,
35173 +                                           pciio_endian_t desired_end);
35174 +
35175 +static unsigned int __init
35176 +pci_init_sgiioc4(struct pci_dev *dev, ide_pci_device_t * d)
35177 +{
35178 +       if (pci_enable_device(dev)) {
35179 +               printk(KERN_INFO
35180 +                      "Failed to enable device %s at slot %s\n",
35181 +                      d->name, dev->slot_name);
35182 +               return 1;
35183 +       }
35184 +       pci_set_master(dev);
35185 +
35186 +       /* Enable Byte Swapping in the PIC... */
35187 +       if (snia_pciio_endian_set) {
35188 +               snia_pciio_endian_set(dev, PCIDMA_ENDIAN_LITTLE,
35189 +                                     PCIDMA_ENDIAN_BIG);
35190 +       } else {
35191 +               printk(KERN_INFO
35192 +                      "Failed to set endianness for device %s at slot %s\n",
35193 +                      d->name, dev->slot_name);
35194 +               return 1;
35195 +       }
35196 +
35197 +#ifdef CONFIG_PROC_FS
35198 +       sgiioc4_devs[n_sgiioc4_devs++] = dev;
35199 +       if (!sgiioc4_proc) {
35200 +               sgiioc4_proc = 1;
35201 +               ide_pci_register_host_proc(&sgiioc4_procs[0]);
35202 +       }
35203 +#endif
35204 +       sgiioc4_ide_setup_pci_device(dev, d);
35205 +
35206 +       return 0;
35207 +}
35208 +
35209 +static void
35210 +sgiioc4_init_hwif_ports(hw_regs_t * hw, unsigned long data_port,
35211 +                       unsigned long ctrl_port, unsigned long irq_port)
35212 +{
35213 +       unsigned long reg = data_port;
35214 +       int i;
35215 +
35216 +       /* Registers are word (32 bit) aligned */
35217 +       for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
35218 +               hw->io_ports[i] = reg + i * 4;
35219 +
35220 +       if (ctrl_port)
35221 +               hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
35222 +
35223 +       if (irq_port)
35224 +               hw->io_ports[IDE_IRQ_OFFSET] = irq_port;
35225 +}
35226 +
35227 +static void
35228 +sgiioc4_resetproc(ide_drive_t * drive)
35229 +{
35230 +       sgiioc4_ide_dma_end(drive);
35231 +       sgiioc4_clearirq(drive);
35232 +}
35233 +
35234 +static void
35235 +sgiioc4_maskproc(ide_drive_t * drive, int mask)
35236 +{
35237 +       ide_hwif_t *hwif = HWIF(drive);
35238 +       hwif->OUTB(mask ? (drive->ctl | 2) : (drive->ctl & ~2),
35239 +                  IDE_CONTROL_REG);
35240 +}
35241 +
35242 +static void __init
35243 +ide_init_sgiioc4(ide_hwif_t * hwif)
35244 +{
35245 +       hwif->mmio = 2;
35246 +       hwif->autodma = 1;
35247 +       hwif->atapi_dma = 1;
35248 +       hwif->ultra_mask = 0x0; /* Disable Ultra DMA */
35249 +       hwif->mwdma_mask = 0x2; /* Multimode-2 DMA  */
35250 +       hwif->swdma_mask = 0x2;
35251 +       hwif->identify = NULL;
35252 +       hwif->tuneproc = NULL;  /* Sets timing for PIO mode */
35253 +       hwif->speedproc = NULL; /* Sets timing for DMA &/or PIO modes */
35254 +       hwif->selectproc = NULL;/* Use the default routine to select drive */
35255 +       hwif->reset_poll = NULL;/* No HBA specific reset_poll needed */
35256 +       hwif->pre_reset = NULL; /* No HBA specific pre_set needed */
35257 +       hwif->resetproc = &sgiioc4_resetproc;/* Reset DMA engine,
35258 +                                               clear interrupts */
35259 +       hwif->intrproc = NULL;  /* Enable or Disable interrupt from drive */
35260 +       hwif->maskproc = &sgiioc4_maskproc;     /* Mask on/off NIEN register */
35261 +       hwif->quirkproc = NULL;
35262 +       hwif->busproc = NULL;
35263 +
35264 +       hwif->ide_dma_read = &sgiioc4_ide_dma_read;
35265 +       hwif->ide_dma_write = &sgiioc4_ide_dma_write;
35266 +       hwif->ide_dma_begin = &sgiioc4_ide_dma_begin;
35267 +       hwif->ide_dma_end = &sgiioc4_ide_dma_end;
35268 +       hwif->ide_dma_check = &sgiioc4_ide_dma_check;
35269 +       hwif->ide_dma_on = &sgiioc4_ide_dma_on;
35270 +       hwif->ide_dma_off = &sgiioc4_ide_dma_off;
35271 +       hwif->ide_dma_off_quietly = &sgiioc4_ide_dma_off_quietly;
35272 +       hwif->ide_dma_test_irq = &sgiioc4_ide_dma_test_irq;
35273 +       hwif->ide_dma_host_on = &sgiioc4_ide_dma_host_on;
35274 +       hwif->ide_dma_host_off = &sgiioc4_ide_dma_host_off;
35275 +       hwif->ide_dma_bad_drive = &__ide_dma_bad_drive;
35276 +       hwif->ide_dma_good_drive = &__ide_dma_good_drive;
35277 +       hwif->ide_dma_count = &sgiioc4_ide_dma_count;
35278 +       hwif->ide_dma_verbose = &sgiioc4_ide_dma_verbose;
35279 +       hwif->ide_dma_retune = &__ide_dma_retune;
35280 +       hwif->ide_dma_lostirq = &sgiioc4_ide_dma_lostirq;
35281 +       hwif->ide_dma_timeout = &sgiioc4_ide_dma_timeout;
35282 +       hwif->INB = &sgiioc4_INB;
35283 +}
35284 +
35285 +static int
35286 +sgiioc4_ide_dma_read(ide_drive_t * drive)
35287 +{
35288 +       struct request *rq = HWGROUP(drive)->rq;
35289 +       unsigned int count = 0;
35290 +
35291 +       if (!(count = sgiioc4_build_dma_table(drive, rq, PCI_DMA_FROMDEVICE))) {
35292 +               /* try PIO instead of DMA */
35293 +               return 1;
35294 +       }
35295 +       /* Writes FROM the IOC4 TO Main Memory */
35296 +       sgiioc4_configure_for_dma(IOC4_DMA_WRITE, drive);
35297 +
35298 +       return 0;
35299 +}
35300 +
35301 +static int
35302 +sgiioc4_ide_dma_write(ide_drive_t * drive)
35303 +{
35304 +       struct request *rq = HWGROUP(drive)->rq;
35305 +       unsigned int count = 0;
35306 +
35307 +       if (!(count = sgiioc4_build_dma_table(drive, rq, PCI_DMA_TODEVICE))) {
35308 +               /* try PIO instead of DMA */
35309 +               return 1;
35310 +       }
35311 +
35312 +       sgiioc4_configure_for_dma(IOC4_DMA_READ, drive);
35313 +       /* Writes TO the IOC4 FROM Main Memory */
35314 +
35315 +       return 0;
35316 +}
35317 +
35318 +static int
35319 +sgiioc4_ide_dma_begin(ide_drive_t * drive)
35320 +{
35321 +       ide_hwif_t *hwif = HWIF(drive);
35322 +       unsigned int reg = hwif->INL(hwif->dma_base + IOC4_DMA_CTRL * 4);
35323 +       unsigned int temp_reg = reg | IOC4_S_DMA_START;
35324 +
35325 +       hwif->OUTL(temp_reg, hwif->dma_base + IOC4_DMA_CTRL * 4);
35326 +
35327 +       return 0;
35328 +}
35329 +
35330 +/* Stops the IOC4 DMA Engine */
35331 +static int
35332 +sgiioc4_ide_dma_end(ide_drive_t * drive)
35333 +{
35334 +       u32 ioc4_dma, bc_dev, bc_mem, num, valid = 0, cnt = 0;
35335 +       ide_hwif_t *hwif = HWIF(drive);
35336 +       uint64_t dma_base = hwif->dma_base;
35337 +       int dma_stat = 0, count;
35338 +       unsigned long *ending_dma = (unsigned long *) hwif->dma_base2;
35339 +
35340 +       hwif->OUTL(IOC4_S_DMA_STOP, dma_base + IOC4_DMA_CTRL * 4);
35341 +
35342 +       count = 0;
35343 +       do {
35344 +               xide_delay(count);
35345 +               ioc4_dma = hwif->INL(dma_base + IOC4_DMA_CTRL * 4);
35346 +               count += 10;
35347 +       } while ((ioc4_dma & IOC4_S_DMA_STOP) && (count < 100));
35348 +
35349 +       if (ioc4_dma & IOC4_S_DMA_STOP) {
35350 +               printk(KERN_ERR
35351 +                      "%s(%s): IOC4 DMA STOP bit is still 1 :"
35352 +                      "ioc4_dma_reg 0x%x\n",
35353 +                      __FUNCTION__, drive->name, ioc4_dma);
35354 +               dma_stat = 1;
35355 +       }
35356 +
35357 +       if (ending_dma) {
35358 +               do {
35359 +                       for (num = 0; num < 16; num++) {
35360 +                               if (ending_dma[num] & (~0ul)) {
35361 +                                       valid = 1;
35362 +                                       break;
35363 +                               }
35364 +                       }
35365 +                       xide_delay(cnt);
35366 +               } while ((cnt++ < 100) && (!valid));
35367 +       }
35368 +
35369 +       if (!valid)
35370 +               printk(KERN_INFO "%s(%s) : Stale DMA Data in Memory\n",
35371 +                      __FUNCTION__, drive->name);
35372 +
35373 +       bc_dev = hwif->INL(dma_base + IOC4_BC_DEV * 4);
35374 +       bc_mem = hwif->INL(dma_base + IOC4_BC_MEM * 4);
35375 +
35376 +       if ((bc_dev & 0x01FF) || (bc_mem & 0x1FF)) {
35377 +               if (bc_dev > bc_mem + 8) {
35378 +                       printk(KERN_ERR
35379 +                              "%s(%s): WARNING!! byte_count_dev %d "
35380 +                              "!= byte_count_mem %d\n",
35381 +                              __FUNCTION__, drive->name, bc_dev, bc_mem);
35382 +               }
35383 +       }
35384 +
35385 +       drive->waiting_for_dma = 0;
35386 +       ide_destroy_dmatable(drive);
35387 +
35388 +       return dma_stat;
35389 +}
35390 +
35391 +static int
35392 +sgiioc4_ide_dma_check(ide_drive_t * drive)
35393 +{
35394 +       if (ide_config_drive_speed(drive, XFER_MW_DMA_2) != 0) {
35395 +               printk(KERN_INFO
35396 +                      "Couldnot set %s in Multimode-2 DMA mode | "
35397 +                          "Drive %s using PIO instead\n",
35398 +                      drive->name, drive->name);
35399 +               drive->using_dma = 0;
35400 +       } else
35401 +               drive->using_dma = 1;
35402 +
35403 +       return 0;
35404 +}
35405 +
35406 +static int
35407 +sgiioc4_ide_dma_on(ide_drive_t * drive)
35408 +{
35409 +       drive->using_dma = 1;
35410 +
35411 +       return HWIF(drive)->ide_dma_host_on(drive);
35412 +}
35413 +
35414 +static int
35415 +sgiioc4_ide_dma_off(ide_drive_t * drive)
35416 +{
35417 +       printk(KERN_INFO "%s: DMA disabled\n", drive->name);
35418 +
35419 +       return HWIF(drive)->ide_dma_off_quietly(drive);
35420 +}
35421 +
35422 +static int
35423 +sgiioc4_ide_dma_off_quietly(ide_drive_t * drive)
35424 +{
35425 +       drive->using_dma = 0;
35426 +
35427 +       return HWIF(drive)->ide_dma_host_off(drive);
35428 +}
35429 +
35430 +/* returns 1 if dma irq issued, 0 otherwise */
35431 +static int
35432 +sgiioc4_ide_dma_test_irq(ide_drive_t * drive)
35433 +{
35434 +       return sgiioc4_checkirq(HWIF(drive));
35435 +}
35436 +
35437 +static int
35438 +sgiioc4_ide_dma_host_on(ide_drive_t * drive)
35439 +{
35440 +       if (drive->using_dma)
35441 +               return 0;
35442 +
35443 +       return 1;
35444 +}
35445 +
35446 +static int
35447 +sgiioc4_ide_dma_host_off(ide_drive_t * drive)
35448 +{
35449 +       sgiioc4_clearirq(drive);
35450 +
35451 +       return 0;
35452 +}
35453 +
35454 +static int
35455 +sgiioc4_ide_dma_count(ide_drive_t * drive)
35456 +{
35457 +       return HWIF(drive)->ide_dma_begin(drive);
35458 +}
35459 +
35460 +static int
35461 +sgiioc4_ide_dma_verbose(ide_drive_t * drive)
35462 +{
35463 +       if (drive->using_dma == 1)
35464 +               printk(", UDMA(16)");
35465 +       else
35466 +               printk(", PIO");
35467 +
35468 +       return 1;
35469 +}
35470 +
35471 +static int
35472 +sgiioc4_ide_dma_lostirq(ide_drive_t * drive)
35473 +{
35474 +       HWIF(drive)->resetproc(drive);
35475 +
35476 +       return __ide_dma_lostirq(drive);
35477 +}
35478 +
35479 +static int
35480 +sgiioc4_ide_dma_timeout(ide_drive_t * drive)
35481 +{
35482 +       printk(KERN_ERR "%s: timeout waiting for DMA\n", drive->name);
35483 +       if (HWIF(drive)->ide_dma_test_irq(drive))
35484 +               return 0;
35485 +
35486 +       return HWIF(drive)->ide_dma_end(drive);
35487 +}
35488 +
35489 +static u8
35490 +sgiioc4_INB(unsigned long port)
35491 +{
35492 +       u8 reg = (u8) inb(port);
35493 +
35494 +       if ((port & 0xFFF) == 0x11C) {  /* Status register of IOC4 */
35495 +               if (reg & 0x51) {       /* Not busy...check for interrupt */
35496 +                       unsigned long other_ir = port - 0x110;
35497 +                       unsigned int intr_reg = (u32) inl(other_ir);
35498 +
35499 +                       /* Clear the Interrupt, Error bits on the IOC4 */
35500 +                       if (intr_reg & 0x03) {
35501 +                               outl(0x03, other_ir);
35502 +                               intr_reg = (u32) inl(other_ir);
35503 +                       }
35504 +               }
35505 +       }
35506 +
35507 +       return reg;
35508 +}
35509 +
35510 +/* Creates a dma map for the scatter-gather list entries */
35511 +static void __init
35512 +ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base)
35513 +{
35514 +       int num_ports = sizeof (ioc4_dma_regs_t);
35515 +
35516 +       printk(KERN_INFO "%s: BM-DMA at 0x%04lx-0x%04lx\n", hwif->name,
35517 +              dma_base, dma_base + num_ports - 1);
35518 +
35519 +       if (!request_region(dma_base, num_ports, hwif->name)) {
35520 +               printk(KERN_ERR
35521 +                      "%s(%s) -- WARNING, Addresses 0x%p to 0x%p "
35522 +                      "ALREADY in use\n",
35523 +                      __FUNCTION__, hwif->name, (void *) dma_base,
35524 +                      (void *) dma_base + num_ports - 1);
35525 +       }
35526 +
35527 +       hwif->dma_base = dma_base;
35528 +       hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev,
35529 +                                         IOC4_PRD_ENTRIES * IOC4_PRD_BYTES,
35530 +                                         &hwif->dmatable_dma);
35531 +
35532 +       if (!hwif->dmatable_cpu)
35533 +               goto dma_alloc_failure;
35534 +
35535 +       hwif->sg_table =
35536 +           kmalloc(sizeof (struct scatterlist) * IOC4_PRD_ENTRIES, GFP_KERNEL);
35537 +
35538 +       if (!hwif->sg_table) {
35539 +               pci_free_consistent(hwif->pci_dev,
35540 +                                   IOC4_PRD_ENTRIES * IOC4_PRD_BYTES,
35541 +                                   hwif->dmatable_cpu, hwif->dmatable_dma);
35542 +               goto dma_alloc_failure;
35543 +       }
35544 +
35545 +       hwif->dma_base2 = (unsigned long)
35546 +               pci_alloc_consistent(hwif->pci_dev,
35547 +                                    IOC4_IDE_CACHELINE_SIZE,
35548 +                                    (dma_addr_t *) &(hwif->dma_status));
35549 +
35550 +       if (!hwif->dma_base2) {
35551 +               pci_free_consistent(hwif->pci_dev,
35552 +                                   IOC4_PRD_ENTRIES * IOC4_PRD_BYTES,
35553 +                                   hwif->dmatable_cpu, hwif->dmatable_dma);
35554 +               kfree(hwif->sg_table);
35555 +               goto dma_alloc_failure;
35556 +       }
35557 +
35558 +       return;
35559 +
35560 +      dma_alloc_failure:
35561 +       printk(KERN_INFO
35562 +              "%s() -- Error! Unable to allocate DMA Maps for drive %s\n",
35563 +              __FUNCTION__, hwif->name);
35564 +       printk(KERN_INFO
35565 +              "Changing from DMA to PIO mode for Drive %s\n", hwif->name);
35566 +
35567 +       /* Disable DMA because we couldnot allocate any DMA maps */
35568 +       hwif->autodma = 0;
35569 +       hwif->atapi_dma = 0;
35570 +}
35571 +
35572 +/* Initializes the IOC4 DMA Engine */
35573 +static void
35574 +sgiioc4_configure_for_dma(int dma_direction, ide_drive_t * drive)
35575 +{
35576 +       u32 ioc4_dma;
35577 +       int count;
35578 +       ide_hwif_t *hwif = HWIF(drive);
35579 +       uint64_t dma_base = hwif->dma_base;
35580 +       uint32_t dma_addr, ending_dma_addr;
35581 +
35582 +       ioc4_dma = hwif->INL(dma_base + IOC4_DMA_CTRL * 4);
35583 +
35584 +       if (ioc4_dma & IOC4_S_DMA_ACTIVE) {
35585 +               printk(KERN_WARNING
35586 +                       "%s(%s):Warning!! DMA from previous transfer was still active\n",
35587 +                      __FUNCTION__, drive->name);
35588 +               hwif->OUTL(IOC4_S_DMA_STOP, dma_base + IOC4_DMA_CTRL * 4);
35589 +               count = 0;
35590 +               do {
35591 +                       xide_delay(count);
35592 +                       ioc4_dma = hwif->INL(dma_base + IOC4_DMA_CTRL * 4);
35593 +                       count += 10;
35594 +               } while ((ioc4_dma & IOC4_S_DMA_STOP) && (count < 100));
35595 +
35596 +               if (ioc4_dma & IOC4_S_DMA_STOP)
35597 +                       printk(KERN_ERR
35598 +                              "%s(%s) : IOC4 Dma STOP bit is still 1\n",
35599 +                              __FUNCTION__, drive->name);
35600 +       }
35601 +
35602 +       ioc4_dma = hwif->INL(dma_base + IOC4_DMA_CTRL * 4);
35603 +       if (ioc4_dma & IOC4_S_DMA_ERROR) {
35604 +               printk(KERN_WARNING
35605 +                      "%s(%s) : Warning!! - DMA Error during Previous"
35606 +                      " transfer | status 0x%x\n",
35607 +                      __FUNCTION__, drive->name, ioc4_dma);
35608 +               hwif->OUTL(IOC4_S_DMA_STOP, dma_base + IOC4_DMA_CTRL * 4);
35609 +               count = 0;
35610 +               do {
35611 +                       ioc4_dma = hwif->INL(dma_base + IOC4_DMA_CTRL * 4);
35612 +                       xide_delay(count);
35613 +                       count += 10;
35614 +               } while ((ioc4_dma & IOC4_S_DMA_STOP) && (count < 100));
35615 +
35616 +               if (ioc4_dma & IOC4_S_DMA_STOP)
35617 +                       printk(KERN_ERR
35618 +                              "%s(%s) : IOC4 DMA STOP bit is still 1\n",
35619 +                              __FUNCTION__, drive->name);
35620 +       }
35621 +
35622 +       /* Address of the Scatter Gather List */
35623 +       dma_addr = cpu_to_le32(hwif->dmatable_dma);
35624 +       hwif->OUTL(dma_addr, dma_base + IOC4_DMA_PTR_L * 4);
35625 +
35626 +       /* Address of the Ending DMA */
35627 +       memset((unsigned int *) hwif->dma_base2, 0, IOC4_IDE_CACHELINE_SIZE);
35628 +       ending_dma_addr = cpu_to_le32(hwif->dma_status);
35629 +       hwif->OUTL(ending_dma_addr, dma_base + IOC4_DMA_END_ADDR * 4);
35630 +
35631 +       hwif->OUTL(dma_direction, dma_base + IOC4_DMA_CTRL * 4);
35632 +       drive->waiting_for_dma = 1;
35633 +}
35634 +
35635 +/* IOC4 Scatter Gather list Format                                      */
35636 +/* 128 Bit entries to support 64 bit addresses in the future            */
35637 +/* The Scatter Gather list Entry should be in the BIG-ENDIAN Format     */
35638 +/* --------------------------------------------------------------------- */
35639 +/* | Upper 32 bits - Zero           |          Lower 32 bits- address | */
35640 +/* --------------------------------------------------------------------- */
35641 +/* | Upper 32 bits - Zero          |EOL| 15 unused     | 16 Bit Length| */
35642 +/* --------------------------------------------------------------------- */
35643 +/* Creates the scatter gather list, DMA Table */
35644 +static unsigned int
35645 +sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir)
35646 +{
35647 +       ide_hwif_t *hwif = HWIF(drive);
35648 +       unsigned int *table = hwif->dmatable_cpu;
35649 +       unsigned int count = 0, i = 1;
35650 +       struct scatterlist *sg;
35651 +
35652 +       if (HWGROUP(drive)->rq->flags & REQ_DRIVE_TASKFILE)
35653 +               hwif->sg_nents = i = sgiioc4_ide_raw_build_sglist(drive, rq);
35654 +       else
35655 +               hwif->sg_nents = i = sgiioc4_ide_build_sglist(drive, rq);
35656 +
35657 +       if (!i)
35658 +               return 0;       /* sglist of length Zero */
35659 +
35660 +       sg = hwif->sg_table;
35661 +       while (i && sg_dma_len(sg)) {
35662 +               dma_addr_t cur_addr;
35663 +               int cur_len;
35664 +               cur_addr = sg_dma_address(sg);
35665 +               cur_len = sg_dma_len(sg);
35666 +
35667 +               while (cur_len) {
35668 +                       if (count++ >= IOC4_PRD_ENTRIES) {
35669 +                               printk(KERN_WARNING
35670 +                                      "%s: DMA table too small\n",
35671 +                                      drive->name);
35672 +                               goto use_pio_instead;
35673 +                       } else {
35674 +                               uint32_t xcount, bcount =
35675 +                                   0x10000 - (cur_addr & 0xffff);
35676 +
35677 +                               if (bcount > cur_len)
35678 +                                       bcount = cur_len;
35679 +
35680 +                               /* put the addr, length in
35681 +                                * the IOC4 dma-table format */
35682 +                               *table = 0x0;
35683 +                               table++;
35684 +                               *table = cpu_to_be32(cur_addr);
35685 +                               table++;
35686 +                               *table = 0x0;
35687 +                               table++;
35688 +
35689 +                               xcount = bcount & 0xffff;
35690 +                               *table = cpu_to_be32(xcount);
35691 +                               table++;
35692 +
35693 +                               cur_addr += bcount;
35694 +                               cur_len -= bcount;
35695 +                       }
35696 +               }
35697 +
35698 +               sg++;
35699 +               i--;
35700 +       }
35701 +
35702 +       if (count) {
35703 +               table--;
35704 +               *table |= cpu_to_be32(0x80000000);
35705 +               return count;
35706 +       }
35707 +
35708 +      use_pio_instead:
35709 +       pci_unmap_sg(hwif->pci_dev, hwif->sg_table, hwif->sg_nents,
35710 +                    hwif->sg_dma_direction);
35711 +       hwif->sg_dma_active = 0;
35712 +
35713 +       return 0;               /* revert to PIO for this request */
35714 +}
35715 +
35716 +static int
35717 +sgiioc4_checkirq(ide_hwif_t * hwif)
35718 +{
35719 +       uint8_t intr_reg =
35720 +           hwif->INL(hwif->io_ports[IDE_IRQ_OFFSET] + IOC4_INTR_REG * 4);
35721 +
35722 +       if (intr_reg & 0x03)
35723 +               return 1;
35724 +
35725 +       return 0;
35726 +}
35727 +
35728 +static int
35729 +sgiioc4_clearirq(ide_drive_t * drive)
35730 +{
35731 +       u32 intr_reg;
35732 +       ide_hwif_t *hwif = HWIF(drive);
35733 +       unsigned long other_ir =
35734 +           hwif->io_ports[IDE_IRQ_OFFSET] + (IOC4_INTR_REG << 2);
35735 +
35736 +       /* Code to check for PCI error conditions */
35737 +       intr_reg = hwif->INL(other_ir);
35738 +       if (intr_reg & 0x03) {
35739 +               /* Valid IOC4-IDE interrupt */
35740 +               u8 stat = hwif->INB(IDE_STATUS_REG);
35741 +               int count = 0;
35742 +               do {
35743 +                       xide_delay(count);
35744 +                       stat = hwif->INB(IDE_STATUS_REG);
35745 +                       /* Removes Interrupt from IDE Device */
35746 +               } while ((stat & 0x80) && (count++ < 1024));
35747 +
35748 +               if (intr_reg & 0x02) {
35749 +                       /* Error when transferring DMA data on PCI bus */
35750 +                       uint32_t pci_err_addr_low, pci_err_addr_high,
35751 +                           pci_stat_cmd_reg;
35752 +
35753 +                       pci_err_addr_low =
35754 +                               hwif->INL(hwif->io_ports[IDE_IRQ_OFFSET]);
35755 +                       pci_err_addr_high =
35756 +                               hwif->INL(hwif->io_ports[IDE_IRQ_OFFSET] + 4);
35757 +                       pci_read_config_dword(hwif->pci_dev, PCI_COMMAND,
35758 +                                             &pci_stat_cmd_reg);
35759 +                       printk(KERN_ERR
35760 +                              "%s(%s) : PCI Bus Error when doing DMA:"
35761 +                                  " status-cmd reg is 0x%x\n",
35762 +                              __FUNCTION__, drive->name, pci_stat_cmd_reg);
35763 +                       printk(KERN_ERR
35764 +                              "%s(%s) : PCI Error Address is 0x%x%x\n",
35765 +                              __FUNCTION__, drive->name,
35766 +                              pci_err_addr_high, pci_err_addr_low);
35767 +                       /* Clear the PCI Error indicator */
35768 +                       pci_write_config_dword(hwif->pci_dev, PCI_COMMAND,
35769 +                                              0x00000146);
35770 +               }
35771 +
35772 +               /* Clear the Interrupt, Error bits on the IOC4 */
35773 +               hwif->OUTL(0x03, other_ir);
35774 +
35775 +               intr_reg = hwif->INL(other_ir);
35776 +       }
35777 +
35778 +       return intr_reg;
35779 +}
35780 +
35781 +/**
35782 + *     "Copied from drivers/ide/ide-dma.c"
35783 + *     sgiioc4_ide_build_sglist - map IDE scatter gather for DMA I/O
35784 + *     @hwif: the interface to build the DMA table for
35785 + *     @rq: the request holding the sg list
35786 + *     @ddir: data direction
35787 + *
35788 + *     Perform the PCI mapping magic neccessary to access the source
35789 + *     or target buffers of a request via PCI DMA. The lower layers
35790 + *     of the kernel provide the neccessary cache management so that
35791 + *     we can operate in a portable fashion.
35792 + *
35793 + *     This code is identical to ide_build_sglist in ide-dma.c
35794 + *     however that is not exported.
35795 + */
35796 +
35797 +static int
35798 +sgiioc4_ide_build_sglist(ide_drive_t * drive, struct request *rq)
35799 +{
35800 +       ide_hwif_t *hwif = HWIF(drive);
35801 +       struct scatterlist *sg = hwif->sg_table;
35802 +       int nents;
35803 +
35804 +       if (hwif->sg_dma_active)
35805 +               BUG();
35806 +
35807 +       nents = blk_rq_map_sg(drive->queue, rq, hwif->sg_table);
35808 +
35809 +       if (rq_data_dir(rq) == READ)
35810 +               hwif->sg_dma_direction = PCI_DMA_FROMDEVICE;
35811 +       else
35812 +               hwif->sg_dma_direction = PCI_DMA_TODEVICE;
35813 +
35814 +       return pci_map_sg(hwif->pci_dev, sg, nents, hwif->sg_dma_direction);
35815 +}
35816 +
35817 +/**
35818 + *     Copied from drivers/ide/ide-dma.c
35819 + *     sgiioc4_ide_raw_build_sglist    -       map IDE scatter gather for DMA
35820 + *     @hwif: the interface to build the DMA table for
35821 + *     @rq: the request holding the sg list
35822 + *
35823 + *     Perform the PCI mapping magic neccessary to access the source or
35824 + *     target buffers of a taskfile request via PCI DMA. The lower layers
35825 + *     of the  kernel provide the neccessary cache management so that we can
35826 + *     operate in a portable fashion
35827 + *
35828 + *     This code is identical to ide_raw_build_sglist in ide-dma.c
35829 + *     however that is not exported
35830 + */
35831 +
35832 +static int
35833 +sgiioc4_ide_raw_build_sglist(ide_drive_t * drive, struct request *rq)
35834 +{
35835 +       ide_hwif_t *hwif = HWIF(drive);
35836 +       struct scatterlist *sg = hwif->sg_table;
35837 +       int nents = 0;
35838 +       ide_task_t *args = rq->special;
35839 +       u8 *virt_addr = rq->buffer;
35840 +       int sector_count = rq->nr_sectors;
35841 +
35842 +       if (args->command_type == IDE_DRIVE_TASK_RAW_WRITE)
35843 +               hwif->sg_dma_direction = PCI_DMA_TODEVICE;
35844 +       else
35845 +               hwif->sg_dma_direction = PCI_DMA_FROMDEVICE;
35846 +
35847 +#if 1
35848 +       if (sector_count > 256)
35849 +               BUG();
35850 +
35851 +       if (sector_count > 128) {
35852 +#else
35853 +       while (sector_count > 128) {
35854 +#endif
35855 +               memset(&sg[nents], 0, sizeof (*sg));
35856 +               sg[nents].page = virt_to_page(virt_addr);
35857 +               sg[nents].offset = offset_in_page(virt_addr);
35858 +               sg[nents].length = 128 * SECTOR_SIZE;
35859 +               nents++;
35860 +               virt_addr = virt_addr + (128 * SECTOR_SIZE);
35861 +               sector_count -= 128;
35862 +       }
35863 +       memset(&sg[nents], 0, sizeof (*sg));
35864 +       sg[nents].page = virt_to_page(virt_addr);
35865 +       sg[nents].offset = offset_in_page(virt_addr);
35866 +       sg[nents].length = sector_count * SECTOR_SIZE;
35867 +       nents++;
35868 +
35869 +       return pci_map_sg(hwif->pci_dev, sg, nents, hwif->sg_dma_direction);
35870 +}
35871 +
35872 +#ifdef CONFIG_PROC_FS
35873 +
35874 +static int
35875 +sgiioc4_get_info(char *buffer, char **addr, off_t offset, int count)
35876 +{
35877 +       char *p = buffer;
35878 +       unsigned int class_rev;
35879 +       int i = 0;
35880 +
35881 +       while (i < n_sgiioc4_devs) {
35882 +               pci_read_config_dword(sgiioc4_devs[i], PCI_CLASS_REVISION, &class_rev);
35883 +               class_rev &= 0xff;
35884 +
35885 +               if (sgiioc4_devs[i]->device == PCI_DEVICE_ID_SGI_IOC4) {
35886 +                       p += sprintf(p,
35887 +       "\n\tSGI IOC4 Chipset rev %d.\n\t"
35888 +       "Chipset has 1 IDE channel and supports 2 devices on that channel.\n\t"
35889 +       "Chipset supports DMA in MultiMode-2 data transfer protocol.\n",
35890 +                               class_rev);
35891 +                       /* Do we need more info. here? */
35892 +               }
35893 +               i++;
35894 +       }
35895 +
35896 +       return p - buffer;
35897 +}
35898 +
35899 +#endif                         /* CONFIG_PROC_FS */
35900 +
35901 +static int __devinit
35902 +sgiioc4_init_one(struct pci_dev *dev, const struct pci_device_id *id)
35903 +{
35904 +       unsigned int class_rev;
35905 +       ide_pci_device_t *d = &sgiioc4_chipsets[id->driver_data];
35906 +       if (dev->device != d->device) {
35907 +               printk(KERN_ERR "Error in %s(dev 0x%p | id 0x%p )\n",
35908 +                      __FUNCTION__, (void *) dev, (void *) id);
35909 +               BUG();
35910 +       }
35911 +
35912 +       pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
35913 +       class_rev &= 0xff;
35914 +
35915 +       if (class_rev < IOC4_SUPPORTED_FIRMWARE_REV) {
35916 +               printk(KERN_INFO
35917 +                      "Disabling IOC4 IDE Part due to "
35918 +                      "unsupported Firmware Rev (%d)",
35919 +                      class_rev);
35920 +               printk(KERN_INFO
35921 +                      "\nPlease upgrade to Firmware Rev 46 or higher\n");
35922 +               return 0;
35923 +       }
35924 +
35925 +       printk(KERN_INFO "%s: IDE controller at PCI slot %s\n", d->name,
35926 +              dev->slot_name);
35927 +
35928 +       if (pci_init_sgiioc4(dev, d))
35929 +               return 0;
35930 +
35931 +       MOD_INC_USE_COUNT;
35932 +
35933 +       return 0;
35934 +}
35935 +
35936 +static struct pci_device_id sgiioc4_pci_tbl[] = {
35937 +       {PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC4, PCI_ANY_ID,
35938 +        PCI_ANY_ID, 0x0b4000, 0xFFFFFF, 0},
35939 +       {0}
35940 +};
35941 +
35942 +static struct pci_driver driver = {
35943 +       .name = "SGI-IOC4 IDE",
35944 +       .id_table = sgiioc4_pci_tbl,
35945 +       .probe = sgiioc4_init_one,
35946 +};
35947 +
35948 +static int
35949 +sgiioc4_ide_init(void)
35950 +{
35951 +       return ide_pci_register_driver(&driver);
35952 +}
35953 +
35954 +static void
35955 +sgiioc4_ide_exit(void)
35956 +{
35957 +       ide_pci_unregister_driver(&driver);
35958 +}
35959 +
35960 +module_init(sgiioc4_ide_init);
35961 +module_exit(sgiioc4_ide_exit);
35962 +
35963 +MODULE_AUTHOR("Aniket Malatpure - Silicon Graphics Inc. (SGI)");
35964 +MODULE_DESCRIPTION("PCI driver module for SGI IOC4 Base-IO Card");
35965 +MODULE_LICENSE("GPL");
35966 --- linux-2.6.0-test6/drivers/ide/pci/siimage.c 2003-09-08 13:58:57.000000000 -0700
35967 +++ 25/drivers/ide/pci/siimage.c        2003-10-05 00:33:24.000000000 -0700
35968 @@ -1150,20 +1150,6 @@ static void __init init_hwif_siimage (id
35969         hwif->drives[1].autodma = hwif->autodma;
35970  }
35971  
35972 -/**
35973 - *     init_dma_siimage        -       set up IDE DMA
35974 - *     @hwif: interface
35975 - *     @dmabase: DMA base address to use
35976 - *     
35977 - *     For the SI chips this requires no special set up so we can just
35978 - *     let the IDE DMA core do the usual work.
35979 - */
35980
35981 -static void __init init_dma_siimage (ide_hwif_t *hwif, unsigned long dmabase)
35982 -{
35983 -       ide_setup_dma(hwif, dmabase, 8);
35984 -}
35985 -
35986  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
35987  
35988  
35989 --- linux-2.6.0-test6/drivers/ide/pci/siimage.h 2003-09-08 13:58:57.000000000 -0700
35990 +++ 25/drivers/ide/pci/siimage.h        2003-10-05 00:33:24.000000000 -0700
35991 @@ -44,7 +44,6 @@ static ide_pci_host_proc_t siimage_procs
35992  static unsigned int init_chipset_siimage(struct pci_dev *, const char *);
35993  static void init_iops_siimage(ide_hwif_t *);
35994  static void init_hwif_siimage(ide_hwif_t *);
35995 -static void init_dma_siimage(ide_hwif_t *, unsigned long);
35996  
35997  static ide_pci_device_t siimage_chipsets[] __devinitdata = {
35998         {       /* 0 */
35999 @@ -54,7 +53,6 @@ static ide_pci_device_t siimage_chipsets
36000                 .init_chipset   = init_chipset_siimage,
36001                 .init_iops      = init_iops_siimage,
36002                 .init_hwif      = init_hwif_siimage,
36003 -               .init_dma       = init_dma_siimage,
36004                 .channels       = 2,
36005                 .autodma        = AUTODMA,
36006                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
36007 @@ -67,7 +65,6 @@ static ide_pci_device_t siimage_chipsets
36008                 .init_chipset   = init_chipset_siimage,
36009                 .init_iops      = init_iops_siimage,
36010                 .init_hwif      = init_hwif_siimage,
36011 -               .init_dma       = init_dma_siimage,
36012                 .channels       = 2,
36013                 .autodma        = AUTODMA,
36014                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
36015 @@ -80,7 +77,6 @@ static ide_pci_device_t siimage_chipsets
36016                 .init_chipset   = init_chipset_siimage,
36017                 .init_iops      = init_iops_siimage,
36018                 .init_hwif      = init_hwif_siimage,
36019 -               .init_dma       = init_dma_siimage,
36020                 .channels       = 2,
36021                 .autodma        = AUTODMA,
36022                 .enablebits     = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
36023 --- linux-2.6.0-test6/drivers/ide/pci/sis5513.c 2003-09-08 13:58:57.000000000 -0700
36024 +++ 25/drivers/ide/pci/sis5513.c        2003-10-05 00:33:24.000000000 -0700
36025 @@ -942,11 +942,6 @@ static void __init init_hwif_sis5513 (id
36026         return;
36027  }
36028  
36029 -static void __init init_dma_sis5513 (ide_hwif_t *hwif, unsigned long dmabase)
36030 -{
36031 -       ide_setup_dma(hwif, dmabase, 8);
36032 -}
36033 -
36034  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
36035  
36036  
36037 --- linux-2.6.0-test6/drivers/ide/pci/sis5513.h 2003-06-14 12:18:24.000000000 -0700
36038 +++ 25/drivers/ide/pci/sis5513.h        2003-10-05 00:33:24.000000000 -0700
36039 @@ -27,7 +27,6 @@ static ide_pci_host_proc_t sis_procs[] _
36040  
36041  static unsigned int init_chipset_sis5513(struct pci_dev *, const char *);
36042  static void init_hwif_sis5513(ide_hwif_t *);
36043 -static void init_dma_sis5513(ide_hwif_t *, unsigned long);
36044  
36045  static ide_pci_device_t sis5513_chipsets[] __devinitdata = {
36046         {       /* 0 */
36047 @@ -37,7 +36,6 @@ static ide_pci_device_t sis5513_chipsets
36048                 .init_chipset   = init_chipset_sis5513,
36049                 .init_iops      = NULL,
36050                 .init_hwif      = init_hwif_sis5513,
36051 -               .init_dma       = init_dma_sis5513,
36052                 .channels       = 2,
36053                 .autodma        = NOAUTODMA,
36054                 .enablebits     = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
36055 --- linux-2.6.0-test6/drivers/ide/pci/slc90e66.c        2003-09-08 13:58:57.000000000 -0700
36056 +++ 25/drivers/ide/pci/slc90e66.c       2003-10-05 00:33:24.000000000 -0700
36057 @@ -362,11 +362,6 @@ static void __init init_hwif_slc90e66 (i
36058  #endif /* !CONFIG_BLK_DEV_IDEDMA */
36059  }
36060  
36061 -static void __init init_dma_slc90e66 (ide_hwif_t *hwif, unsigned long dmabase)
36062 -{
36063 -       ide_setup_dma(hwif, dmabase, 8);
36064 -}
36065 -
36066  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
36067  
36068  
36069 --- linux-2.6.0-test6/drivers/ide/pci/slc90e66.h        2003-06-14 12:18:05.000000000 -0700
36070 +++ 25/drivers/ide/pci/slc90e66.h       2003-10-05 00:33:24.000000000 -0700
36071 @@ -29,7 +29,6 @@ static ide_pci_host_proc_t slc90e66_proc
36072  
36073  static unsigned int init_chipset_slc90e66(struct pci_dev *, const char *);
36074  static void init_hwif_slc90e66(ide_hwif_t *);
36075 -static void init_dma_slc90e66(ide_hwif_t *, unsigned long);
36076  
36077  static ide_pci_device_t slc90e66_chipsets[] __devinitdata = {
36078         {       /* 0 */
36079 @@ -39,7 +38,6 @@ static ide_pci_device_t slc90e66_chipset
36080                 .init_chipset   = init_chipset_slc90e66,
36081                 .init_iops      = NULL,
36082                 .init_hwif      = init_hwif_slc90e66,
36083 -               .init_dma       = init_dma_slc90e66,
36084                 .channels       = 2,
36085                 .autodma        = AUTODMA,
36086                 .enablebits     = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
36087 --- linux-2.6.0-test6/drivers/ide/pci/via82cxxx.c       2003-08-08 22:55:11.000000000 -0700
36088 +++ 25/drivers/ide/pci/via82cxxx.c      2003-10-05 00:33:24.000000000 -0700
36089 @@ -1,6 +1,6 @@
36090  /*
36091   *
36092 - * Version 3.37
36093 + * Version 3.38
36094   *
36095   * VIA IDE driver for Linux. Supported southbridges:
36096   *
36097 @@ -96,7 +96,6 @@ static struct via_isa_bridge {
36098  };
36099  
36100  static struct via_isa_bridge *via_config;
36101 -static unsigned char via_enabled;
36102  static unsigned int via_80w;
36103  static unsigned int via_clock;
36104  static char *via_dma[] = { "MWDMA16", "UDMA33", "UDMA66", "UDMA100", "UDMA133" };
36105 @@ -146,7 +145,7 @@ static int via_get_info(char *buffer, ch
36106         via_print("----------VIA BusMastering IDE Configuration"
36107                 "----------------");
36108  
36109 -       via_print("Driver Version:                     3.37");
36110 +       via_print("Driver Version:                     3.38");
36111         via_print("South Bridge:                       VIA %s",
36112                 via_config->name);
36113  
36114 @@ -370,9 +369,6 @@ static int via_set_drive(ide_drive_t *dr
36115  
36116  static void via82cxxx_tune_drive(ide_drive_t *drive, u8 pio)
36117  {
36118 -       if (!((via_enabled >> HWIF(drive)->channel) & 1))
36119 -               return;
36120 -
36121         if (pio == 255) {
36122                 via_set_drive(drive,
36123                         ide_find_best_mode(drive, XFER_PIO | XFER_EPIO));
36124 @@ -506,7 +502,6 @@ static unsigned int __init init_chipset_
36125          */
36126  
36127         pci_read_config_byte(dev, VIA_IDE_ENABLE, &v);
36128 -       via_enabled = ((v & 1) ? 2 : 0) | ((v & 2) ? 1 : 0);
36129  
36130         /*
36131          * Set up FIFO sizes and thresholds.
36132 @@ -523,9 +518,9 @@ static unsigned int __init init_chipset_
36133         /* Fix FIFO split between channels */
36134         if (via_config->flags & VIA_SET_FIFO) {
36135                 t &= (t & 0x9f);
36136 -               switch (via_enabled) {
36137 -                       case 1: t |= 0x00; break;       /* 16 on primary */
36138 -                       case 2: t |= 0x60; break;       /* 16 on secondary */
36139 +               switch (v & 3) {
36140 +                       case 2: t |= 0x00; break;       /* 16 on primary */
36141 +                       case 1: t |= 0x60; break;       /* 16 on secondary */
36142                         case 3: t |= 0x20; break;       /* 8 pri 8 sec */
36143                 }
36144         }
36145 @@ -603,8 +598,8 @@ static void __init init_hwif_via82cxxx(i
36146         hwif->mwdma_mask = 0x07;
36147         hwif->swdma_mask = 0x07;
36148  
36149 -       if (!(hwif->udma_four))
36150 -               hwif->udma_four = ((via_enabled & via_80w) >> hwif->channel) & 1;
36151 +       if (!hwif->udma_four)
36152 +               hwif->udma_four = (via_80w >> hwif->channel) & 1;
36153         hwif->ide_dma_check = &via82cxxx_ide_dma_check;
36154         if (!noautodma)
36155                 hwif->autodma = 1;
36156 @@ -612,20 +607,6 @@ static void __init init_hwif_via82cxxx(i
36157         hwif->drives[1].autodma = hwif->autodma;
36158  }
36159  
36160 -/**
36161 - *     init_dma_via82cxxx      -       set up for IDE DMA
36162 - *     @hwif: IDE interface
36163 - *     @dmabase: DMA base address
36164 - *
36165 - *     We allow the BM-DMA driver to only work on enabled interfaces.
36166 - */
36167 -
36168 -static void __init init_dma_via82cxxx(ide_hwif_t *hwif, unsigned long dmabase)
36169 -{
36170 -       if ((via_enabled >> hwif->channel) & 1)
36171 -               ide_setup_dma(hwif, dmabase, 8);
36172 -}
36173 -
36174  extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
36175  
36176  static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id)
36177 --- linux-2.6.0-test6/drivers/ide/pci/via82cxxx.h       2003-06-14 12:18:24.000000000 -0700
36178 +++ 25/drivers/ide/pci/via82cxxx.h      2003-10-05 00:33:24.000000000 -0700
36179 @@ -27,7 +27,6 @@ static ide_pci_host_proc_t via_procs[] _
36180  
36181  static unsigned int init_chipset_via82cxxx(struct pci_dev *, const char *);
36182  static void init_hwif_via82cxxx(ide_hwif_t *);
36183 -static void init_dma_via82cxxx(ide_hwif_t *, unsigned long);
36184  
36185  static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = {
36186         {       /* 0 */
36187 @@ -35,9 +34,7 @@ static ide_pci_device_t via82cxxx_chipse
36188                 .device         = PCI_DEVICE_ID_VIA_82C576_1,
36189                 .name           = "VP_IDE",
36190                 .init_chipset   = init_chipset_via82cxxx,
36191 -               .init_iops      = NULL,
36192                 .init_hwif      = init_hwif_via82cxxx,
36193 -               .init_dma       = init_dma_via82cxxx,
36194                 .channels       = 2,
36195                 .autodma        = NOAUTODMA,
36196                 .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
36197 @@ -48,9 +45,7 @@ static ide_pci_device_t via82cxxx_chipse
36198                 .device         = PCI_DEVICE_ID_VIA_82C586_1,
36199                 .name           = "VP_IDE",
36200                 .init_chipset   = init_chipset_via82cxxx,
36201 -               .init_iops      = NULL,
36202                 .init_hwif      = init_hwif_via82cxxx,
36203 -               .init_dma       = init_dma_via82cxxx,
36204                 .channels       = 2,
36205                 .autodma        = NOAUTODMA,
36206                 .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
36207 --- linux-2.6.0-test6/drivers/input/input.c     2003-09-27 18:57:44.000000000 -0700
36208 +++ 25/drivers/input/input.c    2003-10-05 00:34:14.000000000 -0700
36209 @@ -447,9 +447,10 @@ void input_register_device(struct input_
36210         list_add_tail(&dev->node, &input_dev_list);
36211  
36212         list_for_each_entry(handler, &input_handler_list, node)
36213 -               if ((id = input_match_device(handler->id_table, dev)))
36214 -                       if ((handle = handler->connect(handler, dev, id)))
36215 -                               input_link_handle(handle);
36216 +               if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
36217 +                       if ((id = input_match_device(handler->id_table, dev)))
36218 +                               if ((handle = handler->connect(handler, dev, id)))
36219 +                                       input_link_handle(handle);
36220  
36221  #ifdef CONFIG_HOTPLUG
36222         input_call_hotplug("add", dev);
36223 @@ -507,9 +508,10 @@ void input_register_handler(struct input
36224         list_add_tail(&handler->node, &input_handler_list);
36225         
36226         list_for_each_entry(dev, &input_dev_list, node)
36227 -               if ((id = input_match_device(handler->id_table, dev)))
36228 -                       if ((handle = handler->connect(handler, dev, id)))
36229 -                               input_link_handle(handle);
36230 +               if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
36231 +                       if ((id = input_match_device(handler->id_table, dev)))
36232 +                               if ((handle = handler->connect(handler, dev, id)))
36233 +                                       input_link_handle(handle);
36234  
36235  #ifdef CONFIG_PROC_FS
36236         input_devices_state++;
36237 --- linux-2.6.0-test6/drivers/input/joydev.c    2003-09-08 13:58:57.000000000 -0700
36238 +++ 25/drivers/input/joydev.c   2003-10-05 00:34:14.000000000 -0700
36239 @@ -380,10 +380,6 @@ static struct input_handle *joydev_conne
36240         struct joydev *joydev;
36241         int i, j, t, minor;
36242  
36243 -       /* Avoid tablets */
36244 -        if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_TOUCH, dev->keybit))
36245 -               return NULL;
36246 -
36247         for (minor = 0; minor < JOYDEV_MINORS && joydev_table[minor]; minor++);
36248         if (minor == JOYDEV_MINORS) {
36249                 printk(KERN_ERR "joydev: no more free joydev devices\n");
36250 @@ -464,6 +460,15 @@ static void joydev_disconnect(struct inp
36251                 joydev_free(joydev);
36252  }
36253  
36254 +static struct input_device_id joydev_blacklist[] = {
36255 +       {
36256 +               .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT,
36257 +               .evbit = { BIT(EV_KEY) },
36258 +               .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) },
36259 +       },      /* Avoid itouchpads, touchscreens and tablets */
36260 +       { },    /* Terminating entry */
36261 +};
36262 +
36263  static struct input_device_id joydev_ids[] = {
36264         {
36265                 .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
36266 @@ -493,6 +498,7 @@ static struct input_handler joydev_handl
36267         .minor =        JOYDEV_MINOR_BASE,
36268         .name =         "joydev",
36269         .id_table =     joydev_ids,
36270 +       .blacklist =    joydev_blacklist,
36271  };
36272  
36273  static int __init joydev_init(void)
36274 --- linux-2.6.0-test6/drivers/input/joystick/analog.c   2003-06-16 22:32:21.000000000 -0700
36275 +++ 25/drivers/input/joystick/analog.c  2003-10-05 00:33:24.000000000 -0700
36276 @@ -159,7 +159,7 @@ static unsigned int get_time_pit(void)
36277  #define DELTA(x,y)     ((y)-(x))
36278  #define TIME_NAME      "TSC"
36279  #elif __alpha__
36280 -#define GET_TIME(x)    do { x = get_cycles(x); } while (0)
36281 +#define GET_TIME(x)    do { x = get_cycles(); } while (0)
36282  #define DELTA(x,y)     ((y)-(x))
36283  #define TIME_NAME      "PCC"
36284  #else
36285 --- linux-2.6.0-test6/drivers/input/keyboard/atkbd.c    2003-09-27 18:57:44.000000000 -0700
36286 +++ 25/drivers/input/keyboard/atkbd.c   2003-10-05 00:36:37.000000000 -0700
36287 @@ -369,10 +369,11 @@ static int atkbd_command(struct atkbd *a
36288  static int atkbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
36289  {
36290         struct atkbd *atkbd = dev->private;
36291 -       struct { int p; u8 v; } period[] =      
36292 -               { {30, 0x00}, {25, 0x02}, {20, 0x04}, {15, 0x08}, {10, 0x0c}, {7, 0x10}, {5, 0x14}, {0, 0x14} };
36293 -       struct { int d; u8 v; } delay[] =
36294 -               { {1000, 0x60}, {750, 0x40}, {500, 0x20}, {250, 0x00}, {0, 0x00} };
36295 +       const short period[32] =
36296 +               { 33,  37,  42,  46,  50,  54,  58,  63,  67,  75,  83,  92, 100, 109, 116, 125,
36297 +                133, 149, 167, 182, 200, 217, 232, 250, 270, 303, 333, 370, 400, 435, 470, 500 };
36298 +       const short delay[4] =
36299 +               { 250, 500, 750, 1000 };
36300         char param[2];
36301         int i, j;
36302  
36303 @@ -406,11 +407,11 @@ static int atkbd_event(struct input_dev 
36304                         if (atkbd_softrepeat) return 0;
36305  
36306                         i = j = 0;
36307 -                       while (period[i].p > dev->rep[REP_PERIOD]) i++;
36308 -                       while (delay[j].d > dev->rep[REP_DELAY]) j++;
36309 -                       dev->rep[REP_PERIOD] = period[i].p;
36310 -                       dev->rep[REP_DELAY] = delay[j].d;
36311 -                       param[0] = period[i].v | delay[j].v;
36312 +                       while (i < 32 && period[i] < dev->rep[REP_PERIOD]) i++;
36313 +                       while (j < 4 && delay[j] < dev->rep[REP_DELAY]) j++;
36314 +                       dev->rep[REP_PERIOD] = period[i];
36315 +                       dev->rep[REP_DELAY] = delay[j];
36316 +                       param[0] = i | (j << 5);
36317                         atkbd_command(atkbd, param, ATKBD_CMD_SETREP);
36318  
36319                         return 0;
36320 @@ -576,6 +577,7 @@ static void atkbd_disconnect(struct seri
36321         struct atkbd *atkbd = serio->private;
36322         input_unregister_device(&atkbd->dev);
36323         serio_close(serio);
36324 +       serio->private = NULL;
36325         kfree(atkbd);
36326  }
36327  
36328 @@ -634,6 +636,7 @@ static void atkbd_connect(struct serio *
36329         serio->private = atkbd;
36330  
36331         if (serio_open(serio, dev)) {
36332 +               serio->private = NULL;
36333                 kfree(atkbd);
36334                 return;
36335         }
36336 @@ -642,6 +645,7 @@ static void atkbd_connect(struct serio *
36337  
36338                 if (atkbd_probe(atkbd)) {
36339                         serio_close(serio);
36340 +                       serio->private = NULL;
36341                         kfree(atkbd);
36342                         return;
36343                 }
36344 --- linux-2.6.0-test6/drivers/input/keyboard/Kconfig    2003-09-27 18:57:44.000000000 -0700
36345 +++ 25/drivers/input/keyboard/Kconfig   2003-10-05 00:33:24.000000000 -0700
36346 @@ -12,10 +12,11 @@ config INPUT_KEYBOARD
36347           If unsure, say Y.
36348  
36349  config KEYBOARD_ATKBD
36350 -       tristate "AT keyboard support" if EMBEDDED || !X86 
36351 +       tristate "AT keyboard support" if !PC
36352         default y
36353         depends on INPUT && INPUT_KEYBOARD
36354 -       select SERIO_I8042
36355 +       select SERIO
36356 +       select SERIO_I8042 if PC
36357         help
36358           Say Y here if you want to use a standard AT or PS/2 keyboard. Usually
36359           you'll need this, unless you have a different type keyboard (USB, ADB
36360 --- linux-2.6.0-test6/drivers/input/mouse/Kconfig       2003-09-27 18:57:44.000000000 -0700
36361 +++ 25/drivers/input/mouse/Kconfig      2003-10-05 00:33:24.000000000 -0700
36362 @@ -15,7 +15,8 @@ config MOUSE_PS2
36363         tristate "PS/2 mouse"
36364         default y
36365         depends on INPUT && INPUT_MOUSE
36366 -       select SERIO_I8042
36367 +       select SERIO
36368 +       select SERIO_I8042 if PC
36369         ---help---
36370           Say Y here if you have a PS/2 mouse connected to your system. This
36371           includes the standard 2 or 3-button PS/2 mouse, as well as PS/2
36372 --- linux-2.6.0-test6/drivers/input/mouse/logips2pp.c   2003-06-22 12:04:44.000000000 -0700
36373 +++ 25/drivers/input/mouse/logips2pp.c  2003-10-05 00:34:15.000000000 -0700
36374 @@ -10,6 +10,7 @@
36375   */
36376  
36377  #include <linux/input.h>
36378 +#include <linux/serio.h>
36379  #include "psmouse.h"
36380  #include "logips2pp.h"
36381  
36382 --- linux-2.6.0-test6/drivers/input/mouse/psmouse-base.c        2003-09-27 18:57:44.000000000 -0700
36383 +++ 25/drivers/input/mouse/psmouse-base.c       2003-10-05 00:34:15.000000000 -0700
36384 @@ -141,7 +141,8 @@ static irqreturn_t psmouse_interrupt(str
36385                 goto out;
36386         }
36387  
36388 -       if (psmouse->pktcnt && time_after(jiffies, psmouse->last + HZ/2)) {
36389 +       if (psmouse->state == PSMOUSE_ACTIVATED && 
36390 +           psmouse->pktcnt && time_after(jiffies, psmouse->last + HZ/2)) {
36391                 printk(KERN_WARNING "psmouse.c: %s at %s lost synchronization, throwing %d bytes away.\n",
36392                        psmouse->name, psmouse->phys, psmouse->pktcnt);
36393                 psmouse->pktcnt = 0;
36394 @@ -276,24 +277,18 @@ static int psmouse_extensions(struct psm
36395                 return PSMOUSE_PS2;
36396  
36397  /*
36398 - * Try Synaptics TouchPad magic ID
36399 + * Try Synaptics TouchPad
36400   */
36401 -
36402 -       param[0] = 0;
36403 -       psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
36404 -       psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
36405 -       psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
36406 -       psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
36407 -       psmouse_command(psmouse, param, PSMOUSE_CMD_GETINFO);
36408 -
36409 -       if (param[1] == 0x47) {
36410 +       if (synaptics_detect(psmouse) == 0) {
36411                 psmouse->vendor = "Synaptics";
36412                 psmouse->name = "TouchPad";
36413 -               if (!synaptics_init(psmouse))
36414 +
36415 +#if CONFIG_MOUSE_PS2_SYNAPTICS
36416 +               if (synaptics_init(psmouse) == 0)
36417                         return PSMOUSE_SYNAPTICS;
36418 -               else
36419 -                       return PSMOUSE_PS2;
36420 -       }
36421 +#endif
36422 +               return PSMOUSE_PS2;
36423 +       }
36424  
36425  /*
36426   * Try Genius NetMouse magic init.
36427 @@ -519,7 +514,18 @@ static void psmouse_disconnect(struct se
36428         struct psmouse *psmouse = serio->private;
36429  
36430         psmouse->state = PSMOUSE_IGNORE;
36431 -       synaptics_disconnect(psmouse);
36432 +       
36433 +       if (psmouse->ptport) {
36434 +               if (psmouse->ptport->deactivate)
36435 +                       psmouse->ptport->deactivate(psmouse);
36436 +               __serio_unregister_port(&psmouse->ptport->serio); /* we have serio_sem */
36437 +               kfree(psmouse->ptport);
36438 +               psmouse->ptport = NULL;
36439 +       }
36440 +               
36441 +       if (psmouse->disconnect)
36442 +               psmouse->disconnect(psmouse);
36443 +       
36444         input_unregister_device(&psmouse->dev);
36445         serio_close(serio);
36446         kfree(psmouse);
36447 @@ -532,20 +538,10 @@ static void psmouse_disconnect(struct se
36448  static int psmouse_pm_callback(struct pm_dev *dev, pm_request_t request, void *data)
36449  {
36450         struct psmouse *psmouse = dev->data;
36451 -       struct serio_dev *ser_dev = psmouse->serio->dev;
36452 -
36453 -       synaptics_disconnect(psmouse);
36454 -
36455 -       /* We need to reopen the serio port to reinitialize the i8042 controller */
36456 -       serio_close(psmouse->serio);
36457 -       serio_open(psmouse->serio, ser_dev);
36458 -
36459 -       /* Probe and re-initialize the mouse */
36460 -       psmouse_probe(psmouse);
36461 -       psmouse_initialize(psmouse);
36462 -       synaptics_pt_init(psmouse);
36463 -       psmouse_activate(psmouse);
36464  
36465 +       psmouse->state = PSMOUSE_IGNORE;
36466 +       serio_reconnect(psmouse->serio);
36467 +       
36468         return 0;
36469  }
36470  
36471 @@ -553,7 +549,6 @@ static int psmouse_pm_callback(struct pm
36472   * psmouse_connect() is a callback from the serio module when
36473   * an unhandled serio port is found.
36474   */
36475 -
36476  static void psmouse_connect(struct serio *serio, struct serio_dev *dev)
36477  {
36478         struct psmouse *psmouse;
36479 @@ -578,7 +573,6 @@ static void psmouse_connect(struct serio
36480         psmouse->dev.private = psmouse;
36481  
36482         serio->private = psmouse;
36483 -
36484         if (serio_open(serio, dev)) {
36485                 kfree(psmouse);
36486                 return;
36487 @@ -590,10 +584,12 @@ static void psmouse_connect(struct serio
36488                 return;
36489         }
36490         
36491 -       pmdev = pm_register(PM_SYS_DEV, PM_SYS_UNKNOWN, psmouse_pm_callback);
36492 -       if (pmdev) {
36493 -               psmouse->dev.pm_dev = pmdev;
36494 -               pmdev->data = psmouse;
36495 +       if (serio->type != SERIO_PS_PSTHRU) {
36496 +               pmdev = pm_register(PM_SYS_DEV, PM_SYS_UNKNOWN, psmouse_pm_callback);
36497 +               if (pmdev) {
36498 +                       psmouse->dev.pm_dev = pmdev;
36499 +                       pmdev->data = psmouse;
36500 +               }
36501         }
36502  
36503         sprintf(psmouse->devname, "%s %s %s",
36504 @@ -614,14 +610,70 @@ static void psmouse_connect(struct serio
36505  
36506         psmouse_initialize(psmouse);
36507  
36508 -       synaptics_pt_init(psmouse);
36509 +       if (psmouse->ptport) {
36510 +               printk(KERN_INFO "serio: %s port at %s\n", psmouse->ptport->serio.name, psmouse->phys);
36511 +               __serio_register_port(&psmouse->ptport->serio); /* we have serio_sem */
36512 +               if (psmouse->ptport->activate)
36513 +                       psmouse->ptport->activate(psmouse);
36514 +       }
36515 +       
36516 +       psmouse_activate(psmouse);
36517 +}
36518  
36519 +
36520 +static int psmouse_reconnect(struct serio *serio)
36521 +{
36522 +       struct psmouse *psmouse = serio->private;
36523 +       struct serio_dev *dev = serio->dev;
36524 +       int old_type = psmouse->type;
36525 +       
36526 +       if (!dev) {
36527 +               printk(KERN_DEBUG "psmouse: reconnect request, but serio is disconnected, ignoring...\n");
36528 +               return -1;
36529 +       }
36530 +       
36531 +       /* We need to reopen the serio port to reinitialize the i8042 controller */
36532 +       serio_close(serio);
36533 +       if (serio_open(serio, dev)) {
36534 +               /* do a disconnect here as serio_open leaves dev as NULL so disconnect 
36535 +                * will not be called automatically later
36536 +                */
36537 +               psmouse_disconnect(serio);
36538 +               return -1;
36539 +       }
36540 +       
36541 +       psmouse->state = PSMOUSE_NEW_DEVICE;
36542 +       psmouse->type = psmouse->acking = psmouse->cmdcnt = psmouse->pktcnt = 0;
36543 +       if (psmouse->reconnect) {
36544 +              if (psmouse->reconnect(psmouse))
36545 +                       return -1;
36546 +       } else if (psmouse_probe(psmouse) != old_type)
36547 +               return -1;
36548 +       
36549 +       /* ok, the device type (and capabilities) match the old one,
36550 +        * we can continue using it, complete intialization
36551 +        */ 
36552 +       psmouse->type = old_type;
36553 +       psmouse_initialize(psmouse);
36554 +
36555 +       if (psmouse->ptport) {
36556 +                       if (psmouse_reconnect(&psmouse->ptport->serio)) {
36557 +                       __serio_unregister_port(&psmouse->ptport->serio);
36558 +                       __serio_register_port(&psmouse->ptport->serio);
36559 +                       if (psmouse->ptport->activate)
36560 +                               psmouse->ptport->activate(psmouse);
36561 +               }
36562 +       }
36563 +       
36564         psmouse_activate(psmouse);
36565 +       return 0;
36566  }
36567  
36568 +
36569  static struct serio_dev psmouse_dev = {
36570         .interrupt =    psmouse_interrupt,
36571         .connect =      psmouse_connect,
36572 +       .reconnect =    psmouse_reconnect,
36573         .disconnect =   psmouse_disconnect,
36574         .cleanup =      psmouse_cleanup,
36575  };
36576 --- linux-2.6.0-test6/drivers/input/mouse/psmouse.h     2003-09-27 18:57:44.000000000 -0700
36577 +++ 25/drivers/input/mouse/psmouse.h    2003-10-05 00:34:15.000000000 -0700
36578 @@ -22,10 +22,20 @@
36579  #define PSMOUSE_ACTIVATED      1
36580  #define PSMOUSE_IGNORE         2
36581  
36582 +struct psmouse;
36583 +
36584 +struct psmouse_ptport {
36585 +       struct serio serio;
36586 +
36587 +       void (*activate)(struct psmouse *parent);
36588 +       void (*deactivate)(struct psmouse *parent);
36589 +};
36590 +
36591  struct psmouse {
36592         void *private;
36593         struct input_dev dev;
36594         struct serio *serio;
36595 +       struct psmouse_ptport *ptport;
36596         char *vendor;
36597         char *name;
36598         unsigned char cmdbuf[8];
36599 @@ -41,6 +51,9 @@ struct psmouse {
36600         char error;
36601         char devname[64];
36602         char phys[32];
36603 +       
36604 +       int (*reconnect)(struct psmouse *psmouse);
36605 +       void (*disconnect)(struct psmouse *psmouse);
36606  };
36607  
36608  #define PSMOUSE_PS2            1
36609 --- linux-2.6.0-test6/drivers/input/mouse/synaptics.c   2003-09-27 18:57:44.000000000 -0700
36610 +++ 25/drivers/input/mouse/synaptics.c  2003-10-05 00:34:15.000000000 -0700
36611 @@ -2,7 +2,8 @@
36612   * Synaptics TouchPad PS/2 mouse driver
36613   *
36614   *   2003 Dmitry Torokhov <dtor@mail.ru>
36615 - *     Added support for pass-through port
36616 + *     Added support for pass-through port. Special thanks to Peter Berg Larsen
36617 + *     for explaining various Synaptics quirks.
36618   *
36619   *   2003 Peter Osterlund <petero2@telia.com>
36620   *     Ported to 2.5 input device infrastructure.
36621 @@ -194,9 +195,7 @@ static void print_ident(struct synaptics
36622  
36623  static int synaptics_query_hardware(struct psmouse *psmouse)
36624  {
36625 -       struct synaptics_data *priv = psmouse->private;
36626         int retries = 0;
36627 -       int mode;
36628  
36629         while ((retries++ < 3) && synaptics_reset(psmouse))
36630                 printk(KERN_ERR "synaptics reset failed\n");
36631 @@ -207,8 +206,15 @@ static int synaptics_query_hardware(stru
36632                 return -1;
36633         if (synaptics_capability(psmouse))
36634                 return -1;
36635 +       
36636 +       return 0;
36637 +}
36638  
36639 -       mode = SYN_BIT_ABSOLUTE_MODE | SYN_BIT_HIGH_RATE;
36640 +static int synaptics_set_mode(struct psmouse *psmouse, int mode)
36641 +{
36642 +       struct synaptics_data *priv = psmouse->private;
36643 +
36644 +       mode |= SYN_BIT_ABSOLUTE_MODE | SYN_BIT_HIGH_RATE;
36645         if (SYN_ID_MAJOR(priv->identity) >= 4)
36646                 mode |= SYN_BIT_DISABLE_GESTURE;
36647         if (SYN_CAP_EXTENDED(priv->capabilities))
36648 @@ -265,49 +271,38 @@ static void synaptics_pass_pt_packet(str
36649         }
36650  }
36651  
36652 -int synaptics_pt_init(struct psmouse *psmouse)
36653 +static void synaptics_pt_activate(struct psmouse *psmouse)
36654  {
36655 -       struct synaptics_data *priv = psmouse->private;
36656 -       struct serio *port;
36657 -       struct psmouse *child;
36658 +       struct psmouse *child = psmouse->ptport->serio.private;
36659 +       
36660 +       /* adjust the touchpad to child's choice of protocol */
36661 +       if (child && child->type >= PSMOUSE_GENPS) {
36662 +               if (synaptics_set_mode(psmouse, SYN_BIT_FOUR_BYTE_CLIENT))
36663 +                       printk(KERN_INFO "synaptics: failed to enable 4-byte guest protocol\n");
36664 +       }
36665 +}
36666  
36667 -       if (psmouse->type != PSMOUSE_SYNAPTICS)
36668 -               return -1;
36669 -       if (!SYN_CAP_EXTENDED(priv->capabilities))
36670 -               return -1;
36671 -       if (!SYN_CAP_PASS_THROUGH(priv->capabilities))
36672 -               return -1;
36673 +static void synaptics_pt_create(struct psmouse *psmouse)
36674 +{
36675 +       struct psmouse_ptport *port;
36676  
36677 -       priv->ptport = port = kmalloc(sizeof(struct serio), GFP_KERNEL);
36678 +       psmouse->ptport = port = kmalloc(sizeof(struct psmouse_ptport), GFP_KERNEL);
36679         if (!port) {
36680 -               printk(KERN_ERR "synaptics: not enough memory to allocate serio port\n");
36681 -               return -1;
36682 +               printk(KERN_ERR "synaptics: not enough memory to allocate pass-through port\n");
36683 +               return;
36684         }
36685  
36686 -       memset(port, 0, sizeof(struct serio));
36687 -       port->type = SERIO_PS_PSTHRU;
36688 -       port->name = "Synaptics pass-through";
36689 -       port->phys = "synaptics-pt/serio0";
36690 -       port->write = synaptics_pt_write;
36691 -       port->open = synaptics_pt_open;
36692 -       port->close = synaptics_pt_close;
36693 -       port->driver = psmouse;
36694 +       memset(port, 0, sizeof(struct psmouse_ptport));
36695  
36696 -       printk(KERN_INFO "serio: %s port at %s\n", port->name, psmouse->phys);
36697 -       serio_register_slave_port(port);
36698 +       port->serio.type = SERIO_PS_PSTHRU;
36699 +       port->serio.name = "Synaptics pass-through";
36700 +       port->serio.phys = "synaptics-pt/serio0";
36701 +       port->serio.write = synaptics_pt_write;
36702 +       port->serio.open = synaptics_pt_open;
36703 +       port->serio.close = synaptics_pt_close;
36704 +       port->serio.driver = psmouse;
36705  
36706 -       /* adjust the touchpad to child's choice of protocol */
36707 -       child = port->private;
36708 -       if (child && child->type >= PSMOUSE_GENPS) {
36709 -               if (synaptics_mode_cmd(psmouse, (SYN_BIT_ABSOLUTE_MODE |
36710 -                                                SYN_BIT_HIGH_RATE |
36711 -                                                SYN_BIT_DISABLE_GESTURE |
36712 -                                                SYN_BIT_FOUR_BYTE_CLIENT |
36713 -                                                SYN_BIT_W_MODE)))
36714 -                       printk(KERN_INFO "synaptics: failed to enable 4-byte guest protocol\n");
36715 -       }
36716 -
36717 -       return 0;
36718 +       port->activate = synaptics_pt_activate;
36719  }
36720  
36721  /*****************************************************************************
36722 @@ -371,27 +366,82 @@ static void set_input_params(struct inpu
36723         clear_bit(REL_Y, dev->relbit);
36724  }
36725  
36726 +static void synaptics_disconnect(struct psmouse *psmouse)
36727 +{
36728 +       synaptics_mode_cmd(psmouse, 0);
36729 +       kfree(psmouse->private);
36730 +}
36731 +
36732 +static int synaptics_reconnect(struct psmouse *psmouse)
36733 +{
36734 +       struct synaptics_data *priv = psmouse->private;
36735 +       struct synaptics_data old_priv = *priv;
36736 +
36737 +       if (synaptics_detect(psmouse))
36738 +               return -1;
36739 +
36740 +       if (synaptics_query_hardware(psmouse)) {
36741 +               printk(KERN_ERR "Unable to query Synaptics hardware.\n");
36742 +               return -1;
36743 +       }
36744 +       
36745 +       if (old_priv.identity != priv->identity ||
36746 +           old_priv.model_id != priv->model_id ||
36747 +           old_priv.capabilities != priv->capabilities ||
36748 +           old_priv.ext_cap != priv->ext_cap)
36749 +               return -1;
36750 +       
36751 +       if (synaptics_set_mode(psmouse, 0)) {
36752 +               printk(KERN_ERR "Unable to initialize Synaptics hardware.\n");
36753 +               return -1;
36754 +       }
36755 +
36756 +       return 0;
36757 +}
36758 +
36759 +int synaptics_detect(struct psmouse *psmouse)
36760 +{
36761 +       unsigned char param[4];
36762 +       
36763 +       param[0] = 0;
36764 +       
36765 +       psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
36766 +       psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
36767 +       psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
36768 +       psmouse_command(psmouse, param, PSMOUSE_CMD_SETRES);
36769 +       psmouse_command(psmouse, param, PSMOUSE_CMD_GETINFO);
36770 +       
36771 +       return param[1] == 0x47 ? 0 : -1;
36772 +}
36773 +
36774  int synaptics_init(struct psmouse *psmouse)
36775  {
36776         struct synaptics_data *priv;
36777  
36778 -#ifndef CONFIG_MOUSE_PS2_SYNAPTICS
36779 -       return -1;
36780 -#endif
36781 -
36782         psmouse->private = priv = kmalloc(sizeof(struct synaptics_data), GFP_KERNEL);
36783         if (!priv)
36784                 return -1;
36785         memset(priv, 0, sizeof(struct synaptics_data));
36786  
36787         if (synaptics_query_hardware(psmouse)) {
36788 -               printk(KERN_ERR "Unable to query/initialize Synaptics hardware.\n");
36789 +               printk(KERN_ERR "Unable to query Synaptics hardware.\n");
36790 +               goto init_fail;
36791 +       }
36792 +       
36793 +       if (synaptics_set_mode(psmouse, 0)) {
36794 +               printk(KERN_ERR "Unable to initialize Synaptics hardware.\n");
36795                 goto init_fail;
36796         }
36797  
36798 +       if (SYN_CAP_EXTENDED(priv->capabilities) && SYN_CAP_PASS_THROUGH(priv->capabilities))
36799 +                       synaptics_pt_create(psmouse);
36800 +       
36801         print_ident(priv);
36802         set_input_params(&psmouse->dev, priv);
36803  
36804 +       psmouse->disconnect = synaptics_disconnect;
36805 +       psmouse->reconnect = synaptics_reconnect;
36806 +       
36807         return 0;
36808  
36809   init_fail:
36810 @@ -399,36 +449,13 @@ int synaptics_init(struct psmouse *psmou
36811         return -1;
36812  }
36813  
36814 -void synaptics_disconnect(struct psmouse *psmouse)
36815 -{
36816 -       struct synaptics_data *priv = psmouse->private;
36817 -
36818 -       if (psmouse->type == PSMOUSE_SYNAPTICS && priv) {
36819 -               synaptics_mode_cmd(psmouse, 0);
36820 -               if (priv->ptport) {
36821 -                       serio_unregister_slave_port(priv->ptport);
36822 -                       kfree(priv->ptport);
36823 -               }
36824 -               kfree(priv);
36825 -       }
36826 -}
36827 -
36828  /*****************************************************************************
36829   *     Functions to interpret the absolute mode packets
36830   ****************************************************************************/
36831  
36832  static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data *priv, struct synaptics_hw_state *hw)
36833  {
36834 -       hw->up    = 0;
36835 -       hw->down  = 0;
36836 -       hw->b0    = 0;
36837 -       hw->b1    = 0;
36838 -       hw->b2    = 0;
36839 -       hw->b3    = 0;
36840 -       hw->b4    = 0;
36841 -       hw->b5    = 0;
36842 -       hw->b6    = 0;
36843 -       hw->b7    = 0;
36844 +       memset(hw, 0, sizeof(struct synaptics_hw_state));
36845  
36846         if (SYN_MODEL_NEWABS(priv->model_id)) {
36847                 hw->x = (((buf[3] & 0x10) << 8) |
36848 @@ -570,64 +597,47 @@ static void synaptics_process_packet(str
36849         input_sync(dev);
36850  }
36851  
36852 +static int synaptics_validate_byte(struct psmouse *psmouse)
36853 +{
36854 +       static unsigned char newabs_mask[] = { 0xC8, 0x00, 0x00, 0xC8, 0x00 };
36855 +       static unsigned char newabs_rslt[] = { 0x80, 0x00, 0x00, 0xC0, 0x00 };
36856 +       static unsigned char oldabs_mask[] = { 0xC0, 0x60, 0x00, 0xC0, 0x60 };
36857 +       static unsigned char oldabs_rslt[] = { 0xC0, 0x00, 0x00, 0x80, 0x00 };
36858 +       struct synaptics_data *priv = psmouse->private;
36859 +       int idx = psmouse->pktcnt - 1;
36860 +
36861 +       if (SYN_MODEL_NEWABS(priv->model_id))
36862 +               return (psmouse->packet[idx] & newabs_mask[idx]) == newabs_rslt[idx];
36863 +       else
36864 +               return (psmouse->packet[idx] & oldabs_mask[idx]) == oldabs_rslt[idx];
36865 +}
36866 +
36867  void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
36868  {
36869         struct input_dev *dev = &psmouse->dev;
36870         struct synaptics_data *priv = psmouse->private;
36871 -       unsigned char data = psmouse->packet[psmouse->pktcnt - 1];
36872 -       int newabs = SYN_MODEL_NEWABS(priv->model_id);
36873  
36874         input_regs(dev, regs);
36875  
36876 -       switch (psmouse->pktcnt) {
36877 -       case 1:
36878 -               if (newabs ? ((data & 0xC8) != 0x80) : ((data & 0xC0) != 0xC0)) {
36879 -                       printk(KERN_WARNING "Synaptics driver lost sync at 1st byte\n");
36880 -                       goto bad_sync;
36881 -               }
36882 -               break;
36883 -       case 2:
36884 -               if (!newabs && ((data & 0x60) != 0x00)) {
36885 -                       printk(KERN_WARNING "Synaptics driver lost sync at 2nd byte\n");
36886 -                       goto bad_sync;
36887 -               }
36888 -               break;
36889 -       case 4:
36890 -               if (newabs ? ((data & 0xC8) != 0xC0) : ((data & 0xC0) != 0x80)) {
36891 -                       printk(KERN_WARNING "Synaptics driver lost sync at 4th byte\n");
36892 -                       goto bad_sync;
36893 -               }
36894 -               break;
36895 -       case 5:
36896 -               if (!newabs && ((data & 0x60) != 0x00)) {
36897 -                       printk(KERN_WARNING "Synaptics driver lost sync at 5th byte\n");
36898 -                       goto bad_sync;
36899 -               }
36900 -               break;
36901 -       default:
36902 -               if (psmouse->pktcnt < 6)
36903 -                       break;              /* Wait for full packet */
36904 -
36905 +       if (psmouse->pktcnt >= 6) { /* Full packet received */
36906                 if (priv->out_of_sync) {
36907                         priv->out_of_sync = 0;
36908                         printk(KERN_NOTICE "Synaptics driver resynced.\n");
36909                 }
36910  
36911 -               if (priv->ptport && synaptics_is_pt_packet(psmouse->packet))
36912 -                       synaptics_pass_pt_packet(priv->ptport, psmouse->packet);
36913 +               if (psmouse->ptport && psmouse->ptport->serio.dev && synaptics_is_pt_packet(psmouse->packet))
36914 +                       synaptics_pass_pt_packet(&psmouse->ptport->serio, psmouse->packet);
36915                 else
36916                         synaptics_process_packet(psmouse);
36917 -
36918                 psmouse->pktcnt = 0;
36919 -               break;
36920 -       }
36921 -       return;
36922  
36923 - bad_sync:
36924 -       priv->out_of_sync++;
36925 -       psmouse->pktcnt = 0;
36926 -       if (psmouse_resetafter > 0 && priv->out_of_sync == psmouse_resetafter) {
36927 -               psmouse->state = PSMOUSE_IGNORE;
36928 -               serio_rescan(psmouse->serio);
36929 +       } else if (psmouse->pktcnt && !synaptics_validate_byte(psmouse)) {
36930 +               printk(KERN_WARNING "Synaptics driver lost sync at byte %d\n", psmouse->pktcnt);
36931 +               psmouse->pktcnt = 0;
36932 +               if (++priv->out_of_sync == psmouse_resetafter) {
36933 +                       psmouse->state = PSMOUSE_IGNORE;
36934 +                       printk(KERN_NOTICE "synaptics: issuing reconnect request\n");
36935 +                       serio_reconnect(psmouse->serio);
36936 +               }
36937         }
36938  }
36939 --- linux-2.6.0-test6/drivers/input/mouse/synaptics.h   2003-09-27 18:57:44.000000000 -0700
36940 +++ 25/drivers/input/mouse/synaptics.h  2003-10-05 00:34:15.000000000 -0700
36941 @@ -9,11 +9,9 @@
36942  #ifndef _SYNAPTICS_H
36943  #define _SYNAPTICS_H
36944  
36945 -
36946  extern void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs);
36947 +extern int synaptics_detect(struct psmouse *psmouse);
36948  extern int synaptics_init(struct psmouse *psmouse);
36949 -extern int synaptics_pt_init(struct psmouse *psmouse);
36950 -extern void synaptics_disconnect(struct psmouse *psmouse);
36951  
36952  /* synaptics queries */
36953  #define SYN_QUE_IDENTIFY               0x00
36954 @@ -105,8 +103,6 @@ struct synaptics_data {
36955         /* Data for normal processing */
36956         unsigned int out_of_sync;               /* # of packets out of sync */
36957         int old_w;                              /* Previous w value */
36958 -       
36959 -       struct serio *ptport;                   /* pass-through port */
36960  };
36961  
36962  #endif /* _SYNAPTICS_H */
36963 --- linux-2.6.0-test6/drivers/input/serio/serio.c       2003-09-27 18:57:44.000000000 -0700
36964 +++ 25/drivers/input/serio/serio.c      2003-10-05 00:34:15.000000000 -0700
36965 @@ -49,14 +49,15 @@ MODULE_LICENSE("GPL");
36966  
36967  EXPORT_SYMBOL(serio_interrupt);
36968  EXPORT_SYMBOL(serio_register_port);
36969 -EXPORT_SYMBOL(serio_register_slave_port);
36970 +EXPORT_SYMBOL(__serio_register_port);
36971  EXPORT_SYMBOL(serio_unregister_port);
36972 -EXPORT_SYMBOL(serio_unregister_slave_port);
36973 +EXPORT_SYMBOL(__serio_unregister_port);
36974  EXPORT_SYMBOL(serio_register_device);
36975  EXPORT_SYMBOL(serio_unregister_device);
36976  EXPORT_SYMBOL(serio_open);
36977  EXPORT_SYMBOL(serio_close);
36978  EXPORT_SYMBOL(serio_rescan);
36979 +EXPORT_SYMBOL(serio_reconnect);
36980  
36981  struct serio_event {
36982         int type;
36983 @@ -83,10 +84,20 @@ static void serio_find_dev(struct serio 
36984  }
36985  
36986  #define SERIO_RESCAN   1
36987 +#define SERIO_RECONNECT        2
36988  
36989  static DECLARE_WAIT_QUEUE_HEAD(serio_wait);
36990  static DECLARE_COMPLETION(serio_exited);
36991  
36992 +static void serio_invalidate_pending_events(struct serio *serio)
36993 +{
36994 +       struct serio_event *event;
36995 +       
36996 +       list_for_each_entry(event, &serio_event_list, node)
36997 +               if (event->serio == serio)
36998 +                       event->serio = NULL;
36999 +}
37000 +
37001  void serio_handle_events(void)
37002  {
37003         struct list_head *node, *next;
37004 @@ -95,17 +106,27 @@ void serio_handle_events(void)
37005         list_for_each_safe(node, next, &serio_event_list) {
37006                 event = container_of(node, struct serio_event, node);   
37007  
37008 +               down(&serio_sem);
37009 +               if (event->serio == NULL)
37010 +                       goto event_done;
37011 +               
37012                 switch (event->type) {
37013 +                       case SERIO_RECONNECT :
37014 +                               if (event->serio->dev && event->serio->dev->reconnect)
37015 +                                       if (event->serio->dev->reconnect(event->serio) == 0)
37016 +                                               break;
37017 +                               /* reconnect failed - fall through to rescan */
37018 +                               
37019                         case SERIO_RESCAN :
37020 -                               down(&serio_sem);
37021                                 if (event->serio->dev && event->serio->dev->disconnect)
37022                                         event->serio->dev->disconnect(event->serio);
37023                                 serio_find_dev(event->serio);
37024 -                               up(&serio_sem);
37025                                 break;
37026                         default:
37027                                 break;
37028                 }
37029 +event_done:
37030 +               up(&serio_sem);
37031                 list_del_init(node);
37032                 kfree(event);
37033         }
37034 @@ -130,18 +151,27 @@ static int serio_thread(void *nothing)
37035         complete_and_exit(&serio_exited, 0);
37036  }
37037  
37038 -void serio_rescan(struct serio *serio)
37039 +static void serio_queue_event(struct serio *serio, int event_type)
37040  {
37041         struct serio_event *event;
37042  
37043 -       if (!(event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC)))
37044 -               return;
37045 +       if ((event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC))) {
37046 +               event->type = event_type;
37047 +               event->serio = serio;
37048  
37049 -       event->type = SERIO_RESCAN;
37050 -       event->serio = serio;
37051 +               list_add_tail(&event->node, &serio_event_list);
37052 +               wake_up(&serio_wait);
37053 +       }
37054 +}
37055  
37056 -       list_add_tail(&event->node, &serio_event_list);
37057 -       wake_up(&serio_wait);
37058 +void serio_rescan(struct serio *serio)
37059 +{
37060 +       serio_queue_event(serio, SERIO_RESCAN);
37061 +}
37062 +
37063 +void serio_reconnect(struct serio *serio)
37064 +{
37065 +       serio_queue_event(serio, SERIO_RECONNECT);
37066  }
37067  
37068  irqreturn_t serio_interrupt(struct serio *serio,
37069 @@ -163,17 +193,16 @@ irqreturn_t serio_interrupt(struct serio
37070  void serio_register_port(struct serio *serio)
37071  {
37072         down(&serio_sem);
37073 -       list_add_tail(&serio->node, &serio_list);
37074 -       serio_find_dev(serio);
37075 +       __serio_register_port(serio);
37076         up(&serio_sem);
37077  }
37078  
37079  /*
37080 - * Same as serio_register_port but does not try to acquire serio_sem.
37081 - * Should be used when registering a serio from other input device's
37082 + * Should only be called directly if serio_sem has already been taken,
37083 + * for example when unregistering a serio from other input device's 
37084   * connect() function.
37085   */
37086 -void serio_register_slave_port(struct serio *serio)
37087 +void __serio_register_port(struct serio *serio)
37088  {
37089         list_add_tail(&serio->node, &serio_list);
37090         serio_find_dev(serio);
37091 @@ -182,19 +211,18 @@ void serio_register_slave_port(struct se
37092  void serio_unregister_port(struct serio *serio)
37093  {
37094         down(&serio_sem);
37095 -       list_del_init(&serio->node);
37096 -       if (serio->dev && serio->dev->disconnect)
37097 -               serio->dev->disconnect(serio);
37098 +       __serio_unregister_port(serio);
37099         up(&serio_sem);
37100  }
37101  
37102  /*
37103 - * Same as serio_unregister_port but does not try to acquire serio_sem.
37104 - * Should be used when unregistering a serio from other input device's
37105 + * Should only be called directly if serio_sem has already been taken,
37106 + * for example when unregistering a serio from other input device's 
37107   * disconnect() function.
37108   */
37109 -void serio_unregister_slave_port(struct serio *serio)
37110 +void __serio_unregister_port(struct serio *serio)
37111  {
37112 +       serio_invalidate_pending_events(serio);
37113         list_del_init(&serio->node);
37114         if (serio->dev && serio->dev->disconnect)
37115                 serio->dev->disconnect(serio);
37116 --- linux-2.6.0-test6/drivers/isdn/hardware/eicon/debuglib.h    2003-09-27 18:57:44.000000000 -0700
37117 +++ 25/drivers/isdn/hardware/eicon/debuglib.h   2003-10-05 00:33:24.000000000 -0700
37118 @@ -103,28 +103,28 @@
37119  #define DL_TO_KERNEL    0x40000000
37120  
37121  #ifdef DIVA_NO_DEBUGLIB
37122 -#define myDbgPrint_LOG(x,...) do { } while(0);
37123 -#define myDbgPrint_FTL(x,...) do { } while(0);
37124 -#define myDbgPrint_ERR(x,...) do { } while(0);
37125 -#define myDbgPrint_TRC(x,...) do { } while(0);
37126 -#define myDbgPrint_MXLOG(x,...) do { } while(0);
37127 -#define myDbgPrint_EVL(x,...) do { } while(0);
37128 -#define myDbgPrint_REG(x,...) do { } while(0);
37129 -#define myDbgPrint_MEM(x,...) do { } while(0);
37130 -#define myDbgPrint_SPL(x,...) do { } while(0);
37131 -#define myDbgPrint_IRP(x,...) do { } while(0);
37132 -#define myDbgPrint_TIM(x,...) do { } while(0);
37133 -#define myDbgPrint_BLK(x,...) do { } while(0);
37134 -#define myDbgPrint_TAPI(x,...) do { } while(0);
37135 -#define myDbgPrint_NDIS(x,...) do { } while(0);
37136 -#define myDbgPrint_CONN(x,...) do { } while(0);
37137 -#define myDbgPrint_STAT(x,...) do { } while(0);
37138 -#define myDbgPrint_SEND(x,...) do { } while(0);
37139 -#define myDbgPrint_RECV(x,...) do { } while(0);
37140 -#define myDbgPrint_PRV0(x,...) do { } while(0);
37141 -#define myDbgPrint_PRV1(x,...) do { } while(0);
37142 -#define myDbgPrint_PRV2(x,...) do { } while(0);
37143 -#define myDbgPrint_PRV3(x,...) do { } while(0);
37144 +#define myDbgPrint_LOG(x...) do { } while(0);
37145 +#define myDbgPrint_FTL(x...) do { } while(0);
37146 +#define myDbgPrint_ERR(x...) do { } while(0);
37147 +#define myDbgPrint_TRC(x...) do { } while(0);
37148 +#define myDbgPrint_MXLOG(x...) do { } while(0);
37149 +#define myDbgPrint_EVL(x...) do { } while(0);
37150 +#define myDbgPrint_REG(x...) do { } while(0);
37151 +#define myDbgPrint_MEM(x...) do { } while(0);
37152 +#define myDbgPrint_SPL(x...) do { } while(0);
37153 +#define myDbgPrint_IRP(x...) do { } while(0);
37154 +#define myDbgPrint_TIM(x...) do { } while(0);
37155 +#define myDbgPrint_BLK(x...) do { } while(0);
37156 +#define myDbgPrint_TAPI(x...) do { } while(0);
37157 +#define myDbgPrint_NDIS(x...) do { } while(0);
37158 +#define myDbgPrint_CONN(x...) do { } while(0);
37159 +#define myDbgPrint_STAT(x...) do { } while(0);
37160 +#define myDbgPrint_SEND(x...) do { } while(0);
37161 +#define myDbgPrint_RECV(x...) do { } while(0);
37162 +#define myDbgPrint_PRV0(x...) do { } while(0);
37163 +#define myDbgPrint_PRV1(x...) do { } while(0);
37164 +#define myDbgPrint_PRV2(x...) do { } while(0);
37165 +#define myDbgPrint_PRV3(x...) do { } while(0);
37166  #define DBG_TEST(func,args) do { } while(0);
37167  #define DBG_EVL_ID(args) do { } while(0);
37168  
37169 --- linux-2.6.0-test6/drivers/isdn/hardware/eicon/divamnt.c     2003-09-27 18:57:44.000000000 -0700
37170 +++ 25/drivers/isdn/hardware/eicon/divamnt.c    2003-10-05 00:33:24.000000000 -0700
37171 @@ -1,4 +1,4 @@
37172 -/* $Id: 2.6.0-test6-mm4.patch,v 1.5 2004/02/23 23:37:02 phil Exp $
37173 +/* Id: 2.6.0-test6-mm4.patch,v 1.3.2.1 2004/02/14 07:21:32 nic Exp $
37174   *
37175   * Driver for Eicon DIVA Server ISDN cards.
37176   * Maint module
37177 @@ -24,10 +24,9 @@
37178  #include "platform.h"
37179  #include "di_defs.h"
37180  #include "divasync.h"
37181 -#include "di_defs.h"
37182  #include "debug_if.h"
37183  
37184 -static char *main_revision = "$Revision: 1.5 $";
37185 +static char *main_revision = "$Revision: 1.5 $";
37186  
37187  static int major;
37188  
37189 --- linux-2.6.0-test6/drivers/isdn/hardware/eicon/divasmain.c   2003-09-27 18:57:44.000000000 -0700
37190 +++ 25/drivers/isdn/hardware/eicon/divasmain.c  2003-10-05 00:33:24.000000000 -0700
37191 @@ -1,4 +1,4 @@
37192 -/* $Id: 2.6.0-test6-mm4.patch,v 1.5 2004/02/23 23:37:02 phil Exp $
37193 +/* Id: 2.6.0-test6-mm4.patch,v 1.3.2.1 2004/02/14 07:21:32 nic Exp $
37194   *
37195   * Low level driver for Eicon DIVA Server ISDN cards.
37196   *
37197 @@ -9,13 +9,11 @@
37198   * of the GNU General Public License, incorporated herein by reference.
37199   */
37200  
37201 -#define __KERNEL_SYSCALLS__
37202  #include <linux/config.h>
37203  #include <linux/module.h>
37204  #include <linux/init.h>
37205  #include <linux/kernel.h>
37206  #include <linux/sched.h>
37207 -#include <linux/unistd.h>
37208  #include <linux/devfs_fs_kernel.h>
37209  #include <asm/uaccess.h>
37210  #include <asm/io.h>
37211 @@ -43,7 +41,7 @@
37212  #include "diva_dma.h"
37213  #include "diva_pci.h"
37214  
37215 -static char *main_revision = "$Revision: 1.5 $";
37216 +static char *main_revision = "$Revision: 1.5 $";
37217  
37218  static int major;
37219  
37220 --- linux-2.6.0-test6/drivers/isdn/hardware/eicon/dqueue.c      2003-06-14 12:18:22.000000000 -0700
37221 +++ 25/drivers/isdn/hardware/eicon/dqueue.c     2003-10-05 00:33:24.000000000 -0700
37222 @@ -1,10 +1,10 @@
37223 -/* $Id: 2.6.0-test6-mm4.patch,v 1.5 2004/02/23 23:37:02 phil Exp $
37224 +/* Id: 2.6.0-test6-mm4.patch,v 1.3.2.1 2004/02/14 07:21:32 nic Exp $
37225   *
37226   * Driver for Eicon DIVA Server ISDN cards.
37227   * User Mode IDI Interface
37228   *
37229 - * Copyright 2000,2001 by Armin Schindler (mac@melware.de)
37230 - * Copyright 2000,2001 Cytronics & Melware (info@melware.de)
37231 + * Copyright 2000-2003 by Armin Schindler (mac@melware.de)
37232 + * Copyright 2000-2003 Cytronics & Melware (info@melware.de)
37233   *
37234   * This software may be used and distributed according to the terms
37235   * of the GNU General Public License, incorporated herein by reference.
37236 --- linux-2.6.0-test6/drivers/isdn/hardware/eicon/mntfunc.c     2003-09-27 18:57:44.000000000 -0700
37237 +++ 25/drivers/isdn/hardware/eicon/mntfunc.c    2003-10-05 00:33:24.000000000 -0700
37238 @@ -1,4 +1,4 @@
37239 -/* $Id: 2.6.0-test6-mm4.patch,v 1.5 2004/02/23 23:37:02 phil Exp $
37240 +/* Id: 2.6.0-test6-mm4.patch,v 1.4 2004/02/14 03:14:33 rread Exp $
37241   *
37242   * Driver for Eicon DIVA Server ISDN cards.
37243   * Maint module
37244 @@ -14,7 +14,6 @@
37245  #include "platform.h"
37246  #include "di_defs.h"
37247  #include "divasync.h"
37248 -#include "di_defs.h"
37249  #include "debug_if.h"
37250  
37251  extern char *DRIVERRELEASE_MNT;
37252 --- linux-2.6.0-test6/drivers/isdn/hardware/eicon/os_capi.h     2003-06-14 12:18:25.000000000 -0700
37253 +++ 25/drivers/isdn/hardware/eicon/os_capi.h    2003-10-05 00:33:24.000000000 -0700
37254 @@ -1,10 +1,10 @@
37255 -/* $Id: 2.6.0-test6-mm4.patch,v 1.5 2004/02/23 23:37:02 phil Exp $
37256 +/* Id: 2.6.0-test6-mm4.patch,v 1.3.2.1 2004/02/14 07:21:32 nic Exp $
37257   *
37258   * ISDN interface module for Eicon active cards DIVA.
37259   * CAPI Interface OS include files 
37260   * 
37261 - * Copyright 2000-2002 by Armin Schindler (mac@melware.de) 
37262 - * Copyright 2000-2002 Cytronics & Melware (info@melware.de)
37263 + * Copyright 2000-2003 by Armin Schindler (mac@melware.de) 
37264 + * Copyright 2000-2003 Cytronics & Melware (info@melware.de)
37265   * 
37266   * This software may be used and distributed according to the terms
37267   * of the GNU General Public License, incorporated herein by reference.
37268 --- linux-2.6.0-test6/drivers/isdn/hardware/eicon/platform.h    2003-09-27 18:57:44.000000000 -0700
37269 +++ 25/drivers/isdn/hardware/eicon/platform.h   2003-10-05 00:33:24.000000000 -0700
37270 @@ -1,4 +1,4 @@
37271 -/* $Id: 2.6.0-test6-mm4.patch,v 1.5 2004/02/23 23:37:02 phil Exp $
37272 +/* Id: 2.6.0-test6-mm4.patch,v 1.3.2.1 2004/02/14 07:21:32 nic Exp $
37273   *
37274   * platform.h
37275   * 
37276 @@ -19,7 +19,6 @@
37277  #endif
37278  
37279  #include <linux/config.h>
37280 -#include <linux/version.h>
37281  #include <linux/module.h>
37282  #include <linux/init.h>
37283  #include <linux/kernel.h>
37284 --- linux-2.6.0-test6/drivers/isdn/i4l/isdn_common.c    2003-09-27 18:57:44.000000000 -0700
37285 +++ 25/drivers/isdn/i4l/isdn_common.c   2003-10-05 00:33:24.000000000 -0700
37286 @@ -2229,8 +2229,10 @@ static int __init isdn_init(void)
37287         isdn_info_update();
37288         return 0;
37289  
37290 -/* err_tty_modem:*/
37291 +#ifdef CONFIG_ISDN_PPP
37292 + err_tty_modem:
37293         isdn_tty_exit();
37294 +#endif
37295   err_cleanup_devfs:
37296         isdn_cleanup_devfs();
37297         unregister_chrdev(ISDN_MAJOR, "isdn");
37298 --- linux-2.6.0-test6/drivers/mca/mca-legacy.c  2003-08-22 19:23:40.000000000 -0700
37299 +++ 25/drivers/mca/mca-legacy.c 2003-10-05 00:33:24.000000000 -0700
37300 @@ -28,7 +28,7 @@
37301  
37302  #include <linux/module.h>
37303  #include <linux/device.h>
37304 -#include <linux/mca.h>
37305 +#include <linux/mca-legacy.h>
37306  #include <asm/io.h>
37307  
37308  /* NOTE: This structure is stack allocated */
37309 --- linux-2.6.0-test6/drivers/mca/mca-proc.c    2003-08-22 19:23:40.000000000 -0700
37310 +++ 25/drivers/mca/mca-proc.c   2003-10-05 00:33:24.000000000 -0700
37311 @@ -120,12 +120,13 @@ static int mca_default_procfn(char* buf,
37312         len += sprintf(buf+len, "Id: %02x%02x\n",
37313                 mca_dev->pos[1], mca_dev->pos[0]);
37314         len += sprintf(buf+len, "Enabled: %s\nPOS: ",
37315 -               mca_isenabled(slot) ? "Yes" : "No");
37316 +               mca_device_status(mca_dev) == MCA_ADAPTER_NORMAL ?
37317 +                       "Yes" : "No");
37318         for(i=0; i<8; i++) {
37319                 len += sprintf(buf+len, "%02x ", mca_dev->pos[i]);
37320         }
37321         len += sprintf(buf+len, "\nDriver Installed: %s",
37322 -               mca_is_adapter_used(slot) ? "Yes" : "No");
37323 +               mca_device_claimed(mca_dev) ? "Yes" : "No");
37324         buf[len++] = '\n';
37325         buf[len] = 0;
37326  
37327 @@ -189,6 +190,7 @@ void __init mca_do_proc_init(void)
37328         /* Initialize /proc/mca entries for existing adapters */
37329  
37330         for(i = 0; i < MCA_NUMADAPTERS; i++) {
37331 +               enum MCA_AdapterStatus status;
37332                 mca_dev = mca_find_device_by_slot(i);
37333                 if(!mca_dev)
37334                         continue;
37335 @@ -200,7 +202,10 @@ void __init mca_do_proc_init(void)
37336                 else if(i == MCA_INTEGSCSI) sprintf(mca_dev->procname,"scsi");
37337                 else if(i == MCA_MOTHERBOARD) sprintf(mca_dev->procname,"planar");
37338  
37339 -               if(!mca_isadapter(i)) continue;
37340 +               status = mca_device_status(mca_dev);
37341 +               if (status != MCA_ADAPTER_NORMAL &&
37342 +                   status != MCA_ADAPTER_DISABLED)
37343 +                       continue;
37344  
37345                 node = create_proc_read_entry(mca_dev->procname, 0, proc_mca,
37346                                               mca_read_proc, (void *)mca_dev);
37347 --- linux-2.6.0-test6/drivers/md/dm.c   2003-09-27 18:57:44.000000000 -0700
37348 +++ 25/drivers/md/dm.c  2003-10-05 00:34:01.000000000 -0700
37349 @@ -160,20 +160,16 @@ static void __exit dm_exit(void)
37350  /*
37351   * Block device functions
37352   */
37353 -static int dm_blk_open(struct inode *inode, struct file *file)
37354 +static int dm_blk_open(struct block_device *bdev, struct file *file)
37355  {
37356 -       struct mapped_device *md;
37357 -
37358 -       md = inode->i_bdev->bd_disk->private_data;
37359 +       struct mapped_device *md = bdev->bd_disk->private_data;
37360         dm_get(md);
37361         return 0;
37362  }
37363  
37364 -static int dm_blk_close(struct inode *inode, struct file *file)
37365 +static int dm_blk_close(struct gendisk *disk)
37366  {
37367 -       struct mapped_device *md;
37368 -
37369 -       md = inode->i_bdev->bd_disk->private_data;
37370 +       struct mapped_device *md = disk->private_data;
37371         dm_put(md);
37372         return 0;
37373  }
37374 --- linux-2.6.0-test6/drivers/md/md.c   2003-09-27 18:57:44.000000000 -0700
37375 +++ 25/drivers/md/md.c  2003-10-05 00:34:01.000000000 -0700
37376 @@ -2360,11 +2360,10 @@ static int set_disk_faulty(mddev_t *mdde
37377         return 1;
37378  }
37379  
37380 -static int md_ioctl(struct inode *inode, struct file *file,
37381 +static int md_ioctl(struct block_device *bdev, struct file *file,
37382                         unsigned int cmd, unsigned long arg)
37383  {
37384         char b[BDEVNAME_SIZE];
37385 -       unsigned int minor = iminor(inode);
37386         int err = 0;
37387         struct hd_geometry *loc = (struct hd_geometry *) arg;
37388         mddev_t *mddev = NULL;
37389 @@ -2372,11 +2371,6 @@ static int md_ioctl(struct inode *inode,
37390         if (!capable(CAP_SYS_ADMIN))
37391                 return -EACCES;
37392  
37393 -       if (minor >= MAX_MD_DEVS) {
37394 -               MD_BUG();
37395 -               return -EINVAL;
37396 -       }
37397 -
37398         /*
37399          * Commands dealing with the RAID driver but not any
37400          * particular array:
37401 @@ -2405,7 +2399,7 @@ static int md_ioctl(struct inode *inode,
37402          * Commands creating/starting a new array:
37403          */
37404  
37405 -       mddev = inode->i_bdev->bd_inode->u.generic_ip;
37406 +       mddev = bdev->bd_inode->u.generic_ip;
37407  
37408         if (!mddev) {
37409                 BUG();
37410 @@ -2527,7 +2521,7 @@ static int md_ioctl(struct inode *inode,
37411                                                 (short *) &loc->cylinders);
37412                         if (err)
37413                                 goto abort_unlock;
37414 -                       err = put_user (get_start_sect(inode->i_bdev),
37415 +                       err = put_user (get_start_sect(bdev),
37416                                                 (long *) &loc->start);
37417                         goto done_unlock;
37418         }
37419 @@ -2605,12 +2599,12 @@ abort:
37420         return err;
37421  }
37422  
37423 -static int md_open(struct inode *inode, struct file *file)
37424 +static int md_open(struct block_device *bdev, struct file *file)
37425  {
37426         /*
37427          * Succeed if we can find or allocate a mddev structure.
37428          */
37429 -       mddev_t *mddev = mddev_find(iminor(inode));
37430 +       mddev_t *mddev = mddev_find(MINOR(bdev->bd_dev));
37431         int err = -ENOMEM;
37432  
37433         if (!mddev)
37434 @@ -2621,16 +2615,16 @@ static int md_open(struct inode *inode, 
37435  
37436         err = 0;
37437         mddev_unlock(mddev);
37438 -       inode->i_bdev->bd_inode->u.generic_ip = mddev_get(mddev);
37439 +       bdev->bd_inode->u.generic_ip = mddev_get(mddev);
37440   put:
37441         mddev_put(mddev);
37442   out:
37443         return err;
37444  }
37445  
37446 -static int md_release(struct inode *inode, struct file * file)
37447 +static int md_release(struct gendisk *disk)
37448  {
37449 -       mddev_t *mddev = inode->i_bdev->bd_inode->u.generic_ip;
37450 +       mddev_t *mddev = disk->private_data;
37451  
37452         if (!mddev)
37453                 BUG();
37454 --- linux-2.6.0-test6/drivers/media/common/saa7146_i2c.c        2003-08-08 22:55:12.000000000 -0700
37455 +++ 25/drivers/media/common/saa7146_i2c.c       2003-10-05 00:33:24.000000000 -0700
37456 @@ -1,3 +1,4 @@
37457 +#include <linux/version.h>
37458  #include <media/saa7146_vv.h>
37459  
37460  /* helper function */
37461 --- linux-2.6.0-test6/drivers/media/dvb/dvb-core/dvbdev.h       2003-07-27 12:14:39.000000000 -0700
37462 +++ 25/drivers/media/dvb/dvb-core/dvbdev.h      2003-10-05 00:33:24.000000000 -0700
37463 @@ -28,7 +28,6 @@
37464  #include <linux/poll.h>
37465  #include <linux/fs.h>
37466  #include <linux/list.h>
37467 -#include <linux/version.h>
37468  #include <linux/devfs_fs_kernel.h>
37469  
37470  #define DVB_MAJOR 250
37471 --- linux-2.6.0-test6/drivers/media/dvb/dvb-core/dvb_functions.c        2003-07-27 12:14:39.000000000 -0700
37472 +++ 25/drivers/media/dvb/dvb-core/dvb_functions.c       2003-10-05 00:33:24.000000000 -0700
37473 @@ -1,4 +1,3 @@
37474 -#include <linux/version.h>
37475  #include <linux/errno.h>
37476  #include <linux/fs.h>
37477  #include <linux/string.h>
37478 --- linux-2.6.0-test6/drivers/media/dvb/dvb-core/dvb_functions.h        2003-07-27 12:14:39.000000000 -0700
37479 +++ 25/drivers/media/dvb/dvb-core/dvb_functions.h       2003-10-05 00:33:24.000000000 -0700
37480 @@ -1,8 +1,6 @@
37481  #ifndef __DVB_FUNCTIONS_H__
37482  #define __DVB_FUNCTIONS_H__
37483  
37484 -#include <linux/version.h>
37485 -
37486  /**
37487   *  a sleeping delay function, waits i ms
37488   *
37489 --- linux-2.6.0-test6/drivers/media/dvb/ttpci/av7110.c  2003-07-27 12:14:39.000000000 -0700
37490 +++ 25/drivers/media/dvb/ttpci/av7110.c 2003-10-05 00:33:24.000000000 -0700
37491 @@ -55,10 +55,8 @@
37492  #include <linux/ptrace.h>
37493  #include <linux/ioport.h>
37494  #include <linux/in.h>
37495 -#include <linux/slab.h>
37496  #include <linux/string.h>
37497  #include <linux/pci.h>
37498 -#include <linux/init.h>
37499  #include <linux/vmalloc.h>
37500  #include <linux/netdevice.h>
37501  #include <linux/inetdevice.h>
37502 @@ -4745,12 +4743,19 @@ static struct saa7146_extension av7110_e
37503  
37504  static int __init av7110_init(void) 
37505  {
37506 -       if (saa7146_register_extension(&av7110_extension))
37507 -               return -ENODEV;
37508 +       int retval;
37509 +       retval = saa7146_register_extension(&av7110_extension);
37510 +       if (retval)
37511 +               goto failed_saa7146_register;
37512         
37513 -       av7110_ir_init();
37514 -
37515 +       retval = av7110_ir_init();
37516 +       if (retval)
37517 +               goto failed_av7110_ir_init;
37518         return 0;
37519 +failed_av7110_ir_init:
37520 +       saa7146_unregister_extension(&av7110_extension);
37521 +failed_saa7146_register:
37522 +       return retval;
37523  }
37524  
37525  
37526 --- linux-2.6.0-test6/drivers/media/dvb/ttpci/budget.c  2003-07-27 12:14:39.000000000 -0700
37527 +++ 25/drivers/media/dvb/ttpci/budget.c 2003-10-05 00:33:24.000000000 -0700
37528 @@ -228,10 +228,7 @@ static struct saa7146_extension budget_e
37529  
37530  static int __init budget_init(void) 
37531  {
37532 -       if (saa7146_register_extension(&budget_extension))
37533 -               return -ENODEV;
37534 -       
37535 -       return 0;
37536 +       return saa7146_register_extension(&budget_extension);
37537  }
37538  
37539  
37540 --- linux-2.6.0-test6/drivers/media/dvb/ttpci/budget-ci.c       2003-07-27 12:14:39.000000000 -0700
37541 +++ 25/drivers/media/dvb/ttpci/budget-ci.c      2003-10-05 00:33:24.000000000 -0700
37542 @@ -384,10 +384,7 @@ static struct saa7146_extension budget_e
37543  
37544  static int __init budget_ci_init(void) 
37545  {
37546 -       if (saa7146_register_extension(&budget_extension))
37547 -               return -ENODEV;
37548 -       
37549 -       return 0;
37550 +       return saa7146_register_extension(&budget_extension);
37551  }
37552  
37553  
37554 --- linux-2.6.0-test6/drivers/media/dvb/ttpci/budget-patch.c    2003-08-08 22:55:12.000000000 -0700
37555 +++ 25/drivers/media/dvb/ttpci/budget-patch.c   2003-10-05 00:33:24.000000000 -0700
37556 @@ -247,10 +247,7 @@ static int budget_patch_detach (struct s
37557  
37558  static int __init budget_patch_init(void) 
37559  {
37560 -        if (saa7146_register_extension(&budget_extension))
37561 -                return -ENODEV;
37562 -        
37563 -        return 0;
37564 +       return saa7146_register_extension(&budget_extension);
37565  }
37566  
37567  
37568 --- linux-2.6.0-test6/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c 2003-09-08 13:58:57.000000000 -0700
37569 +++ 25/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c        2003-10-05 00:33:24.000000000 -0700
37570 @@ -9,6 +9,7 @@
37571   *     published by the Free Software Foundation; either version 2 of
37572   *     the License, or (at your option) any later version.
37573   */
37574 +#include <linux/version.h>
37575  #include <linux/init.h>
37576  #include <linux/slab.h>
37577  #include <linux/wait.h>
37578 @@ -27,7 +28,6 @@
37579  #include <linux/dvb/frontend.h>
37580  #include <linux/dvb/dmx.h>
37581  #include <linux/pci.h>
37582 -#include <linux/usb.h>
37583  
37584  #include "dvb_functions.h"
37585  
37586 @@ -1055,7 +1055,8 @@ static ssize_t stc_read(struct file *fil
37587         if (tc < 0)
37588                 return 0;
37589  
37590 -       copy_to_user(buf, stc_firmware + *offset, tc);
37591 +       if (copy_to_user(buf, stc_firmware + *offset, tc))
37592 +               return -EFAULT;
37593  
37594         *offset += tc;
37595  
37596 --- linux-2.6.0-test6/drivers/media/dvb/ttusb-dec/ttusb_dec.c   2003-09-08 13:58:57.000000000 -0700
37597 +++ 25/drivers/media/dvb/ttusb-dec/ttusb_dec.c  2003-10-05 00:33:24.000000000 -0700
37598 @@ -19,6 +19,7 @@
37599   *
37600   */
37601  
37602 +#include <linux/version.h>
37603  #include <linux/module.h>
37604  #include <linux/pci.h>
37605  #include <linux/slab.h>
37606 --- linux-2.6.0-test6/drivers/media/radio/radio-gemtek-pci.c    2003-06-14 12:17:57.000000000 -0700
37607 +++ 25/drivers/media/radio/radio-gemtek-pci.c   2003-10-05 00:33:24.000000000 -0700
37608 @@ -37,7 +37,6 @@
37609   ***************************************************************************
37610   */
37611  
37612 -#include <linux/version.h>
37613  #include <linux/config.h>
37614  #include <linux/types.h>
37615  #include <linux/list.h>
37616 --- linux-2.6.0-test6/drivers/media/video/adv7170.c     2003-09-08 13:58:57.000000000 -0700
37617 +++ 25/drivers/media/video/adv7170.c    2003-10-05 00:33:24.000000000 -0700
37618 @@ -28,8 +28,6 @@
37619   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37620   */
37621  
37622 -#include <linux/version.h>
37623 -
37624  #include <linux/module.h>
37625  #include <linux/init.h>
37626  #include <linux/delay.h>
37627 @@ -49,7 +47,6 @@
37628  #include <linux/types.h>
37629  
37630  #include <linux/videodev.h>
37631 -#include <linux/version.h>
37632  #include <asm/uaccess.h>
37633  
37634  MODULE_DESCRIPTION("Analog Devices ADV7170 video encoder driver");
37635 --- linux-2.6.0-test6/drivers/media/video/adv7175.c     2003-09-08 13:58:57.000000000 -0700
37636 +++ 25/drivers/media/video/adv7175.c    2003-10-05 00:33:24.000000000 -0700
37637 @@ -24,8 +24,6 @@
37638   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37639   */
37640  
37641 -#include <linux/version.h>
37642 -
37643  #include <linux/module.h>
37644  #include <linux/init.h>
37645  #include <linux/delay.h>
37646 @@ -45,7 +43,6 @@
37647  #include <linux/types.h>
37648  
37649  #include <linux/videodev.h>
37650 -#include <linux/version.h>
37651  #include <asm/uaccess.h>
37652  
37653  MODULE_DESCRIPTION("Analog Devices ADV7175 video encoder driver");
37654 --- linux-2.6.0-test6/drivers/media/video/bt819.c       2003-09-08 13:58:57.000000000 -0700
37655 +++ 25/drivers/media/video/bt819.c      2003-10-05 00:33:24.000000000 -0700
37656 @@ -28,8 +28,6 @@
37657   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37658   */
37659  
37660 -#include <linux/version.h>
37661 -
37662  #include <linux/module.h>
37663  #include <linux/init.h>
37664  #include <linux/delay.h>
37665 @@ -49,7 +47,6 @@
37666  #include <linux/types.h>
37667  
37668  #include <linux/videodev.h>
37669 -#include <linux/version.h>
37670  #include <asm/uaccess.h>
37671  
37672  MODULE_DESCRIPTION("Brooktree-819 video decoder driver");
37673 --- linux-2.6.0-test6/drivers/media/video/bt856.c       2003-09-08 13:58:57.000000000 -0700
37674 +++ 25/drivers/media/video/bt856.c      2003-10-05 00:33:24.000000000 -0700
37675 @@ -28,8 +28,6 @@
37676   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37677   */
37678  
37679 -#include <linux/version.h>
37680 -
37681  #include <linux/module.h>
37682  #include <linux/init.h>
37683  #include <linux/delay.h>
37684 @@ -49,7 +47,6 @@
37685  #include <linux/types.h>
37686  
37687  #include <linux/videodev.h>
37688 -#include <linux/version.h>
37689  #include <asm/uaccess.h>
37690  
37691  MODULE_DESCRIPTION("Brooktree-856A video encoder driver");
37692 --- linux-2.6.0-test6/drivers/media/video/bttvp.h       2003-08-22 19:23:40.000000000 -0700
37693 +++ 25/drivers/media/video/bttvp.h      2003-10-05 00:33:24.000000000 -0700
37694 @@ -25,6 +25,7 @@
37695  #define _BTTVP_H_
37696  
37697  
37698 +#include <linux/version.h>
37699  #define BTTV_VERSION_CODE KERNEL_VERSION(0,9,11)
37700  
37701  #include <linux/types.h>
37702 --- linux-2.6.0-test6/drivers/media/video/bw-qcam.c     2003-08-08 22:55:12.000000000 -0700
37703 +++ 25/drivers/media/video/bw-qcam.c    2003-10-05 00:33:24.000000000 -0700
37704 @@ -72,7 +72,6 @@ OTHER DEALINGS IN THE SOFTWARE.
37705  #include <linux/mm.h>
37706  #include <linux/parport.h>
37707  #include <linux/sched.h>
37708 -#include <linux/version.h>
37709  #include <linux/videodev.h>
37710  #include <asm/semaphore.h>
37711  #include <asm/uaccess.h>
37712 --- linux-2.6.0-test6/drivers/media/video/cpia.c        2003-08-08 22:55:12.000000000 -0700
37713 +++ 25/drivers/media/video/cpia.c       2003-10-05 00:33:24.000000000 -0700
37714 @@ -29,7 +29,6 @@
37715  #include <linux/config.h>
37716  
37717  #include <linux/module.h>
37718 -#include <linux/version.h>
37719  #include <linux/init.h>
37720  #include <linux/fs.h>
37721  #include <linux/vmalloc.h>
37722 --- linux-2.6.0-test6/drivers/media/video/cpia_pp.c     2003-06-14 12:17:56.000000000 -0700
37723 +++ 25/drivers/media/video/cpia_pp.c    2003-10-05 00:33:24.000000000 -0700
37724 @@ -26,7 +26,6 @@
37725  /* #define _CPIA_DEBUG_  1 */  
37726  
37727  #include <linux/config.h>
37728 -#include <linux/version.h>
37729  
37730  #include <linux/module.h>
37731  #include <linux/init.h>
37732 --- linux-2.6.0-test6/drivers/media/video/c-qcam.c      2003-08-08 22:55:12.000000000 -0700
37733 +++ 25/drivers/media/video/c-qcam.c     2003-10-05 00:33:24.000000000 -0700
37734 @@ -33,7 +33,6 @@
37735  #include <linux/mm.h>
37736  #include <linux/parport.h>
37737  #include <linux/sched.h>
37738 -#include <linux/version.h>
37739  #include <linux/videodev.h>
37740  #include <asm/semaphore.h>
37741  #include <asm/uaccess.h>
37742 --- linux-2.6.0-test6/drivers/media/video/meye.h        2003-09-08 13:58:57.000000000 -0700
37743 +++ 25/drivers/media/video/meye.h       2003-10-05 00:33:24.000000000 -0700
37744 @@ -36,8 +36,6 @@
37745  #include <linux/config.h>
37746  #include <linux/types.h>
37747  #include <linux/pci.h>
37748 -#include <linux/sonypi.h>
37749 -#include <linux/meye.h>
37750  
37751  /****************************************************************************/
37752  /* Motion JPEG chip registers                                               */
37753 --- linux-2.6.0-test6/drivers/media/video/planb.c       2003-09-08 13:58:57.000000000 -0700
37754 +++ 25/drivers/media/video/planb.c      2003-10-05 00:33:24.000000000 -0700
37755 @@ -27,7 +27,6 @@
37756  
37757  /* $Id: 2.6.0-test6-mm4.patch,v 1.5 2004/02/23 23:37:02 phil Exp $ */
37758  
37759 -#include <linux/version.h>
37760  #include <linux/init.h>
37761  #include <linux/errno.h>
37762  #include <linux/module.h>
37763 --- linux-2.6.0-test6/drivers/media/video/pms.c 2003-08-08 22:55:12.000000000 -0700
37764 +++ 25/drivers/media/video/pms.c        2003-10-05 00:33:24.000000000 -0700
37765 @@ -30,7 +30,6 @@
37766  #include <asm/io.h>
37767  #include <linux/sched.h>
37768  #include <linux/videodev.h>
37769 -#include <linux/version.h>
37770  #include <asm/uaccess.h>
37771  
37772  
37773 --- linux-2.6.0-test6/drivers/media/video/saa7110.c     2003-09-08 13:58:57.000000000 -0700
37774 +++ 25/drivers/media/video/saa7110.c    2003-10-05 00:33:24.000000000 -0700
37775 @@ -25,8 +25,6 @@
37776   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37777   */
37778  
37779 -#include <linux/version.h>
37780 -
37781  #include <linux/module.h>
37782  #include <linux/init.h>
37783  #include <linux/types.h>
37784 --- linux-2.6.0-test6/drivers/media/video/saa7111.c     2003-09-08 13:58:57.000000000 -0700
37785 +++ 25/drivers/media/video/saa7111.c    2003-10-05 00:33:24.000000000 -0700
37786 @@ -24,8 +24,6 @@
37787   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37788   */
37789  
37790 -#include <linux/version.h>
37791 -
37792  #include <linux/module.h>
37793  #include <linux/init.h>
37794  #include <linux/delay.h>
37795 @@ -45,7 +43,6 @@
37796  #include <linux/types.h>
37797  
37798  #include <linux/videodev.h>
37799 -#include <linux/version.h>
37800  #include <asm/uaccess.h>
37801  
37802  MODULE_DESCRIPTION("Philips SAA7111 video decoder driver");
37803 --- linux-2.6.0-test6/drivers/media/video/saa7114.c     2003-09-08 13:58:57.000000000 -0700
37804 +++ 25/drivers/media/video/saa7114.c    2003-10-05 00:33:24.000000000 -0700
37805 @@ -28,8 +28,6 @@
37806   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37807   */
37808  
37809 -#include <linux/version.h>
37810 -
37811  #include <linux/module.h>
37812  #include <linux/init.h>
37813  #include <linux/delay.h>
37814 @@ -51,7 +49,6 @@
37815  #include <linux/types.h>
37816  
37817  #include <linux/videodev.h>
37818 -#include <linux/version.h>
37819  #include <asm/uaccess.h>
37820  
37821  MODULE_DESCRIPTION("Philips SAA7114H video decoder driver");
37822 --- linux-2.6.0-test6/drivers/media/video/saa7134/saa7134.h     2003-08-08 22:55:12.000000000 -0700
37823 +++ 25/drivers/media/video/saa7134/saa7134.h    2003-10-05 00:33:24.000000000 -0700
37824 @@ -18,6 +18,7 @@
37825   *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37826   */
37827  
37828 +#include <linux/version.h>
37829  #include <linux/pci.h>
37830  #include <linux/i2c.h>
37831  #include <linux/videodev.h>
37832 --- linux-2.6.0-test6/drivers/media/video/saa7185.c     2003-09-08 13:58:57.000000000 -0700
37833 +++ 25/drivers/media/video/saa7185.c    2003-10-05 00:33:24.000000000 -0700
37834 @@ -24,8 +24,6 @@
37835   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37836   */
37837  
37838 -#include <linux/version.h>
37839 -
37840  #include <linux/module.h>
37841  #include <linux/init.h>
37842  #include <linux/delay.h>
37843 @@ -45,7 +43,6 @@
37844  #include <linux/types.h>
37845  
37846  #include <linux/videodev.h>
37847 -#include <linux/version.h>
37848  #include <asm/uaccess.h>
37849  
37850  MODULE_DESCRIPTION("Philips SAA7185 video encoder driver");
37851 --- linux-2.6.0-test6/drivers/media/video/stradis.c     2003-09-08 13:58:57.000000000 -0700
37852 +++ 25/drivers/media/video/stradis.c    2003-10-05 00:33:24.000000000 -0700
37853 @@ -20,7 +20,6 @@
37854   */
37855  
37856  #include <linux/module.h>
37857 -#include <linux/version.h>
37858  #include <linux/delay.h>
37859  #include <linux/errno.h>
37860  #include <linux/fs.h>
37861 --- linux-2.6.0-test6/drivers/media/video/tuner-3036.c  2003-08-08 22:55:12.000000000 -0700
37862 +++ 25/drivers/media/video/tuner-3036.c 2003-10-05 00:33:24.000000000 -0700
37863 @@ -21,7 +21,6 @@
37864  #include <linux/delay.h>
37865  #include <linux/errno.h>
37866  #include <linux/slab.h>
37867 -#include <linux/version.h>
37868  #include <linux/init.h>
37869  
37870  #include <linux/i2c.h>
37871 --- linux-2.6.0-test6/drivers/media/video/v4l2-common.c 2003-06-14 12:18:34.000000000 -0700
37872 +++ 25/drivers/media/video/v4l2-common.c        2003-10-05 00:33:24.000000000 -0700
37873 @@ -45,7 +45,6 @@
37874   */
37875  
37876  #include <linux/config.h>
37877 -#include <linux/version.h>
37878  #include <linux/module.h>
37879  #include <linux/types.h>
37880  #include <linux/kernel.h>
37881 --- linux-2.6.0-test6/drivers/media/video/videocodec.c  2003-08-22 19:23:40.000000000 -0700
37882 +++ 25/drivers/media/video/videocodec.c 2003-10-05 00:33:24.000000000 -0700
37883 @@ -29,7 +29,6 @@
37884  
37885  #define VIDEOCODEC_VERSION "v0.2"
37886  
37887 -#include <linux/version.h>
37888  #include <linux/kernel.h>
37889  #include <linux/module.h>
37890  #include <linux/init.h>
37891 --- linux-2.6.0-test6/drivers/media/video/videodev.c    2003-09-08 13:58:57.000000000 -0700
37892 +++ 25/drivers/media/video/videodev.c   2003-10-05 00:33:24.000000000 -0700
37893 @@ -15,7 +15,6 @@
37894   *             - Added procfs support
37895   */
37896  
37897 -#include <linux/version.h>
37898  #include <linux/module.h>
37899  #include <linux/types.h>
37900  #include <linux/kernel.h>
37901 @@ -27,7 +26,6 @@
37902  #include <linux/init.h>
37903  #include <linux/kmod.h>
37904  #include <linux/slab.h>
37905 -#include <linux/types.h>
37906  #include <linux/devfs_fs_kernel.h>
37907  #include <asm/uaccess.h>
37908  #include <asm/system.h>
37909 @@ -52,7 +50,7 @@ static ssize_t show_dev(struct class_dev
37910  {
37911         struct video_device *vfd = container_of(cd, struct video_device, class_dev);
37912         dev_t dev = MKDEV(VIDEO_MAJOR, vfd->minor);
37913 -       return sprintf(buf,"%04x\n",old_encode_dev(dev));
37914 +       return print_dev_t(buf,dev);
37915  }
37916  
37917  static CLASS_DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
37918 --- linux-2.6.0-test6/drivers/media/video/vpx3220.c     2003-09-08 13:58:57.000000000 -0700
37919 +++ 25/drivers/media/video/vpx3220.c    2003-10-05 00:33:24.000000000 -0700
37920 @@ -18,7 +18,6 @@
37921   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37922   */
37923  
37924 -#include <linux/version.h>
37925  #include <linux/module.h>
37926  #include <linux/init.h>
37927  #include <linux/delay.h>
37928 --- linux-2.6.0-test6/drivers/media/video/zoran_card.c  2003-09-08 13:58:57.000000000 -0700
37929 +++ 25/drivers/media/video/zoran_card.c 2003-10-05 00:33:24.000000000 -0700
37930 @@ -28,7 +28,6 @@
37931   */
37932  
37933  #include <linux/config.h>
37934 -#include <linux/version.h>
37935  #include <linux/types.h>
37936  #include <linux/kernel.h>
37937  #include <linux/module.h>
37938 --- linux-2.6.0-test6/drivers/media/video/zoran_device.c        2003-09-08 13:58:57.000000000 -0700
37939 +++ 25/drivers/media/video/zoran_device.c       2003-10-05 00:33:24.000000000 -0700
37940 @@ -28,7 +28,6 @@
37941   */
37942  
37943  #include <linux/config.h>
37944 -#include <linux/version.h>
37945  #include <linux/types.h>
37946  #include <linux/kernel.h>
37947  #include <linux/module.h>
37948 --- linux-2.6.0-test6/drivers/media/video/zoran_procfs.c        2003-09-08 13:58:57.000000000 -0700
37949 +++ 25/drivers/media/video/zoran_procfs.c       2003-10-05 00:33:24.000000000 -0700
37950 @@ -28,7 +28,6 @@
37951   */
37952  
37953  #include <linux/config.h>
37954 -#include <linux/version.h>
37955  #include <linux/types.h>
37956  #include <linux/kernel.h>
37957  #include <linux/module.h>
37958 --- linux-2.6.0-test6/drivers/media/video/zr36120.c     2003-08-08 22:55:12.000000000 -0700
37959 +++ 25/drivers/media/video/zr36120.c    2003-10-05 00:33:24.000000000 -0700
37960 @@ -36,7 +36,6 @@
37961  #include <linux/sched.h>
37962  #include <linux/video_decoder.h>
37963  
37964 -#include <linux/version.h>
37965  #include <asm/uaccess.h>
37966  
37967  #include "tuner.h"
37968 --- linux-2.6.0-test6/drivers/media/video/zr36120_i2c.c 2003-06-14 12:18:52.000000000 -0700
37969 +++ 25/drivers/media/video/zr36120_i2c.c        2003-10-05 00:33:24.000000000 -0700
37970 @@ -22,7 +22,6 @@
37971  #include <linux/delay.h>
37972  #include <asm/io.h>
37973  
37974 -#include <linux/version.h>
37975  #include <linux/video_decoder.h>
37976  #include <asm/uaccess.h>
37977  
37978 --- linux-2.6.0-test6/drivers/message/i2o/i2o_block.c   2003-08-08 22:55:12.000000000 -0700
37979 +++ 25/drivers/message/i2o/i2o_block.c  2003-10-05 00:34:01.000000000 -0700
37980 @@ -885,10 +885,10 @@ static void i2o_block_biosparam(
37981   *     Issue device specific ioctl calls.
37982   */
37983  
37984 -static int i2ob_ioctl(struct inode *inode, struct file *file,
37985 +static int i2ob_ioctl(struct block_device *bdev, struct file *file,
37986                      unsigned int cmd, unsigned long arg)
37987  {
37988 -       struct gendisk *disk = inode->i_bdev->bd_disk;
37989 +       struct gendisk *disk = bdev->bd_disk;
37990         struct i2ob_device *dev = disk->private_data;
37991  
37992         /* Anyone capable of this syscall can do *real bad* things */
37993 @@ -901,7 +901,7 @@ static int i2ob_ioctl(struct inode *inod
37994                         struct hd_geometry g;
37995                         i2o_block_biosparam(get_capacity(disk), 
37996                                         &g.cylinders, &g.heads, &g.sectors);
37997 -                       g.start = get_start_sect(inode->i_bdev);
37998 +                       g.start = get_start_sect(bdev);
37999                         return copy_to_user((void *)arg,&g, sizeof(g))?-EFAULT:0;
38000                 }
38001                 
38002 @@ -927,9 +927,8 @@ static int i2ob_ioctl(struct inode *inod
38003   *     Close the block device down
38004   */
38005   
38006 -static int i2ob_release(struct inode *inode, struct file *file)
38007 +static int i2ob_release(struct gendisk *disk)
38008  {
38009 -       struct gendisk *disk = inode->i_bdev->bd_disk;
38010         struct i2ob_device *dev = disk->private_data;
38011  
38012         /*
38013 @@ -999,9 +998,9 @@ static int i2ob_release(struct inode *in
38014   *     Open the block device.
38015   */
38016   
38017 -static int i2ob_open(struct inode *inode, struct file *file)
38018 +static int i2ob_open(struct block_device *bdev, struct file *file)
38019  {
38020 -       struct gendisk *disk = inode->i_bdev->bd_disk;
38021 +       struct gendisk *disk = bdev->bd_disk;
38022         struct i2ob_device *dev = disk->private_data;
38023  
38024         if(!dev->i2odev)        
38025 --- linux-2.6.0-test6/drivers/mtd/chips/cfi_cmdset_0020.c       2003-06-14 12:18:06.000000000 -0700
38026 +++ 25/drivers/mtd/chips/cfi_cmdset_0020.c      2003-10-05 00:33:24.000000000 -0700
38027 @@ -17,6 +17,7 @@
38028   *     - added a writev function
38029   */
38030  
38031 +#include <linux/version.h>
38032  #include <linux/module.h>
38033  #include <linux/types.h>
38034  #include <linux/kernel.h>
38035 @@ -26,7 +27,6 @@
38036  #include <asm/byteorder.h>
38037  
38038  #include <linux/errno.h>
38039 -#include <linux/init.h>
38040  #include <linux/slab.h>
38041  #include <linux/delay.h>
38042  #include <linux/interrupt.h>
38043 @@ -208,6 +208,7 @@ static struct mtd_info *cfi_staa_setup(s
38044         if (!mtd->eraseregions) { 
38045                 printk(KERN_ERR "Failed to allocate memory for MTD erase region info\n");
38046                 kfree(cfi->cmdset_priv);
38047 +               kfree(mtd);
38048                 return NULL;
38049         }
38050         
38051 @@ -232,6 +233,7 @@ static struct mtd_info *cfi_staa_setup(s
38052                         printk(KERN_WARNING "Sum of regions (%lx) != total size of set of interleaved chips (%lx)\n", offset, devsize);
38053                         kfree(mtd->eraseregions);
38054                         kfree(cfi->cmdset_priv);
38055 +                       kfree(mtd);
38056                         return NULL;
38057                 }
38058  
38059 --- linux-2.6.0-test6/drivers/mtd/chips/gen_probe.c     2003-07-02 14:53:14.000000000 -0700
38060 +++ 25/drivers/mtd/chips/gen_probe.c    2003-10-05 00:33:24.000000000 -0700
38061 @@ -11,7 +11,6 @@
38062  #include <linux/mtd/mtd.h>
38063  #include <linux/mtd/map.h>
38064  #include <linux/mtd/cfi.h>
38065 -#include <linux/mtd/mtd.h>
38066  #include <linux/mtd/gen_probe.h>
38067  
38068  static struct mtd_info *check_cmd_set(struct map_info *, int);
38069 --- linux-2.6.0-test6/drivers/mtd/chips/map_rom.c       2003-06-14 12:18:24.000000000 -0700
38070 +++ 25/drivers/mtd/chips/map_rom.c      2003-10-05 00:33:24.000000000 -0700
38071 @@ -4,7 +4,6 @@
38072   * $Id: 2.6.0-test6-mm4.patch,v 1.5 2004/02/23 23:37:02 phil Exp $
38073   */
38074  
38075 -#include <linux/version.h>
38076  #include <linux/module.h>
38077  #include <linux/types.h>
38078  #include <linux/kernel.h>
38079 --- linux-2.6.0-test6/drivers/mtd/chips/sharp.c 2003-08-22 19:23:41.000000000 -0700
38080 +++ 25/drivers/mtd/chips/sharp.c        2003-10-05 00:33:24.000000000 -0700
38081 @@ -22,7 +22,6 @@
38082  
38083  #include <linux/kernel.h>
38084  #include <linux/module.h>
38085 -#include <linux/version.h>
38086  #include <linux/types.h>
38087  #include <linux/sched.h>
38088  #include <linux/errno.h>
38089 --- linux-2.6.0-test6/drivers/mtd/devices/lart.c        2003-06-14 12:18:08.000000000 -0700
38090 +++ 25/drivers/mtd/devices/lart.c       2003-10-05 00:33:24.000000000 -0700
38091 @@ -42,7 +42,6 @@
38092  #include <linux/kernel.h>
38093  #include <linux/module.h>
38094  #include <linux/types.h>
38095 -#include <linux/version.h>
38096  #include <linux/errno.h>
38097  #include <linux/mtd/mtd.h>
38098  #ifdef HAVE_PARTITIONS
38099 --- linux-2.6.0-test6/drivers/mtd/devices/pmc551.c      2003-06-14 12:18:29.000000000 -0700
38100 +++ 25/drivers/mtd/devices/pmc551.c     2003-10-05 00:33:24.000000000 -0700
38101 @@ -82,6 +82,7 @@
38102   *       * Comb the init routine.  It's still a bit cludgy on a few things.
38103   */
38104  
38105 +#include <linux/version.h>
38106  #include <linux/config.h>
38107  #include <linux/kernel.h>
38108  #include <linux/module.h>
38109 --- linux-2.6.0-test6/drivers/mtd/maps/integrator-flash.c       2003-06-14 12:18:29.000000000 -0700
38110 +++ 25/drivers/mtd/maps/integrator-flash.c      2003-10-05 00:33:24.000000000 -0700
38111 @@ -31,223 +31,181 @@
38112  #include <linux/kernel.h>
38113  #include <linux/slab.h>
38114  #include <linux/ioport.h>
38115 +#include <linux/device.h>
38116  #include <linux/init.h>
38117  
38118  #include <linux/mtd/mtd.h>
38119  #include <linux/mtd/map.h>
38120  #include <linux/mtd/partitions.h>
38121  
38122 +#include <asm/mach/flash.h>
38123  #include <asm/hardware.h>
38124  #include <asm/io.h>
38125  #include <asm/system.h>
38126  
38127 -// board specific stuff - sorry, it should be in arch/arm/mach-*.
38128 -#ifdef CONFIG_ARCH_INTEGRATOR
38129 -
38130 -#define FLASH_BASE     INTEGRATOR_FLASH_BASE
38131 -#define FLASH_SIZE     INTEGRATOR_FLASH_SIZE
38132 -
38133 -#define FLASH_PART_SIZE 0x400000
38134 -
38135 -#define SC_CTRLC       (IO_ADDRESS(INTEGRATOR_SC_BASE) + INTEGRATOR_SC_CTRLC_OFFSET)
38136 -#define SC_CTRLS       (IO_ADDRESS(INTEGRATOR_SC_BASE) + INTEGRATOR_SC_CTRLS_OFFSET)
38137 -#define EBI_CSR1       (IO_ADDRESS(INTEGRATOR_EBI_BASE) + INTEGRATOR_EBI_CSR1_OFFSET)
38138 -#define EBI_LOCK       (IO_ADDRESS(INTEGRATOR_EBI_BASE) + INTEGRATOR_EBI_LOCK_OFFSET)
38139 -
38140 -/*
38141 - * Initialise the flash access systems:
38142 - *  - Disable VPP
38143 - *  - Assert WP
38144 - *  - Set write enable bit in EBI reg
38145 - */
38146 -static void armflash_flash_init(void)
38147 -{
38148 -       unsigned int tmp;
38149 -
38150 -       __raw_writel(INTEGRATOR_SC_CTRL_nFLVPPEN | INTEGRATOR_SC_CTRL_nFLWP, SC_CTRLC);
38151 -
38152 -       tmp = __raw_readl(EBI_CSR1) | INTEGRATOR_EBI_WRITE_ENABLE;
38153 -       __raw_writel(tmp, EBI_CSR1);
38154 -
38155 -       if (!(__raw_readl(EBI_CSR1) & INTEGRATOR_EBI_WRITE_ENABLE)) {
38156 -               __raw_writel(0xa05f, EBI_LOCK);
38157 -               __raw_writel(tmp, EBI_CSR1);
38158 -               __raw_writel(0, EBI_LOCK);
38159 -       }
38160 -}
38161 -
38162 -/*
38163 - * Shutdown the flash access systems:
38164 - *  - Disable VPP
38165 - *  - Assert WP
38166 - *  - Clear write enable bit in EBI reg
38167 - */
38168 -static void armflash_flash_exit(void)
38169 -{
38170 -       unsigned int tmp;
38171 -
38172 -       __raw_writel(INTEGRATOR_SC_CTRL_nFLVPPEN | INTEGRATOR_SC_CTRL_nFLWP, SC_CTRLC);
38173 -
38174 -       /*
38175 -        * Clear the write enable bit in system controller EBI register.
38176 -        */
38177 -       tmp = __raw_readl(EBI_CSR1) & ~INTEGRATOR_EBI_WRITE_ENABLE;
38178 -       __raw_writel(tmp, EBI_CSR1);
38179 -
38180 -       if (__raw_readl(EBI_CSR1) & INTEGRATOR_EBI_WRITE_ENABLE) {
38181 -               __raw_writel(0xa05f, EBI_LOCK);
38182 -               __raw_writel(tmp, EBI_CSR1);
38183 -               __raw_writel(0, EBI_LOCK);
38184 -       }
38185 -}
38186 -
38187 -static void armflash_flash_wp(int on)
38188 -{
38189 -       unsigned int reg;
38190 -
38191 -       if (on)
38192 -               reg = SC_CTRLC;
38193 -       else
38194 -               reg = SC_CTRLS;
38195 -
38196 -       __raw_writel(INTEGRATOR_SC_CTRL_nFLWP, reg);
38197 -}
38198 -
38199 -static void armflash_set_vpp(struct map_info *map, int on)
38200 -{
38201 -       unsigned int reg;
38202 -
38203 -       if (on)
38204 -               reg = SC_CTRLS;
38205 -       else
38206 -               reg = SC_CTRLC;
38207 -
38208 -       __raw_writel(INTEGRATOR_SC_CTRL_nFLVPPEN, reg);
38209 -}
38210 -#endif
38211 -
38212  #ifdef CONFIG_ARCH_P720T
38213 -
38214  #define FLASH_BASE             (0x04000000)
38215  #define FLASH_SIZE             (64*1024*1024)
38216 +#endif
38217  
38218 -#define FLASH_PART_SIZE        (4*1024*1024)
38219 -#define FLASH_BLOCK_SIZE       (128*1024)
38220 +struct armflash_info {
38221 +       struct flash_platform_data *plat;
38222 +       struct resource         *res;
38223 +       struct mtd_partition    *parts;
38224 +       struct mtd_info         *mtd;
38225 +       struct map_info         map;
38226 +};
38227  
38228 -static void armflash_flash_init(void)
38229 +static void armflash_set_vpp(struct map_info *map, int on)
38230  {
38231 -}
38232 +       struct armflash_info *info = container_of(map, struct armflash_info, map);
38233  
38234 -static void armflash_flash_exit(void)
38235 -{
38236 +       if (info->plat && info->plat->set_vpp)
38237 +               info->plat->set_vpp(on);
38238  }
38239  
38240 -static void armflash_flash_wp(int on)
38241 -{
38242 -}
38243 +static const char *probes[] = { "RedBoot", "afs", NULL };
38244  
38245 -static void armflash_set_vpp(struct map_info *map, int on)
38246 +static int armflash_probe(struct device *_dev)
38247  {
38248 -}
38249 -#endif
38250 +       struct platform_device *dev = to_platform_device(_dev);
38251 +       struct flash_platform_data *plat = dev->dev.platform_data;
38252 +       struct resource *res = dev->resource;
38253 +       unsigned int size = res->end - res->start + 1;
38254 +       struct armflash_info *info;
38255 +       int err;
38256 +       void *base;
38257  
38258 +       info = kmalloc(sizeof(struct armflash_info), GFP_KERNEL);
38259 +       if (!info) {
38260 +               err = -ENOMEM;
38261 +               goto out;
38262 +       }
38263  
38264 -static struct map_info armflash_map =
38265 -{
38266 -       .name =         "AFS",
38267 -       .set_vpp =      armflash_set_vpp,
38268 -       .phys =         FLASH_BASE,
38269 -};
38270 +       memset(info, 0, sizeof(struct armflash_info));
38271  
38272 -static struct mtd_info *mtd;
38273 -static struct mtd_partition *parts;
38274 -static const char *probes[] = { "RedBoot", "afs", NULL };
38275 +       info->plat = plat;
38276 +       if (plat && plat->init) {
38277 +               err = plat->init();
38278 +               if (err)
38279 +                       goto no_resource;
38280 +       }
38281  
38282 -static int __init armflash_cfi_init(void *base, u_int size)
38283 -{
38284 -       int ret;
38285 +       info->res = request_mem_region(res->start, size, "armflash");
38286 +       if (!info->res) {
38287 +               err = -EBUSY;
38288 +               goto no_resource;
38289 +       }
38290  
38291 -       armflash_flash_init();
38292 -       armflash_flash_wp(1);
38293 +       base = ioremap(res->start, size);
38294 +       if (!base) {
38295 +               err = -ENOMEM;
38296 +               goto no_mem;
38297 +       }
38298  
38299         /*
38300          * look for CFI based flash parts fitted to this board
38301          */
38302 -       armflash_map.size       = size;
38303 -       armflash_map.buswidth   = 4;
38304 -       armflash_map.virt = (unsigned long) base;
38305 +       info->map.size          = size;
38306 +       info->map.buswidth      = plat->width;
38307 +       info->map.phys          = res->start;
38308 +       info->map.virt          = (unsigned long) base;
38309 +       info->map.name          = dev->dev.bus_id;
38310 +       info->map.set_vpp       = armflash_set_vpp;
38311  
38312 -       simple_map_init(&armflash_map);
38313 +       simple_map_init(&info->map);
38314  
38315         /*
38316          * Also, the CFI layer automatically works out what size
38317          * of chips we have, and does the necessary identification
38318          * for us automatically.
38319          */
38320 -       mtd = do_map_probe("cfi_probe", &armflash_map);
38321 -       if (!mtd)
38322 -               return -ENXIO;
38323 -
38324 -       mtd->owner = THIS_MODULE;
38325 -
38326 -       ret = parse_mtd_partitions(mtd, probes, &parts, (void *)0);
38327 -       if (ret > 0) {
38328 -               ret = add_mtd_partitions(mtd, parts, ret);
38329 -               if (ret)
38330 -                       printk(KERN_ERR "mtd partition registration "
38331 -                               "failed: %d\n", ret);
38332 +       info->mtd = do_map_probe(plat->map_name, &info->map);
38333 +       if (!info->mtd) {
38334 +               err = -ENXIO;
38335 +               goto no_device;
38336         }
38337  
38338 +       info->mtd->owner = THIS_MODULE;
38339 +
38340 +       err = parse_mtd_partitions(info->mtd, probes, &info->parts, 0);
38341 +       if (err > 0) {
38342 +               err = add_mtd_partitions(info->mtd, info->parts, err);
38343 +               if (err)
38344 +                       printk(KERN_ERR
38345 +                              "mtd partition registration failed: %d\n", err);
38346 +       }
38347 +
38348 +       if (err == 0)
38349 +               dev_set_drvdata(&dev->dev, info);
38350 +
38351         /*
38352          * If we got an error, free all resources.
38353          */
38354 -       if (ret < 0) {
38355 -               del_mtd_partitions(mtd);
38356 -               map_destroy(mtd);
38357 -       }
38358 +       if (err < 0) {
38359 +               if (info->mtd) {
38360 +                       del_mtd_partitions(info->mtd);
38361 +                       map_destroy(info->mtd);
38362 +               }
38363 +               if (info->parts)
38364 +                       kfree(info->parts);
38365  
38366 -       return ret;
38367 -}
38368 -
38369 -static void armflash_cfi_exit(void)
38370 -{
38371 -       if (mtd) {
38372 -               del_mtd_partitions(mtd);
38373 -               map_destroy(mtd);
38374 + no_device:
38375 +               iounmap(base);
38376 + no_mem:
38377 +               release_mem_region(res->start, size);
38378 + no_resource:
38379 +               if (plat && plat->exit)
38380 +                       plat->exit();
38381 +               kfree(info);
38382         }
38383 -       if (parts)
38384 -               kfree(parts);
38385 + out:
38386 +       return err;
38387  }
38388  
38389 -static int __init armflash_init(void)
38390 +static int armflash_remove(struct device *_dev)
38391  {
38392 -       int err = -EBUSY;
38393 -       void *base;
38394 +       struct platform_device *dev = to_platform_device(_dev);
38395 +       struct armflash_info *info = dev_get_drvdata(&dev->dev);
38396  
38397 -       if (request_mem_region(FLASH_BASE, FLASH_SIZE, "flash") == NULL)
38398 -               goto out;
38399 +       dev_set_drvdata(&dev->dev, NULL);
38400  
38401 -       base = ioremap(FLASH_BASE, FLASH_SIZE);
38402 -       err = -ENOMEM;
38403 -       if (base == NULL)
38404 -               goto release;
38405 +       if (info) {
38406 +               if (info->mtd) {
38407 +                       del_mtd_partitions(info->mtd);
38408 +                       map_destroy(info->mtd);
38409 +               }
38410 +               if (info->parts)
38411 +                       kfree(info->parts);
38412  
38413 -       err = armflash_cfi_init(base, FLASH_SIZE);
38414 -       if (err) {
38415 -               iounmap(base);
38416 -release:
38417 -               release_mem_region(FLASH_BASE, FLASH_SIZE);
38418 +               iounmap((void *)info->map.virt);
38419 +               release_resource(info->res);
38420 +               kfree(info->res);
38421 +
38422 +               if (info->plat && info->plat->exit)
38423 +                       info->plat->exit();
38424 +
38425 +               kfree(info);
38426         }
38427 -out:
38428 -       return err;
38429 +
38430 +       return 0;
38431 +}
38432 +
38433 +static struct device_driver armflash_driver = {
38434 +       .name           = "armflash",
38435 +       .bus            = &platform_bus_type,
38436 +       .probe          = armflash_probe,
38437 +       .remove         = armflash_remove,
38438 +};
38439 +
38440 +static int __init armflash_init(void)
38441 +{
38442 +       return driver_register(&armflash_driver);
38443  }
38444  
38445  static void __exit armflash_exit(void)
38446  {
38447 -       armflash_cfi_exit();
38448 -       iounmap((void *)armflash_map.virt);
38449 -       release_mem_region(FLASH_BASE, FLASH_SIZE);
38450 -       armflash_flash_exit();
38451 +       driver_unregister(&armflash_driver);
38452  }
38453  
38454  module_init(armflash_init);
38455 --- linux-2.6.0-test6/drivers/mtd/maps/sun_uflash.c     2003-06-14 12:18:25.000000000 -0700
38456 +++ 25/drivers/mtd/maps/sun_uflash.c    2003-10-05 00:33:24.000000000 -0700
38457 @@ -12,7 +12,6 @@
38458  
38459  #include <linux/kernel.h>
38460  #include <linux/module.h>
38461 -#include <linux/version.h>
38462  #include <linux/fs.h>
38463  #include <linux/errno.h>
38464  #include <linux/init.h>
38465 --- linux-2.6.0-test6/drivers/mtd/mtd_blkdevs.c 2003-09-27 18:57:44.000000000 -0700
38466 +++ 25/drivers/mtd/mtd_blkdevs.c        2003-10-05 00:34:01.000000000 -0700
38467 @@ -141,14 +141,12 @@ static void mtd_blktrans_request(struct 
38468  }
38469  
38470  
38471 -int blktrans_open(struct inode *i, struct file *f)
38472 +static int blktrans_open(struct block_device *bdev, struct file *f)
38473  {
38474 -       struct mtd_blktrans_dev *dev;
38475 -       struct mtd_blktrans_ops *tr;
38476 +       struct mtd_blktrans_dev *dev = bdev->bd_disk->private_data;
38477 +       struct mtd_blktrans_ops *tr = dev->tr;
38478         int ret = -ENODEV;
38479  
38480 -       dev = i->i_bdev->bd_disk->private_data;
38481 -       tr = dev->tr;
38482  
38483         if (!try_module_get(dev->mtd->owner))
38484                 goto out;
38485 @@ -172,15 +170,12 @@ int blktrans_open(struct inode *i, struc
38486         return ret;
38487  }
38488  
38489 -int blktrans_release(struct inode *i, struct file *f)
38490 +static int blktrans_release(struct gendisk *disk)
38491  {
38492 -       struct mtd_blktrans_dev *dev;
38493 -       struct mtd_blktrans_ops *tr;
38494 +       struct mtd_blktrans_dev *dev = disk->private_data;
38495 +       struct mtd_blktrans_ops *tr = dev->tr;
38496         int ret = 0;
38497  
38498 -       dev = i->i_bdev->bd_disk->private_data;
38499 -       tr = dev->tr;
38500 -
38501         if (tr->release)
38502                 ret = tr->release(dev);
38503  
38504 @@ -194,10 +189,10 @@ int blktrans_release(struct inode *i, st
38505  }
38506  
38507  
38508 -static int blktrans_ioctl(struct inode *inode, struct file *file, 
38509 +static int blktrans_ioctl(struct block_device *bdev, struct file *file, 
38510                               unsigned int cmd, unsigned long arg)
38511  {
38512 -       struct mtd_blktrans_dev *dev = inode->i_bdev->bd_disk->private_data;
38513 +       struct mtd_blktrans_dev *dev = bdev->bd_disk->private_data;
38514         struct mtd_blktrans_ops *tr = dev->tr;
38515  
38516         switch (cmd) {
38517 @@ -217,7 +212,7 @@ static int blktrans_ioctl(struct inode *
38518                         if (ret)
38519                                 return ret;
38520  
38521 -                       g.start = get_start_sect(inode->i_bdev);
38522 +                       g.start = get_start_sect(bdev);
38523                         if (copy_to_user((void *)arg, &g, sizeof(g)))
38524                                 return -EFAULT;
38525                         return 0;
38526 --- linux-2.6.0-test6/drivers/mtd/mtdcore.c     2003-06-14 12:18:20.000000000 -0700
38527 +++ 25/drivers/mtd/mtdcore.c    2003-10-05 00:33:24.000000000 -0700
38528 @@ -6,6 +6,7 @@
38529   *
38530   */
38531  
38532 +#include <linux/version.h>
38533  #include <linux/config.h>
38534  #include <linux/module.h>
38535  #include <linux/kernel.h>
38536 --- linux-2.6.0-test6/drivers/mtd/nand/autcpu12.c       2003-09-08 13:58:57.000000000 -0700
38537 +++ 25/drivers/mtd/nand/autcpu12.c      2003-10-05 00:33:24.000000000 -0700
38538 @@ -27,6 +27,7 @@
38539   *     10-06-2002 TG   128K card support added
38540   */
38541  
38542 +#include <linux/version.h>
38543  #include <linux/slab.h>
38544  #include <linux/init.h>
38545  #include <linux/module.h>
38546 --- linux-2.6.0-test6/drivers/net/3c523.c       2003-09-08 13:58:57.000000000 -0700
38547 +++ 25/drivers/net/3c523.c      2003-10-05 00:33:24.000000000 -0700
38548 @@ -102,7 +102,7 @@
38549  #include <linux/slab.h>
38550  #include <linux/interrupt.h>
38551  #include <linux/delay.h>
38552 -#include <linux/mca.h>
38553 +#include <linux/mca-legacy.h>
38554  #include <linux/ethtool.h>
38555  
38556  #include <asm/uaccess.h>
38557 --- linux-2.6.0-test6/drivers/net/3c527.c       2003-09-08 13:58:57.000000000 -0700
38558 +++ 25/drivers/net/3c527.c      2003-10-05 00:33:24.000000000 -0700
38559 @@ -92,7 +92,7 @@ DRV_NAME ".c:v" DRV_VERSION " " DRV_RELD
38560  #include <linux/types.h>
38561  #include <linux/fcntl.h>
38562  #include <linux/interrupt.h>
38563 -#include <linux/mca.h>
38564 +#include <linux/mca-legacy.h>
38565  #include <linux/ioport.h>
38566  #include <linux/in.h>
38567  #include <linux/skbuff.h>
38568 --- linux-2.6.0-test6/drivers/net/3c59x.c       2003-09-08 13:58:57.000000000 -0700
38569 +++ 25/drivers/net/3c59x.c      2003-10-05 00:33:46.000000000 -0700
38570 @@ -1063,6 +1063,22 @@ static int __devinit vortex_init_one (st
38571         return rc;
38572  }
38573  
38574 +#ifdef CONFIG_NET_POLL_CONTROLLER
38575 +static void vortex_rx_poll(struct net_device *dev)
38576 +{
38577 +       disable_irq(dev->irq);
38578 +       vortex_interrupt(dev->irq, (void *)dev, 0);
38579 +       enable_irq(dev->irq);
38580 +}
38581 +
38582 +static void boomerang_rx_poll(struct net_device *dev)
38583 +{
38584 +       disable_irq(dev->irq);
38585 +       boomerang_interrupt(dev->irq, (void *)dev, 0);
38586 +       enable_irq(dev->irq);
38587 +}
38588 +#endif
38589 +
38590  /*
38591   * Start up the PCI/EISA device which is described by *gendev.
38592   * Return 0 on success.
38593 @@ -1450,6 +1466,13 @@ static int __devinit vortex_probe1(struc
38594         dev->set_multicast_list = set_rx_mode;
38595         dev->tx_timeout = vortex_tx_timeout;
38596         dev->watchdog_timeo = (watchdog * HZ) / 1000;
38597 +#ifdef CONFIG_NET_POLL_CONTROLLER
38598 +       if (vp->full_bus_master_tx)
38599 +               dev->poll_controller = boomerang_rx_poll;
38600 +       else
38601 +               dev->poll_controller = vortex_rx_poll;
38602 +#endif
38603 +
38604         if (pdev) {
38605                 vp->pm_state_valid = 1;
38606                 pci_save_state(VORTEX_PCI(vp), vp->power_state);
38607 --- linux-2.6.0-test6/drivers/net/8139too.c     2003-09-08 13:58:57.000000000 -0700
38608 +++ 25/drivers/net/8139too.c    2003-10-05 00:34:34.000000000 -0700
38609 @@ -248,6 +248,7 @@ static struct pci_device_id rtl8139_pci_
38610         {0x14ea, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
38611         {0x14ea, 0xab07, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
38612         {0x11db, 0x1234, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
38613 +       {0x1432, 0x9130, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
38614  
38615  #ifdef CONFIG_SH_SECUREEDGE5410
38616         /* Bogus 8139 silicon reports 8129 without external PROM :-( */
38617 --- linux-2.6.0-test6/drivers/net/arcnet/com20020.c     2003-08-22 19:23:41.000000000 -0700
38618 +++ 25/drivers/net/arcnet/com20020.c    2003-10-05 00:33:24.000000000 -0700
38619 @@ -180,10 +180,6 @@ int com20020_found(struct net_device *de
38620         if (!dev->dev_addr[0])
38621                 dev->dev_addr[0] = inb(ioaddr + 8);     /* FIXME: do this some other way! */
38622  
38623 -       /* reserve the I/O region */
38624 -       if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "arcnet (COM20020)"))
38625 -               return -EBUSY;
38626 -
38627         SET_SUBADR(SUB_SETUP1);
38628         outb(lp->setup, _XREG);
38629  
38630 @@ -207,7 +203,6 @@ int com20020_found(struct net_device *de
38631         if (request_irq(dev->irq, &arcnet_interrupt, shared,
38632                         "arcnet (COM20020)", dev)) {
38633                 BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", dev->irq);
38634 -               release_region(ioaddr, ARCNET_TOTAL_SIZE);
38635                 return -ENODEV;
38636         }
38637  
38638 @@ -227,7 +222,6 @@ int com20020_found(struct net_device *de
38639                clockrates[3 - ((lp->setup2 & 0xF0) >> 4) + ((lp->setup & 0x0F) >> 1)]);
38640  
38641         if (!dev->init && register_netdev(dev)) {
38642 -               release_region(ioaddr, ARCNET_TOTAL_SIZE);
38643                 free_irq(dev->irq, dev);
38644                 return -EIO;
38645         }
38646 @@ -342,7 +336,6 @@ void com20020_remove(struct net_device *
38647  {
38648         unregister_netdev(dev);
38649         free_irq(dev->irq, dev);
38650 -       release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
38651         kfree(dev->priv);
38652         free_netdev(dev);
38653  }
38654 --- linux-2.6.0-test6/drivers/net/arcnet/com20020-isa.c 2003-08-08 22:55:12.000000000 -0700
38655 +++ 25/drivers/net/arcnet/com20020-isa.c        2003-10-05 00:33:24.000000000 -0700
38656 @@ -53,6 +53,7 @@ static int __init com20020isa_probe(stru
38657         int ioaddr;
38658         unsigned long airqmask;
38659         struct arcnet_local *lp = dev->priv;
38660 +       int err;
38661  
38662         BUGLVL(D_NORMAL) printk(VERSION);
38663  
38664 @@ -62,17 +63,20 @@ static int __init com20020isa_probe(stru
38665                        "must specify the base address!\n");
38666                 return -ENODEV;
38667         }
38668 -       if (check_region(ioaddr, ARCNET_TOTAL_SIZE)) {
38669 +       if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "arcnet (COM20020)")) {
38670                 BUGMSG(D_NORMAL, "IO region %xh-%xh already allocated.\n",
38671                        ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
38672                 return -ENXIO;
38673         }
38674         if (ASTATUS() == 0xFF) {
38675                 BUGMSG(D_NORMAL, "IO address %x empty\n", ioaddr);
38676 -               return -ENODEV;
38677 +               err = -ENODEV;
38678 +               goto out;
38679 +       }
38680 +       if (com20020_check(dev)) {
38681 +               err = -ENODEV;
38682 +               goto out;
38683         }
38684 -       if (com20020_check(dev))
38685 -               return -ENODEV;
38686  
38687         if (!dev->irq) {
38688                 /* if we do this, we're sure to get an IRQ since the
38689 @@ -96,13 +100,21 @@ static int __init com20020isa_probe(stru
38690                         dev->irq = probe_irq_off(airqmask);
38691                         if (dev->irq <= 0) {
38692                                 BUGMSG(D_NORMAL, "Autoprobe IRQ failed.\n");
38693 -                               return -ENODEV;
38694 +                               err = -ENODEV;
38695 +                               goto out;
38696                         }
38697                 }
38698         }
38699  
38700         lp->card_name = "ISA COM20020";
38701 -       return com20020_found(dev, 0);
38702 +       if ((err = com20020_found(dev, 0)) != 0)
38703 +               goto out;
38704 +
38705 +       return 0;
38706 +
38707 +out:
38708 +       release_region(ioaddr, ARCNET_TOTAL_SIZE);
38709 +       return err;
38710  }
38711  
38712  
38713 @@ -170,6 +182,7 @@ int init_module(void)
38714  void cleanup_module(void)
38715  {
38716         com20020_remove(my_dev);
38717 +       release_region(my_dev->base_addr, ARCNET_TOTAL_SIZE);
38718  }
38719  
38720  #else
38721 --- linux-2.6.0-test6/drivers/net/arcnet/com20020-pci.c 2003-08-22 19:23:41.000000000 -0700
38722 +++ 25/drivers/net/arcnet/com20020-pci.c        2003-10-05 00:33:24.000000000 -0700
38723 @@ -115,20 +115,20 @@ static int __devinit com20020pci_probe(s
38724                 BUGMSG(D_NORMAL, "IO address %Xh was reported by PCI BIOS, "
38725                        "but seems empty!\n", ioaddr);
38726                 err = -EIO;
38727 -               goto out_priv;
38728 +               goto out_port;
38729         }
38730         if (com20020_check(dev)) {
38731                 err = -EIO;
38732 -               goto out_priv;
38733 +               goto out_port;
38734         }
38735  
38736 -       release_region(ioaddr, ARCNET_TOTAL_SIZE);
38737 -
38738         if ((err = com20020_found(dev, SA_SHIRQ)) != 0)
38739 -               goto out_priv;
38740 +               goto out_port;
38741  
38742         return 0;
38743  
38744 +out_port:
38745 +       release_region(ioaddr, ARCNET_TOTAL_SIZE);
38746  out_priv:
38747         kfree(dev->priv);
38748  out_dev:
38749 @@ -138,7 +138,9 @@ out_dev:
38750  
38751  static void __devexit com20020pci_remove(struct pci_dev *pdev)
38752  {
38753 -       com20020_remove(pci_get_drvdata(pdev));
38754 +       struct net_device *dev = pci_get_drvdata(pdev);
38755 +       com20020_remove(dev);
38756 +       release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
38757  }
38758  
38759  static struct pci_device_id com20020pci_id_table[] = {
38760 --- linux-2.6.0-test6/drivers/net/at1700.c      2003-06-14 12:18:07.000000000 -0700
38761 +++ 25/drivers/net/at1700.c     2003-10-05 00:33:24.000000000 -0700
38762 @@ -43,7 +43,7 @@
38763  #include <linux/errno.h>
38764  #include <linux/netdevice.h>
38765  #include <linux/etherdevice.h>
38766 -#include <linux/mca.h>
38767 +#include <linux/mca-legacy.h>
38768  #include <linux/module.h>
38769  #include <linux/kernel.h>
38770  #include <linux/types.h>
38771 --- linux-2.6.0-test6/drivers/net/e100/e100_main.c      2003-09-27 18:57:45.000000000 -0700
38772 +++ 25/drivers/net/e100/e100_main.c     2003-10-05 00:33:46.000000000 -0700
38773 @@ -539,6 +539,15 @@ e100_trigger_SWI(struct e100_private *bd
38774         readw(&(bdp->scb->scb_status)); /* flushes last write, read-safe */
38775  }
38776  
38777 +#ifdef CONFIG_NET_POLL_CONTROLLER
38778 +static void e100_rx_poll(struct net_device *dev)
38779 +{
38780 +       disable_irq(dev->irq);
38781 +       e100intr(dev->irq, (void *)dev, 0);
38782 +       enable_irq(dev->irq);
38783 +}
38784 +#endif
38785 +
38786  static int __devinit
38787  e100_found1(struct pci_dev *pcid, const struct pci_device_id *ent)
38788  {
38789 @@ -631,7 +640,9 @@ e100_found1(struct pci_dev *pcid, const 
38790         dev->set_multicast_list = &e100_set_multi;
38791         dev->set_mac_address = &e100_set_mac;
38792         dev->do_ioctl = &e100_ioctl;
38793 -
38794 +#ifdef CONFIG_NET_POLL_CONTROLLER
38795 +       dev->poll_controller = e100_rx_poll;
38796 +#endif
38797         if (bdp->flags & USE_IPCB)
38798         dev->features = NETIF_F_SG | NETIF_F_IP_CSUM |
38799                         NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
38800 --- linux-2.6.0-test6/drivers/net/eepro100.c    2003-09-08 13:58:57.000000000 -0700
38801 +++ 25/drivers/net/eepro100.c   2003-10-05 00:33:47.000000000 -0700
38802 @@ -543,6 +543,7 @@ static void speedo_refill_rx_buffers(str
38803  static int speedo_rx(struct net_device *dev);
38804  static void speedo_tx_buffer_gc(struct net_device *dev);
38805  static irqreturn_t speedo_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
38806 +static void poll_speedo (struct net_device *dev);
38807  static int speedo_close(struct net_device *dev);
38808  static struct net_device_stats *speedo_get_stats(struct net_device *dev);
38809  static int speedo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
38810 @@ -885,6 +886,9 @@ static int __devinit speedo_found1(struc
38811         dev->get_stats = &speedo_get_stats;
38812         dev->set_multicast_list = &set_rx_mode;
38813         dev->do_ioctl = &speedo_ioctl;
38814 +#ifdef CONFIG_NET_POLL_CONTROLLER
38815 +       dev->poll_controller = &poll_speedo;
38816 +#endif
38817  
38818         if (register_netdevice(dev))
38819                 goto err_free_unlock;
38820 @@ -1675,6 +1679,22 @@ static irqreturn_t speedo_interrupt(int 
38821         return IRQ_RETVAL(handled);
38822  }
38823  
38824 +#ifdef CONFIG_NET_POLL_CONTROLLER
38825 +
38826 +/*
38827 + * Polling 'interrupt' - used by things like netconsole to send skbs
38828 + * without having to re-enable interrupts. It's not called while
38829 + * the interrupt routine is executing.
38830 + */
38831 +
38832 +static void poll_speedo (struct net_device *dev)
38833 +{
38834 +       disable_irq(dev->irq);
38835 +       speedo_interrupt (dev->irq, dev, NULL);
38836 +       enable_irq(dev->irq);
38837 +}
38838 +#endif
38839 +
38840  static inline struct RxFD *speedo_rx_alloc(struct net_device *dev, int entry)
38841  {
38842         struct speedo_private *sp = (struct speedo_private *)dev->priv;
38843 --- linux-2.6.0-test6/drivers/net/eexpress.c    2003-08-22 19:23:41.000000000 -0700
38844 +++ 25/drivers/net/eexpress.c   2003-10-05 00:33:24.000000000 -0700
38845 @@ -113,7 +113,6 @@
38846  #include <linux/etherdevice.h>
38847  #include <linux/skbuff.h>
38848  #include <linux/slab.h>
38849 -#include <linux/mca.h>
38850  #include <linux/mca-legacy.h>
38851  #include <linux/spinlock.h>
38852  
38853 --- linux-2.6.0-test6/drivers/net/ibmlana.c     2003-09-27 18:57:45.000000000 -0700
38854 +++ 25/drivers/net/ibmlana.c    2003-10-05 00:33:24.000000000 -0700
38855 @@ -82,7 +82,7 @@ History:
38856  #include <linux/interrupt.h>
38857  #include <linux/delay.h>
38858  #include <linux/time.h>
38859 -#include <linux/mca.h>
38860 +#include <linux/mca-legacy.h>
38861  #include <linux/module.h>
38862  #include <linux/netdevice.h>
38863  #include <linux/etherdevice.h>
38864 --- linux-2.6.0-test6/drivers/net/irda/act200l.c        2003-09-08 13:58:57.000000000 -0700
38865 +++ 25/drivers/net/irda/act200l.c       2003-10-05 00:33:24.000000000 -0700
38866 @@ -84,12 +84,12 @@ static int  act200l_change_speed(struct 
38867  #define ACT200L_OSCL    0x04 /* oscillator in low power, medium accuracy mode */
38868  
38869  static struct dongle_reg dongle = {
38870 -       Q_NULL,
38871 -       IRDA_ACT200L_DONGLE,
38872 -       act200l_open,
38873 -       act200l_close,
38874 -       act200l_reset,
38875 -       act200l_change_speed,
38876 +       .type = IRDA_ACT200L_DONGLE,
38877 +       .open = act200l_open,
38878 +       .close = act200l_close,
38879 +       .reset = act200l_reset,
38880 +       .change_speed = act200l_change_speed,
38881 +       .owner = THIS_MODULE,
38882  };
38883  
38884  int __init act200l_init(void)
38885 @@ -112,8 +112,6 @@ static void act200l_open(dongle_t *self,
38886         /* Set the speeds we can accept */
38887         qos->baud_rate.bits &= IR_9600|IR_19200|IR_38400|IR_57600|IR_115200;
38888         qos->min_turn_time.bits = 0x03;
38889 -
38890 -       MOD_INC_USE_COUNT;
38891  }
38892  
38893  static void act200l_close(dongle_t *self)
38894 @@ -122,8 +120,6 @@ static void act200l_close(dongle_t *self
38895  
38896         /* Power off the dongle */
38897         self->set_dtr_rts(self->dev, FALSE, FALSE);
38898 -
38899 -       MOD_DEC_USE_COUNT;
38900  }
38901  
38902  /*
38903 --- linux-2.6.0-test6/drivers/net/irda/actisys.c        2003-09-08 13:58:57.000000000 -0700
38904 +++ 25/drivers/net/irda/actisys.c       2003-10-05 00:33:24.000000000 -0700
38905 @@ -64,21 +64,21 @@ static __u32 baud_rates[] = { 9600, 1920
38906  #define MAX_SPEEDS 5
38907  
38908  static struct dongle_reg dongle = {
38909 -       Q_NULL,
38910 -       IRDA_ACTISYS_DONGLE,
38911 -       actisys_open,
38912 -       actisys_close,
38913 -       actisys_reset,
38914 -       actisys_change_speed,
38915 +       .type = IRDA_ACTISYS_DONGLE,
38916 +       .open = actisys_open,
38917 +       .close = actisys_close,
38918 +       .reset = actisys_reset,
38919 +       .change_speed = actisys_change_speed,
38920 +       .owner = THIS_MODULE,
38921  };
38922  
38923  static struct dongle_reg dongle_plus = {
38924 -       Q_NULL,
38925 -       IRDA_ACTISYS_PLUS_DONGLE,
38926 -       actisys_open,
38927 -       actisys_close,
38928 -       actisys_reset,
38929 -       actisys_change_speed,
38930 +       .type = IRDA_ACTISYS_PLUS_DONGLE,
38931 +       .open = actisys_open,
38932 +       .close = actisys_close,
38933 +       .reset = actisys_reset,
38934 +       .change_speed = actisys_change_speed,
38935 +       .owner = THIS_MODULE,
38936  };
38937  
38938  /*
38939 @@ -128,16 +128,12 @@ static void actisys_open(dongle_t *self,
38940                 qos->baud_rate.bits &= ~IR_38400;
38941         
38942         qos->min_turn_time.bits = 0x7f; /* Needs 0.01 ms */
38943 -
38944 -       MOD_INC_USE_COUNT;
38945  }
38946  
38947  static void actisys_close(dongle_t *self)
38948  {
38949         /* Power off the dongle */
38950         self->set_dtr_rts(self->dev, FALSE, FALSE);
38951 -
38952 -       MOD_DEC_USE_COUNT;
38953  }
38954  
38955  /*
38956 --- linux-2.6.0-test6/drivers/net/irda/ali-ircc.c       2003-09-27 18:57:45.000000000 -0700
38957 +++ 25/drivers/net/irda/ali-ircc.c      2003-10-05 00:33:24.000000000 -0700
38958 @@ -254,7 +254,7 @@ static int ali_ircc_open(int i, chipio_t
38959         if ((ali_ircc_setup(info)) == -1)
38960                 return -1;
38961                 
38962 -       dev = alloc_netdev(sizeof(*self), "irda%d", irda_device_setup);
38963 +       dev = alloc_irdadev(sizeof(*self));
38964         if (dev == NULL) {
38965                 ERROR("%s(), can't allocate memory for control block!\n", __FUNCTION__);
38966                 return -ENOMEM;
38967 --- linux-2.6.0-test6/drivers/net/irda/donauboe.c       2003-09-27 18:57:45.000000000 -0700
38968 +++ 25/drivers/net/irda/donauboe.c      2003-10-05 00:33:24.000000000 -0700
38969 @@ -1598,8 +1598,7 @@ toshoboe_open (struct pci_dev *pci_dev, 
38970    if ((err=pci_enable_device(pci_dev)))
38971      return err;
38972  
38973 -  dev = alloc_netdev(sizeof (struct toshoboe_cb), "irda%d",
38974 -                    irda_device_setup);
38975 +  dev = alloc_irdadev(sizeof (struct toshoboe_cb));
38976    if (dev == NULL)
38977      {
38978        printk (KERN_ERR DRIVER_NAME ": can't allocate memory for "
38979 --- linux-2.6.0-test6/drivers/net/irda/ep7211_ir.c      2003-09-08 13:58:57.000000000 -0700
38980 +++ 25/drivers/net/irda/ep7211_ir.c     2003-10-05 00:33:24.000000000 -0700
38981 @@ -24,12 +24,12 @@ static int  ep7211_ir_change_speed(struc
38982  static int  ep7211_ir_reset(struct irda_task *task);
38983  
38984  static struct dongle_reg dongle = {
38985 -       Q_NULL,
38986 -       IRDA_EP7211_IR,
38987 -       ep7211_ir_open,
38988 -       ep7211_ir_close,
38989 -       ep7211_ir_reset,
38990 -       ep7211_ir_change_speed,
38991 +       .type = IRDA_EP7211_IR,
38992 +       .open = ep7211_ir_open,
38993 +       .close = ep7211_ir_close,
38994 +       .reset = ep7211_ir_reset,
38995 +       .change_speed = ep7211_ir_change_speed,
38996 +       .owner = THIS_MODULE,
38997  };
38998  
38999  static void ep7211_ir_open(dongle_t *self, struct qos_info *qos)
39000 @@ -47,8 +47,6 @@ static void ep7211_ir_open(dongle_t *sel
39001                 UART (interrupt #14). */
39002  
39003         restore_flags(flags);
39004 -
39005 -       MOD_INC_USE_COUNT;
39006  }
39007  
39008  static void ep7211_ir_close(dongle_t *self)
39009 @@ -66,8 +64,6 @@ static void ep7211_ir_close(dongle_t *se
39010                 reset them back to their original state. */
39011  
39012         restore_flags(flags);
39013 -
39014 -       MOD_DEC_USE_COUNT;
39015  }
39016  
39017  /*
39018 --- linux-2.6.0-test6/drivers/net/irda/esi.c    2003-09-08 13:58:57.000000000 -0700
39019 +++ 25/drivers/net/irda/esi.c   2003-10-05 00:33:24.000000000 -0700
39020 @@ -44,12 +44,12 @@ static int  esi_change_speed(struct irda
39021  static int  esi_reset(struct irda_task *task);
39022  
39023  static struct dongle_reg dongle = {
39024 -       Q_NULL,
39025 -       IRDA_ESI_DONGLE,
39026 -       esi_open,
39027 -       esi_close,
39028 -       esi_reset,
39029 -       esi_change_speed,
39030 +       .type = IRDA_ESI_DONGLE,
39031 +       .open = esi_open,
39032 +       .close = esi_close,
39033 +       .reset = esi_reset,
39034 +       .change_speed = esi_change_speed,
39035 +       .owner = THIS_MODULE,
39036  };
39037  
39038  int __init esi_init(void)
39039 @@ -66,16 +66,12 @@ static void esi_open(dongle_t *self, str
39040  {
39041         qos->baud_rate.bits &= IR_9600|IR_19200|IR_115200;
39042         qos->min_turn_time.bits = 0x01; /* Needs at least 10 ms */
39043 -
39044 -       MOD_INC_USE_COUNT;
39045  }
39046  
39047  static void esi_close(dongle_t *dongle)
39048  {              
39049         /* Power off dongle */
39050         dongle->set_dtr_rts(dongle->dev, FALSE, FALSE);
39051 -
39052 -       MOD_DEC_USE_COUNT;
39053  }
39054  
39055  /*
39056 --- linux-2.6.0-test6/drivers/net/irda/girbil.c 2003-09-08 13:58:57.000000000 -0700
39057 +++ 25/drivers/net/irda/girbil.c        2003-10-05 00:33:24.000000000 -0700
39058 @@ -63,12 +63,12 @@ static int  girbil_change_speed(struct i
39059  #define GIRBIL_LOAD    0x51 /* Load the new baud rate value */
39060  
39061  static struct dongle_reg dongle = {
39062 -       Q_NULL,
39063 -       IRDA_GIRBIL_DONGLE,
39064 -       girbil_open,
39065 -       girbil_close,
39066 -       girbil_reset,
39067 -       girbil_change_speed,
39068 +       .type = IRDA_GIRBIL_DONGLE,
39069 +       .open = girbil_open,
39070 +       .close = girbil_close,
39071 +       .reset = girbil_reset,
39072 +       .change_speed = girbil_change_speed,
39073 +       .owner = THIS_MODULE,
39074  };
39075  
39076  int __init girbil_init(void)
39077 @@ -85,16 +85,12 @@ static void girbil_open(dongle_t *self, 
39078  {
39079         qos->baud_rate.bits &= IR_9600|IR_19200|IR_38400|IR_57600|IR_115200;
39080         qos->min_turn_time.bits = 0x03;
39081 -
39082 -       MOD_INC_USE_COUNT;
39083  }
39084  
39085  static void girbil_close(dongle_t *self)
39086  {
39087         /* Power off dongle */
39088         self->set_dtr_rts(self->dev, FALSE, FALSE);
39089 -
39090 -       MOD_DEC_USE_COUNT;
39091  }
39092  
39093  /*
39094 --- linux-2.6.0-test6/drivers/net/irda/irda-usb.c       2003-09-27 18:57:45.000000000 -0700
39095 +++ 25/drivers/net/irda/irda-usb.c      2003-10-05 00:33:24.000000000 -0700
39096 @@ -1176,7 +1176,7 @@ static inline int irda_usb_open(struct i
39097         memset(self->speed_buff, 0, IRDA_USB_SPEED_MTU);
39098  
39099         /* Create a network device for us */
39100 -       netdev = alloc_netdev(0, "irda%d",  irda_device_setup);
39101 +       netdev = alloc_irdadev(0);
39102         if (!netdev) {
39103                 ERROR("%s(), alloc_net_dev() failed!\n", __FUNCTION__);
39104                 return -ENOMEM;
39105 --- linux-2.6.0-test6/drivers/net/irda/irport.c 2003-06-14 12:18:25.000000000 -0700
39106 +++ 25/drivers/net/irda/irport.c        2003-10-05 00:33:24.000000000 -0700
39107 @@ -78,7 +78,6 @@ static inline void irport_write_wakeup(s
39108  static inline int  irport_write(int iobase, int fifo_size, __u8 *buf, int len);
39109  static inline void irport_receive(struct irport_cb *self);
39110  
39111 -static int  irport_net_init(struct net_device *dev);
39112  static int  irport_net_ioctl(struct net_device *dev, struct ifreq *rq, 
39113                              int cmd);
39114  static inline int  irport_is_receiving(struct irport_cb *self);
39115 @@ -136,30 +135,27 @@ irport_open(int i, unsigned int iobase, 
39116  {
39117         struct net_device *dev;
39118         struct irport_cb *self;
39119 -       void *ret;
39120 -       int err;
39121  
39122         IRDA_DEBUG(1, "%s()\n", __FUNCTION__);
39123  
39124         /* Lock the port that we need */
39125 -       ret = request_region(iobase, IO_EXTENT, driver_name);
39126 -       if (!ret) {
39127 +       if (!request_region(iobase, IO_EXTENT, driver_name)) {
39128                 IRDA_DEBUG(0, "%s(), can't get iobase of 0x%03x\n",
39129                            __FUNCTION__, iobase);
39130 -               return NULL;
39131 +               goto err_out1;
39132         }
39133  
39134         /*
39135          *  Allocate new instance of the driver
39136          */
39137 -       self = kmalloc(sizeof(struct irport_cb), GFP_KERNEL);
39138 -       if (!self) {
39139 +       dev = alloc_irdadev(sizeof(struct irport_cb));
39140 +       if (!dev) {
39141                 ERROR("%s(), can't allocate memory for "
39142 -                     "control block!\n", __FUNCTION__);
39143 -               release_region(iobase, IO_EXTENT);
39144 -               return NULL;
39145 +                     "irda device!\n", __FUNCTION__);
39146 +               goto err_out2;
39147         }
39148 -       memset(self, 0, sizeof(struct irport_cb));
39149 +
39150 +       self = dev->priv;
39151         spin_lock_init(&self->lock);
39152  
39153         /* Need to store self somewhere */
39154 @@ -189,8 +185,11 @@ irport_open(int i, unsigned int iobase, 
39155         self->rx_buff.truesize = IRDA_SKB_MAX_MTU;
39156         self->rx_buff.skb = __dev_alloc_skb(self->rx_buff.truesize,
39157                                             GFP_KERNEL);
39158 -       if (self->rx_buff.skb == NULL)
39159 -               return NULL;
39160 +       if (self->rx_buff.skb == NULL) {
39161 +               ERROR("%s(), can't allocate memory for "
39162 +                     "receive buffer!\n", __FUNCTION__);
39163 +               goto err_out3;
39164 +       }
39165         skb_reserve(self->rx_buff.skb, 1);
39166         self->rx_buff.head = self->rx_buff.skb->data;
39167         /* No need to memset the buffer, unless you are really pedantic */
39168 @@ -208,30 +207,23 @@ irport_open(int i, unsigned int iobase, 
39169                 self->tx_buff.head = (__u8 *) kmalloc(self->tx_buff.truesize, 
39170                                                       GFP_KERNEL);
39171                 if (self->tx_buff.head == NULL) {
39172 -                       kfree_skb(self->rx_buff.skb);
39173 -                       self->rx_buff.skb = NULL;
39174 -                       self->rx_buff.head = NULL;
39175 -                       return NULL;
39176 +                       ERROR("%s(), can't allocate memory for "
39177 +                             "transmit buffer!\n", __FUNCTION__);
39178 +                       goto err_out4;
39179                 }
39180                 memset(self->tx_buff.head, 0, self->tx_buff.truesize);
39181         }       
39182         self->tx_buff.data = self->tx_buff.head;
39183  
39184 -       if (!(dev = dev_alloc("irda%d", &err))) {
39185 -               ERROR("%s(), dev_alloc() failed!\n", __FUNCTION__);
39186 -               return NULL;
39187 -       }
39188         self->netdev = dev;
39189         /* Keep track of module usage */
39190         SET_MODULE_OWNER(dev);
39191  
39192         /* May be overridden by piggyback drivers */
39193 -       dev->priv = (void *) self;
39194         self->interrupt    = irport_interrupt;
39195         self->change_speed = irport_change_speed;
39196  
39197         /* Override the network functions we need to use */
39198 -       dev->init            = irport_net_init;
39199         dev->hard_start_xmit = irport_hard_xmit;
39200         dev->tx_timeout      = irport_timeout;
39201         dev->watchdog_timeo  = HZ;  /* Allow time enough for speed change */
39202 @@ -244,17 +236,25 @@ irport_open(int i, unsigned int iobase, 
39203         dev->base_addr = iobase;
39204         dev->irq = irq;
39205  
39206 -       rtnl_lock();
39207 -       err = register_netdevice(dev);
39208 -       rtnl_unlock();
39209 -       if (err) {
39210 +       if (register_netdev(dev)) {
39211                 ERROR("%s(), register_netdev() failed!\n", __FUNCTION__);
39212 -               return NULL;
39213 +               goto err_out5;
39214         }
39215         MESSAGE("IrDA: Registered device %s (irport io=0x%X irq=%d)\n",
39216                 dev->name, iobase, irq);
39217  
39218         return self;
39219 + err_out5:
39220 +       kfree(self->tx_buff.head);
39221 + err_out4:
39222 +       kfree_skb(self->rx_buff.skb);
39223 + err_out3:
39224 +       free_netdev(dev);
39225 +       dev_self[i] = NULL;
39226 + err_out2:
39227 +       release_region(iobase, IO_EXTENT);
39228 + err_out1:
39229 +       return NULL;
39230  }
39231  
39232  int irport_close(struct irport_cb *self)
39233 @@ -267,8 +267,7 @@ int irport_close(struct irport_cb *self)
39234         self->dongle = NULL;
39235         
39236         /* Remove netdevice */
39237 -       if (self->netdev)
39238 -               unregister_netdev(self->netdev);
39239 +       unregister_netdev(self->netdev);
39240  
39241         /* Release the IO-port that this driver is using */
39242         IRDA_DEBUG(0 , "%s(), Releasing Region %03x\n", 
39243 @@ -284,7 +283,7 @@ int irport_close(struct irport_cb *self)
39244         
39245         /* Remove ourselves */
39246         dev_self[self->index] = NULL;
39247 -       kfree(self);
39248 +       free_netdev(self->netdev);
39249         
39250         return 0;
39251  }
39252 @@ -886,16 +885,6 @@ irqreturn_t irport_interrupt(int irq, vo
39253         return IRQ_RETVAL(handled);
39254  }
39255  
39256 -static int irport_net_init(struct net_device *dev)
39257 -{
39258 -       /* Set up to be a normal IrDA network device driver */
39259 -       irda_device_setup(dev);
39260 -
39261 -       /* Insert overrides below this line! */
39262 -
39263 -       return 0;
39264 -}
39265 -
39266  /*
39267   * Function irport_net_open (dev)
39268   *
39269 --- linux-2.6.0-test6/drivers/net/irda/litelink.c       2003-09-08 13:58:57.000000000 -0700
39270 +++ 25/drivers/net/irda/litelink.c      2003-10-05 00:33:24.000000000 -0700
39271 @@ -48,12 +48,12 @@ static int  litelink_reset(struct irda_t
39272  static __u32 baud_rates[] = { 115200, 57600, 38400, 19200, 9600 };
39273  
39274  static struct dongle_reg dongle = {
39275 -       Q_NULL,
39276 -       IRDA_LITELINK_DONGLE,
39277 -       litelink_open,
39278 -       litelink_close,
39279 -       litelink_reset,
39280 -       litelink_change_speed,
39281 +       .type = IRDA_LITELINK_DONGLE,
39282 +       .open = litelink_open,
39283 +       .close = litelink_close,
39284 +       .reset = litelink_reset,
39285 +       .change_speed = litelink_change_speed,
39286 +       .owner = THIS_MODULE,
39287  };
39288  
39289  int __init litelink_init(void)
39290 @@ -70,16 +70,12 @@ static void litelink_open(dongle_t *self
39291  {
39292         qos->baud_rate.bits &= IR_9600|IR_19200|IR_38400|IR_57600|IR_115200;
39293         qos->min_turn_time.bits = 0x7f; /* Needs 0.01 ms */
39294 -
39295 -       MOD_INC_USE_COUNT;
39296  }
39297  
39298  static void litelink_close(dongle_t *self)
39299  {
39300         /* Power off dongle */
39301         self->set_dtr_rts(self->dev, FALSE, FALSE);
39302 -
39303 -       MOD_DEC_USE_COUNT;
39304  }
39305  
39306  /*
39307 --- linux-2.6.0-test6/drivers/net/irda/ma600.c  2003-09-08 13:58:57.000000000 -0700
39308 +++ 25/drivers/net/irda/ma600.c 2003-10-05 00:33:24.000000000 -0700
39309 @@ -74,12 +74,12 @@ static int  ma600_reset(struct irda_task
39310  #define MA600_2400     0x08
39311  
39312  static struct dongle_reg dongle = {
39313 -       Q_NULL,
39314 -       IRDA_MA600_DONGLE,
39315 -       ma600_open,
39316 -       ma600_close,
39317 -       ma600_reset,
39318 -       ma600_change_speed,
39319 +       .type = IRDA_MA600_DONGLE,
39320 +       .open = ma600_open,
39321 +       .close = ma600_close,
39322 +       .reset = ma600_reset,
39323 +       .change_speed = ma600_change_speed,
39324 +       .owner = THIS_MODULE,
39325  };
39326  
39327  int __init ma600_init(void)
39328 @@ -115,8 +115,6 @@ static void ma600_open(dongle_t *self, s
39329  
39330         self->set_dtr_rts(self->dev, TRUE, TRUE);
39331         // should wait 1 second
39332 -
39333 -       MOD_INC_USE_COUNT;
39334  }
39335  
39336  static void ma600_close(dongle_t *self)
39337 @@ -125,8 +123,6 @@ static void ma600_close(dongle_t *self)
39338  
39339         /* Power off dongle */
39340         self->set_dtr_rts(self->dev, FALSE, FALSE);
39341 -
39342 -       MOD_DEC_USE_COUNT;
39343  }
39344  
39345  static __u8 get_control_byte(__u32 speed)
39346 --- linux-2.6.0-test6/drivers/net/irda/mcp2120.c        2003-09-08 13:58:57.000000000 -0700
39347 +++ 25/drivers/net/irda/mcp2120.c       2003-10-05 00:33:24.000000000 -0700
39348 @@ -40,12 +40,12 @@ static int  mcp2120_change_speed(struct 
39349  #define MCP2120_COMMIT  0x11
39350  
39351  static struct dongle_reg dongle = {
39352 -       Q_NULL,
39353 -       IRDA_MCP2120_DONGLE,
39354 -       mcp2120_open,
39355 -       mcp2120_close,
39356 -       mcp2120_reset,
39357 -       mcp2120_change_speed,
39358 +       .type = IRDA_MCP2120_DONGLE,
39359 +       .open = mcp2120_open,
39360 +       .close = mcp2120_close,
39361 +       .reset = mcp2120_reset,
39362 +       .change_speed = mcp2120_change_speed,
39363 +       .owner = THIS_MODULE,
39364  };
39365  
39366  int __init mcp2120_init(void)
39367 @@ -62,8 +62,6 @@ static void mcp2120_open(dongle_t *self,
39368  {
39369         qos->baud_rate.bits &= IR_9600|IR_19200|IR_38400|IR_57600|IR_115200;
39370         qos->min_turn_time.bits = 0x01;
39371 -
39372 -       MOD_INC_USE_COUNT;
39373  }
39374  
39375  static void mcp2120_close(dongle_t *self)
39376 @@ -72,8 +70,6 @@ static void mcp2120_close(dongle_t *self
39377          /* reset and inhibit mcp2120 */
39378         self->set_dtr_rts(self->dev, TRUE, TRUE);
39379         //self->set_dtr_rts(self->dev, FALSE, FALSE);
39380 -
39381 -       MOD_DEC_USE_COUNT;
39382  }
39383  
39384  /*
39385 --- linux-2.6.0-test6/drivers/net/irda/nsc-ircc.c       2003-09-27 18:57:45.000000000 -0700
39386 +++ 25/drivers/net/irda/nsc-ircc.c      2003-10-05 00:33:24.000000000 -0700
39387 @@ -260,8 +260,7 @@ static int __init nsc_ircc_open(int i, c
39388  
39389         MESSAGE("%s, driver loaded (Dag Brattli)\n", driver_name);
39390  
39391 -       dev = alloc_netdev(sizeof(struct nsc_ircc_cb), "irda%d",
39392 -                          irda_device_setup);
39393 +       dev = alloc_irdadev(sizeof(struct nsc_ircc_cb));
39394         if (dev == NULL) {
39395                 ERROR("%s(), can't allocate memory for "
39396                        "control block!\n", __FUNCTION__);
39397 --- linux-2.6.0-test6/drivers/net/irda/old_belkin.c     2003-09-08 13:58:57.000000000 -0700
39398 +++ 25/drivers/net/irda/old_belkin.c    2003-10-05 00:33:24.000000000 -0700
39399 @@ -74,12 +74,12 @@ static int  old_belkin_reset(struct irda
39400  /* static __u32 baud_rates[] = { 9600 }; */
39401  
39402  static struct dongle_reg dongle = {
39403 -       Q_NULL,
39404 -       IRDA_OLD_BELKIN_DONGLE,
39405 -       old_belkin_open,
39406 -       old_belkin_close,
39407 -       old_belkin_reset,
39408 -       old_belkin_change_speed,
39409 +       .type = IRDA_OLD_BELKIN_DONGLE,
39410 +       .open = old_belkin_open,
39411 +       .close = old_belkin_close,
39412 +       .reset = old_belkin_reset,
39413 +       .change_speed = old_belkin_change_speed,
39414 +       .owner = THIS_MODULE,
39415  };
39416  
39417  int __init old_belkin_init(void)
39418 @@ -98,16 +98,12 @@ static void old_belkin_open(dongle_t *se
39419         qos->baud_rate.bits &= IR_9600;
39420         /* Needs at least 10 ms (totally wild guess, can do probably better) */
39421         qos->min_turn_time.bits = 0x01;
39422 -
39423 -       MOD_INC_USE_COUNT;
39424  }
39425  
39426  static void old_belkin_close(dongle_t *self)
39427  {
39428         /* Power off dongle */
39429         self->set_dtr_rts(self->dev, FALSE, FALSE);
39430 -
39431 -       MOD_DEC_USE_COUNT;
39432  }
39433  
39434  /*
39435 --- linux-2.6.0-test6/drivers/net/irda/sir_dev.c        2003-07-10 18:50:31.000000000 -0700
39436 +++ 25/drivers/net/irda/sir_dev.c       2003-10-05 00:33:24.000000000 -0700
39437 @@ -538,28 +538,6 @@ out:
39438  
39439  /* ----------------------------------------------------------------------------- */
39440  
39441 -static int sirdev_init(struct net_device *ndev)
39442 -{
39443 -       struct sir_dev *dev = ndev->priv;
39444 -
39445 -       SET_MODULE_OWNER(ndev);
39446 -
39447 -       /* Set up to be a normal IrDA network device driver */
39448 -       irda_device_setup(ndev);
39449 -
39450 -       dev->flags = IFF_SIR | IFF_PIO;
39451 -
39452 -       /* Override the network functions we need to use */
39453 -       ndev->hard_start_xmit = sirdev_hard_xmit;
39454 -       ndev->open = sirdev_open;
39455 -       ndev->stop = sirdev_close;
39456 -       ndev->get_stats = sirdev_get_stats;
39457 -       ndev->do_ioctl = sirdev_ioctl;
39458 -
39459 -       return 0;
39460 -}
39461 -
39462 -
39463  struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *name)
39464  {
39465         struct net_device *ndev;
39466 @@ -577,12 +555,12 @@ struct sir_dev * sirdev_get_instance(con
39467         /*
39468          *  Allocate new instance of the device
39469          */
39470 -       dev = kmalloc(sizeof(*dev), GFP_KERNEL);
39471 -       if (dev == NULL) {
39472 +       ndev = alloc_irdadev(sizeof(*dev));
39473 +       if (ndev == NULL) {
39474                 ERROR("%s - Can't allocate memory for IrDA control block!\n", __FUNCTION__);
39475                 goto out;
39476         }
39477 -       memset(dev, 0, sizeof(*dev));
39478 +       dev = ndev->priv;
39479  
39480         irda_init_max_qos_capabilies(&dev->qos);
39481         dev->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|IR_115200;
39482 @@ -591,11 +569,6 @@ struct sir_dev * sirdev_get_instance(con
39483  
39484         strncpy(dev->hwname, name, sizeof(dev->hwname)-1);
39485  
39486 -       ndev = kmalloc(sizeof(*ndev), GFP_KERNEL);
39487 -       if (ndev == NULL)
39488 -               goto out_freedev;
39489 -       memset(ndev, 0, sizeof(*ndev));
39490 -
39491         atomic_set(&dev->enable_rx, 0);
39492         dev->tx_skb = NULL;
39493  
39494 @@ -609,10 +582,17 @@ struct sir_dev * sirdev_get_instance(con
39495         dev->drv = drv;
39496         dev->netdev = ndev;
39497  
39498 -       ndev->priv = (void *) dev;
39499 -       ndev->init = sirdev_init;
39500 +       SET_MODULE_OWNER(ndev);
39501 +
39502 +       dev->flags = IFF_SIR | IFF_PIO;
39503 +
39504 +       /* Override the network functions we need to use */
39505 +       ndev->hard_start_xmit = sirdev_hard_xmit;
39506 +       ndev->open = sirdev_open;
39507 +       ndev->stop = sirdev_close;
39508 +       ndev->get_stats = sirdev_get_stats;
39509 +       ndev->do_ioctl = sirdev_ioctl;
39510  
39511 -       strcpy(ndev->name, "irda%d");
39512         if (register_netdev(ndev)) {
39513                 ERROR("%s(), register_netdev() failed!\n", __FUNCTION__);
39514                 goto out_freenetdev;
39515 @@ -621,9 +601,7 @@ struct sir_dev * sirdev_get_instance(con
39516         return dev;
39517  
39518  out_freenetdev:
39519 -       kfree(ndev);
39520 -out_freedev:
39521 -       kfree(dev);
39522 +       free_netdev(ndev);
39523  out:
39524         return NULL;
39525  }
39526 @@ -653,10 +631,9 @@ int sirdev_put_instance(struct sir_dev *
39527         up(&dev->fsm.sem);
39528  
39529         /* Remove netdevice */
39530 -       if (dev->netdev)
39531 -               unregister_netdev(dev->netdev);
39532 +       unregister_netdev(dev->netdev);
39533  
39534 -       kfree(dev);
39535 +       free_netdev(dev->netdev);
39536  
39537         return 0;
39538  }
39539 --- linux-2.6.0-test6/drivers/net/irda/smsc-ircc2.c     2003-06-14 12:18:24.000000000 -0700
39540 +++ 25/drivers/net/irda/smsc-ircc2.c    2003-10-05 00:33:24.000000000 -0700
39541 @@ -140,10 +140,8 @@ static const char *driver_name = "smsc-i
39542  
39543  static int smsc_ircc_open(unsigned int firbase, unsigned int sirbase, u8 dma, u8 irq);
39544  static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base);
39545 -static int smsc_ircc_setup_io(struct smsc_ircc_cb *self, unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq);
39546 -static int smsc_ircc_setup_buffers(struct smsc_ircc_cb *self);
39547 +static void smsc_ircc_setup_io(struct smsc_ircc_cb *self, unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq);
39548  static void smsc_ircc_setup_qos(struct smsc_ircc_cb *self);
39549 -static int smsc_ircc_setup_netdev(struct smsc_ircc_cb *self);
39550  static void smsc_ircc_init_chip(struct smsc_ircc_cb *self);
39551  static int __exit smsc_ircc_close(struct smsc_ircc_cb *self);
39552  static int  smsc_ircc_dma_receive(struct smsc_ircc_cb *self, int iobase); 
39553 @@ -163,7 +161,6 @@ static void smsc_ircc_sir_stop(struct sm
39554  #endif
39555  static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self);
39556  static int  smsc_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len);
39557 -static int  smsc_ircc_net_init(struct net_device *dev);
39558  static int  smsc_ircc_net_open(struct net_device *dev);
39559  static int  smsc_ircc_net_close(struct net_device *dev);
39560  static int  smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
39561 @@ -366,38 +363,81 @@ int __init smsc_ircc_init(void)
39562  static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq)
39563  {
39564         struct smsc_ircc_cb *self;
39565 +       struct net_device *dev;
39566         int err;
39567         
39568         IRDA_DEBUG(1, "%s\n", __FUNCTION__);
39569  
39570 -       err= smsc_ircc_present(fir_base, sir_base);
39571 -       if(err) return -ENODEV;
39572 +       err = smsc_ircc_present(fir_base, sir_base);
39573 +       if(err) 
39574 +               goto err_out;
39575                 
39576 -       if (dev_count>DIM(dev_self)) {
39577 +       err = -ENOMEM;
39578 +       if (dev_count > DIM(dev_self)) {
39579                 WARNING("%s(), too many devices!\n", __FUNCTION__);
39580 -               return -ENOMEM;
39581 +               goto err_out1;
39582         }
39583  
39584         /*
39585          *  Allocate new instance of the driver
39586          */
39587 -       self = kmalloc(sizeof(struct smsc_ircc_cb), GFP_KERNEL);
39588 -       if (self == NULL) {
39589 -               ERROR("%s, Can't allocate memory for control block!\n",
39590 -                      driver_name);
39591 -               return -ENOMEM;
39592 +       dev = alloc_irdadev(sizeof(struct smsc_ircc_cb));
39593 +       if (!dev) {
39594 +               WARNING("%s() can't allocate net device\n", __FUNCTION__);
39595 +               goto err_out1;
39596         }
39597 -       memset(self, 0, sizeof(struct smsc_ircc_cb));
39598 +
39599 +       SET_MODULE_OWNER(dev);
39600 +
39601 +       dev->hard_start_xmit = smsc_ircc_hard_xmit_sir;
39602 +#if SMSC_IRCC2_C_NET_TIMEOUT
39603 +       dev->tx_timeout      = smsc_ircc_timeout;
39604 +       dev->watchdog_timeo  = HZ*2;  /* Allow enough time for speed change */
39605 +#endif
39606 +       dev->open            = smsc_ircc_net_open;
39607 +       dev->stop            = smsc_ircc_net_close;
39608 +       dev->do_ioctl        = smsc_ircc_net_ioctl;
39609 +       dev->get_stats       = smsc_ircc_net_get_stats;
39610 +       
39611 +       self = dev->priv;
39612 +       self->netdev = dev;
39613 +
39614 +       /* Make ifconfig display some details */
39615 +       dev->base_addr = self->io.fir_base = fir_base;
39616 +       dev->irq = self->io.irq = irq;
39617  
39618         /* Need to store self somewhere */
39619         dev_self[dev_count++] = self;
39620         spin_lock_init(&self->lock);
39621  
39622 -       err = smsc_ircc_setup_buffers(self);
39623 -       if(err) return err;
39624 +       self->rx_buff.truesize = SMSC_IRCC2_RX_BUFF_TRUESIZE; 
39625 +       self->tx_buff.truesize = SMSC_IRCC2_TX_BUFF_TRUESIZE;
39626 +
39627 +       self->rx_buff.head = (u8 *) kmalloc(self->rx_buff.truesize,
39628 +                                             GFP_KERNEL|GFP_DMA);
39629 +       if (self->rx_buff.head == NULL) {
39630 +               ERROR("%s, Can't allocate memory for receive buffer!\n",
39631 +                      driver_name);
39632 +               goto err_out2;
39633 +       }
39634 +
39635 +       self->tx_buff.head = (u8 *) kmalloc(self->tx_buff.truesize, 
39636 +                                             GFP_KERNEL|GFP_DMA);
39637 +       if (self->tx_buff.head == NULL) {
39638 +               ERROR("%s, Can't allocate memory for transmit buffer!\n",
39639 +                      driver_name);
39640 +               goto err_out3;
39641 +       }
39642 +
39643 +       memset(self->rx_buff.head, 0, self->rx_buff.truesize);
39644 +       memset(self->tx_buff.head, 0, self->tx_buff.truesize);
39645 +
39646 +       self->rx_buff.in_frame = FALSE;
39647 +       self->rx_buff.state = OUTSIDE_FRAME;
39648 +       self->tx_buff.data = self->tx_buff.head;
39649 +       self->rx_buff.data = self->rx_buff.head;
39650            
39651 -       err= smsc_ircc_setup_io(self, fir_base, sir_base, dma, irq);
39652 -       if(err) return err;
39653 +       smsc_ircc_setup_io(self, fir_base, sir_base, dma, irq);
39654  
39655         smsc_ircc_setup_qos(self);
39656  
39657 @@ -405,17 +445,38 @@ static int __init smsc_ircc_open(unsigne
39658                 
39659         smsc_ircc_init_chip(self);
39660         
39661 -       if(ircc_transceiver > 0 && ircc_transceiver < SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS) self->transceiver = ircc_transceiver;
39662 -       else smsc_ircc_probe_transceiver(self);
39663 +       if(ircc_transceiver > 0  && 
39664 +          ircc_transceiver < SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS)
39665 +               self->transceiver = ircc_transceiver;
39666 +       else
39667 +               smsc_ircc_probe_transceiver(self);
39668  
39669 -       err = smsc_ircc_setup_netdev(self);
39670 -       if(err) return err;
39671 +       err = register_netdev(self->netdev);
39672 +       if(err) {
39673 +               ERROR("%s, Network device registration failed!\n",
39674 +                     driver_name);
39675 +               goto err_out4;
39676 +       }
39677  
39678         self->pmdev = pm_register(PM_SYS_DEV, PM_SYS_IRDA, smsc_ircc_pmproc);
39679         if (self->pmdev)
39680                 self->pmdev->data = self;
39681  
39682 +       MESSAGE("IrDA: Registered device %s\n", dev->name);
39683 +
39684         return 0;
39685 + err_out4:
39686 +       kfree(self->tx_buff.head);
39687 + err_out3:
39688 +       kfree(self->rx_buff.head);
39689 + err_out2:
39690 +       free_netdev(self->netdev);
39691 +       dev_self[--dev_count] = NULL;
39692 + err_out1:
39693 +       release_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT);
39694 +       release_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT);
39695 + err_out:
39696 +       return err;
39697  }
39698  
39699  /*
39700 @@ -428,18 +489,19 @@ static int smsc_ircc_present(unsigned in
39701  {
39702         unsigned char low, high, chip, config, dma, irq, version;
39703  
39704 -       if (check_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT) < 0) {
39705 +       if (!request_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT,
39706 +                           driver_name)) {
39707                 WARNING("%s: can't get fir_base of 0x%03x\n",
39708                         __FUNCTION__, fir_base);
39709 -               return -ENODEV;
39710 +               goto out1;
39711         }
39712 -#if POSSIBLE_USED_BY_SERIAL_DRIVER
39713 -       if (check_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT) < 0) {
39714 +
39715 +       if (!request_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT,
39716 +                           driver_name)) {
39717                 WARNING("%s: can't get sir_base of 0x%03x\n",
39718                         __FUNCTION__, sir_base);
39719 -               return -ENODEV;
39720 +               goto out2;
39721         }
39722 -#endif
39723  
39724         register_bank(fir_base, 3);
39725  
39726 @@ -454,54 +516,19 @@ static int smsc_ircc_present(unsigned in
39727         if (high != 0x10 || low != 0xb8 || (chip != 0xf1 && chip != 0xf2)) { 
39728                 WARNING("%s(), addr 0x%04x - no device found!\n",
39729                         __FUNCTION__, fir_base);
39730 -               return -ENODEV;
39731 +               goto out3;
39732         }
39733         MESSAGE("SMsC IrDA Controller found\n IrCC version %d.%d, "
39734                 "firport 0x%03x, sirport 0x%03x dma=%d, irq=%d\n",
39735                 chip & 0x0f, version, fir_base, sir_base, dma, irq);
39736  
39737         return 0;
39738 -}
39739 -
39740 -/*
39741 - * Function smsc_ircc_setup_buffers(self)
39742 - *
39743 - *    Setup RX/TX buffers
39744 - *
39745 - */
39746 -static int smsc_ircc_setup_buffers(struct smsc_ircc_cb *self)
39747 -{
39748 -       self->rx_buff.truesize = SMSC_IRCC2_RX_BUFF_TRUESIZE; 
39749 -       self->tx_buff.truesize = SMSC_IRCC2_TX_BUFF_TRUESIZE;
39750 -
39751 -       self->rx_buff.head = (u8 *) kmalloc(self->rx_buff.truesize,
39752 -                                             GFP_KERNEL|GFP_DMA);
39753 -       if (self->rx_buff.head == NULL) {
39754 -               ERROR("%s, Can't allocate memory for receive buffer!\n",
39755 -                      driver_name);
39756 -               kfree(self);
39757 -               return -ENOMEM;
39758 -       }
39759 -
39760 -       self->tx_buff.head = (u8 *) kmalloc(self->tx_buff.truesize, 
39761 -                                             GFP_KERNEL|GFP_DMA);
39762 -       if (self->tx_buff.head == NULL) {
39763 -               ERROR("%s, Can't allocate memory for transmit buffer!\n",
39764 -                      driver_name);
39765 -               kfree(self->rx_buff.head);
39766 -               kfree(self);
39767 -               return -ENOMEM;
39768 -       }
39769 -
39770 -       memset(self->rx_buff.head, 0, self->rx_buff.truesize);
39771 -       memset(self->tx_buff.head, 0, self->tx_buff.truesize);
39772 -
39773 -       self->rx_buff.in_frame = FALSE;
39774 -       self->rx_buff.state = OUTSIDE_FRAME;
39775 -       self->tx_buff.data = self->tx_buff.head;
39776 -       self->rx_buff.data = self->rx_buff.head;
39777 -
39778 -       return 0;
39779 + out3:
39780 +       release_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT);
39781 + out2:
39782 +       release_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT);
39783 + out1:
39784 +       return -ENODEV;
39785  }
39786  
39787  /*
39788 @@ -510,10 +537,11 @@ static int smsc_ircc_setup_buffers(struc
39789   *    Setup I/O
39790   *
39791   */
39792 -static int smsc_ircc_setup_io(struct smsc_ircc_cb *self, unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq)
39793 +static void smsc_ircc_setup_io(struct smsc_ircc_cb *self, 
39794 +                              unsigned int fir_base, unsigned int sir_base, 
39795 +                              u8 dma, u8 irq)
39796  {
39797         unsigned char config, chip_dma, chip_irq;
39798 -       void *ret;
39799  
39800         register_bank(fir_base, 3);
39801         config  = inb(fir_base+IRCC_INTERFACE);
39802 @@ -545,27 +573,6 @@ static int smsc_ircc_setup_io(struct sms
39803         else
39804                 self->io.dma = chip_dma;
39805  
39806 -       ret = request_region(self->io.fir_base, self->io.fir_ext, driver_name);
39807 -       if (!ret) { 
39808 -               WARNING("%s(), can't get iobase of 0x%03x\n",
39809 -                       __FUNCTION__, self->io.fir_base);
39810 -               kfree(self->tx_buff.head);
39811 -               kfree(self->rx_buff.head);
39812 -               kfree(self);
39813 -               return -ENODEV;
39814 -       }
39815 -       ret = request_region(self->io.sir_base, self->io.sir_ext, driver_name);
39816 -       if (!ret) { 
39817 -               WARNING("%s(), can't get iobase of 0x%03x\n",
39818 -                       __FUNCTION__, self->io.sir_base);
39819 -               release_region(self->io.fir_base, self->io.fir_ext);
39820 -               kfree(self->tx_buff.head);
39821 -               kfree(self->rx_buff.head);
39822 -               kfree(self);
39823 -               return -ENODEV;
39824 -       }
39825 -
39826 -       return 0;
39827  }
39828  
39829  /*
39830 @@ -635,59 +642,6 @@ static void smsc_ircc_init_chip(struct s
39831  }
39832  
39833  /*
39834 - * Function smsc_ircc_setup_netdev(self)
39835 - *
39836 - *    Alloc and setup network device
39837 - *
39838 - */
39839 -static int smsc_ircc_setup_netdev(struct smsc_ircc_cb *self)
39840 -{
39841 -       struct net_device *dev;
39842 -       int err;
39843 -       /* Alloc netdev */
39844 -
39845 -       if (!(dev = dev_alloc("irda%d", &err))) {
39846 -               ERROR("%s(), dev_alloc() failed!\n", __FUNCTION__);
39847 -               kfree(self->tx_buff.head);
39848 -               kfree(self->rx_buff.head);
39849 -               kfree(self);
39850 -               return -ENOMEM;
39851 -       }
39852 -
39853 -       dev->priv = (void *) self;
39854 -       self->netdev = dev;
39855 -
39856 -       dev->init            = smsc_ircc_net_init;
39857 -       dev->hard_start_xmit = smsc_ircc_hard_xmit_sir;
39858 -       #if SMSC_IRCC2_C_NET_TIMEOUT
39859 -       dev->tx_timeout      = smsc_ircc_timeout;
39860 -       dev->watchdog_timeo  = HZ*2;  /* Allow enough time for speed change */
39861 -       #endif
39862 -       dev->open            = smsc_ircc_net_open;
39863 -       dev->stop            = smsc_ircc_net_close;
39864 -       dev->do_ioctl        = smsc_ircc_net_ioctl;
39865 -       dev->get_stats       = smsc_ircc_net_get_stats;
39866 -       
39867 -       /* Make ifconfig display some details */
39868 -       dev->base_addr = self->io.fir_base;
39869 -       dev->irq = self->io.irq;
39870 -
39871 -       rtnl_lock();
39872 -       err = register_netdevice(dev);
39873 -       rtnl_unlock();
39874 -       if (err) {
39875 -               ERROR("%s(), register_netdev() failed!\n", __FUNCTION__);
39876 -               kfree(self->tx_buff.head);
39877 -               kfree(self->rx_buff.head);
39878 -               kfree(self);
39879 -               return -ENODEV;
39880 -       }
39881 -       MESSAGE("IrDA: Registered device %s\n", dev->name);
39882 -
39883 -       return 0;
39884 -}
39885 -
39886 -/*
39887   * Function smsc_ircc_net_ioctl (dev, rq, cmd)
39888   *
39889   *    Process IOCTL commands for this device
39890 @@ -1571,18 +1525,6 @@ static int ircc_is_receiving(struct smsc
39891  }
39892  #endif /* unused */
39893  
39894 -static int smsc_ircc_net_init(struct net_device *dev)
39895 -{
39896 -       /* Keep track of module usage */
39897 -       SET_MODULE_OWNER(dev);
39898 -
39899 -       /* Set up to be a normal IrDA network device driver */
39900 -       irda_device_setup(dev);
39901 -
39902 -       /* Insert overrides below this line! */
39903 -
39904 -       return 0;
39905 -}
39906  
39907  /*
39908   * Function smsc_ircc_net_open (dev)
39909 @@ -1745,11 +1687,7 @@ static int __exit smsc_ircc_close(struct
39910                 pm_unregister(self->pmdev);
39911  
39912         /* Remove netdevice */
39913 -       if (self->netdev) {
39914 -               rtnl_lock();
39915 -               unregister_netdevice(self->netdev);
39916 -               rtnl_unlock();
39917 -       }
39918 +       unregister_netdev(self->netdev);
39919  
39920         /* Make sure the irq handler is not exectuting */
39921         spin_lock_irqsave(&self->lock, flags);
39922 @@ -1784,7 +1722,7 @@ static int __exit smsc_ircc_close(struct
39923         if (self->rx_buff.head)
39924                 kfree(self->rx_buff.head);
39925  
39926 -       kfree(self);
39927 +       free_netdev(self->netdev);
39928  
39929         return 0;
39930  }
39931 @@ -2269,32 +2207,36 @@ static const smsc_chip_t * __init smsc_i
39932  
39933  static int __init smsc_superio_fdc(unsigned short cfg_base)
39934  {
39935 -       if (check_region(cfg_base, 2) < 0) {
39936 +       int ret = -1;
39937 +
39938 +       if (!request_region(cfg_base, 2, driver_name)) {
39939                 WARNING("%s: can't get cfg_base of 0x%03x\n",
39940                         __FUNCTION__, cfg_base);
39941 -               return -1;
39942 -       }
39943 +       } else {
39944 +               if (!smsc_superio_flat(fdc_chips_flat,cfg_base,"FDC")
39945 +                   ||!smsc_superio_paged(fdc_chips_paged,cfg_base,"FDC"))
39946 +                       ret =  0;
39947  
39948 -       if (!smsc_superio_flat(fdc_chips_flat,cfg_base,"FDC")||!smsc_superio_paged(fdc_chips_paged,cfg_base,"FDC"))
39949 -               return 0;
39950 +               release_region(cfg_base, 2);
39951 +       }
39952  
39953 -       return -1;
39954 +       return ret;
39955  }
39956  
39957  static int __init smsc_superio_lpc(unsigned short cfg_base)
39958  {
39959 -#if 0
39960 -       if (check_region(cfg_base, 2) < 0) {
39961 -               IRDA_DEBUG(0, __FUNCTION__ ": can't get cfg_base of 0x%03x\n",
39962 -                          cfg_base);
39963 -               return -1;
39964 -       }
39965 -#endif
39966 -
39967 -       if (!smsc_superio_flat(lpc_chips_flat,cfg_base,"LPC")||!smsc_superio_paged(lpc_chips_paged,cfg_base,"LPC"))
39968 -               return 0;
39969 +       int ret = -1;
39970  
39971 -       return -1;
39972 +       if (!request_region(cfg_base, 2, driver_name)) {
39973 +               WARNING("%s: can't get cfg_base of 0x%03x\n",
39974 +                       __FUNCTION__, cfg_base);
39975 +       } else {
39976 +               if (!smsc_superio_flat(lpc_chips_flat,cfg_base,"LPC")
39977 +                   ||!smsc_superio_paged(lpc_chips_paged,cfg_base,"LPC"))
39978 +                       ret = 0;
39979 +               release_region(cfg_base, 2);
39980 +       }
39981 +       return ret;
39982  }
39983  
39984  /************************************************
39985 --- linux-2.6.0-test6/drivers/net/irda/tekram.c 2003-09-08 13:58:57.000000000 -0700
39986 +++ 25/drivers/net/irda/tekram.c        2003-10-05 00:33:24.000000000 -0700
39987 @@ -44,12 +44,12 @@ static int  tekram_reset(struct irda_tas
39988  #define TEKRAM_PW     0x10 /* Pulse select bit */
39989  
39990  static struct dongle_reg dongle = {
39991 -       Q_NULL,
39992 -       IRDA_TEKRAM_DONGLE,
39993 -       tekram_open,
39994 -       tekram_close,
39995 -       tekram_reset,
39996 -       tekram_change_speed,
39997 +       .type = IRDA_TEKRAM_DONGLE,
39998 +       .open  = tekram_open,
39999 +       .close = tekram_close,
40000 +       .reset = tekram_reset,
40001 +       .change_speed = tekram_change_speed,
40002 +       .owner = THIS_MODULE,
40003  };
40004  
40005  int __init tekram_init(void)
40006 @@ -69,8 +69,6 @@ static void tekram_open(dongle_t *self, 
40007         qos->baud_rate.bits &= IR_9600|IR_19200|IR_38400|IR_57600|IR_115200;
40008         qos->min_turn_time.bits = 0x01; /* Needs at least 10 ms */      
40009         irda_qos_bits_to_value(qos);
40010 -
40011 -       MOD_INC_USE_COUNT;
40012  }
40013  
40014  static void tekram_close(dongle_t *self)
40015 @@ -84,8 +82,6 @@ static void tekram_close(dongle_t *self)
40016                 irda_task_delete(self->reset_task);
40017         if (self->speed_task)
40018                 irda_task_delete(self->speed_task);
40019 -
40020 -       MOD_DEC_USE_COUNT;
40021  }
40022  
40023  /*
40024 --- linux-2.6.0-test6/drivers/net/irda/via-ircc.c       2003-09-27 18:57:45.000000000 -0700
40025 +++ 25/drivers/net/irda/via-ircc.c      2003-10-05 00:33:24.000000000 -0700
40026 @@ -335,8 +335,7 @@ static __devinit int via_ircc_open(int i
40027                 return -1;
40028  
40029         /* Allocate new instance of the driver */
40030 -       dev = alloc_netdev(sizeof(struct via_ircc_cb), "irda%d",
40031 -                          irda_device_setup);
40032 +       dev = alloc_irdadev(sizeof(struct via_ircc_cb));
40033         if (dev == NULL) 
40034                 return -ENOMEM;
40035  
40036 --- linux-2.6.0-test6/drivers/net/irda/vlsi_ir.c        2003-09-08 13:58:57.000000000 -0700
40037 +++ 25/drivers/net/irda/vlsi_ir.c       2003-10-05 00:33:24.000000000 -0700
40038 @@ -1859,15 +1859,6 @@ static void __devexit vlsi_irda_remove(s
40039   * otherwise we might get cheated by pci-pm.
40040   */
40041  
40042 -static int vlsi_irda_save_state(struct pci_dev *pdev, u32 state)
40043 -{
40044 -       if (state < 1 || state > 3 ) {
40045 -               ERROR("%s - %s: invalid pm state request: %u\n",
40046 -                       __FUNCTION__, PCIDEV_NAME(pdev), state);
40047 -               return -1;
40048 -       }
40049 -       return 0;
40050 -}
40051  
40052  static int vlsi_irda_suspend(struct pci_dev *pdev, u32 state)
40053  {
40054 @@ -1970,7 +1961,6 @@ static struct pci_driver vlsi_irda_drive
40055         .probe          = vlsi_irda_probe,
40056         .remove         = __devexit_p(vlsi_irda_remove),
40057  #ifdef CONFIG_PM
40058 -       .save_state     = vlsi_irda_save_state,
40059         .suspend        = vlsi_irda_suspend,
40060         .resume         = vlsi_irda_resume,
40061  #endif
40062 --- linux-2.6.0-test6/drivers/net/irda/w83977af_ir.c    2003-09-27 18:57:45.000000000 -0700
40063 +++ 25/drivers/net/irda/w83977af_ir.c   2003-10-05 00:33:24.000000000 -0700
40064 @@ -170,8 +170,7 @@ int w83977af_open(int i, unsigned int io
40065         /*
40066          *  Allocate new instance of the driver
40067          */
40068 -       dev = alloc_netdev(sizeof(struct w83977af_ir), "irda%d",
40069 -                          irda_device_setup);
40070 +       dev = alloc_irdadev(sizeof(struct w83977af_ir));
40071         if (dev == NULL) {
40072                 printk( KERN_ERR "IrDA: Can't allocate memory for "
40073                         "IrDA control block!\n");
40074 --- linux-2.6.0-test6/drivers/net/Kconfig       2003-09-27 18:57:44.000000000 -0700
40075 +++ 25/drivers/net/Kconfig      2003-10-05 00:33:46.000000000 -0700
40076 @@ -8,32 +8,18 @@ config NETDEVICES
40077         bool "Network device support"
40078         ---help---
40079           You can say N here if you don't intend to connect your Linux box to
40080 -         any other computer at all or if all your connections will be over a
40081 -         telephone line with a modem either via UUCP (UUCP is a protocol to
40082 -         forward mail and news between unix hosts over telephone lines; read
40083 -         the UUCP-HOWTO, available from
40084 -         <http://www.tldp.org/docs.html#howto>) or dialing up a shell
40085 -         account or a BBS, even using term (term is a program which gives you
40086 -         almost full Internet connectivity if you have a regular dial up
40087 -         shell account on some Internet connected Unix computer. Read
40088 -         <http://www.bart.nl/~patrickr/term-howto/Term-HOWTO.html>).
40089 +         any other computer at all.
40090  
40091           You'll have to say Y if your computer contains a network card that
40092 -         you want to use under Linux (make sure you know its name because you
40093 -         will be asked for it and read the Ethernet-HOWTO (especially if you
40094 -         plan to use more than one network card under Linux)) or if you want
40095 -         to use SLIP (Serial Line Internet Protocol is the protocol used to
40096 -         send Internet traffic over telephone lines or null modem cables) or
40097 -         CSLIP (compressed SLIP) or PPP (Point to Point Protocol, a better
40098 -         and newer replacement for SLIP) or PLIP (Parallel Line Internet
40099 -         Protocol is mainly used to create a mini network by connecting the
40100 -         parallel ports of two local machines) or AX.25/KISS (protocol for
40101 -         sending Internet traffic over amateur radio links).
40102 -
40103 -         Make sure to read the NET-3-HOWTO. Eventually, you will have to read
40104 -         Olaf Kirch's excellent and free book "Network Administrator's
40105 -         Guide", to be found in <http://www.tldp.org/docs.html#guide>. If
40106 -         unsure, say Y.
40107 +         you want to use under Linux. If you are going to run SLIP or PPP over
40108 +         telephone line or null modem cable you need say Y here. Connecting
40109 +         two machines with parallel ports using PLIP needs this, as well as
40110 +         AX.25/KISS for sending Internet traffic over amateur radio links.
40111 +
40112 +         See also "The Linux Network Administrator's Guide" by Olaf Kirch and
40113 +         Terry Dawson. Available at <http://www.tldp.org/guides.html>.
40114 +
40115 +         If unsure, say Y.
40116  
40117  if NETDEVICES
40118         source "drivers/net/arcnet/Kconfig"
40119 @@ -332,7 +318,7 @@ config MAC8390
40120  
40121  config MAC89x0
40122         tristate "Macintosh CS89x0 based ethernet cards"
40123 -       depends on NETDEVICES && MAC
40124 +       depends on NETDEVICES && MAC && BROKEN
40125         ---help---
40126           Support for CS89x0 chipset based Ethernet cards.  If you have a
40127           Nubus or LC-PDS network (Ethernet) card of this type, say Y and
40128 @@ -405,7 +391,7 @@ config ATARILANCE
40129  
40130  config ATARI_BIONET
40131         tristate "BioNet-100 support"
40132 -       depends on NETDEVICES && ATARI && ATARI_ACSI!=n
40133 +       depends on NETDEVICES && ATARI && ATARI_ACSI!=n && BROKEN
40134         help
40135           Say Y to include support for BioData's BioNet-100 Ethernet adapter
40136           for the ACSI port. The driver works (has to work...) with a polled
40137 @@ -413,7 +399,7 @@ config ATARI_BIONET
40138  
40139  config ATARI_PAMSNET
40140         tristate "PAMsNet support"
40141 -       depends on NETDEVICES && ATARI && ATARI_ACSI!=n
40142 +       depends on NETDEVICES && ATARI && ATARI_ACSI!=n && BROKEN
40143         help
40144           Say Y to include support for the PAMsNet Ethernet adapter for the
40145           ACSI port ("ACSI node"). The driver works (has to work...) with a
40146 @@ -808,7 +794,7 @@ config ULTRA32
40147  
40148  config SMC9194
40149         tristate "SMC 9194 support"
40150 -       depends on NET_VENDOR_SMC && (ISA || MAC)
40151 +       depends on NET_VENDOR_SMC && (ISA || MAC && BROKEN)
40152         select CRC32
40153         ---help---
40154           This is support for the SMC9xxx based Ethernet cards. Choose this
40155 @@ -2455,6 +2441,9 @@ config SHAPER
40156           To compile this driver as a module, choose M here: the module
40157           will be called shaper.  If unsure, say N.
40158  
40159 +config NET_POLL_CONTROLLER
40160 +       def_bool KGDB
40161 +
40162  source "drivers/net/wan/Kconfig"
40163  
40164  source "drivers/net/pcmcia/Kconfig"
40165 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
40166 +++ 25/drivers/net/kgdb_eth.c   2003-10-05 00:33:51.000000000 -0700
40167 @@ -0,0 +1,517 @@
40168 +/*
40169 + * Network interface GDB stub
40170 + *
40171 + * Written by San Mehat (nettwerk@biodome.org)
40172 + * Based upon 'gdbserial' by David Grothe (dave@gcom.com)
40173 + * and Scott Foehner (sfoehner@engr.sgi.com)
40174 + *
40175 + * Twiddled for 2.6 by Robert Walsh <rjwalsh@durables.org>
40176 + * and wangdi <wangdi@clusterfs.com>.
40177 + */
40178 +
40179 +#include <linux/module.h>
40180 +#include <linux/errno.h>
40181 +#include <linux/signal.h>
40182 +#include <linux/sched.h>
40183 +#include <linux/timer.h>
40184 +#include <linux/interrupt.h>
40185 +#include <linux/config.h>
40186 +#include <linux/major.h>
40187 +#include <linux/string.h>
40188 +#include <linux/fcntl.h>
40189 +#include <linux/termios.h>
40190 +#include <asm/kgdb.h>
40191 +#include <linux/if_ether.h>
40192 +#include <linux/netdevice.h>
40193 +#include <linux/etherdevice.h>
40194 +#include <linux/skbuff.h>
40195 +#include <linux/delay.h>
40196 +#include <net/tcp.h>
40197 +#include <net/udp.h>
40198 +
40199 +#include <asm/system.h>
40200 +#include <asm/io.h>
40201 +#include <asm/segment.h>
40202 +#include <asm/bitops.h>
40203 +#include <asm/system.h>
40204 +#include <asm/irq.h>
40205 +#include <asm/atomic.h>
40206 +
40207 +#define        GDB_BUF_SIZE    512             /* power of 2, please */
40208 +
40209 +static char    kgdb_buf[GDB_BUF_SIZE] ;
40210 +static int     kgdb_buf_in_inx ;
40211 +static atomic_t        kgdb_buf_in_cnt ;
40212 +static int     kgdb_buf_out_inx ;
40213 +
40214 +extern void    set_debug_traps(void) ;         /* GDB routine */
40215 +extern void    breakpoint(void);
40216 +
40217 +unsigned int   kgdb_remoteip = 0;
40218 +unsigned short kgdb_listenport = 6443;
40219 +unsigned short kgdb_sendport= 6442;
40220 +int            kgdb_eth = -1; /* Default tty mode */
40221 +unsigned char  kgdb_remotemac[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
40222 +unsigned char  kgdb_localmac[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
40223 +volatile int   kgdb_eth_is_initializing = 0;
40224 +int            kgdb_eth_need_breakpoint[NR_CPUS];
40225 +
40226 +struct net_device *kgdb_netdevice = NULL;
40227 +
40228 +/*
40229 + * Get a char if available, return -1 if nothing available.
40230 + * Empty the receive buffer first, then look at the interface hardware.
40231 + */
40232 +static int
40233 +read_char(void)
40234 +{
40235 +       /* intr routine has queued chars */
40236 +       if (atomic_read(&kgdb_buf_in_cnt) != 0)
40237 +       {
40238 +               int chr;
40239 +
40240 +               chr = kgdb_buf[kgdb_buf_out_inx++] ;
40241 +               kgdb_buf_out_inx &= (GDB_BUF_SIZE - 1) ;
40242 +               atomic_dec(&kgdb_buf_in_cnt) ;
40243 +               return chr;
40244 +       }
40245 +
40246 +       return -1; /* no data */
40247 +}
40248 +
40249 +/*
40250 + * Wait until the interface can accept a char, then write it.
40251 + */
40252 +static void
40253 +write_buffer(char *buf, int len)
40254 +{
40255 +       int                     total_len, eth_len, ip_len, udp_len;
40256 +       struct in_device        *in_dev;
40257 +       struct sk_buff          *skb;
40258 +       struct udphdr           *udph;
40259 +       struct iphdr            *iph;
40260 +       struct ethhdr           *eth;
40261 +
40262 +       if (!(in_dev = (struct in_device *) kgdb_netdevice->ip_ptr)) {
40263 +               panic("No in_device available for interface!\n");
40264 +       }
40265 +
40266 +       if (!(in_dev->ifa_list)) {
40267 +               panic("No interface address set for interface!\n");
40268 +       }
40269 +
40270 +       udp_len = len + sizeof(struct udphdr);
40271 +       ip_len = eth_len = udp_len + sizeof(struct iphdr);
40272 +       total_len = eth_len + ETH_HLEN;
40273 +
40274 +       if (!(skb = alloc_skb(total_len, GFP_ATOMIC))) {
40275 +               return;
40276 +       }
40277 +
40278 +       atomic_set(&skb->users, 1);
40279 +       skb_reserve(skb, total_len - len);
40280 +
40281 +       memcpy(skb->data, (unsigned char *) buf, len);
40282 +       skb->len += len;
40283 +
40284 +       udph = (struct udphdr *) skb_push(skb, sizeof(*udph));
40285 +       udph->source = htons(kgdb_listenport);
40286 +       udph->dest   = htons(kgdb_sendport);
40287 +       udph->len    = htons(udp_len);
40288 +       udph->check  = 0;
40289 +
40290 +       iph = (struct iphdr *)skb_push(skb, sizeof(*iph));
40291 +       iph->version  = 4;
40292 +       iph->ihl      = 5;
40293 +       iph->tos      = 0;
40294 +       iph->tot_len  = htons(ip_len);
40295 +       iph->id       = 0;
40296 +       iph->frag_off = 0;
40297 +       iph->ttl      = 64;
40298 +       iph->protocol = IPPROTO_UDP;
40299 +       iph->check    = 0;
40300 +       iph->saddr    = in_dev->ifa_list->ifa_address;
40301 +       iph->daddr    = kgdb_remoteip;
40302 +       iph->check    = ip_fast_csum((unsigned char *)iph, iph->ihl);
40303 +
40304 +       eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
40305 +       eth->h_proto = htons(ETH_P_IP);
40306 +       memcpy(eth->h_source, kgdb_localmac, kgdb_netdevice->addr_len);
40307 +       memcpy(eth->h_dest, kgdb_remotemac, kgdb_netdevice->addr_len);
40308 +
40309 +repeat:
40310 +       spin_lock(&kgdb_netdevice->xmit_lock);
40311 +       kgdb_netdevice->xmit_lock_owner = smp_processor_id();
40312 +
40313 +       if (netif_queue_stopped(kgdb_netdevice)) {
40314 +               kgdb_netdevice->xmit_lock_owner = -1;
40315 +               spin_unlock(&kgdb_netdevice->xmit_lock);
40316 +
40317 +               kgdb_netdevice->poll_controller(kgdb_netdevice);
40318 +               goto repeat;
40319 +       }
40320 +
40321 +       kgdb_netdevice->hard_start_xmit(skb, kgdb_netdevice);
40322 +       kgdb_netdevice->xmit_lock_owner = -1;
40323 +       spin_unlock(&kgdb_netdevice->xmit_lock);
40324 +}
40325 +
40326 +/*
40327 + * In the interrupt state the target machine will not respond to any
40328 + * arp requests, so handle them here.
40329 + */
40330 +
40331 +static struct sk_buff *send_skb = NULL;
40332 +
40333 +void
40334 +kgdb_eth_reply_arp(void)
40335 +{
40336 +       if (send_skb) {
40337 +               spin_lock(&kgdb_netdevice->xmit_lock);
40338 +               kgdb_netdevice->xmit_lock_owner = smp_processor_id();
40339 +               kgdb_netdevice->hard_start_xmit(send_skb, kgdb_netdevice);
40340 +               kgdb_netdevice->xmit_lock_owner = -1;
40341 +               spin_unlock(&kgdb_netdevice->xmit_lock);
40342 +               send_skb = NULL;
40343 +       }
40344 +}
40345 +
40346 +static int
40347 +make_arp_request(struct sk_buff *skb)
40348 +{
40349 +       struct arphdr *arp;
40350 +       unsigned char *arp_ptr;
40351 +       int type = ARPOP_REPLY;
40352 +       int ptype = ETH_P_ARP;
40353 +       u32 sip, tip;
40354 +       unsigned char *sha, *tha;
40355 +       struct in_device *in_dev = (struct in_device *) kgdb_netdevice->ip_ptr;
40356 +
40357 +       /* No arp on this interface */
40358 +
40359 +       if (kgdb_netdevice->flags & IFF_NOARP) {
40360 +               return 0;
40361 +       }
40362 +
40363 +       if (!pskb_may_pull(skb, (sizeof(struct arphdr) +
40364 +                                (2 * kgdb_netdevice->addr_len) +
40365 +                                (2 * sizeof(u32))))) {
40366 +               return 0;
40367 +       }
40368 +
40369 +       skb->h.raw = skb->nh.raw = skb->data;
40370 +       arp = skb->nh.arph;
40371 +
40372 +       if ((arp->ar_hrd != htons(ARPHRD_ETHER) &&
40373 +            arp->ar_hrd != htons(ARPHRD_IEEE802)) ||
40374 +           arp->ar_pro != htons(ETH_P_IP)) {
40375 +               return 0;
40376 +       }
40377 +
40378 +       /* Understand only these message types */
40379 +
40380 +       if (arp->ar_op != htons(ARPOP_REQUEST)) {
40381 +               return 0;
40382 +       }
40383 +
40384 +       /* Extract fields */
40385 +
40386 +       arp_ptr= (unsigned char *)(arp+1);
40387 +       sha = arp_ptr;
40388 +       arp_ptr += kgdb_netdevice->addr_len;
40389 +       memcpy(&sip, arp_ptr, 4);
40390 +       arp_ptr += 4;
40391 +       tha = arp_ptr;
40392 +       arp_ptr += kgdb_netdevice->addr_len;
40393 +       memcpy(&tip, arp_ptr, 4);
40394 +
40395 +       if (tip != in_dev->ifa_list->ifa_address) {
40396 +               return 0;
40397 +       }
40398 +
40399 +       if (kgdb_remoteip != sip) {
40400 +               return 0;
40401 +       }
40402 +
40403 +       /*
40404 +        * Check for bad requests for 127.x.x.x and requests for multicast
40405 +        * addresses.  If this is one such, delete it.
40406 +        */
40407 +
40408 +       if (LOOPBACK(tip) || MULTICAST(tip)) {
40409 +               return 0;
40410 +       }
40411 +
40412 +       /* reply to the ARP request */
40413 +
40414 +       send_skb = alloc_skb(sizeof(struct arphdr) + 2 * (kgdb_netdevice->addr_len + 4) + LL_RESERVED_SPACE(kgdb_netdevice), GFP_ATOMIC);
40415 +
40416 +       if (send_skb == NULL) {
40417 +               return 0;
40418 +       }
40419 +
40420 +       skb_reserve(send_skb, LL_RESERVED_SPACE(kgdb_netdevice));
40421 +       send_skb->nh.raw = send_skb->data;
40422 +       arp = (struct arphdr *) skb_put(send_skb, sizeof(struct arphdr) + 2 * (kgdb_netdevice->addr_len + 4));
40423 +       send_skb->dev = kgdb_netdevice;
40424 +       send_skb->protocol = htons(ETH_P_ARP);
40425 +
40426 +       /* Fill the device header for the ARP frame */
40427 +
40428 +       if (kgdb_netdevice->hard_header &&
40429 +           kgdb_netdevice->hard_header(send_skb, kgdb_netdevice, ptype,
40430 +                                      kgdb_remotemac, kgdb_localmac,
40431 +                                      send_skb->len) < 0) {
40432 +               kfree_skb(send_skb);
40433 +               return 0;
40434 +       }
40435 +
40436 +       /*
40437 +        * Fill out the arp protocol part.
40438 +        *
40439 +        * we only support ethernet device type,
40440 +        * which (according to RFC 1390) should always equal 1 (Ethernet).
40441 +        */
40442 +
40443 +       arp->ar_hrd = htons(kgdb_netdevice->type);
40444 +       arp->ar_pro = htons(ETH_P_IP);
40445 +
40446 +       arp->ar_hln = kgdb_netdevice->addr_len;
40447 +       arp->ar_pln = 4;
40448 +       arp->ar_op = htons(type);
40449 +
40450 +       arp_ptr=(unsigned char *)(arp + 1);
40451 +
40452 +       memcpy(arp_ptr, kgdb_netdevice->dev_addr, kgdb_netdevice->addr_len);
40453 +       arp_ptr += kgdb_netdevice->addr_len;
40454 +       memcpy(arp_ptr, &tip, 4);
40455 +       arp_ptr += 4;
40456 +       memcpy(arp_ptr, kgdb_localmac, kgdb_netdevice->addr_len);
40457 +       arp_ptr += kgdb_netdevice->addr_len;
40458 +       memcpy(arp_ptr, &sip, 4);
40459 +       return 0;
40460 +}
40461 +
40462 +
40463 +/*
40464 + * Accept an skbuff from net_device layer and add the payload onto
40465 + * kgdb buffer
40466 + *
40467 + * When the kgdb stub routine getDebugChar() is called it draws characters
40468 + * out of the buffer until it is empty and then reads directly from the
40469 + * serial port.
40470 + *
40471 + * We do not attempt to write chars from the interrupt routine since
40472 + * the stubs do all of that via putDebugChar() which writes one byte
40473 + * after waiting for the interface to become ready.
40474 + *
40475 + * The debug stubs like to run with interrupts disabled since, after all,
40476 + * they run as a consequence of a breakpoint in the kernel.
40477 + *
40478 + * NOTE: Return value of 1 means it was for us and is an indication to
40479 + * the calling driver to destroy the sk_buff and not send it up the stack.
40480 + */
40481 +int
40482 +kgdb_net_interrupt(struct sk_buff *skb)
40483 +{
40484 +       unsigned char   chr;
40485 +       struct iphdr    *iph = (struct iphdr*)skb->data;
40486 +       struct udphdr   *udph= (struct udphdr*)(skb->data+(iph->ihl<<2));
40487 +       unsigned char   *data = (unsigned char *) udph + sizeof(struct udphdr);
40488 +       int             len;
40489 +       int             i;
40490 +
40491 +       if ((kgdb_eth != -1) && (!kgdb_netdevice) &&
40492 +           (iph->protocol == IPPROTO_UDP) &&
40493 +           (be16_to_cpu(udph->dest) == kgdb_listenport)) {
40494 +               kgdb_sendport = be16_to_cpu(udph->source);
40495 +
40496 +               while (kgdb_eth_is_initializing)
40497 +                       ;
40498 +               if (!kgdb_netdevice)
40499 +                       kgdb_eth_hook();
40500 +               if (!kgdb_netdevice) {
40501 +                       /* Lets not even try again. */
40502 +                       kgdb_eth = -1;
40503 +                       return 0;
40504 +               }
40505 +       }
40506 +       if (!kgdb_netdevice) {
40507 +               return 0;
40508 +       }
40509 +       if (skb->protocol == __constant_htons(ETH_P_ARP) && !send_skb) {
40510 +               make_arp_request(skb);
40511 +               return 0;
40512 +       }
40513 +       if (iph->protocol != IPPROTO_UDP) {
40514 +               return 0;
40515 +       }
40516 +
40517 +       if (be16_to_cpu(udph->dest) != kgdb_listenport) {
40518 +               return 0;
40519 +       }
40520 +
40521 +       len = (be16_to_cpu(iph->tot_len) -
40522 +              (sizeof(struct udphdr) + sizeof(struct iphdr)));
40523 +
40524 +       for (i = 0; i < len; i++) {
40525 +               chr = data[i];
40526 +               if (chr == 3) {
40527 +                       kgdb_eth_need_breakpoint[smp_processor_id()] = 1;
40528 +                       continue;
40529 +               }
40530 +               if (atomic_read(&kgdb_buf_in_cnt) >= GDB_BUF_SIZE) {
40531 +                       /* buffer overflow, clear it */
40532 +                       kgdb_buf_in_inx = 0;
40533 +                       atomic_set(&kgdb_buf_in_cnt, 0);
40534 +                       kgdb_buf_out_inx = 0;
40535 +                       break;
40536 +               }
40537 +               kgdb_buf[kgdb_buf_in_inx++] = chr;
40538 +               kgdb_buf_in_inx &= (GDB_BUF_SIZE - 1);
40539 +               atomic_inc(&kgdb_buf_in_cnt);
40540 +       }
40541 +
40542 +       if (!kgdb_netdevice->kgdb_is_trapped) {
40543 +               /*
40544 +                * If a new gdb instance is trying to attach, we need to
40545 +                * break here.
40546 +                */
40547 +               if (!strncmp(data, "$Hc-1#09", 8))
40548 +                       kgdb_eth_need_breakpoint[smp_processor_id()] = 1;
40549 +       }
40550 +       return 1;
40551 +}
40552 +EXPORT_SYMBOL(kgdb_net_interrupt);
40553 +
40554 +int
40555 +kgdb_eth_hook(void)
40556 +{
40557 +       char kgdb_netdev[16];
40558 +       extern void kgdb_respond_ok(void);
40559 +
40560 +       if (kgdb_remotemac[0] == 0xff) {
40561 +               panic("ERROR! 'gdbeth_remotemac' option not set!\n");
40562 +       }
40563 +       if (kgdb_localmac[0] == 0xff) {
40564 +               panic("ERROR! 'gdbeth_localmac' option not set!\n");
40565 +       }
40566 +       if (kgdb_remoteip == 0) {
40567 +               panic("ERROR! 'gdbeth_remoteip' option not set!\n");
40568 +       }
40569 +
40570 +       sprintf(kgdb_netdev,"eth%d",kgdb_eth);
40571 +
40572 +#ifdef CONFIG_SMP
40573 +       if (num_online_cpus() > CONFIG_NO_KGDB_CPUS) {
40574 +               printk("kgdb: too manu cpus. Cannot enable debugger with more than %d cpus\n", CONFIG_NO_KGDB_CPUS);
40575 +               return -1;
40576 +       }
40577 +#endif
40578 +       for (kgdb_netdevice = dev_base;
40579 +               kgdb_netdevice != NULL;
40580 +               kgdb_netdevice = kgdb_netdevice->next) {
40581 +               if (strncmp(kgdb_netdevice->name, kgdb_netdev, IFNAMSIZ) == 0) {
40582 +                       break;
40583 +               }
40584 +       }
40585 +       if (!kgdb_netdevice) {
40586 +               printk("KGDB NET : Unable to find interface %s\n",kgdb_netdev);
40587 +               return -ENODEV;
40588 +       }
40589 +
40590 +       /*
40591 +        * Call GDB routine to setup the exception vectors for the debugger
40592 +        */
40593 +       set_debug_traps();
40594 +
40595 +       /*
40596 +        * Call the breakpoint() routine in GDB to start the debugging
40597 +        * session.
40598 +        */
40599 +       kgdb_eth_is_initializing = 1;
40600 +       kgdb_eth_need_breakpoint[smp_processor_id()] = 1;
40601 +       return 0;
40602 +}
40603 +
40604 +/*
40605 + * getDebugChar
40606 + *
40607 + * This is a GDB stub routine.  It waits for a character from the
40608 + * serial interface and then returns it.  If there is no serial
40609 + * interface connection then it returns a bogus value which will
40610 + * almost certainly cause the system to hang.
40611 + */
40612 +int
40613 +eth_getDebugChar(void)
40614 +{
40615 +       volatile int    chr;
40616 +
40617 +       while ((chr = read_char()) < 0) {
40618 +               if (send_skb) {
40619 +                       kgdb_eth_reply_arp();
40620 +               }
40621 +               if (kgdb_netdevice->poll_controller) {
40622 +                       kgdb_netdevice->poll_controller(kgdb_netdevice);
40623 +               } else {
40624 +                       printk("KGDB NET: Error - Device %s is not supported!\n", kgdb_netdevice->name);
40625 +                       panic("Please add support for kgdb net to this driver");
40626 +               }
40627 +       }
40628 +       return chr;
40629 +}
40630 +
40631 +#define ETH_QUEUE_SIZE 256
40632 +static char eth_queue[ETH_QUEUE_SIZE];
40633 +static int outgoing_queue;
40634 +
40635 +void
40636 +eth_flushDebugChar(void)
40637 +{
40638 +       if(outgoing_queue) {
40639 +               write_buffer(eth_queue, outgoing_queue);
40640 +
40641 +               outgoing_queue = 0;
40642 +       }
40643 +}
40644 +
40645 +static void
40646 +put_char_on_queue(int chr)
40647 +{
40648 +       eth_queue[outgoing_queue++] = chr;
40649 +       if(outgoing_queue == ETH_QUEUE_SIZE)
40650 +       {
40651 +               eth_flushDebugChar();
40652 +       }
40653 +}
40654 +
40655 +/*
40656 + * eth_putDebugChar
40657 + *
40658 + * This is a GDB stub routine.  It waits until the interface is ready
40659 + * to transmit a char and then sends it.
40660 + */
40661 +void
40662 +eth_putDebugChar(int chr)
40663 +{
40664 +       put_char_on_queue(chr); /* this routine will wait */
40665 +}
40666 +
40667 +void
40668 +kgdb_eth_set_trapmode(int mode)
40669 +{
40670 +       if (!kgdb_netdevice) {
40671 +               return;
40672 +       }
40673 +       kgdb_netdevice->kgdb_is_trapped = mode;
40674 +}
40675 +
40676 +int
40677 +kgdb_eth_is_trapped()
40678 +{
40679 +       if (!kgdb_netdevice) {
40680 +               return 0;
40681 +       }
40682 +       return kgdb_netdevice->kgdb_is_trapped;
40683 +}
40684 +EXPORT_SYMBOL(kgdb_eth_is_trapped);
40685 --- linux-2.6.0-test6/drivers/net/loopback.c    2003-09-08 13:58:57.000000000 -0700
40686 +++ 25/drivers/net/loopback.c   2003-10-05 00:33:24.000000000 -0700
40687 @@ -30,6 +30,7 @@
40688   */
40689  #include <linux/kernel.h>
40690  #include <linux/jiffies.h>
40691 +#include <linux/module.h>
40692  #include <linux/interrupt.h>
40693  #include <linux/fs.h>
40694  #include <linux/types.h>
40695 @@ -202,3 +203,5 @@ int __init loopback_init(void)
40696         
40697         return register_netdev(&loopback_dev);
40698  };
40699 +
40700 +EXPORT_SYMBOL(loopback_dev);
40701 --- linux-2.6.0-test6/drivers/net/mac8390.c     2003-07-27 12:14:39.000000000 -0700
40702 +++ 25/drivers/net/mac8390.c    2003-10-05 00:33:24.000000000 -0700
40703 @@ -442,14 +442,14 @@ int __init mac8390_initdev(struct net_de
40704                 ei_status.tx_start_page = CABLETRON_TX_START_PG;
40705                 ei_status.rx_start_page = CABLETRON_RX_START_PG;
40706                 ei_status.stop_page = CABLETRON_RX_STOP_PG;
40707 -               dev->rmem_start = dev->mem_start;
40708 -               dev->rmem_end = dev->mem_start + CABLETRON_RX_STOP_PG*256;
40709 +               ei_status.rmem_start = dev->mem_start;
40710 +               ei_status.rmem_end = dev->mem_start + CABLETRON_RX_STOP_PG*256;
40711         } else {
40712                 ei_status.tx_start_page = WD_START_PG;
40713                 ei_status.rx_start_page = WD_START_PG + TX_PAGES;
40714                 ei_status.stop_page = (dev->mem_end - dev->mem_start)/256;
40715 -               dev->rmem_start = dev->mem_start + TX_PAGES*256;
40716 -               dev->rmem_end = dev->mem_end;
40717 +               ei_status.rmem_start = dev->mem_start + TX_PAGES*256;
40718 +               ei_status.rmem_end = dev->mem_end;
40719         }
40720         
40721         /* Fill in model-specific information and functions */
40722 @@ -621,12 +621,12 @@ static void sane_block_input(struct net_
40723         unsigned long xfer_base = ring_offset - (WD_START_PG<<8);
40724         unsigned long xfer_start = xfer_base + dev->mem_start;
40725  
40726 -       if (xfer_start + count > dev->rmem_end) {
40727 +       if (xfer_start + count > ei_status.rmem_end) {
40728                 /* We must wrap the input move. */
40729 -               int semi_count = dev->rmem_end - xfer_start;
40730 +               int semi_count = ei_status.rmem_end - xfer_start;
40731                 memcpy_fromio(skb->data, (char *)dev->mem_start + xfer_base, semi_count);
40732                 count -= semi_count;
40733 -               memcpy_toio(skb->data + semi_count, (char *)dev->rmem_start, count);
40734 +               memcpy_toio(skb->data + semi_count, (char *)ei_status.rmem_start, count);
40735         } else {
40736                 memcpy_fromio(skb->data, (char *)dev->mem_start + xfer_base, count);
40737         }
40738 @@ -657,15 +657,16 @@ static void dayna_block_input(struct net
40739  
40740         /* Note the offset math is done in card memory space which is word
40741            per long onto our space. */
40742 -        
40743 -       if (xfer_start + count > dev->rmem_end) 
40744 +
40745 +       if (xfer_start + count > ei_status.rmem_end)
40746         {
40747                 /* We must wrap the input move. */
40748 -               int semi_count = dev->rmem_end - xfer_start;
40749 +               int semi_count = ei_status.rmem_end - xfer_start;
40750                 dayna_memcpy_fromcard(dev, skb->data, xfer_base, semi_count);
40751                 count -= semi_count;
40752 -               dayna_memcpy_fromcard(dev, skb->data + semi_count, 
40753 -                       dev->rmem_start - dev->mem_start, count);
40754 +               dayna_memcpy_fromcard(dev, skb->data + semi_count,
40755 +                                     ei_status.rmem_start - dev->mem_start,
40756 +                                     count);
40757         }
40758         else
40759         {
40760 @@ -697,15 +698,15 @@ static void slow_sane_block_input(struct
40761         unsigned long xfer_base = ring_offset - (WD_START_PG<<8);
40762         unsigned long xfer_start = xfer_base+dev->mem_start;
40763  
40764 -       if (xfer_start + count > dev->rmem_end)
40765 +       if (xfer_start + count > ei_status.rmem_end)
40766         {
40767                 /* We must wrap the input move. */
40768 -               int semi_count = dev->rmem_end - xfer_start;
40769 +               int semi_count = ei_status.rmem_end - xfer_start;
40770                 word_memcpy_fromcard(skb->data, (char *)dev->mem_start +
40771                         xfer_base, semi_count);
40772                 count -= semi_count;
40773                 word_memcpy_fromcard(skb->data + semi_count,
40774 -                       (char *)dev->rmem_start, count);
40775 +                                    (char *)ei_status.rmem_start, count);
40776         }
40777         else
40778         {
40779 --- linux-2.6.0-test6/drivers/net/Makefile      2003-09-27 18:57:44.000000000 -0700
40780 +++ 25/drivers/net/Makefile     2003-10-05 00:33:44.000000000 -0700
40781 @@ -32,6 +32,8 @@ obj-$(CONFIG_BMAC) += bmac.o
40782  
40783  obj-$(CONFIG_OAKNET) += oaknet.o 8390.o
40784  
40785 +obj-$(CONFIG_KGDB) += kgdb_eth.o
40786 +
40787  obj-$(CONFIG_DGRS) += dgrs.o
40788  obj-$(CONFIG_RCPCI) += rcpci.o
40789  obj-$(CONFIG_VORTEX) += 3c59x.o
40790 --- linux-2.6.0-test6/drivers/net/ne2.c 2003-09-27 18:57:45.000000000 -0700
40791 +++ 25/drivers/net/ne2.c        2003-10-05 00:33:24.000000000 -0700
40792 @@ -70,7 +70,7 @@ static const char *version = "ne2.c:v0.9
40793  #include <linux/string.h>
40794  #include <linux/errno.h>
40795  #include <linux/init.h>
40796 -#include <linux/mca.h>
40797 +#include <linux/mca-legacy.h>
40798  #include <linux/netdevice.h>
40799  #include <linux/etherdevice.h>
40800  #include <linux/skbuff.h>
40801 --- linux-2.6.0-test6/drivers/net/ne3210.c      2003-09-27 18:57:45.000000000 -0700
40802 +++ 25/drivers/net/ne3210.c     2003-10-05 00:33:24.000000000 -0700
40803 @@ -23,6 +23,7 @@
40804         This driver WILL NOT WORK FOR THE NE3200 - it is completely different
40805         and does not use an 8390 at all.
40806  
40807 +       Updated to EISA probing API 5/2003 by Marc Zyngier.
40808  */
40809  
40810  static const char *version =
40811 @@ -44,9 +45,6 @@ static const char *version =
40812  
40813  #include "8390.h"
40814  
40815 -int ne3210_probe(struct net_device *dev);
40816 -static int ne3210_probe1(struct net_device *dev, int ioaddr);
40817 -
40818  static int ne3210_open(struct net_device *dev);
40819  static int ne3210_close(struct net_device *dev);
40820  
40821 @@ -59,7 +57,6 @@ static void ne3210_block_output(struct n
40822  #define NE3210_START_PG                0x00    /* First page of TX buffer      */
40823  #define NE3210_STOP_PG         0x80    /* Last page +1 of RX ring      */
40824  
40825 -#define NE3210_ID_PORT         0xc80   /* Same for all EISA cards      */
40826  #define NE3210_IO_EXTENT       0x20
40827  #define NE3210_SA_PROM         0x16    /* Start of e'net addr.         */
40828  #define NE3210_RESET_PORT      0xc84
40829 @@ -69,10 +66,9 @@ static void ne3210_block_output(struct n
40830  #define NE3210_ADDR1           0x00
40831  #define NE3210_ADDR2           0x1b
40832  
40833 -#define NE3210_ID      0x0118cc3a      /* 0x3acc = 1110 10110 01100 =  nvl */
40834 -
40835  #define NE3210_CFG1            0xc84   /* NB: 0xc84 is also "reset" port. */
40836  #define NE3210_CFG2            0xc90
40837 +#define NE3210_CFG_EXTENT       (NE3210_CFG2 - NE3210_CFG1 + 1)
40838  
40839  /*
40840   *     You can OR any of the following bits together and assign it
40841 @@ -89,152 +85,108 @@ static void ne3210_block_output(struct n
40842  
40843  static unsigned char irq_map[] __initdata = {15, 12, 11, 10, 9, 7, 5, 3};
40844  static unsigned int shmem_map[] __initdata = {0xff0, 0xfe0, 0xfff0, 0xd8, 0xffe0, 0xffc0, 0xd0, 0x0};
40845 +static const char *ifmap[] __initdata = {"UTP", "?", "BNC", "AUI"};
40846 +static int ifmap_val[] __initdata = {
40847 +               IF_PORT_10BASET,
40848 +               IF_PORT_UNKNOWN,
40849 +               IF_PORT_10BASE2,
40850 +               IF_PORT_AUI,
40851 +};
40852  
40853 -/*
40854 - *     Probe for the card. The best way is to read the EISA ID if it
40855 - *     is known. Then we can check the prefix of the station address
40856 - *     PROM for a match against the value assigned to Novell.
40857 - */
40858 -
40859 -int __init ne3210_probe(struct net_device *dev)
40860 +static int __init ne3210_eisa_probe (struct device *device)
40861  {
40862 -       unsigned short ioaddr = dev->base_addr;
40863 -
40864 -       SET_MODULE_OWNER(dev);
40865 +       unsigned long ioaddr, phys_mem;
40866 +       int i, retval, port_index;
40867 +       struct eisa_device *edev = to_eisa_device (device);
40868 +       struct net_device *dev;
40869  
40870 -       if (ioaddr > 0x1ff)             /* Check a single specified location. */
40871 -               return ne3210_probe1(dev, ioaddr);
40872 -       else if (ioaddr > 0)            /* Don't probe at all. */
40873 -               return -ENXIO;
40874 -
40875 -       if (!EISA_bus) {
40876 -#if NE3210_DEBUG & NE3210_D_PROBE
40877 -               printk("ne3210-debug: Not an EISA bus. Not probing high ports.\n");
40878 -#endif
40879 -               return -ENXIO;
40880 +       /* Allocate dev->priv and fill in 8390 specific dev fields. */
40881 +       if (!(dev = alloc_ei_netdev ())) {
40882 +               printk ("ne3210.c: unable to allocate memory for dev!\n");
40883 +               return -ENOMEM;
40884         }
40885  
40886 -       /* EISA spec allows for up to 16 slots, but 8 is typical. */
40887 -       for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000)
40888 -               if (ne3210_probe1(dev, ioaddr) == 0)
40889 -                       return 0;
40890 -
40891 -       return -ENODEV;
40892 -}
40893 -
40894 -static int __init ne3210_probe1(struct net_device *dev, int ioaddr)
40895 -{
40896 -       int i, retval;
40897 -       unsigned long eisa_id;
40898 -       const char *ifmap[] = {"UTP", "?", "BNC", "AUI"};
40899 -
40900 -       if (!request_region(dev->base_addr, NE3210_IO_EXTENT, dev->name))
40901 -               return -EBUSY;
40902 +       SET_MODULE_OWNER(dev);
40903 +       SET_NETDEV_DEV(dev, device);
40904 +       device->driver_data = dev;
40905 +       ioaddr = edev->base_addr;
40906  
40907 -       if (inb_p(ioaddr + NE3210_ID_PORT) == 0xff) {
40908 -               retval = -ENODEV;
40909 +       if (ethdev_init (dev)) {
40910 +               printk ("ne3210.c: unable to allocate memory for dev->priv!\n");
40911 +               retval = -ENOMEM;
40912                 goto out;
40913         }
40914  
40915 -#if NE3210_DEBUG & NE3210_D_PROBE
40916 -       printk("ne3210-debug: probe at %#x, ID %#8x\n", ioaddr, inl(ioaddr + NE3210_ID_PORT));
40917 -       printk("ne3210-debug: config regs: %#x %#x\n",
40918 -               inb(ioaddr + NE3210_CFG1), inb(ioaddr + NE3210_CFG2));
40919 -#endif
40920 -
40921 -
40922 -/*     Check the EISA ID of the card. */
40923 -       eisa_id = inl(ioaddr + NE3210_ID_PORT);
40924 -       if (eisa_id != NE3210_ID) {
40925 -               retval = -ENODEV;
40926 +       if (!request_region(ioaddr, NE3210_IO_EXTENT, dev->name)) {
40927 +               retval = -EBUSY;
40928                 goto out;
40929         }
40930  
40931 -       
40932 -#if 0
40933 -/*     Check the vendor ID as well. Not really required. */
40934 -       if (inb(ioaddr + NE3210_SA_PROM + 0) != NE3210_ADDR0
40935 -               || inb(ioaddr + NE3210_SA_PROM + 1) != NE3210_ADDR1
40936 -               || inb(ioaddr + NE3210_SA_PROM + 2) != NE3210_ADDR2 ) {
40937 -               printk("ne3210.c: card not found");
40938 -               for(i = 0; i < ETHER_ADDR_LEN; i++)
40939 -                       printk(" %02x", inb(ioaddr + NE3210_SA_PROM + i));
40940 -               printk(" (invalid prefix).\n");
40941 -               retval = -ENODEV;
40942 -               goto out;
40943 +       if (!request_region(ioaddr + NE3210_CFG1,
40944 +                           NE3210_CFG_EXTENT, dev->name)) {
40945 +               retval = -EBUSY;
40946 +               goto out1;
40947         }
40948 +
40949 +#if NE3210_DEBUG & NE3210_D_PROBE
40950 +       printk("ne3210-debug: probe at %#x, ID %s\n", ioaddr, edev->id.sig);
40951 +       printk("ne3210-debug: config regs: %#x %#x\n",
40952 +               inb(ioaddr + NE3210_CFG1), inb(ioaddr + NE3210_CFG2));
40953  #endif
40954  
40955 -       /* Allocate dev->priv and fill in 8390 specific dev fields. */
40956 -       if (ethdev_init(dev)) {
40957 -               printk ("ne3210.c: unable to allocate memory for dev->priv!\n");
40958 -               retval = -ENOMEM;
40959 -               goto out;
40960 -       }
40961  
40962 +       port_index = inb(ioaddr + NE3210_CFG2) >> 6;
40963         printk("ne3210.c: NE3210 in EISA slot %d, media: %s, addr:",
40964 -               ioaddr/0x1000, ifmap[inb(ioaddr + NE3210_CFG2) >> 6]);
40965 +               edev->slot, ifmap[port_index]);
40966         for(i = 0; i < ETHER_ADDR_LEN; i++)
40967                 printk(" %02x", (dev->dev_addr[i] = inb(ioaddr + NE3210_SA_PROM + i)));
40968 -       printk(".\nne3210.c: ");
40969 +       
40970  
40971         /* Snarf the interrupt now. CFG file has them all listed as `edge' with share=NO */
40972 -       if (dev->irq == 0) {
40973 -               unsigned char irq_reg = inb(ioaddr + NE3210_CFG2) >> 3;
40974 -               dev->irq = irq_map[irq_reg & 0x07];
40975 -               printk("using");
40976 -       } else {
40977 -               /* This is useless unless we reprogram the card here too */
40978 -               if (dev->irq == 2) dev->irq = 9;        /* Doh! */
40979 -               printk("assigning");
40980 -       }
40981 -       printk(" IRQ %d,", dev->irq);
40982 +       dev->irq = irq_map[(inb(ioaddr + NE3210_CFG2) >> 3) & 0x07];
40983 +       printk(".\nne3210.c: using IRQ %d, ", dev->irq);
40984  
40985         retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev);
40986         if (retval) {
40987                 printk (" unable to get IRQ %d.\n", dev->irq);
40988 -               goto out1;
40989 -       }
40990 -
40991 -       if (dev->mem_start == 0) {
40992 -               unsigned char mem_reg = inb(ioaddr + NE3210_CFG2) & 0x07;
40993 -               dev->mem_start = shmem_map[mem_reg] * 0x1000;
40994 -               printk(" using ");
40995 -       } else {
40996 -               /* Should check for value in shmem_map and reprogram the card to use it */
40997 -               dev->mem_start &= 0xfff8000;
40998 -               printk(" assigning ");
40999 +               goto out2;
41000         }
41001  
41002 -       printk("%dkB memory at physical address %#lx\n",
41003 -                       NE3210_STOP_PG/4, dev->mem_start);
41004 +       phys_mem = shmem_map[inb(ioaddr + NE3210_CFG2) & 0x07] * 0x1000;
41005  
41006         /*
41007            BEWARE!! Some dain-bramaged EISA SCUs will allow you to put
41008            the card mem within the region covered by `normal' RAM  !!!
41009         */
41010 -       if (dev->mem_start > 1024*1024) {       /* phys addr > 1MB */
41011 -               if (dev->mem_start < virt_to_phys(high_memory)) {
41012 +       if (phys_mem > 1024*1024) {     /* phys addr > 1MB */
41013 +               if (phys_mem < virt_to_phys(high_memory)) {
41014                         printk(KERN_CRIT "ne3210.c: Card RAM overlaps with normal memory!!!\n");
41015                         printk(KERN_CRIT "ne3210.c: Use EISA SCU to set card memory below 1MB,\n");
41016                         printk(KERN_CRIT "ne3210.c: or to an address above 0x%lx.\n", virt_to_phys(high_memory));
41017                         printk(KERN_CRIT "ne3210.c: Driver NOT installed.\n");
41018                         retval = -EINVAL;
41019 -                       goto out2;
41020 +                       goto out3;
41021                 }
41022 -               dev->mem_start = (unsigned long)ioremap(dev->mem_start, NE3210_STOP_PG*0x100);
41023 -               if (dev->mem_start == 0) {
41024 -                       printk(KERN_ERR "ne3210.c: Unable to remap card memory above 1MB !!\n");
41025 -                       printk(KERN_ERR "ne3210.c: Try using EISA SCU to set memory below 1MB.\n");
41026 -                       printk(KERN_ERR "ne3210.c: Driver NOT installed.\n");
41027 -                       retval = -EAGAIN;
41028 -                       goto out2;
41029 -               }
41030 -               ei_status.reg0 = 1;     /* Use as remap flag */
41031 -               printk("ne3210.c: remapped %dkB card memory to virtual address %#lx\n",
41032 -                               NE3210_STOP_PG/4, dev->mem_start);
41033         }
41034 +       
41035 +       if (!request_mem_region (phys_mem, NE3210_STOP_PG*0x100, dev->name)) {
41036 +               printk ("ne3210.c: Unable to request shared memory at physical address %#lx\n",
41037 +                       phys_mem);
41038 +               goto out3;
41039 +       }
41040 +       
41041 +       printk("%dkB memory at physical address %#lx\n",
41042 +              NE3210_STOP_PG/4, phys_mem);
41043  
41044 +       dev->mem_start = (unsigned long)ioremap(phys_mem, NE3210_STOP_PG*0x100);
41045 +       if (dev->mem_start == 0) {
41046 +               printk(KERN_ERR "ne3210.c: Unable to remap card memory !!\n");
41047 +               printk(KERN_ERR "ne3210.c: Driver NOT installed.\n");
41048 +               retval = -EAGAIN;
41049 +               goto out4;
41050 +       }
41051 +       printk("ne3210.c: remapped %dkB card memory to virtual address %#lx\n",
41052 +              NE3210_STOP_PG/4, dev->mem_start);
41053         dev->mem_end = ei_status.rmem_end = dev->mem_start
41054                 + (NE3210_STOP_PG - NE3210_START_PG)*256;
41055         ei_status.rmem_start = dev->mem_start + TX_PAGES*256;
41056 @@ -247,6 +199,7 @@ static int __init ne3210_probe1(struct n
41057         ei_status.rx_start_page = NE3210_START_PG + TX_PAGES;
41058         ei_status.stop_page = NE3210_STOP_PG;
41059         ei_status.word16 = 1;
41060 +       ei_status.priv = phys_mem;
41061  
41062         if (ei_debug > 0)
41063                 printk(version);
41064 @@ -258,18 +211,46 @@ static int __init ne3210_probe1(struct n
41065  
41066         dev->open = &ne3210_open;
41067         dev->stop = &ne3210_close;
41068 +       dev->if_port = ifmap_val[port_index];
41069 +
41070 +       if ((retval = register_netdev (dev)))
41071 +               goto out5;
41072 +               
41073         NS8390_init(dev, 0);
41074         return 0;
41075 -out2:
41076 -       free_irq(dev->irq, dev);        
41077 -out1:
41078 -       kfree(dev->priv);
41079 -       dev->priv = NULL;
41080 -out:
41081 -       release_region(ioaddr, NE3210_IO_EXTENT);
41082 +
41083 + out5:
41084 +       iounmap((void *)dev->mem_start);
41085 + out4:
41086 +       release_mem_region (phys_mem, NE3210_STOP_PG*0x100);
41087 + out3:
41088 +       free_irq (dev->irq, dev);
41089 + out2:
41090 +       release_region (ioaddr + NE3210_CFG1, NE3210_CFG_EXTENT);
41091 + out1:
41092 +       release_region (ioaddr, NE3210_IO_EXTENT);
41093 + out:
41094 +       free_netdev (dev);
41095 +       
41096         return retval;
41097  }
41098  
41099 +static int __devexit ne3210_eisa_remove (struct device *device)
41100 +{
41101 +       struct net_device  *dev    = device->driver_data;
41102 +       unsigned long       ioaddr = to_eisa_device (device)->base_addr;
41103 +
41104 +       unregister_netdev (dev);
41105 +       iounmap((void *)dev->mem_start);
41106 +       release_mem_region (ei_status.priv, NE3210_STOP_PG*0x100);
41107 +       free_irq (dev->irq, dev);
41108 +       release_region (ioaddr + NE3210_CFG1, NE3210_CFG_EXTENT);
41109 +       release_region (ioaddr, NE3210_IO_EXTENT);
41110 +       free_netdev (dev);
41111 +
41112 +       return 0;
41113 +}
41114 +
41115  /*
41116   *     Reset by toggling the "Board Enable" bits (bit 2 and 0).
41117   */
41118 @@ -309,7 +290,7 @@ static void
41119  ne3210_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
41120  {
41121         unsigned long hdr_start = dev->mem_start + ((ring_page - NE3210_START_PG)<<8);
41122 -       isa_memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr));
41123 +       memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr));
41124         hdr->count = (hdr->count + 3) & ~3;     /* Round up allocation. */
41125  }
41126  
41127 @@ -327,12 +308,12 @@ static void ne3210_block_input(struct ne
41128         if (xfer_start + count > ei_status.rmem_end) {
41129                 /* Packet wraps over end of ring buffer. */
41130                 int semi_count = ei_status.rmem_end - xfer_start;
41131 -               isa_memcpy_fromio(skb->data, xfer_start, semi_count);
41132 +               memcpy_fromio(skb->data, xfer_start, semi_count);
41133                 count -= semi_count;
41134 -               isa_memcpy_fromio(skb->data + semi_count, ei_status.rmem_start, count);
41135 +               memcpy_fromio(skb->data + semi_count, ei_status.rmem_start, count);
41136         } else {
41137                 /* Packet is in one chunk. */
41138 -               isa_memcpy_fromio(skb->data, xfer_start, count);
41139 +               memcpy_fromio(skb->data, xfer_start, count);
41140         }
41141  }
41142  
41143 @@ -342,7 +323,7 @@ static void ne3210_block_output(struct n
41144         unsigned long shmem = dev->mem_start + ((start_page - NE3210_START_PG)<<8);
41145  
41146         count = (count + 3) & ~3;     /* Round up to doubleword */
41147 -       isa_memcpy_toio(shmem, buf, count);
41148 +       memcpy_toio(shmem, buf, count);
41149  }
41150  
41151  static int ne3210_open(struct net_device *dev)
41152 @@ -361,7 +342,23 @@ static int ne3210_close(struct net_devic
41153         return 0;
41154  }
41155  
41156 +static struct eisa_device_id ne3210_ids[] = {
41157 +       { "EGL0101" },
41158 +       { "NVL1801" },
41159 +       { "" },
41160 +};
41161 +
41162 +static struct eisa_driver ne3210_eisa_driver = {
41163 +       .id_table = ne3210_ids,
41164 +       .driver   = {
41165 +               .name   = "ne3210",
41166 +               .probe  = ne3210_eisa_probe,
41167 +               .remove = __devexit_p (ne3210_eisa_remove),
41168 +       },
41169 +};
41170 +
41171  #ifdef MODULE
41172 +#if 0
41173  #define MAX_NE3210_CARDS       4       /* Max number of NE3210 cards per module */
41174  static struct net_device dev_ne3210[MAX_NE3210_CARDS];
41175  static int io[MAX_NE3210_CARDS];
41176 @@ -374,50 +371,22 @@ MODULE_PARM(mem, "1-" __MODULE_STRING(MA
41177  MODULE_PARM_DESC(io, "I/O base address(es)");
41178  MODULE_PARM_DESC(irq, "IRQ number(s)");
41179  MODULE_PARM_DESC(mem, "memory base address(es)");
41180 +#endif
41181 +#endif /* MODULE */
41182 +
41183 +
41184  MODULE_DESCRIPTION("NE3210 EISA Ethernet driver");
41185  MODULE_LICENSE("GPL");
41186  
41187 -int init_module(void)
41188 +int ne3210_init(void)
41189  {
41190 -       int this_dev, found = 0;
41191 -
41192 -       for (this_dev = 0; this_dev < MAX_NE3210_CARDS; this_dev++) {
41193 -               struct net_device *dev = &dev_ne3210[this_dev];
41194 -               dev->irq = irq[this_dev];
41195 -               dev->base_addr = io[this_dev];
41196 -               dev->mem_start = mem[this_dev];
41197 -               dev->init = ne3210_probe;
41198 -               /* Default is to only install one card. */
41199 -               if (io[this_dev] == 0 && this_dev != 0) break;
41200 -               if (register_netdev(dev) != 0) {
41201 -                       printk(KERN_WARNING "ne3210.c: No NE3210 card found (i/o = 0x%x).\n", io[this_dev]);
41202 -                       if (found != 0) {       /* Got at least one. */
41203 -                               return 0;
41204 -                       }
41205 -                       return -ENXIO;
41206 -               }
41207 -               found++;
41208 -       }
41209 -       return 0;
41210 +       return eisa_driver_register (&ne3210_eisa_driver);
41211  }
41212  
41213 -void cleanup_module(void)
41214 +void ne3210_cleanup(void)
41215  {
41216 -       int this_dev;
41217 -
41218 -       for (this_dev = 0; this_dev < MAX_NE3210_CARDS; this_dev++) {
41219 -               struct net_device *dev = &dev_ne3210[this_dev];
41220 -               if (dev->priv != NULL) {
41221 -                       free_irq(dev->irq, dev);
41222 -                       release_region(dev->base_addr, NE3210_IO_EXTENT);
41223 -                       if (ei_status.reg0)
41224 -                               iounmap((void *)dev->mem_start);
41225 -                       unregister_netdev(dev);
41226 -                       kfree(dev->priv);
41227 -                       dev->priv = NULL;
41228 -               }
41229 -       }
41230 +       eisa_driver_unregister (&ne3210_eisa_driver);
41231  }
41232  
41233 -#endif /* MODULE */
41234 -
41235 +module_init (ne3210_init);
41236 +module_exit (ne3210_cleanup);
41237 --- linux-2.6.0-test6/drivers/net/sk_mca.c      2003-09-08 13:58:57.000000000 -0700
41238 +++ 25/drivers/net/sk_mca.c     2003-10-05 00:33:24.000000000 -0700
41239 @@ -89,7 +89,7 @@ History:
41240  #include <linux/interrupt.h>
41241  #include <linux/delay.h>
41242  #include <linux/time.h>
41243 -#include <linux/mca.h>
41244 +#include <linux/mca-legacy.h>
41245  #include <linux/init.h>
41246  #include <linux/module.h>
41247  #include <linux/version.h>
41248 --- linux-2.6.0-test6/drivers/net/slip.c        2003-09-27 18:57:45.000000000 -0700
41249 +++ 25/drivers/net/slip.c       2003-10-05 00:36:15.000000000 -0700
41250 @@ -1307,7 +1307,7 @@ static int sl_ioctl(struct net_device *d
41251                 /* Resolve race condition, when ioctl'ing hanged up 
41252                    and opened by another process device.
41253                  */
41254 -               if (sl->tty != current->tty && sl->pid != current->pid) {
41255 +               if (sl->tty != process_tty(current) && sl->pid != current->pid) {
41256                         spin_unlock_bh(&sl->lock);
41257                         return -EPERM;
41258                 }
41259 --- linux-2.6.0-test6/drivers/net/Space.c       2003-09-27 18:57:45.000000000 -0700
41260 +++ 25/drivers/net/Space.c      2003-10-05 00:33:24.000000000 -0700
41261 @@ -67,7 +67,6 @@ extern int elplus_probe(struct net_devic
41262  extern int ac3200_probe(struct net_device *);
41263  extern int es_probe(struct net_device *);
41264  extern int lne390_probe(struct net_device *);
41265 -extern int ne3210_probe(struct net_device *);
41266  extern int e2100_probe(struct net_device *);
41267  extern int ni5010_probe(struct net_device *);
41268  extern int ni52_probe(struct net_device *);
41269 @@ -155,9 +154,6 @@ static struct devprobe eisa_probes[] __i
41270  #ifdef CONFIG_LNE390
41271         {lne390_probe, 0},
41272  #endif
41273 -#ifdef CONFIG_NE3210
41274 -       {ne3210_probe, 0},
41275 -#endif
41276         {NULL, 0},
41277  };
41278  
41279 @@ -480,3 +476,5 @@ void __init probe_old_netdevs(void)
41280  struct net_device *dev_base;
41281  rwlock_t dev_base_lock = RW_LOCK_UNLOCKED;
41282  
41283 +EXPORT_SYMBOL(dev_base);
41284 +EXPORT_SYMBOL(dev_base_lock);
41285 --- linux-2.6.0-test6/drivers/net/tlan.c        2003-09-27 18:57:45.000000000 -0700
41286 +++ 25/drivers/net/tlan.c       2003-10-05 00:33:48.000000000 -0700
41287 @@ -297,6 +297,7 @@ static int  TLan_ioctl( struct net_device
41288  static int      TLan_probe1( struct pci_dev *pdev, long ioaddr, int irq, int rev, const struct pci_device_id *ent);
41289  static void    TLan_tx_timeout( struct net_device *dev);
41290  static int     tlan_init_one( struct pci_dev *pdev, const struct pci_device_id *ent);
41291 +static void    TLan_Poll(struct net_device *dev);
41292  
41293  static u32     TLan_HandleInvalid( struct net_device *, u16 );
41294  static u32     TLan_HandleTxEOF( struct net_device *, u16 );
41295 @@ -453,6 +454,25 @@ static void __devexit tlan_remove_one( s
41296         pci_set_drvdata( pdev, NULL );
41297  } 
41298  
41299 +#ifdef CONFIG_NET_POLL_CONTROLLER
41300 +
41301 +/*
41302 + * Polling 'interrupt' - used by things like netconsole to send skbs
41303 + * without having to re-enable interrupts. It's not called while
41304 + * the interrupt routine is executing.
41305 + */
41306 +
41307 +static void TLan_Poll (struct net_device *dev)
41308 +{
41309 +       disable_irq(dev->irq);
41310 +       TLan_HandleInterrupt(dev->irq, dev, NULL);
41311 +       enable_irq(dev->irq);
41312 +}
41313 +
41314 +#endif
41315 +
41316 +
41317 +
41318  static struct pci_driver tlan_driver = {
41319         .name           = "tlan",
41320         .id_table       = tlan_pci_tbl,
41321 @@ -895,6 +915,9 @@ static int TLan_Init( struct net_device 
41322         dev->do_ioctl = &TLan_ioctl;
41323         dev->tx_timeout = &TLan_tx_timeout;
41324         dev->watchdog_timeo = TX_TIMEOUT;
41325 +#ifdef CONFIG_NET_POLL_CONTROLLER
41326 +       dev->poll_controller = &TLan_Poll;
41327 +#endif
41328  
41329         return 0;
41330  
41331 --- linux-2.6.0-test6/drivers/net/tokenring/madgemc.c   2003-08-22 19:23:41.000000000 -0700
41332 +++ 25/drivers/net/tokenring/madgemc.c  2003-10-05 00:33:24.000000000 -0700
41333 @@ -20,7 +20,7 @@
41334  static const char version[] = "madgemc.c: v0.91 23/01/2000 by Adam Fritzler\n";
41335  
41336  #include <linux/module.h>
41337 -#include <linux/mca.h>
41338 +#include <linux/mca-legacy.h>
41339  #include <linux/kernel.h>
41340  #include <linux/errno.h>
41341  #include <linux/pci.h>
41342 --- linux-2.6.0-test6/drivers/net/tokenring/smctr.c     2003-09-27 18:57:45.000000000 -0700
41343 +++ 25/drivers/net/tokenring/smctr.c    2003-10-05 00:33:24.000000000 -0700
41344 @@ -43,7 +43,7 @@
41345  #include <linux/errno.h>
41346  #include <linux/init.h>
41347  #include <linux/pci.h>
41348 -#include <linux/mca.h>
41349 +#include <linux/mca-legacy.h>
41350  #include <linux/delay.h>
41351  #include <linux/netdevice.h>
41352  #include <linux/etherdevice.h>
41353 --- linux-2.6.0-test6/drivers/net/tulip/interrupt.c     2003-06-14 12:18:04.000000000 -0700
41354 +++ 25/drivers/net/tulip/interrupt.c    2003-10-05 00:36:07.000000000 -0700
41355 @@ -19,13 +19,13 @@
41356  #include <linux/etherdevice.h>
41357  #include <linux/pci.h>
41358  
41359 -
41360  int tulip_rx_copybreak;
41361  unsigned int tulip_max_interrupt_work;
41362  
41363 -#ifdef CONFIG_NET_HW_FLOWCONTROL
41364 -
41365 +#ifdef CONFIG_TULIP_NAPI_HW_MITIGATION
41366  #define MIT_SIZE 15
41367 +#define MIT_TABLE 15 /* We use 0 or max */
41368 +
41369  unsigned int mit_table[MIT_SIZE+1] =
41370  {
41371          /*  CRS11 21143 hardware Mitigation Control Interrupt
41372 @@ -99,16 +99,28 @@ int tulip_refill_rx(struct net_device *d
41373         return refilled;
41374  }
41375  
41376 +#ifdef CONFIG_TULIP_NAPI
41377  
41378 -static int tulip_rx(struct net_device *dev)
41379 +void oom_timer(unsigned long data)
41380 +{
41381 +        struct net_device *dev = (struct net_device *)data;
41382 +       netif_rx_schedule(dev);
41383 +}
41384 +
41385 +int tulip_poll(struct net_device *dev, int *budget)
41386  {
41387         struct tulip_private *tp = (struct tulip_private *)dev->priv;
41388         int entry = tp->cur_rx % RX_RING_SIZE;
41389 -       int rx_work_limit = tp->dirty_rx + RX_RING_SIZE - tp->cur_rx;
41390 +       int rx_work_limit = *budget;
41391         int received = 0;
41392  
41393 -#ifdef CONFIG_NET_HW_FLOWCONTROL
41394 -        int drop = 0, mit_sel = 0;
41395 +       if (!netif_running(dev))
41396 +               goto done;
41397 +
41398 +       if (rx_work_limit > dev->quota)
41399 +               rx_work_limit = dev->quota;
41400 +
41401 +#ifdef CONFIG_TULIP_NAPI_HW_MITIGATION
41402  
41403  /* that one buffer is needed for mit activation; or might be a
41404     bug in the ring buffer code; check later -- JHS*/
41405 @@ -119,6 +131,237 @@ static int tulip_rx(struct net_device *d
41406         if (tulip_debug > 4)
41407                 printk(KERN_DEBUG " In tulip_rx(), entry %d %8.8x.\n", entry,
41408                            tp->rx_ring[entry].status);
41409 +
41410 +       do {
41411 +               /* Acknowledge current RX interrupt sources. */
41412 +               outl((RxIntr | RxNoBuf), dev->base_addr + CSR5);
41413 +
41414 +
41415 +               /* If we own the next entry, it is a new packet. Send it up. */
41416 +               while ( ! (tp->rx_ring[entry].status & cpu_to_le32(DescOwned))) {
41417 +                       s32 status = le32_to_cpu(tp->rx_ring[entry].status);
41418 +
41419 +
41420 +                       if (tp->dirty_rx + RX_RING_SIZE == tp->cur_rx)
41421 +                               break;
41422 +
41423 +                       if (tulip_debug > 5)
41424 +                               printk(KERN_DEBUG "%s: In tulip_rx(), entry %d %8.8x.\n",
41425 +                                      dev->name, entry, status);
41426 +                       if (--rx_work_limit < 0)
41427 +                               goto not_done;
41428 +
41429 +                       if ((status & 0x38008300) != 0x0300) {
41430 +                               if ((status & 0x38000300) != 0x0300) {
41431 +                                /* Ingore earlier buffers. */
41432 +                                       if ((status & 0xffff) != 0x7fff) {
41433 +                                               if (tulip_debug > 1)
41434 +                                                       printk(KERN_WARNING "%s: Oversized Ethernet frame "
41435 +                                                              "spanned multiple buffers, status %8.8x!\n",
41436 +                                                              dev->name, status);
41437 +                                               tp->stats.rx_length_errors++;
41438 +                                       }
41439 +                               } else if (status & RxDescFatalErr) {
41440 +                                /* There was a fatal error. */
41441 +                                       if (tulip_debug > 2)
41442 +                                               printk(KERN_DEBUG "%s: Receive error, Rx status %8.8x.\n",
41443 +                                                      dev->name, status);
41444 +                                       tp->stats.rx_errors++; /* end of a packet.*/
41445 +                                       if (status & 0x0890) tp->stats.rx_length_errors++;
41446 +                                       if (status & 0x0004) tp->stats.rx_frame_errors++;
41447 +                                       if (status & 0x0002) tp->stats.rx_crc_errors++;
41448 +                                       if (status & 0x0001) tp->stats.rx_fifo_errors++;
41449 +                               }
41450 +                       } else {
41451 +                               /* Omit the four octet CRC from the length. */
41452 +                               short pkt_len = ((status >> 16) & 0x7ff) - 4;
41453 +                               struct sk_buff *skb;
41454 +
41455 +#ifndef final_version
41456 +                               if (pkt_len > 1518) {
41457 +                                       printk(KERN_WARNING "%s: Bogus packet size of %d (%#x).\n",
41458 +                                              dev->name, pkt_len, pkt_len);
41459 +                                       pkt_len = 1518;
41460 +                                       tp->stats.rx_length_errors++;
41461 +                               }
41462 +#endif
41463 +                               /* Check if the packet is long enough to accept without copying
41464 +                                  to a minimally-sized skbuff. */
41465 +                               if (pkt_len < tulip_rx_copybreak
41466 +                                   && (skb = dev_alloc_skb(pkt_len + 2)) != NULL) {
41467 +                                       skb->dev = dev;
41468 +                                       skb_reserve(skb, 2);    /* 16 byte align the IP header */
41469 +                                       pci_dma_sync_single(tp->pdev,
41470 +                                                           tp->rx_buffers[entry].mapping,
41471 +                                                           pkt_len, PCI_DMA_FROMDEVICE);
41472 +#if ! defined(__alpha__)
41473 +                                       eth_copy_and_sum(skb, tp->rx_buffers[entry].skb->tail,
41474 +                                                        pkt_len, 0);
41475 +                                       skb_put(skb, pkt_len);
41476 +#else
41477 +                                       memcpy(skb_put(skb, pkt_len),
41478 +                                              tp->rx_buffers[entry].skb->tail,
41479 +                                              pkt_len);
41480 +#endif
41481 +                               } else {        /* Pass up the skb already on the Rx ring. */
41482 +                                       char *temp = skb_put(skb = tp->rx_buffers[entry].skb,
41483 +                                                            pkt_len);
41484 +
41485 +#ifndef final_version
41486 +                                       if (tp->rx_buffers[entry].mapping !=
41487 +                                           le32_to_cpu(tp->rx_ring[entry].buffer1)) {
41488 +                                               printk(KERN_ERR "%s: Internal fault: The skbuff addresses "
41489 +                                                      "do not match in tulip_rx: %08x vs. %08x %p / %p.\n",
41490 +                                                      dev->name,
41491 +                                                      le32_to_cpu(tp->rx_ring[entry].buffer1),
41492 +                                                      tp->rx_buffers[entry].mapping,
41493 +                                                      skb->head, temp);
41494 +                                       }
41495 +#endif
41496 +
41497 +                                       pci_unmap_single(tp->pdev, tp->rx_buffers[entry].mapping,
41498 +                                                        PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
41499 +
41500 +                                       tp->rx_buffers[entry].skb = NULL;
41501 +                                       tp->rx_buffers[entry].mapping = 0;
41502 +                               }
41503 +                               skb->protocol = eth_type_trans(skb, dev);
41504 +
41505 +                               netif_receive_skb(skb);
41506 +
41507 +                               dev->last_rx = jiffies;
41508 +                               tp->stats.rx_packets++;
41509 +                               tp->stats.rx_bytes += pkt_len;
41510 +                       }
41511 +                       received++;
41512 +
41513 +                       entry = (++tp->cur_rx) % RX_RING_SIZE;
41514 +                       if (tp->cur_rx - tp->dirty_rx > RX_RING_SIZE/4)
41515 +                               tulip_refill_rx(dev);
41516 +
41517 +                }
41518 +
41519 +               /* New ack strategy... irq does not ack Rx any longer
41520 +                  hopefully this helps */
41521 +
41522 +               /* Really bad things can happen here... If new packet arrives
41523 +                * and an irq arrives (tx or just due to occasionally unset
41524 +                * mask), it will be acked by irq handler, but new thread
41525 +                * is not scheduled. It is major hole in design.
41526 +                * No idea how to fix this if "playing with fire" will fail
41527 +                * tomorrow (night 011029). If it will not fail, we won
41528 +                * finally: amount of IO did not increase at all. */
41529 +       } while ((inl(dev->base_addr + CSR5) & RxIntr));
41530 +
41531 +done:
41532 +
41533 + #ifdef CONFIG_TULIP_NAPI_HW_MITIGATION
41534 +
41535 +          /* We use this simplistic scheme for IM. It's proven by
41536 +             real life installations. We can have IM enabled
41537 +            continuesly but this would cause unnecessary latency.
41538 +            Unfortunely we can't use all the NET_RX_* feedback here.
41539 +            This would turn on IM for devices that is not contributing
41540 +            to backlog congestion with unnecessary latency.
41541 +
41542 +             We monitor the the device RX-ring and have:
41543 +
41544 +             HW Interrupt Mitigation either ON or OFF.
41545 +
41546 +            ON:  More then 1 pkt received (per intr.) OR we are dropping
41547 +             OFF: Only 1 pkt received
41548 +
41549 +             Note. We only use min and max (0, 15) settings from mit_table */
41550 +
41551 +
41552 +          if( tp->flags &  HAS_INTR_MITIGATION) {
41553 +                 if( received > 1 ) {
41554 +                         if( ! tp->mit_on ) {
41555 +                                 tp->mit_on = 1;
41556 +                                 outl(mit_table[MIT_TABLE], dev->base_addr + CSR11);
41557 +                         }
41558 +                  }
41559 +                 else {
41560 +                         if( tp->mit_on ) {
41561 +                                 tp->mit_on = 0;
41562 +                                 outl(0, dev->base_addr + CSR11);
41563 +                         }
41564 +                  }
41565 +          }
41566 +
41567 +#endif /* CONFIG_TULIP_NAPI_HW_MITIGATION */
41568 +
41569 +         dev->quota -= received;
41570 +         *budget -= received;
41571 +
41572 +         tulip_refill_rx(dev);
41573 +
41574 +         /* If RX ring is not full we are out of memory. */
41575 +         if (tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL) goto oom;
41576 +
41577 +         /* Remove us from polling list and enable RX intr. */
41578 +
41579 +         netif_rx_complete(dev);
41580 +         outl(tulip_tbl[tp->chip_id].valid_intrs, dev->base_addr+CSR7);
41581 +
41582 +         /* The last op happens after poll completion. Which means the following:
41583 +          * 1. it can race with disabling irqs in irq handler
41584 +          * 2. it can race with dise/enabling irqs in other poll threads
41585 +          * 3. if an irq raised after beginning loop, it will be immediately
41586 +          *    triggered here.
41587 +          *
41588 +          * Summarizing: the logic results in some redundant irqs both
41589 +          * due to races in masking and due to too late acking of already
41590 +          * processed irqs. But it must not result in losing events.
41591 +          */
41592 +
41593 +         return 0;
41594 +
41595 + not_done:
41596 +         if (!received) {
41597 +
41598 +                 received = dev->quota; /* Not to happen */
41599 +         }
41600 +         dev->quota -= received;
41601 +         *budget -= received;
41602 +
41603 +         if (tp->cur_rx - tp->dirty_rx > RX_RING_SIZE/2 ||
41604 +             tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL)
41605 +                 tulip_refill_rx(dev);
41606 +
41607 +         if (tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL) goto oom;
41608 +
41609 +         return 1;
41610 +
41611 +
41612 + oom:    /* Executed with RX ints disabled */
41613 +
41614 +
41615 +         /* Start timer, stop polling, but do not enable rx interrupts. */
41616 +         mod_timer(&tp->oom_timer, jiffies+1);
41617 +
41618 +         /* Think: timer_pending() was an explicit signature of bug.
41619 +          * Timer can be pending now but fired and completed
41620 +          * before we did netif_rx_complete(). See? We would lose it. */
41621 +
41622 +         /* remove ourselves from the polling list */
41623 +         netif_rx_complete(dev);
41624 +
41625 +         return 0;
41626 +}
41627 +
41628 +#else /* CONFIG_TULIP_NAPI */
41629 +
41630 +static int tulip_rx(struct net_device *dev)
41631 +{
41632 +       struct tulip_private *tp = (struct tulip_private *)dev->priv;
41633 +       int entry = tp->cur_rx % RX_RING_SIZE;
41634 +       int rx_work_limit = tp->dirty_rx + RX_RING_SIZE - tp->cur_rx;
41635 +       int received = 0;
41636 +
41637 +       if (tulip_debug > 4)
41638 +               printk(KERN_DEBUG " In tulip_rx(), entry %d %8.8x.\n", entry,
41639 +                          tp->rx_ring[entry].status);
41640         /* If we own the next entry, it is a new packet. Send it up. */
41641         while ( ! (tp->rx_ring[entry].status & cpu_to_le32(DescOwned))) {
41642                 s32 status = le32_to_cpu(tp->rx_ring[entry].status);
41643 @@ -163,11 +406,6 @@ static int tulip_rx(struct net_device *d
41644                         }
41645  #endif
41646  
41647 -#ifdef CONFIG_NET_HW_FLOWCONTROL
41648 -                        drop = atomic_read(&netdev_dropping);
41649 -                        if (drop)
41650 -                                goto throttle;
41651 -#endif
41652                         /* Check if the packet is long enough to accept without copying
41653                            to a minimally-sized skbuff. */
41654                         if (pkt_len < tulip_rx_copybreak
41655 @@ -209,44 +447,9 @@ static int tulip_rx(struct net_device *d
41656                                 tp->rx_buffers[entry].mapping = 0;
41657                         }
41658                         skb->protocol = eth_type_trans(skb, dev);
41659 -#ifdef CONFIG_NET_HW_FLOWCONTROL
41660 -                        mit_sel =
41661 -#endif
41662 -                       netif_rx(skb);
41663  
41664 -#ifdef CONFIG_NET_HW_FLOWCONTROL
41665 -                        switch (mit_sel) {
41666 -                        case NET_RX_SUCCESS:
41667 -                        case NET_RX_CN_LOW:
41668 -                        case NET_RX_CN_MOD:
41669 -                                break;
41670 -
41671 -                        case NET_RX_CN_HIGH:
41672 -                                rx_work_limit -= NET_RX_CN_HIGH; /* additional*/
41673 -                                break;
41674 -                        case NET_RX_DROP:
41675 -                                rx_work_limit = -1;
41676 -                                break;
41677 -                        default:
41678 -                                printk("unknown feedback return code %d\n", mit_sel);
41679 -                                break;
41680 -                        }
41681 +                       netif_rx(skb);
41682  
41683 -                        drop = atomic_read(&netdev_dropping);
41684 -                        if (drop) {
41685 -throttle:
41686 -                                rx_work_limit = -1;
41687 -                                mit_sel = NET_RX_DROP;
41688 -
41689 -                                if (tp->fc_bit) {
41690 -                                        long ioaddr = dev->base_addr;
41691 -
41692 -                                        /* disable Rx & RxNoBuf ints. */
41693 -                                        outl(tulip_tbl[tp->chip_id].valid_intrs&RX_A_NBF_STOP, ioaddr + CSR7);
41694 -                                        set_bit(tp->fc_bit, &netdev_fc_xoff);
41695 -                                }
41696 -                        }
41697 -#endif
41698                         dev->last_rx = jiffies;
41699                         tp->stats.rx_packets++;
41700                         tp->stats.rx_bytes += pkt_len;
41701 @@ -254,42 +457,9 @@ throttle:
41702                 received++;
41703                 entry = (++tp->cur_rx) % RX_RING_SIZE;
41704         }
41705 -#ifdef CONFIG_NET_HW_FLOWCONTROL
41706 -
41707 -        /* We use this simplistic scheme for IM. It's proven by
41708 -           real life installations. We can have IM enabled
41709 -           continuesly but this would cause unnecessary latency.
41710 -           Unfortunely we can't use all the NET_RX_* feedback here.
41711 -           This would turn on IM for devices that is not contributing
41712 -           to backlog congestion with unnecessary latency.
41713 -
41714 -           We monitor the device RX-ring and have:
41715 -
41716 -           HW Interrupt Mitigation either ON or OFF.
41717 -
41718 -           ON:  More then 1 pkt received (per intr.) OR we are dropping
41719 -           OFF: Only 1 pkt received
41720 -
41721 -           Note. We only use min and max (0, 15) settings from mit_table */
41722 -
41723 -
41724 -        if( tp->flags &  HAS_INTR_MITIGATION) {
41725 -                if((received > 1 || mit_sel == NET_RX_DROP)
41726 -                   && tp->mit_sel != 15 ) {
41727 -                        tp->mit_sel = 15;
41728 -                        tp->mit_change = 1; /* Force IM change */
41729 -                }
41730 -                if((received <= 1 && mit_sel != NET_RX_DROP) && tp->mit_sel != 0 ) {
41731 -                        tp->mit_sel = 0;
41732 -                        tp->mit_change = 1; /* Force IM change */
41733 -                }
41734 -        }
41735 -
41736 -        return RX_RING_SIZE+1; /* maxrx+1 */
41737 -#else
41738         return received;
41739 -#endif
41740  }
41741 +#endif  /* CONFIG_TULIP_NAPI */
41742  
41743  static inline unsigned int phy_interrupt (struct net_device *dev)
41744  {
41745 @@ -323,7 +493,6 @@ irqreturn_t tulip_interrupt(int irq, voi
41746         struct tulip_private *tp = (struct tulip_private *)dev->priv;
41747         long ioaddr = dev->base_addr;
41748         int csr5;
41749 -       int entry;
41750         int missed;
41751         int rx = 0;
41752         int tx = 0;
41753 @@ -331,6 +500,11 @@ irqreturn_t tulip_interrupt(int irq, voi
41754         int maxrx = RX_RING_SIZE;
41755         int maxtx = TX_RING_SIZE;
41756         int maxoi = TX_RING_SIZE;
41757 +#ifdef CONFIG_TULIP_NAPI
41758 +       int rxd = 0;
41759 +#else
41760 +       int entry;
41761 +#endif
41762         unsigned int work_count = tulip_max_interrupt_work;
41763         unsigned int handled = 0;
41764  
41765 @@ -346,22 +520,41 @@ irqreturn_t tulip_interrupt(int irq, voi
41766         tp->nir++;
41767  
41768         do {
41769 +
41770 +#ifdef CONFIG_TULIP_NAPI
41771 +
41772 +               if (!rxd && (csr5 & (RxIntr | RxNoBuf))) {
41773 +                       rxd++;
41774 +                       /* Mask RX intrs and add the device to poll list. */
41775 +                       outl(tulip_tbl[tp->chip_id].valid_intrs&~RxPollInt, ioaddr + CSR7);
41776 +                       netif_rx_schedule(dev);
41777 +
41778 +                       if (!(csr5&~(AbnormalIntr|NormalIntr|RxPollInt|TPLnkPass)))
41779 +                               break;
41780 +               }
41781 +
41782 +               /* Acknowledge the interrupt sources we handle here ASAP
41783 +                  the poll function does Rx and RxNoBuf acking */
41784 +
41785 +               outl(csr5 & 0x0001ff3f, ioaddr + CSR5);
41786 +
41787 +#else
41788                 /* Acknowledge all of the current interrupt sources ASAP. */
41789                 outl(csr5 & 0x0001ffff, ioaddr + CSR5);
41790  
41791 -               if (tulip_debug > 4)
41792 -                       printk(KERN_DEBUG "%s: interrupt  csr5=%#8.8x new csr5=%#8.8x.\n",
41793 -                                  dev->name, csr5, inl(dev->base_addr + CSR5));
41794  
41795                 if (csr5 & (RxIntr | RxNoBuf)) {
41796 -#ifdef CONFIG_NET_HW_FLOWCONTROL
41797 -                        if ((!tp->fc_bit) ||
41798 -                           (!test_bit(tp->fc_bit, &netdev_fc_xoff)))
41799 -#endif
41800                                 rx += tulip_rx(dev);
41801                         tulip_refill_rx(dev);
41802                 }
41803  
41804 +#endif /*  CONFIG_TULIP_NAPI */
41805 +
41806 +               if (tulip_debug > 4)
41807 +                       printk(KERN_DEBUG "%s: interrupt  csr5=%#8.8x new csr5=%#8.8x.\n",
41808 +                              dev->name, csr5, inl(dev->base_addr + CSR5));
41809 +
41810 +
41811                 if (csr5 & (TxNoBuf | TxDied | TxIntr | TimerInt)) {
41812                         unsigned int dirty_tx;
41813  
41814 @@ -462,15 +655,8 @@ irqreturn_t tulip_interrupt(int irq, voi
41815                         }
41816                         if (csr5 & RxDied) {            /* Missed a Rx frame. */
41817                                  tp->stats.rx_missed_errors += inl(ioaddr + CSR8) & 0xffff;
41818 -#ifdef CONFIG_NET_HW_FLOWCONTROL
41819 -                               if (tp->fc_bit && !test_bit(tp->fc_bit, &netdev_fc_xoff)) {
41820 -                                       tp->stats.rx_errors++;
41821 -                                       tulip_start_rxtx(tp);
41822 -                               }
41823 -#else
41824                                 tp->stats.rx_errors++;
41825                                 tulip_start_rxtx(tp);
41826 -#endif
41827                         }
41828                         /*
41829                          * NB: t21142_lnk_change() does a del_timer_sync(), so be careful if this
41830 @@ -504,10 +690,6 @@ irqreturn_t tulip_interrupt(int irq, voi
41831                         if (tulip_debug > 2)
41832                                 printk(KERN_ERR "%s: Re-enabling interrupts, %8.8x.\n",
41833                                            dev->name, csr5);
41834 -#ifdef CONFIG_NET_HW_FLOWCONTROL
41835 -                        if (tp->fc_bit && (test_bit(tp->fc_bit, &netdev_fc_xoff)))
41836 -                          if (net_ratelimit()) printk("BUG!! enabling interrupt when FC off (timerintr.) \n");
41837 -#endif
41838                         outl(tulip_tbl[tp->chip_id].valid_intrs, ioaddr + CSR7);
41839                         tp->ttimer = 0;
41840                         oi++;
41841 @@ -520,16 +702,9 @@ irqreturn_t tulip_interrupt(int irq, voi
41842                         /* Acknowledge all interrupt sources. */
41843                          outl(0x8001ffff, ioaddr + CSR5);
41844                          if (tp->flags & HAS_INTR_MITIGATION) {
41845 -#ifdef CONFIG_NET_HW_FLOWCONTROL
41846 -                                if(tp->mit_change) {
41847 -                                        outl(mit_table[tp->mit_sel], ioaddr + CSR11);
41848 -                                        tp->mit_change = 0;
41849 -                                }
41850 -#else
41851                       /* Josip Loncaric at ICASE did extensive experimentation
41852                         to develop a good interrupt mitigation setting.*/
41853                                  outl(0x8b240000, ioaddr + CSR11);
41854 -#endif
41855                          } else if (tp->chip_id == LC82C168) {
41856                                 /* the LC82C168 doesn't have a hw timer.*/
41857                                 outl(0x00, ioaddr + CSR7);
41858 @@ -537,10 +712,8 @@ irqreturn_t tulip_interrupt(int irq, voi
41859                         } else {
41860                            /* Mask all interrupting sources, set timer to
41861                                 re-enable. */
41862 -#ifndef CONFIG_NET_HW_FLOWCONTROL
41863                                  outl(((~csr5) & 0x0001ebef) | AbnormalIntr | TimerInt, ioaddr + CSR7);
41864                                  outl(0x0012, ioaddr + CSR11);
41865 -#endif
41866                          }
41867                         break;
41868                 }
41869 @@ -550,6 +723,21 @@ irqreturn_t tulip_interrupt(int irq, voi
41870                         break;
41871  
41872                 csr5 = inl(ioaddr + CSR5);
41873 +
41874 +#ifdef CONFIG_TULIP_NAPI
41875 +               if (rxd)
41876 +                       csr5 &= ~RxPollInt;
41877 +       } while ((csr5 & (TxNoBuf |
41878 +                         TxDied |
41879 +                         TxIntr |
41880 +                         TimerInt |
41881 +                         /* Abnormal intr. */
41882 +                         RxDied |
41883 +                         TxFIFOUnderflow |
41884 +                         TxJabber |
41885 +                         TPLnkFail |
41886 +                         SytemError )) != 0);
41887 +#else
41888         } while ((csr5 & (NormalIntr|AbnormalIntr)) != 0);
41889  
41890         tulip_refill_rx(dev);
41891 @@ -574,6 +762,7 @@ irqreturn_t tulip_interrupt(int irq, voi
41892                         }
41893                 }
41894         }
41895 +#endif /* CONFIG_TULIP_NAPI */
41896  
41897         if ((missed = inl(ioaddr + CSR8) & 0x1ffff)) {
41898                 tp->stats.rx_dropped += missed & 0x10000 ? 0x10000 : missed;
41899 --- linux-2.6.0-test6/drivers/net/tulip/Kconfig 2003-09-27 18:57:45.000000000 -0700
41900 +++ 25/drivers/net/tulip/Kconfig        2003-10-05 00:34:49.000000000 -0700
41901 @@ -68,6 +68,26 @@ config TULIP_MMIO
41902           obscure bugs if your mainboard has memory controller timing issues.
41903           If in doubt, say N.
41904  
41905 +config TULIP_NAPI
41906 +       bool "Use NAPI RX polling "
41907 +       depends on TULIP
41908 +       ---help---
41909 +         This is of useful for servers and routers dealing with high network loads.
41910 +
41911 +         See <file:Documentation/networking/NAPI_HOWTO.txt>.
41912 +
41913 +         If in doubt, say N.
41914 +
41915 +config TULIP_NAPI_HW_MITIGATION
41916 +       bool "Use Interrupt Mitigation "
41917 +       depends on TULIP_NAPI
41918 +       ---help---
41919 +         Use HW to reduce RX interrupts. Not strict necessary since NAPI reduces
41920 +         RX interrupts but itself. Although this reduces RX interrupts even at
41921 +         low levels traffic at the cost of a small latency.
41922 +
41923 +         If in doubt, say Y.
41924 +
41925  config DE4X5
41926         tristate "Generic DECchip & DIGITAL EtherWORKS PCI/EISA"
41927         depends on NET_TULIP && (PCI || EISA)
41928 --- linux-2.6.0-test6/drivers/net/tulip/tulip_core.c    2003-08-22 19:23:41.000000000 -0700
41929 +++ 25/drivers/net/tulip/tulip_core.c   2003-10-05 00:34:49.000000000 -0700
41930 @@ -14,11 +14,17 @@
41931  
41932  */
41933  
41934 +#include <linux/config.h>
41935 +
41936  #define DRV_NAME       "tulip"
41937 +#ifdef CONFIG_TULIP_NAPI
41938 +#define DRV_VERSION    "1.1.13-NAPI" /* Keep at least for test */
41939 +#else
41940  #define DRV_VERSION    "1.1.13"
41941 +#endif
41942  #define DRV_RELDATE    "May 11, 2002"
41943  
41944 -#include <linux/config.h>
41945 +
41946  #include <linux/module.h>
41947  #include "tulip.h"
41948  #include <linux/pci.h>
41949 @@ -246,6 +252,7 @@ static void tulip_down(struct net_device
41950  static struct net_device_stats *tulip_get_stats(struct net_device *dev);
41951  static int private_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
41952  static void set_rx_mode(struct net_device *dev);
41953 +static void poll_tulip(struct net_device *dev);
41954  
41955  
41956  
41957 @@ -465,29 +472,16 @@ media_picked:
41958            to an alternate media type. */
41959         tp->timer.expires = RUN_AT(next_tick);
41960         add_timer(&tp->timer);
41961 -}
41962 -
41963 -#ifdef CONFIG_NET_HW_FLOWCONTROL
41964 -/* Enable receiver */
41965 -void tulip_xon(struct net_device *dev)
41966 -{
41967 -        struct tulip_private *tp = (struct tulip_private *)dev->priv;
41968 -
41969 -        clear_bit(tp->fc_bit, &netdev_fc_xoff);
41970 -        if (netif_running(dev)){
41971 -
41972 -                tulip_refill_rx(dev);
41973 -                outl(tulip_tbl[tp->chip_id].valid_intrs,  dev->base_addr+CSR7);
41974 -        }
41975 -}
41976 +#ifdef CONFIG_TULIP_NAPI
41977 +       init_timer(&tp->oom_timer);
41978 +        tp->oom_timer.data = (unsigned long)dev;
41979 +        tp->oom_timer.function = oom_timer;
41980  #endif
41981 +}
41982  
41983  static int
41984  tulip_open(struct net_device *dev)
41985  {
41986 -#ifdef CONFIG_NET_HW_FLOWCONTROL
41987 -        struct tulip_private *tp = (struct tulip_private *)dev->priv;
41988 -#endif
41989         int retval;
41990  
41991         if ((retval = request_irq(dev->irq, &tulip_interrupt, SA_SHIRQ, dev->name, dev)))
41992 @@ -497,10 +491,6 @@ tulip_open(struct net_device *dev)
41993  
41994         tulip_up (dev);
41995  
41996 -#ifdef CONFIG_NET_HW_FLOWCONTROL
41997 -        tp->fc_bit = netdev_register_fc(dev, tulip_xon);
41998 -#endif
41999 -
42000         netif_start_queue (dev);
42001  
42002         return 0;
42003 @@ -581,10 +571,7 @@ static void tulip_tx_timeout(struct net_
42004  #endif
42005  
42006         /* Stop and restart the chip's Tx processes . */
42007 -#ifdef CONFIG_NET_HW_FLOWCONTROL
42008 -        if (tp->fc_bit && test_bit(tp->fc_bit,&netdev_fc_xoff))
42009 -                printk("BUG tx_timeout restarting rx when fc on\n");
42010 -#endif
42011 +
42012         tulip_restart_rxtx(tp);
42013         /* Trigger an immediate transmit demand. */
42014         outl(0, ioaddr + CSR1);
42015 @@ -741,7 +728,9 @@ static void tulip_down (struct net_devic
42016         unsigned long flags;
42017  
42018         del_timer_sync (&tp->timer);
42019 -
42020 +#ifdef CONFIG_TULIP_NAPI
42021 +       del_timer_sync (&tp->oom_timer);
42022 +#endif
42023         spin_lock_irqsave (&tp->lock, flags);
42024  
42025         /* Disable interrupts by clearing the interrupt mask. */
42026 @@ -780,13 +769,6 @@ static int tulip_close (struct net_devic
42027  
42028         netif_stop_queue (dev);
42029  
42030 -#ifdef CONFIG_NET_HW_FLOWCONTROL
42031 -        if (tp->fc_bit) {
42032 -                int bit = tp->fc_bit;
42033 -                tp->fc_bit = 0;
42034 -                netdev_unregister_fc(bit);
42035 -        }
42036 -#endif
42037         tulip_down (dev);
42038  
42039         if (tulip_debug > 1)
42040 @@ -1627,10 +1609,17 @@ static int __devinit tulip_init_one (str
42041         dev->hard_start_xmit = tulip_start_xmit;
42042         dev->tx_timeout = tulip_tx_timeout;
42043         dev->watchdog_timeo = TX_TIMEOUT;
42044 +#ifdef CONFIG_TULIP_NAPI
42045 +       dev->poll = tulip_poll;
42046 +       dev->weight = 16;
42047 +#endif
42048         dev->stop = tulip_close;
42049         dev->get_stats = tulip_get_stats;
42050         dev->do_ioctl = private_ioctl;
42051         dev->set_multicast_list = set_rx_mode;
42052 +#ifdef CONFIG_NET_POLL_CONTROLLER
42053 +       dev->poll_controller = &poll_tulip;
42054 +#endif
42055  
42056         if (register_netdev(dev))
42057                 goto err_out_free_ring;
42058 @@ -1788,6 +1777,24 @@ static void __devexit tulip_remove_one (
42059  }
42060  
42061  
42062 +#ifdef CONFIG_NET_POLL_CONTROLLER
42063 +
42064 +/*
42065 + * Polling 'interrupt' - used by things like netconsole to send skbs
42066 + * without having to re-enable interrupts. It's not called while
42067 + * the interrupt routine is executing.
42068 + */
42069 +
42070 +static void poll_tulip (struct net_device *dev)
42071 +{
42072 +       disable_irq(dev->irq);
42073 +       tulip_interrupt (dev->irq, dev, NULL);
42074 +       enable_irq(dev->irq);
42075 +}
42076 +
42077 +#endif
42078 +
42079 +
42080  static struct pci_driver tulip_driver = {
42081         .name           = DRV_NAME,
42082         .id_table       = tulip_pci_tbl,
42083 --- linux-2.6.0-test6/drivers/net/tulip/tulip.h 2003-06-14 12:18:34.000000000 -0700
42084 +++ 25/drivers/net/tulip/tulip.h        2003-10-05 00:34:49.000000000 -0700
42085 @@ -126,6 +126,7 @@ enum pci_cfg_driver_reg {
42086         CFDD_Snooze = (1 << 30),
42087  };
42088  
42089 +#define RxPollInt (RxIntr|RxNoBuf|RxDied|RxJabber)
42090  
42091  /* The bits in the CSR5 status registers, mostly interrupt sources. */
42092  enum status_bits {
42093 @@ -251,9 +252,9 @@ enum t21143_csr6_bits {
42094     Making the Tx ring too large decreases the effectiveness of channel
42095     bonding and packet priority.
42096     There are no ill effects from too-large receive rings. */
42097 -#define TX_RING_SIZE   16
42098 -#define RX_RING_SIZE   32
42099  
42100 +#define TX_RING_SIZE   32
42101 +#define RX_RING_SIZE   128
42102  #define MEDIA_MASK     31
42103  
42104  #define PKT_BUF_SZ             1536    /* Size of each temporary Rx buffer. */
42105 @@ -343,17 +344,15 @@ struct tulip_private {
42106         int flags;
42107         struct net_device_stats stats;
42108         struct timer_list timer;        /* Media selection timer. */
42109 +       struct timer_list oom_timer;    /* Out of memory timer. */
42110         u32 mc_filter[2];
42111         spinlock_t lock;
42112         spinlock_t mii_lock;
42113         unsigned int cur_rx, cur_tx;    /* The next free ring entry */
42114         unsigned int dirty_rx, dirty_tx;        /* The ring entries to be free()ed. */
42115  
42116 -#ifdef CONFIG_NET_HW_FLOWCONTROL
42117 -#define RX_A_NBF_STOP 0xffffff3f /* To disable RX and RX-NOBUF ints. */
42118 -        int fc_bit;
42119 -        int mit_sel;
42120 -        int mit_change; /* Signal for Interrupt Mitigtion */
42121 +#ifdef         CONFIG_TULIP_NAPI_HW_MITIGATION
42122 +        int mit_on;
42123  #endif
42124         unsigned int full_duplex:1;     /* Full-duplex operation requested. */
42125         unsigned int full_duplex_lock:1;
42126 @@ -415,6 +414,10 @@ extern unsigned int tulip_max_interrupt_
42127  extern int tulip_rx_copybreak;
42128  irqreturn_t tulip_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
42129  int tulip_refill_rx(struct net_device *dev);
42130 +#ifdef CONFIG_TULIP_NAPI
42131 +int tulip_poll(struct net_device *dev, int *budget);
42132 +#endif
42133 +
42134  
42135  /* media.c */
42136  int tulip_mdio_read(struct net_device *dev, int phy_id, int location);
42137 @@ -438,6 +441,7 @@ extern int tulip_debug;
42138  extern const char * const medianame[];
42139  extern const char tulip_media_cap[];
42140  extern struct tulip_chip_table tulip_tbl[];
42141 +void oom_timer(unsigned long data);
42142  extern u8 t21040_csr13[];
42143  
42144  #ifndef USE_IO_OPS
42145 --- linux-2.6.0-test6/drivers/net/wan/comx-hw-munich.c  2003-09-27 18:57:45.000000000 -0700
42146 +++ 25/drivers/net/wan/comx-hw-munich.c 2003-10-05 00:33:24.000000000 -0700
42147 @@ -1849,7 +1849,7 @@ static int MUNICH_open(struct net_device
42148      if (board->isx21)
42149      {
42150         init_timer(&board->modemline_timer);
42151 -       board->modemline_timer.data = (unsigned int)board;
42152 +       board->modemline_timer.data = (unsigned long)board;
42153         board->modemline_timer.function = pcicom_modemline;
42154         board->modemline_timer.expires = jiffies + HZ;
42155         add_timer((struct timer_list *)&board->modemline_timer);
42156 --- linux-2.6.0-test6/drivers/net/wan/dscc4.c   2003-09-27 18:57:45.000000000 -0700
42157 +++ 25/drivers/net/wan/dscc4.c  2003-10-05 00:36:13.000000000 -0700
42158 @@ -107,7 +107,7 @@
42159  #include <linux/hdlc.h>
42160  
42161  /* Version */
42162 -static const char version[] = "$Id: 2.6.0-test6-mm4.patch,v 1.5 2004/02/23 23:37:02 phil Exp $ for Linux\n";
42163 +static const char version[] = "Id: 2.6.0-test6-mm4.patch,v 1.3.2.1 2004/02/14 07:21:32 nic Exp $ for Linux\n";
42164  static int debug;
42165  static int quartz;
42166  
42167 @@ -592,6 +592,7 @@ static inline int dscc4_xpr_ack(struct d
42168         return (i >= 0 ) ? i : -EAGAIN;
42169  }
42170  
42171 +#if 0 /* dscc4_{rx/tx}_reset are both unreliable - more tweak needed */
42172  static void dscc4_rx_reset(struct dscc4_dev_priv *dpriv, struct net_device *dev)
42173  {
42174         unsigned long flags;
42175 @@ -606,6 +607,9 @@ static void dscc4_rx_reset(struct dscc4_
42176         spin_unlock_irqrestore(&dpriv->pci_priv->lock, flags);
42177  }
42178  
42179 +#endif
42180 +
42181 +#if 0
42182  static void dscc4_tx_reset(struct dscc4_dev_priv *dpriv, struct net_device *dev)
42183  {
42184         u16 i = 0;
42185 @@ -625,6 +629,7 @@ static void dscc4_tx_reset(struct dscc4_
42186         if (dscc4_do_action(dev, "Rdt") < 0)
42187                 printk(KERN_ERR "%s: Tx reset failed\n", dev->name);
42188  }
42189 +#endif
42190  
42191  /* TODO: (ab)use this function to refill a completely depleted RX ring. */
42192  static inline void dscc4_rx_skb(struct dscc4_dev_priv *dpriv,
42193 @@ -859,7 +864,7 @@ static int dscc4_found1(struct pci_dev *
42194  {
42195         struct dscc4_pci_priv *ppriv;
42196         struct dscc4_dev_priv *root;
42197 -       int i = 0;
42198 +       int i, ret = -ENOMEM;
42199  
42200         root = (struct dscc4_dev_priv *)
42201                 kmalloc(dev_per_card*sizeof(*root), GFP_KERNEL);
42202 @@ -900,7 +905,8 @@ static int dscc4_found1(struct pci_dev *
42203                 hdlc->xmit = dscc4_start_xmit;
42204                 hdlc->attach = dscc4_hdlc_attach;
42205  
42206 -               if (register_hdlc_device(hdlc)) {
42207 +               ret = register_hdlc_device(hdlc);
42208 +               if (ret < 0) {
42209                         printk(KERN_ERR "%s: unable to register\n", DRV_NAME);
42210                         goto err_unregister;
42211                 }
42212 @@ -908,17 +914,20 @@ static int dscc4_found1(struct pci_dev *
42213                 dscc4_init_registers(dpriv, d);
42214                 dpriv->parity = PARITY_CRC16_PR0_CCITT;
42215                 dpriv->encoding = ENCODING_NRZ;
42216 -               if (dscc4_init_ring(d)) {
42217 +
42218 +               ret = dscc4_init_ring(d);
42219 +               if (ret < 0) {
42220                         unregister_hdlc_device(hdlc);
42221                         goto err_unregister;
42222                 }
42223         }
42224 -       if (dscc4_set_quartz(root, quartz) < 0)
42225 +       ret = dscc4_set_quartz(root, quartz);
42226 +       if (ret < 0)
42227                 goto err_unregister;
42228         ppriv->root = root;
42229         spin_lock_init(&ppriv->lock);
42230         pci_set_drvdata(pdev, ppriv);
42231 -       return 0;
42232 +       return ret;
42233  
42234  err_unregister:
42235         while (--i >= 0) {
42236 @@ -929,7 +938,7 @@ err_unregister:
42237  err_free_dev:
42238         kfree(root);
42239  err_out:
42240 -       return -1;
42241 +       return ret;
42242  };
42243  
42244  /* FIXME: get rid of the unneeded code */
42245 @@ -1092,9 +1101,7 @@ done:
42246  
42247  err_disable_scc_events:
42248         scc_writel(0xffffffff, dpriv, dev, IMR);
42249 -err_free_ring:
42250         scc_patchl(PowerUp | Vis, 0, dpriv, dev, CCR0);
42251 -       dscc4_release_ring(dpriv);
42252  err_out:
42253         hdlc_close(hdlc);
42254  err:
42255 @@ -1160,7 +1167,6 @@ static int dscc4_close(struct net_device
42256         dpriv->flags |= FakeReset;
42257  
42258         hdlc_close(hdlc);
42259 -       dscc4_release_ring(dpriv);
42260  
42261         return 0;
42262  }
42263 @@ -2006,6 +2012,7 @@ static int dscc4_hdlc_attach(hdlc_device
42264         return 0;
42265  }
42266  
42267 +#ifndef MODULE
42268  static int __init dscc4_setup(char *str)
42269  {
42270         int *args[] = { &debug, &quartz, NULL }, **p = args;
42271 @@ -2016,6 +2023,7 @@ static int __init dscc4_setup(char *str)
42272  }
42273  
42274  __setup("dscc4.setup=", dscc4_setup);
42275 +#endif
42276  
42277  static struct pci_device_id dscc4_pci_tbl[] = {
42278         { PCI_VENDOR_ID_SIEMENS, PCI_DEVICE_ID_SIEMENS_DSCC4,
42279 --- linux-2.6.0-test6/drivers/net/wan/sbni.c    2003-09-27 18:57:45.000000000 -0700
42280 +++ 25/drivers/net/wan/sbni.c   2003-10-05 00:33:24.000000000 -0700
42281 @@ -1300,12 +1300,9 @@ sbni_ioctl( struct net_device  *dev,  st
42282    
42283         switch( cmd ) {
42284         case  SIOCDEVGETINSTATS :
42285 -               error = verify_area( VERIFY_WRITE, ifr->ifr_data,
42286 -                                    sizeof(struct sbni_in_stats) );
42287 -               if( !error )
42288 -                       if (copy_to_user( ifr->ifr_data, &nl->in_stats,
42289 -                                     sizeof(struct sbni_in_stats) ))
42290 -                               return -EFAULT;
42291 +               if (copy_to_user( ifr->ifr_data, &nl->in_stats,
42292 +                                       sizeof(struct sbni_in_stats) ))
42293 +                       error = -EFAULT;
42294                 break;
42295  
42296         case  SIOCDEVRESINSTATS :
42297 @@ -1321,11 +1318,8 @@ sbni_ioctl( struct net_device  *dev,  st
42298                 flags.rxl       = nl->cur_rxl_index;
42299                 flags.fixed_rxl = nl->delta_rxl == 0;
42300  
42301 -               error = verify_area( VERIFY_WRITE, ifr->ifr_data,
42302 -                                    sizeof flags );
42303 -               if( !error )
42304 -                       if (copy_to_user( ifr->ifr_data, &flags, sizeof flags ))
42305 -                               return -EFAULT;
42306 +               if (copy_to_user( ifr->ifr_data, &flags, sizeof flags ))
42307 +                       error = -EFAULT;
42308                 break;
42309  
42310         case  SIOCDEVSHWSTATE :
42311 @@ -1353,10 +1347,6 @@ sbni_ioctl( struct net_device  *dev,  st
42312                 if( current->euid != 0 )        /* root only */
42313                         return  -EPERM;
42314  
42315 -               if( (error = verify_area( VERIFY_READ, ifr->ifr_data,
42316 -                                         sizeof slave_name )) != 0 )
42317 -                       return  error;
42318 -
42319                 if (copy_from_user( slave_name, ifr->ifr_data, sizeof slave_name ))
42320                         return -EFAULT;
42321                 slave_dev = dev_get_by_name( slave_name );
42322 --- linux-2.6.0-test6/drivers/net/wan/syncppp.c 2003-09-27 18:57:45.000000000 -0700
42323 +++ 25/drivers/net/wan/syncppp.c        2003-10-05 00:33:24.000000000 -0700
42324 @@ -236,7 +236,7 @@ void sppp_input (struct net_device *dev,
42325                 sp->ipkts++;
42326         }
42327  
42328 -       if (skb->len <= PPP_HEADER_LEN) {
42329 +       if (!pskb_may_pull(skb, PPP_HEADER_LEN)) {
42330                 /* Too small packet, drop it. */
42331                 if (sp->pp_flags & PP_DEBUG)
42332                         printk (KERN_DEBUG "%s: input packet is too small, %d bytes\n",
42333 @@ -473,7 +473,7 @@ static void sppp_lcp_input (struct sppp 
42334         u8 *p, opt[6];
42335         u32 rmagic;
42336  
42337 -       if (len < 4) {
42338 +       if (!pskb_may_pull(skb, sizeof(struct lcp_header))) {
42339                 if (sp->pp_flags & PP_DEBUG)
42340                         printk (KERN_WARNING "%s: invalid lcp packet length: %d bytes\n",
42341                                 dev->name, len);
42342 @@ -707,7 +707,9 @@ static void sppp_cisco_input (struct spp
42343         struct cisco_packet *h;
42344         struct net_device *dev = sp->pp_if;
42345  
42346 -       if (skb->len != CISCO_PACKET_LEN && skb->len != CISCO_BIG_PACKET_LEN) {
42347 +       if (!pskb_may_pull(skb, sizeof(struct cisco_packet))
42348 +           || (skb->len != CISCO_PACKET_LEN
42349 +               && skb->len != CISCO_BIG_PACKET_LEN)) {
42350                 if (sp->pp_flags & PP_DEBUG)
42351                         printk (KERN_WARNING "%s: invalid cisco packet length: %d bytes\n",
42352                                 dev->name,  skb->len);
42353 @@ -1211,8 +1213,7 @@ static void sppp_ipcp_input (struct sppp
42354         struct net_device *dev = sp->pp_if;
42355         int len = skb->len;
42356  
42357 -       if (len < 4) 
42358 -       {
42359 +       if (!pskb_may_pull(skb, sizeof(struct lcp_header))) {
42360                 if (sp->pp_flags & PP_DEBUG)
42361                         printk (KERN_WARNING "%s: invalid ipcp packet length: %d bytes\n",
42362                                 dev->name,  len);
42363 --- linux-2.6.0-test6/drivers/net/wireless/arlan-main.c 2003-09-27 18:57:45.000000000 -0700
42364 +++ 25/drivers/net/wireless/arlan-main.c        2003-10-05 00:33:24.000000000 -0700
42365 @@ -5,7 +5,6 @@
42366   * This module provides support for the Arlan 655 card made by Aironet
42367   */
42368  
42369 -#include <linux/version.h>
42370  #include <linux/config.h>
42371  #include "arlan.h"
42372  
42373 @@ -721,9 +720,9 @@ static int arlan_hw_tx(struct net_device
42374         else
42375         {
42376                 netif_stop_queue (dev);
42377 -               return -1;
42378                 IFDEBUG(ARLAN_DEBUG_TX_CHAIN)
42379                         printk(KERN_ERR "TX TAIL & HEAD full, return, tailStart %d headEnd %d\n", tailStarts, headEnds);
42380 +               return -1;
42381         }
42382         priv->out_bytes += length;
42383         priv->out_bytes10 += length;
42384 @@ -1881,6 +1880,8 @@ int __init arlan_probe(struct net_device
42385  
42386  #ifdef  MODULE
42387  
42388 +static int probe = probeUNKNOWN;
42389 +
42390  static int __init arlan_find_devices(void)
42391  {
42392         int m;
42393 --- linux-2.6.0-test6/drivers/parisc/superio.c  2003-08-08 22:55:12.000000000 -0700
42394 +++ 25/drivers/parisc/superio.c 2003-10-05 00:33:24.000000000 -0700
42395 @@ -530,11 +530,6 @@ static struct pci_driver superio_driver 
42396  
42397  static int __init superio_modinit(void)
42398  {
42399 -#ifdef CONFIG_SERIAL_8250
42400 -       extern int serial8250_init(void);
42401 -       serial8250_init();
42402 -#endif
42403 -
42404         return pci_module_init(&superio_driver);
42405  }
42406  
42407 @@ -543,5 +538,10 @@ static void __exit superio_exit(void)
42408         pci_unregister_driver(&superio_driver);
42409  }
42410  
42411 -module_init(superio_modinit);
42412 +/* Make late initcall to ensure the serial and tty layers are initialised
42413 + * before we start superio.
42414 + *
42415 + * FIXME: does this break the superio console?
42416 + */
42417 +late_initcall(superio_modinit);
42418  module_exit(superio_exit);
42419 --- linux-2.6.0-test6/drivers/pci/hotplug/cpqphp.h      2003-09-27 18:57:45.000000000 -0700
42420 +++ 25/drivers/pci/hotplug/cpqphp.h     2003-10-05 00:33:24.000000000 -0700
42421 @@ -766,7 +766,6 @@ static inline int wait_for_ctrl_irq (str
42422         set_current_state(TASK_INTERRUPTIBLE);
42423         /* Sleep for up to 1 second to wait for the LED to change. */
42424         schedule_timeout(1*HZ);
42425 -       set_current_state(TASK_RUNNING);
42426         remove_wait_queue(&ctrl->queue, &wait);
42427         if (signal_pending(current))
42428                 retval =  -EINTR;
42429 --- linux-2.6.0-test6/drivers/pci/hotplug/pci_hotplug_core.c    2003-09-27 18:57:45.000000000 -0700
42430 +++ 25/drivers/pci/hotplug/pci_hotplug_core.c   2003-10-05 00:33:24.000000000 -0700
42431 @@ -69,7 +69,7 @@ static int debug;
42432  
42433  static LIST_HEAD(pci_hotplug_slot_list);
42434  
42435 -static struct subsystem hotplug_slots_subsys;
42436 +struct subsystem pci_hotplug_slots_subsys;
42437  
42438  static ssize_t hotplug_slot_attr_show(struct kobject *kobj,
42439                 struct attribute *attr, char *buf)
42440 @@ -104,7 +104,7 @@ static struct kobj_type hotplug_slot_kty
42441         .release = &hotplug_slot_release,
42442  };
42443  
42444 -static decl_subsys(hotplug_slots, &hotplug_slot_ktype, NULL);
42445 +decl_subsys(pci_hotplug_slots, &hotplug_slot_ktype, NULL);
42446  
42447  
42448  /* these strings match up with the values in pci_bus_speed */
42449 @@ -534,7 +534,7 @@ int pci_hp_register (struct hotplug_slot
42450                 return -EINVAL;
42451  
42452         strlcpy(slot->kobj.name, slot->name, KOBJ_NAME_LEN);
42453 -       kobj_set_kset_s(slot, hotplug_slots_subsys);
42454 +       kobj_set_kset_s(slot, pci_hotplug_slots_subsys);
42455  
42456         /* this can fail if we have already registered a slot with the same name */
42457         if (kobject_register(&slot->kobj)) {
42458 @@ -629,8 +629,8 @@ static int __init pci_hotplug_init (void
42459  {
42460         int result;
42461  
42462 -       kset_set_kset_s(&hotplug_slots_subsys, pci_bus_type.subsys);
42463 -       result = subsystem_register(&hotplug_slots_subsys);
42464 +       kset_set_kset_s(&pci_hotplug_slots_subsys, pci_bus_type.subsys);
42465 +       result = subsystem_register(&pci_hotplug_slots_subsys);
42466         if (result) {
42467                 err("Register subsys with error %d\n", result);
42468                 goto exit;
42469 @@ -645,7 +645,7 @@ static int __init pci_hotplug_init (void
42470         goto exit;
42471         
42472  err_subsys:
42473 -       subsystem_unregister(&hotplug_slots_subsys);
42474 +       subsystem_unregister(&pci_hotplug_slots_subsys);
42475  exit:
42476         return result;
42477  }
42478 @@ -653,7 +653,7 @@ exit:
42479  static void __exit pci_hotplug_exit (void)
42480  {
42481         cpci_hotplug_exit();
42482 -       subsystem_unregister(&hotplug_slots_subsys);
42483 +       subsystem_unregister(&pci_hotplug_slots_subsys);
42484  }
42485  
42486  module_init(pci_hotplug_init);
42487 @@ -665,6 +665,7 @@ MODULE_LICENSE("GPL");
42488  MODULE_PARM(debug, "i");
42489  MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
42490  
42491 +EXPORT_SYMBOL_GPL(pci_hotplug_slots_subsys);
42492  EXPORT_SYMBOL_GPL(pci_hp_register);
42493  EXPORT_SYMBOL_GPL(pci_hp_deregister);
42494  EXPORT_SYMBOL_GPL(pci_hp_change_slot_info);
42495 --- linux-2.6.0-test6/drivers/pci/hotplug/pci_hotplug.h 2003-09-27 18:57:45.000000000 -0700
42496 +++ 25/drivers/pci/hotplug/pci_hotplug.h        2003-10-05 00:33:24.000000000 -0700
42497 @@ -145,6 +145,7 @@ extern int pci_hp_register          (struct hotp
42498  extern int pci_hp_deregister           (struct hotplug_slot *slot);
42499  extern int pci_hp_change_slot_info     (struct hotplug_slot *slot,
42500                                          struct hotplug_slot_info *info);
42501 +extern struct subsystem pci_hotplug_slots_subsys;
42502  
42503  #endif
42504  
42505 --- linux-2.6.0-test6/drivers/pci/Makefile      2003-07-27 12:14:39.000000000 -0700
42506 +++ 25/drivers/pci/Makefile     2003-10-05 00:36:20.000000000 -0700
42507 @@ -4,7 +4,6 @@
42508  
42509  obj-y          += access.o bus.o probe.o remove.o pci.o pool.o quirks.o \
42510                         names.o pci-driver.o search.o pci-sysfs.o
42511 -obj-$(CONFIG_PM)  += power.o
42512  obj-$(CONFIG_PROC_FS) += proc.o
42513  
42514  ifndef CONFIG_SPARC64
42515 @@ -28,6 +27,7 @@ obj-$(CONFIG_PPC64) += setup-bus.o
42516  obj-$(CONFIG_SGI_IP27) += setup-irq.o
42517  obj-$(CONFIG_SGI_IP32) += setup-irq.o
42518  obj-$(CONFIG_X86_VISWS) += setup-irq.o
42519 +obj-$(CONFIG_PCI_USE_VECTOR) += msi.o
42520  
42521  # Cardbus & CompactPCI use setup-bus
42522  obj-$(CONFIG_HOTPLUG) += setup-bus.o
42523 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
42524 +++ 25/drivers/pci/msi.c        2003-10-05 00:36:21.000000000 -0700
42525 @@ -0,0 +1,1062 @@
42526 +/*
42527 + * linux/drivers/pci/msi.c
42528 + */
42529 +
42530 +#include <linux/mm.h>
42531 +#include <linux/irq.h>
42532 +#include <linux/interrupt.h>
42533 +#include <linux/init.h>
42534 +#include <linux/config.h>
42535 +#include <linux/ioport.h>
42536 +#include <linux/smp_lock.h>
42537 +#include <linux/pci.h>
42538 +#include <linux/proc_fs.h>
42539 +#include <linux/acpi.h>
42540 +
42541 +#include <asm/errno.h>
42542 +#include <asm/io.h>
42543 +#include <asm/smp.h>
42544 +#include <asm/desc.h>
42545 +#include <asm/io_apic.h>
42546 +#include <mach_apic.h>
42547 +
42548 +#include <linux/pci_msi.h>
42549 +
42550 +_DEFINE_DBG_BUFFER
42551 +
42552 +static spinlock_t msi_lock = SPIN_LOCK_UNLOCKED;
42553 +static struct msi_desc* msi_desc[NR_IRQS] = { [0 ... NR_IRQS-1] = NULL };
42554 +static kmem_cache_t* msi_cachep;
42555 +
42556 +static int pci_msi_enable = 1;
42557 +static int nr_alloc_vectors = 0;
42558 +static int nr_released_vectors = 0;
42559 +static int nr_reserved_vectors = NR_HP_RESERVED_VECTORS;
42560 +static int nr_msix_devices = 0;
42561 +
42562 +#ifndef CONFIG_X86_IO_APIC
42563 +int vector_irq[NR_IRQS] = { [0 ... NR_IRQS -1] = -1};
42564 +int irq_vector[NR_IRQS] = { FIRST_DEVICE_VECTOR , 0 };
42565 +#endif
42566 +
42567 +static void msi_cache_ctor(void *p, kmem_cache_t *cache, unsigned long flags)
42568 +{
42569 +       memset(p, 0, NR_IRQS * sizeof(struct msi_desc));
42570 +}
42571 +
42572 +static int msi_cache_init(void)
42573 +{
42574 +       msi_cachep = kmem_cache_create("msi_cache",
42575 +                       NR_IRQS * sizeof(struct msi_desc),
42576 +                       0, SLAB_HWCACHE_ALIGN, msi_cache_ctor, NULL);
42577 +       if (!msi_cachep)
42578 +               return -ENOMEM;
42579 +
42580 +       return 0;
42581 +}
42582 +
42583 +static void msi_set_mask_bit(unsigned int vector, int flag)
42584 +{
42585 +       struct msi_desc *entry;
42586 +
42587 +       entry = (struct msi_desc *)msi_desc[vector];
42588 +       if (!entry || !entry->dev || !entry->mask_base)
42589 +               return;
42590 +       switch (entry->msi_attrib.type) {
42591 +       case PCI_CAP_ID_MSI:
42592 +       {
42593 +               int             pos;
42594 +               unsigned int    mask_bits;
42595 +
42596 +               pos = entry->mask_base;
42597 +               entry->dev->bus->ops->read(entry->dev->bus, entry->dev->devfn,
42598 +                               pos, 4, &mask_bits);
42599 +               mask_bits &= ~(1);
42600 +               mask_bits |= flag;
42601 +               entry->dev->bus->ops->write(entry->dev->bus, entry->dev->devfn,
42602 +                               pos, 4, mask_bits);
42603 +               break;
42604 +       }
42605 +       case PCI_CAP_ID_MSIX:
42606 +       {
42607 +               int offset = entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE +
42608 +                       PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET;
42609 +               writel(flag, entry->mask_base + offset);
42610 +               break;
42611 +       }
42612 +       default:
42613 +               break;
42614 +       }
42615 +}
42616 +
42617 +#ifdef CONFIG_SMP
42618 +static void set_msi_affinity(unsigned int vector, unsigned long cpu_mask)
42619 +{
42620 +       struct msi_desc *entry;
42621 +       struct msg_address address;
42622 +       unsigned int dest_id;
42623 +
42624 +       entry = (struct msi_desc *)msi_desc[vector];
42625 +       if (!entry || !entry->dev)
42626 +               return;
42627 +
42628 +       switch (entry->msi_attrib.type) {
42629 +       case PCI_CAP_ID_MSI:
42630 +       {
42631 +               int pos;
42632 +
42633 +               if (!(pos = pci_find_capability(entry->dev, PCI_CAP_ID_MSI)))
42634 +                       return;
42635 +
42636 +               entry->dev->bus->ops->read(entry->dev->bus, entry->dev->devfn,
42637 +                       msi_lower_address_reg(pos), 4,
42638 +                       &address.lo_address.value);
42639 +               dest_id = (address.lo_address.u.dest_id &
42640 +                       MSI_ADDRESS_HEADER_MASK) |
42641 +                       (cpu_mask_to_apicid(cpu_mask) << MSI_TARGET_CPU_SHIFT);
42642 +               address.lo_address.u.dest_id = dest_id;
42643 +               entry->msi_attrib.current_cpu = cpu_mask_to_apicid(cpu_mask);
42644 +               entry->dev->bus->ops->write(entry->dev->bus, entry->dev->devfn,
42645 +                       msi_lower_address_reg(pos), 4,
42646 +                       address.lo_address.value);
42647 +               break;
42648 +       }
42649 +       case PCI_CAP_ID_MSIX:
42650 +       {
42651 +               int offset = entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE +
42652 +                       PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET;
42653 +
42654 +               address.lo_address.value = readl(entry->mask_base + offset);
42655 +               dest_id = (address.lo_address.u.dest_id &
42656 +                       MSI_ADDRESS_HEADER_MASK) |
42657 +                       (cpu_mask_to_apicid(cpu_mask) << MSI_TARGET_CPU_SHIFT);
42658 +               address.lo_address.u.dest_id = dest_id;
42659 +               entry->msi_attrib.current_cpu = cpu_mask_to_apicid(cpu_mask);
42660 +               writel(address.lo_address.value, entry->mask_base + offset);
42661 +               break;
42662 +       }
42663 +       default:
42664 +               break;
42665 +       }
42666 +}
42667 +
42668 +static inline void move_msi(int vector)
42669 +{
42670 +       if (unlikely(pending_irq_balance_cpumask[vector])) {
42671 +               set_msi_affinity(vector, pending_irq_balance_cpumask[vector]);
42672 +               pending_irq_balance_cpumask[vector] = 0;
42673 +       }
42674 +}
42675 +#endif
42676 +
42677 +static void mask_MSI_irq(unsigned int vector)
42678 +{
42679 +       msi_set_mask_bit(vector, 1);
42680 +}
42681 +
42682 +static void unmask_MSI_irq(unsigned int vector)
42683 +{
42684 +       msi_set_mask_bit(vector, 0);
42685 +}
42686 +
42687 +static unsigned int startup_msi_irq_wo_maskbit(unsigned int vector)
42688 +{
42689 +       return 0;       /* never anything pending */
42690 +}
42691 +
42692 +static void pci_disable_msi(unsigned int vector);
42693 +static void shutdown_msi_irq(unsigned int vector)
42694 +{
42695 +       pci_disable_msi(vector);
42696 +}
42697 +
42698 +#define shutdown_msi_irq_wo_maskbit    shutdown_msi_irq
42699 +static void enable_msi_irq_wo_maskbit(unsigned int vector) {}
42700 +static void disable_msi_irq_wo_maskbit(unsigned int vector) {}
42701 +static void ack_msi_irq_wo_maskbit(unsigned int vector) {}
42702 +static void end_msi_irq_wo_maskbit(unsigned int vector)
42703 +{
42704 +       move_msi(vector);
42705 +       ack_APIC_irq();
42706 +}
42707 +
42708 +static unsigned int startup_msi_irq_w_maskbit(unsigned int vector)
42709 +{
42710 +       unmask_MSI_irq(vector);
42711 +       return 0;       /* never anything pending */
42712 +}
42713 +
42714 +#define shutdown_msi_irq_w_maskbit     shutdown_msi_irq
42715 +#define enable_msi_irq_w_maskbit       unmask_MSI_irq
42716 +#define disable_msi_irq_w_maskbit      mask_MSI_irq
42717 +#define ack_msi_irq_w_maskbit          mask_MSI_irq
42718 +
42719 +static void end_msi_irq_w_maskbit(unsigned int vector)
42720 +{
42721 +       move_msi(vector);
42722 +       unmask_MSI_irq(vector);
42723 +       ack_APIC_irq();
42724 +}
42725 +
42726 +/*
42727 + * Interrupt Type for MSI-X PCI/PCI-X/PCI-Express Devices,
42728 + * which implement the MSI-X Capability Structure.
42729 + */
42730 +static struct hw_interrupt_type msix_irq_type = {
42731 +       .typename       = "PCI MSI-X",
42732 +       .startup        = startup_msi_irq_w_maskbit,
42733 +       .shutdown       = shutdown_msi_irq_w_maskbit,
42734 +       .enable         = enable_msi_irq_w_maskbit,
42735 +       .disable        = disable_msi_irq_w_maskbit,
42736 +       .ack            = ack_msi_irq_w_maskbit,
42737 +       .end            = end_msi_irq_w_maskbit,
42738 +       .set_affinity   = set_msi_irq_affinity
42739 +};
42740 +
42741 +/*
42742 + * Interrupt Type for MSI PCI/PCI-X/PCI-Express Devices,
42743 + * which implement the MSI Capability Structure with
42744 + * Mask-and-Pending Bits.
42745 + */
42746 +static struct hw_interrupt_type msi_irq_w_maskbit_type = {
42747 +       .typename       = "PCI MSI",
42748 +       .startup        = startup_msi_irq_w_maskbit,
42749 +       .shutdown       = shutdown_msi_irq_w_maskbit,
42750 +       .enable         = enable_msi_irq_w_maskbit,
42751 +       .disable        = disable_msi_irq_w_maskbit,
42752 +       .ack            = ack_msi_irq_w_maskbit,
42753 +       .end            = end_msi_irq_w_maskbit,
42754 +       .set_affinity   = set_msi_irq_affinity
42755 +};
42756 +
42757 +/*
42758 + * Interrupt Type for MSI PCI/PCI-X/PCI-Express Devices,
42759 + * which implement the MSI Capability Structure without
42760 + * Mask-and-Pending Bits.
42761 + */
42762 +static struct hw_interrupt_type msi_irq_wo_maskbit_type = {
42763 +       .typename       = "PCI MSI",
42764 +       .startup        = startup_msi_irq_wo_maskbit,
42765 +       .shutdown       = shutdown_msi_irq_wo_maskbit,
42766 +       .enable         = enable_msi_irq_wo_maskbit,
42767 +       .disable        = disable_msi_irq_wo_maskbit,
42768 +       .ack            = ack_msi_irq_wo_maskbit,
42769 +       .end            = end_msi_irq_wo_maskbit,
42770 +       .set_affinity   = set_msi_irq_affinity
42771 +};
42772 +
42773 +static void msi_data_init(struct msg_data *msi_data,
42774 +                         unsigned int vector)
42775 +{
42776 +       memset(msi_data, 0, sizeof(struct msg_data));
42777 +       msi_data->vector = (u8)vector;
42778 +       msi_data->delivery_mode = MSI_DELIVERY_MODE;
42779 +       msi_data->level = MSI_LEVEL_MODE;
42780 +       msi_data->trigger = MSI_TRIGGER_MODE;
42781 +}
42782 +
42783 +static void msi_address_init(struct msg_address *msi_address)
42784 +{
42785 +       unsigned int    dest_id;
42786 +
42787 +       memset(msi_address, 0, sizeof(struct msg_address));
42788 +       msi_address->hi_address = (u32)0;
42789 +       dest_id = (MSI_ADDRESS_HEADER << MSI_ADDRESS_HEADER_SHIFT) |
42790 +                (MSI_TARGET_CPU << MSI_TARGET_CPU_SHIFT);
42791 +       msi_address->lo_address.u.dest_mode = MSI_LOGICAL_MODE;
42792 +       msi_address->lo_address.u.redirection_hint = MSI_REDIRECTION_HINT_MODE;
42793 +       msi_address->lo_address.u.dest_id = dest_id;
42794 +}
42795 +
42796 +static int pci_vector_resources(void)
42797 +{
42798 +       static int res = -EINVAL;
42799 +       int nr_free_vectors;
42800 +
42801 +       if (res == -EINVAL) {
42802 +               int i, repeat;
42803 +               for (i = NR_REPEATS; i > 0; i--) {
42804 +                       if ((FIRST_DEVICE_VECTOR + i * 8) > FIRST_SYSTEM_VECTOR)
42805 +                               continue;
42806 +                       break;
42807 +               }
42808 +               i++;
42809 +               repeat = (FIRST_SYSTEM_VECTOR - FIRST_DEVICE_VECTOR)/i;
42810 +               res = i * repeat - NR_RESERVED_VECTORS + 1;
42811 +       }
42812 +
42813 +       nr_free_vectors = res + nr_released_vectors - nr_alloc_vectors;
42814 +
42815 +       return nr_free_vectors;
42816 +}
42817 +
42818 +int assign_irq_vector(int irq)
42819 +{
42820 +       static int current_vector = FIRST_DEVICE_VECTOR, offset = 0;
42821 +
42822 +       if (irq != MSI_AUTO && IO_APIC_VECTOR(irq) > 0)
42823 +               return IO_APIC_VECTOR(irq);
42824 +next:
42825 +       current_vector += 8;
42826 +       if (current_vector == SYSCALL_VECTOR)
42827 +               goto next;
42828 +
42829 +       if (current_vector > FIRST_SYSTEM_VECTOR) {
42830 +               offset++;
42831 +               current_vector = FIRST_DEVICE_VECTOR + offset;
42832 +       }
42833 +
42834 +       if (current_vector == FIRST_SYSTEM_VECTOR)
42835 +               return -ENOSPC;
42836 +
42837 +       vector_irq[current_vector] = irq;
42838 +       if (irq != MSI_AUTO)
42839 +               IO_APIC_VECTOR(irq) = current_vector;
42840 +
42841 +       nr_alloc_vectors++;
42842 +
42843 +       return current_vector;
42844 +}
42845 +
42846 +static int assign_msi_vector(void)
42847 +{
42848 +       static int new_vector_avail = 1;
42849 +       int vector;
42850 +       unsigned long flags;
42851 +
42852 +       /*
42853 +        * msi_lock is provided to ensure that successful allocation of MSI
42854 +        * vector is assigned unique among drivers.
42855 +        */
42856 +       spin_lock_irqsave(&msi_lock, flags);
42857 +       if (!(pci_vector_resources() > 0)) {
42858 +               spin_unlock_irqrestore(&msi_lock, flags);
42859 +               return -EBUSY;
42860 +       }
42861 +
42862 +       if (!new_vector_avail) {
42863 +               /*
42864 +                * vector_irq[] = -1 indicates that this specific vector is:
42865 +                * - assigned for MSI (since MSI have no associated IRQ) or
42866 +                * - assigned for legacy if less than 16, or
42867 +                * - having no corresponding 1:1 vector-to-IOxAPIC IRQ mapping
42868 +                * vector_irq[] = 0 indicates that this vector, previously
42869 +                * assigned for MSI, is freed by hotplug removed operations.
42870 +                * This vector will be reused for any subsequent hotplug added
42871 +                * operations.
42872 +                * vector_irq[] > 0 indicates that this vector is assigned for
42873 +                * IOxAPIC IRQs. This vector and its value provides a 1-to-1
42874 +                * vector-to-IOxAPIC IRQ mapping.
42875 +                */
42876 +               for (vector = FIRST_DEVICE_VECTOR; vector < NR_IRQS; vector++) {
42877 +                       if (vector_irq[vector] != 0)
42878 +                               continue;
42879 +                       vector_irq[vector] = -1;
42880 +                       nr_released_vectors--;
42881 +                       spin_unlock_irqrestore(&msi_lock, flags);
42882 +                       return vector;
42883 +               }
42884 +               spin_unlock_irqrestore(&msi_lock, flags);
42885 +               return -EBUSY;
42886 +       }
42887 +
42888 +       vector = assign_irq_vector(MSI_AUTO);
42889 +       if (vector  == (FIRST_SYSTEM_VECTOR - 8))
42890 +               new_vector_avail = 0;
42891 +
42892 +       spin_unlock_irqrestore(&msi_lock, flags);
42893 +       return vector;
42894 +}
42895 +
42896 +static int get_new_vector(void)
42897 +{
42898 +       int vector;
42899 +
42900 +       if ((vector = assign_msi_vector()) > 0)
42901 +               set_intr_gate(vector, interrupt[vector]);
42902 +
42903 +       return vector;
42904 +}
42905 +
42906 +static int msi_init(void)
42907 +{
42908 +       static int status = -ENOMEM;
42909 +
42910 +       if (!status)
42911 +               return status;
42912 +
42913 +       if ((status = msi_cache_init()) < 0) {
42914 +               pci_msi_enable = 0;
42915 +               printk(KERN_INFO "WARNING: MSI INIT FAILURE\n");
42916 +               return status;
42917 +       }
42918 +       printk(KERN_INFO "MSI INIT SUCCESS\n");
42919 +
42920 +       return status;
42921 +}
42922 +
42923 +static int get_msi_vector(struct pci_dev *dev)
42924 +{
42925 +       return get_new_vector();
42926 +}
42927 +
42928 +static struct msi_desc* alloc_msi_entry(void)
42929 +{
42930 +       struct msi_desc *entry;
42931 +
42932 +       entry = (struct msi_desc*) kmem_cache_alloc(msi_cachep, SLAB_KERNEL);
42933 +       if (!entry)
42934 +               return NULL;
42935 +
42936 +       memset(entry, 0, sizeof(struct msi_desc));
42937 +       entry->link.tail = entry->link.head = 0;        /* single message */
42938 +       entry->dev = NULL;
42939 +
42940 +       return entry;
42941 +}
42942 +
42943 +static void attach_msi_entry(struct msi_desc *entry, int vector)
42944 +{
42945 +       unsigned long flags;
42946 +
42947 +       spin_lock_irqsave(&msi_lock, flags);
42948 +       msi_desc[vector] = entry;
42949 +       spin_unlock_irqrestore(&msi_lock, flags);
42950 +}
42951 +
42952 +static void irq_handler_init(int cap_id, int pos, int mask)
42953 +{
42954 +       spin_lock(&irq_desc[pos].lock);
42955 +       if (cap_id == PCI_CAP_ID_MSIX)
42956 +               irq_desc[pos].handler = &msix_irq_type;
42957 +       else {
42958 +               if (!mask)
42959 +                       irq_desc[pos].handler = &msi_irq_wo_maskbit_type;
42960 +               else
42961 +                       irq_desc[pos].handler = &msi_irq_w_maskbit_type;
42962 +       }
42963 +       spin_unlock(&irq_desc[pos].lock);
42964 +}
42965 +
42966 +static void enable_msi_mode(struct pci_dev *dev, int pos, int type)
42967 +{
42968 +       u32 control;
42969 +
42970 +       dev->bus->ops->read(dev->bus, dev->devfn,
42971 +               msi_control_reg(pos), 2, &control);
42972 +       if (type == PCI_CAP_ID_MSI) {
42973 +               /* Set enabled bits to single MSI & enable MSI_enable bit */
42974 +               msi_enable(control, 1);
42975 +               dev->bus->ops->write(dev->bus, dev->devfn,
42976 +                       msi_control_reg(pos), 2, control);
42977 +       } else {
42978 +               msix_enable(control);
42979 +               dev->bus->ops->write(dev->bus, dev->devfn,
42980 +                       msi_control_reg(pos), 2, control);
42981 +       }
42982 +       if (pci_find_capability(dev, PCI_CAP_ID_EXP)) {
42983 +               /* PCI Express Endpoint device detected */
42984 +               u32 cmd;
42985 +               dev->bus->ops->read(dev->bus, dev->devfn, PCI_COMMAND, 2, &cmd);
42986 +               cmd |= PCI_COMMAND_INTX_DISABLE;
42987 +               dev->bus->ops->write(dev->bus, dev->devfn, PCI_COMMAND, 2, cmd);
42988 +       }
42989 +}
42990 +
42991 +static void disable_msi_mode(struct pci_dev *dev, int pos, int type)
42992 +{
42993 +       u32 control;
42994 +
42995 +       dev->bus->ops->read(dev->bus, dev->devfn,
42996 +               msi_control_reg(pos), 2, &control);
42997 +       if (type == PCI_CAP_ID_MSI) {
42998 +               /* Set enabled bits to single MSI & enable MSI_enable bit */
42999 +               msi_disable(control);
43000 +               dev->bus->ops->write(dev->bus, dev->devfn,
43001 +                       msi_control_reg(pos), 2, control);
43002 +       } else {
43003 +               msix_disable(control);
43004 +               dev->bus->ops->write(dev->bus, dev->devfn,
43005 +                       msi_control_reg(pos), 2, control);
43006 +       }
43007 +       if (pci_find_capability(dev, PCI_CAP_ID_EXP)) {
43008 +               /* PCI Express Endpoint device detected */
43009 +               u32 cmd;
43010 +               dev->bus->ops->read(dev->bus, dev->devfn, PCI_COMMAND, 2, &cmd);
43011 +               cmd &= ~PCI_COMMAND_INTX_DISABLE;
43012 +               dev->bus->ops->write(dev->bus, dev->devfn, PCI_COMMAND, 2, cmd);
43013 +       }
43014 +}
43015 +
43016 +static int msi_lookup_vector(struct pci_dev *dev)
43017 +{
43018 +       int vector;
43019 +       unsigned long flags;
43020 +
43021 +       spin_lock_irqsave(&msi_lock, flags);
43022 +       for (vector = FIRST_DEVICE_VECTOR; vector < NR_IRQS; vector++) {
43023 +               if (!msi_desc[vector] || msi_desc[vector]->dev != dev ||
43024 +                       msi_desc[vector]->msi_attrib.entry_nr ||
43025 +                       msi_desc[vector]->msi_attrib.default_vector != dev->irq)
43026 +                       continue;       /* not entry 0, skip */
43027 +               spin_unlock_irqrestore(&msi_lock, flags);
43028 +               /* This pre-assigned entry-0 MSI vector for this device
43029 +                  already exits. Override dev->irq with this vector */
43030 +               dev->irq = vector;
43031 +               return 0;
43032 +       }
43033 +       spin_unlock_irqrestore(&msi_lock, flags);
43034 +
43035 +       return -EACCES;
43036 +}
43037 +
43038 +void pci_scan_msi_device(struct pci_dev *dev)
43039 +{
43040 +       if (!dev)
43041 +               return;
43042 +
43043 +       if (pci_find_capability(dev, PCI_CAP_ID_MSIX) > 0) {
43044 +               nr_reserved_vectors++;
43045 +               nr_msix_devices++;
43046 +       } else if (pci_find_capability(dev, PCI_CAP_ID_MSI) > 0)
43047 +               nr_reserved_vectors++;
43048 +}
43049 +
43050 +/**
43051 + * msi_capability_init - configure device's MSI capability structure
43052 + * @dev: pointer to the pci_dev data structure of MSI device function
43053 + *
43054 + * Setup the MSI capability structure of device funtion with a single
43055 + * MSI vector, regardless of device function is capable of handling
43056 + * multiple messages. A return of zero indicates the successful setup
43057 + * of an entry zero with the new MSI vector or non-zero for otherwise.
43058 + **/
43059 +static int msi_capability_init(struct pci_dev *dev)
43060 +{
43061 +       struct msi_desc *entry;
43062 +       struct msg_address address;
43063 +       struct msg_data data;
43064 +       int pos, vector;
43065 +       u32 control;
43066 +
43067 +       pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
43068 +       if (!pos)
43069 +               return -EINVAL;
43070 +
43071 +       dev->bus->ops->read(dev->bus, dev->devfn, msi_control_reg(pos),
43072 +               2, &control);
43073 +       if (control & PCI_MSI_FLAGS_ENABLE)
43074 +               return 0;
43075 +
43076 +       vector = dev->irq;
43077 +       if (vector > 0 && !msi_lookup_vector(dev)) {
43078 +               /* Lookup Sucess */
43079 +               enable_msi_mode(dev, pos, PCI_CAP_ID_MSI);
43080 +               return 0;
43081 +       }
43082 +       /* MSI Entry Initialization */
43083 +       if (!(entry = alloc_msi_entry()))
43084 +               return -ENOMEM;
43085 +
43086 +       if ((vector = get_msi_vector(dev)) < 0) {
43087 +               kmem_cache_free(msi_cachep, entry);
43088 +               return -EBUSY;
43089 +       }
43090 +       entry->msi_attrib.type = PCI_CAP_ID_MSI;
43091 +       entry->msi_attrib.entry_nr = 0;
43092 +       entry->msi_attrib.maskbit = is_mask_bit_support(control);
43093 +       entry->msi_attrib.default_vector = dev->irq;
43094 +       dev->irq = vector;      /* save default pre-assigned ioapic vector */
43095 +       entry->dev = dev;
43096 +       if (is_mask_bit_support(control)) {
43097 +               entry->mask_base = msi_mask_bits_reg(pos,
43098 +                               is_64bit_address(control));
43099 +       }
43100 +       /* Replace with MSI handler */
43101 +       irq_handler_init(PCI_CAP_ID_MSI, vector, entry->msi_attrib.maskbit);
43102 +       /* Configure MSI capability structure */
43103 +       msi_address_init(&address);
43104 +       msi_data_init(&data, vector);
43105 +       entry->msi_attrib.current_cpu = ((address.lo_address.u.dest_id >>
43106 +                               MSI_TARGET_CPU_SHIFT) & MSI_TARGET_CPU_MASK);
43107 +       dev->bus->ops->write(dev->bus, dev->devfn, msi_lower_address_reg(pos),
43108 +                               4, address.lo_address.value);
43109 +       if (is_64bit_address(control)) {
43110 +               dev->bus->ops->write(dev->bus, dev->devfn,
43111 +                       msi_upper_address_reg(pos), 4, address.hi_address);
43112 +               dev->bus->ops->write(dev->bus, dev->devfn,
43113 +                       msi_data_reg(pos, 1), 2, *((u32*)&data));
43114 +       } else
43115 +               dev->bus->ops->write(dev->bus, dev->devfn,
43116 +                       msi_data_reg(pos, 0), 2, *((u32*)&data));
43117 +       if (entry->msi_attrib.maskbit) {
43118 +               unsigned int maskbits, temp;
43119 +               /* All MSIs are unmasked by default, Mask them all */
43120 +               dev->bus->ops->read(dev->bus, dev->devfn,
43121 +                       msi_mask_bits_reg(pos, is_64bit_address(control)), 4,
43122 +                       &maskbits);
43123 +               temp = (1 << multi_msi_capable(control));
43124 +               temp = ((temp - 1) & ~temp);
43125 +               maskbits |= temp;
43126 +               dev->bus->ops->write(dev->bus, dev->devfn,
43127 +                       msi_mask_bits_reg(pos, is_64bit_address(control)), 4,
43128 +                       maskbits);
43129 +       }
43130 +       attach_msi_entry(entry, vector);
43131 +       /* Set MSI enabled bits  */
43132 +       enable_msi_mode(dev, pos, PCI_CAP_ID_MSI);
43133 +
43134 +       return 0;
43135 +}
43136 +
43137 +/**
43138 + * msix_capability_init - configure device's MSI-X capability
43139 + * @dev: pointer to the pci_dev data structure of MSI-X device function
43140 + *
43141 + * Setup the MSI-X capability structure of device funtion with a
43142 + * single MSI-X vector. A return of zero indicates the successful setup
43143 + * of an entry zero with the new MSI-X vector or non-zero for otherwise.
43144 + * To request for additional MSI-X vectors, the device drivers are
43145 + * required to utilize the following supported APIs:
43146 + * 1) msi_alloc_vectors(...) for requesting one or more MSI-X vectors
43147 + * 2) msi_free_vectors(...) for releasing one or more MSI-X vectors
43148 + *    back to PCI subsystem before calling free_irq(...)
43149 + **/
43150 +static int msix_capability_init(struct pci_dev *dev)
43151 +{
43152 +       struct msi_desc *entry;
43153 +       struct msg_address address;
43154 +       struct msg_data data;
43155 +       int vector, pos, dev_msi_cap;
43156 +       u32 phys_addr, table_offset;
43157 +       u32 control;
43158 +       u8 bir;
43159 +       void *base;
43160 +
43161 +       pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
43162 +       if (!pos)
43163 +               return -EINVAL;
43164 +
43165 +       /* Request & Map MSI-X table region */
43166 +       dev->bus->ops->read(dev->bus, dev->devfn, msi_control_reg(pos), 2,
43167 +               &control);
43168 +       if (control & PCI_MSIX_FLAGS_ENABLE)
43169 +               return 0;
43170 +
43171 +       vector = dev->irq;
43172 +       if (vector > 0 && !msi_lookup_vector(dev)) {
43173 +               /* Lookup Sucess */
43174 +               enable_msi_mode(dev, pos, PCI_CAP_ID_MSIX);
43175 +               return 0;
43176 +       }
43177 +
43178 +       dev_msi_cap = multi_msix_capable(control);
43179 +       dev->bus->ops->read(dev->bus, dev->devfn,
43180 +               msix_table_offset_reg(pos), 4, &table_offset);
43181 +       bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK);
43182 +       phys_addr = pci_resource_start (dev, bir);
43183 +       phys_addr += (u32)(table_offset & ~PCI_MSIX_FLAGS_BIRMASK);
43184 +       if (!request_mem_region(phys_addr,
43185 +               dev_msi_cap * PCI_MSIX_ENTRY_SIZE,
43186 +               "MSI-X iomap Failure"))
43187 +               return -ENOMEM;
43188 +       base = ioremap_nocache(phys_addr, dev_msi_cap * PCI_MSIX_ENTRY_SIZE);
43189 +       if (base == NULL)
43190 +               goto free_region;
43191 +       /* MSI Entry Initialization */
43192 +       entry = alloc_msi_entry();
43193 +       if (!entry)
43194 +               goto free_iomap;
43195 +       if ((vector = get_msi_vector(dev)) < 0)
43196 +               goto free_entry;
43197 +
43198 +       entry->msi_attrib.type = PCI_CAP_ID_MSIX;
43199 +       entry->msi_attrib.entry_nr = 0;
43200 +       entry->msi_attrib.maskbit = 1;
43201 +       entry->msi_attrib.default_vector = dev->irq;
43202 +       dev->irq = vector;      /* save default pre-assigned ioapic vector */
43203 +       entry->dev = dev;
43204 +       entry->mask_base = (unsigned long)base;
43205 +       /* Replace with MSI handler */
43206 +       irq_handler_init(PCI_CAP_ID_MSIX, vector, 1);
43207 +       /* Configure MSI-X capability structure */
43208 +       msi_address_init(&address);
43209 +       msi_data_init(&data, vector);
43210 +       entry->msi_attrib.current_cpu = ((address.lo_address.u.dest_id >>
43211 +                               MSI_TARGET_CPU_SHIFT) & MSI_TARGET_CPU_MASK);
43212 +       writel(address.lo_address.value, base + PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET);
43213 +       writel(address.hi_address, base + PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET);
43214 +       writel(*(u32*)&data, base + PCI_MSIX_ENTRY_DATA_OFFSET);
43215 +       /* Initialize all entries from 1 up to 0 */
43216 +       for (pos = 1; pos < dev_msi_cap; pos++) {
43217 +               writel(0, base + pos * PCI_MSIX_ENTRY_SIZE +
43218 +                       PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET);
43219 +               writel(0, base + pos * PCI_MSIX_ENTRY_SIZE +
43220 +                       PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET);
43221 +               writel(0, base + pos * PCI_MSIX_ENTRY_SIZE +
43222 +                       PCI_MSIX_ENTRY_DATA_OFFSET);
43223 +       }
43224 +       attach_msi_entry(entry, vector);
43225 +       /* Set MSI enabled bits  */
43226 +       enable_msi_mode(dev, pos, PCI_CAP_ID_MSIX);
43227 +
43228 +       return 0;
43229 +
43230 +free_entry:
43231 +       kmem_cache_free(msi_cachep, entry);
43232 +free_iomap:
43233 +       iounmap(base);
43234 +free_region:
43235 +       release_mem_region(phys_addr, dev_msi_cap * PCI_MSIX_ENTRY_SIZE);
43236 +
43237 +       return ((vector < 0) ? -EBUSY : -ENOMEM);
43238 +}
43239 +
43240 +/**
43241 + * pci_enable_msi - configure device's MSI(X) capability structure
43242 + * @dev: pointer to the pci_dev data structure of MSI(X) device function
43243 + *
43244 + * Setup the MSI/MSI-X capability structure of device function with
43245 + * a single MSI(X) vector upon its software driver call to request for
43246 + * MSI(X) mode enabled on its hardware device function. A return of zero
43247 + * indicates the successful setup of an entry zero with the new MSI(X)
43248 + * vector or non-zero for otherwise.
43249 + **/
43250 +int pci_enable_msi(struct pci_dev* dev)
43251 +{
43252 +       int status = -EINVAL;
43253 +
43254 +       if (!pci_msi_enable || !dev)
43255 +               return status;
43256 +
43257 +       if (msi_init() < 0)
43258 +               return -ENOMEM;
43259 +
43260 +       if ((status = msix_capability_init(dev)) == -EINVAL)
43261 +               status = msi_capability_init(dev);
43262 +       if (!status)
43263 +               nr_reserved_vectors--;
43264 +
43265 +       return status;
43266 +}
43267 +
43268 +static int msi_free_vector(struct pci_dev* dev, int vector);
43269 +static void pci_disable_msi(unsigned int vector)
43270 +{
43271 +       int head, tail, type, default_vector;
43272 +       struct msi_desc *entry;
43273 +       struct pci_dev *dev;
43274 +       unsigned long flags;
43275 +
43276 +       spin_lock_irqsave(&msi_lock, flags);
43277 +       entry = msi_desc[vector];
43278 +       if (!entry || !entry->dev) {
43279 +               spin_unlock_irqrestore(&msi_lock, flags);
43280 +               return;
43281 +       }
43282 +       dev = entry->dev;
43283 +       type = entry->msi_attrib.type;
43284 +       head = entry->link.head;
43285 +       tail = entry->link.tail;
43286 +       default_vector = entry->msi_attrib.default_vector;
43287 +       spin_unlock_irqrestore(&msi_lock, flags);
43288 +
43289 +       disable_msi_mode(dev, pci_find_capability(dev, type), type);
43290 +       /* Restore dev->irq to its default pin-assertion vector */
43291 +       dev->irq = default_vector;
43292 +       if (type == PCI_CAP_ID_MSIX && head != tail) {
43293 +               /* Bad driver, which do not call msi_free_vectors before exit.
43294 +                  We must do a cleanup here */
43295 +               while (1) {
43296 +                       spin_lock_irqsave(&msi_lock, flags);
43297 +                       entry = msi_desc[vector];
43298 +                       head = entry->link.head;
43299 +                       tail = entry->link.tail;
43300 +                       spin_unlock_irqrestore(&msi_lock, flags);
43301 +                       if (tail == head)
43302 +                               break;
43303 +                       if (msi_free_vector(dev, entry->link.tail))
43304 +                               break;
43305 +               }
43306 +       }
43307 +}
43308 +
43309 +static int msi_alloc_vector(struct pci_dev* dev, int head)
43310 +{
43311 +       struct msi_desc *entry;
43312 +       struct msg_address address;
43313 +       struct msg_data data;
43314 +       int i, offset, pos, dev_msi_cap, vector;
43315 +       u32 low_address, control;
43316 +       unsigned long base = 0L;
43317 +       unsigned long flags;
43318 +
43319 +       spin_lock_irqsave(&msi_lock, flags);
43320 +       entry = msi_desc[dev->irq];
43321 +       if (!entry) {
43322 +               spin_unlock_irqrestore(&msi_lock, flags);
43323 +               return -EINVAL;
43324 +       }
43325 +       base = entry->mask_base;
43326 +       spin_unlock_irqrestore(&msi_lock, flags);
43327 +
43328 +       pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
43329 +       dev->bus->ops->read(dev->bus, dev->devfn, msi_control_reg(pos),
43330 +               2, &control);
43331 +       dev_msi_cap = multi_msix_capable(control);
43332 +       for (i = 1; i < dev_msi_cap; i++) {
43333 +               if (!(low_address = readl(base + i * PCI_MSIX_ENTRY_SIZE)))
43334 +                        break;
43335 +       }
43336 +       if (i >= dev_msi_cap)
43337 +               return -EINVAL;
43338 +
43339 +       /* MSI Entry Initialization */
43340 +       if (!(entry = alloc_msi_entry()))
43341 +               return -ENOMEM;
43342 +
43343 +       if ((vector = get_new_vector()) < 0) {
43344 +               kmem_cache_free(msi_cachep, entry);
43345 +               return vector;
43346 +       }
43347 +       entry->msi_attrib.type = PCI_CAP_ID_MSIX;
43348 +       entry->msi_attrib.entry_nr = i;
43349 +       entry->msi_attrib.maskbit = 1;
43350 +       entry->dev = dev;
43351 +       entry->link.head = head;
43352 +       entry->mask_base = base;
43353 +       irq_handler_init(PCI_CAP_ID_MSIX, vector, 1);
43354 +       /* Configure MSI-X capability structure */
43355 +       msi_address_init(&address);
43356 +       msi_data_init(&data, vector);
43357 +       entry->msi_attrib.current_cpu = ((address.lo_address.u.dest_id >>
43358 +                               MSI_TARGET_CPU_SHIFT) & MSI_TARGET_CPU_MASK);
43359 +       offset = entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE;
43360 +       writel(address.lo_address.value, base + offset +
43361 +               PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET);
43362 +       writel(address.hi_address, base + offset +
43363 +               PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET);
43364 +       writel(*(u32*)&data, base + offset + PCI_MSIX_ENTRY_DATA_OFFSET);
43365 +       writel(1, base + offset + PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
43366 +       attach_msi_entry(entry, vector);
43367 +
43368 +       return vector;
43369 +}
43370 +
43371 +static int msi_free_vector(struct pci_dev* dev, int vector)
43372 +{
43373 +       struct msi_desc *entry;
43374 +       int entry_nr, type;
43375 +       unsigned long base = 0L;
43376 +       unsigned long flags;
43377 +
43378 +       spin_lock_irqsave(&msi_lock, flags);
43379 +       entry = msi_desc[vector];
43380 +       if (!entry || entry->dev != dev) {
43381 +               spin_unlock_irqrestore(&msi_lock, flags);
43382 +               return -EINVAL;
43383 +       }
43384 +       type = entry->msi_attrib.type;
43385 +       entry_nr = entry->msi_attrib.entry_nr;
43386 +       base = entry->mask_base;
43387 +       if (entry->link.tail != entry->link.head) {
43388 +               msi_desc[entry->link.head]->link.tail = entry->link.tail;
43389 +               if (entry->link.tail)
43390 +                       msi_desc[entry->link.tail]->link.head = entry->link.head;
43391 +       }
43392 +       entry->dev = NULL;
43393 +       vector_irq[vector] = 0;
43394 +       nr_released_vectors++;
43395 +       msi_desc[vector] = NULL;
43396 +       spin_unlock_irqrestore(&msi_lock, flags);
43397 +
43398 +       kmem_cache_free(msi_cachep, entry);
43399 +       if (type == PCI_CAP_ID_MSIX) {
43400 +               int offset;
43401 +
43402 +               offset = entry_nr * PCI_MSIX_ENTRY_SIZE;
43403 +               writel(1, base + offset + PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
43404 +               writel(0, base + offset + PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET);
43405 +       }
43406 +
43407 +       return 0;
43408 +}
43409 +
43410 +/**
43411 + * msi_alloc_vectors - allocate additional MSI-X vectors
43412 + * @dev: pointer to the pci_dev data structure of MSI-X device function
43413 + * @vector: pointer to an array of new allocated MSI-X vectors
43414 + * @nvec: number of MSI-X vectors requested for allocation by device driver
43415 + *
43416 + * Allocate additional MSI-X vectors requested by device driver. A
43417 + * return of zero indicates the successful setup of MSI-X capability
43418 + * structure with new allocated MSI-X vectors or non-zero for otherwise.
43419 + **/
43420 +int msi_alloc_vectors(struct pci_dev* dev, int *vector, int nvec)
43421 +{
43422 +       struct msi_desc *entry;
43423 +       int i, head, pos, vec, free_vectors, alloc_vectors;
43424 +       int *vectors = (int *)vector;
43425 +       u32 control;
43426 +       unsigned long flags;
43427 +
43428 +       if (!pci_msi_enable || !dev)
43429 +               return -EINVAL;
43430 +
43431 +       if (!(pos = pci_find_capability(dev, PCI_CAP_ID_MSIX)))
43432 +               return -EINVAL;
43433 +
43434 +       dev->bus->ops->read(dev->bus, dev->devfn, msi_control_reg(pos),                         2, &control);
43435 +       if (nvec > multi_msix_capable(control))
43436 +               return -EINVAL;
43437 +
43438 +       spin_lock_irqsave(&msi_lock, flags);
43439 +       entry = msi_desc[dev->irq];
43440 +       if (!entry || entry->dev != dev ||              /* legal call */
43441 +          entry->msi_attrib.type != PCI_CAP_ID_MSIX || /* must be MSI-X */
43442 +          entry->link.head != entry->link.tail) {      /* already multi */
43443 +               spin_unlock_irqrestore(&msi_lock, flags);
43444 +               return -EINVAL;
43445 +       }
43446 +       /*
43447 +        * msi_lock is provided to ensure that enough vectors resources are
43448 +        * available before granting.
43449 +        */
43450 +       free_vectors = pci_vector_resources();
43451 +       /* Ensure that each MSI/MSI-X device has one vector reserved by
43452 +          default to avoid any MSI-X driver to take all available
43453 +          resources */
43454 +       free_vectors -= nr_reserved_vectors;
43455 +       /* Find the average of free vectors among MSI-X devices */
43456 +       if (nr_msix_devices > 0)
43457 +               free_vectors /= nr_msix_devices;
43458 +       spin_unlock_irqrestore(&msi_lock, flags);
43459 +
43460 +       if (nvec > free_vectors)
43461 +               return -EBUSY;
43462 +
43463 +       alloc_vectors = 0;
43464 +       head = dev->irq;
43465 +       for (i = 0; i < nvec; i++) {
43466 +               if ((vec = msi_alloc_vector(dev, head)) < 0)
43467 +                       break;
43468 +               *(vectors + i) = vec;
43469 +               head = vec;
43470 +               alloc_vectors++;
43471 +       }
43472 +       if (alloc_vectors != nvec) {
43473 +               for (i = 0; i < alloc_vectors; i++) {
43474 +                       vec = *(vectors + i);
43475 +                       msi_free_vector(dev, vec);
43476 +               }
43477 +               spin_lock_irqsave(&msi_lock, flags);
43478 +               msi_desc[dev->irq]->link.tail = msi_desc[dev->irq]->link.head;
43479 +               spin_unlock_irqrestore(&msi_lock, flags);
43480 +               return -EBUSY;
43481 +       }
43482 +       if (nr_msix_devices > 0)
43483 +               nr_msix_devices--;
43484 +
43485 +       return 0;
43486 +}
43487 +
43488 +/**
43489 + * msi_free_vectors - reclaim MSI-X vectors to unused state
43490 + * @dev: pointer to the pci_dev data structure of MSI-X device function
43491 + * @vector: pointer to an array of released MSI-X vectors
43492 + * @nvec: number of MSI-X vectors requested for release by device driver
43493 + *
43494 + * Reclaim MSI-X vectors released by device driver to unused state,
43495 + * which may be used later on. A return of zero indicates the
43496 + * success or non-zero for otherwise. Device driver should call this
43497 + * before calling function free_irq.
43498 + **/
43499 +int msi_free_vectors(struct pci_dev* dev, int *vector, int nvec)
43500 +{
43501 +       struct msi_desc *entry;
43502 +       int i;
43503 +       unsigned long flags;
43504 +
43505 +       if (!pci_msi_enable)
43506 +               return -EINVAL;
43507 +
43508 +       spin_lock_irqsave(&msi_lock, flags);
43509 +       entry = msi_desc[dev->irq];
43510 +       if (!entry || entry->dev != dev ||
43511 +               entry->msi_attrib.type != PCI_CAP_ID_MSIX ||
43512 +               entry->link.head == entry->link.tail) { /* Nothing to free */
43513 +               spin_unlock_irqrestore(&msi_lock, flags);
43514 +               return -EINVAL;
43515 +       }
43516 +       spin_unlock_irqrestore(&msi_lock, flags);
43517 +
43518 +       for (i = 0; i < nvec; i++) {
43519 +               if (*(vector + i) == dev->irq)
43520 +                       continue;/* Don't free entry 0 if mistaken by driver */
43521 +               msi_free_vector(dev, *(vector + i));
43522 +       }
43523 +
43524 +       return 0;
43525 +}
43526 +
43527 +/**
43528 + * msi_remove_pci_irq_vectors - reclaim MSI(X) vectors to unused state
43529 + * @dev: pointer to the pci_dev data structure of MSI(X) device function
43530 + *
43531 + * Being called during hotplug remove, from which the device funciton
43532 + * is hot-removed. All previous assigned MSI/MSI-X vectors, if
43533 + * allocated for this device function, are reclaimed to unused state,
43534 + * which may be used later on.
43535 + **/
43536 +void msi_remove_pci_irq_vectors(struct pci_dev* dev)
43537 +{
43538 +       struct msi_desc *entry;
43539 +       int type;
43540 +       unsigned long flags;
43541 +
43542 +       if (!pci_msi_enable)
43543 +               return;
43544 +
43545 +       spin_lock_irqsave(&msi_lock, flags);
43546 +       entry = msi_desc[dev->irq];
43547 +       if (!entry || entry->dev != dev) {
43548 +               spin_unlock_irqrestore(&msi_lock, flags);
43549 +               return;
43550 +       }
43551 +       type = entry->msi_attrib.type;
43552 +       spin_unlock_irqrestore(&msi_lock, flags);
43553 +
43554 +       msi_free_vector(dev, dev->irq);
43555 +       if (type == PCI_CAP_ID_MSIX) {
43556 +               int i, pos, dev_msi_cap;
43557 +               u32 phys_addr, table_offset;
43558 +               u32 control;
43559 +               u8 bir;
43560 +
43561 +               pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
43562 +               dev->bus->ops->read(dev->bus, dev->devfn, msi_control_reg(pos),                         2, &control);
43563 +               dev_msi_cap = multi_msix_capable(control);
43564 +               dev->bus->ops->read(dev->bus, dev->devfn,
43565 +                       msix_table_offset_reg(pos), 4, &table_offset);
43566 +               bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK);
43567 +               phys_addr = pci_resource_start (dev, bir);
43568 +               phys_addr += (u32)(table_offset & ~PCI_MSIX_FLAGS_BIRMASK);
43569 +               for (i = FIRST_DEVICE_VECTOR; i < NR_IRQS; i++) {
43570 +                       spin_lock_irqsave(&msi_lock, flags);
43571 +                       if (!msi_desc[i] || msi_desc[i]->dev != dev) {
43572 +                               spin_unlock_irqrestore(&msi_lock, flags);
43573 +                               continue;
43574 +                       }
43575 +                       spin_unlock_irqrestore(&msi_lock, flags);
43576 +                       msi_free_vector(dev, i);
43577 +               }
43578 +               writel(1, entry->mask_base + PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
43579 +               iounmap((void*)entry->mask_base);
43580 +               release_mem_region(phys_addr, dev_msi_cap * PCI_MSIX_ENTRY_SIZE);
43581 +       }
43582 +       nr_reserved_vectors++;
43583 +}
43584 +
43585 +EXPORT_SYMBOL(pci_enable_msi);
43586 +EXPORT_SYMBOL(msi_alloc_vectors);
43587 +EXPORT_SYMBOL(msi_free_vectors);
43588 --- linux-2.6.0-test6/drivers/pci/pci.c 2003-08-08 22:55:12.000000000 -0700
43589 +++ 25/drivers/pci/pci.c        2003-10-05 00:36:10.000000000 -0700
43590 @@ -126,11 +126,13 @@ pci_find_capability(struct pci_dev *dev,
43591  
43592  /**
43593   * pci_bus_find_capability - query for devices' capabilities 
43594 - * @dev: PCI device to query
43595 - * @cap: capability code
43596 + * @bus:   the PCI bus to query
43597 + * @devfn: PCI device to query
43598 + * @cap:   capability code
43599   *
43600   * Like pci_find_capability() but works for pci devices that do not have a
43601   * pci_dev structure set up yet. 
43602 + *
43603   * Returns the address of the requested capability structure within the
43604   * device's PCI configuration space or 0 in case the device does not
43605   * support it.
43606 --- linux-2.6.0-test6/drivers/pci/pool.c        2003-07-27 12:14:39.000000000 -0700
43607 +++ 25/drivers/pci/pool.c       2003-10-05 00:33:24.000000000 -0700
43608 @@ -296,7 +296,6 @@ restart:
43609  
43610                         schedule_timeout (POOL_TIMEOUT_JIFFIES);
43611  
43612 -                       current->state = TASK_RUNNING;
43613                         remove_wait_queue (&pool->waitq, &wait);
43614                         goto restart;
43615                 }
43616 --- linux-2.6.0-test6/drivers/pci/power.c       2003-06-14 12:18:25.000000000 -0700
43617 +++ /dev/null   2002-08-30 16:31:37.000000000 -0700
43618 @@ -1,159 +0,0 @@
43619 -#include <linux/pci.h>
43620 -#include <linux/pm.h>
43621 -#include <linux/init.h>
43622 -
43623 -/*
43624 - * PCI Power management..
43625 - *
43626 - * This needs to be done centralized, so that we power manage PCI
43627 - * devices in the right order: we should not shut down PCI bridges
43628 - * before we've shut down the devices behind them, and we should
43629 - * not wake up devices before we've woken up the bridge to the
43630 - * device.. Eh?
43631 - *
43632 - * We do not touch devices that don't have a driver that exports
43633 - * a suspend/resume function. That is just too dangerous. If the default
43634 - * PCI suspend/resume functions work for a device, the driver can
43635 - * easily implement them (ie just have a suspend function that calls
43636 - * the pci_set_power_state() function).
43637 - */
43638 -
43639 -static int pci_pm_save_state_device(struct pci_dev *dev, u32 state)
43640 -{
43641 -       int error = 0;
43642 -       if (dev) {
43643 -               struct pci_driver *driver = dev->driver;
43644 -               if (driver && driver->save_state) 
43645 -                       error = driver->save_state(dev,state);
43646 -       }
43647 -       return error;
43648 -}
43649 -
43650 -static int pci_pm_suspend_device(struct pci_dev *dev, u32 state)
43651 -{
43652 -       int error = 0;
43653 -       if (dev) {
43654 -               struct pci_driver *driver = dev->driver;
43655 -               if (driver && driver->suspend)
43656 -                       error = driver->suspend(dev,state);
43657 -       }
43658 -       return error;
43659 -}
43660 -
43661 -static int pci_pm_resume_device(struct pci_dev *dev)
43662 -{
43663 -       int error = 0;
43664 -       if (dev) {
43665 -               struct pci_driver *driver = dev->driver;
43666 -               if (driver && driver->resume)
43667 -                       error = driver->resume(dev);
43668 -       }
43669 -       return error;
43670 -}
43671 -
43672 -static int pci_pm_save_state_bus(struct pci_bus *bus, u32 state)
43673 -{
43674 -       struct list_head *list;
43675 -       int error = 0;
43676 -
43677 -       list_for_each(list, &bus->children) {
43678 -               error = pci_pm_save_state_bus(pci_bus_b(list),state);
43679 -               if (error) return error;
43680 -       }
43681 -       list_for_each(list, &bus->devices) {
43682 -               error = pci_pm_save_state_device(pci_dev_b(list),state);
43683 -               if (error) return error;
43684 -       }
43685 -       return 0;
43686 -}
43687 -
43688 -static int pci_pm_suspend_bus(struct pci_bus *bus, u32 state)
43689 -{
43690 -       struct list_head *list;
43691 -
43692 -       /* Walk the bus children list */
43693 -       list_for_each(list, &bus->children) 
43694 -               pci_pm_suspend_bus(pci_bus_b(list),state);
43695 -
43696 -       /* Walk the device children list */
43697 -       list_for_each(list, &bus->devices)
43698 -               pci_pm_suspend_device(pci_dev_b(list),state);
43699 -       return 0;
43700 -}
43701 -
43702 -static int pci_pm_resume_bus(struct pci_bus *bus)
43703 -{
43704 -       struct list_head *list;
43705 -
43706 -       /* Walk the device children list */
43707 -       list_for_each(list, &bus->devices)
43708 -               pci_pm_resume_device(pci_dev_b(list));
43709 -
43710 -       /* And then walk the bus children */
43711 -       list_for_each(list, &bus->children)
43712 -               pci_pm_resume_bus(pci_bus_b(list));
43713 -       return 0;
43714 -}
43715 -
43716 -static int pci_pm_save_state(u32 state)
43717 -{
43718 -       struct pci_bus *bus = NULL;
43719 -       int error = 0;
43720 -
43721 -       while ((bus = pci_find_next_bus(bus)) != NULL) {
43722 -               error = pci_pm_save_state_bus(bus,state);
43723 -               if (!error)
43724 -                       error = pci_pm_save_state_device(bus->self,state);
43725 -       }
43726 -       return error;
43727 -}
43728 -
43729 -static int pci_pm_suspend(u32 state)
43730 -{
43731 -       struct pci_bus *bus = NULL;
43732 -
43733 -       while ((bus = pci_find_next_bus(bus)) != NULL) {
43734 -               pci_pm_suspend_bus(bus,state);
43735 -               pci_pm_suspend_device(bus->self,state);
43736 -       }
43737 -       return 0;
43738 -}
43739 -
43740 -static int pci_pm_resume(void)
43741 -{
43742 -       struct pci_bus *bus = NULL;
43743 -
43744 -       while ((bus = pci_find_next_bus(bus)) != NULL) {
43745 -               pci_pm_resume_device(bus->self);
43746 -               pci_pm_resume_bus(bus);
43747 -       }
43748 -       return 0;
43749 -}
43750 -
43751 -static int 
43752 -pci_pm_callback(struct pm_dev *pm_device, pm_request_t rqst, void *data)
43753 -{
43754 -       int error = 0;
43755 -
43756 -       switch (rqst) {
43757 -       case PM_SAVE_STATE:
43758 -               error = pci_pm_save_state((unsigned long)data);
43759 -               break;
43760 -       case PM_SUSPEND:
43761 -               error = pci_pm_suspend((unsigned long)data);
43762 -               break;
43763 -       case PM_RESUME:
43764 -               error = pci_pm_resume();
43765 -               break;
43766 -       default: break;
43767 -       }
43768 -       return error;
43769 -}
43770 -
43771 -static int __init pci_pm_init(void)
43772 -{
43773 -       pm_register(PM_PCI_DEV, 0, pci_pm_callback);
43774 -       return 0;
43775 -}
43776 -
43777 -subsys_initcall(pci_pm_init);
43778 --- linux-2.6.0-test6/drivers/pci/probe.c       2003-08-08 22:55:12.000000000 -0700
43779 +++ 25/drivers/pci/probe.c      2003-10-05 00:36:20.000000000 -0700
43780 @@ -176,7 +176,7 @@ void __devinit pci_read_bridge_bases(str
43781                 limit |= (io_limit_hi << 16);
43782         }
43783  
43784 -       if (base && base <= limit) {
43785 +       if (base <= limit) {
43786                 res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO;
43787                 res->start = base;
43788                 res->end = limit + 0xfff;
43789 @@ -187,7 +187,7 @@ void __devinit pci_read_bridge_bases(str
43790         pci_read_config_word(dev, PCI_MEMORY_LIMIT, &mem_limit_lo);
43791         base = (mem_base_lo & PCI_MEMORY_RANGE_MASK) << 16;
43792         limit = (mem_limit_lo & PCI_MEMORY_RANGE_MASK) << 16;
43793 -       if (base && base <= limit) {
43794 +       if (base <= limit) {
43795                 res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM;
43796                 res->start = base;
43797                 res->end = limit + 0xfffff;
43798 @@ -213,7 +213,7 @@ void __devinit pci_read_bridge_bases(str
43799                 }
43800  #endif
43801         }
43802 -       if (base && base <= limit) {
43803 +       if (base <= limit) {
43804                 res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM | IORESOURCE_PREFETCH;
43805                 res->start = base;
43806                 res->end = limit + 0xfffff;
43807 @@ -552,6 +552,7 @@ int __devinit pci_scan_slot(struct pci_b
43808                 struct pci_dev *dev;
43809  
43810                 dev = pci_scan_device(bus, devfn);
43811 +               pci_scan_msi_device(dev);
43812                 if (func == 0) {
43813                         if (!dev)
43814                                 break;
43815 --- linux-2.6.0-test6/drivers/pci/quirks.c      2003-08-22 19:23:41.000000000 -0700
43816 +++ 25/drivers/pci/quirks.c     2003-10-05 00:33:24.000000000 -0700
43817 @@ -750,6 +750,9 @@ static void __init quirk_sis_96x_compati
43818  
43819  /*
43820   *  The main table of quirks.
43821 + *
43822 + *  Note: any hooks for hotpluggable devices in this table must _NOT_
43823 + *        be declared __init.
43824   */
43825  
43826  static struct pci_fixup pci_fixups[] __devinitdata = {
43827 --- linux-2.6.0-test6/drivers/pci/remove.c      2003-07-27 12:14:39.000000000 -0700
43828 +++ 25/drivers/pci/remove.c     2003-10-05 00:36:20.000000000 -0700
43829 @@ -14,6 +14,8 @@ static void pci_free_resources(struct pc
43830  {
43831         int i;
43832  
43833 +       msi_remove_pci_irq_vectors(dev);
43834 +
43835         for (i = 0; i < PCI_NUM_RESOURCES; i++) {
43836                 struct resource *res = dev->resource + i;
43837                 if (res->parent)
43838 --- linux-2.6.0-test6/drivers/s390/block/dasd.c 2003-09-27 18:57:45.000000000 -0700
43839 +++ 25/drivers/s390/block/dasd.c        2003-10-05 00:34:01.000000000 -0700
43840 @@ -1643,9 +1643,9 @@ dasd_flush_request_queue(struct dasd_dev
43841  }
43842  
43843  static int
43844 -dasd_open(struct inode *inp, struct file *filp)
43845 +dasd_open(struct block_device *bdev, struct file *filp)
43846  {
43847 -       struct gendisk *disk = inp->i_bdev->bd_disk;
43848 +       struct gendisk *disk = bdev->bd_disk;
43849         struct dasd_device *device = disk->private_data;
43850         int rc;
43851  
43852 @@ -1676,10 +1676,8 @@ out:
43853         return rc;
43854  }
43855  
43856 -static int
43857 -dasd_release(struct inode *inp, struct file *filp)
43858 +static int dasd_release(struct gendisk *disk)
43859  {
43860 -       struct gendisk *disk = inp->i_bdev->bd_disk;
43861         struct dasd_device *device = disk->private_data;
43862  
43863         if (device->state < DASD_STATE_BASIC) {
43864 --- linux-2.6.0-test6/drivers/s390/block/dasd_int.h     2003-09-27 18:57:45.000000000 -0700
43865 +++ 25/drivers/s390/block/dasd_int.h    2003-10-05 00:33:54.000000000 -0700
43866 @@ -493,7 +493,7 @@ int  dasd_ioctl_init(void);
43867  void dasd_ioctl_exit(void);
43868  int  dasd_ioctl_no_register(struct module *, int, dasd_ioctl_fn_t);
43869  int  dasd_ioctl_no_unregister(struct module *, int, dasd_ioctl_fn_t);
43870 -int  dasd_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
43871 +int  dasd_ioctl(struct block_device *, struct file *, unsigned int, unsigned long);
43872  
43873  /* externals in dasd_proc.c */
43874  int dasd_proc_init(void);
43875 --- linux-2.6.0-test6/drivers/s390/block/dasd_ioctl.c   2003-09-27 18:57:45.000000000 -0700
43876 +++ 25/drivers/s390/block/dasd_ioctl.c  2003-10-05 00:33:54.000000000 -0700
43877 @@ -78,10 +78,9 @@ dasd_ioctl_no_unregister(struct module *
43878  }
43879  
43880  int
43881 -dasd_ioctl(struct inode *inp, struct file *filp,
43882 +dasd_ioctl(struct block_device *bdev, struct file *filp,
43883            unsigned int no, unsigned long data)
43884  {
43885 -       struct block_device *bdev = inp->i_bdev;
43886         struct dasd_device *device = bdev->bd_disk->private_data;
43887         struct dasd_ioctl *ioctl;
43888         const char *dir;
43889 --- linux-2.6.0-test6/drivers/s390/block/xpram.c        2003-09-27 18:57:45.000000000 -0700
43890 +++ 25/drivers/s390/block/xpram.c       2003-10-05 00:33:54.000000000 -0700
43891 @@ -328,7 +328,7 @@ fail:
43892         return 0;
43893  }
43894  
43895 -static int xpram_ioctl (struct inode *inode, struct file *filp,
43896 +static int xpram_ioctl (struct block_device *bdev, struct file *filp,
43897                  unsigned int cmd, unsigned long arg)
43898  {
43899         struct hd_geometry *geo;
43900 --- linux-2.6.0-test6/drivers/s390/char/tape_block.c    2003-09-27 18:57:45.000000000 -0700
43901 +++ 25/drivers/s390/char/tape_block.c   2003-10-05 00:34:01.000000000 -0700
43902 @@ -27,8 +27,8 @@
43903  /*
43904   * file operation structure for tape block frontend
43905   */
43906 -static int tapeblock_open(struct inode *, struct file *);
43907 -static int tapeblock_release(struct inode *, struct file *);
43908 +static int tapeblock_open(block_device *, struct file *);
43909 +static int tapeblock_release(struct gendisk *);
43910  
43911  static struct block_device_operations tapeblock_fops = {
43912         .owner          = THIS_MODULE,
43913 @@ -299,9 +299,9 @@ static int tapeblock_mediumdetect(struct
43914   * Block frontend tape device open function.
43915   */
43916  static int
43917 -tapeblock_open(struct inode *inode, struct file *filp)
43918 +tapeblock_open(struct block_device *bdev, struct file *filp)
43919  {
43920 -       struct gendisk *disk = inode->i_bdev->bd_disk;
43921 +       struct gendisk *disk = bdev->bd_disk;
43922         struct tape_device *device = disk->private_data;
43923         int rc;
43924  
43925 @@ -336,9 +336,8 @@ tapeblock_open(struct inode *inode, stru
43926   * Block frontend tape device release function.
43927   */
43928  static int
43929 -tapeblock_release(struct inode *inode, struct file *filp)
43930 +tapeblock_release(struct gendisk *disk)
43931  {
43932 -       struct gendisk *disk = inode->i_bdev->bd_disk;
43933         struct tape_device *device = disk->private_data;
43934  
43935         tape_release(device);
43936 --- linux-2.6.0-test6/drivers/sbus/char/bbc_envctrl.c   2003-06-14 12:18:08.000000000 -0700
43937 +++ 25/drivers/sbus/char/bbc_envctrl.c  2003-10-05 00:33:24.000000000 -0700
43938 @@ -59,7 +59,7 @@ static int errno;
43939   * before the hardware based power-off event is triggered.
43940   */
43941  
43942 -/* These settings are in celcius.  We use these defaults only
43943 +/* These settings are in Celsius.  We use these defaults only
43944   * if we cannot interrogate the cpu-fru SEEPROM.
43945   */
43946  struct temp_limits {
43947 --- linux-2.6.0-test6/drivers/sbus/char/cpwatchdog.c    2003-09-27 18:57:45.000000000 -0700
43948 +++ 25/drivers/sbus/char/cpwatchdog.c   2003-10-05 00:33:24.000000000 -0700
43949 @@ -539,7 +539,7 @@ static void wd_toggleintr(struct wd_time
43950  static void wd_pingtimer(struct wd_timer* pTimer)
43951  {
43952         if(wd_readb(&pTimer->regs->status) & WD_S_RUNNING) {
43953 -               wd_readb(&pTimer->regs->dcntr);
43954 +               wd_readw(&pTimer->regs->dcntr);
43955         }
43956  }
43957  
43958 --- linux-2.6.0-test6/drivers/sbus/char/jsflash.c       2003-08-08 22:55:12.000000000 -0700
43959 +++ 25/drivers/sbus/char/jsflash.c      2003-10-05 00:33:24.000000000 -0700
43960 @@ -37,6 +37,7 @@
43961  #include <linux/string.h>
43962  #include <linux/smp_lock.h>
43963  #include <linux/genhd.h>
43964 +#include <linux/blkdev.h>
43965  
43966  #define MAJOR_NR       JSFD_MAJOR
43967  
43968 @@ -187,7 +188,7 @@ static void jsfd_read(char *buf, unsigne
43969  static void jsfd_do_request(request_queue_t *q)
43970  {
43971         struct request *req;
43972 -       
43973 +
43974         while ((req = elv_next_request(q)) != NULL) {
43975                 struct jsfd_part *jdp = req->rq_disk->private_data;
43976                 unsigned long offset = req->sector << 9;
43977 @@ -198,16 +199,11 @@ static void jsfd_do_request(request_queu
43978                         continue;
43979                 }
43980  
43981 -               if (req->cmd == WRITE) {
43982 +               if (rq_data_dir(req) != READ) {
43983                         printk(KERN_ERR "jsfd: write\n");
43984                         end_request(req, 0);
43985                         continue;
43986                 }
43987 -               if (req->cmd != READ) {
43988 -                       printk(KERN_ERR "jsfd: bad req->cmd %d\n", req->cmd);
43989 -                       end_request(req, 0);
43990 -                       continue;
43991 -               }
43992  
43993                 if ((jdp->dbase & 0xff000000) != 0x20000000) {
43994                         printk(KERN_ERR "jsfd: bad base %x\n", (int)jdp->dbase);
43995 @@ -215,7 +211,6 @@ static void jsfd_do_request(request_queu
43996                         continue;
43997                 }
43998  
43999 -/* printk("%s: read buf %p off %x len %x\n", req->rq_disk->disk_name, req->buffer, (int)offset, (int)len); */ /* P3 */
44000                 jsfd_read(req->buffer, jdp->dbase + offset, len);
44001  
44002                 end_request(req, 1);
44003 @@ -265,9 +260,6 @@ static ssize_t jsf_read(struct file * fi
44004                 unsigned int n;
44005         } b;
44006  
44007 -       if (verify_area(VERIFY_WRITE, buf, togo))
44008 -               return -EFAULT; 
44009 -
44010         if (p < JSF_BASE_ALL || p >= JSF_BASE_TOP) {
44011                 return 0;
44012         }
44013 @@ -298,7 +290,8 @@ static ssize_t jsf_read(struct file * fi
44014         while (togo >= 4) {
44015                 togo -= 4;
44016                 b.n = jsf_inl(p);
44017 -               copy_to_user(tmp, b.s, 4);
44018 +               if (copy_to_user(tmp, b.s, 4))
44019 +                       return -EFAULT;
44020                 tmp += 4;
44021                 p += 4;
44022         }
44023 @@ -374,19 +367,17 @@ static int jsf_ioctl_program(unsigned lo
44024                 char s[4];
44025         } b;
44026  
44027 -       if (verify_area(VERIFY_READ, (void *)arg, JSFPRGSZ))
44028 +       if (copy_from_user(&abuf, (char *)arg, JSFPRGSZ))
44029                 return -EFAULT; 
44030 -       copy_from_user(&abuf, (char *)arg, JSFPRGSZ);
44031         p = abuf.off;
44032         togo = abuf.size;
44033         if ((togo & 3) || (p & 3)) return -EINVAL;
44034  
44035         uptr = (char *) (unsigned long) abuf.data;
44036 -       if (verify_area(VERIFY_READ, uptr, togo))
44037 -               return -EFAULT;
44038         while (togo != 0) {
44039                 togo -= 4;
44040 -               copy_from_user(&b.s[0], uptr, 4);
44041 +               if (copy_from_user(&b.s[0], uptr, 4))
44042 +                       return -EFAULT;
44043                 jsf_write4(p, b.n);
44044                 p += 4;
44045                 uptr += 4;
44046 @@ -404,10 +395,8 @@ static int jsf_ioctl(struct inode *inode
44047                 return -EPERM;
44048         switch (cmd) {
44049         case JSFLASH_IDENT:
44050 -               if (verify_area(VERIFY_WRITE, (void *)arg, JSFIDSZ))
44051 -                       return -EFAULT; 
44052 -               copy_to_user(arg, &jsf0.id, JSFIDSZ);
44053 -               error = 0;
44054 +               if (copy_to_user((void *)arg, &jsf0.id, JSFIDSZ))
44055 +                       return -EFAULT;
44056                 break;
44057         case JSFLASH_ERASE:
44058                 error = jsf_ioctl_erase(arg);
44059 --- linux-2.6.0-test6/drivers/scsi/a2091.c      2003-07-27 12:14:39.000000000 -0700
44060 +++ 25/drivers/scsi/a2091.c     2003-10-05 00:33:24.000000000 -0700
44061 @@ -25,31 +25,20 @@
44062  #define DMA(ptr) ((a2091_scsiregs *)((ptr)->base))
44063  #define HDATA(ptr) ((struct WD33C93_hostdata *)((ptr)->hostdata))
44064  
44065 -static struct Scsi_Host *first_instance = NULL;
44066 -static Scsi_Host_Template *a2091_template;
44067 -
44068 -static irqreturn_t a2091_intr (int irq, void *dummy, struct pt_regs *fp)
44069 +static irqreturn_t a2091_intr (int irq, void *_instance, struct pt_regs *fp)
44070  {
44071      unsigned long flags;
44072      unsigned int status;
44073 -    struct Scsi_Host *instance;
44074 -    int handled = 0;
44075 +    struct Scsi_Host *instance = (struct Scsi_Host *)_instance;
44076  
44077 -    for (instance = first_instance; instance &&
44078 -        instance->hostt == a2091_template; instance = instance->next)
44079 -    {
44080 -       status = DMA(instance)->ISTR;
44081 -       if (!(status & (ISTR_INT_F|ISTR_INT_P)))
44082 -               continue;
44083 -
44084 -       if (status & ISTR_INTS) {
44085 -               spin_lock_irqsave(instance->host_lock, flags);
44086 -               wd33c93_intr (instance);
44087 -               spin_unlock_irqrestore(instance->host_lock, flags);
44088 -               handled = 1;
44089 -       }
44090 -    }
44091 -    return IRQ_RETVAL(handled);
44092 +    status = DMA(instance)->ISTR;
44093 +    if (!(status & (ISTR_INT_F|ISTR_INT_P)) || !(status & ISTR_INTS))
44094 +       return IRQ_NONE;
44095 +
44096 +    spin_lock_irqsave(instance->host_lock, flags);
44097 +    wd33c93_intr(instance);
44098 +    spin_unlock_irqrestore(instance->host_lock, flags);
44099 +    return IRQ_HANDLED;
44100  }
44101  
44102  static int dma_setup (Scsi_Cmnd *cmd, int dir_in)
44103 @@ -184,8 +173,6 @@ static void dma_stop (struct Scsi_Host *
44104      }
44105  }
44106  
44107 -static int num_a2091 = 0;
44108 -
44109  int __init a2091_detect(Scsi_Host_Template *tpnt)
44110  {
44111      static unsigned char called = 0;
44112 @@ -193,6 +180,7 @@ int __init a2091_detect(Scsi_Host_Templa
44113      unsigned long address;
44114      struct zorro_dev *z = NULL;
44115      wd33c93_regs regs;
44116 +    int num_a2091 = 0;
44117  
44118      if (!MACH_IS_AMIGA || called)
44119         return 0;
44120 @@ -221,13 +209,10 @@ int __init a2091_detect(Scsi_Host_Templa
44121         regs.SASR = &(DMA(instance)->SASR);
44122         regs.SCMD = &(DMA(instance)->SCMD);
44123         wd33c93_init(instance, regs, dma_setup, dma_stop, WD33C93_FS_8_10);
44124 -       if (num_a2091++ == 0) {
44125 -           first_instance = instance;
44126 -           a2091_template = instance->hostt;
44127 -           request_irq(IRQ_AMIGA_PORTS, a2091_intr, SA_SHIRQ, "A2091 SCSI",
44128 -                       a2091_intr);
44129 -       }
44130 +       request_irq(IRQ_AMIGA_PORTS, a2091_intr, SA_SHIRQ, "A2091 SCSI",
44131 +                   instance);
44132         DMA(instance)->CNTR = CNTR_PDMD | CNTR_INTEN;
44133 +       num_a2091++;
44134      }
44135  
44136      return num_a2091;
44137 @@ -266,8 +251,7 @@ int a2091_release(struct Scsi_Host *inst
44138  #ifdef MODULE
44139         DMA(instance)->CNTR = 0;
44140         release_mem_region(ZTWO_PADDR(instance->base), 256);
44141 -       if (--num_a2091 == 0)
44142 -               free_irq(IRQ_AMIGA_PORTS, a2091_intr);
44143 +       free_irq(IRQ_AMIGA_PORTS, instance);
44144         wd33c93_release();
44145  #endif
44146         return 1;
44147 --- linux-2.6.0-test6/drivers/scsi/aic7xxx/aicasm/Makefile      2003-06-14 12:18:32.000000000 -0700
44148 +++ 25/drivers/scsi/aic7xxx/aicasm/Makefile     2003-10-05 00:34:29.000000000 -0700
44149 @@ -49,14 +49,18 @@ aicdb.h:
44150  clean:
44151         rm -f $(clean-files)
44152  
44153 -aicasm_gram.c aicasm_gram.h: aicasm_gram.y
44154 +aicasm_gram.c: aicasm_gram.h
44155 +       mv $(<:.h=).tab.c $(<:.h=.c)
44156 +
44157 +aicasm_gram.h: aicasm_gram.y
44158         $(YACC) $(YFLAGS) -b $(<:.y=) $<
44159 -       mv $(<:.y=).tab.c $(<:.y=.c)
44160         mv $(<:.y=).tab.h $(<:.y=.h)
44161  
44162 -aicasm_macro_gram.c aicasm_macro_gram.h: aicasm_macro_gram.y
44163 +aicasm_macro_gram.c: aicasm_macro_gram.h
44164 +       mv $(<:.h=).tab.c $(<:.h=.c)
44165 +
44166 +aicasm_macro_gram.h: aicasm_macro_gram.y
44167         $(YACC) $(YFLAGS) -b $(<:.y=) -p mm $<
44168 -       mv $(<:.y=).tab.c $(<:.y=.c)
44169         mv $(<:.y=).tab.h $(<:.y=.h)
44170  
44171  aicasm_scan.c: aicasm_scan.l
44172 --- linux-2.6.0-test6/drivers/scsi/aic7xxx/Makefile     2003-06-14 12:18:48.000000000 -0700
44173 +++ 25/drivers/scsi/aic7xxx/Makefile    2003-10-05 00:34:29.000000000 -0700
44174 @@ -58,7 +58,9 @@ aicasm-7xxx-opts-$(CONFIG_AIC7XXX_REG_PR
44175         -p $(obj)/aic7xxx_reg_print.c -i aic7xxx_osm.h
44176  
44177  ifeq ($(CONFIG_AIC7XXX_BUILD_FIRMWARE),y)
44178 -$(aic7xxx-gen-y): $(src)/aic7xxx.seq $(src)/aic7xxx.reg $(obj)/aicasm/aicasm
44179 +$(aic7xxx-gen-y): $(src)/aic7xxx.seq
44180 +
44181 +$(src)/aic7xxx.seq: $(obj)/aicasm/aicasm $(src)/aic7xxx.reg
44182         $(obj)/aicasm/aicasm -I$(src) -r $(obj)/aic7xxx_reg.h \
44183                               $(aicasm-7xxx-opts-y) -o $(obj)/aic7xxx_seq.h \
44184                               $(src)/aic7xxx.seq
44185 @@ -72,7 +74,9 @@ aicasm-79xx-opts-$(CONFIG_AIC79XX_REG_PR
44186         -p $(obj)/aic79xx_reg_print.c -i aic79xx_osm.h
44187  
44188  ifeq ($(CONFIG_AIC79XX_BUILD_FIRMWARE),y)
44189 -$(aic79xx-gen-y): $(src)/aic79xx.seq $(src)/aic79xx.reg $(obj)/aicasm/aicasm
44190 +$(aic79xx-gen-y): $(src)/aic79xx.seq
44191 +
44192 +$(src)/aic79xx.seq: $(obj)/aicasm/aicasm $(src)/aic79xx.reg
44193         $(obj)/aicasm/aicasm -I$(src) -r $(obj)/aic79xx_reg.h \
44194                               $(aicasm-79xx-opts-y) -o $(obj)/aic79xx_seq.h \
44195                               $(src)/aic79xx.seq
44196 --- linux-2.6.0-test6/drivers/scsi/aic7xxx_old/aic7xxx_proc.c   2003-06-14 12:18:33.000000000 -0700
44197 +++ 25/drivers/scsi/aic7xxx_old/aic7xxx_proc.c  2003-10-05 00:36:51.000000000 -0700
44198 @@ -92,7 +92,7 @@ aic7xxx_proc_info ( struct Scsi_Host *HB
44199  
44200    HBAptr = NULL;
44201  
44202 -  for(p=first_aic7xxx; p->host != HBAptr; p=p->next)
44203 +  for(p=first_aic7xxx; p && p->host != HBAptr; p=p->next)
44204      ;
44205  
44206    if (!p)
44207 --- linux-2.6.0-test6/drivers/scsi/g_NCR5380.c  2003-09-27 18:57:45.000000000 -0700
44208 +++ 25/drivers/scsi/g_NCR5380.c 2003-10-05 00:33:24.000000000 -0700
44209 @@ -527,8 +527,9 @@ int generic_NCR5380_release_resources(st
44210   *     Locks: none
44211   */
44212  
44213 -int generic_NCR5380_biosparam(struct scsi_device *sdev,
44214 -               struct block_device *bdev, sector_t capacity, int *ip)
44215 +static int
44216 +generic_NCR5380_biosparam(struct scsi_device *sdev, struct block_device *bdev,
44217 +                         sector_t capacity, int *ip)
44218  {
44219         ip[0] = 64;
44220         ip[1] = 32;
44221 --- linux-2.6.0-test6/drivers/scsi/g_NCR5380.h  2003-06-14 12:17:56.000000000 -0700
44222 +++ 25/drivers/scsi/g_NCR5380.h 2003-10-05 00:33:24.000000000 -0700
44223 @@ -52,7 +52,6 @@ static int generic_NCR5380_bus_reset(Scs
44224  static int generic_NCR5380_host_reset(Scsi_Cmnd *);
44225  static int generic_NCR5380_device_reset(Scsi_Cmnd *);
44226  static const char* generic_NCR5380_info(struct Scsi_Host *);
44227 -static int generic_NCR5380_biosparam(struct scsi_device *, struct block_device *, sector_t, int *);
44228  
44229  #ifndef CMD_PER_LUN
44230  #define CMD_PER_LUN 2
44231 --- linux-2.6.0-test6/drivers/scsi/gvp11.c      2003-07-27 12:14:39.000000000 -0700
44232 +++ 25/drivers/scsi/gvp11.c     2003-10-05 00:33:24.000000000 -0700
44233 @@ -25,29 +25,20 @@
44234  #define DMA(ptr) ((gvp11_scsiregs *)((ptr)->base))
44235  #define HDATA(ptr) ((struct WD33C93_hostdata *)((ptr)->hostdata))
44236  
44237 -static struct Scsi_Host *first_instance = NULL;
44238 -static Scsi_Host_Template *gvp11_template;
44239 -
44240 -static irqreturn_t gvp11_intr (int irq, void *dummy, struct pt_regs *fp)
44241 +static irqreturn_t gvp11_intr (int irq, void *_instance, struct pt_regs *fp)
44242  {
44243      unsigned long flags;
44244      unsigned int status;
44245 -    struct Scsi_Host *instance;
44246 -    int handled = 0;
44247 -
44248 -    for (instance = first_instance; instance &&
44249 -        instance->hostt == gvp11_template; instance = instance->next)
44250 -    {
44251 -       status = DMA(instance)->CNTR;
44252 -       if (!(status & GVP11_DMAC_INT_PENDING))
44253 -           continue;
44254 +    struct Scsi_Host *instance = (struct Scsi_Host *)_instance;
44255  
44256 -       spin_lock_irqsave(instance->host_lock, flags);
44257 -       wd33c93_intr (instance);
44258 -       spin_unlock_irqrestore(instance->host_lock, flags);
44259 -       handled = 1;
44260 -    }
44261 -    return IRQ_RETVAL(handled);
44262 +    status = DMA(instance)->CNTR;
44263 +    if (!(status & GVP11_DMAC_INT_PENDING))
44264 +       return IRQ_NONE;
44265 +
44266 +    spin_lock_irqsave(instance->host_lock, flags);
44267 +    wd33c93_intr(instance);
44268 +    spin_unlock_irqrestore(instance->host_lock, flags);
44269 +    return IRQ_HANDLED;
44270  }
44271  
44272  static int gvp11_xfer_mask = 0;
44273 @@ -177,8 +168,6 @@ static void dma_stop (struct Scsi_Host *
44274      }
44275  }
44276  
44277 -static int num_gvp11 = 0;
44278 -
44279  #define CHECK_WD33C93
44280  
44281  int __init gvp11_detect(Scsi_Host_Template *tpnt)
44282 @@ -190,6 +179,7 @@ int __init gvp11_detect(Scsi_Host_Templa
44283      struct zorro_dev *z = NULL;
44284      unsigned int default_dma_xfer_mask;
44285      wd33c93_regs regs;
44286 +    int num_gvp11 = 0;
44287  #ifdef CHECK_WD33C93
44288      volatile unsigned char *sasr_3393, *scmd_3393;
44289      unsigned char save_sasr;
44290 @@ -339,13 +329,10 @@ int __init gvp11_detect(Scsi_Host_Templa
44291                      (epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10
44292                                              : WD33C93_FS_12_15);
44293  
44294 -       if (num_gvp11++ == 0) {
44295 -               first_instance = instance;
44296 -               gvp11_template = instance->hostt;
44297 -               request_irq(IRQ_AMIGA_PORTS, gvp11_intr, SA_SHIRQ,
44298 -                           "GVP11 SCSI", gvp11_intr);
44299 -       }
44300 +       request_irq(IRQ_AMIGA_PORTS, gvp11_intr, SA_SHIRQ, "GVP11 SCSI",
44301 +                   instance);
44302         DMA(instance)->CNTR = GVP11_DMAC_INT_ENABLE;
44303 +       num_gvp11++;
44304         continue;
44305  
44306  release:
44307 @@ -391,8 +378,7 @@ int gvp11_release(struct Scsi_Host *inst
44308  #ifdef MODULE
44309      DMA(instance)->CNTR = 0;
44310      release_mem_region(ZTWO_PADDR(instance->base), 256);
44311 -    if (--num_gvp11 == 0)
44312 -           free_irq(IRQ_AMIGA_PORTS, gvp11_intr);
44313 +    free_irq(IRQ_AMIGA_PORTS, instance);
44314      wd33c93_release();
44315  #endif
44316      return 1;
44317 --- linux-2.6.0-test6/drivers/scsi/ide-scsi.c   2003-09-27 18:57:45.000000000 -0700
44318 +++ 25/drivers/scsi/ide-scsi.c  2003-10-05 00:34:01.000000000 -0700
44319 @@ -635,24 +635,23 @@ static ide_driver_t idescsi_driver = {
44320         .drives                 = LIST_HEAD_INIT(idescsi_driver.drives),
44321  };
44322  
44323 -static int idescsi_ide_open(struct inode *inode, struct file *filp)
44324 +static int idescsi_ide_open(struct block_device *bdev, struct file *filp)
44325  {
44326 -       ide_drive_t *drive = inode->i_bdev->bd_disk->private_data;
44327 +       ide_drive_t *drive = bdev->bd_disk->private_data;
44328         drive->usage++;
44329         return 0;
44330  }
44331  
44332 -static int idescsi_ide_release(struct inode *inode, struct file *filp)
44333 +static int idescsi_ide_release(struct gendisk *disk)
44334  {
44335 -       ide_drive_t *drive = inode->i_bdev->bd_disk->private_data;
44336 +       ide_drive_t *drive = disk->private_data;
44337         drive->usage--;
44338         return 0;
44339  }
44340  
44341 -static int idescsi_ide_ioctl(struct inode *inode, struct file *file,
44342 +static int idescsi_ide_ioctl(struct block_device *bdev, struct file *file,
44343                         unsigned int cmd, unsigned long arg)
44344  {
44345 -       struct block_device *bdev = inode->i_bdev;
44346         return generic_ide_ioctl(bdev, cmd, arg);
44347  }
44348  
44349 --- linux-2.6.0-test6/drivers/scsi/Kconfig      2003-09-27 18:57:45.000000000 -0700
44350 +++ 25/drivers/scsi/Kconfig     2003-10-05 00:36:26.000000000 -0700
44351 @@ -55,6 +55,14 @@ config BLK_DEV_SD
44352           In this case, do not compile the driver for your SCSI host adapter
44353           (below) as a module either.
44354  
44355 +config MAX_SD_DISKS
44356 +       int "Maximum number of SCSI disks to support (256-8192)"
44357 +       depends on BLK_DEV_SD
44358 +       default "256"
44359 +       help
44360 +       The maximum number SCSI disks to support. Default is 256.
44361 +       Change this value if you want kernel to support lots of SCSI devices.
44362 +
44363  config CHR_DEV_ST
44364         tristate "SCSI tape support"
44365         depends on SCSI
44366 @@ -1148,16 +1156,6 @@ config SCSI_QLOGIC_1280
44367           To compile this driver as a module, choose M here: the
44368           module will be called qla1280.
44369  
44370 -config SCSI_QLOGIC_1280_PIO
44371 -       bool "Use PIO instead of MMIO" if !X86_VISWS
44372 -       depends on SCSI_QLOGIC_1280
44373 -       default y if X86_VISWS
44374 -       help
44375 -         This instructs the driver to use programmed I/O ports (PIO) instead
44376 -         of PCI shared memory (MMIO).  This can possibly solve some problems
44377 -         in case your mainboard has memory consistency issues.  If unsure,
44378 -         say N.
44379 -
44380  config SCSI_QLOGICPTI
44381         tristate "PTI Qlogic, ISP Driver"
44382         depends on SBUS && SCSI
44383 @@ -1435,7 +1433,7 @@ config A3000_SCSI
44384  
44385  config A4000T_SCSI
44386         bool "A4000T SCSI support (EXPERIMENTAL)"
44387 -       depends on AMIGA && SCSI && EXPERIMENTAL
44388 +       depends on AMIGA && SCSI && EXPERIMENTAL && BROKEN
44389         help
44390           Support for the NCR53C710 SCSI controller on the Amiga 4000T.
44391  
44392 @@ -1503,7 +1501,7 @@ config FASTLANE_SCSI
44393  
44394  config A4091_SCSI
44395         bool "A4091 SCSI support (EXPERIMENTAL)"
44396 -       depends on ZORRO && SCSI && EXPERIMENTAL
44397 +       depends on ZORRO && SCSI && EXPERIMENTAL && BROKEN
44398         help
44399           Support for the NCR53C710 chip on the Amiga 4091 Z3 SCSI2 controller
44400           (1993).  Very obscure -- the 4091 was part of an Amiga 4000 upgrade
44401 @@ -1511,7 +1509,7 @@ config A4091_SCSI
44402  
44403  config WARPENGINE_SCSI
44404         bool "WarpEngine SCSI support (EXPERIMENTAL)"
44405 -       depends on ZORRO && SCSI && EXPERIMENTAL
44406 +       depends on ZORRO && SCSI && EXPERIMENTAL && BROKEN
44407         help
44408           Support for MacroSystem Development's WarpEngine Amiga SCSI-2
44409           controller. Info at
44410 @@ -1519,7 +1517,7 @@ config WARPENGINE_SCSI
44411  
44412  config BLZ603EPLUS_SCSI
44413         bool "Blizzard PowerUP 603e+ SCSI (EXPERIMENTAL)"
44414 -       depends on ZORRO && SCSI && EXPERIMENTAL
44415 +       depends on ZORRO && SCSI && EXPERIMENTAL && BROKEN
44416         help
44417           If you have an Amiga 1200 with a Phase5 Blizzard PowerUP 603e+
44418           accelerator, say Y. Otherwise, say N.
44419 @@ -1535,7 +1533,7 @@ config OKTAGON_SCSI
44420  
44421  config ATARI_SCSI
44422         tristate "Atari native SCSI support"
44423 -       depends on ATARI && SCSI
44424 +       depends on ATARI && SCSI && BROKEN
44425         ---help---
44426           If you have an Atari with built-in NCR5380 SCSI controller (TT,
44427           Falcon, ...) say Y to get it supported. Of course also, if you have
44428 @@ -1604,7 +1602,7 @@ config MVME147_SCSI
44429  
44430  config MVME16x_SCSI
44431         bool "NCR53C710 SCSI driver for MVME16x"
44432 -       depends on MVME16x && SCSI
44433 +       depends on MVME16x && SCSI && BROKEN
44434         help
44435           The Motorola MVME162, 166, 167, 172 and 177 boards use the NCR53C710
44436           SCSI controller chip.  Almost everyone using one of these boards
44437 @@ -1612,7 +1610,7 @@ config MVME16x_SCSI
44438  
44439  config BVME6000_SCSI
44440         bool "NCR53C710 SCSI driver for BVME6000"
44441 -       depends on BVME6000 && SCSI
44442 +       depends on BVME6000 && SCSI && BROKEN
44443         help
44444           The BVME4000 and BVME6000 boards from BVM Ltd use the NCR53C710
44445           SCSI controller chip.  Almost everyone using one of these boards
44446 --- linux-2.6.0-test6/drivers/scsi/megaraid.c   2003-09-08 13:58:58.000000000 -0700
44447 +++ 25/drivers/scsi/megaraid.c  2003-10-05 00:33:24.000000000 -0700
44448 @@ -586,7 +586,7 @@ mega_find_card(Scsi_Host_Template *host_
44449  
44450                 /* Set the Mode of addressing to 64 bit if we can */
44451                 if((adapter->flag & BOARD_64BIT)&&(sizeof(dma_addr_t) == 8)) {
44452 -                       pci_set_dma_mask(pdev, 0xffffffffffffffff);
44453 +                       pci_set_dma_mask(pdev, 0xffffffffffffffffULL);
44454                         adapter->has_64bit_addr = 1;
44455                 }
44456                 else  {
44457 --- linux-2.6.0-test6/drivers/scsi/ncr53c8xx.c  2003-09-27 18:57:45.000000000 -0700
44458 +++ 25/drivers/scsi/ncr53c8xx.c 2003-10-05 00:33:24.000000000 -0700
44459 @@ -7757,7 +7757,7 @@ static void ncr_init_ccb(ncb_p np, ccb_p
44460         cp->start.schedule.l_cmd = cpu_to_scr(SCR_JUMP);
44461         cp->start.p_phys         = cpu_to_scr(CCB_PHYS(cp, phys));
44462  
44463 -       bcopy(&cp->start, &cp->restart, sizeof(cp->restart));
44464 +       memcpy(&cp->restart, &cp->start, sizeof(cp->restart));
44465  
44466         cp->start.schedule.l_paddr   = cpu_to_scr(NCB_SCRIPT_PHYS (np, idle));
44467         cp->restart.schedule.l_paddr = cpu_to_scr(NCB_SCRIPTH_PHYS (np, abort));
44468 --- linux-2.6.0-test6/drivers/scsi/nsp32.c      2003-09-08 13:58:58.000000000 -0700
44469 +++ 25/drivers/scsi/nsp32.c     2003-10-05 00:33:24.000000000 -0700
44470 @@ -3435,15 +3435,6 @@ static inline int nsp32_prom_get(nsp32_h
44471   * Power Management
44472   */
44473  #ifdef CONFIG_PM
44474 -/* Save Device Context */
44475 -static int nsp32_save_state(struct pci_dev *pdev, u32 state)
44476 -{
44477 -       struct Scsi_Host *host = pci_get_drvdata(pdev);
44478 -
44479 -       nsp32_msg(KERN_INFO, "pci-save_state: stub, pdev=0x%p, state=%ld, slot=%s, host=0x%p", pdev, state, pci_name(pdev), host);
44480 -
44481 -       return 0;
44482 -}
44483  
44484  /* Device suspended */
44485  static int nsp32_suspend(struct pci_dev *pdev, u32 state)
44486 @@ -3573,7 +3564,6 @@ static struct pci_driver nsp32_driver = 
44487         .probe          = nsp32_probe,
44488         .remove         = __devexit_p(nsp32_remove),
44489  #ifdef CONFIG_PM
44490 -       .save_state     = nsp32_save_state,
44491         .suspend        = nsp32_suspend, 
44492         .resume         = nsp32_resume, 
44493         .enable_wake    = nsp32_enable_wake,
44494 --- linux-2.6.0-test6/drivers/scsi/qla1280.c    2003-09-27 18:57:45.000000000 -0700
44495 +++ 25/drivers/scsi/qla1280.c   2003-10-05 00:33:24.000000000 -0700
44496 @@ -16,10 +16,15 @@
44497  * General Public License for more details.
44498  *
44499  ******************************************************************************/
44500 -#define QLA1280_VERSION      "3.23.36"
44501 +#define QLA1280_VERSION      "3.23.37"
44502  /*****************************************************************************
44503      Revision History:
44504 -    Rev  3.23.36 September 19, 2003, Christoph Hellwig
44505 +    Rev  3.23.37 October 1, 2003, Jes Sorensen
44506 +       - Make MMIO depend on CONFIG_X86_VISWS instead of yet another
44507 +         random CONFIG option
44508 +       - Clean up locking in probe path
44509 +    Rev  3.23.36 October 1, 2003, Christoph Hellwig
44510 +       - queuecommand only ever receives new commands - clear flags
44511         - Reintegrate lost fixes from Linux 2.5
44512      Rev  3.23.35 August 14, 2003, Jes Sorensen
44513         - Build against 2.6
44514 @@ -315,14 +320,14 @@
44515  
44516  #if LINUX_VERSION_CODE >= 0x020545
44517  #include <scsi/scsi_host.h>
44518 +#include "scsi.h"
44519  #else
44520  #include <linux/blk.h>
44521 +#include "scsi.h"
44522  #include "hosts.h"
44523  #include "sd.h"
44524  #endif
44525  
44526 -#include "scsi.h"
44527 -
44528  #if LINUX_VERSION_CODE < 0x020407
44529  #error "Kernels older than 2.4.7 are no longer supported"
44530  #endif
44531 @@ -339,7 +344,10 @@
44532  #define  DEBUG_PRINT_NVRAM     0
44533  #define  DEBUG_QLA1280         0
44534  
44535 -#ifdef CONFIG_SCSI_QLOGIC_1280_PIO
44536 +/*
44537 + * The SGI VISWS is broken and doesn't support MMIO ;-(
44538 + */
44539 +#ifdef CONFIG_X86_VISWS
44540  #define        MEMORY_MAPPED_IO        0
44541  #else
44542  #define        MEMORY_MAPPED_IO        1
44543 @@ -414,6 +422,11 @@ scsi_adjust_queue_depth(Scsi_Device *dev
44544  #else
44545  #define HOST_LOCK                      ha->host->host_lock
44546  #endif
44547 +#if LINUX_VERSION_CODE < 0x020600
44548 +#define DEV_SIMPLE_TAGS(device)                device->tagged_queue
44549 +#else
44550 +#define DEV_SIMPLE_TAGS(device)                device->simple_tags
44551 +#endif
44552  #if defined(__ia64__) && !defined(ia64_platform_is)
44553  #define ia64_platform_is(foo)          (!strcmp(x, platform_name))
44554  #endif
44555 @@ -647,11 +660,11 @@ static int ql_debug_level = 1;
44556  #define        PROC_BUF        &qla1280_buffer[len]
44557  
44558  #if LINUX_VERSION_CODE < 0x020600
44559 -static int qla1280_proc_info(char *buffer, char **start, off_t offset, int length,
44560 -                     int hostno, int inout)
44561 +static int qla1280_proc_info(char *buffer, char **start, off_t offset,
44562 +                            int length, int hostno, int inout)
44563  #else
44564 -static int qla1280_proc_info(struct Scsi_Host *host, char *buffer, char **start,
44565 -                     off_t offset, int length, int inout)
44566 +static int qla1280_proc_info(struct Scsi_Host *host, char *buffer,
44567 +                            char **start, off_t offset, int length, int inout)
44568  #endif
44569  {
44570         struct scsi_qla_host *ha;
44571 @@ -955,8 +968,8 @@ qla1280_do_device_init(struct pci_dev *p
44572                        host->io_port, host->io_port + 0xff);
44573                 goto error_free_irq;
44574         }
44575 -
44576  #endif
44577 +
44578         /* load the F/W, read paramaters, and init the H/W */
44579         if (qla1280_initialize_adapter(ha)) {
44580                 printk(KERN_INFO "qla1x160: Failed to initialize adapter\n");
44581 @@ -1598,6 +1611,7 @@ qla1280_intr_handler(int irq, void *dev_
44582         return IRQ_RETVAL(handled);
44583  }
44584  
44585 +
44586  static int
44587  qla12160_set_target_parameters(struct scsi_qla_host *ha, int bus, int target)
44588  {
44589 @@ -1666,9 +1680,7 @@ qla1280_slave_configure(Scsi_Device *dev
44590         int target = device->id;
44591         int status = 0;
44592         struct nvram *nv;
44593 -#if LINUX_VERSION_CODE < 0x020500
44594         unsigned long flags;
44595 -#endif
44596  
44597         ha = (struct scsi_qla_host *)device->host->hostdata;
44598         nv = &ha->nvram;
44599 @@ -1706,17 +1718,13 @@ qla1280_slave_configure(Scsi_Device *dev
44600                         nv->bus[bus].target[target].ppr_1x160.flags.enable_ppr = 0;
44601         }
44602  
44603 -#if LINUX_VERSION_CODE < 0x020500
44604         spin_lock_irqsave(HOST_LOCK, flags);
44605 -#endif
44606         if (nv->bus[bus].target[target].parameter.f.enable_sync) {
44607                 status = qla12160_set_target_parameters(ha, bus, target);
44608         }
44609  
44610         qla12160_get_target_parameters(ha, device);
44611 -#if LINUX_VERSION_CODE < 0x020500
44612         spin_unlock_irqrestore(HOST_LOCK, flags);
44613 -#endif
44614         return status;
44615  }
44616  
44617 @@ -1995,7 +2003,7 @@ qla1280_mem_alloc(struct scsi_qla_host *
44618         if (ha->request_ring)
44619                 pci_free_consistent(ha->pdev,
44620                                      ((REQUEST_ENTRY_CNT + 1) *
44621 -                                     (sizeof(request_t))),
44622 +                                    (sizeof(request_t))),
44623                                      ha->request_ring, ha->request_dma);
44624   finish:
44625         LEAVE("qla1280_mem_alloc");
44626 @@ -2088,6 +2096,9 @@ qla1280_initialize_adapter(struct scsi_q
44627         struct device_reg *reg;
44628         int status;
44629         int bus;
44630 +#if LINUX_VERSION_CODE > 0x020500
44631 +       unsigned long flags;
44632 +#endif
44633  
44634         ENTER("qla1280_initialize_adapter");
44635  
44636 @@ -2131,6 +2142,15 @@ qla1280_initialize_adapter(struct scsi_q
44637                         "NVRAM\n");
44638         }
44639  
44640 +#if LINUX_VERSION_CODE >= 0x020500
44641 +       /*
44642 +        * It's necessary to grab the spin here as qla1280_mailbox_command
44643 +        * needs to be able to drop the lock unconditionally to wait
44644 +        * for completion.
44645 +        * In 2.4 ->detect is called with the io_request_lock held.
44646 +        */
44647 +       spin_lock_irqsave(HOST_LOCK, flags);
44648 +#endif
44649         /* If firmware needs to be loaded */
44650         if (qla1280_isp_firmware(ha)) {
44651                 if (!(status = qla1280_chip_diag (ha))) {
44652 @@ -2183,6 +2203,9 @@ qla1280_initialize_adapter(struct scsi_q
44653                 status = 1;
44654  
44655   out:
44656 +#if LINUX_VERSION_CODE >= 0x020500
44657 +       spin_unlock_irqrestore(HOST_LOCK, flags);
44658 +#endif
44659         if (status)
44660                 dprintk(2, "qla1280_initialize_adapter: **** FAILED ****\n");
44661  
44662 @@ -3208,18 +3231,14 @@ qla1280_mailbox_command(struct scsi_qla_
44663         timer.function = qla1280_mailbox_timeout;
44664         add_timer(&timer);
44665  
44666 -#if LINUX_VERSION_CODE < 0x020500
44667         spin_unlock_irq(HOST_LOCK);
44668 -#endif
44669         WRT_REG_WORD(&reg->host_cmd, HC_SET_HOST_INT);
44670         data = qla1280_debounce_register(&reg->istatus);
44671  
44672         wait_for_completion(&wait);
44673         del_timer_sync(&timer);
44674  
44675 -#if LINUX_VERSION_CODE < 0x020500
44676         spin_lock_irq(HOST_LOCK);
44677 -#endif
44678  
44679         ha->mailbox_wait = NULL;
44680  
44681 @@ -3636,7 +3655,7 @@ qla1280_64bit_start_scsi(struct scsi_qla
44682                 (SCSI_TCN_32(cmd) | BIT_7) : SCSI_TCN_32(cmd);
44683  
44684         /* Enable simple tag queuing if device supports it. */
44685 -       if (cmd->device->simple_tags)
44686 +       if (DEV_SIMPLE_TAGS(cmd->device))
44687                 pkt->control_flags |= cpu_to_le16(BIT_3);
44688  
44689         /* Load SCSI command packet. */
44690 @@ -3936,7 +3955,7 @@ qla1280_32bit_start_scsi(struct scsi_qla
44691                 (SCSI_TCN_32(cmd) | BIT_7) : SCSI_TCN_32(cmd);
44692  
44693         /* Enable simple tag queuing if device supports it. */
44694 -       if (cmd->device->simple_tags)
44695 +       if (DEV_SIMPLE_TAGS(cmd->device))
44696                 pkt->control_flags |= cpu_to_le16(BIT_3);
44697  
44698         /* Load SCSI command packet. */
44699 @@ -4823,6 +4842,7 @@ qla1280_debounce_register(volatile u16 *
44700         return ret;
44701  }
44702  
44703 +
44704  /************************************************************************
44705   * qla1280_check_for_dead_scsi_bus                                      *
44706   *                                                                      *
44707 @@ -4891,7 +4911,7 @@ qla12160_get_target_parameters(struct sc
44708         } else
44709                 printk(" Async");
44710  
44711 -       if (device->simple_tags)
44712 +       if (DEV_SIMPLE_TAGS(device))
44713                 printk(", Tagged queuing: depth %d", device->queue_depth);
44714         printk("\n");
44715  }
44716 @@ -5105,6 +5125,7 @@ qla1280_get_token(char *str)
44717         return ret;
44718  }
44719  
44720 +
44721  static Scsi_Host_Template driver_template = {
44722         .proc_info              = qla1280_proc_info,
44723         .name                   = "Qlogic ISP 1280/12160",
44724 @@ -5132,6 +5153,7 @@ static Scsi_Host_Template driver_templat
44725  
44726  #include "scsi_module.c"
44727  
44728 +
44729  /*
44730   * Overrides for Emacs so that we almost follow Linus's tabbing style.
44731   * Emacs will notice this stuff at the end of the file and automatically
44732 --- linux-2.6.0-test6/drivers/scsi/qlogicfc.c   2003-08-22 19:23:41.000000000 -0700
44733 +++ 25/drivers/scsi/qlogicfc.c  2003-10-05 00:33:24.000000000 -0700
44734 @@ -718,8 +718,8 @@ int isp2x00_detect(Scsi_Host_Template * 
44735                                 continue;
44736  
44737                         /* Try to configure DMA attributes. */
44738 -                       if (pci_set_dma_mask(pdev, (u64) 0xffffffffffffffff) &&
44739 -                           pci_set_dma_mask(pdev, (u64) 0xffffffff))
44740 +                       if (pci_set_dma_mask(pdev, 0xffffffffffffffffULL) &&
44741 +                           pci_set_dma_mask(pdev, 0xffffffffULL))
44742                                         continue;
44743  
44744                         host = scsi_register(tmpt, sizeof(struct isp2x00_hostdata));
44745 --- linux-2.6.0-test6/drivers/scsi/sd.c 2003-09-27 18:57:46.000000000 -0700
44746 +++ 25/drivers/scsi/sd.c        2003-10-05 00:36:26.000000000 -0700
44747 @@ -62,6 +62,7 @@
44748   */
44749  #define SD_MAJORS      16
44750  #define SD_DISKS       (SD_MAJORS << 4)
44751 +#define TOTAL_SD_DISKS CONFIG_MAX_SD_DISKS
44752  
44753  /*
44754   * Time out in seconds for disks and Magneto-opticals (which are slower).
44755 @@ -87,7 +88,7 @@ struct scsi_disk {
44756         unsigned        RCD : 1;        /* state of disk RCD bit, unused */
44757  };
44758  
44759 -static unsigned long sd_index_bits[SD_DISKS / BITS_PER_LONG];
44760 +static unsigned long sd_index_bits[TOTAL_SD_DISKS / BITS_PER_LONG];
44761  static spinlock_t sd_index_lock = SPIN_LOCK_UNLOCKED;
44762  
44763  static int sd_revalidate_disk(struct gendisk *disk);
44764 @@ -122,6 +123,9 @@ static int sd_major(int major_idx)
44765                 return SCSI_DISK1_MAJOR + major_idx - 1;
44766         case 8 ... 15:
44767                 return SCSI_DISK8_MAJOR + major_idx - 8;
44768 +#define MAX_IDX        (TOTAL_SD_DISKS >> 4)
44769 +       case 16 ... MAX_IDX:
44770 +               return SCSI_DISK15_MAJOR;
44771         default:
44772                 BUG();
44773                 return 0;       /* shut up gcc */
44774 @@ -348,9 +352,9 @@ queue:
44775   *     In the latter case @inode and @filp carry an abridged amount
44776   *     of information as noted above.
44777   **/
44778 -static int sd_open(struct inode *inode, struct file *filp)
44779 +static int sd_open(struct block_device *bdev, struct file *filp)
44780  {
44781 -       struct gendisk *disk = inode->i_bdev->bd_disk;
44782 +       struct gendisk *disk = bdev->bd_disk;
44783         struct scsi_disk *sdkp = scsi_disk(disk);
44784         struct scsi_device *sdev = sdkp->device;
44785         int retval;
44786 @@ -370,7 +374,7 @@ static int sd_open(struct inode *inode, 
44787                 goto error_out;
44788  
44789         if (sdev->removable || sdkp->write_prot)
44790 -               check_disk_change(inode->i_bdev);
44791 +               check_disk_change(bdev);
44792  
44793         /*
44794          * If the drive is empty, just let the open fail.
44795 @@ -421,9 +425,8 @@ error_out:
44796   *     Note: may block (uninterruptible) if error recovery is underway
44797   *     on this disk.
44798   **/
44799 -static int sd_release(struct inode *inode, struct file *filp)
44800 +static int sd_release(struct gendisk *disk)
44801  {
44802 -       struct gendisk *disk = inode->i_bdev->bd_disk;
44803         struct scsi_disk *sdkp = scsi_disk(disk);
44804         struct scsi_device *sdev = sdkp->device;
44805  
44806 @@ -486,10 +489,9 @@ static int sd_hdio_getgeo(struct block_d
44807   *     Note: most ioctls are forward onto the block subsystem or further
44808   *     down in the scsi subsytem.
44809   **/
44810 -static int sd_ioctl(struct inode * inode, struct file * filp, 
44811 +static int sd_ioctl(struct block_device *bdev, struct file *filp, 
44812                     unsigned int cmd, unsigned long arg)
44813  {
44814 -       struct block_device *bdev = inode->i_bdev;
44815         struct gendisk *disk = bdev->bd_disk;
44816         struct scsi_device *sdp = scsi_disk(disk)->device;
44817         int error;
44818 @@ -1275,8 +1277,8 @@ static int sd_probe(struct device *dev)
44819                 goto out_free;
44820  
44821         spin_lock(&sd_index_lock);
44822 -       index = find_first_zero_bit(sd_index_bits, SD_DISKS);
44823 -       if (index == SD_DISKS) {
44824 +       index = find_first_zero_bit(sd_index_bits, TOTAL_SD_DISKS);
44825 +       if (index == TOTAL_SD_DISKS) {
44826                 spin_unlock(&sd_index_lock);
44827                 error = -EBUSY;
44828                 goto out_put;
44829 @@ -1291,15 +1293,24 @@ static int sd_probe(struct device *dev)
44830         sdkp->openers = 0;
44831  
44832         gd->major = sd_major(index >> 4);
44833 -       gd->first_minor = (index & 15) << 4;
44834 +       if (index > SD_DISKS)
44835 +               gd->first_minor = ((index - SD_DISKS) & 15) << 4;
44836 +       else
44837 +               gd->first_minor = (index & 15) << 4;
44838         gd->minors = 16;
44839         gd->fops = &sd_fops;
44840  
44841 -       if (index >= 26) {
44842 +       if (index < 26) {
44843 +               sprintf(gd->disk_name, "sd%c", 'a' + index % 26);
44844 +       } else if (index < (26*27)) {
44845                 sprintf(gd->disk_name, "sd%c%c",
44846                         'a' + index/26-1,'a' + index % 26);
44847         } else {
44848 -               sprintf(gd->disk_name, "sd%c", 'a' + index % 26);
44849 +               const unsigned int m1 = (index/ 26 - 1) / 26 - 1;
44850 +               const unsigned int m2 = (index / 26 - 1) % 26;
44851 +               const unsigned int m3 = index % 26;
44852 +               sprintf(gd->disk_name, "sd%c%c%c",
44853 +                       'a' + m1, 'a' + m2, 'a' + m3);
44854         }
44855  
44856         strcpy(gd->devfs_name, sdp->devfs_name);
44857 --- linux-2.6.0-test6/drivers/scsi/sr.c 2003-09-27 18:57:46.000000000 -0700
44858 +++ 25/drivers/scsi/sr.c        2003-10-05 00:34:45.000000000 -0700
44859 @@ -289,12 +289,12 @@ static int sr_init_command(struct scsi_c
44860                         return 0;
44861  
44862                 memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
44863 -               if (rq_data_dir(rq) == WRITE)
44864 +               if (!rq->data_len)
44865 +                       SCpnt->sc_data_direction = SCSI_DATA_NONE;
44866 +               else if (rq_data_dir(rq) == WRITE)
44867                         SCpnt->sc_data_direction = SCSI_DATA_WRITE;
44868 -               else if (rq->data_len)
44869 -                       SCpnt->sc_data_direction = SCSI_DATA_READ;
44870                 else
44871 -                       SCpnt->sc_data_direction = SCSI_DATA_NONE;
44872 +                       SCpnt->sc_data_direction = SCSI_DATA_READ;
44873  
44874                 this_count = rq->data_len;
44875                 if (rq->timeout)
44876 @@ -413,22 +413,22 @@ queue:
44877         return 1;
44878  }
44879  
44880 -static int sr_block_open(struct inode *inode, struct file *file)
44881 +static int sr_block_open(struct block_device *bdev, struct file *file)
44882  {
44883 -       struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk);
44884 -       return cdrom_open(&cd->cdi, inode, file);
44885 +       struct scsi_cd *cd = scsi_cd(bdev->bd_disk);
44886 +       return cdrom_open(&cd->cdi, bdev, file);
44887  }
44888  
44889 -static int sr_block_release(struct inode *inode, struct file *file)
44890 +static int sr_block_release(struct gendisk *disk)
44891  {
44892 -       struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk);
44893 -       return cdrom_release(&cd->cdi, file);
44894 +       struct scsi_cd *cd = scsi_cd(disk);
44895 +       return cdrom_release(&cd->cdi);
44896  }
44897  
44898 -static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd,
44899 -                         unsigned long arg)
44900 +static int sr_block_ioctl(struct block_device *bdev, struct file *file,
44901 +                         unsigned cmd, unsigned long arg)
44902  {
44903 -       struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk);
44904 +       struct scsi_cd *cd = scsi_cd(bdev->bd_disk);
44905         struct scsi_device *sdev = cd->device;
44906  
44907          /*
44908 @@ -440,7 +440,7 @@ static int sr_block_ioctl(struct inode *
44909                  case SCSI_IOCTL_GET_BUS_NUMBER:
44910                          return scsi_ioctl(sdev, cmd, (void *)arg);
44911         }
44912 -       return cdrom_ioctl(&cd->cdi, inode, cmd, arg);
44913 +       return cdrom_ioctl(&cd->cdi, bdev, cmd, arg);
44914  }
44915  
44916  static int sr_block_media_changed(struct gendisk *disk)
44917 --- linux-2.6.0-test6/drivers/scsi/sun3_scsi.c  2003-07-27 12:14:40.000000000 -0700
44918 +++ 25/drivers/scsi/sun3_scsi.c 2003-10-05 00:33:24.000000000 -0700
44919 @@ -308,7 +308,6 @@ int sun3scsi_detect(Scsi_Host_Template *
44920         return 1;
44921  }
44922  
44923 -#ifdef MODULE
44924  int sun3scsi_release (struct Scsi_Host *shpnt)
44925  {
44926         if (shpnt->irq != SCSI_IRQ_NONE)
44927 @@ -318,7 +317,6 @@ int sun3scsi_release (struct Scsi_Host *
44928  
44929         return 0;
44930  }
44931 -#endif
44932  
44933  #ifdef RESET_BOOT
44934  /*
44935 --- linux-2.6.0-test6/drivers/scsi/sun3_scsi.h  2003-09-08 13:58:58.000000000 -0700
44936 +++ 25/drivers/scsi/sun3_scsi.h 2003-10-05 00:33:24.000000000 -0700
44937 @@ -52,11 +52,7 @@ static int sun3scsi_detect (Scsi_Host_Te
44938  static const char *sun3scsi_info (struct Scsi_Host *);
44939  static int sun3scsi_bus_reset(Scsi_Cmnd *);
44940  static int sun3scsi_queue_command (Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
44941 -#ifdef MODULE
44942  static int sun3scsi_release (struct Scsi_Host *);
44943 -#else
44944 -#define sun3scsi_release NULL
44945 -#endif
44946  
44947  #ifndef CMD_PER_LUN
44948  #define CMD_PER_LUN 2
44949 --- linux-2.6.0-test6/drivers/scsi/sun3_scsi_vme.c      2003-07-27 12:14:40.000000000 -0700
44950 +++ 25/drivers/scsi/sun3_scsi_vme.c     2003-10-05 00:33:24.000000000 -0700
44951 @@ -140,7 +140,7 @@ static struct Scsi_Host *default_instanc
44952   
44953  static int sun3scsi_detect(Scsi_Host_Template * tpnt)
44954  {
44955 -       unsigned long ioaddr, irq;
44956 +       unsigned long ioaddr, irq = 0;
44957         static int called = 0;
44958         struct Scsi_Host *instance;
44959         int i;
44960 @@ -277,17 +277,15 @@ static int sun3scsi_detect(Scsi_Host_Tem
44961         return 1;
44962  }
44963  
44964 -#ifdef MODULE
44965  int sun3scsi_release (struct Scsi_Host *shpnt)
44966  {
44967         if (shpnt->irq != SCSI_IRQ_NONE)
44968                 free_irq (shpnt->irq, NULL);
44969  
44970 -       iounmap(sun3_scsi_regp);
44971 +       iounmap((void *)sun3_scsi_regp);
44972  
44973         return 0;
44974  }
44975 -#endif
44976  
44977  #ifdef RESET_BOOT
44978  /*
44979 --- linux-2.6.0-test6/drivers/scsi/sym53c8xx_2/sym_glue.c       2003-09-27 18:57:46.000000000 -0700
44980 +++ 25/drivers/scsi/sym53c8xx_2/sym_glue.c      2003-10-05 00:34:19.000000000 -0700
44981 @@ -2159,8 +2159,7 @@ sym53c8xx_pci_init(struct pci_dev *pdev,
44982  
44983         /* If the chip can do Memory Write Invalidate, enable it */
44984         if (chip->features & FE_WRIE) {
44985 -               if (pci_set_mwi(pdev))
44986 -                       return -1;
44987 +               pci_set_mwi(pdev);
44988         }
44989  
44990         /*
44991 --- linux-2.6.0-test6/drivers/scsi/sym53c8xx_2/sym_glue.h       2003-09-27 18:57:46.000000000 -0700
44992 +++ 25/drivers/scsi/sym53c8xx_2/sym_glue.h      2003-10-05 00:33:24.000000000 -0700
44993 @@ -70,10 +70,6 @@
44994  #include <scsi/scsi_host.h>
44995  #include "../scsi.h"           /* XXX: DID_* */
44996  
44997 -#ifndef bcopy
44998 -#define bcopy(s, d, n) memcpy((d), (s), (n))
44999 -#endif
45000 -
45001  #ifndef bzero
45002  #define bzero(d, n)    memset((d), 0, (n))
45003  #endif
45004 --- linux-2.6.0-test6/drivers/scsi/sym53c8xx_2/sym_hipd.c       2003-09-27 18:57:46.000000000 -0700
45005 +++ 25/drivers/scsi/sym53c8xx_2/sym_hipd.c      2003-10-05 00:34:20.000000000 -0700
45006 @@ -838,7 +838,8 @@ static int sym_prepare_setting(hcb_p np,
45007  
45008         period = parisc_setup_hcb(np, period);
45009  
45010 -       if      (period <= 250)         np->minsync = 10;
45011 +       if      (period == 250)         np->minsync = 9;
45012 +       else if (period <= 250)         np->minsync = 10;
45013         else if (period <= 303)         np->minsync = 11;
45014         else if (period <= 500)         np->minsync = 12;
45015         else                            np->minsync = (period + 40 - 1) / 40;
45016 @@ -5889,9 +5890,9 @@ int sym_hcb_attach(hcb_p np, struct sym_
45017         /*
45018          *  Copy scripts to controller instance.
45019          */
45020 -       bcopy(fw->a_base, np->scripta0, np->scripta_sz);
45021 -       bcopy(fw->b_base, np->scriptb0, np->scriptb_sz);
45022 -       bcopy(fw->z_base, np->scriptz0, np->scriptz_sz);
45023 +       memcpy(np->scripta0, fw->a_base, np->scripta_sz);
45024 +       memcpy(np->scriptb0, fw->b_base, np->scriptb_sz);
45025 +       memcpy(np->scriptz0, fw->z_base, np->scriptz_sz);
45026  
45027         /*
45028          *  Setup variable parts in scripts and compute
45029 --- linux-2.6.0-test6/drivers/scsi/sym53c8xx_2/sym_misc.c       2003-06-14 12:18:32.000000000 -0700
45030 +++ 25/drivers/scsi/sym53c8xx_2/sym_misc.c      2003-10-05 00:33:24.000000000 -0700
45031 @@ -225,7 +225,7 @@ void sym_announce_transfer_rate(hcb_p np
45032   */
45033  void sym_update_trans_settings(hcb_p np, tcb_p tp)
45034  {
45035 -       bcopy(&tp->tinfo.user, &tp->tinfo.goal, sizeof(tp->tinfo.goal));
45036 +       memcpy(&tp->tinfo.goal, &tp->tinfo.user, sizeof(tp->tinfo.goal));
45037  
45038         if (tp->inq_version >= 4) {
45039                 switch(tp->inq_byte56 & INQ56_CLOCKING) {
45040 --- linux-2.6.0-test6/drivers/scsi/sym53c8xx_comm.h     2003-09-27 18:57:46.000000000 -0700
45041 +++ 25/drivers/scsi/sym53c8xx_comm.h    2003-10-05 00:33:24.000000000 -0700
45042 @@ -88,10 +88,6 @@
45043  #define u_int          unsigned int
45044  #define u_long         unsigned long
45045  
45046 -#ifndef bcopy
45047 -#define bcopy(s, d, n) memcpy((d), (s), (n))
45048 -#endif
45049 -
45050  #ifndef bcmp
45051  #define bcmp(s, d, n)  memcmp((d), (s), (n))
45052  #endif
45053 --- linux-2.6.0-test6/drivers/serial/8250.c     2003-09-27 18:57:46.000000000 -0700
45054 +++ 25/drivers/serial/8250.c    2003-10-05 00:36:10.000000000 -0700
45055 @@ -469,8 +469,14 @@ static void autoconfig_16550a(struct uar
45056          */
45057         serial_outp(up, UART_LCR, UART_LCR_DLAB);
45058         if (serial_in(up, UART_EFR) == 0) {
45059 -               DEBUG_AUTOCONF("EFRv1 ");
45060 -               up->port.type = PORT_16650;
45061 +               serial_outp(up, UART_EFR, 0xA8);
45062 +               if (serial_in(up, UART_EFR) != 0) {
45063 +                       DEBUG_AUTOCONF("EFRv1 ");
45064 +                       up->port.type = PORT_16650;
45065 +               } else {
45066 +                       DEBUG_AUTOCONF("Motorola 8xxx DUART ");
45067 +               }
45068 +               serial_outp(up, UART_EFR, 0);
45069                 return;
45070         }
45071  
45072 @@ -490,7 +496,9 @@ static void autoconfig_16550a(struct uar
45073          * Attempt to switch to bank 2, read the value of the LOOP bit
45074          * from EXCR1. Switch back to bank 0, change it in MCR. Then
45075          * switch back to bank 2, read it from EXCR1 again and check
45076 -        * it's changed. If so, set baud_base in EXCR2 to 921600.
45077 +        * it's changed. If so, set baud_base in EXCR2 to 921600. -- dwmw2
45078 +        * On PowerPC we don't want to change baud_base, as we have
45079 +        * a number of different divisors.  -- Tom Rini
45080          */
45081         serial_outp(up, UART_LCR, 0);
45082         status1 = serial_in(up, UART_MCR);
45083 @@ -506,12 +514,14 @@ static void autoconfig_16550a(struct uar
45084                 serial_outp(up, UART_MCR, status1);
45085  
45086                 if ((status2 ^ status1) & UART_MCR_LOOP) {
45087 +#ifndef CONFIG_PPC
45088                         serial_outp(up, UART_LCR, 0xE0);
45089                         status1 = serial_in(up, 0x04); /* EXCR1 */
45090                         status1 &= ~0xB0; /* Disable LOCK, mask out PRESL[01] */
45091                         status1 |= 0x10;  /* 1.625 divisor for baud_base --> 921600 */
45092                         serial_outp(up, 0x04, status1);
45093                         serial_outp(up, UART_LCR, 0);
45094 +#endif
45095  
45096                         up->port.type = PORT_NS16550A;
45097                         up->port.uartclk = 921600*16;
45098 @@ -825,7 +835,7 @@ receive_chars(struct uart_8250_port *up,
45099                 if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) {
45100                         tty->flip.work.func((void *)tty);
45101                         if (tty->flip.count >= TTY_FLIPBUF_SIZE)
45102 -                               return; // if TTY_DONT_FLIP is set
45103 +                               return; /* if TTY_DONT_FLIP is set */
45104                 }
45105                 ch = serial_inp(up, UART_RX);
45106                 *tty->flip.char_buf_ptr = ch;
45107 @@ -1186,12 +1196,21 @@ static void serial8250_break_ctl(struct 
45108         spin_unlock_irqrestore(&up->port.lock, flags);
45109  }
45110  
45111 +#ifdef CONFIG_KGDB
45112 +static int kgdb_irq = -1;
45113 +#endif
45114 +
45115  static int serial8250_startup(struct uart_port *port)
45116  {
45117         struct uart_8250_port *up = (struct uart_8250_port *)port;
45118         unsigned long flags;
45119         int retval;
45120  
45121 +#ifdef CONFIG_KGDB
45122 +       if (up->port.irq == kgdb_irq)
45123 +               return -EBUSY;
45124 +#endif
45125 +
45126         up->capabilities = uart_config[up->port.type].flags;
45127  
45128         if (up->port.type == PORT_16C950) {
45129 @@ -1857,6 +1876,10 @@ static void __init serial8250_register_p
45130         for (i = 0; i < UART_NR; i++) {
45131                 struct uart_8250_port *up = &serial8250_ports[i];
45132  
45133 +#ifdef CONFIG_KGDB
45134 +               if (up->port.irq == kgdb_irq)
45135 +                       up->port.kgdb = 1;
45136 +#endif
45137                 up->port.line = i;
45138                 up->port.ops = &serial8250_pops;
45139                 init_timer(&up->timer);
45140 @@ -2101,7 +2124,8 @@ void serial8250_get_irq_map(unsigned int
45141  
45142  /**
45143   *     serial8250_suspend_port - suspend one serial port
45144 - *     @line: serial line number
45145 + *     @line:  serial line number
45146 + *      @level: the level of port suspension, as per uart_suspend_port
45147   *
45148   *     Suspend one serial port.
45149   */
45150 @@ -2112,7 +2136,8 @@ void serial8250_suspend_port(int line)
45151  
45152  /**
45153   *     serial8250_resume_port - resume one serial port
45154 - *     @line: serial line number
45155 + *     @line:  serial line number
45156 + *      @level: the level of port resumption, as per uart_resume_port
45157   *
45158   *     Resume one serial port.
45159   */
45160 @@ -2121,6 +2146,31 @@ void serial8250_resume_port(int line)
45161         uart_resume_port(&serial8250_reg, &serial8250_ports[line].port);
45162  }
45163  
45164 +#ifdef CONFIG_KGDB
45165 +/*
45166 + * Find all the ports using the given irq and shut them down.
45167 + * Result should be that the irq will be released.
45168 + */
45169 +void shutdown_for_kgdb(struct async_struct * info)
45170 +{
45171 +        int irq = info->state->irq;
45172 +        struct uart_8250_port *up;
45173 +       int ttyS;
45174 +
45175 +       kgdb_irq = irq;                 /* save for later init */
45176 +       for (ttyS = 0; ttyS < UART_NR; ttyS++){
45177 +               up =  &serial8250_ports[ttyS];
45178 +               if (up->port.irq == irq && (irq_lists + irq)->head) {
45179 +#ifdef CONFIG_DEBUG_SPINLOCK   /* ugly business... */
45180 +                       if(up->port.lock.magic != SPINLOCK_MAGIC)
45181 +                               spin_lock_init(&up->port.lock);
45182 +#endif
45183 +                       serial8250_shutdown(&up->port);
45184 +               }
45185 +        }
45186 +}
45187 +#endif /* CONFIG_KGDB */
45188 +
45189  static int __init serial8250_init(void)
45190  {
45191         int ret, i;
45192 --- linux-2.6.0-test6/drivers/serial/serial_core.c      2003-09-27 18:57:46.000000000 -0700
45193 +++ 25/drivers/serial/serial_core.c     2003-10-05 00:36:10.000000000 -0700
45194 @@ -263,9 +263,9 @@ static void uart_shutdown(struct uart_st
45195  
45196  /**
45197   *     uart_update_timeout - update per-port FIFO timeout.
45198 - *     @port: uart_port structure describing the port.
45199 + *     @port:  uart_port structure describing the port
45200   *     @cflag: termios cflag value
45201 - *     @quot: uart clock divisor quotient
45202 + *     @baud:  speed of the port
45203   *
45204   *     Set the port FIFO timeout value.  The @cflag value should
45205   *     reflect the actual hardware settings.
45206 @@ -1973,6 +1973,11 @@ uart_configure_port(struct uart_driver *
45207  {
45208         unsigned int flags;
45209  
45210 +#ifdef CONFIG_KGDB
45211 +       if (port->kgdb)
45212 +               return;
45213 +#endif
45214 +
45215         /*
45216          * If there isn't a port here, don't do anything further.
45217          */
45218 --- linux-2.6.0-test6/drivers/telephony/ixj.h   2003-06-22 12:04:44.000000000 -0700
45219 +++ 25/drivers/telephony/ixj.h  2003-10-05 00:33:24.000000000 -0700
45220 @@ -42,6 +42,7 @@ static char ixj_h_rcsid[] = "$Id: ixj.h,
45221  
45222  #define IXJ_VERSION 3031
45223  
45224 +#include <linux/version.h>
45225  #include <linux/types.h>
45226  
45227  #include <linux/ixjuser.h>
45228 --- linux-2.6.0-test6/drivers/telephony/phonedev.c      2003-09-08 13:58:58.000000000 -0700
45229 +++ 25/drivers/telephony/phonedev.c     2003-10-05 00:33:24.000000000 -0700
45230 @@ -14,7 +14,6 @@
45231   *              phone_register_device now works with unit!=PHONE_UNIT_ANY
45232   */
45233  
45234 -#include <linux/version.h>
45235  #include <linux/module.h>
45236  #include <linux/types.h>
45237  #include <linux/kernel.h>
45238 --- linux-2.6.0-test6/drivers/usb/core/inode.c  2003-09-08 13:58:58.000000000 -0700
45239 +++ 25/drivers/usb/core/inode.c 2003-10-05 00:33:24.000000000 -0700
45240 @@ -38,6 +38,7 @@
45241  #include <linux/namei.h>
45242  #include <linux/usbdevice_fs.h>
45243  #include <linux/smp_lock.h>
45244 +#include <linux/parser.h>
45245  #include <asm/byteorder.h>
45246  
45247  static struct super_operations usbfs_ops;
45248 @@ -62,86 +63,94 @@ static umode_t devmode = S_IWUSR | S_IRU
45249  static umode_t busmode = S_IXUGO | S_IRUGO;
45250  static umode_t listmode = S_IRUGO;
45251  
45252 +enum {
45253 +       Opt_devuid, Opt_devgid, Opt_devmode,
45254 +       Opt_busuid, Opt_busgid, Opt_busmode,
45255 +       Opt_listuid, Opt_listgid, Opt_listmode,
45256 +       Opt_err,
45257 +};
45258 +
45259 +static match_table_t tokens = {
45260 +       {Opt_devuid, "devuid=%u"},
45261 +       {Opt_devgid, "devgid=%u"},
45262 +       {Opt_devmode, "devmode=%o"},
45263 +       {Opt_busuid, "busuid=%u"},
45264 +       {Opt_busgid, "busgid=%u"},
45265 +       {Opt_busmode, "busmode=%o"},
45266 +       {Opt_listuid, "listuid=%u"},
45267 +       {Opt_listgid, "listgid=%u"},
45268 +       {Opt_listmode, "listmode=%o"},
45269 +       {Opt_err, NULL}
45270 +};
45271 +
45272  static int parse_options(struct super_block *s, char *data)
45273  {
45274 -       char *curopt = NULL, *value;
45275 +       char *p;
45276 +       int option;
45277  
45278 -       while ((curopt = strsep(&data, ",")) != NULL) {
45279 -               if (!*curopt)
45280 +       while ((p = strsep(&data, ",")) != NULL) {
45281 +               substring_t args[MAX_OPT_ARGS];
45282 +               int token;
45283 +               if (!*p)
45284                         continue;
45285 -               if ((value = strchr(curopt, '=')) != NULL)
45286 -                       *value++ = 0;
45287 -               if (!strcmp(curopt, "devuid")) {
45288 -                       if (!value || !value[0])
45289 -                               return -EINVAL;
45290 -                       devuid = simple_strtoul(value, &value, 0);
45291 -                       if (*value)
45292 -                               return -EINVAL;
45293 -               }
45294 -               if (!strcmp(curopt, "devgid")) {
45295 -                       if (!value || !value[0])
45296 -                               return -EINVAL;
45297 -                       devgid = simple_strtoul(value, &value, 0);
45298 -                       if (*value)
45299 -                               return -EINVAL;
45300 -               }
45301 -               if (!strcmp(curopt, "devmode")) {
45302 -                       if (!value || !value[0])
45303 -                               return -EINVAL;
45304 -                       devmode = simple_strtoul(value, &value, 0) & S_IRWXUGO;
45305 -                       if (*value)
45306 -                               return -EINVAL;
45307 -               }
45308 -               if (!strcmp(curopt, "busuid")) {
45309 -                       if (!value || !value[0])
45310 -                               return -EINVAL;
45311 -                       busuid = simple_strtoul(value, &value, 0);
45312 -                       if (*value)
45313 -                               return -EINVAL;
45314 -               }
45315 -               if (!strcmp(curopt, "busgid")) {
45316 -                       if (!value || !value[0])
45317 -                               return -EINVAL;
45318 -                       busgid = simple_strtoul(value, &value, 0);
45319 -                       if (*value)
45320 -                               return -EINVAL;
45321 -               }
45322 -               if (!strcmp(curopt, "busmode")) {
45323 -                       if (!value || !value[0])
45324 -                               return -EINVAL;
45325 -                       busmode = simple_strtoul(value, &value, 0) & S_IRWXUGO;
45326 -                       if (*value)
45327 -                               return -EINVAL;
45328 -               }
45329 -               if (!strcmp(curopt, "listuid")) {
45330 -                       if (!value || !value[0])
45331 -                               return -EINVAL;
45332 -                       listuid = simple_strtoul(value, &value, 0);
45333 -                       if (*value)
45334 -                               return -EINVAL;
45335 -               }
45336 -               if (!strcmp(curopt, "listgid")) {
45337 -                       if (!value || !value[0])
45338 -                               return -EINVAL;
45339 -                       listgid = simple_strtoul(value, &value, 0);
45340 -                       if (*value)
45341 +
45342 +               token = match_token(p, tokens, args);
45343 +               switch (token) {
45344 +               case Opt_devuid:
45345 +                       if (match_int(&args[0], &option))
45346 +                              return -EINVAL;
45347 +                       devuid = option;
45348 +                       break;
45349 +               case Opt_devgid:
45350 +                       if (match_int(&args[0], &option))
45351 +                              return -EINVAL;
45352 +                       devgid = option;
45353 +                       break;
45354 +               case Opt_devmode:
45355 +                       if (match_octal(&args[0], &option))
45356                                 return -EINVAL;
45357 -               }
45358 -               if (!strcmp(curopt, "listmode")) {
45359 -                       if (!value || !value[0])
45360 +                       devmode = option & S_IRWXUGO;
45361 +                       break;
45362 +               case Opt_busuid:
45363 +                       if (match_int(&args[0], &option))
45364 +                              return -EINVAL;
45365 +                       busuid = option;
45366 +                       break;
45367 +               case Opt_busgid:
45368 +                       if (match_int(&args[0], &option))
45369 +                              return -EINVAL;
45370 +                       busgid = option;
45371 +                       break;
45372 +               case Opt_busmode:
45373 +                       if (match_octal(&args[0], &option))
45374                                 return -EINVAL;
45375 -                       listmode = simple_strtoul(value, &value, 0) & S_IRWXUGO;
45376 -                       if (*value)
45377 +                       busmode = option & S_IRWXUGO;
45378 +                       break;
45379 +               case Opt_listuid:
45380 +                       if (match_int(&args[0], &option))
45381 +                              return -EINVAL;
45382 +                       listuid = option;
45383 +                       break;
45384 +               case Opt_listgid:
45385 +                       if (match_int(&args[0], &option))
45386 +                              return -EINVAL;
45387 +                       listgid = option;
45388 +                       break;
45389 +               case Opt_listmode:
45390 +                       if (match_octal(&args[0], &option))
45391                                 return -EINVAL;
45392 +                       listmode = option & S_IRWXUGO;
45393 +                       break;
45394 +               default:
45395 +                       err("usbfs: unrecognised mount option \"%s\" "
45396 +                           "or missing value\n", p);
45397 +                       return -EINVAL;
45398                 }
45399         }
45400  
45401         return 0;
45402  }
45403  
45404 -
45405 -/* --------------------------------------------------------------------- */
45406 -
45407  static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t dev)
45408  {
45409         struct inode *inode = new_inode(sb);
45410 --- linux-2.6.0-test6/drivers/usb/host/uhci-debug.c     2003-07-02 14:53:16.000000000 -0700
45411 +++ 25/drivers/usb/host/uhci-debug.c    2003-10-05 00:33:24.000000000 -0700
45412 @@ -99,82 +99,6 @@ static int uhci_show_td(struct uhci_td *
45413         return out - buf;
45414  }
45415  
45416 -static int uhci_show_sc(int port, unsigned short status, char *buf, int len)
45417 -{
45418 -       char *out = buf;
45419 -
45420 -       /* Try to make sure there's enough memory */
45421 -       if (len < 80)
45422 -               return 0;
45423 -
45424 -       out += sprintf(out, "  stat%d     =     %04x   %s%s%s%s%s%s%s%s\n",
45425 -               port,
45426 -               status,
45427 -               (status & USBPORTSC_SUSP) ? "PortSuspend " : "",
45428 -               (status & USBPORTSC_PR) ?   "PortReset " : "",
45429 -               (status & USBPORTSC_LSDA) ? "LowSpeed " : "",
45430 -               (status & USBPORTSC_RD) ?   "ResumeDetect " : "",
45431 -               (status & USBPORTSC_PEC) ?  "EnableChange " : "",
45432 -               (status & USBPORTSC_PE) ?   "PortEnabled " : "",
45433 -               (status & USBPORTSC_CSC) ?  "ConnectChange " : "",
45434 -               (status & USBPORTSC_CCS) ?  "PortConnected " : "");
45435 -
45436 -       return out - buf;
45437 -}
45438 -
45439 -static int uhci_show_status(struct uhci_hcd *uhci, char *buf, int len)
45440 -{
45441 -       char *out = buf;
45442 -       unsigned int io_addr = uhci->io_addr;
45443 -       unsigned short usbcmd, usbstat, usbint, usbfrnum;
45444 -       unsigned int flbaseadd;
45445 -       unsigned char sof;
45446 -       unsigned short portsc1, portsc2;
45447 -
45448 -       /* Try to make sure there's enough memory */
45449 -       if (len < 80 * 6)
45450 -               return 0;
45451 -
45452 -       usbcmd    = inw(io_addr + 0);
45453 -       usbstat   = inw(io_addr + 2);
45454 -       usbint    = inw(io_addr + 4);
45455 -       usbfrnum  = inw(io_addr + 6);
45456 -       flbaseadd = inl(io_addr + 8);
45457 -       sof       = inb(io_addr + 12);
45458 -       portsc1   = inw(io_addr + 16);
45459 -       portsc2   = inw(io_addr + 18);
45460 -
45461 -       out += sprintf(out, "  usbcmd    =     %04x   %s%s%s%s%s%s%s%s\n",
45462 -               usbcmd,
45463 -               (usbcmd & USBCMD_MAXP) ?    "Maxp64 " : "Maxp32 ",
45464 -               (usbcmd & USBCMD_CF) ?      "CF " : "",
45465 -               (usbcmd & USBCMD_SWDBG) ?   "SWDBG " : "",
45466 -               (usbcmd & USBCMD_FGR) ?     "FGR " : "",
45467 -               (usbcmd & USBCMD_EGSM) ?    "EGSM " : "",
45468 -               (usbcmd & USBCMD_GRESET) ?  "GRESET " : "",
45469 -               (usbcmd & USBCMD_HCRESET) ? "HCRESET " : "",
45470 -               (usbcmd & USBCMD_RS) ?      "RS " : "");
45471 -
45472 -       out += sprintf(out, "  usbstat   =     %04x   %s%s%s%s%s%s\n",
45473 -               usbstat,
45474 -               (usbstat & USBSTS_HCH) ?    "HCHalted " : "",
45475 -               (usbstat & USBSTS_HCPE) ?   "HostControllerProcessError " : "",
45476 -               (usbstat & USBSTS_HSE) ?    "HostSystemError " : "",
45477 -               (usbstat & USBSTS_RD) ?     "ResumeDetect " : "",
45478 -               (usbstat & USBSTS_ERROR) ?  "USBError " : "",
45479 -               (usbstat & USBSTS_USBINT) ? "USBINT " : "");
45480 -
45481 -       out += sprintf(out, "  usbint    =     %04x\n", usbint);
45482 -       out += sprintf(out, "  usbfrnum  =   (%d)%03x\n", (usbfrnum >> 10) & 1,
45483 -               0xfff & (4*(unsigned int)usbfrnum));
45484 -       out += sprintf(out, "  flbaseadd = %08x\n", flbaseadd);
45485 -       out += sprintf(out, "  sof       =       %02x\n", sof);
45486 -       out += uhci_show_sc(1, portsc1, out, len - (out - buf));
45487 -       out += uhci_show_sc(2, portsc2, out, len - (out - buf));
45488 -
45489 -       return out - buf;
45490 -}
45491 -
45492  static int uhci_show_qh(struct uhci_qh *qh, char *buf, int len, int space)
45493  {
45494         char *out = buf;
45495 @@ -274,6 +198,13 @@ out:
45496         return out - buf;
45497  }
45498  
45499 +#define show_frame_num()       \
45500 +       if (!shown) {           \
45501 +         shown = 1;            \
45502 +         out += sprintf(out, "- Frame %d\n", i); \
45503 +       }
45504 +
45505 +#ifdef CONFIG_PROC_FS
45506  static const char *qh_names[] = {
45507    "skel_int128_qh", "skel_int64_qh",
45508    "skel_int32_qh", "skel_int16_qh",
45509 @@ -283,18 +214,88 @@ static const char *qh_names[] = {
45510    "skel_bulk_qh", "skel_term_qh"
45511  };
45512  
45513 -#define show_frame_num()       \
45514 -       if (!shown) {           \
45515 -         shown = 1;            \
45516 -         out += sprintf(out, "- Frame %d\n", i); \
45517 -       }
45518 -
45519  #define show_qh_name()         \
45520         if (!shown) {           \
45521           shown = 1;            \
45522           out += sprintf(out, "- %s\n", qh_names[i]); \
45523         }
45524  
45525 +static int uhci_show_sc(int port, unsigned short status, char *buf, int len)
45526 +{
45527 +       char *out = buf;
45528 +
45529 +       /* Try to make sure there's enough memory */
45530 +       if (len < 80)
45531 +               return 0;
45532 +
45533 +       out += sprintf(out, "  stat%d     =     %04x   %s%s%s%s%s%s%s%s\n",
45534 +               port,
45535 +               status,
45536 +               (status & USBPORTSC_SUSP) ? "PortSuspend " : "",
45537 +               (status & USBPORTSC_PR) ?   "PortReset " : "",
45538 +               (status & USBPORTSC_LSDA) ? "LowSpeed " : "",
45539 +               (status & USBPORTSC_RD) ?   "ResumeDetect " : "",
45540 +               (status & USBPORTSC_PEC) ?  "EnableChange " : "",
45541 +               (status & USBPORTSC_PE) ?   "PortEnabled " : "",
45542 +               (status & USBPORTSC_CSC) ?  "ConnectChange " : "",
45543 +               (status & USBPORTSC_CCS) ?  "PortConnected " : "");
45544 +
45545 +       return out - buf;
45546 +}
45547 +
45548 +static int uhci_show_status(struct uhci_hcd *uhci, char *buf, int len)
45549 +{
45550 +       char *out = buf;
45551 +       unsigned int io_addr = uhci->io_addr;
45552 +       unsigned short usbcmd, usbstat, usbint, usbfrnum;
45553 +       unsigned int flbaseadd;
45554 +       unsigned char sof;
45555 +       unsigned short portsc1, portsc2;
45556 +
45557 +       /* Try to make sure there's enough memory */
45558 +       if (len < 80 * 6)
45559 +               return 0;
45560 +
45561 +       usbcmd    = inw(io_addr + 0);
45562 +       usbstat   = inw(io_addr + 2);
45563 +       usbint    = inw(io_addr + 4);
45564 +       usbfrnum  = inw(io_addr + 6);
45565 +       flbaseadd = inl(io_addr + 8);
45566 +       sof       = inb(io_addr + 12);
45567 +       portsc1   = inw(io_addr + 16);
45568 +       portsc2   = inw(io_addr + 18);
45569 +
45570 +       out += sprintf(out, "  usbcmd    =     %04x   %s%s%s%s%s%s%s%s\n",
45571 +               usbcmd,
45572 +               (usbcmd & USBCMD_MAXP) ?    "Maxp64 " : "Maxp32 ",
45573 +               (usbcmd & USBCMD_CF) ?      "CF " : "",
45574 +               (usbcmd & USBCMD_SWDBG) ?   "SWDBG " : "",
45575 +               (usbcmd & USBCMD_FGR) ?     "FGR " : "",
45576 +               (usbcmd & USBCMD_EGSM) ?    "EGSM " : "",
45577 +               (usbcmd & USBCMD_GRESET) ?  "GRESET " : "",
45578 +               (usbcmd & USBCMD_HCRESET) ? "HCRESET " : "",
45579 +               (usbcmd & USBCMD_RS) ?      "RS " : "");
45580 +
45581 +       out += sprintf(out, "  usbstat   =     %04x   %s%s%s%s%s%s\n",
45582 +               usbstat,
45583 +               (usbstat & USBSTS_HCH) ?    "HCHalted " : "",
45584 +               (usbstat & USBSTS_HCPE) ?   "HostControllerProcessError " : "",
45585 +               (usbstat & USBSTS_HSE) ?    "HostSystemError " : "",
45586 +               (usbstat & USBSTS_RD) ?     "ResumeDetect " : "",
45587 +               (usbstat & USBSTS_ERROR) ?  "USBError " : "",
45588 +               (usbstat & USBSTS_USBINT) ? "USBINT " : "");
45589 +
45590 +       out += sprintf(out, "  usbint    =     %04x\n", usbint);
45591 +       out += sprintf(out, "  usbfrnum  =   (%d)%03x\n", (usbfrnum >> 10) & 1,
45592 +               0xfff & (4*(unsigned int)usbfrnum));
45593 +       out += sprintf(out, "  flbaseadd = %08x\n", flbaseadd);
45594 +       out += sprintf(out, "  sof       =       %02x\n", sof);
45595 +       out += uhci_show_sc(1, portsc1, out, len - (out - buf));
45596 +       out += uhci_show_sc(2, portsc2, out, len - (out - buf));
45597 +
45598 +       return out - buf;
45599 +}
45600 +
45601  static int uhci_show_urbp(struct uhci_hcd *uhci, struct urb_priv *urbp, char *buf, int len)
45602  {
45603         struct list_head *tmp;
45604 @@ -512,7 +513,6 @@ static int uhci_sprint_schedule(struct u
45605         return out - buf;
45606  }
45607  
45608 -#ifdef CONFIG_PROC_FS
45609  #define MAX_OUTPUT     (64 * 1024)
45610  
45611  static struct proc_dir_entry *uhci_proc_root = NULL;
45612 --- linux-2.6.0-test6/drivers/usb/host/uhci-hcd.c       2003-09-27 18:57:46.000000000 -0700
45613 +++ 25/drivers/usb/host/uhci-hcd.c      2003-10-05 00:33:24.000000000 -0700
45614 @@ -2185,8 +2185,8 @@ static int uhci_reset(struct usb_hcd *hc
45615         /* Maybe kick BIOS off this hardware.  Then reset, so we won't get
45616          * interrupts from any previous setup.
45617          */
45618 -       pci_write_config_word(hcd->pdev, USBLEGSUP, USBLEGSUP_DEFAULT);
45619         reset_hc(uhci);
45620 +       pci_write_config_word(hcd->pdev, USBLEGSUP, USBLEGSUP_DEFAULT);
45621         return 0;
45622  }
45623  
45624 --- linux-2.6.0-test6/drivers/usb/input/Kconfig 2003-09-27 18:57:46.000000000 -0700
45625 +++ 25/drivers/usb/input/Kconfig        2003-10-05 00:33:24.000000000 -0700
45626 @@ -186,8 +186,5 @@ config USB_XPAD
45627           For information about how to connect the X-Box pad to USB, see
45628           Documentation/input/xpad.txt.
45629  
45630 -         This driver is also available as a module ( = code which can be
45631 -         inserted in and removed from the running kernel whenever you want).
45632 -         The module will be called xpad.  If you want to compile it as a
45633 -         module, say M here and read <file:Documentation/modules.txt>.
45634 -
45635 +         To compile this driver as a module, choose M here: the
45636 +         module will be called xpad.
45637 --- linux-2.6.0-test6/drivers/usb/misc/brlvger.c        2003-09-08 13:58:58.000000000 -0700
45638 +++ 25/drivers/usb/misc/brlvger.c       2003-10-05 00:33:24.000000000 -0700
45639 @@ -591,14 +591,14 @@ brlvger_write(struct file *file, const c
45640                         int firstpart = 6 - off;
45641                         
45642  #ifdef WRITE_DEBUG
45643 -                       dbg3("off: %d, rs: %d, count: %d, firstpart: %d",
45644 +                       dbg3("off: %lld, rs: %d, count: %d, firstpart: %d",
45645                              off, rs, count, firstpart);
45646  #endif
45647  
45648                         firstpart = (firstpart < count) ? firstpart : count;
45649  
45650  #ifdef WRITE_DEBUG
45651 -                       dbg3("off: %d", off);
45652 +                       dbg3("off: %lld", off);
45653                         dbg3("firstpart: %d", firstpart);
45654  #endif
45655  
45656 @@ -618,7 +618,7 @@ brlvger_write(struct file *file, const c
45657                         off +=2;
45658  
45659  #ifdef WRITE_DEBUG
45660 -                       dbg3("off: %d, rs: %d, count: %d, firstpart: %d, "
45661 +                       dbg3("off: %lld, rs: %d, count: %d, firstpart: %d, "
45662                                 "written: %d",  off, rs, count, firstpart, written);
45663  #endif
45664                 }
45665 --- linux-2.6.0-test6/drivers/usb/misc/speedtch.c       2003-09-27 18:57:46.000000000 -0700
45666 +++ 25/drivers/usb/misc/speedtch.c      2003-10-05 00:33:24.000000000 -0700
45667 @@ -189,8 +189,7 @@ struct udsl_vcc_data {
45668         struct atm_vcc *vcc;
45669  
45670         /* raw cell reassembly */
45671 -       struct sk_buff *skb;
45672 -       unsigned int max_pdu;
45673 +       struct sk_buff *sarb;
45674  };
45675  
45676  /* send */
45677 @@ -314,12 +313,10 @@ static void udsl_extract_cells (struct u
45678  {
45679         struct udsl_vcc_data *cached_vcc = NULL;
45680         struct atm_vcc *vcc;
45681 -       struct sk_buff *skb;
45682 +       struct sk_buff *sarb;
45683         struct udsl_vcc_data *vcc_data;
45684         int cached_vci = 0;
45685         unsigned int i;
45686 -       unsigned int length;
45687 -       unsigned int pdu_length;
45688         int pti;
45689         int vci;
45690         short cached_vpi = 0;
45691 @@ -344,74 +341,73 @@ static void udsl_extract_cells (struct u
45692                 }
45693  
45694                 vcc = vcc_data->vcc;
45695 +               sarb = vcc_data->sarb;
45696  
45697 -               if (!vcc_data->skb && !(vcc_data->skb = dev_alloc_skb (vcc_data->max_pdu))) {
45698 -                       dbg ("udsl_extract_cells: no memory for skb (vcc: 0x%p)!", vcc);
45699 -                       if (pti)
45700 -                               atomic_inc (&vcc->stats->rx_err);
45701 -                       continue;
45702 -               }
45703 -
45704 -               skb = vcc_data->skb;
45705 -
45706 -               if (skb->len + ATM_CELL_PAYLOAD > vcc_data->max_pdu) {
45707 -                       dbg ("udsl_extract_cells: buffer overrun (max_pdu: %u, skb->len %u, vcc: 0x%p)", vcc_data->max_pdu, skb->len, vcc);
45708 +               if (sarb->tail + ATM_CELL_PAYLOAD > sarb->end) {
45709 +                       dbg ("udsl_extract_cells: buffer overrun (sarb->len %u, vcc: 0x%p)!", sarb->len, vcc);
45710                         /* discard cells already received */
45711 -                       skb_trim (skb, 0);
45712 -                       DEBUG_ON (vcc_data->max_pdu < ATM_CELL_PAYLOAD);
45713 +                       skb_trim (sarb, 0);
45714                 }
45715  
45716 -               memcpy (skb->tail, source + ATM_CELL_HEADER, ATM_CELL_PAYLOAD);
45717 -               __skb_put (skb, ATM_CELL_PAYLOAD);
45718 +               memcpy (sarb->tail, source + ATM_CELL_HEADER, ATM_CELL_PAYLOAD);
45719 +               __skb_put (sarb, ATM_CELL_PAYLOAD);
45720  
45721                 if (pti) {
45722 +                       struct sk_buff *skb;
45723 +                       unsigned int length;
45724 +                       unsigned int pdu_length;
45725 +
45726                         length = (source [ATM_CELL_SIZE - 6] << 8) + source [ATM_CELL_SIZE - 5];
45727  
45728                         /* guard against overflow */
45729                         if (length > ATM_MAX_AAL5_PDU) {
45730 -                               dbg ("udsl_extract_cells: bogus length %u (vcc: 0x%p)", length, vcc);
45731 -                               goto drop;
45732 +                               dbg ("udsl_extract_cells: bogus length %u (vcc: 0x%p)!", length, vcc);
45733 +                               atomic_inc (&vcc->stats->rx_err);
45734 +                               goto out;
45735                         }
45736  
45737                         pdu_length = UDSL_NUM_CELLS (length) * ATM_CELL_PAYLOAD;
45738  
45739 -                       if (skb->len < pdu_length) {
45740 -                               dbg ("udsl_extract_cells: bogus pdu_length %u (skb->len: %u, vcc: 0x%p)", pdu_length, skb->len, vcc);
45741 -                               goto drop;
45742 +                       if (sarb->len < pdu_length) {
45743 +                               dbg ("udsl_extract_cells: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!", pdu_length, sarb->len, vcc);
45744 +                               atomic_inc (&vcc->stats->rx_err);
45745 +                               goto out;
45746                         }
45747  
45748 -                       if (crc32_be (~0, skb->tail - pdu_length, pdu_length) != 0xc704dd7b) {
45749 -                               dbg ("udsl_extract_cells: packet failed crc check (vcc: 0x%p)", vcc);
45750 -                               goto drop;
45751 +                       if (crc32_be (~0, sarb->tail - pdu_length, pdu_length) != 0xc704dd7b) {
45752 +                               dbg ("udsl_extract_cells: packet failed crc check (vcc: 0x%p)!", vcc);
45753 +                               atomic_inc (&vcc->stats->rx_err);
45754 +                               goto out;
45755                         }
45756  
45757 -                       if (!atm_charge (vcc, skb->truesize)) {
45758 -                               dbg ("udsl_extract_cells: failed atm_charge (skb->truesize: %u)", skb->truesize);
45759 -                               goto drop_no_stats; /* atm_charge increments rx_drop */
45760 -                       }
45761 +                       vdbg ("udsl_extract_cells: got packet (length: %u, pdu_length: %u, vcc: 0x%p)", length, pdu_length, vcc);
45762  
45763 -                       /* now that we are sure to send the skb, it is ok to change skb->data */
45764 -                       if (skb->len > pdu_length)
45765 -                               skb_pull (skb, skb->len - pdu_length); /* discard initial junk */
45766 +                       if (!(skb = dev_alloc_skb (length))) {
45767 +                               dbg ("udsl_extract_cells: no memory for skb (length: %u)!", length);
45768 +                               atomic_inc (&vcc->stats->rx_drop);
45769 +                               goto out;
45770 +                       }
45771  
45772 -                       skb_trim (skb, length); /* drop zero padding and trailer */
45773 +                       vdbg ("udsl_extract_cells: allocated new sk_buff (skb: 0x%p, skb->truesize: %u)", skb, skb->truesize);
45774  
45775 -                       atomic_inc (&vcc->stats->rx);
45776 +                       if (!atm_charge (vcc, skb->truesize)) {
45777 +                               dbg ("udsl_extract_cells: failed atm_charge (skb->truesize: %u)!", skb->truesize);
45778 +                               dev_kfree_skb (skb);
45779 +                               goto out; /* atm_charge increments rx_drop */
45780 +                       }
45781  
45782 -                       PACKETDEBUG (skb->data, skb->len);
45783 +                       memcpy (skb->data, sarb->tail - pdu_length, length);
45784 +                       __skb_put (skb, length);
45785  
45786                         vdbg ("udsl_extract_cells: sending skb 0x%p, skb->len %u, skb->truesize %u", skb, skb->len, skb->truesize);
45787  
45788 -                       vcc->push (vcc, skb);
45789 -
45790 -                       vcc_data->skb = NULL;
45791 +                       PACKETDEBUG (skb->data, skb->len);
45792  
45793 -                       continue;
45794 +                       vcc->push (vcc, skb);
45795  
45796 -drop:
45797 -                       atomic_inc (&vcc->stats->rx_err);
45798 -drop_no_stats:
45799 -                       skb_trim (skb, 0);
45800 +                       atomic_inc (&vcc->stats->rx);
45801 +out:
45802 +                       skb_trim (sarb, 0);
45803                 }
45804         }
45805  }
45806 @@ -871,6 +867,7 @@ static int udsl_atm_open (struct atm_vcc
45807  {
45808         struct udsl_instance_data *instance = vcc->dev->dev_data;
45809         struct udsl_vcc_data *new;
45810 +       unsigned int max_pdu;
45811  
45812         dbg ("udsl_atm_open: vpi %hd, vci %d", vpi, vci);
45813  
45814 @@ -883,8 +880,10 @@ static int udsl_atm_open (struct atm_vcc
45815                 return -EINVAL;
45816  
45817         /* only support AAL5 */
45818 -       if ((vcc->qos.aal != ATM_AAL5) || (vcc->qos.rxtp.max_sdu < 0) || (vcc->qos.rxtp.max_sdu > ATM_MAX_AAL5_PDU))
45819 +       if ((vcc->qos.aal != ATM_AAL5) || (vcc->qos.rxtp.max_sdu < 0) || (vcc->qos.rxtp.max_sdu > ATM_MAX_AAL5_PDU)) {
45820 +               dbg ("udsl_atm_open: unsupported ATM type %d!", vcc->qos.aal);
45821                 return -EINVAL;
45822 +       }
45823  
45824         if (!instance->firmware_loaded) {
45825                 dbg ("udsl_atm_open: firmware not loaded!");
45826 @@ -894,11 +893,13 @@ static int udsl_atm_open (struct atm_vcc
45827         down (&instance->serialize); /* vs self, udsl_atm_close */
45828  
45829         if (udsl_find_vcc (instance, vpi, vci)) {
45830 +               dbg ("udsl_atm_open: %hd/%d already in use!", vpi, vci);
45831                 up (&instance->serialize);
45832                 return -EADDRINUSE;
45833         }
45834  
45835         if (!(new = kmalloc (sizeof (struct udsl_vcc_data), GFP_KERNEL))) {
45836 +               dbg ("udsl_atm_open: no memory for vcc_data!");
45837                 up (&instance->serialize);
45838                 return -ENOMEM;
45839         }
45840 @@ -907,7 +908,15 @@ static int udsl_atm_open (struct atm_vcc
45841         new->vcc = vcc;
45842         new->vpi = vpi;
45843         new->vci = vci;
45844 -       new->max_pdu = max (1, UDSL_NUM_CELLS (vcc->qos.rxtp.max_sdu)) * ATM_CELL_PAYLOAD;
45845 +
45846 +       /* udsl_extract_cells requires at least one cell */
45847 +       max_pdu = max (1, UDSL_NUM_CELLS (vcc->qos.rxtp.max_sdu)) * ATM_CELL_PAYLOAD;
45848 +       if (!(new->sarb = alloc_skb (max_pdu, GFP_KERNEL))) {
45849 +               dbg ("udsl_atm_open: no memory for SAR buffer!");
45850 +               kfree (new);
45851 +               up (&instance->serialize);
45852 +               return -ENOMEM;
45853 +       }
45854  
45855         vcc->dev_data = new;
45856         vcc->vpi = vpi;
45857 @@ -925,7 +934,7 @@ static int udsl_atm_open (struct atm_vcc
45858  
45859         tasklet_schedule (&instance->receive_tasklet);
45860  
45861 -       dbg ("udsl_atm_open: allocated vcc data 0x%p (max_pdu: %u)", new, new->max_pdu);
45862 +       dbg ("udsl_atm_open: allocated vcc data 0x%p (max_pdu: %u)", new, max_pdu);
45863  
45864         return 0;
45865  }
45866 @@ -952,9 +961,8 @@ static void udsl_atm_close (struct atm_v
45867         list_del (&vcc_data->list);
45868         tasklet_enable (&instance->receive_tasklet);
45869  
45870 -       if (vcc_data->skb)
45871 -               dev_kfree_skb (vcc_data->skb);
45872 -       vcc_data->skb = NULL;
45873 +       kfree_skb (vcc_data->sarb);
45874 +       vcc_data->sarb = NULL;
45875  
45876         kfree (vcc_data);
45877         vcc->dev_data = NULL;
45878 @@ -1216,7 +1224,7 @@ static void udsl_usb_disconnect (struct 
45879  
45880         for (i = 0; i < num_rcv_urbs; i++)
45881                 if ((result = usb_unlink_urb (instance->receivers [i].urb)) < 0)
45882 -                       dbg ("udsl_usb_disconnect: usb_unlink_urb on receive urb %d returned %d", i, result);
45883 +                       dbg ("udsl_usb_disconnect: usb_unlink_urb on receive urb %d returned %d!", i, result);
45884  
45885         /* wait for completion handlers to finish */
45886         do {
45887 @@ -1252,7 +1260,7 @@ static void udsl_usb_disconnect (struct 
45888  
45889         for (i = 0; i < num_snd_urbs; i++)
45890                 if ((result = usb_unlink_urb (instance->senders [i].urb)) < 0)
45891 -                       dbg ("udsl_usb_disconnect: usb_unlink_urb on send urb %d returned %d", i, result);
45892 +                       dbg ("udsl_usb_disconnect: usb_unlink_urb on send urb %d returned %d!", i, result);
45893  
45894         /* wait for completion handlers to finish */
45895         do {
45896 @@ -1298,11 +1306,9 @@ static void udsl_usb_disconnect (struct 
45897  
45898  static int __init udsl_usb_init (void)
45899  {
45900 -       struct sk_buff *skb; /* dummy for sizeof */
45901 -
45902         dbg ("udsl_usb_init: driver version " DRIVER_VERSION);
45903  
45904 -       if (sizeof (struct udsl_control) > sizeof (skb->cb)) {
45905 +       if (sizeof (struct udsl_control) > sizeof (((struct sk_buff *)0)->cb)) {
45906                 printk (KERN_ERR __FILE__ ": unusable with this kernel!\n");
45907                 return -EIO;
45908         }
45909 --- linux-2.6.0-test6/drivers/usb/serial/keyspan.c      2003-09-08 13:58:58.000000000 -0700
45910 +++ 25/drivers/usb/serial/keyspan.c     2003-10-05 00:33:24.000000000 -0700
45911 @@ -28,6 +28,9 @@
45912  
45913    Change History
45914  
45915 +    2003sep04  LPM (Keyspan) add support for new single port product USA19HS.
45916 +                               Improve setup message handling for all devices.
45917 +
45918      Wed Feb 19 22:00:00 PST 2003 (Jeffrey S. Laing <keyspan@jsl.com>)
45919        Merged the current (1/31/03) Keyspan code with the current (2.4.21-pre4)
45920        Linux source tree.  The Linux tree lacked support for the 49WLC and
45921 @@ -172,6 +175,7 @@ struct keyspan_port_private {
45922         int             baud;
45923         int             old_baud;
45924         unsigned int    cflag;
45925 +       unsigned int    old_cflag;
45926         enum            {flow_none, flow_cts, flow_xon} flow_control;
45927         int             rts_state;      /* Handshaking pins (outputs) */
45928         int             dtr_state;
45929 @@ -187,11 +191,12 @@ struct keyspan_port_private {
45930  
45931         
45932  /* Include Keyspan message headers.  All current Keyspan Adapters
45933 -   make use of one of three message formats which are referred
45934 -   to as USA-26, USA-28 and USA-49 by Keyspan and within this driver. */
45935 +   make use of one of four message formats which are referred
45936 +   to as USA-26, USA-28 and USA-49, USA-90 by Keyspan and within this driver. */
45937  #include "keyspan_usa26msg.h"
45938  #include "keyspan_usa28msg.h"
45939  #include "keyspan_usa49msg.h"
45940 +#include "keyspan_usa90msg.h"
45941         
45942  
45943  /* Functions used by new usb-serial code. */
45944 @@ -346,8 +351,8 @@ static int keyspan_ioctl(struct usb_seri
45945         return -ENOIOCTLCMD;
45946  }
45947  
45948 -       /* Write function is generic for the three protocols used
45949 -          with only a minor change for usa49 required */
45950 +       /* Write function is similar for the four protocols used
45951 +          with only a minor change for usa90 (usa19hs) required */
45952  static int keyspan_write(struct usb_serial_port *port, int from_user, 
45953                          const unsigned char *buf, int count)
45954  {
45955 @@ -356,18 +361,26 @@ static int keyspan_write(struct usb_seri
45956         int                             flip;
45957         int                             left, todo;
45958         struct urb                      *this_urb;
45959 -       int                             err;
45960 +       int                             err, maxDataLen, dataOffset;
45961  
45962         p_priv = usb_get_serial_port_data(port);
45963         d_details = p_priv->device_details;
45964  
45965 +       if (d_details->msg_format == msg_usa90) {
45966 +               maxDataLen = 64;
45967 +               dataOffset = 0;
45968 +       } else {
45969 +               maxDataLen = 63;
45970 +               dataOffset = 1;
45971 +       }
45972 +       
45973         dbg("%s - for port %d (%d chars), flip=%d",
45974             __FUNCTION__, port->number, count, p_priv->out_flip);
45975  
45976         for (left = count; left > 0; left -= todo) {
45977                 todo = left;
45978 -               if (todo > 63)
45979 -                       todo = 63;
45980 +               if (todo > maxDataLen)
45981 +                       todo = maxDataLen;
45982  
45983                 flip = p_priv->out_flip;
45984         
45985 @@ -390,20 +403,20 @@ static int keyspan_write(struct usb_seri
45986                         break;
45987                 }
45988  
45989 -               /* First byte in buffer is "last flag" - unused so
45990 +               /* First byte in buffer is "last flag" (except for usa19hx) - unused so
45991                    for now so set to zero */
45992                 ((char *)this_urb->transfer_buffer)[0] = 0;
45993  
45994                 if (from_user) {
45995 -                       if (copy_from_user(this_urb->transfer_buffer + 1, buf, todo))
45996 +                       if (copy_from_user(this_urb->transfer_buffer + dataOffset, buf, todo))
45997                                 return -EFAULT;
45998                 } else {
45999 -                       memcpy (this_urb->transfer_buffer + 1, buf, todo);
46000 +                       memcpy (this_urb->transfer_buffer + dataOffset, buf, todo);
46001                 }
46002                 buf += todo;
46003  
46004                 /* send the data out the bulk port */
46005 -               this_urb->transfer_buffer_length = todo + 1;
46006 +               this_urb->transfer_buffer_length = todo + dataOffset;
46007  
46008                 this_urb->transfer_flags &= ~URB_ASYNC_UNLINK;
46009                 this_urb->dev = port->serial->dev;
46010 @@ -443,9 +456,12 @@ static void        usa26_indat_callback(struct 
46011         if (urb->actual_length) {
46012                 /* 0x80 bit is error flag */
46013                 if ((data[0] & 0x80) == 0) {
46014 -                       /* no error on any byte */
46015 +                       /* no errors on individual bytes, only possible overrun err*/
46016 +                       if (data[0] & RXERROR_OVERRUN)
46017 +                                       err = TTY_OVERRUN;
46018 +                       else err = 0;
46019                         for (i = 1; i < urb->actual_length ; ++i) {
46020 -                               tty_insert_flip_char(tty, data[i], 0);
46021 +                               tty_insert_flip_char(tty, data[i], err);
46022                         }
46023                 } else {
46024                         /* some bytes had errors, every byte has status */
46025 @@ -474,7 +490,7 @@ static void usa26_indat_callback(struct 
46026         return;
46027  }
46028  
46029 -       /* Outdat handling is common for usa26, usa28 and usa49 messages */
46030 +       /* Outdat handling is common for all devices */
46031  static void    usa2x_outdat_callback(struct urb *urb, struct pt_regs *regs)
46032  {
46033         struct usb_serial_port *port;
46034 @@ -577,7 +593,7 @@ static void usa26_glocont_callback(struc
46035  }
46036  
46037  
46038 -static void     usa28_indat_callback(struct urb *urb, struct pt_regs *regs)
46039 +static void usa28_indat_callback(struct urb *urb, struct pt_regs *regs)
46040  {
46041         int                     i, err;
46042         struct usb_serial_port  *port;
46043 @@ -861,29 +877,172 @@ static void      usa49_outcont_callback(struc
46044         dbg ("%s", __FUNCTION__);
46045  }
46046  
46047 +static void    usa90_indat_callback(struct urb *urb, struct pt_regs *regs)
46048 +{
46049 +       int                     i, err;
46050 +       int                     endpoint;
46051 +       struct usb_serial_port  *port;
46052 +       struct keyspan_port_private             *p_priv;
46053 +       struct tty_struct       *tty;
46054 +       unsigned char           *data = urb->transfer_buffer;
46055 +
46056 +       dbg ("%s", __FUNCTION__); 
46057 +
46058 +       endpoint = usb_pipeendpoint(urb->pipe);
46059 +
46060 +
46061 +       if (urb->status) {
46062 +               dbg("%s - nonzero status: %x on endpoint %d.",
46063 +                   __FUNCTION__, urb->status, endpoint);
46064 +               return;
46065 +       }
46066 +
46067 +       port = (struct usb_serial_port *) urb->context;
46068 +       p_priv = usb_get_serial_port_data(port);
46069 +
46070 +       tty = port->tty;
46071 +       if (urb->actual_length) {
46072 +       
46073 +               /* if current mode is DMA, looks like usa28 format
46074 +                       otherwise looks like usa26 data format */
46075 +
46076 +               if (p_priv->baud > 57600) {
46077 +                       for (i = 0; i < urb->actual_length ; ++i) 
46078 +                               tty_insert_flip_char(tty, data[i], 0);
46079 +               }
46080 +               else {
46081 +                       
46082 +                       /* 0x80 bit is error flag */
46083 +                       if ((data[0] & 0x80) == 0) {
46084 +                               /* no errors on individual bytes, only possible overrun err*/
46085 +                               if (data[0] & RXERROR_OVERRUN)
46086 +                                               err = TTY_OVERRUN;
46087 +                               else err = 0;
46088 +                               for (i = 1; i < urb->actual_length ; ++i) 
46089 +                                       tty_insert_flip_char(tty, data[i], err);
46090 +                       
46091 +                       } 
46092 +                       else {
46093 +                       /* some bytes had errors, every byte has status */
46094 +                               dbg("%s - RX error!!!!", __FUNCTION__);
46095 +                               for (i = 0; i + 1 < urb->actual_length; i += 2) {
46096 +                                       int stat = data[i], flag = 0;
46097 +                                       if (stat & RXERROR_OVERRUN)
46098 +                                               flag |= TTY_OVERRUN;
46099 +                                       if (stat & RXERROR_FRAMING)
46100 +                                               flag |= TTY_FRAME;
46101 +                                       if (stat & RXERROR_PARITY)
46102 +                                               flag |= TTY_PARITY;
46103 +                                       /* XXX should handle break (0x10) */
46104 +                                       tty_insert_flip_char(tty, data[i+1], flag);
46105 +                               }
46106 +                       }
46107 +               }
46108 +               tty_flip_buffer_push(tty);
46109 +       }
46110 +                               
46111 +       /* Resubmit urb so we continue receiving */
46112 +       urb->dev = port->serial->dev;
46113 +       if (port->open_count)
46114 +               if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
46115 +                       dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err);
46116 +               }
46117 +       return;
46118 +}
46119 +
46120 +
46121 +static void    usa90_instat_callback(struct urb *urb, struct pt_regs *regs)
46122 +{
46123 +       unsigned char                           *data = urb->transfer_buffer;
46124 +       struct keyspan_usa90_portStatusMessage  *msg;
46125 +       struct usb_serial                       *serial;
46126 +       struct usb_serial_port                  *port;
46127 +       struct keyspan_port_private             *p_priv;
46128 +       int old_dcd_state, err;
46129 +
46130 +       serial = (struct usb_serial *) urb->context;
46131 +
46132 +       if (urb->status) {
46133 +               dbg("%s - nonzero status: %x", __FUNCTION__, urb->status);
46134 +               return;
46135 +       }
46136 +       if (urb->actual_length < 14) {
46137 +               dbg("%s - %d byte report??", __FUNCTION__, urb->actual_length);
46138 +               goto exit;
46139 +       }
46140 +
46141 +       msg = (struct keyspan_usa90_portStatusMessage *)data;
46142 +
46143 +       /* Now do something useful with the data */
46144 +
46145 +       port = serial->port[0];
46146 +       p_priv = usb_get_serial_port_data(port);
46147 +       
46148 +       /* Update handshaking pin state information */
46149 +       old_dcd_state = p_priv->dcd_state;
46150 +       p_priv->cts_state = ((msg->cts) ? 1 : 0);
46151 +       p_priv->dsr_state = ((msg->dsr) ? 1 : 0);
46152 +       p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
46153 +       p_priv->ri_state = ((msg->ri) ? 1 : 0);
46154 +
46155 +       if (port->tty && !C_CLOCAL(port->tty)
46156 +           && old_dcd_state != p_priv->dcd_state) {
46157 +               if (old_dcd_state)
46158 +                       tty_hangup(port->tty);
46159 +               /*  else */
46160 +               /*      wake_up_interruptible(&p_priv->open_wait); */
46161 +       }
46162 +       
46163 +       /* Resubmit urb so we continue receiving */
46164 +       urb->dev = serial->dev;
46165 +       if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
46166 +               dbg("%s - resubmit read urb failed. (%d)", __FUNCTION__, err);
46167 +       }
46168 +exit:
46169 +       ;
46170 +}
46171 +
46172 +static void    usa90_outcont_callback(struct urb *urb, struct pt_regs *regs)
46173 +{
46174 +       struct usb_serial_port *port;
46175 +       struct keyspan_port_private *p_priv;
46176 +
46177 +       port = (struct usb_serial_port *) urb->context;
46178 +       p_priv = usb_get_serial_port_data(port);
46179  
46180 +       if (p_priv->resend_cont) {
46181 +               dbg ("%s - sending setup", __FUNCTION__); 
46182 +               keyspan_usa90_send_setup(port->serial, port, p_priv->resend_cont - 1);
46183 +       }
46184 +}
46185  
46186  static int keyspan_write_room (struct usb_serial_port *port)
46187  {
46188         struct keyspan_port_private     *p_priv;
46189         const struct keyspan_device_details     *d_details;
46190         int                             flip;
46191 +       int                             data_len;
46192         struct urb                      *this_urb;
46193  
46194         dbg("%s", __FUNCTION__);
46195         p_priv = usb_get_serial_port_data(port);
46196         d_details = p_priv->device_details;
46197  
46198 +       if (d_details->msg_format == msg_usa90)
46199 +               data_len = 64;
46200 +       else
46201 +               data_len = 63;
46202 +
46203         flip = p_priv->out_flip;
46204  
46205         /* Check both endpoints to see if any are available. */
46206         if ((this_urb = p_priv->out_urbs[flip]) != 0) {
46207                 if (this_urb->status != -EINPROGRESS)
46208 -                       return (63);
46209 +                       return (data_len);
46210                 flip = (flip + 1) & d_details->outdat_endp_flip;        
46211                 if ((this_urb = p_priv->out_urbs[flip]) != 0) 
46212                         if (this_urb->status != -EINPROGRESS)
46213 -                               return (63);
46214 +                               return (data_len);
46215         }
46216         return (0);
46217  }
46218 @@ -902,17 +1061,24 @@ static int keyspan_open (struct usb_seri
46219         struct usb_serial               *serial = port->serial;
46220         const struct keyspan_device_details     *d_details;
46221         int                             i, err;
46222 +       int                             baud_rate, device_port;
46223         struct urb                      *urb;
46224 +       unsigned int                    cflag;
46225  
46226         s_priv = usb_get_serial_data(serial);
46227         p_priv = usb_get_serial_port_data(port);
46228 -       d_details = s_priv->device_details;
46229 +       d_details = p_priv->device_details;
46230         
46231         dbg("%s - port%d.", __FUNCTION__, port->number); 
46232  
46233         /* Set some sane defaults */
46234         p_priv->rts_state = 1;
46235         p_priv->dtr_state = 1;
46236 +       p_priv->baud = 9600;
46237 +
46238 +       /* force baud and lcr to be set on open */
46239 +       p_priv->old_baud = 0;
46240 +       p_priv->old_cflag = 0;
46241  
46242         p_priv->out_flip = 0;
46243         p_priv->in_flip = 0;
46244 @@ -922,7 +1088,10 @@ static int keyspan_open (struct usb_seri
46245                 if ((urb = p_priv->in_urbs[i]) == NULL)
46246                         continue;
46247                 urb->dev = serial->dev;
46248 -               usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0);
46249 +
46250 +               /* make sure endpoint data toggle is synchronized with the device */
46251 +               
46252 +               usb_clear_halt(urb->dev, urb->pipe);
46253  
46254                 if ((err = usb_submit_urb(urb, GFP_KERNEL)) != 0) {
46255                         dbg("%s - submit urb %d failed (%d)", __FUNCTION__, i, err);
46256 @@ -937,12 +1106,29 @@ static int keyspan_open (struct usb_seri
46257                 /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0); */
46258         }
46259  
46260 -       // if the device is a USA49x, determine whether it is an W or WLC model
46261 -       // and set the baud clock accordingly
46262 +       /* get the terminal config for the setup message now so we don't 
46263 +        * need to send 2 of them */
46264 +
46265 +       cflag = port->tty->termios->c_cflag;
46266 +       device_port = port->number - port->serial->minor;
46267 +
46268 +       /* Baud rate calculation takes baud rate as an integer
46269 +          so other rates can be generated if desired. */
46270 +       baud_rate = tty_get_baud_rate(port->tty);
46271 +       /* If no match or invalid, leave as default */          
46272 +       if (baud_rate >= 0
46273 +           && d_details->calculate_baud_rate(baud_rate, d_details->baudclk,
46274 +                               NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
46275 +               p_priv->baud = baud_rate;
46276 +       }
46277 +
46278 +       /* set CTS/RTS handshake etc. */
46279 +       p_priv->cflag = cflag;
46280 +       p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none;
46281  
46282         keyspan_send_setup(port, 1);
46283         //mdelay(100);
46284 -       keyspan_set_termios(port, NULL);
46285 +       //keyspan_set_termios(port, NULL);
46286  
46287         return (0);
46288  }
46289 @@ -977,7 +1163,7 @@ static void keyspan_close(struct usb_ser
46290                 keyspan_send_setup(port, 2);
46291                 /* pilot-xfer seems to work best with this delay */
46292                 mdelay(100);
46293 -               keyspan_set_termios(port, NULL);
46294 +               // keyspan_set_termios(port, NULL);
46295         }
46296  
46297         /*while (p_priv->outcont_urb->status == -EINPROGRESS) {
46298 @@ -1172,6 +1358,14 @@ static struct callbacks {
46299                 .outdat_callback =      usa2x_outdat_callback,
46300                 .inack_callback =       usa49_inack_callback,
46301                 .outcont_callback =     usa49_outcont_callback,
46302 +       }, {
46303 +               /* msg_usa90 callbacks */
46304 +               .instat_callback =      usa90_instat_callback,
46305 +               .glocont_callback =     usa28_glocont_callback,         
46306 +               .indat_callback =       usa90_indat_callback,
46307 +               .outdat_callback =      usa2x_outdat_callback,
46308 +               .inack_callback =       usa28_inack_callback,
46309 +               .outcont_callback =     usa90_outcont_callback,
46310         }
46311  };
46312  
46313 @@ -1295,6 +1489,41 @@ static int keyspan_usa19_calc_baud(u32 b
46314         return (KEYSPAN_BAUD_RATE_OK);
46315  }
46316  
46317 +/* usa19hs function doesn't require prescaler */
46318 +static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
46319 +                                  u8 *rate_low, u8 *prescaler, int portnum)
46320 +{
46321 +       u32     b16,    /* baud rate times 16 (actual rate used internally) */
46322 +                       div;    /* divisor */   
46323 +               
46324 +       dbg ("%s - %d.", __FUNCTION__, baud_rate);
46325 +
46326 +               /* prevent divide by zero...  */
46327 +       if( (b16 = (baud_rate * 16L)) == 0) 
46328 +               return (KEYSPAN_INVALID_BAUD_RATE);
46329 +       
46330 +
46331 +
46332 +               /* calculate the divisor */
46333 +       if( (div = (baudclk / b16)) == 0) 
46334 +               return (KEYSPAN_INVALID_BAUD_RATE);
46335 +
46336 +       if(div > 0xffff) 
46337 +               return (KEYSPAN_INVALID_BAUD_RATE);
46338 +
46339 +               /* return the counter values if non-null */
46340 +       if (rate_low) 
46341 +               *rate_low = (u8) (div & 0xff);
46342 +       
46343 +       if (rate_hi) 
46344 +               *rate_hi = (u8) ((div >> 8) & 0xff);
46345 +       
46346 +       if (rate_low && rate_hi) 
46347 +               dbg ("%s - %d %02x %02x.", __FUNCTION__, baud_rate, *rate_hi, *rate_low);
46348 +       
46349 +       return (KEYSPAN_BAUD_RATE_OK);
46350 +}
46351 +
46352  static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
46353                                     u8 *rate_low, u8 *prescaler, int portnum)
46354  {
46355 @@ -1447,6 +1676,7 @@ static int keyspan_usa26_send_setup(stru
46356                 p_priv->resend_cont = reset_port + 1;
46357         if (this_urb->status == -EINPROGRESS) {
46358                 /*  dbg ("%s - already writing", __FUNCTION__); */
46359 +               mdelay(5);
46360                 return(-1);
46361         }
46362  
46363 @@ -1597,6 +1827,7 @@ static int keyspan_usa28_send_setup(stru
46364                 p_priv->resend_cont = reset_port + 1;
46365         if (this_urb->status == -EINPROGRESS) {
46366                 dbg ("%s already writing", __FUNCTION__);
46367 +               mdelay(5);
46368                 return(-1);
46369         }
46370  
46371 @@ -1729,6 +1960,7 @@ static int keyspan_usa49_send_setup(stru
46372                 p_priv->resend_cont = reset_port + 1;
46373         if (this_urb->status == -EINPROGRESS) {
46374                 /*  dbg ("%s - already writing", __FUNCTION__); */
46375 +               mdelay(5);
46376                 return(-1);
46377         }
46378  
46379 @@ -1857,6 +2089,144 @@ static int keyspan_usa49_send_setup(stru
46380         return (0);
46381  }
46382  
46383 +static int keyspan_usa90_send_setup(struct usb_serial *serial,
46384 +                                   struct usb_serial_port *port,
46385 +                                   int reset_port)
46386 +{
46387 +       struct keyspan_usa90_portControlMessage msg;            
46388 +       struct keyspan_serial_private           *s_priv;
46389 +       struct keyspan_port_private             *p_priv;
46390 +       const struct keyspan_device_details     *d_details;
46391 +       struct urb                              *this_urb;
46392 +       int                                     err;
46393 +       u8                                              prescaler;
46394 +
46395 +       dbg ("%s", __FUNCTION__);
46396 +
46397 +       s_priv = usb_get_serial_data(serial);
46398 +       p_priv = usb_get_serial_port_data(port);
46399 +       d_details = s_priv->device_details;
46400 +
46401 +       /* only do something if we have a bulk out endpoint */
46402 +       if ((this_urb = p_priv->outcont_urb) == NULL) {
46403 +               dbg("%s - oops no urb.", __FUNCTION__);
46404 +               return -1;
46405 +       }
46406 +
46407 +       /* Save reset port val for resend.
46408 +          Don't overwrite resend for open/close condition. */
46409 +       if ((reset_port + 1) > p_priv->resend_cont)
46410 +               p_priv->resend_cont = reset_port + 1;
46411 +       if (this_urb->status == -EINPROGRESS) {
46412 +               dbg ("%s already writing", __FUNCTION__);
46413 +               mdelay(5);
46414 +               return(-1);
46415 +       }
46416 +
46417 +       memset(&msg, 0, sizeof (struct keyspan_usa90_portControlMessage));
46418 +
46419 +       /* Only set baud rate if it's changed */        
46420 +       if (p_priv->old_baud != p_priv->baud) {
46421 +               p_priv->old_baud = p_priv->baud;
46422 +               msg.setClocking = 0x01;
46423 +               if (d_details->calculate_baud_rate
46424 +                   (p_priv->baud, d_details->baudclk, &msg.baudHi,
46425 +                    &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE ) {
46426 +                       dbg("%s - Invalid baud rate %d requested, using 9600.", __FUNCTION__,
46427 +                           p_priv->baud);
46428 +                       p_priv->baud = 9600;
46429 +                       d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, 
46430 +                               &msg.baudHi, &msg.baudLo, &prescaler, 0);
46431 +               }
46432 +               msg.setRxMode = 1;
46433 +               msg.setTxMode = 1;
46434 +       }
46435 +
46436 +       /* modes must always be correctly specified */
46437 +       if (p_priv->baud > 57600)
46438 +       {
46439 +               msg.rxMode = RXMODE_DMA;
46440 +               msg.txMode = TXMODE_DMA;
46441 +       }
46442 +       else
46443 +       {
46444 +               msg.rxMode = RXMODE_BYHAND;
46445 +               msg.txMode = TXMODE_BYHAND;
46446 +       }
46447 +
46448 +       msg.lcr = (p_priv->cflag & CSTOPB)? STOPBITS_678_2: STOPBITS_5678_1;
46449 +       switch (p_priv->cflag & CSIZE) {
46450 +       case CS5:
46451 +               msg.lcr |= USA_DATABITS_5;
46452 +               break;
46453 +       case CS6:
46454 +               msg.lcr |= USA_DATABITS_6;
46455 +               break;
46456 +       case CS7:
46457 +               msg.lcr |= USA_DATABITS_7;
46458 +               break;
46459 +       case CS8:
46460 +               msg.lcr |= USA_DATABITS_8;
46461 +               break;
46462 +       }
46463 +       if (p_priv->cflag & PARENB) {
46464 +               /* note USA_PARITY_NONE == 0 */
46465 +               msg.lcr |= (p_priv->cflag & PARODD)?
46466 +                       USA_PARITY_ODD: USA_PARITY_EVEN;
46467 +       }
46468 +       if (p_priv->old_cflag != p_priv->cflag) {
46469 +               p_priv->old_cflag = p_priv->cflag;
46470 +               msg.setLcr = 0x01;
46471 +       }
46472 +
46473 +       if (p_priv->flow_control == flow_cts)
46474 +               msg.txFlowControl = TXFLOW_CTS;
46475 +       msg.setTxFlowControl = 0x01;
46476 +       msg.setRxFlowControl = 0x01;
46477 +       
46478 +       msg.rxForwardingLength = 16;
46479 +       msg.rxForwardingTimeout = 16;   
46480 +       msg.txAckSetting = 0;
46481 +       msg.xonChar = 17;
46482 +       msg.xoffChar = 19;
46483 +
46484 +       /* Opening port */ 
46485 +       if (reset_port == 1) {
46486 +               msg.portEnabled = 1;
46487 +               msg.rxFlush = 1;
46488 +               msg.txBreak = (p_priv->break_on);
46489 +       }
46490 +       /* Closing port */
46491 +       else if (reset_port == 2) {
46492 +               msg.portEnabled = 0;
46493 +       }
46494 +       /* Sending intermediate configs */
46495 +       else {
46496 +               if (port->open_count)
46497 +                       msg.portEnabled = 1;
46498 +               msg.txBreak = (p_priv->break_on);
46499 +       }
46500 +
46501 +       /* Do handshaking outputs */    
46502 +       msg.setRts = 0x01;
46503 +       msg.rts = p_priv->rts_state;
46504 +
46505 +       msg.setDtr = 0x01;
46506 +       msg.dtr = p_priv->dtr_state;
46507 +               
46508 +       p_priv->resend_cont = 0;
46509 +       memcpy (this_urb->transfer_buffer, &msg, sizeof(msg));
46510 +       
46511 +       /* send the data out the device on control endpoint */
46512 +       this_urb->transfer_buffer_length = sizeof(msg);
46513 +
46514 +       this_urb->dev = serial->dev;
46515 +       if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
46516 +               dbg("%s - usb_submit_urb(setup) failed (%d)", __FUNCTION__, err);
46517 +       }
46518 +       return (0);
46519 +}
46520 +
46521  static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
46522  {
46523         struct usb_serial *serial = port->serial;
46524 @@ -1878,9 +2248,13 @@ static void keyspan_send_setup(struct us
46525         case msg_usa49:
46526                 keyspan_usa49_send_setup(serial, port, reset_port);
46527                 break;
46528 +       case msg_usa90:
46529 +               keyspan_usa90_send_setup(serial, port, reset_port);
46530 +               break;
46531         }
46532  }
46533  
46534 +
46535  /* Gets called by the "real" driver (ie once firmware is loaded
46536     and renumeration has taken place. */
46537  static int keyspan_startup (struct usb_serial *serial)
46538 --- linux-2.6.0-test6/drivers/usb/serial/keyspan.h      2003-06-14 12:18:25.000000000 -0700
46539 +++ 25/drivers/usb/serial/keyspan.h     2003-10-05 00:33:24.000000000 -0700
46540 @@ -82,6 +82,10 @@ static int  keyspan_usa28_calc_baud  (u32
46541                                          u8 *rate_hi, u8 *rate_low,
46542                                          u8 *prescaler, int portnum);
46543  
46544 +static int  keyspan_usa19hs_calc_baud  (u32 baud_rate, u32 baudclk,
46545 +                                        u8 *rate_hi, u8 *rate_low,
46546 +                                        u8 *prescaler, int portnum);
46547 +
46548  static int  keyspan_usa28_send_setup   (struct usb_serial *serial,
46549                                          struct usb_serial_port *port,
46550                                          int reset_port);
46551 @@ -92,6 +96,9 @@ static int  keyspan_usa49_send_setup  (st
46552                                          struct usb_serial_port *port,
46553                                          int reset_port);
46554  
46555 +static int  keyspan_usa90_send_setup   (struct usb_serial *serial,
46556 +                                        struct usb_serial_port *port,
46557 +                                        int reset_port);
46558  
46559  /* Struct used for firmware - increased size of data section
46560     to allow Keyspan's 'C' firmware struct to be used unmodified */
46561 @@ -183,6 +190,7 @@ struct ezusb_hex_record {
46562  #define        KEYSPAN_USA18X_BAUDCLK                  (12000000L)     /* a guess */
46563  #define        KEYSPAN_USA19_BAUDCLK                   (12000000L)
46564  #define        KEYSPAN_USA19W_BAUDCLK                  (24000000L)
46565 +#define        KEYSPAN_USA19HS_BAUDCLK                 (14769231L)
46566  #define        KEYSPAN_USA28_BAUDCLK                   (1843200L)
46567  #define        KEYSPAN_USA28X_BAUDCLK                  (12000000L)
46568  #define        KEYSPAN_USA49W_BAUDCLK                  (48000000L)
46569 @@ -215,6 +223,7 @@ struct ezusb_hex_record {
46570  #define        keyspan_usa18x_product_id               0x0112
46571  #define        keyspan_usa19_product_id                0x0107
46572  #define        keyspan_usa19qi_product_id              0x010c
46573 +#define        keyspan_usa19hs_product_id              0x0121
46574  #define        keyspan_mpr_product_id                  0x011c
46575  #define        keyspan_usa19qw_product_id              0x0119
46576  #define        keyspan_usa19w_product_id               0x0108
46577 @@ -230,7 +239,7 @@ struct keyspan_device_details {
46578         /* product ID value */
46579         int     product_id;
46580  
46581 -       enum    {msg_usa26, msg_usa28, msg_usa49} msg_format;
46582 +       enum    {msg_usa26, msg_usa28, msg_usa49, msg_usa90} msg_format;
46583  
46584                 /* Number of physical ports */
46585         int     num_ports;
46586 @@ -349,6 +358,22 @@ static const struct keyspan_device_detai
46587         .baudclk                = KEYSPAN_USA19W_BAUDCLK,
46588  };
46589  
46590 +static const struct keyspan_device_details usa19hs_device_details = {
46591 +       product_id:             keyspan_usa19hs_product_id,
46592 +       msg_format:             msg_usa90,
46593 +       num_ports:              1,
46594 +       indat_endp_flip:        0,
46595 +       outdat_endp_flip:       0,
46596 +       indat_endpoints:        {0x81},
46597 +       outdat_endpoints:       {0x01},
46598 +       inack_endpoints:        {-1},
46599 +       outcont_endpoints:      {0x02},
46600 +       instat_endpoint:        0x82,
46601 +       glocont_endpoint:       -1,
46602 +       calculate_baud_rate:    keyspan_usa19hs_calc_baud,
46603 +       baudclk:                KEYSPAN_USA19HS_BAUDCLK,
46604 +};
46605 +
46606  static const struct keyspan_device_details usa28_device_details = {
46607         .product_id             = keyspan_usa28_product_id,
46608         .msg_format             = msg_usa28,
46609 @@ -437,6 +462,7 @@ static const struct keyspan_device_detai
46610         &usa19qi_device_details,
46611         &usa19qw_device_details,
46612         &usa19w_device_details,
46613 +       &usa19hs_device_details,
46614         &usa28_device_details,
46615         &usa28x_device_details,
46616         &usa28xa_device_details,
46617 @@ -464,6 +490,7 @@ static struct usb_device_id keyspan_ids_
46618         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19w_product_id) },
46619         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qi_product_id) },
46620         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19qw_product_id) },
46621 +       { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa19hs_product_id) },
46622         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_mpr_product_id) },
46623         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28_product_id) },
46624         { USB_DEVICE(KEYSPAN_VENDOR_ID, keyspan_usa28x_product_id) },
46625 @@ -544,8 +571,8 @@ static struct usb_serial_device_type key
46626         .short_name             = "keyspan_1",
46627         .id_table               = keyspan_1port_ids,
46628         .num_interrupt_in       = NUM_DONT_CARE,
46629 -       .num_bulk_in            = 3,
46630 -       .num_bulk_out           = 4,
46631 +       .num_bulk_in            = NUM_DONT_CARE,
46632 +       .num_bulk_out           = NUM_DONT_CARE,
46633         .num_ports              = 1,
46634         .open                   = keyspan_open,
46635         .close                  = keyspan_close,
46636 --- linux-2.6.0-test6/drivers/usb/serial/keyspan_usa26msg.h     2003-09-08 13:58:58.000000000 -0700
46637 +++ 25/drivers/usb/serial/keyspan_usa26msg.h    2003-10-05 00:33:24.000000000 -0700
46638 @@ -4,7 +4,7 @@
46639         Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
46640         This file is available under a BSD-style copyright
46641  
46642 -       Keyspan USB Async Firmware to run on Anchor EZ-USB
46643 +       Keyspan USB Async Message Formats for the USA28X
46644  
46645         Redistribution and use in source and binary forms, with or without
46646         modification, are permitted provided that the following conditions are
46647 @@ -19,11 +19,7 @@
46648  
46649                 This file is available under a BSD-style copyright
46650  
46651 -       2. Redistributions in binary form must reproduce the above copyright
46652 -       notice, this list of conditions and the following disclaimer in the
46653 -       documentation and/or other materials provided with the distribution.
46654 -
46655 -       3. The name of InnoSys Incorporated may not be used to endorse or promote
46656 +       2. The name of InnoSys Incorporated may not be used to endorse or promote
46657         products derived from this software without specific prior written
46658         permission.
46659  
46660 --- linux-2.6.0-test6/drivers/usb/serial/keyspan_usa28msg.h     2003-09-08 13:58:58.000000000 -0700
46661 +++ 25/drivers/usb/serial/keyspan_usa28msg.h    2003-10-05 00:33:24.000000000 -0700
46662 @@ -4,7 +4,7 @@
46663         Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
46664         This file is available under a BSD-style copyright
46665  
46666 -       Keyspan USB Async Firmware to run on Anchor EZ-USB
46667 +       Keyspan USB Async Message Formats for the USA26X
46668  
46669         Redistribution and use in source and binary forms, with or without
46670         modification, are permitted provided that the following conditions are
46671 @@ -19,11 +19,7 @@
46672  
46673                 This file is available under a BSD-style copyright
46674  
46675 -       2. Redistributions in binary form must reproduce the above copyright
46676 -       notice, this list of conditions and the following disclaimer in the
46677 -       documentation and/or other materials provided with the distribution.
46678 -
46679 -       3. The name of InnoSys Incorporated may not be used to endorse or promote
46680 +       2. The name of InnoSys Incorporated may not be used to endorse or promote
46681         products derived from this software without specific prior written
46682         permission.
46683  
46684 --- linux-2.6.0-test6/drivers/usb/serial/keyspan_usa49msg.h     2003-09-08 13:58:58.000000000 -0700
46685 +++ 25/drivers/usb/serial/keyspan_usa49msg.h    2003-10-05 00:33:24.000000000 -0700
46686 @@ -4,7 +4,7 @@
46687         Copyright (C) 1998-2000 InnoSys Incorporated.  All Rights Reserved
46688         This file is available under a BSD-style copyright
46689  
46690 -       Keyspan USB Async Firmware to run on Anchor EZ-USB
46691 +       Keyspan USB Async Message Formats for the USA49W
46692  
46693         Redistribution and use in source and binary forms, with or without
46694         modification, are permitted provided that the following conditions are
46695 @@ -19,11 +19,7 @@
46696  
46697                 This file is available under a BSD-style copyright
46698  
46699 -       2. Redistributions in binary form must reproduce the above copyright
46700 -       notice, this list of conditions and the following disclaimer in the
46701 -       documentation and/or other materials provided with the distribution.
46702 -
46703 -       3. The name of InnoSys Incorporated may not be used to endorse or promote
46704 +       2. The name of InnoSys Incorporated may not be used to endorse or promote
46705         products derived from this software without specific prior written
46706         permission.
46707  
46708 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
46709 +++ 25/drivers/usb/serial/keyspan_usa90msg.h    2003-10-05 00:33:24.000000000 -0700
46710 @@ -0,0 +1,198 @@
46711 +/*
46712 +       usa90msg.h
46713 +
46714 +       Copyright (c) 1998-2003 InnoSys Incorporated.  All Rights Reserved
46715 +       This file is available under a BSD-style copyright
46716 +
46717 +       Keyspan USB Async Message Formats for the USA19HS
46718 +
46719 +       Redistribution and use in source and binary forms, with or without
46720 +       modification, are permitted provided that the following conditions are
46721 +       met:
46722 +
46723 +       1. Redistributions of source code must retain this licence text
46724 +       without modification, this list of conditions, and the following
46725 +       disclaimer.  The following copyright notice must appear immediately at
46726 +       the beginning of all source files:
46727 +
46728 +               Copyright (c) 1998-2003 InnoSys Incorporated.  All Rights Reserved
46729 +
46730 +               This file is available under a BSD-style copyright
46731 +
46732 +       2. The name of InnoSys Incorprated may not be used to endorse or promote
46733 +       products derived from this software without specific prior written
46734 +       permission.
46735 +
46736 +       THIS SOFTWARE IS PROVIDED BY INNOSYS CORP. ``AS IS'' AND ANY EXPRESS OR
46737 +       IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
46738 +       OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
46739 +       NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
46740 +       INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
46741 +       (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
46742 +       SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
46743 +       CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
46744 +       LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
46745 +       OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46746 +       SUCH DAMAGE.    
46747 +
46748 +       Revisions:
46749 +
46750 +       2003feb14               add setTxMode/txMode  and cancelRxXoff to portControl
46751 +       2003mar21               change name of PARITY_0/1 to add MARK/SPACE
46752 +*/
46753 +
46754 +#ifndef        __USA90MSG__
46755 +#define        __USA90MSG__
46756 +
46757 +struct keyspan_usa90_portControlMessage
46758 +{
46759 +       /*
46760 +               there are three types of "commands" sent in the control message:
46761 +
46762 +               1.      configuration changes which must be requested by setting
46763 +                       the corresponding "set" flag (and should only be requested
46764 +                       when necessary, to reduce overhead on the device):
46765 +       */
46766 +
46767 +       u8      setClocking,    // host requests baud rate be set
46768 +               baudLo,                 // host does baud divisor calculation
46769 +               baudHi,                 // host does baud divisor calculation 
46770 +               
46771 +               setLcr,                 // host requests lcr be set
46772 +               lcr,                    // use PARITY, STOPBITS, DATABITS below
46773 +               
46774 +               setRxMode,              // set receive mode
46775 +               rxMode,                 // RXMODE_DMA or RXMODE_BYHAND
46776 +
46777 +               setTxMode,              // set transmit mode
46778 +               txMode,                 // TXMODE_DMA or TXMODE_BYHAND
46779 +
46780 +               setTxFlowControl,       // host requests tx flow control be set
46781 +               txFlowControl   ,       // use TX_FLOW... bits below
46782 +               setRxFlowControl,       // host requests rx flow control be set
46783 +               rxFlowControl,  // use RX_FLOW... bits below
46784 +               sendXoff,               // host requests XOFF transmitted immediately
46785 +               sendXon,                // host requests XON char transmitted
46786 +               xonChar,                // specified in current character format
46787 +               xoffChar,               // specified in current character format
46788 +
46789 +               sendChar,               // host requests char transmitted immediately
46790 +               txChar,                 // character to send
46791 +
46792 +               setRts,                 // host requests RTS output be set
46793 +               rts,                    // 1=on, 0=off
46794 +               setDtr,                 // host requests DTR output be set
46795 +               dtr;                    // 1=on, 0=off
46796 +
46797 +       
46798 +       /*
46799 +               2.      configuration data which is simply used as is 
46800 +                       and must be specified correctly in every host message.
46801 +       */
46802 +
46803 +       u8      rxForwardingLength,  // forward when this number of chars available
46804 +               rxForwardingTimeout, // (1-31 in ms)
46805 +               txAckSetting;      // 0=don't ack, 1=normal, 2-255 TBD...
46806 +       /*
46807 +               3.      Firmware states which cause actions if they change                                      
46808 +               and must be specified correctly in every host message.
46809 +       */
46810 +
46811 +       u8      portEnabled,    // 0=disabled, 1=enabled
46812 +               txFlush,                // 0=normal, 1=toss outbound data
46813 +               txBreak,                // 0=break off, 1=break on
46814 +               loopbackMode;   // 0=no loopback, 1=loopback enabled
46815 +
46816 +       /*
46817 +               4.      commands which are flags only; these are processed in order
46818 +                       (so that, e.g., if rxFlush and rxForward flags are set, the
46819 +                       port will have no data to forward); any non-zero value 
46820 +                       is respected
46821 +       */
46822 +
46823 +       u8      rxFlush,                // toss inbound data
46824 +               rxForward,              // forward all inbound data, NOW (as if fwdLen==1)
46825 +               cancelRxXoff,   // cancel any receive XOFF state (_txXoff)
46826 +               returnStatus;   // return current status NOW
46827 +};
46828 +
46829 +// defines for bits in lcr
46830 +#define                USA_DATABITS_5          0x00
46831 +#define                USA_DATABITS_6          0x01
46832 +#define                USA_DATABITS_7          0x02
46833 +#define                USA_DATABITS_8          0x03
46834 +#define                STOPBITS_5678_1         0x00    // 1 stop bit for all byte sizes
46835 +#define                STOPBITS_5_1p5          0x04    // 1.5 stop bits for 5-bit byte
46836 +#define                STOPBITS_678_2          0x04    // 2 stop bits for 6-8 bit byte
46837 +#define                USA_PARITY_NONE         0x00
46838 +#define                USA_PARITY_ODD          0x08
46839 +#define                USA_PARITY_EVEN         0x18
46840 +#define                PARITY_MARK_1           0x28    // force parity MARK
46841 +#define                PARITY_SPACE_0          0x38    // force parity SPACE
46842 +
46843 +#define                TXFLOW_CTS                      0x04    
46844 +#define                TXFLOW_DSR                      0x08
46845 +#define                TXFLOW_XOFF                     0x01    
46846 +#define                TXFLOW_XOFF_ANY         0x02    
46847 +#define                TXFLOW_XOFF_BITS        (TXFLOW_XOFF | TXFLOW_XOFF_ANY)
46848 +
46849 +#define                RXFLOW_XOFF                     0x10    
46850 +#define                RXFLOW_RTS                      0x20    
46851 +#define                RXFLOW_DTR                      0x40
46852 +#define                RXFLOW_DSR_SENSITIVITY  0x80
46853 +
46854 +#define                RXMODE_BYHAND           0x00    
46855 +#define                RXMODE_DMA                      0x02    
46856 +
46857 +#define                TXMODE_BYHAND           0x00    
46858 +#define                TXMODE_DMA                      0x02    
46859 +
46860 +
46861 +// all things called "StatusMessage" are sent on the status endpoint
46862 +
46863 +struct keyspan_usa90_portStatusMessage 
46864 +{
46865 +       u8      msr,                    // reports the actual MSR register
46866 +               cts,                    // reports CTS pin
46867 +               dcd,                    // reports DCD pin
46868 +               dsr,                    // reports DSR pin
46869 +               ri,                             // reports RI pin
46870 +               _txXoff,                // port is in XOFF state (we received XOFF)
46871 +               rxBreak,                // reports break state
46872 +               rxOverrun,              // count of overrun errors (since last reported)
46873 +               rxParity,               // count of parity errors (since last reported)
46874 +               rxFrame,                // count of frame errors (since last reported)
46875 +               portState,              // PORTSTATE_xxx bits (useful for debugging)
46876 +               messageAck,             // message acknowledgement
46877 +               charAck,                // character acknowledgement
46878 +               controlResponse;        // (value = returnStatus) a control message has been processed 
46879 +};
46880 +
46881 +// bits in RX data message when STAT byte is included
46882 +
46883 +#define        RXERROR_OVERRUN         0x02
46884 +#define        RXERROR_PARITY          0x04
46885 +#define        RXERROR_FRAMING         0x08
46886 +#define        RXERROR_BREAK           0x10
46887 +
46888 +#define        PORTSTATE_ENABLED       0x80
46889 +#define        PORTSTATE_TXFLUSH       0x01
46890 +#define        PORTSTATE_TXBREAK       0x02
46891 +#define        PORTSTATE_LOOPBACK      0x04
46892 +
46893 +// MSR bits
46894 +
46895 +#define MSR_dCTS                       0x01            // CTS has changed since last report    
46896 +#define MSR_dDSR                       0x02
46897 +#define MSR_dRI                                0x04
46898 +#define MSR_dDCD                       0x08
46899 +
46900 +#define MSR_CTS                                0x10            // current state of CTS
46901 +#define MSR_DSR                                0x20
46902 +#define MSR_RI                         0x40
46903 +#define MSR_DCD                                0x80
46904 +
46905 +// ie: the maximum length of an endpoint buffer
46906 +#define                MAX_DATA_LEN                    64
46907 +
46908 +#endif
46909 --- linux-2.6.0-test6/drivers/usb/storage/freecom.c     2003-07-13 21:44:34.000000000 -0700
46910 +++ 25/drivers/usb/storage/freecom.c    2003-10-05 00:33:24.000000000 -0700
46911 @@ -101,7 +101,8 @@ struct freecom_status {
46912  #define FCM_PACKET_IDE_READ    0xC0
46913  
46914  /* All packets (except for status) are 64 bytes long. */
46915 -#define FCM_PACKET_LENGTH      64
46916 +#define FCM_PACKET_LENGTH              64
46917 +#define FCM_STATUS_PACKET_LENGTH       4
46918  
46919  static int
46920  freecom_readdata (Scsi_Cmnd *srb, struct us_data *us,
46921 @@ -216,7 +217,7 @@ int freecom_transport(Scsi_Cmnd *srb, st
46922         /* There are times we can optimize out this status read, but it
46923          * doesn't hurt us to always do it now. */
46924         result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
46925 -                       FCM_PACKET_LENGTH, &partial);
46926 +                       FCM_STATUS_PACKET_LENGTH, &partial);
46927         US_DEBUGP("foo Status result %d %u\n", result, partial);
46928         if (result != USB_STOR_XFER_GOOD)
46929                 return USB_STOR_TRANSPORT_ERROR;
46930 @@ -256,10 +257,10 @@ int freecom_transport(Scsi_Cmnd *srb, st
46931  
46932                 /* get the data */
46933                 result = usb_stor_bulk_transfer_buf (us, ipipe, fst,
46934 -                               FCM_PACKET_LENGTH, &partial);
46935 +                               FCM_STATUS_PACKET_LENGTH, &partial);
46936  
46937                 US_DEBUGP("bar Status result %d %u\n", result, partial);
46938 -               if (result > USB_STOR_XFER_SHORT)
46939 +               if (result != USB_STOR_XFER_GOOD)
46940                         return USB_STOR_TRANSPORT_ERROR;
46941  
46942                 US_DEBUG(pdump ((void *) fst, partial));
46943 @@ -302,6 +303,9 @@ int freecom_transport(Scsi_Cmnd *srb, st
46944  
46945         switch (us->srb->sc_data_direction) {
46946         case SCSI_DATA_READ:
46947 +               /* catch bogus "read 0 length" case */
46948 +               if (!length)
46949 +                       break;
46950                 /* Make sure that the status indicates that the device
46951                  * wants data as well. */
46952                 if ((fst->Status & DRQ_STAT) == 0 || (fst->Reason & 3) != 2) {
46953 @@ -331,6 +335,9 @@ int freecom_transport(Scsi_Cmnd *srb, st
46954                 break;
46955  
46956         case SCSI_DATA_WRITE:
46957 +               /* catch bogus "write 0 length" case */
46958 +               if (!length)
46959 +                       break;
46960                 /* Make sure the status indicates that the device wants to
46961                  * send us data. */
46962                 /* !!IMPLEMENT!! */
46963 @@ -362,6 +369,7 @@ int freecom_transport(Scsi_Cmnd *srb, st
46964                 break;
46965  
46966         default:
46967 +               /* should never hit here -- filtered in usb.c */
46968                 US_DEBUGP ("freecom unimplemented direction: %d\n",
46969                                 us->srb->sc_data_direction);
46970                 // Return fail, SCSI seems to handle this better.
46971 --- linux-2.6.0-test6/drivers/usb/storage/unusual_devs.h        2003-09-27 18:57:46.000000000 -0700
46972 +++ 25/drivers/usb/storage/unusual_devs.h       2003-10-05 00:33:24.000000000 -0700
46973 @@ -394,6 +394,12 @@ UNUSUAL_DEV( 0x0686, 0x4011, 0x0001, 0x0
46974                 "Dimage F300",
46975                 US_SC_SCSI, US_PR_BULK, NULL, 0 ),
46976  
46977 +/* Reported by Miguel A. Fosas <amn3s1a@ono.com> */
46978 +UNUSUAL_DEV(  0x0686, 0x4017, 0x0001, 0x0001,
46979 +                "Minolta",
46980 +                "DIMAGE E223",
46981 +                US_SC_SCSI, US_PR_DEVICE, NULL, 0 ),
46982 +
46983  UNUSUAL_DEV(  0x0693, 0x0002, 0x0100, 0x0100, 
46984                 "Hagiwara",
46985                 "FlashGate SmartMedia",
46986 @@ -542,7 +548,7 @@ UNUSUAL_DEV(  0x07c4, 0xa400, 0x0000, 0x
46987   * - They don't like the INQUIRY command. So we must handle this command
46988   *   of the SCSI layer ourselves.
46989   */
46990 -UNUSUAL_DEV( 0x07cf, 0x1001, 0x1000, 0x9009,
46991 +UNUSUAL_DEV( 0x07cf, 0x1001, 0x1000, 0x5009,
46992                 "Casio",
46993                 "QV DigitalCamera",
46994                 US_SC_8070, US_PR_CB, NULL,
46995 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
46996 +++ 25/drivers/video/asiliantfb.c       2003-10-05 00:34:22.000000000 -0700
46997 @@ -0,0 +1,619 @@
46998 +/*
46999 + * drivers/video/asiliantfb.c
47000 + *  frame buffer driver for Asiliant 69000 chip
47001 + *  Copyright (C) 2001-2003 Saito.K & Jeanne
47002 + *
47003 + *  from driver/video/chipsfb.c and,
47004 + *
47005 + *  drivers/video/asiliantfb.c -- frame buffer device for
47006 + *  Asiliant 69030 chip (formerly Intel, formerly Chips & Technologies)
47007 + *  Author: apc@agelectronics.co.uk
47008 + *  Copyright (C) 2000 AG Electronics
47009 + *  Note: the data sheets don't seem to be available from Asiliant.
47010 + *  They are available by searching developer.intel.com, but are not otherwise
47011 + *  linked to.
47012 + *
47013 + *  This driver should be portable with minimal effort to the 69000 display
47014 + *  chip, and to the twin-display mode of the 69030.
47015 + *  Contains code from Thomas Hhenleitner <th@visuelle-maschinen.de> (thanks)
47016 + *
47017 + *  Derived from the CT65550 driver chipsfb.c:
47018 + *  Copyright (C) 1998 Paul Mackerras
47019 + *  ...which was derived from the Powermac "chips" driver:
47020 + *  Copyright (C) 1997 Fabio Riccardi.
47021 + *  And from the frame buffer device for Open Firmware-initialized devices:
47022 + *  Copyright (C) 1997 Geert Uytterhoeven.
47023 + *
47024 + *  This file is subject to the terms and conditions of the GNU General Public
47025 + *  License. See the file COPYING in the main directory of this archive for
47026 + *  more details.
47027 + */
47028 +
47029 +#include <linux/config.h>
47030 +#include <linux/module.h>
47031 +#include <linux/kernel.h>
47032 +#include <linux/errno.h>
47033 +#include <linux/string.h>
47034 +#include <linux/mm.h>
47035 +#include <linux/tty.h>
47036 +#include <linux/slab.h>
47037 +#include <linux/vmalloc.h>
47038 +#include <linux/delay.h>
47039 +#include <linux/interrupt.h>
47040 +#include <linux/fb.h>
47041 +#include <linux/init.h>
47042 +#include <linux/pci.h>
47043 +#include <asm/io.h>
47044 +
47045 +static struct fb_info asiliantfb_info;
47046 +
47047 +/* Built in clock of the 69030 */
47048 +const unsigned Fref = 14318180;
47049 +
47050 +static u32 pseudo_palette[17];
47051 +
47052 +#define mmio_base (p->screen_base + 0x400000)
47053 +
47054 +#define mm_write_ind(num, val, ap, dp) do { \
47055 +       writeb((num), mmio_base + (ap)); writeb((val), mmio_base + (dp)); \
47056 +} while (0)
47057 +
47058 +static void mm_write_xr(struct fb_info *p, u8 reg, u8 data)
47059 +{
47060 +       mm_write_ind(reg, data, 0x7ac, 0x7ad);
47061 +}
47062 +#define write_xr(num, val)     mm_write_xr(p, num, val)
47063 +
47064 +static void mm_write_fr(struct fb_info *p, u8 reg, u8 data)
47065 +{
47066 +       mm_write_ind(reg, data, 0x7a0, 0x7a1);
47067 +}
47068 +#define write_fr(num, val)     mm_write_fr(p, num, val)
47069 +
47070 +static void mm_write_cr(struct fb_info *p, u8 reg, u8 data)
47071 +{
47072 +       mm_write_ind(reg, data, 0x7a8, 0x7a9);
47073 +}
47074 +#define write_cr(num, val)     mm_write_cr(p, num, val)
47075 +
47076 +static void mm_write_gr(struct fb_info *p, u8 reg, u8 data)
47077 +{
47078 +       mm_write_ind(reg, data, 0x79c, 0x79d);
47079 +}
47080 +#define write_gr(num, val)     mm_write_gr(p, num, val)
47081 +
47082 +static void mm_write_sr(struct fb_info *p, u8 reg, u8 data)
47083 +{
47084 +       mm_write_ind(reg, data, 0x788, 0x789);
47085 +}
47086 +#define write_sr(num, val)     mm_write_sr(p, num, val)
47087 +
47088 +static void mm_write_ar(struct fb_info *p, u8 reg, u8 data)
47089 +{
47090 +       readb(mmio_base + 0x7b4);
47091 +       mm_write_ind(reg, data, 0x780, 0x780);
47092 +}
47093 +#define write_ar(num, val)     mm_write_ar(p, num, val)
47094 +
47095 +/*
47096 + * Exported functions
47097 + */
47098 +int asiliantfb_init(void);
47099 +
47100 +static int asiliantfb_pci_init(struct pci_dev *dp, const struct pci_device_id *);
47101 +static int asiliantfb_check_var(struct fb_var_screeninfo *var,
47102 +                               struct fb_info *info);
47103 +static int asiliantfb_set_par(struct fb_info *info);
47104 +static int asiliantfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
47105 +                               u_int transp, struct fb_info *info);
47106 +
47107 +static struct fb_ops asiliantfb_ops = {
47108 +       .owner          = THIS_MODULE,
47109 +       .fb_check_var   = asiliantfb_check_var,
47110 +       .fb_set_par     = asiliantfb_set_par,
47111 +       .fb_setcolreg   = asiliantfb_setcolreg,
47112 +       .fb_fillrect    = cfb_fillrect,
47113 +       .fb_copyarea    = cfb_copyarea,
47114 +       .fb_imageblit   = cfb_imageblit,
47115 +       .fb_cursor      = soft_cursor,
47116 +};
47117 +
47118 +/* Calculate the ratios for the dot clocks without using a single long long
47119 + * value */
47120 +static void asiliant_calc_dclk2(u32 *ppixclock, u8 *dclk2_m, u8 *dclk2_n, u8 *dclk2_div)
47121 +{
47122 +       unsigned pixclock = *ppixclock;
47123 +       unsigned Ftarget = 1000000 * (1000000 / pixclock);
47124 +       unsigned n;
47125 +       unsigned best_error = 0xffffffff;
47126 +       unsigned best_m = 0xffffffff,
47127 +                best_n = 0xffffffff;
47128 +       unsigned ratio;
47129 +       unsigned remainder;
47130 +       unsigned char divisor = 0;
47131 +
47132 +       /* Calculate the frequency required. This is hard enough. */
47133 +       ratio = 1000000 / pixclock;
47134 +       remainder = 1000000 % pixclock;
47135 +       Ftarget = 1000000 * ratio + (1000000 * remainder) / pixclock;
47136 +
47137 +       while (Ftarget < 100000000) {
47138 +               divisor += 0x10;
47139 +               Ftarget <<= 1;
47140 +       }
47141 +
47142 +       ratio = Ftarget / Fref;
47143 +       remainder = Ftarget % Fref;
47144 +
47145 +       /* This expresses the constraint that 150kHz <= Fref/n <= 5Mhz,
47146 +        * together with 3 <= n <= 257. */
47147 +       for (n = 3; n <= 257; n++) {
47148 +               unsigned m = n * ratio + (n * remainder) / Fref;
47149 +
47150 +               /* 3 <= m <= 257 */
47151 +               if (m >= 3 && m <= 257) {
47152 +                       unsigned new_error = ((Ftarget * n) - (Fref * m)) >= 0 ?
47153 +                                              ((Ftarget * n) - (Fref * m)) : ((Fref * m) - (Ftarget * n));
47154 +                       if (new_error < best_error) {
47155 +                               best_n = n;
47156 +                               best_m = m;
47157 +                               best_error = new_error;
47158 +                       }
47159 +               }
47160 +               /* But if VLD = 4, then 4m <= 1028 */
47161 +               else if (m <= 1028) {
47162 +                       /* remember there are still only 8-bits of precision in m, so
47163 +                        * avoid over-optimistic error calculations */
47164 +                       unsigned new_error = ((Ftarget * n) - (Fref * (m & ~3))) >= 0 ?
47165 +                                              ((Ftarget * n) - (Fref * (m & ~3))) : ((Fref * (m & ~3)) - (Ftarget * n));
47166 +                       if (new_error < best_error) {
47167 +                               best_n = n;
47168 +                               best_m = m;
47169 +                               best_error = new_error;
47170 +                       }
47171 +               }
47172 +       }
47173 +       if (best_m > 257)
47174 +               best_m >>= 2;   /* divide m by 4, and leave VCO loop divide at 4 */
47175 +       else
47176 +               divisor |= 4;   /* or set VCO loop divide to 1 */
47177 +       *dclk2_m = best_m - 2;
47178 +       *dclk2_n = best_n - 2;
47179 +       *dclk2_div = divisor;
47180 +       *ppixclock = pixclock;
47181 +       return;
47182 +}
47183 +
47184 +static void asiliant_set_timing(struct fb_info *p)
47185 +{
47186 +       unsigned hd = p->var.xres / 8;
47187 +       unsigned hs = (p->var.xres + p->var.right_margin) / 8;
47188 +               unsigned he = (p->var.xres + p->var.right_margin + p->var.hsync_len) / 8;
47189 +       unsigned ht = (p->var.left_margin + p->var.xres + p->var.right_margin + p->var.hsync_len) / 8;
47190 +       unsigned vd = p->var.yres;
47191 +       unsigned vs = p->var.yres + p->var.lower_margin;
47192 +       unsigned ve = p->var.yres + p->var.lower_margin + p->var.vsync_len;
47193 +       unsigned vt = p->var.upper_margin + p->var.yres + p->var.lower_margin + p->var.vsync_len;
47194 +       unsigned wd = (p->var.xres_virtual * ((p->var.bits_per_pixel+7)/8)) / 8;
47195 +
47196 +       if ((p->var.xres == 640) && (p->var.yres == 480) && (p->var.pixclock == 39722)) {
47197 +         write_fr(0x01, 0x02);  /* LCD */
47198 +       } else {
47199 +         write_fr(0x01, 0x01);  /* CRT */
47200 +       }
47201 +
47202 +       write_cr(0x11, (ve - 1) & 0x0f);
47203 +       write_cr(0x00, (ht - 5) & 0xff);
47204 +       write_cr(0x01, hd - 1);
47205 +       write_cr(0x02, hd);
47206 +       write_cr(0x03, ((ht - 1) & 0x1f) | 0x80);
47207 +       write_cr(0x04, hs);
47208 +       write_cr(0x05, (((ht - 1) & 0x20) <<2) | (he & 0x1f));
47209 +       write_cr(0x3c, (ht - 1) & 0xc0);
47210 +       write_cr(0x06, (vt - 2) & 0xff);
47211 +       write_cr(0x30, (vt - 2) >> 8);
47212 +       write_cr(0x07, 0x00);
47213 +       write_cr(0x08, 0x00);
47214 +       write_cr(0x09, 0x00);
47215 +       write_cr(0x10, (vs - 1) & 0xff);
47216 +       write_cr(0x32, ((vs - 1) >> 8) & 0xf);
47217 +       write_cr(0x11, ((ve - 1) & 0x0f) | 0x80);
47218 +       write_cr(0x12, (vd - 1) & 0xff);
47219 +       write_cr(0x31, ((vd - 1) & 0xf00) >> 8);
47220 +       write_cr(0x13, wd & 0xff);
47221 +       write_cr(0x41, (wd & 0xf00) >> 8);
47222 +       write_cr(0x15, (vs - 1) & 0xff);
47223 +       write_cr(0x33, ((vs - 1) >> 8) & 0xf);
47224 +       write_cr(0x38, ((ht - 5) & 0x100) >> 8);
47225 +       write_cr(0x16, (vt - 1) & 0xff);
47226 +       write_cr(0x18, 0x00);
47227 +
47228 +       if (p->var.xres == 640) {
47229 +         writeb(0xc7, mmio_base + 0x784);      /* set misc output reg */
47230 +       } else {
47231 +         writeb(0x07, mmio_base + 0x784);      /* set misc output reg */
47232 +       }
47233 +}
47234 +
47235 +static int asiliantfb_check_var(struct fb_var_screeninfo *var,
47236 +                            struct fb_info *p)
47237 +{
47238 +       unsigned long Ftarget, ratio, remainder;
47239 +
47240 +       ratio = 1000000 / var->pixclock;
47241 +       remainder = 1000000 % var->pixclock;
47242 +       Ftarget = 1000000 * ratio + (1000000 * remainder) / var->pixclock;
47243 +
47244 +       /* First check the constraint that the maximum post-VCO divisor is 32,
47245 +        * and the maximum Fvco is 220MHz */
47246 +       if (Ftarget > 220000000 || Ftarget < 3125000) {
47247 +               printk(KERN_ERR "asiliantfb dotclock must be between 3.125 and 220MHz\n");
47248 +               return -ENXIO;
47249 +       }
47250 +       var->xres_virtual = var->xres;
47251 +       var->yres_virtual = var->yres;
47252 +
47253 +       if (var->bits_per_pixel == 24) {
47254 +               var->red.offset = 16;
47255 +               var->green.offset = 8;
47256 +               var->blue.offset = 0;
47257 +               var->red.length = var->blue.length = var->green.length = 8;
47258 +       } else if (var->bits_per_pixel == 16) {
47259 +               switch (var->red.offset) {
47260 +                       case 11:
47261 +                               var->green.length = 6;
47262 +                               break;
47263 +                       case 10:
47264 +                               var->green.length = 5;
47265 +                               break;
47266 +                       default:
47267 +                               return -EINVAL;
47268 +               }
47269 +               var->green.offset = 5;
47270 +               var->blue.offset = 0;
47271 +               var->red.length = var->blue.length = 5;
47272 +       } else if (var->bits_per_pixel == 8) {
47273 +               var->red.offset = var->green.offset = var->blue.offset = 0;
47274 +               var->red.length = var->green.length = var->blue.length = 8;
47275 +       }
47276 +       return 0;
47277 +}
47278 +
47279 +static int asiliantfb_set_par(struct fb_info *p)
47280 +{
47281 +       u8 dclk2_m;             /* Holds m-2 value for register */
47282 +       u8 dclk2_n;             /* Holds n-2 value for register */
47283 +       u8 dclk2_div;           /* Holds divisor bitmask */
47284 +
47285 +       /* Set pixclock */
47286 +       asiliant_calc_dclk2(&p->var.pixclock, &dclk2_m, &dclk2_n, &dclk2_div);
47287 +
47288 +       /* Set color depth */
47289 +       if (p->var.bits_per_pixel == 24) {
47290 +               write_xr(0x81, 0x16);   /* 24 bit packed color mode */
47291 +               write_xr(0x82, 0x00);   /* Disable palettes */
47292 +               write_xr(0x20, 0x20);   /* 24 bit blitter mode */
47293 +       } else if (p->var.bits_per_pixel == 16) {
47294 +               if (p->var.red.offset == 11)
47295 +                       write_xr(0x81, 0x15);   /* 16 bit color mode */
47296 +               else
47297 +                       write_xr(0x81, 0x14);   /* 15 bit color mode */
47298 +               write_xr(0x82, 0x00);   /* Disable palettes */
47299 +               write_xr(0x20, 0x10);   /* 16 bit blitter mode */
47300 +       } else if (p->var.bits_per_pixel == 8) {
47301 +               write_xr(0x0a, 0x02);   /* Linear */
47302 +               write_xr(0x81, 0x12);   /* 8 bit color mode */
47303 +               write_xr(0x82, 0x00);   /* Graphics gamma enable */
47304 +               write_xr(0x20, 0x00);   /* 8 bit blitter mode */
47305 +       }
47306 +       p->fix.line_length = p->var.xres * (p->var.bits_per_pixel >> 3);
47307 +       p->fix.visual = (p->var.bits_per_pixel == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
47308 +       write_xr(0xc4, dclk2_m);
47309 +       write_xr(0xc5, dclk2_n);
47310 +       write_xr(0xc7, dclk2_div);
47311 +       /* Set up the CR registers */
47312 +       asiliant_set_timing(p);
47313 +       return 0;
47314 +}
47315 +
47316 +static int asiliantfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
47317 +                            u_int transp, struct fb_info *p)
47318 +{
47319 +       if (regno > 255)
47320 +               return 1;
47321 +       red >>= 8;
47322 +       green >>= 8;
47323 +       blue >>= 8;
47324 +
47325 +        /* Set hardware palete */
47326 +       writeb(regno, mmio_base + 0x790);
47327 +       udelay(1);
47328 +       writeb(red, mmio_base + 0x791);
47329 +       writeb(green, mmio_base + 0x791);
47330 +       writeb(blue, mmio_base + 0x791);
47331 +
47332 +       switch(p->var.bits_per_pixel) {
47333 +       case 15:
47334 +               if (regno < 16) {
47335 +                       ((u32 *)(p->pseudo_palette))[regno] =
47336 +                               ((red & 0xf8) << 7) |
47337 +                               ((green & 0xf8) << 2) |
47338 +                               ((blue & 0xf8) >> 3);
47339 +               }
47340 +               break;
47341 +       case 16:
47342 +               if (regno < 16) {
47343 +                       ((u32 *)(p->pseudo_palette))[regno] =
47344 +                               ((red & 0xf8) << 8) |
47345 +                               ((green & 0xfc) << 3) |
47346 +                               ((blue & 0xf8) >> 3);
47347 +               }
47348 +               break;
47349 +       case 24:
47350 +               if (regno < 24) {
47351 +                       ((u32 *)(p->pseudo_palette))[regno] =
47352 +                               (red << 16)  |
47353 +                               (green << 8) |
47354 +                               (blue);
47355 +               }
47356 +               break;
47357 +       }
47358 +       return 0;
47359 +}
47360 +
47361 +struct chips_init_reg {
47362 +       unsigned char addr;
47363 +       unsigned char data;
47364 +};
47365 +
47366 +#define N_ELTS(x)      (sizeof(x) / sizeof(x[0]))
47367 +
47368 +static struct chips_init_reg chips_init_sr[] =
47369 +{
47370 +       {0x00, 0x03},           /* Reset register */
47371 +       {0x01, 0x01},           /* Clocking mode */
47372 +       {0x02, 0x0f},           /* Plane mask */
47373 +       {0x04, 0x0e}            /* Memory mode */
47374 +};
47375 +
47376 +static struct chips_init_reg chips_init_gr[] =
47377 +{
47378 +        {0x03, 0x00},          /* Data rotate */
47379 +       {0x05, 0x00},           /* Graphics mode */
47380 +       {0x06, 0x01},           /* Miscellaneous */
47381 +       {0x08, 0x00}            /* Bit mask */
47382 +};
47383 +
47384 +static struct chips_init_reg chips_init_ar[] =
47385 +{
47386 +       {0x10, 0x01},           /* Mode control */
47387 +       {0x11, 0x00},           /* Overscan */
47388 +       {0x12, 0x0f},           /* Memory plane enable */
47389 +       {0x13, 0x00}            /* Horizontal pixel panning */
47390 +};
47391 +
47392 +static struct chips_init_reg chips_init_cr[] =
47393 +{
47394 +       {0x0c, 0x00},           /* Start address high */
47395 +       {0x0d, 0x00},           /* Start address low */
47396 +       {0x40, 0x00},           /* Extended Start Address */
47397 +       {0x41, 0x00},           /* Extended Start Address */
47398 +       {0x14, 0x00},           /* Underline location */
47399 +       {0x17, 0xe3},           /* CRT mode control */
47400 +       {0x70, 0x00}            /* Interlace control */
47401 +};
47402 +
47403 +
47404 +static struct chips_init_reg chips_init_fr[] =
47405 +{
47406 +       {0x01, 0x02},
47407 +       {0x03, 0x08},
47408 +       {0x08, 0xcc},
47409 +       {0x0a, 0x08},
47410 +       {0x18, 0x00},
47411 +       {0x1e, 0x80},
47412 +       {0x40, 0x83},
47413 +       {0x41, 0x00},
47414 +       {0x48, 0x13},
47415 +       {0x4d, 0x60},
47416 +       {0x4e, 0x0f},
47417 +
47418 +       {0x0b, 0x01},
47419 +
47420 +       {0x21, 0x51},
47421 +       {0x22, 0x1d},
47422 +       {0x23, 0x5f},
47423 +       {0x20, 0x4f},
47424 +       {0x34, 0x00},
47425 +       {0x24, 0x51},
47426 +       {0x25, 0x00},
47427 +       {0x27, 0x0b},
47428 +       {0x26, 0x00},
47429 +       {0x37, 0x80},
47430 +       {0x33, 0x0b},
47431 +       {0x35, 0x11},
47432 +       {0x36, 0x02},
47433 +       {0x31, 0xea},
47434 +       {0x32, 0x0c},
47435 +       {0x30, 0xdf},
47436 +       {0x10, 0x0c},
47437 +       {0x11, 0xe0},
47438 +       {0x12, 0x50},
47439 +       {0x13, 0x00},
47440 +       {0x16, 0x03},
47441 +       {0x17, 0xbd},
47442 +       {0x1a, 0x00},
47443 +};
47444 +
47445 +
47446 +static struct chips_init_reg chips_init_xr[] =
47447 +{
47448 +       {0xce, 0x00},           /* set default memory clock */
47449 +       {0xcc, 200 },           /* MCLK ratio M */
47450 +       {0xcd, 18  },           /* MCLK ratio N */
47451 +       {0xce, 0x90},           /* MCLK divisor = 2 */
47452 +
47453 +       {0xc4, 209 },
47454 +       {0xc5, 118 },
47455 +       {0xc7, 32  },
47456 +       {0xcf, 0x06},
47457 +       {0x09, 0x01},           /* IO Control - CRT controller extensions */
47458 +       {0x0a, 0x02},           /* Frame buffer mapping */
47459 +       {0x0b, 0x01},           /* PCI burst write */
47460 +       {0x40, 0x03},           /* Memory access control */
47461 +       {0x80, 0x82},           /* Pixel pipeline configuration 0 */
47462 +       {0x81, 0x12},           /* Pixel pipeline configuration 1 */
47463 +       {0x82, 0x08},           /* Pixel pipeline configuration 2 */
47464 +
47465 +       {0xd0, 0x0f},
47466 +       {0xd1, 0x01},
47467 +};
47468 +
47469 +static void __init chips_hw_init(struct fb_info *p)
47470 +{
47471 +       int i;
47472 +
47473 +       for (i = 0; i < N_ELTS(chips_init_xr); ++i)
47474 +               write_xr(chips_init_xr[i].addr, chips_init_xr[i].data);
47475 +       write_xr(0x81, 0x12);
47476 +       write_xr(0x82, 0x08);
47477 +       write_xr(0x20, 0x00);
47478 +       for (i = 0; i < N_ELTS(chips_init_sr); ++i)
47479 +               write_sr(chips_init_sr[i].addr, chips_init_sr[i].data);
47480 +       for (i = 0; i < N_ELTS(chips_init_gr); ++i)
47481 +               write_gr(chips_init_gr[i].addr, chips_init_gr[i].data);
47482 +       for (i = 0; i < N_ELTS(chips_init_ar); ++i)
47483 +               write_ar(chips_init_ar[i].addr, chips_init_ar[i].data);
47484 +       /* Enable video output in attribute index register */
47485 +       writeb(0x20, mmio_base + 0x780);
47486 +       for (i = 0; i < N_ELTS(chips_init_cr); ++i)
47487 +               write_cr(chips_init_cr[i].addr, chips_init_cr[i].data);
47488 +       for (i = 0; i < N_ELTS(chips_init_fr); ++i)
47489 +               write_fr(chips_init_fr[i].addr, chips_init_fr[i].data);
47490 +}
47491 +
47492 +static struct fb_fix_screeninfo asiliantfb_fix __initdata = {
47493 +       .id =           "Asiliant 69000",
47494 +       .type =         FB_TYPE_PACKED_PIXELS,
47495 +       .visual =       FB_VISUAL_PSEUDOCOLOR,
47496 +       .accel =        FB_ACCEL_NONE,
47497 +       .line_length =  640,
47498 +       .smem_len =     0x200000,       /* 2MB */
47499 +};
47500 +
47501 +static struct fb_var_screeninfo asiliantfb_var __initdata = {
47502 +       .xres           = 640,
47503 +       .yres           = 480,
47504 +       .xres_virtual   = 640,
47505 +       .yres_virtual   = 480,
47506 +       .bits_per_pixel = 8,
47507 +       .red            = { .length = 8 },
47508 +       .green          = { .length = 8 },
47509 +       .blue           = { .length = 8 },
47510 +       .height         = -1,
47511 +       .width          = -1,
47512 +       .vmode          = FB_VMODE_NONINTERLACED,
47513 +       .pixclock       = 39722,
47514 +       .left_margin    = 48,
47515 +       .right_margin   = 16,
47516 +       .upper_margin   = 33,
47517 +       .lower_margin   = 10,
47518 +       .hsync_len      = 96,
47519 +       .vsync_len      = 2,
47520 +};
47521 +
47522 +static void __init init_asiliant(struct fb_info *p, unsigned long addr)
47523 +{
47524 +       p->fix                  = asiliantfb_fix;
47525 +       p->fix.smem_start       = addr;
47526 +       p->var                  = asiliantfb_var;
47527 +       p->fbops                = &asiliantfb_ops;
47528 +       p->pseudo_palette       = pseudo_palette;
47529 +       p->flags                = FBINFO_FLAG_DEFAULT;
47530 +
47531 +       fb_alloc_cmap(&p->cmap, 256, 0);
47532 +
47533 +       if (register_framebuffer(p) < 0) {
47534 +               printk(KERN_ERR "C&T 69000 framebuffer failed to register\n");
47535 +               return;
47536 +       }
47537 +
47538 +       printk(KERN_INFO "fb%d: Asiliant 69000 frame buffer (%dK RAM detected)\n",
47539 +               p->node, p->fix.smem_len / 1024);
47540 +
47541 +       writeb(0xff, mmio_base + 0x78c);
47542 +       chips_hw_init(p);
47543 +}
47544 +
47545 +static int __devinit
47546 +asiliantfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent)
47547 +{
47548 +       struct fb_info *p = &asiliantfb_info;
47549 +       unsigned long addr, size;
47550 +
47551 +       if ((dp->resource[0].flags & IORESOURCE_MEM) == 0)
47552 +               return -ENODEV;
47553 +       addr = pci_resource_start(dp, 0);
47554 +       size = pci_resource_len(dp, 0);
47555 +       if (addr == 0)
47556 +               return -ENODEV;
47557 +       if (p->screen_base != 0)
47558 +               return -EBUSY;
47559 +       if (!request_mem_region(addr, size, "asiliantfb"))
47560 +               return -EBUSY;
47561 +
47562 +       p->screen_base = ioremap(addr, 0x800000);
47563 +       if (p->screen_base == NULL) {
47564 +               release_mem_region(addr, size);
47565 +               return -ENOMEM;
47566 +       }
47567 +
47568 +       pci_write_config_dword(dp, 4, 0x02800083);
47569 +       writeb(3, addr + 0x400784);
47570 +
47571 +       init_asiliant(p, addr);
47572 +
47573 +       /* Clear the entire framebuffer */
47574 +       memset(p->screen_base, 0, 0x200000);
47575 +
47576 +       pci_set_drvdata(dp, p);
47577 +       return 0;
47578 +}
47579 +
47580 +static void __devexit asiliantfb_remove(struct pci_dev *dp)
47581 +{
47582 +       struct fb_info *p = pci_get_drvdata(dp);
47583 +
47584 +       if (p != &asiliantfb_info || p->screen_base == NULL)
47585 +               return;
47586 +       unregister_framebuffer(p);
47587 +       iounmap(p->screen_base);
47588 +       p->screen_base = NULL;
47589 +       release_mem_region(pci_resource_start(dp, 0), pci_resource_len(dp, 0));
47590 +}
47591 +
47592 +static struct pci_device_id asiliantfb_pci_tbl[] __devinitdata = {
47593 +       { PCI_VENDOR_ID_CT, PCI_DEVICE_ID_CT_69000, PCI_ANY_ID, PCI_ANY_ID },
47594 +       { 0 }
47595 +};
47596 +
47597 +MODULE_DEVICE_TABLE(pci, asiliantfb_pci_tbl);
47598 +
47599 +static struct pci_driver asiliantfb_driver = {
47600 +       .name =         "asiliantfb",
47601 +       .id_table =     asiliantfb_pci_tbl,
47602 +       .probe =        asiliantfb_pci_init,
47603 +       .remove =       __devexit_p(asiliantfb_remove),
47604 +};
47605 +
47606 +int __init asiliantfb_init(void)
47607 +{
47608 +       return pci_module_init(&asiliantfb_driver);
47609 +}
47610 +
47611 +static void __exit asiliantfb_exit(void)
47612 +{
47613 +       pci_unregister_driver(&asiliantfb_driver);
47614 +}
47615 +
47616 +MODULE_LICENSE("GPL");
47617 --- linux-2.6.0-test6/drivers/video/aty/aty128fb.c      2003-08-08 22:55:13.000000000 -0700
47618 +++ 25/drivers/video/aty/aty128fb.c     2003-10-05 00:34:46.000000000 -0700
47619 @@ -2041,9 +2041,9 @@ aty128fb_setcolreg(u_int regno, u_int re
47620  #define ATY_MIRROR_CRT_ON      0x00000002
47621  
47622  /* out param: u32*     backlight value: 0 to 15 */
47623 -#define FBIO_ATY128_GET_MIRROR _IOR('@', 1, sizeof(__u32*))
47624 +#define FBIO_ATY128_GET_MIRROR _IOR('@', 1, __u32*)
47625  /* in param: u32*      backlight value: 0 to 15 */
47626 -#define FBIO_ATY128_SET_MIRROR _IOW('@', 2, sizeof(__u32*))
47627 +#define FBIO_ATY128_SET_MIRROR _IOW('@', 2, __u32*)
47628  
47629  static int aty128fb_ioctl(struct inode *inode, struct file *file, u_int cmd,
47630                           u_long arg, struct fb_info *info)
47631 --- linux-2.6.0-test6/drivers/video/aty/Makefile        2003-06-14 12:18:06.000000000 -0700
47632 +++ 25/drivers/video/aty/Makefile       2003-10-05 00:34:22.000000000 -0700
47633 @@ -4,4 +4,3 @@ obj-$(CONFIG_FB_ATY128) += aty128fb.o
47634  atyfb-y                                := atyfb_base.o mach64_accel.o
47635  atyfb-$(CONFIG_FB_ATY_GX)      += mach64_gx.o
47636  atyfb-$(CONFIG_FB_ATY_CT)      += mach64_ct.o mach64_cursor.o
47637 -atyfb-objs                     := $(atyfb-y)
47638 --- linux-2.6.0-test6/drivers/video/chipsfb.c   2003-08-08 22:55:13.000000000 -0700
47639 +++ 25/drivers/video/chipsfb.c  2003-10-05 00:34:22.000000000 -0700
47640 @@ -85,7 +85,7 @@ static struct pmu_sleep_notifier chips_s
47641  /*
47642   * Exported functions
47643   */
47644 -int chips_init(void);
47645 +int chipsfb_init(void);
47646  
47647  static int chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *);
47648  static int chipsfb_check_var(struct fb_var_screeninfo *var,
47649 @@ -460,7 +460,7 @@ static struct pci_driver chipsfb_driver 
47650         .remove =       __devexit_p(chipsfb_remove),
47651  };
47652  
47653 -int __init chips_init(void)
47654 +int __init chipsfb_init(void)
47655  {
47656         return pci_module_init(&chipsfb_driver);
47657  }
47658 --- linux-2.6.0-test6/drivers/video/console/fbcon.c     2003-06-14 12:18:25.000000000 -0700
47659 +++ 25/drivers/video/console/fbcon.c    2003-10-05 00:34:22.000000000 -0700
47660 @@ -195,8 +195,7 @@ static void fb_flashcursor(void *private
47661  {
47662         struct fb_info *info = (struct fb_info *) private;
47663  
47664 -       /* Test to see if the cursor is erased but still on */
47665 -       if (!info || (info->cursor.rop == ROP_COPY))
47666 +       if (!info)
47667                 return;
47668         info->cursor.enable ^= 1;
47669         info->fbops->fb_cursor(info, &info->cursor);
47670 @@ -226,8 +225,7 @@ static void cursor_timer_handler(unsigne
47671         struct fb_info *info = (struct fb_info *) dev_addr;
47672         
47673         schedule_work(&info->queue);    
47674 -       cursor_timer.expires = jiffies + HZ / 5;
47675 -       add_timer(&cursor_timer);
47676 +       mod_timer(&cursor_timer, jiffies + HZ/5);
47677  }
47678  
47679  int __init fb_console_setup(char *this_opt)
47680 @@ -308,97 +306,6 @@ int set_con2fb_map(int unit, int newidx)
47681  }
47682  
47683  /*
47684 - * drawing helpers
47685 - */
47686 -static void putcs_unaligned(struct vc_data *vc, struct fb_info *info,
47687 -                           struct fb_image *image, int count,
47688 -                           const unsigned short *s)
47689 -{
47690 -       unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
47691 -       unsigned int width = (vc->vc_font.width + 7) >> 3;
47692 -       unsigned int cellsize = vc->vc_font.height * width;
47693 -       unsigned int maxcnt = info->pixmap.size/cellsize;
47694 -       unsigned int shift_low = 0, mod = vc->vc_font.width % 8;
47695 -       unsigned int shift_high = 8, size, pitch, cnt, k;
47696 -       unsigned int buf_align = info->pixmap.buf_align - 1;
47697 -       unsigned int scan_align = info->pixmap.scan_align - 1;
47698 -       unsigned int idx = vc->vc_font.width >> 3;
47699 -       u8 mask, *src, *dst, *dst0;
47700 -
47701 -       while (count) {
47702 -               if (count > maxcnt)
47703 -                       cnt = k = maxcnt;
47704 -               else
47705 -                       cnt = k = count;
47706 -
47707 -               image->width = vc->vc_font.width * cnt;
47708 -               pitch = ((image->width + 7) >> 3) + scan_align;
47709 -               pitch &= ~scan_align;
47710 -               size = pitch * vc->vc_font.height + buf_align;
47711 -               size &= ~buf_align;
47712 -               dst0 = info->pixmap.addr + fb_get_buffer_offset(info, size);
47713 -               image->data = dst0;
47714 -               while (k--) {
47715 -                       src = vc->vc_font.data + (scr_readw(s++) & charmask)*
47716 -                       cellsize;
47717 -                       dst = dst0;
47718 -                       mask = (u8) (0xfff << shift_high);
47719 -                       move_buf_unaligned(info, dst, src, pitch, image->height,
47720 -                                       mask, shift_high, shift_low, mod, idx);
47721 -                       shift_low += mod;
47722 -                       dst0 += (shift_low >= 8) ? width : width - 1;
47723 -                       shift_low &= 7;
47724 -                       shift_high = 8 - shift_low;
47725 -               }
47726 -               info->fbops->fb_imageblit(info, image);
47727 -               image->dx += cnt * vc->vc_font.width;
47728 -               count -= cnt;
47729 -               atomic_dec(&info->pixmap.count);
47730 -               smp_mb__after_atomic_dec();
47731 -       }
47732 -}
47733 -
47734 -static void putcs_aligned(struct vc_data *vc, struct fb_info *info,
47735 -                         struct fb_image *image, int count,
47736 -                         const unsigned short *s)
47737 -{
47738 -       unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
47739 -       unsigned int width = vc->vc_font.width >> 3;
47740 -       unsigned int cellsize = vc->vc_font.height * width;
47741 -       unsigned int maxcnt = info->pixmap.size/cellsize;
47742 -       unsigned int scan_align = info->pixmap.scan_align - 1;
47743 -       unsigned int buf_align = info->pixmap.buf_align - 1;
47744 -       unsigned int pitch, cnt, size, k;
47745 -       u8 *src, *dst, *dst0;
47746 -
47747 -       while (count) {
47748 -               if (count > maxcnt)
47749 -                       cnt = k = maxcnt;
47750 -               else
47751 -                       cnt = k = count;
47752 -               
47753 -               pitch = width * cnt + scan_align;
47754 -               pitch &= ~scan_align;
47755 -               size = pitch * vc->vc_font.height + buf_align;
47756 -               size &= ~buf_align;
47757 -               image->width = vc->vc_font.width * cnt;
47758 -               dst0 = info->pixmap.addr + fb_get_buffer_offset(info, size);
47759 -               image->data = dst0;
47760 -               while (k--) {
47761 -                       src = vc->vc_font.data + (scr_readw(s++)&charmask)*cellsize;
47762 -                       dst = dst0;
47763 -                       move_buf_aligned(info, dst, src, pitch, width, image->height);
47764 -                       dst0 += width;
47765 -               }
47766 -               info->fbops->fb_imageblit(info, image);
47767 -               image->dx += cnt * vc->vc_font.width;
47768 -               count -= cnt;
47769 -               atomic_dec(&info->pixmap.count);
47770 -               smp_mb__after_atomic_dec();
47771 -       }
47772 -}
47773 -
47774 -/*
47775   * Accelerated handlers.
47776   */
47777  void accel_bmove(struct vc_data *vc, struct fb_info *info, int sy, 
47778 @@ -432,48 +339,21 @@ void accel_clear(struct vc_data *vc, str
47779         info->fbops->fb_fillrect(info, &region);
47780  }      
47781  
47782 -static void accel_putc(struct vc_data *vc, struct fb_info *info,
47783 -                      int c, int ypos, int xpos)
47784 +void accel_putcs(struct vc_data *vc, struct fb_info *info,
47785 +                       const unsigned short *s, int count, int yy, int xx)
47786  {
47787         unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
47788         unsigned int width = (vc->vc_font.width + 7) >> 3;
47789 +       unsigned int cellsize = vc->vc_font.height * width;
47790 +       unsigned int maxcnt = info->pixmap.size/cellsize;
47791         unsigned int scan_align = info->pixmap.scan_align - 1;
47792         unsigned int buf_align = info->pixmap.buf_align - 1;
47793 +       unsigned int shift_low = 0, mod = vc->vc_font.width % 8;
47794 +       unsigned int shift_high = 8, pitch, cnt, size, k;
47795         int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
47796         int fgshift = (vc->vc_hi_font_mask) ? 9 : 8;
47797 -       unsigned int size, pitch;
47798 -       struct fb_image image;
47799 -       u8 *src, *dst;
47800 -
47801 -       image.dx = xpos * vc->vc_font.width;
47802 -       image.dy = ypos * vc->vc_font.height;
47803 -       image.width = vc->vc_font.width;
47804 -       image.height = vc->vc_font.height;
47805 -       image.fg_color = attr_fgcol(fgshift, c);
47806 -       image.bg_color = attr_bgcol(bgshift, c);
47807 -       image.depth = 1;
47808 -
47809 -       pitch = width + scan_align;
47810 -       pitch &= ~scan_align;
47811 -       size = pitch * vc->vc_font.height;
47812 -       size += buf_align;
47813 -       size &= ~buf_align;
47814 -       dst = info->pixmap.addr + fb_get_buffer_offset(info, size);
47815 -       image.data = dst;
47816 -       src = vc->vc_font.data + (c & charmask) * vc->vc_font.height * width;
47817 -
47818 -       move_buf_aligned(info, dst, src, pitch, width, image.height);
47819 -
47820 -       info->fbops->fb_imageblit(info, &image);
47821 -       atomic_dec(&info->pixmap.count);
47822 -       smp_mb__after_atomic_dec();
47823 -}
47824 -
47825 -void accel_putcs(struct vc_data *vc, struct fb_info *info,
47826 -                       const unsigned short *s, int count, int yy, int xx)
47827 -{
47828 -       int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
47829 -       int fgshift = (vc->vc_hi_font_mask) ? 9 : 8;
47830 +       unsigned int idx = vc->vc_font.width >> 3;
47831 +       u8 *src, *dst, *dst0, mask;
47832         struct fb_image image;
47833         u16 c = scr_readw(s);
47834  
47835 @@ -484,10 +364,44 @@ void accel_putcs(struct vc_data *vc, str
47836         image.height = vc->vc_font.height;
47837         image.depth = 1;
47838  
47839 -       if (!(vc->vc_font.width & 7))
47840 -               putcs_aligned(vc, info, &image, count, s);
47841 -        else
47842 -               putcs_unaligned(vc, info, &image, count, s);
47843 +       while (count) {
47844 +               if (count > maxcnt)
47845 +                       cnt = k = maxcnt;
47846 +               else
47847 +                       cnt = k = count;
47848 +
47849 +               image.width = vc->vc_font.width * cnt;
47850 +               pitch = ((image.width + 7) >> 3) + scan_align;
47851 +               pitch &= ~scan_align;
47852 +               size = pitch * vc->vc_font.height + buf_align;
47853 +               size &= ~buf_align;
47854 +               dst0 = fb_get_buffer_offset(info, &info->pixmap, size);
47855 +               image.data = dst0;
47856 +               while (k--) {
47857 +                       src = vc->vc_font.data + (scr_readw(s++) & charmask)*cellsize;
47858 +                       dst = dst0;
47859 +
47860 +                       if (mod) {
47861 +                               mask = (u8) (0xfff << shift_high);
47862 +                               move_buf_unaligned(info, &info->pixmap, dst, src, pitch,
47863 +                                                  image.height, mask, shift_high,
47864 +                                                  shift_low, mod, idx);
47865 +                               shift_low += mod;
47866 +                               dst0 += (shift_low >= 8) ? width : width - 1;
47867 +                               shift_low &= 7;
47868 +                               shift_high = 8 - shift_low;
47869 +                       } else {
47870 +                               move_buf_aligned(info, &info->pixmap, dst, src, pitch, idx,
47871 +                                                image.height);
47872 +                               dst0 += width;
47873 +                       }
47874 +               }
47875 +               info->fbops->fb_imageblit(info, &image);
47876 +               image.dx += cnt * vc->vc_font.width;
47877 +               count -= cnt;
47878 +               atomic_dec(&info->pixmap.count);
47879 +               smp_mb__after_atomic_dec();
47880 +       }
47881  }
47882  
47883  void accel_clear_margins(struct vc_data *vc, struct fb_info *info,
47884 @@ -676,7 +590,7 @@ static const char *fbcon_startup(void)
47885         if (!info->queue.func) {
47886                 INIT_WORK(&info->queue, fb_flashcursor, info);
47887                 
47888 -               cursor_timer.expires = jiffies + HZ / 50;
47889 +               cursor_timer.expires = jiffies + HZ / 5;
47890                 cursor_timer.data = (unsigned long ) info;
47891                 add_timer(&cursor_timer);
47892         }
47893 @@ -728,15 +642,13 @@ static __inline__ void updatescrollmode(
47894  static void fbcon_set_display(struct vc_data *vc, int init, int logo)
47895  {
47896         struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
47897 +       int nr_rows, nr_cols, old_rows, old_cols, i, charcnt = 256;
47898         struct display *p = &fb_display[vc->vc_num];
47899 -       int nr_rows, nr_cols;
47900 -       int old_rows, old_cols;
47901         unsigned short *save = NULL, *r, *q;
47902 -       int i, charcnt = 256;
47903         struct font_desc *font;
47904  
47905         if (vc->vc_num != fg_console || (info->flags & FBINFO_FLAG_MODULE) ||
47906 -           info->fix.type == FB_TYPE_TEXT)
47907 +           (info->fix.type == FB_TYPE_TEXT))
47908                 logo = 0;
47909  
47910         info->var.xoffset = info->var.yoffset = p->yscroll = 0; /* reset wrap/pan */
47911 @@ -960,11 +872,19 @@ static void fbcon_clear(struct vc_data *
47912                 accel_clear(vc, info, real_y(p, sy), sx, height, width);
47913  }
47914  
47915 -
47916  static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
47917  {
47918         struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
47919 +       unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
47920 +       unsigned int scan_align = info->pixmap.scan_align - 1;
47921 +       unsigned int buf_align = info->pixmap.buf_align - 1;
47922 +       unsigned int width = (vc->vc_font.width + 7) >> 3;
47923 +       int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
47924 +       int fgshift = (vc->vc_hi_font_mask) ? 9 : 8;
47925         struct display *p = &fb_display[vc->vc_num];
47926 +       unsigned int size, pitch;
47927 +       struct fb_image image;
47928 +       u8 *src, *dst;
47929  
47930         if (!info->fbops->fb_blank && console_blanked)
47931                 return;
47932 @@ -972,7 +892,31 @@ static void fbcon_putc(struct vc_data *v
47933         if (vt_cons[vc->vc_num]->vc_mode != KD_TEXT)
47934                 return;
47935  
47936 -       accel_putc(vc, info, c, real_y(p, ypos), xpos);
47937 +       image.dx = xpos * vc->vc_font.width;
47938 +       image.dy = real_y(p, ypos) * vc->vc_font.height;
47939 +       image.width = vc->vc_font.width;
47940 +       image.height = vc->vc_font.height;
47941 +       image.fg_color = attr_fgcol(fgshift, c);
47942 +       image.bg_color = attr_bgcol(bgshift, c);
47943 +       image.depth = 1;
47944 +
47945 +       src = vc->vc_font.data + (c & charmask) * vc->vc_font.height * width;
47946 +
47947 +       pitch = width + scan_align;
47948 +       pitch &= ~scan_align;
47949 +       size = pitch * vc->vc_font.height;
47950 +       size += buf_align;
47951 +       size &= ~buf_align;
47952 +
47953 +       dst = fb_get_buffer_offset(info, &info->pixmap, size);
47954 +       image.data = dst;
47955 +
47956 +       move_buf_aligned(info, &info->pixmap, dst, src, pitch, width,
47957 +                       image.height);
47958 +
47959 +       info->fbops->fb_imageblit(info, &image);
47960 +       atomic_dec(&info->pixmap.count);
47961 +       smp_mb__after_atomic_dec();
47962  }
47963  
47964  static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
47965 @@ -994,12 +938,16 @@ static void fbcon_cursor(struct vc_data 
47966  {
47967         struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
47968         unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
47969 +       unsigned int scan_align = info->sprite.scan_align - 1;
47970 +       unsigned int buf_align = info->sprite.buf_align - 1;
47971         int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
47972         int fgshift = (vc->vc_hi_font_mask) ? 9 : 8;
47973         struct display *p = &fb_display[vc->vc_num];
47974 -       int w = (vc->vc_font.width + 7) >> 3, c;
47975 -       int y = real_y(p, vc->vc_y);
47976 +       int y = real_y(p, vc->vc_y), d_pitch, dsize;
47977 +       int s_pitch = (vc->vc_font.width + 7) >> 3;
47978 +       int size = s_pitch * vc->vc_font.height, c;
47979         struct fb_cursor cursor;
47980 +       u8 *src, *dst;
47981         
47982         if (mode & CM_SOFTBACK) {
47983                 mode &= ~CM_SOFTBACK;
47984 @@ -1012,28 +960,24 @@ static void fbcon_cursor(struct vc_data 
47985         } else if (softback_lines)
47986                 fbcon_set_origin(vc);
47987  
47988 -       c = scr_readw((u16 *) vc->vc_pos);
47989 +       del_timer(&cursor_timer);
47990 +       if (info->cursor.enable) {
47991 +               info->cursor.enable = 0;
47992 +               info->fbops->fb_cursor(info, &info->cursor);
47993 +       }
47994  
47995 -       cursor.image.data = vc->vc_font.data + ((c & charmask) * (w * vc->vc_font.height));
47996 -       cursor.set = FB_CUR_SETCUR;
47997 -       cursor.image.depth = 1;
47998 -       
47999 -       switch (mode) {
48000 -       case CM_ERASE:
48001 -               if (info->cursor.rop == ROP_XOR) {
48002 -                       info->cursor.enable = 0;
48003 -                       info->cursor.rop = ROP_COPY;
48004 -                       info->fbops->fb_cursor(info, &cursor);
48005 -               }       
48006 -               break;
48007 -       case CM_MOVE:
48008 -       case CM_DRAW:
48009 +       if (mode != CM_ERASE) {
48010 +               memset(&cursor, 0, sizeof(struct fb_cursor));
48011                 info->cursor.enable = 1;
48012 -               
48013 +
48014 +               c = scr_readw((u16 *) vc->vc_pos);
48015 +
48016 +               src = vc->vc_font.data + ((c & charmask) * size);
48017                 if (info->cursor.image.fg_color != attr_fgcol(fgshift, c) ||
48018                     info->cursor.image.bg_color != attr_bgcol(bgshift, c)) {
48019                         cursor.image.fg_color = attr_fgcol(fgshift, c);
48020                         cursor.image.bg_color = attr_bgcol(bgshift, c);
48021 +                       cursor.image.depth = 1;
48022                         cursor.set |= FB_CUR_SETCMAP;
48023                 }
48024                 
48025 @@ -1056,18 +1000,29 @@ static void fbcon_cursor(struct vc_data 
48026                         cursor.set |= FB_CUR_SETHOT;
48027                 }
48028  
48029 +               src = vc->vc_font.data + ((c & charmask) * size);
48030 +
48031 +               d_pitch = (s_pitch + scan_align) & ~scan_align;
48032 +               dsize = d_pitch * vc->vc_font.height + buf_align;
48033 +               dsize &= ~buf_align;
48034 +               dst = fb_get_buffer_offset(info, &info->sprite, dsize);
48035 +               move_buf_aligned(info, &info->sprite, dst, src, d_pitch, s_pitch, vc->vc_font.height);
48036 +               info->cursor.image.data = dst;
48037 +               cursor.set |= FB_CUR_SETSHAPE;
48038 +
48039                 if ((cursor.set & FB_CUR_SETSIZE) || ((vc->vc_cursor_type & 0x0f) != p->cursor_shape)) {
48040 -                       char *mask = kmalloc(w*vc->vc_font.height, GFP_ATOMIC);
48041 -                       int cur_height, size, i = 0;
48042 +                       char *mask = kmalloc(dsize, GFP_ATOMIC);
48043 +                       int cur_height, i, j, k;
48044  
48045                         if (!mask)      return; 
48046 -               
48047 +
48048 +                       memset(mask, 0, dsize);
48049 +
48050                         if (info->cursor.mask)
48051                                 kfree(info->cursor.mask);
48052                         info->cursor.mask = mask;
48053         
48054                         p->cursor_shape = vc->vc_cursor_type & 0x0f;
48055 -                       cursor.set |= FB_CUR_SETSHAPE;
48056  
48057                         switch (vc->vc_cursor_type & 0x0f) {
48058                         case CUR_NONE:
48059 @@ -1090,17 +1045,19 @@ static void fbcon_cursor(struct vc_data 
48060                                 cur_height = vc->vc_font.height;
48061                                 break;
48062                         }
48063 -                       size = (vc->vc_font.height - cur_height) * w;
48064 -                       while (size--)
48065 -                               mask[i++] = 0;
48066 -                       size = cur_height * w;
48067 -                       while (size--)
48068 -                               mask[i++] = 0xff;
48069 +                       i = (vc->vc_font.height - cur_height) * d_pitch;
48070 +                       for (j = 0; j < cur_height; j++) {
48071 +                               for (k = 0; k < s_pitch; k++)
48072 +                                       mask[i++] = 0xff;
48073 +                               i += (d_pitch - s_pitch);
48074 +                       }
48075                 }
48076                 info->cursor.rop = ROP_XOR;
48077                 info->fbops->fb_cursor(info, &cursor);
48078 +               atomic_dec(&info->sprite.count);
48079 +               smp_mb__after_atomic_dec();
48080 +               mod_timer(&cursor_timer, jiffies + HZ/5);
48081                 vbl_cursor_cnt = CURSOR_DRAW_DELAY;
48082 -               break;
48083         }
48084  }
48085  
48086 @@ -1826,8 +1783,10 @@ static int fbcon_do_set_font(struct vc_d
48087         vc->vc_font.height = h;
48088         if (vc->vc_hi_font_mask && cnt == 256) {
48089                 vc->vc_hi_font_mask = 0;
48090 -               if (vc->vc_can_do_color)
48091 +               if (vc->vc_can_do_color) {
48092                         vc->vc_complement_mask >>= 1;
48093 +                       vc->vc_s_complement_mask >>= 1;
48094 +               }
48095  
48096                 /* ++Edmund: reorder the attribute bits */
48097                 if (vc->vc_can_do_color) {
48098 @@ -1847,8 +1806,10 @@ static int fbcon_do_set_font(struct vc_d
48099                 }
48100         } else if (!vc->vc_hi_font_mask && cnt == 512) {
48101                 vc->vc_hi_font_mask = 0x100;
48102 -               if (vc->vc_can_do_color)
48103 +               if (vc->vc_can_do_color) {
48104                         vc->vc_complement_mask <<= 1;
48105 +                       vc->vc_s_complement_mask <<= 1;
48106 +               }
48107  
48108                 /* ++Edmund: reorder the attribute bits */
48109                 {
48110 --- linux-2.6.0-test6/drivers/video/console/Makefile    2003-06-14 12:18:09.000000000 -0700
48111 +++ 25/drivers/video/console/Makefile   2003-10-05 00:34:22.000000000 -0700
48112 @@ -3,18 +3,16 @@
48113  # Rewritten to use lists instead of if-statements.
48114  
48115  # Font handling
48116 -font-objs := fonts.o
48117 +font-y := fonts.o
48118  
48119 -font-objs-$(CONFIG_FONT_SUN8x16)   += font_sun8x16.o
48120 -font-objs-$(CONFIG_FONT_SUN12x22)  += font_sun12x22.o
48121 -font-objs-$(CONFIG_FONT_8x8)       += font_8x8.o
48122 -font-objs-$(CONFIG_FONT_8x16)      += font_8x16.o
48123 -font-objs-$(CONFIG_FONT_6x11)      += font_6x11.o
48124 -font-objs-$(CONFIG_FONT_PEARL_8x8) += font_pearl_8x8.o
48125 -font-objs-$(CONFIG_FONT_ACORN_8x8) += font_acorn_8x8.o
48126 -font-objs-$(CONFIG_FONT_MINI_4x6)  += font_mini_4x6.o
48127 -
48128 -font-objs += $(font-objs-y)
48129 +font-$(CONFIG_FONT_SUN8x16)   += font_sun8x16.o
48130 +font-$(CONFIG_FONT_SUN12x22)  += font_sun12x22.o
48131 +font-$(CONFIG_FONT_8x8)       += font_8x8.o
48132 +font-$(CONFIG_FONT_8x16)      += font_8x16.o
48133 +font-$(CONFIG_FONT_6x11)      += font_6x11.o
48134 +font-$(CONFIG_FONT_PEARL_8x8) += font_pearl_8x8.o
48135 +font-$(CONFIG_FONT_ACORN_8x8) += font_acorn_8x8.o
48136 +font-$(CONFIG_FONT_MINI_4x6)  += font_mini_4x6.o
48137  
48138  # Each configuration option enables a list of files.
48139  
48140 @@ -31,8 +29,11 @@ obj-$(CONFIG_FB_STI)              += sti
48141  # Files generated that shall be removed upon make clean
48142  clean-files := promcon_tbl.c
48143  
48144 -$(obj)/promcon_tbl.c: $(src)/prom.uni
48145 -       $(objtree)/scripts/conmakehash $< | \
48146 +quiet_cmd_promtbl = GEN        $@
48147 +       cmd_promtbl = scripts/conmakehash $< | \
48148         sed -e '/#include <[^>]*>/p' -e 's/types/init/' \
48149             -e 's/dfont\(_uni.*\]\)/promfont\1 __initdata/' > $@
48150  
48151 +$(obj)/promcon_tbl.c: $(src)/prom.uni
48152 +       $(call cmd,promtbl)
48153 +
48154 --- linux-2.6.0-test6/drivers/video/console/sticore.c   2003-08-08 22:55:13.000000000 -0700
48155 +++ 25/drivers/video/console/sticore.c  2003-10-05 00:33:24.000000000 -0700
48156 @@ -988,7 +988,7 @@ static int __devinit sticore_pci_init(st
48157         
48158         if (!sti) {
48159                 printk(KERN_WARNING "Unable to handle STI device '%s'\n",
48160 -                       pd->dev.name);
48161 +                       pci_name(pd));
48162                 return -ENODEV;
48163         }
48164  #endif /* CONFIG_PCI */
48165 --- linux-2.6.0-test6/drivers/video/controlfb.c 2003-09-08 13:58:58.000000000 -0700
48166 +++ 25/drivers/video/controlfb.c        2003-10-05 00:34:22.000000000 -0700
48167 @@ -136,8 +136,8 @@ static int controlfb_check_var (struct f
48168  /*
48169   * inititialization
48170   */
48171 -int control_init(void);
48172 -void control_setup(char *);
48173 +int controlfb_init(void);
48174 +void controlfb_setup(char *);
48175  
48176  /******************** Prototypes for internal functions **********************/
48177  
48178 @@ -553,7 +553,7 @@ static void control_set_hardware(struct 
48179  /*
48180   * Called from fbmem.c for probing & initializing
48181   */
48182 -int __init control_init(void)
48183 +int __init controlfb_init(void)
48184  {
48185         struct device_node *dp;
48186  
48187 @@ -1057,7 +1057,7 @@ static void control_cleanup(void)
48188  /*
48189   * Parse user speficied options (`video=controlfb:')
48190   */
48191 -void __init control_setup(char *options)
48192 +void __init controlfb_setup(char *options)
48193  {
48194         char *this_opt;
48195  
48196 --- linux-2.6.0-test6/drivers/video/epson1355fb.c       2003-06-14 12:17:57.000000000 -0700
48197 +++ 25/drivers/video/epson1355fb.c      2003-10-05 00:34:22.000000000 -0700
48198 @@ -1,541 +1,714 @@
48199  /*
48200 - * linux/drivers/video/epson1355fb.c
48201 - *     -- Support for the Epson SED1355 LCD/CRT controller
48202 + * linux/drivers/video/epson1355fb.c -- Epson S1D13505 frame buffer for 2.5.
48203   *
48204 - * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
48205 + * Epson Research S1D13505 Embedded RAMDAC LCD/CRT Controller
48206 + *   (previously known as SED1355)
48207   *
48208 - * based on linux/drivers/video/skeletonfb.c, which was
48209 + * Cf. http://www.erd.epson.com/vdc/html/S1D13505.html
48210 + *
48211 + *
48212 + * Copyright (C) Hewlett-Packard Company.  All rights reserved.
48213 + *
48214 + * Written by Christopher Hoover <ch@hpl.hp.com>
48215 + *
48216 + * Adapted from:
48217 + *
48218 + *  linux/drivers/video/skeletonfb.c
48219 + *  Modified to new api Jan 2001 by James Simmons (jsimmons@transvirtual.com)
48220   *  Created 28 Dec 1997 by Geert Uytterhoeven
48221   *
48222 + *  linux/drivers/video/epson1355fb.c (2.4 driver)
48223 + *  Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
48224 + *
48225   * This file is subject to the terms and conditions of the GNU General Public
48226 - * License.  See the file COPYING in the main directory of this archive
48227 - * for more details.
48228 - */
48229 -/* TODO (roughly in order of priority):
48230 - * 16 bpp support
48231 - * crt support
48232 - * hw cursor support
48233 - * SwivelView
48234 + * License. See the file COPYING in the main directory of this archive for
48235 + * more details.
48236 + *
48237 + *
48238 + * Noteworthy Issues
48239 + * -----------------
48240 + *
48241 + * This driver is complicated by the fact that this is a 16-bit chip
48242 + * and, on at least one platform (ceiva), we can only do 16-bit reads
48243 + * and writes to the framebuffer.  We hide this from user space
48244 + * except in the case of mmap().
48245 + *
48246 + *
48247 + * To Do
48248 + * -----
48249 + *
48250 + * - Test 8-bit pseudocolor mode
48251 + * - Allow setting bpp, virtual resolution
48252 + * - Implement horizontal panning
48253 + * - (maybe) Implement hardware cursor
48254   */
48255  
48256 -#include <asm/io.h>
48257 -#include <linux/config.h>
48258 -#include <linux/delay.h>
48259 -#include <linux/errno.h>
48260 -#include <linux/fb.h>
48261 -#include <linux/init.h>
48262 -#include <linux/kernel.h>
48263 -#include <linux/slab.h>
48264 -#include <linux/mm.h>
48265  #include <linux/module.h>
48266 -#include <linux/sched.h>
48267 +#include <linux/kernel.h>
48268 +#include <linux/errno.h>
48269  #include <linux/string.h>
48270 +#include <linux/mm.h>
48271  #include <linux/tty.h>
48272 -#include <video/fbcon-cfb8.h>
48273 -#include <video/fbcon-mfb.h>
48274 -#include <video/fbcon.h>
48275 -
48276 -/* Register defines.  The docs don't seem to provide nice mnemonic names
48277 - * so I made them up myself ... */
48278 -
48279 -#define E1355_PANEL    0x02
48280 -#define E1355_DISPLAY  0x0D
48281 -#define E1355_MISC     0x1B
48282 -#define E1355_GPIO     0x20
48283 -#define E1355_LUT_INDEX 0x24
48284 -#define E1355_LUT_DATA 0x26
48285 +#include <linux/slab.h>
48286 +#include <linux/delay.h>
48287 +#include <linux/fb.h>
48288 +#include <linux/init.h>
48289 +#include <linux/ioport.h>
48290 +#include <asm/types.h>
48291 +#include <asm/io.h>
48292 +#include <asm/uaccess.h>
48293 +
48294 +#include <video/epson1355.h>
48295 +
48296 +static struct fb_info info;
48297 +
48298 +static struct epson1355fb_par {
48299 +       unsigned long reg_addr;
48300 +} par;
48301 +
48302 +static u32 pseudo_palette[16];
48303 +
48304 +/* ------------------------------------------------------------------------- */
48305  
48306  #ifdef CONFIG_SUPERH
48307 -#define E1355_REG_BASE CONFIG_E1355_REG_BASE
48308 -#define E1355_FB_BASE  CONFIG_E1355_FB_BASE
48309  
48310 -static inline u8 e1355_read_reg(int index)
48311 +static inline u8 epson1355_read_reg(int index)
48312  {
48313 -       return ctrl_inb(E1355_REG_BASE + index);
48314 +       return ctrl_inb(par.reg_addr + index);
48315  }
48316  
48317 -static inline void e1355_write_reg(u8 data, int index)
48318 +static inline void epson1355_write_reg(u8 data, int index)
48319  {
48320 -       ctrl_outb(data, E1355_REG_BASE + index);
48321 +       ctrl_outb(data, par.reg_addr + index);
48322  }
48323  
48324 -static inline u16 e1355_read_reg16(int index)
48325 +#elif defined(CONFIG_ARM)
48326 +
48327 +# ifdef CONFIG_ARCH_CEIVA
48328 +#  include <asm/arch/hardware.h>
48329 +#  define EPSON1355FB_BASE_PHYS        (CEIVA_PHYS_SED1355)
48330 +# endif
48331 +
48332 +static inline u8 epson1355_read_reg(int index)
48333  {
48334 -       return e1355_read_reg(index) + (e1355_read_reg(index+1) << 8);
48335 +       return __raw_readb(par.reg_addr + index);
48336  }
48337  
48338 -static inline void e1355_write_reg16(u16 data, int index)
48339 +static inline void epson1355_write_reg(u8 data, int index)
48340  {
48341 -       e1355_write_reg((data&0xff), index);
48342 -       e1355_write_reg(((data>>8)&0xff), index + 1);
48343 +       __raw_writeb(data, par.reg_addr + index);
48344  }
48345 +
48346  #else
48347 -#error unknown architecture
48348 +# error "no architecture-specific epson1355_{read,write}_reg"
48349  #endif
48350  
48351 -struct e1355fb_info {
48352 -       struct fb_info_gen gen;
48353 -};
48354 -
48355 -static int current_par_valid = 0;
48356 -static struct display disp;
48357 +#ifndef EPSON1355FB_BASE_PHYS
48358 +# error  "EPSON1355FB_BASE_PHYS is not defined"
48359 +#endif
48360  
48361 -static struct fb_var_screeninfo default_var;
48362 +#define EPSON1355FB_REGS_OFS   (0)
48363 +#define EPSON1355FB_REGS_PHYS  (EPSON1355FB_BASE_PHYS + EPSON1355FB_REGS_OFS)
48364 +#define EPSON1355FB_REGS_LEN   (64)
48365  
48366 -int e1355fb_init(void);
48367 -int e1355fb_setup(char*);
48368 -static int e1355_encode_var(struct fb_var_screeninfo *var, const void *par,
48369 -                           struct fb_info_gen *info);
48370 -/* ------------------- chipset specific functions -------------------------- */
48371 +#define EPSON1355FB_FB_OFS     (0x00200000)
48372 +#define EPSON1355FB_FB_PHYS    (EPSON1355FB_BASE_PHYS + EPSON1355FB_FB_OFS)
48373 +#define EPSON1355FB_FB_LEN     (2 * 1024 * 1024)
48374  
48375 +/* ------------------------------------------------------------------------- */
48376  
48377 -static void disable_hw_cursor(void)
48378 +static inline u16 epson1355_read_reg16(int index)
48379  {
48380 -       u8 curs;
48381 +       u8 lo = epson1355_read_reg(index);
48382 +       u8 hi = epson1355_read_reg(index + 1);
48383  
48384 -       curs = e1355_read_reg(0x27);
48385 -       curs &= ~0xc0;
48386 -       e1355_write_reg(curs, 0x27);
48387 +       return (hi << 8) | lo;
48388  }
48389  
48390 -static void e1355_detect(void)
48391 +static inline void epson1355_write_reg16(u16 data, int index)
48392  {
48393 -       u8 rev;
48394 +       u8 lo = data & 0xff;
48395 +       u8 hi = (data >> 8) & 0xff;
48396  
48397 -       e1355_write_reg(0x00, E1355_MISC);
48398 +       epson1355_write_reg(lo, index);
48399 +       epson1355_write_reg(hi, index + 1);
48400 +}
48401  
48402 -       rev = e1355_read_reg(0x00);
48403 +static inline u32 epson1355_read_reg20(int index)
48404 +{
48405 +       u8 b0 = epson1355_read_reg(index);
48406 +       u8 b1 = epson1355_read_reg(index + 1);
48407 +       u8 b2 = epson1355_read_reg(index + 2);
48408  
48409 -       if ((rev & 0xfc) != 0x0c) {
48410 -               printk(KERN_WARNING "Epson 1355 not detected\n");
48411 -       }
48412 +       return (b2 & 0x0f) << 16 | (b1 << 8) | b0;
48413 +}
48414  
48415 -       /* XXX */
48416 -       disable_hw_cursor();
48417 +static inline void epson1355_write_reg20(u32 data, int index)
48418 +{
48419 +       u8 b0 = data & 0xff;
48420 +       u8 b1 = (data >> 8) & 0xff;
48421 +       u8 b2 = (data >> 16) & 0x0f;
48422  
48423 -       e1355_encode_var(&default_var, NULL, NULL);
48424 +       epson1355_write_reg(b0, index);
48425 +       epson1355_write_reg(b1, index + 1);
48426 +       epson1355_write_reg(b2, index + 2);
48427  }
48428  
48429 -struct e1355_par {
48430 -       u32 xres;
48431 -       u32 yres;
48432 +/* ------------------------------------------------------------------------- */
48433  
48434 -       int bpp;
48435 -       int mem_bpp;
48436 +static void set_lut(u8 index, u8 r, u8 g, u8 b)
48437 +{
48438 +       epson1355_write_reg(index, REG_LUT_ADDR);
48439 +       epson1355_write_reg(r, REG_LUT_DATA);
48440 +       epson1355_write_reg(g, REG_LUT_DATA);
48441 +       epson1355_write_reg(b, REG_LUT_DATA);
48442 +}
48443  
48444 -       u32 panel_xres;
48445 -       u32 panel_yres;
48446 -       
48447 -       int panel_width;
48448 -       int panel_ymul;
48449 -};
48450  
48451 -static int e1355_encode_fix(struct fb_fix_screeninfo *fix,
48452 -                           const void *raw_par,
48453 -                           struct fb_info_gen *info)
48454 -{
48455 -       const struct e1355_par *par = raw_par;
48456 -       
48457 -       memset(fix, 0, sizeof *fix);
48458 -       
48459 -       fix->type= FB_TYPE_PACKED_PIXELS;
48460 +/**
48461 + *     epson1355fb_setcolreg - sets a color register.
48462 + *      @regno: Which register in the CLUT we are programming
48463 + *      @red: The red value which can be up to 16 bits wide
48464 + *     @green: The green value which can be up to 16 bits wide
48465 + *     @blue:  The blue value which can be up to 16 bits wide.
48466 + *     @transp: If supported the alpha value which can be up to 16 bits wide.
48467 + *      @info: frame buffer info structure
48468 + *
48469 + *     Returns negative errno on error, or zero on success.
48470 + */
48471 +static int epson1355fb_setcolreg(unsigned regno, unsigned r, unsigned g,
48472 +                                unsigned b, unsigned transp,
48473 +                                struct fb_info *info)
48474 +{
48475 +       if (info->var.grayscale)
48476 +               r = g = b = (19595 * r + 38470 * g + 7471 * b) >> 16;
48477 +
48478 +       switch (info->fix.visual) {
48479 +       case FB_VISUAL_TRUECOLOR:
48480 +               if (regno >= 16)
48481 +                       return -EINVAL;
48482  
48483 -       if (!par)
48484 -               BUG();
48485 +               ((u32 *) info->pseudo_palette)[regno] =
48486 +                   (r & 0xf800) | (g & 0xfc00) >> 5 | (b & 0xf800) >> 11;
48487  
48488 -       if (par->bpp == 1) {
48489 -               fix->visual = FB_VISUAL_MONO10;
48490 -       } else if (par->bpp <= 8) {
48491 -               fix->visual = FB_VISUAL_PSEUDOCOLOR;
48492 -       } else {
48493 -               fix->visual = FB_VISUAL_TRUECOLOR;
48494 -       }
48495 +               break;
48496 +       case FB_VISUAL_PSEUDOCOLOR:
48497 +               if (regno >= 256)
48498 +                       return -EINVAL;
48499  
48500 -       return 0;
48501 -}
48502 +               set_lut(regno, r >> 8, g >> 8, b >> 8);
48503  
48504 -static int e1355_set_bpp(struct e1355_par *par, int bpp)
48505 -{
48506 -       int code;
48507 -       u8 disp;
48508 -       u16 bytes_per_line;
48509 -
48510 -       switch(bpp) {
48511 -       case 1:
48512 -               code = 0; break;
48513 -       case 2:
48514 -               code = 1; break;
48515 -       case 4:
48516 -               code = 2; break;
48517 -       case 8:
48518 -               code = 3; break;
48519 -       case 16:
48520 -               code = 5; break;
48521 +               break;
48522         default:
48523 -               return -EINVAL; break;
48524 +               return -ENOSYS;
48525         }
48526 -
48527 -       disp = e1355_read_reg(E1355_DISPLAY);
48528 -       disp &= ~0x1c;
48529 -       disp |= code << 2;
48530 -       e1355_write_reg(disp, E1355_DISPLAY);
48531 -       
48532 -       bytes_per_line = (par->xres * bpp) >> 3;
48533 -       
48534 -       e1355_write_reg16(bytes_per_line, 0x16);
48535 -
48536 -       par->bpp = bpp;
48537 -
48538         return 0;
48539  }
48540 -               
48541 -static int e1355_decode_var(const struct fb_var_screeninfo *var,
48542 -                           void *raw_par,
48543 -                           struct fb_info_gen *info)
48544 +
48545 +/* ------------------------------------------------------------------------- */
48546 +
48547 +/**
48548 + *      epson1355fb_pan_display - Pans the display.
48549 + *      @var: frame buffer variable screen structure
48550 + *      @info: frame buffer structure that represents a single frame buffer
48551 + *
48552 + *     Pan (or wrap, depending on the `vmode' field) the display using the
48553 + *     `xoffset' and `yoffset' fields of the `var' structure.
48554 + *     If the values don't fit, return -EINVAL.
48555 + *
48556 + *      Returns negative errno on error, or zero on success.
48557 + */
48558 +static int epson1355fb_pan_display(struct fb_var_screeninfo *var,
48559 +                                  struct fb_info *info)
48560  {
48561 -       struct e1355_par *par = raw_par;
48562 -       int ret;
48563 +       u32 start;
48564  
48565 -       if (!par)
48566 -               BUG();
48567 +       if (var->xoffset != 0)  /* not yet ... */
48568 +               return -EINVAL;
48569  
48570 -       /*
48571 -        * Don't allow setting any of these yet: xres and yres don't
48572 -        * make sense for LCD panels; xres_virtual and yres_virtual
48573 -        * should be supported fine by our hardware though.
48574 -        */
48575 -       if (var->xres != par->xres ||
48576 -           var->yres != par->yres ||
48577 -           var->xres != var->xres_virtual ||
48578 -           var->yres != var->yres_virtual ||
48579 -           var->xoffset != 0 ||
48580 -           var->yoffset != 0)
48581 +       if (var->yoffset + info->var.yres > info->var.yres_virtual)
48582                 return -EINVAL;
48583  
48584 -       if(var->bits_per_pixel != par->bpp) {
48585 -               ret = e1355_set_bpp(par, var->bits_per_pixel);
48586 +       start = (info->fix.line_length >> 1) * var->yoffset;
48587  
48588 -               if (ret)
48589 -                       goto out_err;
48590 -       }
48591 -               
48592 -       return 0;
48593 +       epson1355_write_reg20(start, REG_SCRN1_DISP_START_ADDR0);
48594  
48595 - out_err:
48596 -       return ret;
48597 +       return 0;
48598  }
48599  
48600 -static void dump_panel_data(void)
48601 +/* ------------------------------------------------------------------------- */
48602 +
48603 +static void lcd_enable(int enable)
48604  {
48605 -       u8 panel = e1355_read_reg(E1355_PANEL);
48606 -       int width[2][4] = { { 4, 8, 16, -1 }, { 9, 12, 16, -1 } };
48607 +       u8 mode = epson1355_read_reg(REG_DISPLAY_MODE);
48608  
48609 -       printk("%s %s %s panel, width %d bits\n",
48610 -              panel & 2 ? "dual" : "single",
48611 -              panel & 4 ? "color" : "mono",
48612 -              panel & 1 ? "TFT" : "passive",
48613 -              width[panel&1][(panel>>4)&3]);
48614 +       if (enable)
48615 +               mode |= 1;
48616 +       else
48617 +               mode &= ~1;
48618  
48619 -       printk("resolution %d x %d\n",
48620 -              (e1355_read_reg(0x04) + 1) * 8,
48621 -              ((e1355_read_reg16(0x08) + 1) * (1 + ((panel & 3) == 2))));
48622 +       epson1355_write_reg(mode, REG_DISPLAY_MODE);
48623  }
48624  
48625 -static int e1355_bpp_to_var(int bpp, struct fb_var_screeninfo *var)
48626 +#if defined(CONFIG_ARCH_CEIVA)
48627 +static void backlight_enable(int enable)
48628  {
48629 -       switch(bpp) {
48630 -       case 1:
48631 -       case 2:
48632 -       case 4:
48633 -       case 8:
48634 -               var->bits_per_pixel = bpp;
48635 -               var->red.offset = var->green.offset = var->blue.offset = 0;
48636 -               var->red.length = var->green.length = var->blue.length = bpp;
48637 +       /* ### this should be protected by a spinlock ... */
48638 +       u8 pddr = clps_readb(PDDR);
48639 +       if (enable)
48640 +               pddr |= (1 << 5);
48641 +       else
48642 +               pddr &= ~(1 << 5);
48643 +       clps_writeb(pddr, PDDR);
48644 +}
48645 +#else
48646 +static void backlight_enable(int enable)
48647 +{
48648 +}
48649 +#endif
48650 +
48651 +
48652 +/**
48653 + *      epson1355fb_blank - blanks the display.
48654 + *      @blank_mode: the blank mode we want.
48655 + *      @info: frame buffer structure that represents a single frame buffer
48656 + *
48657 + *      Blank the screen if blank_mode != 0, else unblank. Return 0 if
48658 + *      blanking succeeded, != 0 if un-/blanking failed due to e.g. a
48659 + *      video mode which doesn't support it. Implements VESA suspend
48660 + *      and powerdown modes on hardware that supports disabling hsync/vsync:
48661 + *      blank_mode == 2: suspend vsync
48662 + *      blank_mode == 3: suspend hsync
48663 + *      blank_mode == 4: powerdown
48664 + *
48665 + *      Returns negative errno on error, or zero on success.
48666 + *
48667 + */
48668 +static int epson1355fb_blank(int blank_mode, struct fb_info *info)
48669 +{
48670 +       switch (blank_mode) {
48671 +       case VESA_NO_BLANKING:
48672 +               lcd_enable(1);
48673 +               backlight_enable(1);
48674                 break;
48675 -       case 16:
48676 -               var->bits_per_pixel = 16;
48677 -               var->red.offset = 11;
48678 -               var->red.length = 5;
48679 -               var->green.offset = 5;
48680 -               var->green.length = 6;
48681 -               var->blue.offset = 0;
48682 -               var->blue.length = 5;
48683 +       case VESA_VSYNC_SUSPEND:
48684 +       case VESA_HSYNC_SUSPEND:
48685 +               backlight_enable(0);
48686                 break;
48687 +       case VESA_POWERDOWN:
48688 +               backlight_enable(0);
48689 +               lcd_enable(0);
48690 +               break;
48691 +       default:
48692 +               return -EINVAL;
48693         }
48694 -
48695         return 0;
48696  }
48697  
48698 -static int e1355_encode_var(struct fb_var_screeninfo *var, const void *raw_par,
48699 -                           struct fb_info_gen *info)
48700 +/* ------------------------------------------------------------------------- */
48701 +
48702 +/*
48703 + * We can't use the cfb generic routines, as we have to limit
48704 + * ourselves to 16-bit or 8-bit loads and stores to this 16-bit
48705 + * chip.
48706 + */
48707 +
48708 +static inline void epson1355fb_fb_writel(unsigned long v, unsigned long *a)
48709  {
48710 -       u8 panel, display;
48711 -       u32 xres, xres_virtual, yres;
48712 -       static int width[2][4] = { { 4, 8, 16, -1 }, { 9, 12, 16, -1 } };
48713 -       static int bpp_tab[8] = { 1, 2, 4, 8, 15, 16 };
48714 -       int bpp, hw_bpp;
48715 -       int is_color, is_dual, is_tft;
48716 -       int lcd_enabled, crt_enabled;
48717 +       u16 *p = (u16 *) a;
48718 +       u16 l = v & 0xffff;
48719 +       u16 h = v >> 16;
48720  
48721 -       panel = e1355_read_reg(E1355_PANEL);
48722 -       display = e1355_read_reg(E1355_DISPLAY);
48723 +       fb_writew(l, p);
48724 +       fb_writew(h, p + 1);
48725 +}
48726  
48727 -       is_color = (panel & 0x04) != 0;
48728 -       is_dual  = (panel & 0x02) != 0;
48729 -       is_tft   = (panel & 0x01) != 0;
48730 +static inline unsigned long epson1355fb_fb_readl(const unsigned long *a)
48731 +{
48732 +       const u16 *p = (u16 *) a;
48733 +       u16 l = fb_readw(p);
48734 +       u16 h = fb_readw(p + 1);
48735  
48736 -       bpp = bpp_tab[(display>>2)&7]; 
48737 -       e1355_bpp_to_var(bpp, var);
48738 +       return (h << 16) | l;
48739 +}
48740  
48741 -       crt_enabled = (display & 0x02) != 0;
48742 -       lcd_enabled = (display & 0x02) != 0;
48743 +#define FB_READL epson1355fb_fb_readl
48744 +#define FB_WRITEL epson1355fb_fb_writel
48745  
48746 -       hw_bpp = width[is_tft][(panel>>4)&3];
48747 +/* ------------------------------------------------------------------------- */
48748  
48749 -       xres = e1355_read_reg(0x04) + 1;
48750 -       yres = e1355_read_reg16(0x08) + 1;
48751 -       
48752 -       xres *= 8;
48753 -       /* talk about weird hardware .. */
48754 -       yres *= (is_dual && !crt_enabled) ? 2 : 1;
48755 -
48756 -       xres_virtual = e1355_read_reg16(0x16);
48757 -       /* it's in 2-byte words initially */
48758 -       xres_virtual *= 16;
48759 -       xres_virtual /= var->bits_per_pixel;
48760 +static inline unsigned long copy_from_user16(void *to, const void *from,
48761 +                                            unsigned long n)
48762 +{
48763 +       u16 *dst = (u16 *) to;
48764 +       u16 *src = (u16 *) from;
48765  
48766 -       var->xres = xres;
48767 -       var->yres = yres;
48768 -       var->xres_virtual = xres_virtual;
48769 -       var->yres_virtual = yres;
48770 +       if (!access_ok(VERIFY_READ, from, n))
48771 +               return n;
48772  
48773 -       var->xoffset = var->yoffset = 0;
48774 +       while (n > 1) {
48775 +               u16 v;
48776 +               if (__get_user(v, src))
48777 +                       return n;
48778  
48779 -       var->grayscale = !is_color;
48780 -       
48781 -       return 0;
48782 -}
48783 +               fb_writew(v, dst);
48784  
48785 -#define is_dual(panel) (((panel)&3)==2)
48786 +               src++, dst++;
48787 +               n -= 2;
48788 +       }
48789  
48790 -static void get_panel_data(struct e1355_par *par)
48791 -{
48792 -       u8 panel;
48793 -       int width[2][4] = { { 4, 8, 16, -1 }, { 9, 12, 16, -1 } };
48794 +       if (n) {
48795 +               u8 v;
48796  
48797 -       panel = e1355_read_reg(E1355_PANEL);
48798 +               if (__get_user(v, ((u8 *) src)))
48799 +                       return n;
48800  
48801 -       par->panel_width = width[panel&1][(panel>>4)&3];
48802 -       par->panel_xres = (e1355_read_reg(0x04) + 1) * 8;
48803 -       par->panel_ymul = is_dual(panel) ? 2 : 1;
48804 -       par->panel_yres = ((e1355_read_reg16(0x08) + 1)
48805 -                          * par->panel_ymul);
48806 +               fb_writeb(v, dst);
48807 +       }
48808 +       return 0;
48809  }
48810  
48811 -static void e1355_get_par(void *raw_par, struct fb_info_gen *info)
48812 +static inline unsigned long copy_to_user16(void *to, const void *from,
48813 +                                          unsigned long n)
48814  {
48815 -       struct e1355_par *par = raw_par;
48816 +       u16 *dst = (u16 *) to;
48817 +       u16 *src = (u16 *) from;
48818  
48819 -       get_panel_data(par);
48820 -}
48821 +       if (!access_ok(VERIFY_WRITE, to, n))
48822 +               return n;
48823  
48824 -static void e1355_set_par(const void *par, struct fb_info_gen *info)
48825 -{
48826 -}
48827 +       while (n > 1) {
48828 +               u16 v = fb_readw(src);
48829  
48830 -static int e1355_getcolreg(unsigned regno, unsigned *red, unsigned *green,
48831 -                          unsigned *blue, unsigned *transp,
48832 -                          struct fb_info *info)
48833 -{
48834 -       u8 r, g, b;
48835 +               if (__put_user(v, dst))
48836 +                       return n;
48837  
48838 -       e1355_write_reg(regno, E1355_LUT_INDEX);
48839 -       r = e1355_read_reg(E1355_LUT_DATA);
48840 -       g = e1355_read_reg(E1355_LUT_DATA);
48841 -       b = e1355_read_reg(E1355_LUT_DATA);
48842 +               src++, dst++;
48843 +               n -= 2;
48844 +       }
48845  
48846 -       *red = r << 8;
48847 -       *green = g << 8;
48848 -       *blue = b << 8;
48849 +       if (n) {
48850 +               u8 v = fb_readb(src);
48851  
48852 +               if (__put_user(v, ((u8 *) dst)))
48853 +                       return n;
48854 +       }
48855         return 0;
48856  }
48857  
48858 -static int e1355fb_setcolreg(unsigned regno, unsigned red, unsigned green,
48859 -                            unsigned blue, unsigned transp,
48860 -                            struct fb_info *info)
48861 -{
48862 -       u8 r = (red >> 8) & 0xf0;
48863 -       u8 g = (green>>8) & 0xf0;
48864 -       u8 b = (blue>> 8) & 0xf0;
48865 -
48866 -       e1355_write_reg(regno, E1355_LUT_INDEX);
48867 -       e1355_write_reg(r, E1355_LUT_DATA);
48868 -       e1355_write_reg(g, E1355_LUT_DATA);
48869 -       e1355_write_reg(b, E1355_LUT_DATA);
48870 -       
48871 -       return 0;
48872 -}
48873  
48874 -static int e1355_pan_display(const struct fb_var_screeninfo *var,
48875 -                            struct fb_info_gen *info)
48876 +static ssize_t
48877 +epson1355fb_read(struct file *file, char *buf, size_t count, loff_t * ppos)
48878  {
48879 -       BUG();
48880 -       
48881 -       return -EINVAL;
48882 +       unsigned long p = *ppos;
48883 +
48884 +       /* from fbmem.c except for our own copy_*_user */
48885 +       if (p >= info.fix.smem_len)
48886 +               return 0;
48887 +       if (count >= info.fix.smem_len)
48888 +               count = info.fix.smem_len;
48889 +       if (count + p > info.fix.smem_len)
48890 +               count = info.fix.smem_len - p;
48891 +
48892 +       if (count) {
48893 +               char *base_addr;
48894 +
48895 +               base_addr = info.screen_base;
48896 +               count -= copy_to_user16(buf, base_addr + p, count);
48897 +               if (!count)
48898 +                       return -EFAULT;
48899 +               *ppos += count;
48900 +       }
48901 +       return count;
48902  }
48903  
48904 -/*
48905 - * The AERO_HACKS parts disable/enable the backlight on the Compaq Aero 8000.
48906 - * I'm not sure they aren't dangerous to the hardware, so be warned.
48907 - */
48908 -#undef AERO_HACKS
48909 +static ssize_t
48910 +epson1355fb_write(struct file *file, const char *buf,
48911 +                 size_t count, loff_t * ppos)
48912 +{
48913 +       unsigned long p = *ppos;
48914 +       int err;
48915 +
48916 +       /* from fbmem.c except for our own copy_*_user */
48917 +       if (p > info.fix.smem_len)
48918 +               return -ENOSPC;
48919 +       if (count >= info.fix.smem_len)
48920 +               count = info.fix.smem_len;
48921 +       err = 0;
48922 +       if (count + p > info.fix.smem_len) {
48923 +               count = info.fix.smem_len - p;
48924 +               err = -ENOSPC;
48925 +       }
48926  
48927 -static int e1355_blank(int blank_mode, struct fb_info_gen *info)
48928 -{
48929 -       u8 disp;
48930 +       if (count) {
48931 +               char *base_addr;
48932  
48933 -       switch (blank_mode) {
48934 -       case VESA_NO_BLANKING:
48935 -               disp = e1355_read_reg(E1355_DISPLAY);
48936 -               disp |= 1;
48937 -               e1355_write_reg(disp, E1355_DISPLAY);
48938 -               
48939 -#ifdef AERO_HACKS
48940 -               e1355_write_reg(0x6, 0x20);
48941 -#endif
48942 -               break;
48943 +               base_addr = info.screen_base;
48944 +               count -= copy_from_user16(base_addr + p, buf, count);
48945 +               *ppos += count;
48946 +               err = -EFAULT;
48947 +       }
48948 +       if (count)
48949 +               return count;
48950 +       return err;
48951 +}
48952 +
48953 +/* ------------------------------------------------------------------------- */
48954 +
48955 +static struct fb_ops epson1355fb_fbops = {
48956 +       .owner          = THIS_MODULE,
48957 +       .fb_setcolreg   = epson1355fb_setcolreg,
48958 +       .fb_pan_display = epson1355fb_pan_display,
48959 +       .fb_blank       = epson1355fb_blank,
48960 +       .fb_fillrect    = cfb_fillrect,
48961 +       .fb_copyarea    = cfb_copyarea,
48962 +       .fb_imageblit   = cfb_imageblit,
48963 +       .fb_read        = epson1355fb_read,
48964 +       .fb_write       = epson1355fb_write,
48965 +       .fb_cursor      = soft_cursor,
48966 +};
48967  
48968 -       case VESA_VSYNC_SUSPEND:
48969 -       case VESA_HSYNC_SUSPEND:
48970 -       case VESA_POWERDOWN:
48971 -               disp = e1355_read_reg(E1355_DISPLAY);
48972 -               disp &= ~1;
48973 -               e1355_write_reg(disp, E1355_DISPLAY);
48974 +/* ------------------------------------------------------------------------- */
48975  
48976 -#ifdef AERO_HACKS
48977 -               e1355_write_reg(0x0, 0x20);
48978 -#endif
48979 -               break;
48980 +static __init unsigned int get_fb_size(struct fb_info *info)
48981 +{
48982 +       unsigned int size = 2 * 1024 * 1024;
48983 +       char *p = info->screen_base;
48984  
48985 -       default:
48986 -               return -EINVAL;
48987 -       }
48988 +       /* the 512k framebuffer is aliased at start + 0x80000 * n */
48989 +       fb_writeb(1, p);
48990 +       fb_writeb(0, p + 0x80000);
48991 +       if (!fb_readb(p))
48992 +               size = 512 * 1024;
48993  
48994 -       return 0;
48995 +       fb_writeb(0, p);
48996 +
48997 +       return size;
48998  }
48999  
49000 -static struct display_switch e1355_dispsw;
49001 +static int epson1355_width_tab[2][4] __initdata =
49002 +    { {4, 8, 16, -1}, {9, 12, 16, -1} };
49003 +static int epson1355_bpp_tab[8] __initdata = { 1, 2, 4, 8, 15, 16 };
49004  
49005 -static void e1355_set_disp(const void *unused, struct display *disp,
49006 -                          struct fb_info_gen *info)
49007 +static void __init fetch_hw_state(struct fb_info *info)
49008  {
49009 -       struct display_switch *d;
49010 +       struct fb_var_screeninfo *var = &info->var;
49011 +       struct fb_fix_screeninfo *fix = &info->fix;
49012 +       u8 panel, display;
49013 +       u16 offset;
49014 +       u32 xres, yres;
49015 +       u32 xres_virtual, yres_virtual;
49016 +       int bpp, lcd_bpp;
49017 +       int is_color, is_dual, is_tft;
49018 +       int lcd_enabled, crt_enabled;
49019 +
49020 +       fix->type = FB_TYPE_PACKED_PIXELS;
49021  
49022 -       disp->dispsw = &e1355_dispsw;
49023 -       
49024 -       switch(disp->var.bits_per_pixel) {
49025 -#ifdef FBCON_HAS_MFB
49026 -       case 1:
49027 -               d = &fbcon_mfb; break;
49028 -#endif        
49029 -#ifdef FBCON_HAS_CFB8
49030 +       display = epson1355_read_reg(REG_DISPLAY_MODE);
49031 +       bpp = epson1355_bpp_tab[(display >> 2) & 7];
49032 +
49033 +       switch (bpp) {
49034         case 8:
49035 -               d = &fbcon_cfb8; break;
49036 -#endif
49037 +               fix->visual = FB_VISUAL_PSEUDOCOLOR;
49038 +               var->bits_per_pixel = 8;
49039 +               var->red.offset = var->green.offset = var->blue.offset = 0;
49040 +               var->red.length = var->green.length = var->blue.length = 8;
49041 +               break;
49042 +       case 16:
49043 +               /* 5-6-5 RGB */
49044 +               fix->visual = FB_VISUAL_TRUECOLOR;
49045 +               var->bits_per_pixel = 16;
49046 +               var->red.offset = 11;
49047 +               var->red.length = 5;
49048 +               var->green.offset = 5;
49049 +               var->green.length = 6;
49050 +               var->blue.offset = 0;
49051 +               var->blue.length = 5;
49052 +               break;
49053         default:
49054 -               BUG(); break;
49055 +               BUG();
49056         }
49057  
49058 -       memcpy(&e1355_dispsw, d, sizeof *d);
49059 +       if (fix->visual == FB_VISUAL_TRUECOLOR) {
49060 +               info->pseudo_palette = &pseudo_palette;
49061 +               fb_alloc_cmap(&(info->cmap), 16, 0);
49062 +       } else
49063 +               fb_alloc_cmap(&(info->cmap), 1 << bpp, 0);
49064 +
49065 +       panel = epson1355_read_reg(REG_PANEL_TYPE);
49066 +       is_color = (panel & 0x04) != 0;
49067 +       is_dual = (panel & 0x02) != 0;
49068 +       is_tft = (panel & 0x01) != 0;
49069 +       crt_enabled = (display & 0x02) != 0;
49070 +       lcd_enabled = (display & 0x01) != 0;
49071 +       lcd_bpp = epson1355_width_tab[is_tft][(panel >> 4) & 3];
49072 +
49073 +       xres = (epson1355_read_reg(REG_HORZ_DISP_WIDTH) + 1) * 8;
49074 +       yres = (epson1355_read_reg16(REG_VERT_DISP_HEIGHT0) + 1) *
49075 +           ((is_dual && !crt_enabled) ? 2 : 1);
49076 +       offset = epson1355_read_reg16(REG_MEM_ADDR_OFFSET0) & 0x7ff;
49077 +       xres_virtual = offset * 16 / bpp;
49078 +       yres_virtual = fix->smem_len / (offset * 2);
49079 +
49080 +       var->xres = xres;
49081 +       var->yres = yres;
49082 +       var->xres_virtual = xres_virtual;
49083 +       var->yres_virtual = yres_virtual;
49084 +       var->xoffset = var->yoffset = 0;
49085  
49086 -       /* reading is terribly slow for us */
49087 -#if 0 /* XXX: need to work out why this doesn't work */
49088 -       e1355_dispsw.bmove = fbcon_redraw_bmove;
49089 +       fix->line_length = offset * 2;
49090 +
49091 +       fix->xpanstep = 0;      /* no pan yet */
49092 +       fix->ypanstep = 1;
49093 +       fix->ywrapstep = 0;
49094 +       fix->accel = FB_ACCEL_NONE;
49095 +
49096 +       var->grayscale = !is_color;
49097 +
49098 +#ifdef DEBUG
49099 +       printk(KERN_INFO
49100 +              "epson1355fb: xres=%d, yres=%d, "
49101 +              "is_color=%d, is_dual=%d, is_tft=%d\n",
49102 +              xres, yres, is_color, is_dual, is_tft);
49103 +       printk(KERN_INFO
49104 +              "epson1355fb: bpp=%d, lcd_bpp=%d, "
49105 +              "crt_enabled=%d, lcd_enabled=%d\n",
49106 +              bpp, lcd_bpp, crt_enabled, lcd_enabled);
49107  #endif
49108  }
49109  
49110 -/* ------------ Interfaces to hardware functions ------------ */
49111  
49112 +static void clearfb16(struct fb_info *info)
49113 +{
49114 +       u16 *dst = (u16 *) info->screen_base;
49115 +       unsigned long n = info->fix.smem_len;
49116  
49117 -struct fbgen_hwswitch e1355_switch = {
49118 -       .detect =       e1355_detect,
49119 -       .encode_fix =   e1355_encode_fix,
49120 -       .decode_var =   e1355_decode_var,
49121 -       .encode_var =   e1355_encode_var,
49122 -       .get_par =      e1355_get_par,
49123 -       .set_par =      e1355_set_par,
49124 -       .getcolreg =    e1355_getcolreg,
49125 -       .pan_display =  e1355_pan_display,
49126 -       .blank =        e1355_blank,
49127 -       .set_disp =     e1355_set_disp,
49128 -};
49129 +       while (n > 1) {
49130 +               fb_writew(0, dst);
49131 +               dst++, n -= 2;
49132 +       }
49133  
49134 +       if (n)
49135 +               fb_writeb(0, dst);
49136 +}
49137  
49138 -/* ------------ Hardware Independent Functions ------------ */
49139 +static void epson1355fb_deinit(void);
49140  
49141 +int __init epson1355fb_init(void)
49142 +{
49143 +       u8 revision;
49144 +       int rc = 0;
49145  
49146 -static struct fb_ops e1355fb_ops = {
49147 -       .owner =        THIS_MODULE,
49148 -       .fb_get_fix =   fbgen_get_fix,
49149 -       .fb_get_var =   fbgen_get_var,
49150 -       .fb_set_var =   fbgen_set_var,
49151 -       .fb_get_cmap =  fbgen_get_cmap,
49152 -       .fb_set_cmap =  gen_set_cmap,
49153 -       .fb_setcolreg = e1355fb_setcolreg,
49154 -       .fb_pan_display =fbgen_pan_display,
49155 -       .fb_blank =     fbgen_blank,
49156 -};
49157 +       if (!request_mem_region
49158 +           (EPSON1355FB_REGS_PHYS, EPSON1355FB_REGS_LEN,
49159 +            "S1D13505 registers")) {
49160 +               printk(KERN_ERR "epson1355fb: unable to reserve "
49161 +                      "registers at 0x%0x\n", EPSON1355FB_REGS_PHYS);
49162 +               rc = -EBUSY;
49163 +               goto bail;
49164 +       }
49165  
49166 -static struct e1355fb_info fb_info;
49167 +       if (!request_mem_region(EPSON1355FB_FB_PHYS, EPSON1355FB_FB_LEN,
49168 +                               "S1D13505 framebuffer")) {
49169 +               printk(KERN_ERR "epson1355fb: unable to reserve "
49170 +                      "framebuffer at 0x%0x\n", EPSON1355FB_FB_PHYS);
49171 +               rc = -EBUSY;
49172 +               goto bail;
49173 +       }
49174 +
49175 +       par.reg_addr = (unsigned long)
49176 +           ioremap(EPSON1355FB_REGS_PHYS, EPSON1355FB_REGS_LEN);
49177 +       if (!par.reg_addr) {
49178 +               printk(KERN_ERR "epson1355fb: unable to map registers\n");
49179 +               rc = -ENOMEM;
49180 +               goto bail;
49181 +       }
49182 +
49183 +       info.screen_base =
49184 +           ioremap(EPSON1355FB_FB_PHYS, EPSON1355FB_FB_LEN);
49185 +       if (!info.screen_base) {
49186 +               printk(KERN_ERR
49187 +                      "epson1355fb: unable to map framebuffer\n");
49188 +               rc = -ENOMEM;
49189 +               goto bail;
49190 +       }
49191 +
49192 +       revision = epson1355_read_reg(REG_REVISION_CODE);
49193 +       if ((revision >> 2) != 3) {
49194 +               printk(KERN_INFO "epson1355fb: epson1355 not found\n");
49195 +               rc = -ENODEV;
49196 +               goto bail;
49197 +       }
49198 +
49199 +       info.fix.mmio_start = EPSON1355FB_REGS_PHYS;
49200 +       info.fix.mmio_len = EPSON1355FB_REGS_LEN;
49201 +       info.fix.smem_start = EPSON1355FB_FB_PHYS;
49202 +       info.fix.smem_len = get_fb_size(&info);
49203 +
49204 +       printk(KERN_INFO
49205 +              "epson1355fb: regs mapped at 0x%lx, fb %d KiB mapped at 0x%p\n",
49206 +              par.reg_addr, info.fix.smem_len / 1024, info.screen_base);
49207 +
49208 +       strcpy(info.fix.id, "S1D13505");
49209 +       info.par = &par;
49210 +       info.node = NODEV;
49211 +       info.fbops = &epson1355fb_fbops;
49212 +       info.flags = FBINFO_FLAG_DEFAULT;
49213 +
49214 +       /* we expect the boot loader to have initialized the chip
49215 +          with appropriate parameters from which we can determinte
49216 +          the flavor of lcd panel attached */
49217 +       fetch_hw_state(&info);
49218 +
49219 +       /* turn this puppy on ... */
49220 +       clearfb16(&info);
49221 +       backlight_enable(1);
49222 +       lcd_enable(1);
49223 +
49224 +       if (register_framebuffer(&info) < 0) {
49225 +               rc = -EINVAL;
49226 +               goto bail;
49227 +       }
49228 +
49229 +       printk(KERN_INFO "fb%d: %s frame buffer device\n",
49230 +              minor(info.node), info.fix.id);
49231  
49232 -int __init e1355fb_setup(char *str)
49233 -{
49234         return 0;
49235 +
49236 +      bail:
49237 +       epson1355fb_deinit();
49238 +       return rc;
49239  }
49240  
49241 -int __init e1355fb_init(void)
49242 +static void epson1355fb_deinit(void)
49243  {
49244 -       fb_info.gen.fbhw = &e1355_switch;
49245 -       fb_info.gen.fbhw->detect();
49246 -       strcpy(fb_info.gen.info.modename, "SED1355");
49247 -       fb_info.gen.info.changevar = NULL;
49248 -       fb_info.gen.info.fbops = &e1355fb_ops;
49249 -       fb_info.gen.info.screen_base = (void *)E1355_FB_BASE;
49250 -       fb_info.gen.currcon = -1;
49251 -       fb_info.gen.info.disp = &disp;
49252 -       fb_info.gen.parsize = sizeof(struct e1355_par);
49253 -       fb_info.gen.info.switch_con = &fbgen_switch;
49254 -       fb_info.gen.info.updatevar = &fbgen_update_var;
49255 -       fb_info.gen.info.flags = FBINFO_FLAG_DEFAULT;
49256 -       /* This should give a reasonable default video mode */
49257 -       fbgen_get_var(&disp.var, -1, &fb_info.gen.info);
49258 -       fbgen_do_set_var(&disp.var, 1, &fb_info.gen);
49259 -       fbgen_set_disp(-1, &fb_info.gen);
49260 -       if (disp.var.bits_per_pixel > 1) 
49261 -               do_install_cmap(0, &fb_info.gen);
49262 -       if (register_framebuffer(&fb_info.gen.info) < 0)
49263 -               return -EINVAL;
49264 -       printk(KERN_INFO "fb%d: %s frame buffer device\n", fb_info.gen.info.node,
49265 -              fb_info.gen.info.modename);
49266 +       fb_dealloc_cmap(&info.cmap);
49267  
49268 -       return 0;
49269 +       if (info.screen_base)
49270 +               iounmap(info.screen_base);
49271 +       if (par.reg_addr)
49272 +               iounmap((void *) par.reg_addr);
49273 +
49274 +       release_mem_region(EPSON1355FB_FB_PHYS, EPSON1355FB_FB_LEN);
49275 +       release_mem_region(EPSON1355FB_REGS_PHYS, EPSON1355FB_REGS_LEN);
49276  }
49277  
49278 +static void __exit epson1355fb_cleanup(void)
49279 +{
49280 +       backlight_enable(0);
49281 +       lcd_enable(0);
49282  
49283 -    /*
49284 -     *  Cleanup
49285 -     */
49286 -
49287 -void e1355fb_cleanup(struct fb_info *info)
49288 -{
49289 -       /*
49290 -        *  If your driver supports multiple boards, you should unregister and
49291 -        *  clean up all instances.
49292 -        */
49293 -       
49294 -       unregister_framebuffer(info);
49295 -       /* ... */
49296 +       unregister_framebuffer(&info);
49297 +       epson1355fb_deinit();
49298  }
49299  
49300 +/* ------------------------------------------------------------------------- */
49301 +
49302 +#ifdef MODULE
49303 +module_init(epson1355fb_init);
49304 +#endif
49305 +module_exit(epson1355fb_cleanup);
49306 +
49307 +MODULE_AUTHOR("Christopher Hoover <ch@hpl.hp.com>");
49308 +MODULE_DESCRIPTION("Framebuffer driver for Epson S1D13505");
49309  MODULE_LICENSE("GPL");
49310 --- linux-2.6.0-test6/drivers/video/fbmem.c     2003-09-08 13:58:58.000000000 -0700
49311 +++ 25/drivers/video/fbmem.c    2003-10-05 00:34:22.000000000 -0700
49312 @@ -25,7 +25,6 @@
49313  #include <linux/mman.h>
49314  #include <linux/tty.h>
49315  #include <linux/init.h>
49316 -#include <linux/linux_logo.h>
49317  #include <linux/proc_fs.h>
49318  #ifdef CONFIG_KMOD
49319  #include <linux/kmod.h>
49320 @@ -102,13 +101,13 @@ extern int hgafb_setup(char*);
49321  extern int matroxfb_init(void);
49322  extern int matroxfb_setup(char*);
49323  extern int hpfb_init(void);
49324 -extern int control_init(void);
49325 -extern int control_setup(char*);
49326 -extern int platinum_init(void);
49327 -extern int platinum_setup(char*);
49328 +extern int controlfb_init(void);
49329 +extern int controlfb_setup(char*);
49330 +extern int platinumfb_init(void);
49331 +extern int platinumfb_setup(char*);
49332  extern int valkyriefb_init(void);
49333  extern int valkyriefb_setup(char*);
49334 -extern int chips_init(void);
49335 +extern int chipsfb_init(void);
49336  extern int g364fb_init(void);
49337  extern int sa1100fb_init(void);
49338  extern int fm2fb_init(void);
49339 @@ -135,14 +134,14 @@ extern int tx3912fb_init(void);
49340  extern int tx3912fb_setup(char*);
49341  extern int radeonfb_init(void);
49342  extern int radeonfb_setup(char*);
49343 -extern int e1355fb_init(void);
49344 -extern int e1355fb_setup(char*);
49345 +extern int epson1355fb_init(void);
49346  extern int pvr2fb_init(void);
49347  extern int pvr2fb_setup(char*);
49348  extern int sstfb_init(void);
49349  extern int sstfb_setup(char*);
49350  extern int i810fb_init(void);
49351  extern int i810fb_setup(char*);
49352 +extern int asiliantfb_init(void);
49353  extern int ffb_init(void);
49354  extern int ffb_setup(char*);
49355  extern int cg6_init(void);
49356 @@ -221,16 +220,16 @@ static struct {
49357         { "radeonfb", radeonfb_init, radeonfb_setup },
49358  #endif
49359  #ifdef CONFIG_FB_CONTROL
49360 -       { "controlfb", control_init, control_setup },
49361 +       { "controlfb", controlfb_init, controlfb_setup },
49362  #endif
49363  #ifdef CONFIG_FB_PLATINUM
49364 -       { "platinumfb", platinum_init, platinum_setup },
49365 +       { "platinumfb", platinumfb_init, platinumfb_setup },
49366  #endif
49367  #ifdef CONFIG_FB_VALKYRIE
49368         { "valkyriefb", valkyriefb_init, valkyriefb_setup },
49369  #endif
49370  #ifdef CONFIG_FB_CT65550
49371 -       { "chipsfb", chips_init, NULL },
49372 +       { "chipsfb", chipsfb_init, NULL },
49373  #endif
49374  #ifdef CONFIG_FB_IMSTT
49375         { "imsttfb", imsttfb_init, imsttfb_setup },
49376 @@ -342,8 +341,8 @@ static struct {
49377  #ifdef CONFIG_FB_TX3912
49378         { "tx3912fb", tx3912fb_init, tx3912fb_setup },
49379  #endif
49380 -#ifdef CONFIG_FB_E1355
49381 -       { "e1355fb", e1355fb_init, e1355fb_setup },
49382 +#ifdef CONFIG_FB_EPSON1355
49383 +       { "s1d1355fb", epson1355fb_init, NULL },
49384  #endif
49385  #ifdef CONFIG_FB_PVR2
49386         { "pvr2fb", pvr2fb_init, pvr2fb_setup },
49387 @@ -360,6 +359,10 @@ static struct {
49388  #ifdef CONFIG_FB_VOODOO1
49389         { "sstfb", sstfb_init, sstfb_setup },
49390  #endif
49391 +#ifdef CONFIG_FB_ASILIANT
49392 +       { "asiliantfb", asiliantfb_init, NULL },
49393 +#endif
49394 +
49395         /*
49396          * Generic drivers that don't use resource management (yet)
49397          */
49398 @@ -409,20 +412,20 @@ void sys_outbuf(u8 *src, u8 *dst, unsign
49399         memcpy(dst, src, size);
49400  }      
49401  
49402 -void move_buf_aligned(struct fb_info *info, u8 *dst, u8 *src, u32 d_pitch, 
49403 -                       u32 s_pitch, u32 height)
49404 +void move_buf_aligned(struct fb_info *info, struct fb_pixmap *buf, u8 *dst, u8 *src,
49405 +                       u32 d_pitch, u32 s_pitch, u32 height)
49406  {
49407         int i;
49408  
49409         for (i = height; i--; ) {
49410 -               info->pixmap.outbuf(src, dst, s_pitch);
49411 +               buf->outbuf(src, dst, s_pitch);
49412                 src += s_pitch;
49413                 dst += d_pitch;
49414         }
49415  }
49416  
49417 -void move_buf_unaligned(struct fb_info *info, u8 *dst, u8 *src, u32 d_pitch, 
49418 -                       u32 height, u32 mask, u32 shift_high, u32 shift_low,
49419 +void move_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf, u8 *dst, u8 *src,
49420 +                       u32 d_pitch, u32 height, u32 mask, u32 shift_high, u32 shift_low,
49421                         u32 mod, u32 idx)
49422  {
49423         int i, j;
49424 @@ -430,21 +433,21 @@ void move_buf_unaligned(struct fb_info *
49425  
49426         for (i = height; i--; ) {
49427                 for (j = 0; j < idx; j++) {
49428 -                       tmp = info->pixmap.inbuf(dst+j);
49429 +                       tmp = buf->inbuf(dst+j);
49430                         tmp &= mask;
49431                         tmp |= *src >> shift_low;
49432 -                       info->pixmap.outbuf(&tmp, dst+j, 1);
49433 +                       buf->outbuf(&tmp, dst+j, 1);
49434                         tmp = *src << shift_high;
49435 -                       info->pixmap.outbuf(&tmp, dst+j+1, 1);
49436 +                       buf->outbuf(&tmp, dst+j+1, 1);
49437                         src++;
49438                 }
49439 -               tmp = info->pixmap.inbuf(dst+idx);
49440 +               tmp = buf->inbuf(dst+idx);
49441                 tmp &= mask;
49442                 tmp |= *src >> shift_low;
49443 -               info->pixmap.outbuf(&tmp, dst+idx, 1);
49444 +               buf->outbuf(&tmp, dst+idx, 1);
49445                 if (shift_high < mod) {
49446                         tmp = *src << shift_high;
49447 -                       info->pixmap.outbuf(&tmp, dst+idx+1, 1);
49448 +                       buf->outbuf(&tmp, dst+idx+1, 1);
49449                 }       
49450                 src++;
49451                 dst += d_pitch;
49452 @@ -455,26 +458,29 @@ void move_buf_unaligned(struct fb_info *
49453   * we need to lock this section since fb_cursor
49454   * may use fb_imageblit()
49455   */
49456 -u32 fb_get_buffer_offset(struct fb_info *info, u32 size)
49457 +char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size)
49458  {
49459 -       u32 align = info->pixmap.buf_align - 1;
49460 +       u32 align = buf->buf_align - 1;
49461         u32 offset, count = 1000;
49462 +       char *addr = buf->addr;
49463  
49464 -       spin_lock(&info->pixmap.lock);
49465 -       offset = info->pixmap.offset + align;
49466 -       offset &= ~align;
49467 -       if (offset + size > info->pixmap.size) {
49468 -               while (atomic_read(&info->pixmap.count) && count--);
49469 -               if (info->fbops->fb_sync && 
49470 -                   info->pixmap.flags & FB_PIXMAP_SYNC)
49471 -                       info->fbops->fb_sync(info);
49472 -               offset = 0;
49473 +       spin_lock(&buf->lock);
49474 +       if (!(buf->flags & FB_PIXMAP_IO)) {
49475 +               offset = buf->offset + align;
49476 +               offset &= ~align;
49477 +               if (offset + size > buf->size) {
49478 +                       while (atomic_read(&buf->count) && count--);
49479 +                       if (info->fbops->fb_sync && (buf->flags & FB_PIXMAP_SYNC))
49480 +                               info->fbops->fb_sync(info);
49481 +                       offset = 0;
49482 +               }
49483 +               buf->offset = offset + size;
49484 +               addr += offset;
49485         }
49486 -       info->pixmap.offset = offset + size;
49487 -       atomic_inc(&info->pixmap.count);        
49488 +       atomic_inc(&buf->count);
49489         smp_mb__after_atomic_inc();
49490 -       spin_unlock(&info->pixmap.lock);
49491 -       return offset;
49492 +       spin_unlock(&buf->lock);
49493 +       return addr;
49494  }
49495  
49496  #ifdef CONFIG_LOGO
49497 @@ -656,7 +662,7 @@ int fb_prepare_logo(struct fb_info *info
49498         }
49499  
49500         /* Return if no suitable logo was found */
49501 -       fb_logo.logo = fb_find_logo(info->var.bits_per_pixel);
49502 +       fb_logo.logo = find_logo(info->var.bits_per_pixel);
49503         
49504         if (!fb_logo.logo || fb_logo.logo->height > info->var.yres) {
49505                 fb_logo.logo = NULL;
49506 @@ -726,8 +732,6 @@ int fb_show_logo(struct fb_info *info)
49507              x <= info->var.xres-fb_logo.logo->width; x += (fb_logo.logo->width + 8)) {
49508                 image.dx = x;
49509                 info->fbops->fb_imageblit(info, &image);
49510 -               //atomic_dec(&info->pixmap.count);
49511 -               //smp_mb__after_atomic_dec();
49512         }
49513         
49514         if (palette != NULL)
49515 @@ -1238,6 +1242,22 @@ register_framebuffer(struct fb_info *fb_
49516                 fb_info->pixmap.inbuf = sys_inbuf;
49517         spin_lock_init(&fb_info->pixmap.lock);
49518  
49519 +       if (fb_info->sprite.addr == NULL) {
49520 +               fb_info->sprite.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL);
49521 +               if (fb_info->sprite.addr) {
49522 +                       fb_info->sprite.size = FBPIXMAPSIZE;
49523 +                       fb_info->sprite.buf_align = 1;
49524 +                       fb_info->sprite.scan_align = 1;
49525 +                       fb_info->sprite.flags = FB_PIXMAP_IO;
49526 +               }
49527 +       }
49528 +       fb_info->sprite.offset = 0;
49529 +       if (fb_info->sprite.outbuf == NULL)
49530 +               fb_info->sprite.outbuf = sys_outbuf;
49531 +       if (fb_info->sprite.inbuf == NULL)
49532 +               fb_info->sprite.inbuf = sys_inbuf;
49533 +       spin_lock_init(&fb_info->sprite.lock);
49534 +
49535         registered_fb[i] = fb_info;
49536  
49537         devfs_mk_cdev(MKDEV(FB_MAJOR, i),
49538 @@ -1371,6 +1391,33 @@ int __init video_setup(char *options)
49539  
49540  __setup("video=", video_setup);
49541  
49542 +static int fbdev_dummy(void)
49543 +{
49544 +       return 0;
49545 +}
49546 +
49547 +#define FBDEV_EMPTY (void *)fbdev_dummy
49548 +
49549 +const struct fb_ops dummy_fbdev = {
49550 +       .fb_open        = FBDEV_EMPTY,
49551 +       .fb_release     = FBDEV_EMPTY,
49552 +       .fb_read        = FBDEV_EMPTY,
49553 +       .fb_write       = FBDEV_EMPTY,
49554 +       .fb_check_var   = FBDEV_EMPTY,
49555 +       .fb_set_par     = FBDEV_EMPTY,
49556 +       .fb_setcolreg   = FBDEV_EMPTY,
49557 +       .fb_blank       = FBDEV_EMPTY,
49558 +       .fb_pan_display = FBDEV_EMPTY,
49559 +       .fb_fillrect    = FBDEV_EMPTY,
49560 +       .fb_copyarea    = FBDEV_EMPTY,
49561 +       .fb_imageblit   = FBDEV_EMPTY,
49562 +       .fb_cursor      = FBDEV_EMPTY,
49563 +       .fb_rotate      = FBDEV_EMPTY,
49564 +       .fb_sync        = FBDEV_EMPTY,
49565 +       .fb_ioctl       = FBDEV_EMPTY,
49566 +       .fb_mmap        = FBDEV_EMPTY,
49567 +};
49568 +
49569      /*
49570       *  Visible symbols for modules
49571       */
49572 --- linux-2.6.0-test6/drivers/video/g364fb.c    2003-06-14 12:17:58.000000000 -0700
49573 +++ 25/drivers/video/g364fb.c   2003-10-05 00:34:22.000000000 -0700
49574 @@ -127,20 +127,55 @@ static struct fb_ops g364fb_ops = {
49575  
49576  int g364fb_cursor(struct fb_info *info, struct fb_cursor *cursor)
49577  {
49578 +
49579 +       /* Turn the cursor off before we start changing it. */
49580 +       *(unsigned int *) CTLA_REG |= CURS_TOGGLE;
49581 +
49582 +       if (cursor->set & FB_CUR_SETHOT)
49583 +               info->cursor.hot = cursor->hot;
49584         
49585 -       switch (cursor->enable) {
49586 -       case CM_ERASE:
49587 -               *(unsigned int *) CTLA_REG |= CURS_TOGGLE;
49588 -               break;
49589 +       if (cursor->set & FB_CUR_SETPOS) {
49590 +               unsigned int tmp;
49591  
49592 -       case CM_MOVE:
49593 -       case CM_DRAW:
49594 -               *(unsigned int *) CTLA_REG &= ~CURS_TOGGLE;
49595 -               *(unsigned int *) CURS_POS_REG =
49596 -                   ((x * fontwidth(p)) << 12) | ((y * fontheight(p)) -
49597 -                                                 info->var.yoffset);
49598 -               break;
49599 +               info->cursor.image.dx = cursor->image.dx;
49600 +               info->cursor.image.dy = cursor->image.dy;
49601 +
49602 +               tmp = cursor->image.dy - info->var.yoffset;
49603 +               tmp |= (cursor->image.dx - info->var.xoffset) << 12;
49604 +
49605 +               *(unsigned int *) CURS_POS_REG = tmp;
49606 +       }
49607 +
49608 +       if (cursor->set & FB_CUR_SETSIZE) {
49609 +               info->cursor.image.height = cursor->image.height;
49610 +               info->cursor.image.width = cursor->image.width;
49611 +
49612 +               /* set the whole cursor to transparent */
49613 +               for (i = 0; i < 512; i++)
49614 +                       *(unsigned short *) (CURS_PAT_REG + i * 8) = 0;
49615         }
49616 +
49617 +       if (cursor->set & FB_CUR_SETCMAP) {
49618 +               volatile unsigned int *curs_pal_ptr =
49619 +                               (volatile unsigned int *) CURS_PAL_REG;
49620 +
49621 +               /* setup cursor */
49622 +               curs_pal_ptr[0] |= 0x00ffffff;
49623 +               curs_pal_ptr[2] |= 0x00ffffff;
49624 +               curs_pal_ptr[4] |= 0x00ffffff;
49625 +       }
49626 +
49627 +       if (cursor->set & FB_CUR_SETSHAPE) {
49628 +               /*
49629 +                * switch the last two lines to cursor palette 3
49630 +                * we assume here, that FONTSIZE_X is 8
49631 +                */
49632 +               *(unsigned short *) (CURS_PAT_REG + 14 * 64) = 0xffff;
49633 +               *(unsigned short *) (CURS_PAT_REG + 15 * 64) = 0xffff;
49634 +       }
49635 +
49636 +       if (info->cursor.enable)
49637 +               *(unsigned int *) CTLA_REG &= ~CURS_TOGGLE;
49638         return 0;
49639  }
49640  
49641 @@ -196,10 +231,6 @@ static int g364fb_setcolreg(u_int regno,
49642   */
49643  int __init g364fb_init(void)
49644  {
49645 -       volatile unsigned int *pal_ptr =
49646 -           (volatile unsigned int *) CLR_PAL_REG;
49647 -       volatile unsigned int *curs_pal_ptr =
49648 -           (volatile unsigned int *) CURS_PAL_REG;
49649         int mem, i, j;
49650  
49651         /* TBD: G364 detection */
49652 @@ -212,23 +243,6 @@ int __init g364fb_init(void)
49653             (*((volatile unsigned int *) VDISPLAY_REG) & 0x00ffffff) / 2;
49654         *(volatile unsigned int *) CTLA_REG |= ENABLE_VTG;
49655  
49656 -       /* setup cursor */
49657 -       curs_pal_ptr[0] |= 0x00ffffff;
49658 -       curs_pal_ptr[2] |= 0x00ffffff;
49659 -       curs_pal_ptr[4] |= 0x00ffffff;
49660 -
49661 -       /*
49662 -        * first set the whole cursor to transparent
49663 -        */
49664 -       for (i = 0; i < 512; i++)
49665 -               *(unsigned short *) (CURS_PAT_REG + i * 8) = 0;
49666 -
49667 -       /*
49668 -        * switch the last two lines to cursor palette 3
49669 -        * we assume here, that FONTSIZE_X is 8
49670 -        */
49671 -       *(unsigned short *) (CURS_PAT_REG + 14 * 64) = 0xffff;
49672 -       *(unsigned short *) (CURS_PAT_REG + 15 * 64) = 0xffff;
49673         fb_var.xres_virtual = fbvar.xres;
49674         fb_fix.line_length = (xres / 8) * fb_var.bits_per_pixel;
49675         fb_fix.smem_start = 0x40000000; /* physical address */
49676 --- linux-2.6.0-test6/drivers/video/i810/Makefile       2003-06-14 12:18:06.000000000 -0700
49677 +++ 25/drivers/video/i810/Makefile      2003-10-05 00:34:22.000000000 -0700
49678 @@ -1,16 +1,9 @@
49679  #
49680  # Makefile for the Intel 810/815 framebuffer driver
49681  #
49682 -# Note! Dependencies are done automagically by 'make dep', which also
49683 -# removes any old dependencies. DON'T put your own dependencies here
49684 -# unless it's something special (ie not a .c file).
49685 -#
49686 -# Note 2! The CFLAGS definitions are now in the main makefile...
49687 -
49688  
49689  obj-$(CONFIG_FB_I810)          += i810fb.o
49690  
49691 -
49692  i810fb-objs                     := i810_main.o i810_accel.o
49693  
49694  ifdef CONFIG_FB_I810_GTF
49695 --- linux-2.6.0-test6/drivers/video/imsttfb.c   2003-08-08 22:55:13.000000000 -0700
49696 +++ 25/drivers/video/imsttfb.c  2003-10-05 00:34:22.000000000 -0700
49697 @@ -1495,6 +1495,8 @@ imsttfb_probe(struct pci_dev *pdev, cons
49698                 default:
49699                         printk(KERN_INFO "imsttfb: Device 0x%x unknown, "
49700                                          "contact maintainer.\n", pdev->device);
49701 +                       release_mem_region(addr, size);
49702 +                       kfree(info);
49703                         return -ENODEV;
49704         }
49705  
49706 --- linux-2.6.0-test6/drivers/video/Kconfig     2003-09-27 18:57:46.000000000 -0700
49707 +++ 25/drivers/video/Kconfig    2003-10-05 00:34:22.000000000 -0700
49708 @@ -188,19 +188,19 @@ config FB_AMIGA_AGA
49709           otherwise say N.
49710  
49711  config FB_CYBER
49712 -       tristate "Amiga CyberVision support"
49713 -       depends on FB && ZORRO
49714 +       tristate "Amiga CyberVision 64 support"
49715 +       depends on FB && ZORRO && BROKEN
49716         help
49717           This enables support for the Cybervision 64 graphics card from
49718           Phase5. Please note that its use is not all that intuitive (i.e. if
49719           you have any questions, be sure to ask!). Say N unless you have a
49720           Cybervision 64 or plan to get one before you next recompile the
49721           kernel. Please note that this driver DOES NOT support the
49722 -         Cybervision 64 3D card, as they use incompatible video chips.
49723 +         Cybervision 64/3D card, as they use incompatible video chips.
49724  
49725  config FB_VIRGE
49726 -       bool "Amiga CyberVision3D support "
49727 -       depends on FB && ZORRO
49728 +       bool "Amiga CyberVision 64/3D support "
49729 +       depends on FB && ZORRO && BROKEN
49730         help
49731           This enables support for the Cybervision 64/3D graphics card from
49732           Phase5. Please note that its use is not all that intuitive (i.e. if
49733 @@ -210,8 +210,8 @@ config FB_VIRGE
49734           Cybervision 64 card, as they use incompatible video chips.
49735  
49736  config FB_RETINAZ3
49737 -       tristate "Amiga RetinaZ3 support"
49738 -       depends on FB && ZORRO
49739 +       tristate "Amiga Retina Z3 support"
49740 +       depends on FB && ZORRO && BROKEN
49741         help
49742           This enables support for the Retina Z3 graphics card. Say N unless
49743           you have a Retina Z3 or plan to get one before you next recompile
49744 @@ -226,7 +226,7 @@ config FB_FM2
49745  
49746  config FB_ATARI
49747         bool "Atari native chipset support"
49748 -       depends on FB && ATARI
49749 +       depends on FB && ATARI && BROKEN
49750         help
49751           This is the frame buffer device driver for the builtin graphics
49752           chipset found in Ataris.
49753 @@ -266,6 +266,10 @@ config FB_CT65550
49754           This is the frame buffer device driver for the Chips & Technologies
49755           65550 graphics chip in PowerBooks.
49756  
49757 +config FB_ASILIANT
49758 +       bool "Chips 69000 display support"
49759 +       depends on FB && PCI
49760 +
49761  config FB_IMSTT
49762         bool "IMS Twin Turbo display support"
49763         depends on FB && PCI
49764 @@ -367,7 +371,7 @@ config BUS_I2C
49765  
49766  config FB_SUN3
49767         bool "Sun3 framebuffer support"
49768 -       depends on FB && (SUN3 || SUN3X)
49769 +       depends on FB && (SUN3 || SUN3X) && BROKEN
49770  
49771  config FB_BW2
49772         bool "BWtwo support"
49773 @@ -414,35 +418,15 @@ config FB_PVR2_DEBUG
49774           messages. Most people will want to say N here. If unsure, you will
49775           also want to say N.
49776  
49777 -config FB_E1355
49778 +config FB_EPSON1355
49779         bool "Epson 1355 framebuffer support"
49780 -       depends on FB && SUPERH
49781 +       depends on FB && (SUPERH || ARCH_CEIVA)
49782         help
49783           Build in support for the SED1355 Epson Research Embedded RAMDAC
49784           LCD/CRT Controller (since redesignated as the S1D13505) as a
49785           framebuffer.  Product specs at
49786           <http://www.erd.epson.com/vdc/html/products.htm>.
49787  
49788 -config E1355_REG_BASE
49789 -       hex "Register Base Address"
49790 -       depends on FB_E1355
49791 -       default "a8000000"
49792 -       help
49793 -         Epson SED1355/S1D13505 LCD/CRT controller register base address.
49794 -         See the manuals at
49795 -         <http://www.erd.epson.com/vdc/html/contents/S1D13505.htm> for
49796 -         discussion.
49797 -
49798 -config E1355_FB_BASE
49799 -       hex "Framebuffer Base Address"
49800 -       depends on FB_E1355
49801 -       default "a8200000"
49802 -       help
49803 -         Epson SED1355/S1D13505 LCD/CRT controller memory base address.  See
49804 -         the manuals at
49805 -         <http://www.erd.epson.com/vdc/html/contents/S1D13505.htm> for
49806 -         discussion.
49807 -
49808  config FB_RIVA
49809         tristate "nVidia Riva support"
49810         depends on FB && PCI
49811 @@ -703,26 +687,40 @@ config FB_ATY_XL_INIT
49812           Say Y here to support booting a Rage XL without BIOS support.
49813  
49814  config FB_SIS
49815 -       tristate "SIS acceleration"
49816 +       tristate "SiS acceleration"
49817         depends on FB && PCI
49818         help
49819 -         This is the frame buffer device driver for the SiS 630 and 640 Super
49820 -         Socket 7 UMA cards.  Specs available at <http://www.sis.com.tw/>.
49821 +         This is the frame buffer device driver for the SiS 300, 315 and Xabre
49822 +         series VGA controller.
49823 +
49824 +         Specs available at <http://www.sis.com.tw/>.
49825 +
49826 +         See <http://www.winischhofer.net/linuxsisvga.shtml> for
49827 +         documentation and updates.
49828 +
49829 +         The driver is also available as a module ( = code which can be
49830 +         inserted and removed from the running kernel whenever you want). The
49831 +         module will be called sisfb. If you want to compile it as a
49832 +         module, say M here and read Documentation/modules.txt.
49833  
49834  config FB_SIS_300
49835 -       bool "SIS 630/540/730 support"
49836 +       bool "SIS 300 series support"
49837         depends on FB_SIS
49838         help
49839 -         This is the frame buffer device driver for the SiS 630 and related
49840 -         Super Socket 7 UMA cards.  Specs available at
49841 -         <http://www.sis.com.tw/>.
49842 +         This is the frame buffer device driver for the SiS 300 series VGA
49843 +         controllers. This includes the 300, 540, 630, 730.
49844 +         Documentation and updates available at
49845 +         http://www.winischhofer.net/linuxsisvga.shtml
49846  
49847  config FB_SIS_315
49848 -       bool "SIS 315H/315 support"
49849 +       bool "SIS 315/Xabre support"
49850         depends on FB_SIS
49851         help
49852 -         This is the frame buffer device driver for the SiS 315 graphics
49853 -         card.  Specs available at <http://www.sis.com.tw/>.
49854 +         This is the frame buffer device driver for the SiS 315 and Xabre
49855 +         series VGA controllers. This includes the 315, 315H, 315PRO, 650,
49856 +         651, M650, 652, M652, 740, 330 (Xabre), 660, M660, 760, M760.
49857 +         Documentation and updates available at
49858 +         http://www.winischhofer.net/linuxsisvga.shtml
49859  
49860  config FB_NEOMAGIC
49861         tristate "NeoMagic display support"
49862 --- linux-2.6.0-test6/drivers/video/logo/logo.c 2003-07-27 12:14:40.000000000 -0700
49863 +++ 25/drivers/video/logo/logo.c        2003-10-05 00:34:22.000000000 -0700
49864 @@ -32,8 +32,7 @@ extern const struct linux_logo logo_supe
49865  extern const struct linux_logo logo_superh_vga16;
49866  extern const struct linux_logo logo_superh_clut224;
49867  
49868 -
49869 -const struct linux_logo *fb_find_logo(int depth)
49870 +const struct linux_logo *find_logo(int depth)
49871  {
49872         const struct linux_logo *logo = 0;
49873  
49874 --- linux-2.6.0-test6/drivers/video/Makefile    2003-09-08 13:58:58.000000000 -0700
49875 +++ 25/drivers/video/Makefile   2003-10-05 00:34:22.000000000 -0700
49876 @@ -22,7 +22,7 @@ obj-$(CONFIG_FB_Q40)              += q40
49877  obj-$(CONFIG_FB_ATARI)            += atafb.o
49878  obj-$(CONFIG_FB_68328)            += 68328fb.o
49879  obj-$(CONFIG_FB_RADEON)                  += radeonfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
49880 -obj-$(CONFIG_FB_NEOMAGIC)         += neofb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
49881 +obj-$(CONFIG_FB_NEOMAGIC)         += neofb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o vgastate.o
49882  obj-$(CONFIG_FB_IGA)              += igafb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
49883  obj-$(CONFIG_FB_CONTROL)          += controlfb.o macmodes.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
49884  obj-$(CONFIG_FB_PLATINUM)         += platinumfb.o macmodes.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
49885 @@ -68,9 +68,10 @@ obj-$(CONFIG_FB_HGA)              += hga
49886  obj-$(CONFIG_FB_SA1100)           += sa1100fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
49887  obj-$(CONFIG_FB_VIRTUAL)          += vfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o 
49888  obj-$(CONFIG_FB_HIT)              += hitfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
49889 -obj-$(CONFIG_FB_E1355)            += epson1355fb.o
49890 -obj-$(CONFIG_FB_PVR2)             += pvr2fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
49891 +obj-$(CONFIG_FB_EPSON1355)        += epson1355fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
49892 +obj-$(CONFIG_FB_PVR2)             += pvr2fb.o cfbcillrect.o cfbcopyarea.o cfbimgblt.o
49893  obj-$(CONFIG_FB_VOODOO1)          += sstfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
49894 +obj-$(CONFIG_FB_ASILIANT)         += asiliantfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
49895  
49896  obj-$(CONFIG_FB_FFB)               += ffb.o sbuslib.o cfbimgblt.o cfbcopyarea.o
49897  obj-$(CONFIG_FB_CG6)               += cg6.o sbuslib.o cfbimgblt.o cfbcopyarea.o
49898 --- linux-2.6.0-test6/drivers/video/neofb.c     2003-08-08 22:55:13.000000000 -0700
49899 +++ 25/drivers/video/neofb.c    2003-10-05 00:34:22.000000000 -0700
49900 @@ -81,9 +81,10 @@ extern int tosh_smm(SMMRegisters *regs);
49901  #include <asm/mtrr.h>
49902  #endif
49903  
49904 +#include <video/vga.h>
49905  #include <video/neomagic.h>
49906  
49907 -#define NEOFB_VERSION "0.4.1"
49908 +#define NEOFB_VERSION "0.4.2"
49909  
49910  /* --------------------------------------------------------------------- */
49911  
49912 @@ -152,6 +153,16 @@ static biosMode bios32[] = {
49913  };
49914  #endif
49915  
49916 +static inline u32 read_le32(int regindex, const struct neofb_par *par)
49917 +{
49918 +       return readl(par->neo2200 + par->cursorOff + regindex);
49919 +}
49920 +
49921 +static inline void write_le32(int regindex, u32 val, const struct neofb_par *par)
49922 +{
49923 +       writel(val, par->neo2200 + par->cursorOff + regindex);
49924 +}
49925 +
49926  static int neoFindMode(int xres, int yres, int depth)
49927  {
49928         int xres_s;
49929 @@ -363,44 +374,61 @@ static int vgaHWInit(const struct fb_var
49930         par->Attribute[18] = 0x0F;
49931         par->Attribute[19] = 0x00;
49932         par->Attribute[20] = 0x00;
49933 -
49934         return 0;
49935  }
49936  
49937 -static void vgaHWLock(void)
49938 +static void vgaHWLock(struct vgastate *state)
49939  {
49940         /* Protect CRTC[0-7] */
49941 -       VGAwCR(0x11, VGArCR(0x11) | 0x80);
49942 +       vga_wcrt(state->vgabase, 0x11, vga_rcrt(state->vgabase, 0x11) | 0x80);
49943  }
49944  
49945  static void vgaHWUnlock(void)
49946  {
49947         /* Unprotect CRTC[0-7] */
49948 -       VGAwCR(0x11, VGArCR(0x11) & ~0x80);
49949 +       vga_wcrt(NULL, 0x11, vga_rcrt(NULL, 0x11) & ~0x80);
49950  }
49951  
49952 -static void neoLock(void)
49953 +static void neoLock(struct vgastate *state)
49954  {
49955 -       VGAwGR(0x09, 0x00);
49956 -       vgaHWLock();
49957 +       vga_wgfx(state->vgabase, 0x09, 0x00);
49958 +       vgaHWLock(state);
49959  }
49960  
49961  static void neoUnlock(void)
49962  {
49963         vgaHWUnlock();
49964 -       VGAwGR(0x09, 0x26);
49965 +       vga_wgfx(NULL, 0x09, 0x26);
49966  }
49967  
49968  /*
49969 - * vgaHWSeqReset
49970 - *      perform a sequencer reset.
49971 + * VGA Palette management
49972   */
49973 -void vgaHWSeqReset(int start)
49974 +static int paletteEnabled = 0;
49975 +
49976 +inline void VGAenablePalette(void)
49977  {
49978 -       if (start)
49979 -               VGAwSEQ(0x00, 0x01);    /* Synchronous Reset */
49980 +       vga_r(NULL, VGA_IS1_RC);
49981 +       vga_w(NULL, VGA_ATT_W, 0x00);
49982 +       paletteEnabled = 1;
49983 +}
49984 +
49985 +inline void VGAdisablePalette(void)
49986 +{
49987 +       vga_r(NULL, VGA_IS1_RC);
49988 +       vga_w(NULL, VGA_ATT_W, 0x20);
49989 +       paletteEnabled = 0;
49990 +}
49991 +
49992 +inline void VGAwATTR(u8 index, u8 value)
49993 +{
49994 +       if (paletteEnabled)
49995 +               index &= ~0x20;
49996         else
49997 -               VGAwSEQ(0x00, 0x03);    /* End Reset */
49998 +               index |= 0x20;
49999 +
50000 +       vga_r(NULL, VGA_IS1_RC);
50001 +       vga_wattr(NULL, index, value);
50002  }
50003  
50004  void vgaHWProtect(int on)
50005 @@ -411,21 +439,18 @@ void vgaHWProtect(int on)
50006                 /*
50007                  * Turn off screen and disable sequencer.
50008                  */
50009 -               tmp = VGArSEQ(0x01);
50010 -
50011 -               vgaHWSeqReset(1);       /* start synchronous reset */
50012 -               VGAwSEQ(0x01, tmp | 0x20);      /* disable the display */
50013 +               tmp = vga_rseq(NULL, 0x01);
50014 +               vga_wseq(NULL, 0x00, 0x01);             /* Synchronous Reset */
50015 +               vga_wseq(NULL, 0x01, tmp | 0x20);       /* disable the display */
50016  
50017                 VGAenablePalette();
50018         } else {
50019                 /*
50020                  * Reenable sequencer, then turn on screen.
50021                  */
50022 -
50023 -               tmp = VGArSEQ(0x01);
50024 -
50025 -               VGAwSEQ(0x01, tmp & ~0x20);     /* reenable display */
50026 -               vgaHWSeqReset(0);       /* clear synchronousreset */
50027 +               tmp = vga_rseq(NULL, 0x01);
50028 +               vga_wseq(NULL, 0x01, tmp & ~0x20);      /* reenable display */
50029 +               vga_wseq(NULL, 0x00, 0x03);             /* clear synchronousreset */
50030  
50031                 VGAdisablePalette();
50032         }
50033 @@ -436,19 +461,19 @@ static void vgaHWRestore(const struct fb
50034  {
50035         int i;
50036  
50037 -       VGAwMISC(par->MiscOutReg);
50038 +       vga_w(NULL, VGA_MIS_W, par->MiscOutReg);
50039  
50040         for (i = 1; i < 5; i++)
50041 -               VGAwSEQ(i, par->Sequencer[i]);
50042 +               vga_wseq(NULL, i, par->Sequencer[i]);
50043  
50044         /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 or CRTC[17] */
50045 -       VGAwCR(17, par->CRTC[17] & ~0x80);
50046 +       vga_wcrt(NULL, 17, par->CRTC[17] & ~0x80);
50047  
50048         for (i = 0; i < 25; i++)
50049 -               VGAwCR(i, par->CRTC[i]);
50050 +               vga_wcrt(NULL, i, par->CRTC[i]);
50051  
50052         for (i = 0; i < 9; i++)
50053 -               VGAwGR(i, par->Graphics[i]);
50054 +               vga_wgfx(NULL, i, par->Graphics[i]);
50055  
50056         VGAenablePalette();
50057  
50058 @@ -535,6 +560,36 @@ static inline void neo2200_accel_init(st
50059  /* --------------------------------------------------------------------- */
50060  
50061  static int
50062 +neofb_open(struct fb_info *info, int user)
50063 +{
50064 +       struct neofb_par *par = (struct neofb_par *) info->par;
50065 +       int cnt = atomic_read(&par->ref_count);
50066 +
50067 +       if (cnt) {
50068 +               memset(&par->state, 0, sizeof(struct vgastate));
50069 +               par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS;
50070 +               save_vga(&par->state);
50071 +       }
50072 +       atomic_inc(&par->ref_count);
50073 +       return 0;
50074 +}
50075 +
50076 +static int
50077 +neofb_release(struct fb_info *info, int user)
50078 +{
50079 +       struct neofb_par *par = (struct neofb_par *) info->par;
50080 +       int cnt = atomic_read(&par->ref_count);
50081 +
50082 +       if (!cnt)
50083 +               return -EINVAL;
50084 +       if (cnt == 1) {
50085 +               restore_vga(&par->state);
50086 +       }
50087 +       atomic_dec(&par->ref_count);
50088 +       return 0;
50089 +}
50090 +
50091 +static int
50092  neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
50093  {
50094         struct neofb_par *par = (struct neofb_par *) info->par;
50095 @@ -981,13 +1036,13 @@ static int neofb_set_par(struct fb_info 
50096         }
50097  
50098         /* alread unlocked above */
50099 -       /* BOGUS  VGAwGR (0x09, 0x26); */
50100 +       /* BOGUS  vga_wgfx(NULL, 0x09, 0x26); */
50101  
50102         /* don't know what this is, but it's 0 from bootup anyway */
50103 -       VGAwGR(0x15, 0x00);
50104 +       vga_wgfx(NULL, 0x15, 0x00);
50105  
50106         /* was set to 0x01 by my bios in text and vesa modes */
50107 -       VGAwGR(0x0A, par->GeneralLockReg);
50108 +       vga_wgfx(NULL, 0x0A, par->GeneralLockReg);
50109  
50110         /*
50111          * The color mode needs to be set before calling vgaHWRestore
50112 @@ -996,7 +1051,7 @@ static int neofb_set_par(struct fb_info 
50113          * NOTE: Make sure we don't change bits make sure we don't change
50114          * any reserved bits.
50115          */
50116 -       temp = VGArGR(0x90);
50117 +       temp = vga_rgfx(NULL, 0x90);
50118         switch (info->fix.accel) {
50119         case FB_ACCEL_NEOMAGIC_NM2070:
50120                 temp &= 0xF0;   /* Save bits 7:4 */
50121 @@ -1015,7 +1070,7 @@ static int neofb_set_par(struct fb_info 
50122                 break;
50123         }
50124  
50125 -       VGAwGR(0x90, temp);
50126 +       vga_wgfx(NULL, 0x90, temp);
50127  
50128         /*
50129          * In some rare cases a lockup might occur if we don't delay
50130 @@ -1027,9 +1082,9 @@ static int neofb_set_par(struct fb_info 
50131          * Disable horizontal and vertical graphics and text expansions so
50132          * that vgaHWRestore works properly.
50133          */
50134 -       temp = VGArGR(0x25);
50135 +       temp = vga_rgfx(NULL, 0x25);
50136         temp &= 0x39;
50137 -       VGAwGR(0x25, temp);
50138 +       vga_wgfx(NULL, 0x25, temp);
50139  
50140         /*
50141          * Sleep for 200ms to make sure that the two operations above have
50142 @@ -1041,19 +1096,18 @@ static int neofb_set_par(struct fb_info 
50143          * This function handles restoring the generic VGA registers.  */
50144         vgaHWRestore(info, par);
50145  
50146 -
50147 -       VGAwGR(0x0E, par->ExtCRTDispAddr);
50148 -       VGAwGR(0x0F, par->ExtCRTOffset);
50149 -       temp = VGArGR(0x10);
50150 +       vga_wgfx(NULL, 0x0E, par->ExtCRTDispAddr);
50151 +       vga_wgfx(NULL, 0x0F, par->ExtCRTOffset);
50152 +       temp = vga_rgfx(NULL, 0x10);
50153         temp &= 0x0F;           /* Save bits 3:0 */
50154         temp |= (par->SysIfaceCntl1 & ~0x0F);   /* VESA Bios sets bit 1! */
50155 -       VGAwGR(0x10, temp);
50156 +       vga_wgfx(NULL, 0x10, temp);
50157  
50158 -       VGAwGR(0x11, par->SysIfaceCntl2);
50159 -       VGAwGR(0x15, 0 /*par->SingleAddrPage */ );
50160 -       VGAwGR(0x16, 0 /*par->DualAddrPage */ );
50161 +       vga_wgfx(NULL, 0x11, par->SysIfaceCntl2);
50162 +       vga_wgfx(NULL, 0x15, 0 /*par->SingleAddrPage */ );
50163 +       vga_wgfx(NULL, 0x16, 0 /*par->DualAddrPage */ );
50164  
50165 -       temp = VGArGR(0x20);
50166 +       temp = vga_rgfx(NULL, 0x20);
50167         switch (info->fix.accel) {
50168         case FB_ACCEL_NEOMAGIC_NM2070:
50169                 temp &= 0xFC;   /* Save bits 7:2 */
50170 @@ -1074,79 +1128,78 @@ static int neofb_set_par(struct fb_info 
50171                 temp |= (par->PanelDispCntlReg1 & ~0x98);
50172                 break;
50173         }
50174 -       VGAwGR(0x20, temp);
50175 +       vga_wgfx(NULL, 0x20, temp);
50176  
50177 -       temp = VGArGR(0x25);
50178 +       temp = vga_rgfx(NULL, 0x25);
50179         temp &= 0x38;           /* Save bits 5:3 */
50180         temp |= (par->PanelDispCntlReg2 & ~0x38);
50181 -       VGAwGR(0x25, temp);
50182 +       vga_wgfx(NULL, 0x25, temp);
50183  
50184         if (info->fix.accel != FB_ACCEL_NEOMAGIC_NM2070) {
50185 -               temp = VGArGR(0x30);
50186 +               temp = vga_rgfx(NULL, 0x30);
50187                 temp &= 0xEF;   /* Save bits 7:5 and bits 3:0 */
50188                 temp |= (par->PanelDispCntlReg3 & ~0xEF);
50189 -               VGAwGR(0x30, temp);
50190 +               vga_wgfx(NULL, 0x30, temp);
50191         }
50192  
50193 -       VGAwGR(0x28, par->PanelVertCenterReg1);
50194 -       VGAwGR(0x29, par->PanelVertCenterReg2);
50195 -       VGAwGR(0x2a, par->PanelVertCenterReg3);
50196 +       vga_wgfx(NULL, 0x28, par->PanelVertCenterReg1);
50197 +       vga_wgfx(NULL, 0x29, par->PanelVertCenterReg2);
50198 +       vga_wgfx(NULL, 0x2a, par->PanelVertCenterReg3);
50199  
50200         if (info->fix.accel != FB_ACCEL_NEOMAGIC_NM2070) {
50201 -               VGAwGR(0x32, par->PanelVertCenterReg4);
50202 -               VGAwGR(0x33, par->PanelHorizCenterReg1);
50203 -               VGAwGR(0x34, par->PanelHorizCenterReg2);
50204 -               VGAwGR(0x35, par->PanelHorizCenterReg3);
50205 +               vga_wgfx(NULL, 0x32, par->PanelVertCenterReg4);
50206 +               vga_wgfx(NULL, 0x33, par->PanelHorizCenterReg1);
50207 +               vga_wgfx(NULL, 0x34, par->PanelHorizCenterReg2);
50208 +               vga_wgfx(NULL, 0x35, par->PanelHorizCenterReg3);
50209         }
50210  
50211         if (info->fix.accel == FB_ACCEL_NEOMAGIC_NM2160)
50212 -               VGAwGR(0x36, par->PanelHorizCenterReg4);
50213 +               vga_wgfx(NULL, 0x36, par->PanelHorizCenterReg4);
50214  
50215         if (info->fix.accel == FB_ACCEL_NEOMAGIC_NM2200 ||
50216             info->fix.accel == FB_ACCEL_NEOMAGIC_NM2230 ||
50217             info->fix.accel == FB_ACCEL_NEOMAGIC_NM2360 ||
50218             info->fix.accel == FB_ACCEL_NEOMAGIC_NM2380) {
50219 -               VGAwGR(0x36, par->PanelHorizCenterReg4);
50220 -               VGAwGR(0x37, par->PanelVertCenterReg5);
50221 -               VGAwGR(0x38, par->PanelHorizCenterReg5);
50222 +               vga_wgfx(NULL, 0x36, par->PanelHorizCenterReg4);
50223 +               vga_wgfx(NULL, 0x37, par->PanelVertCenterReg5);
50224 +               vga_wgfx(NULL, 0x38, par->PanelHorizCenterReg5);
50225  
50226                 clock_hi = 1;
50227         }
50228  
50229         /* Program VCLK3 if needed. */
50230 -       if (par->ProgramVCLK && ((VGArGR(0x9B) != par->VCLK3NumeratorLow)
50231 -                                || (VGArGR(0x9F) != par->VCLK3Denominator)
50232 -                                || (clock_hi && ((VGArGR(0x8F) & ~0x0f)
50233 -                                                 != (par->
50234 -                                                     VCLK3NumeratorHigh &
50235 +       if (par->ProgramVCLK && ((vga_rgfx(NULL, 0x9B) != par->VCLK3NumeratorLow)
50236 +                                || (vga_rgfx(NULL, 0x9F) != par->VCLK3Denominator)
50237 +                                || (clock_hi && ((vga_rgfx(NULL, 0x8F) & ~0x0f)
50238 +                                                 != (par->VCLK3NumeratorHigh &
50239                                                       ~0x0F))))) {
50240 -               VGAwGR(0x9B, par->VCLK3NumeratorLow);
50241 +               vga_wgfx(NULL, 0x9B, par->VCLK3NumeratorLow);
50242                 if (clock_hi) {
50243 -                       temp = VGArGR(0x8F);
50244 +                       temp = vga_rgfx(NULL, 0x8F);
50245                         temp &= 0x0F;   /* Save bits 3:0 */
50246                         temp |= (par->VCLK3NumeratorHigh & ~0x0F);
50247 -                       VGAwGR(0x8F, temp);
50248 +                       vga_wgfx(NULL, 0x8F, temp);
50249                 }
50250 -               VGAwGR(0x9F, par->VCLK3Denominator);
50251 +               vga_wgfx(NULL, 0x9F, par->VCLK3Denominator);
50252         }
50253  
50254         if (par->biosMode)
50255 -               VGAwCR(0x23, par->biosMode);
50256 +               vga_wcrt(NULL, 0x23, par->biosMode);
50257  
50258 -       VGAwGR(0x93, 0xc0);     /* Gives 5x faster framebuffer writes !!! */
50259 +       vga_wgfx(NULL, 0x93, 0xc0);     /* Gives 5x faster framebuffer writes !!! */
50260  
50261         /* Program vertical extension register */
50262         if (info->fix.accel == FB_ACCEL_NEOMAGIC_NM2200 ||
50263             info->fix.accel == FB_ACCEL_NEOMAGIC_NM2230 ||
50264             info->fix.accel == FB_ACCEL_NEOMAGIC_NM2360 ||
50265             info->fix.accel == FB_ACCEL_NEOMAGIC_NM2380) {
50266 -               VGAwCR(0x70, par->VerticalExt);
50267 +               vga_wcrt(NULL, 0x70, par->VerticalExt);
50268         }
50269  
50270         vgaHWProtect(0);        /* Turn on screen */
50271  
50272         /* Calling this also locks offset registers required in update_start */
50273 -       neoLock();
50274 +       neoLock(&par->state);
50275  
50276         info->fix.line_length =
50277             info->var.xres_virtual * (info->var.bits_per_pixel >> 3);
50278 @@ -1167,6 +1220,8 @@ static int neofb_set_par(struct fb_info 
50279  static void neofb_update_start(struct fb_info *info,
50280                                struct fb_var_screeninfo *var)
50281  {
50282 +       struct neofb_par *par = (struct neofb_par *) info->par;
50283 +       struct vgastate *state = &par->state;
50284         int oldExtCRTDispAddr;
50285         int Base;
50286  
50287 @@ -1180,18 +1235,18 @@ static void neofb_update_start(struct fb
50288         /*
50289          * These are the generic starting address registers.
50290          */
50291 -       VGAwCR(0x0C, (Base & 0x00FF00) >> 8);
50292 -       VGAwCR(0x0D, (Base & 0x00FF));
50293 +       vga_wcrt(state->vgabase, 0x0C, (Base & 0x00FF00) >> 8);
50294 +       vga_wcrt(state->vgabase, 0x0D, (Base & 0x00FF));
50295  
50296         /*
50297          * Make sure we don't clobber some other bits that might already
50298          * have been set. NOTE: NM2200 has a writable bit 3, but it shouldn't
50299          * be needed.
50300          */
50301 -       oldExtCRTDispAddr = VGArGR(0x0E);
50302 -       VGAwGR(0x0E, (((Base >> 16) & 0x0f) | (oldExtCRTDispAddr & 0xf0)));
50303 +       oldExtCRTDispAddr = vga_rgfx(NULL, 0x0E);
50304 +       vga_wgfx(state->vgabase, 0x0E, (((Base >> 16) & 0x0f) | (oldExtCRTDispAddr & 0xf0)));
50305  
50306 -       neoLock();
50307 +       neoLock(state);
50308  }
50309  
50310  /*
50311 @@ -1353,7 +1408,7 @@ neo2200_fillrect(struct fb_info *info, c
50312         }
50313  
50314         par->neo2200->dstStart =
50315 -           dst * ((info->var.bits_per_pixel + 7) / 8);
50316 +           dst * ((info->var.bits_per_pixel + 7) >> 3);
50317         par->neo2200->xyExt =
50318             (rect->height << 16) | (rect->width & 0xffff);
50319  }
50320 @@ -1361,24 +1416,20 @@ neo2200_fillrect(struct fb_info *info, c
50321  static void
50322  neo2200_copyarea(struct fb_info *info, const struct fb_copyarea *area)
50323  {
50324 -       struct neofb_par *par = (struct neofb_par *) info->par;
50325         u32 sx = area->sx, sy = area->sy, dx = area->dx, dy = area->dy;
50326 +       struct neofb_par *par = (struct neofb_par *) info->par;
50327         u_long src, dst, bltCntl;
50328  
50329         bltCntl = NEO_BC3_FIFO_EN | NEO_BC3_SKIP_MAPPING | 0x0C0000;
50330  
50331 -       if (sy < dy) {
50332 +       if ((dy > sy) || ((dy == sy) && (dx > sx))) {
50333 +               /* Start with the lower right corner */
50334                 sy += (area->height - 1);
50335                 dy += (area->height - 1);
50336 -
50337 -               bltCntl |= NEO_BC0_DST_Y_DEC | NEO_BC0_SRC_Y_DEC;
50338 -       }
50339 -
50340 -       if (area->sx < area->dx) {
50341                 sx += (area->width - 1);
50342                 dx += (area->width - 1);
50343  
50344 -               bltCntl |= NEO_BC0_X_DEC;
50345 +               bltCntl |= NEO_BC0_X_DEC | NEO_BC0_DST_Y_DEC | NEO_BC0_SRC_Y_DEC;
50346         }
50347  
50348         src = sx * (info->var.bits_per_pixel >> 3) + sy*info->fix.line_length;
50349 @@ -1496,8 +1547,60 @@ neofb_sync(struct fb_info *info)
50350         return 0;               
50351  }
50352  
50353 +static int
50354 +neofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
50355 +{
50356 +       struct neofb_par *par = (struct neofb_par *) info->par;
50357 +
50358 +       /* Disable cursor */
50359 +       write_le32(NEOREG_CURSCNTL, ~NEO_CURS_ENABLE, par);
50360 +
50361 +       if (cursor->set & FB_CUR_SETPOS) {
50362 +               u32 x = cursor->image.dx;
50363 +               u32 y = cursor->image.dy;
50364 +
50365 +               info->cursor.image.dx = x;
50366 +               info->cursor.image.dy = y;
50367 +               write_le32(NEOREG_CURSX, x, par);
50368 +               write_le32(NEOREG_CURSY, y, par);
50369 +       }
50370 +
50371 +       if (cursor->set & FB_CUR_SETSIZE) {
50372 +       }
50373 +
50374 +       if (cursor->set & FB_CUR_SETCMAP) {
50375 +               if (cursor->image.depth == 1) {
50376 +                       u32 fg = cursor->image.fg_color;
50377 +                       u32 bg = cursor->image.bg_color;
50378 +
50379 +                       info->cursor.image.fg_color = fg;
50380 +                       info->cursor.image.bg_color = bg;
50381 +
50382 +                       fg = ((fg & 0xff0000) >> 16) | ((fg & 0xff) << 16) | (fg & 0xff00);
50383 +                       bg = ((bg & 0xff0000) >> 16) | ((bg & 0xff) << 16) | (bg & 0xff00);
50384 +                       write_le32(NEOREG_CURSFGCOLOR, fg, par);
50385 +                       write_le32(NEOREG_CURSBGCOLOR, bg, par);
50386 +               }
50387 +       }
50388 +
50389 +       if (cursor->set & FB_CUR_SETSHAPE) {
50390 +               unsigned long dest = (unsigned long) par->cursorPad;
50391 +               int i, j;
50392 +
50393 +               //memset_io(par->cursorPad, 0xff, 1);
50394 +               //write_le32(NEOREG_CURSMEMPOS, ((0x000f & (dest >> 10)) << 8) |
50395 +               //              ((0x0ff0 & (dest >> 10)) >> 4), par);
50396 +       }
50397 +
50398 +       if (info->cursor.enable)
50399 +               write_le32(NEOREG_CURSCNTL, NEO_CURS_ENABLE, par);
50400 +       return 0;
50401 +}
50402 +
50403  static struct fb_ops neofb_ops = {
50404         .owner          = THIS_MODULE,
50405 +       .fb_open        = neofb_open,
50406 +       .fb_release     = neofb_release,
50407         .fb_check_var   = neofb_check_var,
50408         .fb_set_par     = neofb_set_par,
50409         .fb_setcolreg   = neofb_setcolreg,
50410 @@ -1507,7 +1610,7 @@ static struct fb_ops neofb_ops = {
50411         .fb_fillrect    = neofb_fillrect,
50412         .fb_copyarea    = neofb_copyarea,
50413         .fb_imageblit   = neofb_imageblit,
50414 -       .fb_cursor      = soft_cursor,
50415 +       .fb_cursor      = neofb_cursor,
50416  };
50417  
50418  /* --------------------------------------------------------------------- */
50419 @@ -1650,6 +1753,7 @@ static int __devinit neo_map_video(struc
50420                                    struct pci_dev *dev, int video_len)
50421  {
50422         struct neofb_par *par = (struct neofb_par *) info->par;
50423 +       unsigned long addr;
50424  
50425         DBG("neo_map_video");
50426  
50427 @@ -1681,6 +1785,10 @@ static int __devinit neo_map_video(struc
50428  
50429         /* Clear framebuffer, it's all white in memory after boot */
50430         memset(info->screen_base, 0, info->fix.smem_len);
50431 +
50432 +       /* Allocate Cursor drawing pad. */
50433 +       addr = info->fix.smem_start + info->fix.smem_len;
50434 +       par->cursorPad = (u8 *) ioremap(addr, info->sprite.size);
50435         return 0;
50436  }
50437  
50438 @@ -1725,16 +1833,16 @@ static int __devinit neo_init_hw(struct 
50439         printk(KERN_DEBUG "--- Neo extended register dump ---\n");
50440         for (w = 0; w < 0x85; w++)
50441                 printk(KERN_DEBUG "CR %p: %p\n", (void *) w,
50442 -                      (void *) VGArCR(w));
50443 +                      (void *) vga_rcrt(NULL, w);
50444         for (w = 0; w < 0xC7; w++)
50445                 printk(KERN_DEBUG "GR %p: %p\n", (void *) w,
50446 -                      (void *) VGArGR(w));
50447 +                      (void *) vga_rgfx(NULL, w));
50448  #endif
50449  
50450         /* Determine the panel type */
50451 -       VGAwGR(0x09, 0x26);
50452 -       type = VGArGR(0x21);
50453 -       display = VGArGR(0x20);
50454 +       vga_wgfx(NULL, 0x09, 0x26);
50455 +       type = vga_rgfx(NULL, 0x21);
50456 +       display = vga_rgfx(NULL, 0x20);
50457         if (!par->internal_display && !par->external_display) {
50458                 par->internal_display = display & 2 || !(display & 3) ? 1 : 0;
50459                 par->external_display = display & 1;
50460 @@ -1744,8 +1852,8 @@ static int __devinit neo_init_hw(struct 
50461         }
50462  
50463         /* Determine panel width -- used in NeoValidMode. */
50464 -       w = VGArGR(0x20);
50465 -       VGAwGR(0x09, 0x00);
50466 +       w = vga_rgfx(NULL, 0x20);
50467 +       vga_wgfx(NULL, 0x09, 0x00);
50468         switch ((w & 0x18) >> 3) {
50469         case 0x00:
50470                 par->NeoPanelWidth = 640;
50471 @@ -1870,10 +1978,20 @@ static int __devinit neo_init_hw(struct 
50472                 par->neo2200 = (Neo2200 *) par->mmio_vbase;
50473                 break;
50474         }
50475 -
50476 +       info->sprite.size = CursorMem;
50477 +       info->sprite.addr = kmalloc(CursorMem, GFP_KERNEL);
50478 +       info->sprite.scan_align = 1;
50479 +       info->sprite.buf_align = 1;
50480 +       info->sprite.flags = FB_PIXMAP_IO;
50481         par->maxClock = maxClock;
50482 -
50483 -       return videoRam * 1024;
50484 +       par->cursorOff = CursorOff;
50485 +       /*
50486 +        * We decrease the size of the framebuffer by a page
50487 +        * instead of the size of the cursor pad to avoid
50488 +        * userland being able to page fault the cursor
50489 +        * region and start drawing in it.
50490 +        */
50491 +       return ((videoRam * 1024) - PAGE_SIZE);
50492  }
50493  
50494  
50495 --- linux-2.6.0-test6/drivers/video/platinumfb.c        2003-09-08 13:58:58.000000000 -0700
50496 +++ 25/drivers/video/platinumfb.c       2003-10-05 00:34:22.000000000 -0700
50497 @@ -104,9 +104,6 @@ static int platinum_var_to_par(const str
50498   * Interface used by the world
50499   */
50500  
50501 -int platinum_init(void);
50502 -int platinum_setup(char*);
50503 -
50504  static struct fb_ops platinumfb_ops = {
50505         .owner =        THIS_MODULE,
50506         .fb_check_var   = platinumfb_check_var,
50507 @@ -492,7 +489,7 @@ static int platinum_par_to_var(struct fb
50508  /* 
50509   * Parse user speficied options (`video=platinumfb:')
50510   */
50511 -int __init platinum_setup(char *options)
50512 +int __init platinumfb_setup(char *options)
50513  {
50514         char *this_opt;
50515  
50516 @@ -672,7 +669,7 @@ static struct of_platform_driver platinu
50517         .remove         = platinumfb_remove,
50518  };
50519  
50520 -int __init platinum_init(void)
50521 +int __init platinumfb_init(void)
50522  {
50523         of_register_driver(&platinum_driver);
50524  
50525 --- linux-2.6.0-test6/drivers/video/pm3fb.c     2003-06-14 12:18:02.000000000 -0700
50526 +++ 25/drivers/video/pm3fb.c    2003-10-05 00:33:24.000000000 -0700
50527 @@ -54,7 +54,6 @@
50528  
50529  #include <linux/config.h>
50530  #include <linux/module.h>
50531 -#include <linux/version.h>
50532  #include <linux/kernel.h>
50533  #include <linux/errno.h>
50534  #include <linux/string.h>
50535 --- linux-2.6.0-test6/drivers/video/pvr2fb.c    2003-07-27 12:14:40.000000000 -0700
50536 +++ 25/drivers/video/pvr2fb.c   2003-10-05 00:34:22.000000000 -0700
50537 @@ -166,6 +166,11 @@ static u_long videomemory = 0xa5000000, 
50538  static int cable_type = -1;
50539  static int video_output = -1;
50540  
50541 +#ifdef CONFIG_MTRR
50542 +static int enable_mtrr = 1;
50543 +static int mtrr_handle;
50544 +#endif
50545 +
50546  static int nopan = 0;
50547  static int nowrap = 1;
50548  
50549 @@ -385,6 +390,7 @@ static int pvr2fb_set_par(struct fb_info
50550  
50551  static int pvr2fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
50552  {
50553 +       struct pvr2fb_par *par = (struct pvr2fb_par *)info->par;
50554         u_short vtotal, hsync_total;
50555         u_long line_length;
50556  
50557 @@ -413,7 +419,7 @@ static int pvr2fb_check_var(struct fb_va
50558  
50559         if (var->vmode & FB_VMODE_YWRAP) {
50560                 if (var->xoffset || var->yoffset < 0 || 
50561 -                   var->yoffset >= var->yres_virtual) {
50562 +                   var->yoffset >= var->yres_virtual)
50563                         var->xoffset = var->yoffset = 0;
50564                 } else {
50565                         if (var->xoffset > var->xres_virtual - var->xres ||
50566 @@ -421,9 +427,8 @@ static int pvr2fb_check_var(struct fb_va
50567                             var->xoffset < 0 || var->yoffset < 0)
50568                                 var->xoffset = var->yoffset = 0;
50569                 }
50570 -       } else {
50571 +       } else
50572                 var->xoffset = var->yoffset = 0;
50573 -       }
50574  
50575         /* 
50576          * XXX: Need to be more creative with this (i.e. allow doublecan for
50577 @@ -456,7 +461,6 @@ static int pvr2fb_check_var(struct fb_va
50578                                 DPRINTK("invalid hsync total for NTSC\n");
50579                                 return -EINVAL;
50580                         }
50581 -               }
50582         }
50583         /* Check memory sizes */
50584         line_length = get_line_length(var->xres_virtual, var->bits_per_pixel);
50585 @@ -599,10 +603,10 @@ static int pvr2_init_cable(void)
50586  
50587  int __init pvr2fb_init(void)
50588  {
50589 +       struct fb_var_screeninfo var;
50590         u_long modememused;
50591 -       int err = -EINVAL;
50592  
50593 -       if (!mach_is_dreamcast())
50594 +       if (!MACH_DREAMCAST)
50595                 return -ENXIO;
50596  
50597         fb_info = kmalloc(sizeof(struct fb_info) + sizeof(struct pvr2fb_par) +
50598 @@ -650,8 +654,8 @@ int __init pvr2fb_init(void)
50599         
50600         if (!fb_info->screen_base) {
50601                 printk("Failed to remap MMIO space\n");
50602 -               err = -ENXIO;
50603 -               goto out_err;
50604 +               kfree(fb_info);
50605 +               return -ENXIO;
50606         }
50607  
50608         memset_io((unsigned long)fb_info->screen_base, 0, pvr2_fix.smem_len);
50609 @@ -665,6 +669,8 @@ int __init pvr2fb_init(void)
50610         fb_info->pseudo_palette = (void *)(fb_info->par + 1);
50611         fb_info->flags          = FBINFO_FLAG_DEFAULT;
50612  
50613 +       memset(&var, 0, sizeof(var));
50614 +
50615         if (video_output == VO_VGA)
50616                 defmode = DEFMODE_VGA;
50617  
50618 @@ -677,41 +683,46 @@ int __init pvr2fb_init(void)
50619  
50620         if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0,
50621                         "pvr2 VBL handler", fb_info)) {
50622 -               err = -EBUSY;
50623 -               goto out_err;
50624 +               DPRINTK("couldn't register VBL int\n");
50625 +               kfree(fb_info);
50626 +               return  -EBUSY;
50627         }
50628  
50629 -       if (register_framebuffer(fb_info) < 0)
50630 -               goto reg_failed;
50631 +#ifdef CONFIG_MTRR
50632 +       if (enable_mtrr) {
50633 +               mtrr_handle = mtrr_add(videomemory, videomemorysize, MTRR_TYPE_WRCOMB, 1);
50634 +               printk("pvr2fb: MTRR turned on\n");
50635 +       }
50636 +#endif
50637  
50638 -       modememused = get_line_length(fb_info->var.xres_virtual,
50639 -                                     fb_info->var.bits_per_pixel);
50640 -       modememused *= fb_info->var.yres_virtual;
50641 +       if (register_framebuffer(fb_info) < 0) {
50642 +               kfree(fb_info);
50643 +               return -EINVAL;
50644 +       }
50645  
50646 +       modememused = get_line_length(var.xres_virtual, var.bits_per_pixel);
50647 +       modememused *= var.yres_virtual;
50648         printk("fb%d: %s frame buffer device, using %ldk/%ldk of video memory\n",
50649                fb_info->node, fb_info->fix.id, modememused>>10,
50650                videomemorysize>>10);
50651         printk("fb%d: Mode %dx%d-%d pitch = %ld cable: %s video output: %s\n", 
50652 -              fb_info->node, fb_info->var.xres, fb_info->var.yres,
50653 -              fb_info->var.bits_per_pixel, 
50654 -              get_line_length(fb_info->var.xres, fb_info->var.bits_per_pixel),
50655 +              fb_info->node, var.xres, var.yres, var.bits_per_pixel,
50656 +              get_line_length(var.xres, var.bits_per_pixel),
50657                (char *)pvr2_get_param(cables, NULL, cable_type, 3),
50658                (char *)pvr2_get_param(outputs, NULL, video_output, 3));
50659  
50660         return 0;
50661 -
50662 -reg_failed:
50663 -       free_irq(HW_EVENT_VSYNC, 0);
50664 -out_err:
50665 -       kfree(fb_info);
50666 -
50667 -       return err;
50668  }
50669  
50670  static void __exit pvr2fb_exit(void)
50671  {
50672 +#ifdef CONFIG_MTRR
50673 +       if (enable_mtrr) {
50674 +               mtrr_del(mtrr_handle, videomemory, videomemorysize);
50675 +               printk("pvr2fb: MTRR turned off\n");
50676 +       }
50677 +#endif
50678         unregister_framebuffer(fb_info);
50679 -       free_irq(HW_EVENT_VSYNC, 0);
50680         kfree(fb_info);
50681  }
50682  
50683 @@ -767,6 +778,10 @@ int __init pvr2fb_setup(char *options)
50684                         nopan = 1;
50685                 } else if (!strncmp(this_opt, "nowrap", 6)) {
50686                         nowrap = 1;
50687 +#ifdef CONFIG_MTRR
50688 +               } else if (!strncmp(this_opt, "nomtrr", 6)) {
50689 +                       enable_mtrr = 0;
50690 +#endif
50691                 } else {
50692                         mode_option = this_opt;
50693                 }
50694 --- linux-2.6.0-test6/drivers/video/radeonfb.c  2003-08-08 22:55:13.000000000 -0700
50695 +++ 25/drivers/video/radeonfb.c 2003-10-05 00:34:47.000000000 -0700
50696 @@ -1099,7 +1099,7 @@ static int radeon_get_dfpinfo_BIOS(struc
50697         printk("radeonfb: detected DFP panel size from BIOS: %dx%d\n",
50698                 rinfo->panel_xres, rinfo->panel_yres);
50699  
50700 -       for(i=0; i<20; i++) {
50701 +       for(i=0; i<21; i++) {
50702                 tmp0 = rinfo->bios_seg + readw(tmp+64+i*2);
50703                 if (tmp0 == 0)
50704                         break;
50705 @@ -2090,7 +2090,7 @@ static int radeonfb_set_par (struct fb_i
50706         
50707         }
50708         /* Update fix */
50709 -        info->fix.line_length = rinfo->pitch*64;
50710 +        info->fix.line_length = mode->xres_virtual*(mode->bits_per_pixel/8);
50711          info->fix.visual = rinfo->depth == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
50712  
50713  #ifdef CONFIG_BOOTX_TEXT
50714 --- linux-2.6.0-test6/drivers/video/riva/fbdev.c        2003-09-27 18:57:46.000000000 -0700
50715 +++ 25/drivers/video/riva/fbdev.c       2003-10-05 00:34:22.000000000 -0700
50716 @@ -143,7 +143,17 @@ enum riva_chips {
50717         CH_GEFORCE4_TI_4200,
50718         CH_QUADRO4_900XGL,
50719         CH_QUADRO4_750XGL,
50720 -       CH_QUADRO4_700XGL
50721 +       CH_QUADRO4_700XGL,
50722 +       CH_GEFORCE4_TI_4800,
50723 +       CH_GEFORCE4_TI_4280,
50724 +       CH_GEFORCE4_TI_4800SE,
50725 +       CH_GEFORCE4_4200_GO,
50726 +       CH_GEFORCE_FX_5800_U,
50727 +       CH_GEFORCE_FX_5800,
50728 +       CH_GEFORCE_FX_5600_U,
50729 +       CH_GEFORCE_FX_5600,
50730 +       CH_GEFORCE_FX_5200_U,
50731 +       CH_GEFORCE_FX_5200
50732  };
50733  
50734  /* directly indexed by riva_chips enum, above */
50735 @@ -190,7 +200,17 @@ static struct riva_chip_info {
50736         { "GeForce4 Ti 4200", NV_ARCH_20 },
50737         { "Quadro4-900-XGL", NV_ARCH_20 },
50738         { "Quadro4-750-XGL", NV_ARCH_20 },
50739 -       { "Quadro4-700-XGL", NV_ARCH_20 }
50740 +       { "Quadro4-700-XGL", NV_ARCH_20 },
50741 +       { "GeForce4 Ti 4800", NV_ARCH_20 },
50742 +       { "GeForce4 Ti 4280", NV_ARCH_20},
50743 +       { "GeForce4 Ti 4800 SE", NV_ARCH_20},
50744 +       { "GeForce4 4200 GO", NV_ARCH_20},
50745 +       { "GeForce FX 5800 ULTRA", NV_ARCH_20},
50746 +       { "GeForce FX 5800", NV_ARCH_20},
50747 +       { "GeForce FX 5600 ULTRA", NV_ARCH_20},
50748 +       { "GeForce FX 5600", NV_ARCH_20},
50749 +       { "GeForce FX 5200 ULTRA", NV_ARCH_20},
50750 +       { "GeForce FX 5200", NV_ARCH_20}
50751  };
50752  
50753  static struct pci_device_id rivafb_pci_tbl[] = {
50754 @@ -274,6 +294,26 @@ static struct pci_device_id rivafb_pci_t
50755           PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO4_750XGL },
50756         { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL,
50757           PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO4_700XGL },
50758 +       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800,
50759 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE4_TI_4800 },
50760 +       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4280,
50761 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE4_TI_4280 },
50762 +       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800_SE,
50763 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE4_TI_4800SE },
50764 +       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_4200_GO,
50765 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE4_4200_GO },
50766 +       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800_U,
50767 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE_FX_5800_U },
50768 +       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800,
50769 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE_FX_5800 },
50770 +       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600_U,
50771 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE_FX_5600_U },
50772 +       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600,
50773 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE_FX_5600 },
50774 +       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200_U,
50775 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE_FX_5200_U },
50776 +       { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200,
50777 +         PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE_FX_5200 },
50778         { 0, } /* terminate list */
50779  };
50780  MODULE_DEVICE_TABLE(pci, rivafb_pci_tbl);
50781 @@ -1469,8 +1509,6 @@ static void rivafb_imageblit(struct fb_i
50782  static int rivafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
50783  {
50784         struct riva_par *par = (struct riva_par *) info->par;
50785 -       u8 data[MAX_CURS * MAX_CURS/8];
50786 -       u8 mask[MAX_CURS * MAX_CURS/8];
50787         u16 fg, bg;
50788         int i;
50789  
50790 @@ -1492,7 +1530,6 @@ static int rivafb_cursor(struct fb_info 
50791         if (cursor->set & FB_CUR_SETSIZE) {
50792                 info->cursor.image.height = cursor->image.height;
50793                 info->cursor.image.width = cursor->image.width;
50794 -               memset_io(par->riva.CURSOR, 0, MAX_CURS * MAX_CURS * 2);
50795         }
50796  
50797         if (cursor->set & FB_CUR_SETCMAP) {
50798 @@ -1503,29 +1540,22 @@ static int rivafb_cursor(struct fb_info 
50799         if (cursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETCMAP)) {
50800                 u32 bg_idx = info->cursor.image.bg_color;
50801                 u32 fg_idx = info->cursor.image.fg_color;
50802 -               u32 s_pitch = (info->cursor.image.width+7) >> 3;
50803 -               u32 d_pitch = MAX_CURS/8;
50804 -               u8 *dat = (u8 *) cursor->image.data;
50805 +               u8 *dat = (u8 *) info->cursor.image.data;
50806                 u8 *msk = (u8 *) info->cursor.mask;
50807                 u8 src[64];     
50808                 
50809                 switch (info->cursor.rop) {
50810                 case ROP_XOR:
50811 -                       for (i = 0; i < s_pitch * info->cursor.image.height; i++)
50812 +                       for (i = 0; i < info->sprite.size; i++)
50813                                         src[i] = dat[i] ^ msk[i];
50814                         break;
50815                 case ROP_COPY:
50816                 default:
50817 -                       for (i = 0; i < s_pitch * info->cursor.image.height; i++)
50818 -                               
50819 +                       for (i = 0; i < info->sprite.size; i++)
50820                                         src[i] = dat[i] & msk[i];
50821                         break;
50822                 }
50823                 
50824 -               move_buf_aligned(info, data, src, d_pitch, s_pitch, info->cursor.image.height);
50825 -
50826 -               move_buf_aligned(info, mask, msk, d_pitch, s_pitch, info->cursor.image.height);
50827 -
50828                 bg = ((info->cmap.red[bg_idx] & 0xf8) << 7) |
50829                      ((info->cmap.green[bg_idx] & 0xf8) << 2) |
50830                      ((info->cmap.blue[bg_idx] & 0xf8) >> 3);
50831 @@ -1536,7 +1566,7 @@ static int rivafb_cursor(struct fb_info 
50832  
50833                 par->riva.LockUnlock(&par->riva, 0);
50834  
50835 -               rivafb_load_cursor_image(par, data, mask, bg, fg,
50836 +               rivafb_load_cursor_image(par, dat, msk, bg, fg,
50837                                          info->cursor.image.width, 
50838                                          info->cursor.image.height);
50839         }
50840 @@ -1572,7 +1602,7 @@ static struct fb_ops riva_fb_ops = {
50841         .fb_fillrect    = rivafb_fillrect,
50842         .fb_copyarea    = rivafb_copyarea,
50843         .fb_imageblit   = rivafb_imageblit,
50844 -       .fb_cursor      = rivafb_cursor,        
50845 +       .fb_cursor      = soft_cursor,
50846         .fb_sync        = rivafb_sync,
50847  };
50848  
50849 @@ -1603,6 +1633,15 @@ static int __devinit riva_set_fbinfo(str
50850         info->pixmap.buf_align = 4;
50851         info->pixmap.scan_align = 4;
50852         info->pixmap.flags = FB_PIXMAP_SYSTEM;
50853 +/*
50854 +       info->sprite.addr = (char *) par->riva.CURSOR;
50855 +       info->sprite.size = MAX_CURS * MAX_CURS * 2;
50856 +       info->sprite.buf_align = info->sprite.size;
50857 +       info->sprite.scan_align = MAX_CURS >> 3;
50858 +       info->sprite.access_align = 2;
50859 +       info->sprite.flags = FB_PIXMAP_IO;
50860 +       memset_io(par->riva.CURSOR, 0, MAX_CURS * MAX_CURS * 2);
50861 +*/
50862         return 0;
50863  }
50864  
50865 --- linux-2.6.0-test6/drivers/video/riva/nv_type.h      2003-06-14 12:18:08.000000000 -0700
50866 +++ 25/drivers/video/riva/nv_type.h     2003-10-05 00:34:22.000000000 -0700
50867 @@ -50,8 +50,16 @@
50868  #define NV_CHIP_QUADRO4_900XGL      ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL)
50869  #define NV_CHIP_QUADRO4_750XGL      ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL)
50870  #define NV_CHIP_QUADRO4_700XGL      ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL)
50871 -#define NV_CHIP_0x0280              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x0280)
50872 -#define NV_CHIP_0x0281              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x0281)
50873 +#define NV_CHIP_GEFORCE4_TI_4800    ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800)
50874 +#define NV_CHIP_GEFORCE4_TI_4280    ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4280)
50875 +#define NV_CHIP_GEFORCE4_TI_4800SE  ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800_SE)
50876 +#define NV_CHIP_GEFORCE4_4200_GO    ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE4_4200_GO)
50877 +#define NV_CHIP_GEFORCE_FX_5800_U   ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800_U)
50878 +#define NV_CHIP_GEFORCE_FX_5800     ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800)
50879 +#define NV_CHIP_GEFORCE_FX_5600_U   ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600_U)
50880 +#define NV_CHIP_GEFORCE_FX_5600     ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600)
50881 +#define NV_CHIP_GEFORCE_FX_5200_U   ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200_U)
50882 +#define NV_CHIP_GEFORCE_FX_5200     ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200)
50883  #define NV_CHIP_0x0288              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x0288)
50884  #define NV_CHIP_0x0289              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x0289)
50885  
50886 --- linux-2.6.0-test6/drivers/video/sis/300vtbl.h       2003-06-14 12:17:59.000000000 -0700
50887 +++ 25/drivers/video/sis/300vtbl.h      2003-10-05 00:34:22.000000000 -0700
50888 @@ -1,7 +1,37 @@
50889 -
50890 -
50891 -/* Register settings for SiS 300 series */
50892 -
50893 +/* $XFree86$ */
50894 +/*
50895 + * Register settings for SiS 300 series
50896 + *
50897 + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
50898 + *
50899 + * If distributed as part of the linux kernel, the contents of this file
50900 + * is entirely covered by the GPL.
50901 + *
50902 + * Otherwise, the following terms apply:
50903 + *
50904 + * Permission to use, copy, modify, distribute, and sell this software and its
50905 + * documentation for any purpose is hereby granted without fee, provided that
50906 + * the above copyright notice appear in all copies and that both that
50907 + * copyright notice and this permission notice appear in supporting
50908 + * documentation, and that the name of the copyright holder not be used in
50909 + * advertising or publicity pertaining to distribution of the software without
50910 + * specific, written prior permission.  The copyright holder makes no representations
50911 + * about the suitability of this software for any purpose.  It is provided
50912 + * "as is" without express or implied warranty.
50913 + *
50914 + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
50915 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
50916 + * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
50917 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
50918 + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
50919 + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
50920 + * PERFORMANCE OF THIS SOFTWARE.
50921 + *
50922 + * Author:     Thomas Winischhofer <thomas@winischhofer.net>
50923 + *
50924 + * Based on code by Silicon Intergrated Systems
50925 + *
50926 + */
50927  
50928  typedef struct _SiS300_StStruct
50929  {
50930 @@ -39,470 +69,109 @@ static const SiS300_StStruct  SiS300_SMo
50931         {0xff,     0,   0,   0,   0,   0,   0,   0}
50932  };
50933  
50934 -typedef struct _SiS300_StandTableStruct
50935 -{
50936 -       UCHAR CRT_COLS;
50937 -       UCHAR ROWS;
50938 -       UCHAR CHAR_HEIGHT;
50939 -       USHORT CRT_LEN;
50940 -       UCHAR SR[4];
50941 -       UCHAR MISC;
50942 -       UCHAR CRTC[0x19];
50943 -       UCHAR ATTR[0x14];
50944 -       UCHAR GRC[9];
50945 -} SiS300_StandTableStruct;
50946 -
50947 -static const SiS300_StandTableStruct  SiS300_StandTable[] =
50948 -{
50949 - {0x28,0x18,0x08,0x0800,                       /* 0x00 */
50950 -  {0x09,0x03,0x00,0x02},
50951 -  0x63,
50952 -  {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
50953 -   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
50954 -   0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
50955 -   0xff},
50956 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
50957 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
50958 -   0x08,0x00,0x0f,0x00},
50959 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
50960 -   0xff} },
50961 - {0x28,0x18,0x08,0x0800,                       /* 0x01 */
50962 -  {0x09,0x03,0x00,0x02},
50963 -  0x63,
50964 -  {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
50965 -   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
50966 -   0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
50967 -   0xff},
50968 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
50969 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
50970 -   0x08,0x00,0x0f,0x00},
50971 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
50972 -   0xff} },
50973 - {0x50,0x18,0x08,0x1000,                       /* 0x02 */
50974 -  {0x01,0x03,0x00,0x02},
50975 -  0x63,
50976 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
50977 -   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
50978 -   0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
50979 -   0xff},
50980 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
50981 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
50982 -   0x08,0x00,0x0f,0x00},
50983 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
50984 -   0xff} },
50985 - {0x50,0x18,0x08,0x1000,                       /* 0x03 */
50986 -  {0x01,0x03,0x00,0x02},
50987 -  0x63,
50988 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
50989 -   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
50990 -   0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
50991 -   0xff},
50992 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
50993 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
50994 -   0x08,0x00,0x0f,0x00},
50995 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
50996 -   0xff} },
50997 - {0x28,0x18,0x08,0x4000,                       /* 0x04 */
50998 -  {0x09,0x03,0x00,0x02},
50999 -  0x63,
51000 -  {0x2d,0x27,0x28,0x90,0x2b,0x80,0xbf,0x1f,
51001 -   0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
51002 -   0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2,
51003 -   0xff},
51004 -  {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07,
51005 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
51006 -   0x01,0x00,0x03,0x00},
51007 -  {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,
51008 -   0xff} },
51009 - {0x28,0x18,0x08,0x4000,                       /* 0x05 */
51010 -  {0x09,0x03,0x00,0x02},
51011 -  0x63,
51012 -  {0x2d,0x27,0x28,0x90,0x2b,0x80,0xbf,0x1f,
51013 -   0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
51014 -   0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2,
51015 -   0xff},
51016 -  {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07,
51017 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
51018 -   0x01,0x00,0x03,0x00},
51019 -  {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,
51020 -   0xff} },
51021 - {0x50,0x18,0x08,0x4000,                       /* 0x06 */
51022 -  {0x01,0x01,0x00,0x06},
51023 -  0x63,
51024 -  {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f,
51025 -   0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
51026 -   0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xc2,
51027 -   0xff},
51028 -  {0x00,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
51029 -   0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
51030 -   0x01,0x00,0x01,0x00},
51031 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00,
51032 -   0xff} },
51033 - {0x50,0x18,0x0e,0x1000,                       /* 0x07 */
51034 -  {0x00,0x03,0x00,0x03},
51035 -  0xa6,
51036 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
51037 -   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
51038 -   0x83,0x85,0x5d,0x28,0x0d,0x63,0xba,0xa3,
51039 -   0xff},
51040 -  {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
51041 -   0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
51042 -   0x0e,0x00,0x0f,0x08},
51043 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,
51044 -   0xff} },
51045 -/* MDA_DAC*/
51046 - {0x00,0x00,0x00,0x0000,                       /* 0x08 */
51047 -  {0x00,0x00,0x00,0x15},
51048 -  0x15,
51049 -  {0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
51050 -   0x15,0x15,0x15,0x15,0x15,0x15,0x3f,0x3f,
51051 -   0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,
51052 -   0x00},
51053 -  {0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15,
51054 -   0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
51055 -   0x15,0x15,0x15,0x15},
51056 -  {0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
51057 -   0x3f} },
51058 -/* CGA_DAC*/
51059 - {0x00,0x10,0x04,0x0114,                       /* 0x09 */
51060 -  {0x11,0x09,0x15,0x00},
51061 -  0x10,
51062 -  {0x04,0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,
51063 -   0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x2a,0x3a,
51064 -   0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x10,
51065 -   0x04},
51066 -  {0x14,0x01,0x11,0x09,0x15,0x00,0x10,0x04,
51067 -   0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,0x2e,
51068 -   0x3e,0x2b,0x3b,0x2f},
51069 -  {0x3f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f,
51070 -   0x3f} },
51071 -/* EGA_DAC*/
51072 - {0x00,0x10,0x04,0x0114,                       /* 0x0a */
51073 -  {0x11,0x05,0x15,0x20},
51074 -  0x30,
51075 -  {0x24,0x34,0x21,0x31,0x25,0x35,0x08,0x18,
51076 -   0x0c,0x1c,0x09,0x19,0x0d,0x1d,0x28,0x38,
51077 -   0x2c,0x3c,0x29,0x39,0x2d,0x3d,0x02,0x12,
51078 -   0x06},
51079 -  {0x16,0x03,0x13,0x07,0x17,0x22,0x32,0x26,
51080 -   0x36,0x23,0x33,0x27,0x37,0x0a,0x1a,0x0e,
51081 -   0x1e,0x0b,0x1b,0x0f},
51082 -  {0x1f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f,
51083 -   0x3f} },
51084 -/* VGA_DAC*/
51085 - {0x00,0x10,0x04,0x0114,                       /* 0x0b */
51086 -  {0x11,0x09,0x15,0x2a},
51087 -  0x3a,
51088 -  {0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x05,
51089 -   0x08,0x0b,0x0e,0x11,0x14,0x18,0x1c,0x20,
51090 -   0x24,0x28,0x2d,0x32,0x38,0x3f,0x00,0x10,
51091 -   0x1f},
51092 -  {0x2f,0x3f,0x1f,0x27,0x2f,0x37,0x3f,0x2d,
51093 -   0x31,0x36,0x3a,0x3f,0x00,0x07,0x0e,0x15,
51094 -   0x1c,0x0e,0x11,0x15},
51095 -  {0x18,0x1c,0x14,0x16,0x18,0x1a,0x1c,0x00,
51096 -   0x04} },
51097 - {0x08,0x0c,0x10,0x0a08,                       /* 0x0c */
51098 -  {0x0c,0x0e,0x10,0x0b},
51099 -  0x0c,
51100 -  {0x0d,0x0f,0x10,0x10,0x01,0x08,0x00,0x00,
51101 -   0x00,0x00,0x01,0x00,0x02,0x02,0x01,0x00,
51102 -   0x04,0x04,0x01,0x00,0x05,0x02,0x05,0x00,
51103 -   0x06},
51104 -  {0x01,0x06,0x05,0x06,0x00,0x08,0x01,0x08,
51105 -   0x00,0x07,0x02,0x07,0x06,0x07,0x00,0x00,
51106 -   0x00,0x00,0x00,0x00},
51107 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
51108 -   0x00} },
51109 - {0x28,0x18,0x08,0x2000,                       /* 0x0d */
51110 -  {0x09,0x0f,0x00,0x06},
51111 -  0x63,
51112 -  {0x2d,0x27,0x28,0x90,0x2b,0x80,0xbf,0x1f,
51113 -   0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
51114 -   0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xe3,
51115 -   0xff},
51116 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
51117 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
51118 -   0x01,0x00,0x0f,0x00},
51119 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
51120 -   0xff} },
51121 - {0x50,0x18,0x08,0x4000,                       /* 0x0e */
51122 -  {0x01,0x0f,0x00,0x06},
51123 -  0x63,
51124 -  {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f,
51125 -   0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
51126 -   0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xe3,
51127 -   0xff},
51128 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
51129 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
51130 -   0x01,0x00,0x0f,0x00},
51131 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
51132 -   0xff} },
51133 - {0x00,0x00,0x00,0x0000,                       /* 0x0f */      /* TW: Standtable for VGA modes */
51134 -  {0x01,0x0f,0x00,0x0e},
51135 -  0x23,
51136 -  {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e,
51137 -   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
51138 -   0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3,
51139 -   0xff},
51140 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
51141 -   0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
51142 -   0x01,0x00,0x00,0x00},
51143 -  {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,
51144 -   0xff} },
51145 - {0x4a,0x36,0x00,0x00c0,                       /* 0x10 */
51146 -  {0x00,0x00,0x00,0x00},
51147 -  0x00,
51148 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x3a,
51149 -   0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
51150 -   0x00,0x00,0x1a,0x00,0x57,0x39,0x00,0xc0,
51151 -   0x00},
51152 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
51153 -   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
51154 -   0x00,0x00,0x00,0x00},
51155 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
51156 -   0x00} },
51157 - {0x50,0x18,0x0e,0x8000,                       /* 0x11 */
51158 -  {0x01,0x0f,0x00,0x06},
51159 -  0xa2,
51160 -  {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f,
51161 -   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
51162 -   0x83,0x85,0x5d,0x28,0x0f,0x63,0xba,0xe3,
51163 -   0xff},
51164 -  {0x00,0x08,0x00,0x00,0x18,0x18,0x00,0x00,
51165 -   0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00,
51166 -   0x0b,0x00,0x05,0x00},
51167 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,
51168 -   0xff} },
51169 - {0x50,0x18,0x0e,0x8000,                       /* 0x12 */
51170 -  {0x01,0x0f,0x00,0x06},
51171 -  0xa3,
51172 -  {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f,
51173 -   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
51174 -   0x83,0x85,0x5d,0x28,0x0f,0x63,0xba,0xe3,
51175 -   0xff},
51176 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
51177 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
51178 -   0x01,0x00,0x0f,0x00},
51179 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
51180 -   0xff} },
51181 - {0x28,0x18,0x0e,0x0800,                       /* 0x13 */
51182 -  {0x09,0x03,0x00,0x02},
51183 -  0xa3,
51184 -  {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
51185 -   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
51186 -   0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3,
51187 -   0xff},
51188 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
51189 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
51190 -   0x08,0x00,0x0f,0x00},
51191 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
51192 -   0xff} },
51193 - {0x28,0x18,0x0e,0x0800,                       /* 0x14 */
51194 -  {0x09,0x03,0x00,0x02},
51195 -  0xa3,
51196 -  {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
51197 -   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
51198 -   0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3,
51199 -   0xff},
51200 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
51201 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
51202 -   0x08,0x00,0x0f,0x00},
51203 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
51204 -   0xff} },
51205 - {0x50,0x18,0x0e,0x1000,                       /* 0x15 */
51206 -  {0x01,0x03,0x00,0x02},
51207 -  0xa3,
51208 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
51209 -   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
51210 -   0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3,
51211 -   0xff},
51212 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
51213 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
51214 -   0x08,0x00,0x0f,0x00},
51215 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
51216 -   0xff} },
51217 - {0x50,0x18,0x0e,0x1000,                       /* 0x16 */
51218 -  {0x01,0x03,0x00,0x02},
51219 -  0xa3,
51220 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
51221 -   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
51222 -   0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3,
51223 -   0xff},
51224 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
51225 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
51226 -   0x08,0x00,0x0f,0x00},
51227 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
51228 -   0xff} },
51229 - {0x28,0x18,0x10,0x0800,                       /* 0x17 */
51230 -  {0x08,0x03,0x00,0x02},
51231 -  0x67,
51232 -  {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
51233 -   0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
51234 -   0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
51235 -   0xff},
51236 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
51237 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
51238 -   0x0c,0x00,0x0f,0x08},
51239 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
51240 -   0xff} },
51241 - {0x50,0x18,0x10,0x1000,                       /* 0x18 */
51242 -  {0x00,0x03,0x00,0x02},
51243 -  0x67,
51244 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
51245 -   0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
51246 -   0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
51247 -   0xff},
51248 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
51249 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
51250 -   0x0c,0x00,0x0f,0x08},
51251 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
51252 -   0xff} },
51253 - {0x50,0x18,0x10,0x1000,                       /* 0x19 */
51254 -  {0x00,0x03,0x00,0x02},
51255 -  0x66,
51256 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
51257 -   0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
51258 -   0x9c,0x8e,0x8f,0x28,0x0f,0x96,0xb9,0xa3,
51259 -   0xff},
51260 -  {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
51261 -   0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
51262 -   0x0e,0x00,0x0f,0x08},
51263 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,
51264 -   0xff} },
51265 - {0x50,0x1d,0x10,0xa000,                       /* 0x1a */
51266 -  {0x01,0x0f,0x00,0x06},
51267 -  0xe3,
51268 -  {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e,
51269 -   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
51270 -   0xea,0x8c,0xdf,0x28,0x00,0xe7,0x04,0xc3,
51271 -   0xff},
51272 -  {0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
51273 -   0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
51274 -   0x01,0x00,0x0f,0x00},
51275 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01,
51276 -   0xff} },
51277 - {0x50,0x1d,0x10,0xa000,                       /* 0x1b */
51278 -  {0x01,0x0f,0x00,0x06},
51279 -  0xe3,
51280 -  {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e,
51281 -   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
51282 -   0xea,0x8c,0xdf,0x28,0x00,0xe7,0x04,0xe3,
51283 -   0xff},
51284 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
51285 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
51286 -   0x01,0x00,0x0f,0x00},
51287 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
51288 -   0xff} },
51289 - {0x28,0x18,0x08,0x2000,                       /* 0x1c */
51290 -  {0x01,0x0f,0x00,0x0e},
51291 -  0x63,
51292 -  {0x5f,0x4f,0x50,0x82,0x54,0x80,0xbf,0x1f,
51293 -   0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,
51294 -   0x9c,0x8e,0x8f,0x28,0x40,0x96,0xb9,0xa3,
51295 -   0xff},
51296 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
51297 -   0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
51298 -   0x41,0x00,0x0f,0x00},
51299 -  {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,
51300 -   0xff} }
51301 -};
51302 -
51303  typedef struct _SiS300_ExtStruct
51304  {
51305 -       UCHAR Ext_ModeID;
51306 +       UCHAR  Ext_ModeID;
51307         USHORT Ext_ModeFlag;
51308         USHORT Ext_ModeInfo;
51309 -       USHORT Ext_Point;
51310         USHORT Ext_VESAID;
51311 -       UCHAR Ext_VESAMEMSize;
51312 -       UCHAR Ext_RESINFO;
51313 -       UCHAR VB_ExtTVFlickerIndex;
51314 -       UCHAR VB_ExtTVEdgeIndex;
51315 -       UCHAR VB_ExtTVYFilterIndex;
51316 -       UCHAR REFindex;
51317 +       UCHAR  Ext_RESINFO;
51318 +       UCHAR  VB_ExtTVFlickerIndex;
51319 +       UCHAR  VB_ExtTVEdgeIndex;
51320 +       UCHAR  VB_ExtTVYFilterIndex;
51321 +       UCHAR  REFindex;
51322  } SiS300_ExtStruct;
51323  
51324  static const SiS300_ExtStruct  SiS300_EModeIDTable[] =
51325  {
51326 -       {0x6a,0x2212,0x47,0x3563,0x0102,0x08,0x07,0x00,0x00,0x00,0x00},  /* 800x600x? */
51327 -       {0x2e,0x0a1b,0x36,0x3539,0x0101,0x08,0x06,0x00,0x00,0x00,0x08},
51328 -       {0x2f,0x021b,0x35,0x3532,0x0100,0x08,0x05,0x00,0x00,0x00,0x10},  /* 640x400x8 */
51329 -       {0x30,0x2a1b,0x47,0x3563,0x0103,0x08,0x07,0x00,0x00,0x00,0x00},
51330 -       {0x31,0x0a1b,0xad,0x3630,0x0000,0x08,0x0c,0x00,0x00,0x00,0x11},  /* 720x480x8 */
51331 -       {0x32,0x2a1b,0xae,0x3637,0x0000,0x08,0x0d,0x00,0x00,0x00,0x12},  /* 720x576x8 */
51332 -       {0x33,0x0a1d,0xad,0x3630,0x0000,0x08,0x0c,0x00,0x00,0x00,0x11},  /* 720x480x16 */
51333 -       {0x34,0x2a1d,0xae,0x3637,0x0000,0x08,0x0d,0x00,0x00,0x00,0x12},  /* 720x576x16 */
51334 -       {0x35,0x0a1f,0xad,0x3630,0x0000,0x08,0x0c,0x00,0x00,0x00,0x11},  /* 720x480x32 */
51335 -       {0x36,0x2a1f,0xae,0x3637,0x0000,0x08,0x0d,0x00,0x00,0x00,0x12},  /* 720x576x32 */
51336 -       {0x37,0x0212,0x58,0x358d,0x0104,0x08,0x08,0x00,0x00,0x00,0x13},  /* 1024x768x? */
51337 -       {0x38,0x0a1b,0x58,0x358d,0x0105,0x08,0x08,0x00,0x00,0x00,0x13},  /* 1024x768x8 */
51338 -       {0x3a,0x0e3b,0x69,0x35be,0x0107,0x08,0x09,0x00,0x00,0x00,0x1a},  /* 1280x1024x8 */
51339 -       {0x3c,0x063b,0x7a,0x35d4,0x0130,0x08,0x0a,0x00,0x00,0x00,0x1e},
51340 -       {0x3d,0x067d,0x7a,0x35d4,0x0131,0x08,0x0a,0x00,0x00,0x00,0x1e},
51341 -       {0x40,0x921c,0x00,0x3516,0x010d,0x08,0x00,0x00,0x00,0x00,0x23},
51342 -       {0x41,0x921d,0x00,0x3516,0x010e,0x08,0x00,0x00,0x00,0x00,0x23},
51343 -       {0x43,0x0a1c,0x36,0x3539,0x0110,0x08,0x06,0x00,0x00,0x00,0x08},
51344 -       {0x44,0x0a1d,0x36,0x3539,0x0111,0x08,0x06,0x00,0x00,0x00,0x08},
51345 -       {0x46,0x2a1c,0x47,0x3563,0x0113,0x08,0x07,0x00,0x00,0x00,0x00},  /* 800x600 */
51346 -       {0x47,0x2a1d,0x47,0x3563,0x0114,0x08,0x07,0x00,0x00,0x00,0x00},  /* 800x600 */
51347 -       {0x49,0x0a3c,0x58,0x358d,0x0116,0x08,0x08,0x00,0x00,0x00,0x13},
51348 -       {0x4a,0x0a3d,0x58,0x358d,0x0117,0x08,0x08,0x00,0x00,0x00,0x13},
51349 -       {0x4c,0x0e7c,0x69,0x35be,0x0119,0x08,0x09,0x00,0x00,0x00,0x1a},
51350 -       {0x4d,0x0e7d,0x69,0x35be,0x011a,0x08,0x09,0x00,0x00,0x00,0x1a},
51351 -       {0x50,0x921b,0x01,0x351d,0x0132,0x08,0x01,0x00,0x00,0x00,0x24},
51352 -       {0x51,0xb21b,0x13,0x3524,0x0133,0x08,0x03,0x00,0x00,0x00,0x25},  /* 400x300 */
51353 -       {0x52,0x921b,0x24,0x352b,0x0134,0x08,0x04,0x00,0x00,0x00,0x26},
51354 -       {0x56,0x921d,0x01,0x351d,0x0135,0x08,0x01,0x00,0x00,0x00,0x24},
51355 -       {0x57,0xb21d,0x13,0x3524,0x0136,0x08,0x03,0x00,0x00,0x00,0x25},  /* 400x300 */
51356 -       {0x58,0x921d,0x24,0x352b,0x0137,0x08,0x04,0x00,0x00,0x00,0x26},  
51357 -       {0x59,0x921b,0x00,0x3516,0x0138,0x08,0x00,0x00,0x00,0x00,0x23}, 
51358 -       {0x5c,0x921f,0x24,0x352b,0x0000,0x08,0x04,0x00,0x00,0x00,0x26},  /* TW: inserted 512x384x32 */
51359 -       {0x5d,0x021d,0x35,0x3532,0x0139,0x08,0x05,0x00,0x00,0x00,0x10},  /* 640x400x16 */
51360 -       {0x5e,0x021f,0x35,0x3532,0x0000,0x08,0x05,0x00,0x00,0x00,0x10},  /* TW: inserted 640x400x32 */
51361 -       {0x62,0x0a3f,0x36,0x3539,0x013a,0x08,0x06,0x00,0x00,0x00,0x08},
51362 -       {0x63,0x2a3f,0x47,0x3563,0x013b,0x08,0x07,0x00,0x00,0x00,0x00},  /* 800x600 */
51363 -       {0x64,0x0a7f,0x58,0x358d,0x013c,0x08,0x08,0x00,0x00,0x00,0x13},
51364 -       {0x65,0x0eff,0x69,0x35be,0x013d,0x08,0x09,0x00,0x00,0x00,0x1a},
51365 -       {0x66,0x06ff,0x7a,0x35d4,0x013e,0x08,0x0a,0x00,0x00,0x00,0x1e},
51366 -       {0x68,0x067b,0x8b,0x35ef,0x013f,0x08,0x0b,0x00,0x00,0x00,0x27},
51367 -       {0x69,0x06fd,0x8b,0x35ef,0x0140,0x08,0x0b,0x00,0x00,0x00,0x27},
51368 -       {0x6b,0x07ff,0x8b,0x35ef,0x0000,0x10,0x0b,0x00,0x00,0x00,0x27},
51369 -       {0x6c,0x067b,0x9c,0x35f6,0x0000,0x08,0x11,0x00,0x00,0x00,0x28},  /* TW: 2048x1536x8 - not in BIOS! */
51370 -       {0x6d,0x06fd,0x9c,0x35f6,0x0000,0x10,0x11,0x00,0x00,0x00,0x28},  /* TW: 2048x1536x16 - not in BIOS! */
51371 -       {0x6e,0x0a3b,0x6f,0x35b2,0x0000,0x08,0x0e,0x00,0x00,0x00,0x29},  /* 1280x960x8 */
51372 -       {0x6f,0x0a7d,0x6f,0x35b2,0x0000,0x08,0x0e,0x00,0x00,0x00,0x29},  /* 1280x960x16 */
51373 -       /* TW: 16:9 modes copied from 310/325 series - not in ANY BIOS */
51374 -       {0x70,0x2a1b,0x40,0x3b52,0x0000,0x08,0x12,0x00,0x00,0x07,0x2d},    /* 800x480x8 */
51375 -       {0x71,0x0a1b,0x51,0x3b63,0x0000,0x08,0x13,0x00,0x00,0x00,0x30},    /* 1024x576x8 */
51376 -       {0x74,0x0a1d,0x51,0x3b63,0x0000,0x08,0x13,0x00,0x00,0x00,0x30},    /* 1024x576x16 */
51377 -       {0x75,0x0e3d,0x62,0x3b74,0x0000,0x08,0x14,0x00,0x00,0x00,0x33},    /* 1280x720x16 */
51378 -       {0x76,0x2a1f,0x40,0x3b52,0x0000,0x08,0x12,0x00,0x00,0x07,0x2d},    /* 800x480x32 */
51379 -       {0x77,0x0a3f,0x51,0x3b63,0x0000,0x08,0x13,0x00,0x00,0x00,0x30},    /* 1024x576x32 */
51380 -       {0x78,0x0eff,0x62,0x3b74,0x0000,0x08,0x14,0x00,0x00,0x00,0x33},    /* 1280x720x32 */
51381 -       {0x79,0x0e3b,0x62,0x3b74,0x0000,0x08,0x14,0x00,0x00,0x00,0x33},    /* 1280x720x8 */
51382 -       {0x7a,0x2a1d,0x40,0x3b52,0x0000,0x08,0x12,0x00,0x00,0x07,0x2d},    /* 800x480x16 */
51383 -       /* TW: End of new 16:9 modes */
51384 -       {0x7b,0x0aff,0x6f,0x35b2,0x0000,0x08,0x0e,0x00,0x00,0x00,0x29},    /* 1280x960x32 */
51385 -       {0x20,0x0a1b,0x54,0x0000,0x0000,0x08,0x0f,0x00,0x00,0x00,0x2b},    /* 1024x600 */
51386 -       {0x21,0x0a3d,0x54,0x0000,0x0000,0x08,0x0f,0x00,0x00,0x00,0x2b},
51387 -       {0x22,0x0a7f,0x54,0x0000,0x0000,0x08,0x0f,0x00,0x00,0x00,0x2b},
51388 -       {0x23,0x0a1b,0xc5,0x0000,0x0000,0x08,0x10,0x00,0x00,0x00,0x2c},    /* 1152x768 */
51389 -       {0x24,0x0a3d,0xc5,0x431d,0x0000,0x08,0x10,0x00,0x00,0x00,0x2c},
51390 -       {0x25,0x0a7f,0xc5,0x431d,0x0000,0x08,0x10,0x00,0x00,0x00,0x2c},
51391 -       {0x29,0x0e1b,0xc5,0x0000,0x0000,0x08,0x15,0x00,0x00,0x00,0x36},    /* TW: NEW 1152x864 - not in BIOS */
51392 -       {0x2a,0x0e3d,0xc5,0x0000,0x0000,0x08,0x15,0x00,0x00,0x00,0x36},
51393 -       {0x2b,0x0e7f,0xc5,0x0000,0x0000,0x08,0x15,0x00,0x00,0x00,0x36},
51394 -       {0x39,0x2a1b,0xd6,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x38},    /* TW: NEW 848x480 - not in BIOS */
51395 -       {0x3b,0x2a3d,0xd6,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x38},
51396 -       {0x3e,0x2a7f,0xd6,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x38},
51397 -       {0x3f,0x2a1b,0xd7,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x3a},    /* TW: NEW 856x480 - not in BIOS */
51398 -       {0x42,0x2a3d,0xd7,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x3a},
51399 -       {0x45,0x2a7f,0xd7,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x3a},
51400 -       {0x48,0x223b,0xe8,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x3c},    /* TW: NEW 1360x768 - not in BIOS */
51401 -       {0x4b,0x227d,0xe8,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x3c},
51402 -       {0x4e,0x22ff,0xe8,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x3c},
51403 -       {0xff,0x0000,0x00,0x0000,0xffff,0x00,0x00,0x00,0x00,0x00,0x00}
51404 +       {0x6a,0x2212,0x0407,0x0102,SIS_RI_800x600,  0x00,0x00,0x00,0x00},  /* 800x600x? */
51405 +       {0x2e,0x0a1b,0x0306,0x0101,SIS_RI_640x480,  0x00,0x00,0x00,0x08},
51406 +       {0x2f,0x021b,0x0305,0x0100,SIS_RI_640x400,  0x00,0x00,0x00,0x10},  /* 640x400x8 */
51407 +       {0x30,0x2a1b,0x0407,0x0103,SIS_RI_800x600,  0x00,0x00,0x00,0x00},
51408 +       {0x31,0x0a1b,0x0a0d,0x0000,SIS_RI_720x480,  0x00,0x00,0x00,0x11},  /* 720x480x8 */
51409 +       {0x32,0x2a1b,0x0a0e,0x0000,SIS_RI_720x576,  0x00,0x00,0x00,0x12},  /* 720x576x8 */
51410 +       {0x33,0x0a1d,0x0a0d,0x0000,SIS_RI_720x480,  0x00,0x00,0x00,0x11},  /* 720x480x16 */
51411 +       {0x34,0x2a1d,0x0a0e,0x0000,SIS_RI_720x576,  0x00,0x00,0x00,0x12},  /* 720x576x16 */
51412 +       {0x35,0x0a1f,0x0a0d,0x0000,SIS_RI_720x480,  0x00,0x00,0x00,0x11},  /* 720x480x32 */
51413 +       {0x36,0x2a1f,0x0a0e,0x0000,SIS_RI_720x576,  0x00,0x00,0x00,0x12},  /* 720x576x32 */
51414 +       {0x37,0x0212,0x0508,0x0104,SIS_RI_1024x768, 0x00,0x00,0x00,0x13},  /* 1024x768x? */
51415 +       {0x38,0x0a1b,0x0508,0x0105,SIS_RI_1024x768, 0x00,0x00,0x00,0x13},  /* 1024x768x8 */
51416 +       {0x3a,0x0e3b,0x0609,0x0107,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a},  /* 1280x1024x8 */
51417 +       {0x3c,0x063b,0x070a,0x0130,SIS_RI_1600x1200,0x00,0x00,0x00,0x1e},
51418 +       {0x3d,0x067d,0x070a,0x0131,SIS_RI_1600x1200,0x00,0x00,0x00,0x1e},
51419 +       {0x40,0x921c,0x0000,0x010d,SIS_RI_320x200,  0x00,0x00,0x00,0x23},  /* 320x200x15 */
51420 +       {0x41,0x921d,0x0000,0x010e,SIS_RI_320x200,  0x00,0x00,0x00,0x23},  /* 320x200x16 */
51421 +       {0x43,0x0a1c,0x0306,0x0110,SIS_RI_640x480,  0x00,0x00,0x00,0x08},
51422 +       {0x44,0x0a1d,0x0306,0x0111,SIS_RI_640x480,  0x00,0x00,0x00,0x08},
51423 +       {0x46,0x2a1c,0x0407,0x0113,SIS_RI_800x600,  0x00,0x00,0x00,0x00},  /* 800x600x15 */
51424 +       {0x47,0x2a1d,0x0407,0x0114,SIS_RI_800x600,  0x00,0x00,0x00,0x00},  /* 800x600x16 */
51425 +       {0x49,0x0a3c,0x0508,0x0116,SIS_RI_1024x768, 0x00,0x00,0x00,0x13},
51426 +       {0x4a,0x0a3d,0x0508,0x0117,SIS_RI_1024x768, 0x00,0x00,0x00,0x13},
51427 +       {0x4c,0x0e7c,0x0609,0x0119,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a},
51428 +       {0x4d,0x0e7d,0x0609,0x011a,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a},
51429 +       {0x50,0x921b,0x0001,0x0132,SIS_RI_320x240,  0x00,0x00,0x00,0x24},  /* 320x240x8  */
51430 +       {0x51,0xb21b,0x0103,0x0133,SIS_RI_400x300,  0x00,0x00,0x00,0x25},  /* 400x300x8  */
51431 +       {0x52,0x921b,0x0204,0x0134,SIS_RI_512x384,  0x00,0x00,0x00,0x26},  /* 512x384x8  */
51432 +       {0x56,0x921d,0x0001,0x0135,SIS_RI_320x240,  0x00,0x00,0x00,0x24},  /* 320x240x16 */
51433 +       {0x57,0xb21d,0x0103,0x0136,SIS_RI_400x300,  0x00,0x00,0x00,0x25},  /* 400x300x16 */
51434 +       {0x58,0x921d,0x0204,0x0137,SIS_RI_512x384,  0x00,0x00,0x00,0x26},  /* 512x384x16 */
51435 +       {0x59,0x921b,0x0000,0x0138,SIS_RI_320x200,  0x00,0x00,0x00,0x23},  /* 320x200x8  */
51436 +       {0x5c,0x921f,0x0204,0x0000,SIS_RI_512x384,  0x00,0x00,0x00,0x26},  /* 512x384x32 */
51437 +       {0x5d,0x021d,0x0305,0x0139,SIS_RI_640x400,  0x00,0x00,0x00,0x10},  /* 640x400x16 */
51438 +       {0x5e,0x021f,0x0305,0x0000,SIS_RI_640x400,  0x00,0x00,0x00,0x10},  /* 640x400x32 */
51439 +       {0x62,0x0a3f,0x0306,0x013a,SIS_RI_640x480,  0x00,0x00,0x00,0x08},
51440 +       {0x63,0x2a3f,0x0407,0x013b,SIS_RI_800x600,  0x00,0x00,0x00,0x00},  /* 800x600x32 */
51441 +       {0x64,0x0a7f,0x0508,0x013c,SIS_RI_1024x768, 0x00,0x00,0x00,0x13},
51442 +       {0x65,0x0eff,0x0609,0x013d,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a},
51443 +       {0x66,0x06ff,0x070a,0x013e,SIS_RI_1600x1200,0x00,0x00,0x00,0x1e},
51444 +       {0x68,0x067b,0x080b,0x013f,SIS_RI_1920x1440,0x00,0x00,0x00,0x27},
51445 +       {0x69,0x06fd,0x080b,0x0140,SIS_RI_1920x1440,0x00,0x00,0x00,0x27},
51446 +       {0x6b,0x07ff,0x080b,0x0000,SIS_RI_1920x1440,0x00,0x00,0x00,0x27},
51447 +       {0x6c,0x067b,0x090c,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x28},  /* 2048x1536x8 - not in BIOS! */
51448 +       {0x6d,0x06fd,0x090c,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x28},  /* 2048x1536x16 - not in BIOS! */
51449 +       {0x70,0x2a1b,0x0400,0x0000,SIS_RI_800x480,  0x00,0x00,0x07,0x2d},  /* 800x480x8 */
51450 +       {0x71,0x0a1b,0x0501,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x30},  /* 1024x576x8 */
51451 +       {0x74,0x0a1d,0x0501,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x30},  /* 1024x576x16 */
51452 +       {0x75,0x0e3d,0x0602,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x33},  /* 1280x720x16 */
51453 +       {0x76,0x2a1f,0x0400,0x0000,SIS_RI_800x480,  0x00,0x00,0x07,0x2d},  /* 800x480x32 */
51454 +       {0x77,0x0a3f,0x0501,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x30},  /* 1024x576x32 */
51455 +       {0x78,0x0eff,0x0602,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x33},  /* 1280x720x32 */
51456 +       {0x79,0x0e3b,0x0602,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x33},  /* 1280x720x8 */
51457 +       {0x7a,0x2a1d,0x0400,0x0000,SIS_RI_800x480,  0x00,0x00,0x07,0x2d},  /* 800x480x16 */
51458 +       {0x7c,0x0a3b,0x060f,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x29},  /* 1280x960x8 */
51459 +       {0x7d,0x0a7d,0x060f,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x29},  /* 1280x960x16 */
51460 +       {0x7e,0x0aff,0x060f,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x29},  /* 1280x960x32 */
51461 +       {0x20,0x0a1b,0x0504,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x2b},  /* 1024x600 */
51462 +       {0x21,0x0a3d,0x0504,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x2b},
51463 +       {0x22,0x0a7f,0x0504,0x0000,SIS_RI_1024x600, 0x00,0x00,0x00,0x2b},
51464 +       {0x23,0x0a1b,0x0c05,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x2c},  /* 1152x768 */
51465 +       {0x24,0x0a3d,0x0c05,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x2c},
51466 +       {0x25,0x0a7f,0x0c05,0x0000,SIS_RI_1152x768, 0x00,0x00,0x00,0x2c},
51467 +       {0x29,0x0e1b,0x0c05,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x36},  /* 1152x864 */
51468 +       {0x2a,0x0e3d,0x0c05,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x36},
51469 +       {0x2b,0x0e7f,0x0c05,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x36},
51470 +       {0x39,0x2a1b,0x0d06,0x0000,SIS_RI_848x480,  0x00,0x00,0x00,0x38},  /* 848x480 */
51471 +       {0x3b,0x2a3d,0x0d06,0x0000,SIS_RI_848x480,  0x00,0x00,0x00,0x38},
51472 +       {0x3e,0x2a7f,0x0d06,0x0000,SIS_RI_848x480,  0x00,0x00,0x00,0x38},
51473 +       {0x3f,0x2a1b,0x0d07,0x0000,SIS_RI_856x480,  0x00,0x00,0x00,0x3a},  /* 856x480 */
51474 +       {0x42,0x2a3d,0x0d07,0x0000,SIS_RI_856x480,  0x00,0x00,0x00,0x3a},
51475 +       {0x45,0x2a7f,0x0d07,0x0000,SIS_RI_856x480,  0x00,0x00,0x00,0x3a},
51476 +       {0x48,0x223b,0x0e08,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x3c},  /* 1360x768 */
51477 +       {0x4b,0x227d,0x0e08,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x3c},
51478 +       {0x4e,0x22ff,0x0e08,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x3c},
51479 +       {0x4f,0x921f,0x0000,0x0000,SIS_RI_320x200,  0x00,0x00,0x00,0x23},  /* 320x200x32 */
51480 +       {0x53,0x921f,0x0001,0x0000,SIS_RI_320x240,  0x00,0x00,0x00,0x24},  /* 320x240x32 */
51481 +       {0x54,0xb21f,0x0103,0x0000,SIS_RI_400x300,  0x00,0x00,0x00,0x25},  /* 400x300x32 */
51482 +       {0x55,0x2e3b,0x0609,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x3d},  /* 1280x768   */
51483 +       {0x5a,0x2e7d,0x0609,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x3d},
51484 +       {0x5b,0x2eff,0x0609,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x3d},
51485 +       {0x5f,0x2a1b,0x0f0e,0x0000,SIS_RI_768x576,  0x00,0x00,0x00,0x3e},  /* 768x576x8 */
51486 +       {0x60,0x2a1d,0x0f0e,0x0000,SIS_RI_768x576,  0x00,0x00,0x00,0x3e},  /* 768x576x16 */
51487 +       {0x61,0x2a1f,0x0f0e,0x0000,SIS_RI_768x576,  0x00,0x00,0x00,0x3e},  /* 768x576x32 */
51488 +       {0x67,0x2e3b,0x0e08,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x3f},  /* 1360x1024x8 (BARCO) */
51489 +       {0x6f,0x2e7d,0x0e08,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x3f},  /* 1360x1024x16 (BARCO) */
51490 +       {0x72,0x2eff,0x0e08,0x0000,SIS_RI_1360x1024,0x00,0x00,0x00,0x3f},  /* 1360x1024x32 (BARCO) */
51491 +       {0xff,0x0000,0x0000,0xffff,0x00,            0x00,0x00,0x00,0x00}
51492  };
51493  
51494  typedef struct _SiS300_Ext2Struct
51495 @@ -514,76 +183,77 @@ typedef struct _SiS300_Ext2Struct
51496         UCHAR  ModeID;
51497         USHORT XRes;
51498         USHORT YRes;
51499 -       USHORT ROM_OFFSET;
51500  } SiS300_Ext2Struct;
51501  
51502  static const SiS300_Ext2Struct  SiS300_RefIndex[] =
51503  { /* TW: Don't ever insert anything here, table is indexed */
51504 -       {0x085f,0x0d,0x03,0x05,0x6a, 800, 600,0x3563}, /* 00 */
51505 -       {0x0467,0x0e,0x44,0x05,0x6a, 800, 600,0x3568}, /* 01 */
51506 -       {0x0067,0x0f,0x07,0x48,0x6a, 800, 600,0x356d}, /* 02 - CRT1CRTC was 0x4f */
51507 -       {0x0067,0x10,0x06,0x8b,0x6a, 800, 600,0x3572}, /* 03 */
51508 -       {0x0147,0x11,0x08,0x00,0x6a, 800, 600,0x3577}, /* 04 */
51509 -       {0x0147,0x12,0x0c,0x00,0x6a, 800, 600,0x357c}, /* 05 */
51510 -       {0x0047,0x11,0x4e,0x00,0x6a, 800, 600,0x3581}, /* 06 - CRT1CRTC was 0x51 */
51511 -       {0x0047,0x11,0x13,0x00,0x6a, 800, 600,0x3586}, /* 07 */
51512 -       {0xc85f,0x05,0x00,0x04,0x2e, 640, 480,0x3539}, /* 08 */
51513 -       {0xc067,0x06,0x02,0x04,0x2e, 640, 480,0x353e}, /* 09 */
51514 -       {0xc067,0x07,0x02,0x47,0x2e, 640, 480,0x3543}, /* 0a */
51515 -       {0xc067,0x08,0x03,0x8a,0x2e, 640, 480,0x3548}, /* 0b */
51516 -       {0xc047,0x09,0x05,0x00,0x2e, 640, 480,0x354d}, /* 0c */
51517 -       {0xc047,0x0a,0x08,0x00,0x2e, 640, 480,0x3552}, /* 0d */
51518 -       {0xc047,0x0b,0x0a,0x00,0x2e, 640, 480,0x3557}, /* 0e */
51519 -       {0xc047,0x0c,0x10,0x00,0x2e, 640, 480,0x355c}, /* 0f */
51520 -       {0x487f,0x04,0x00,0x00,0x2f, 640, 400,0x3532}, /* 10 */
51521 -       {0xc00f,0x31,0x01,0x06,0x31, 720, 480,0x3630}, /* 11 */
51522 -       {0x000f,0x32,0x03,0x06,0x32, 720, 576,0x3637}, /* 12 */
51523 -       {0x0187,0x15,0x05,0x00,0x37,1024, 768,0x358d}, /* 13 */
51524 -        {0xc877,0x16,0x09,0x06,0x37,1024, 768,0x3592}, /* 14 */
51525 -       {0xc067,0x17,0x0b,0x49,0x37,1024, 768,0x3597}, /* 15 - CRT1CRTC was 0x97 */
51526 -       {0x0267,0x18,0x0d,0x00,0x37,1024, 768,0x359c}, /* 16 */
51527 -       {0x0047,0x19,0x11,0x8c,0x37,1024, 768,0x35a1}, /* 17 - CRT1CRTC was 0x59 */
51528 -       {0x0047,0x1a,0x52,0x00,0x37,1024, 768,0x35a6}, /* 18 */
51529 -       {0x0007,0x1b,0x16,0x00,0x37,1024, 768,0x35ab}, /* 19 - CRT1CRTC was 0x5b */
51530 -       {0x0387,0x1c,0x4d,0x00,0x3a,1280,1024,0x35be}, /* 1a - CRT1CRTC was 0x5c */
51531 -       {0x0077,0x1d,0x14,0x07,0x3a,1280,1024,0x35c3}, /* 1b */
51532 -       {0x0047,0x1e,0x17,0x00,0x3a,1280,1024,0x35c8}, /* 1c */
51533 -       {0x0007,0x1f,0x98,0x00,0x3a,1280,1024,0x35cd}, /* 1d */
51534 -       {0x0007,0x20,0x59,0x00,0x3c,1600,1200,0x35d4}, /* 1e - CRT1CRTC was 0x60 */
51535 -       {0x0007,0x21,0x5a,0x00,0x3c,1600,1200,0x35d9}, /* 1f */
51536 -       {0x0007,0x22,0x1b,0x00,0x3c,1600,1200,0x35de}, /* 20 */
51537 -       {0x0007,0x23,0x1d,0x00,0x3c,1600,1200,0x35e3}, /* 21 - CRT1CRTC was 0x63 */
51538 -       {0x0007,0x24,0x1e,0x00,0x3c,1600,1200,0x35e8}, /* 22 */
51539 -       {0x407f,0x00,0x00,0x00,0x40, 320, 200,0x3516}, /* 23 */
51540 -       {0xc07f,0x01,0x00,0x04,0x50, 320, 240,0x351d}, /* 24 */
51541 -       {0x0077,0x02,0x04,0x05,0x51, 400, 300,0x3524}, /* 25 */
51542 -       {0xc877,0x03,0x09,0x06,0x52, 512, 384,0x352b}, /* 26 */  /* was c077 */
51543 -       {0x8207,0x25,0x1f,0x00,0x68,1920,1440,0x35ef}, /* 27 */
51544 -       {0x0007,0x26,0x20,0x00,0x6c,2048,1536,0x35f6}, /* 28 */
51545 -       {0x0067,0x27,0x14,0x08,0x6e,1280, 960,0x35b7}, /* 29 - TW: 1280x960-60 */
51546 -       {0x0027,0x45,0x3c,0x08,0x6e,1280, 960,0x35b7}, /* 2a - TW: 1280x960-85 */
51547 -       {0xc077,0x33,0x09,0x06,0x20,1024, 600,0x0000}, /* 2b */
51548 -       {0xc077,0x34,0x0b,0x06,0x23,1152, 768,0x0000}, /* 2c */ /* VCLK 0x09 */
51549 -       {0x0057,0x35,0x27,0x08,0x70, 800, 480,0x3b52}, /* 2d - TW: 16:9 modes */
51550 -       {0x0047,0x36,0x37,0x08,0x70, 800, 480,0x3b57}, /* 2e */
51551 -       {0x0047,0x37,0x08,0x08,0x70, 800, 480,0x3b5c}, /* 2f */
51552 -       {0x0057,0x38,0x09,0x09,0x71,1024, 576,0x3b63}, /* 30 */
51553 -       {0x0047,0x39,0x38,0x09,0x71,1024, 576,0x3b68}, /* 31 */
51554 -       {0x0047,0x3a,0x11,0x09,0x71,1024, 576,0x3b6d}, /* 32 */
51555 -       {0x0057,0x3b,0x39,0x0a,0x75,1280, 720,0x3b74}, /* 33 */
51556 -       {0x0047,0x3c,0x3a,0x0a,0x75,1280, 720,0x3b79}, /* 34 */
51557 -       {0x0007,0x3d,0x3b,0x0a,0x75,1280, 720,0x3b7e}, /* 35 - TW: END of 16:9 modes */
51558 -       {0x0047,0x3e,0x34,0x06,0x29,1152, 864,0x0000}, /* 36 TW: 1152x864-75Hz - Non-BIOS, new */
51559 -       {0x0047,0x44,0x3a,0x06,0x29,1152, 864,0x0000}, /* 37 TW: 1152x864-85Hz - Non-BIOS, new */
51560 -       {0x00c7,0x3f,0x28,0x00,0x39, 848, 480,0x0000}, /* 38 TW: 848x480-38Hzi - Non-BIOS, new */
51561 -       {0xc047,0x40,0x3d,0x00,0x39, 848, 480,0x0000}, /* 39 TW: 848x480-60Hz  - Non-BIOS, new */
51562 -       {0x00c7,0x41,0x28,0x00,0x3f, 856, 480,0x0000}, /* 3a TW: 856x480-38Hzi - Non-BIOS, new */
51563 -       {0xc047,0x42,0x28,0x00,0x3f, 856, 480,0x0000}, /* 3b TW: 856x480-60Hz  - Non-BIOS, new */
51564 -       {0x0047,0x43,0x3e,0x00,0x48,1360, 768,0x0000}, /* 3c TW: 1360x768-60Hz - Non-BIOS, new */
51565 -       {0xffff,0,0,0,0,0,0,0}
51566 +       {0x085f,0x0d,0x03,0x05,0x6a, 800, 600}, /* 00 */
51567 +       {0x0467,0x0e,0x44,0x05,0x6a, 800, 600}, /* 01 */
51568 +       {0x0067,0x0f,0x07,0x48,0x6a, 800, 600}, /* 02 - CRT1CRTC was 0x4f */
51569 +       {0x0067,0x10,0x06,0x8b,0x6a, 800, 600}, /* 03 */
51570 +       {0x0147,0x11,0x08,0x00,0x6a, 800, 600}, /* 04 */
51571 +       {0x0147,0x12,0x0c,0x00,0x6a, 800, 600}, /* 05 */
51572 +       {0x0047,0x11,0x4e,0x00,0x6a, 800, 600}, /* 06 - CRT1CRTC was 0x51 */
51573 +       {0x0047,0x11,0x13,0x00,0x6a, 800, 600}, /* 07 */
51574 +       {0xc85f,0x05,0x00,0x04,0x2e, 640, 480}, /* 08 */
51575 +       {0xc067,0x06,0x02,0x04,0x2e, 640, 480}, /* 09 */
51576 +       {0xc067,0x07,0x02,0x47,0x2e, 640, 480}, /* 0a */
51577 +       {0xc067,0x08,0x03,0x8a,0x2e, 640, 480}, /* 0b */
51578 +       {0xc047,0x09,0x05,0x00,0x2e, 640, 480}, /* 0c */
51579 +       {0xc047,0x0a,0x08,0x00,0x2e, 640, 480}, /* 0d */
51580 +       {0xc047,0x0b,0x0a,0x00,0x2e, 640, 480}, /* 0e */
51581 +       {0xc047,0x0c,0x10,0x00,0x2e, 640, 480}, /* 0f */
51582 +       {0x487f,0x04,0x00,0x00,0x2f, 640, 400}, /* 10 */
51583 +       {0xc00f,0x31,0x01,0x06,0x31, 720, 480}, /* 11 */
51584 +       {0x000f,0x32,0x03,0x06,0x32, 720, 576}, /* 12 */
51585 +       {0x0187,0x15,0x05,0x00,0x37,1024, 768}, /* 13 */
51586 +        {0xc877,0x16,0x09,0x06,0x37,1024, 768}, /* 14 */
51587 +       {0xc067,0x17,0x0b,0x49,0x37,1024, 768}, /* 15 - CRT1CRTC was 0x97 */
51588 +       {0x0267,0x18,0x0d,0x00,0x37,1024, 768}, /* 16 */
51589 +       {0x0047,0x19,0x11,0x8c,0x37,1024, 768}, /* 17 - CRT1CRTC was 0x59 */
51590 +       {0x0047,0x1a,0x52,0x00,0x37,1024, 768}, /* 18 */
51591 +       {0x0007,0x1b,0x16,0x00,0x37,1024, 768}, /* 19 - CRT1CRTC was 0x5b */
51592 +       {0x0387,0x1c,0x4d,0x00,0x3a,1280,1024}, /* 1a - CRT1CRTC was 0x5c */
51593 +       {0x0077,0x1d,0x14,0x07,0x3a,1280,1024}, /* 1b */
51594 +       {0x0047,0x1e,0x17,0x00,0x3a,1280,1024}, /* 1c */
51595 +       {0x0007,0x1f,0x98,0x00,0x3a,1280,1024}, /* 1d */
51596 +       {0x0007,0x20,0x59,0x00,0x3c,1600,1200}, /* 1e - CRT1CRTC was 0x60 */
51597 +       {0x0007,0x21,0x5a,0x00,0x3c,1600,1200}, /* 1f */
51598 +       {0x0007,0x22,0x1b,0x00,0x3c,1600,1200}, /* 20 */
51599 +       {0x0007,0x23,0x1d,0x00,0x3c,1600,1200}, /* 21 - CRT1CRTC was 0x63 */
51600 +       {0x0007,0x24,0x1e,0x00,0x3c,1600,1200}, /* 22 */
51601 +       {0x407f,0x00,0x00,0x00,0x40, 320, 200}, /* 23 */
51602 +       {0xc07f,0x01,0x00,0x04,0x50, 320, 240}, /* 24 */
51603 +       {0x0077,0x02,0x04,0x05,0x51, 400, 300}, /* 25 */
51604 +       {0xc877,0x03,0x09,0x06,0x52, 512, 384}, /* 26 */  /* was c077 */
51605 +       {0x8207,0x25,0x1f,0x00,0x68,1920,1440}, /* 27 */
51606 +       {0x0007,0x26,0x20,0x00,0x6c,2048,1536}, /* 28 */
51607 +       {0x0067,0x27,0x14,0x08,0x6e,1280, 960}, /* 29 - TW: 1280x960-60 */
51608 +       {0x0027,0x45,0x3c,0x08,0x6e,1280, 960}, /* 2a - TW: 1280x960-85 */
51609 +       {0xc077,0x33,0x09,0x06,0x20,1024, 600}, /* 2b */
51610 +       {0xc077,0x34,0x0b,0x06,0x23,1152, 768}, /* 2c */        /* VCLK 0x09 */
51611 +       {0x0057,0x35,0x27,0x08,0x70, 800, 480}, /* 2d */
51612 +       {0x0047,0x36,0x37,0x08,0x70, 800, 480}, /* 2e */
51613 +       {0x0047,0x37,0x08,0x08,0x70, 800, 480}, /* 2f */
51614 +       {0x0057,0x38,0x09,0x09,0x71,1024, 576}, /* 30 */
51615 +       {0x0047,0x39,0x38,0x09,0x71,1024, 576}, /* 31 */
51616 +       {0x0047,0x3a,0x11,0x09,0x71,1024, 576}, /* 32 */
51617 +       {0x0057,0x3b,0x39,0x0a,0x75,1280, 720}, /* 33 */
51618 +       {0x0047,0x3c,0x3a,0x0a,0x75,1280, 720}, /* 34 */
51619 +       {0x0007,0x3d,0x3b,0x0a,0x75,1280, 720}, /* 35 */
51620 +       {0x0047,0x3e,0x34,0x06,0x29,1152, 864}, /* 36 1152x864-75Hz */
51621 +       {0x0047,0x44,0x3a,0x06,0x29,1152, 864}, /* 37 1152x864-85Hz */
51622 +       {0x00c7,0x3f,0x28,0x00,0x39, 848, 480}, /* 38 848x480-38Hzi */
51623 +       {0xc067,0x40,0x3d,0x0b,0x39, 848, 480}, /* 39 848x480-60Hz  */
51624 +       {0x00c7,0x41,0x28,0x00,0x3f, 856, 480}, /* 3a 856x480-38Hzi */
51625 +       {0xc047,0x42,0x28,0x00,0x3f, 856, 480}, /* 3b 856x480-60Hz  */
51626 +       {0x0067,0x43,0x3e,0x0c,0x48,1360, 768}, /* 3c 1360x768-60Hz */
51627 +       {0x0077,0x46,0x3f,0x08,0x55,1280, 768}, /* 3d 1280x768-60Hz */
51628 +       {0x000f,0x47,0x03,0x06,0x5f, 768, 576}, /* 3e 768x576 */
51629 +       {0x0027,0x48,0x13,0x08,0x67,1360,1024}, /* 3f 1360x1024-59Hz (BARCO1366 only) */
51630 +       {0xffff,   0,   0,   0,   0,   0,   0}
51631  };
51632  
51633 -/*add for 300 oem util*/
51634  typedef struct _SiS_VBModeIDTableStruct
51635  {
51636         UCHAR  ModeID;
51637 @@ -649,9 +319,8 @@ static const SiS_VBModeIDTableStruct  Si
51638         {0x6e,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d},
51639         {0x6f,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d},
51640         {0x7b,0x00,0x00,0x01,0x00,0x00,0x0b,0x0d},
51641 -       {0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00}  /* TW: added! */
51642 +       {0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
51643  };
51644 -/*end*/
51645  
51646  typedef struct _SiS300_CRT1TableStruct
51647  {
51648 @@ -660,15 +329,32 @@ typedef struct _SiS300_CRT1TableStruct
51649  
51650  static const SiS300_CRT1TableStruct  SiS300_CRT1Table[] =
51651  {
51652 - {{0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,    /* 0x00 */
51653 -  0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x00,
51654 +#if 1
51655 + {{0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,    /* 0x00 - 320x200 */
51656 +  0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x00,     /* HRE [4],[15] is invalid - but correcting it does not work */
51657 +  0x00}},
51658 +#endif
51659 +#if 0
51660 + {{0x2d,0x27,0x27,0x91,0x2c,0x92,0xbf,0x1f,    /* 0x00 - corrected 320x200-72 - does not work */
51661 +  0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x04,
51662    0x00}},
51663 - {{0x2d,0x27,0x28,0x90,0x2c,0x80,0x0b,0x3e,
51664 -  0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x00,
51665 +#endif
51666 + {{0x2d,0x27,0x28,0x90,0x2c,0x80,0x0b,0x3e,    /* 0x01 */
51667 +  0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x00,     /* HRE [4],[15] is invalid - but correcting it does not work */
51668    0x00}},
51669 - {{0x3d,0x31,0x31,0x81,0x37,0x1f,0x72,0xf0,
51670 +#if 0
51671 + {{0x2d,0x27,0x27,0x91,0x2c,0x92,0x0b,0x3e,    /* 0x01 - corrected 320x240-60 - does not work */
51672 +  0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x04,
51673 +  0x00}},
51674 +#endif
51675 + {{0x3d,0x31,0x31,0x81,0x37,0x1f,0x72,0xf0,    /* 0x02 */
51676 +  0x58,0x8c,0x57,0x57,0x73,0x20,0x00,0x05,
51677 +  0x01}},
51678 +#if 0
51679 + {{0x3d,0x31,0x31,0x81,0x37,0x1f,0x72,0xf0,    /* 0x02 - corrected 400x300-60 */
51680    0x58,0x8c,0x57,0x57,0x73,0x20,0x00,0x05,
51681    0x01}},
51682 +#endif
51683   {{0x4f,0x3f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
51684    0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x01,
51685    0x01}},
51686 @@ -683,7 +369,7 @@ static const SiS300_CRT1TableStruct  SiS
51687   {{0x5f,0x4f,0x4f,0x83,0x55,0x81,0x0b,0x3e,    /* 0x05 - corrected 640x480-60 */
51688    0xe9,0x8b,0xdf,0xe8,0x0c,0x00,0x00,0x05,
51689    0x00}},
51690 - #if 0  
51691 +#if 0
51692   {{0x63,0x4f,0x50,0x86,0x56,0x9b,0x06,0x3e,    /* 0x06 */
51693    0xe8,0x8b,0xdf,0xe7,0xff,0x10,0x00,0x01,
51694    0x00}},
51695 @@ -841,15 +527,10 @@ static const SiS300_CRT1TableStruct  SiS
51696   {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x1e,0xf1,  /* 0x33 - 1024x600 */
51697    0xae,0x85,0x57,0x57,0x1f,0x30,0x00,0x02,
51698    0x01}},
51699 -#if 0
51700 - {{0xa3,0x7f,0x7f,0x87,0x86,0x97,0x24,0xf5,  /* 0x34 - 1152x768 */
51701 -  0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02,
51702 -  0x01}},
51703 -#endif
51704 - {{0xa3,0x8f,0x8f,0x97,0x96,0x97,0x24,0xf5,  /* 0x34 - 1152x768 - TW: corrected */
51705 + {{0xa3,0x8f,0x8f,0x97,0x96,0x97,0x24,0xf5,  /* 0x34 - 1152x768 - corrected */
51706    0x02,0x88,0xff,0xff,0x25,0x10,0x00,0x02,
51707    0x01}},
51708 - {{0x7f,0x63,0x63,0x83,0x6c,0x1c,0x72,0xba,  /* 0x35 - NEW 16:9 modes, not in BIOS ------ */
51709 + {{0x7f,0x63,0x63,0x83,0x6c,0x1c,0x72,0xba,  /* 0x35 */
51710     0x27,0x8b,0xdf,0xdf,0x73,0x00,0x00,0x06,
51711     0x01}}, /* 0x35 */
51712   {{0x7f,0x63,0x63,0x83,0x69,0x13,0x6f,0xba,
51713 @@ -864,7 +545,7 @@ static const SiS300_CRT1TableStruct  SiS
51714   {{0x9f,0x7f,0x7f,0x83,0x85,0x91,0x1e,0xf1,
51715     0xad,0x81,0x3f,0x3f,0x1f,0x30,0x00,0x02,
51716     0x01}}, /* 0x39 */
51717 - {{0xa7,0x7f,0x7f,0x88,0x89,0x95,0x26,0xf1,    /* TW: 95 was 15 - illegal HBE! */
51718 + {{0xa7,0x7f,0x7f,0x88,0x89,0x95,0x26,0xf1,  /* 95 was 15 - illegal HBE! */
51719     0xb1,0x85,0x3f,0x3f,0x27,0x30,0x00,0x02,
51720     0x01}}, /* 0x3a */
51721   {{0xce,0x9f,0x9f,0x92,0xa9,0x17,0x28,0xc4,
51722 @@ -875,36 +556,40 @@ static const SiS300_CRT1TableStruct  SiS
51723     0x01}}, /* 0x3c */
51724   {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0x2e,0xd4,
51725     0x7d,0x81,0xcf,0xcf,0x2f,0x21,0x00,0x07,
51726 -   0x01}}, /* 0x3d */                       /* TW: End of 16:9 modes --------------- */
51727 - {{0xc3,0x8f,0x8f,0x87,0x9b,0x0b,0x82,0xef,  /* TW: New, 1152x864-75 (not in any BIOS)   */
51728 +   0x01}}, /* 0x3d */
51729 + {{0xc3,0x8f,0x8f,0x87,0x9b,0x0b,0x82,0xef,  /* 1152x864-75 */
51730     0x60,0x83,0x5f,0x5f,0x83,0x10,0x00,0x07,
51731     0x01}},  /* 0x3e */
51732 - {{0x86,0x69,0x69,0x8A,0x74,0x06,0x8C,0x15,  /* TW: New, 848x480-38i, not in BIOS */
51733 + {{0x86,0x69,0x69,0x8A,0x74,0x06,0x8C,0x15,  /* 848x480-38i */
51734     0x4F,0x83,0xEF,0xEF,0x8D,0x30,0x00,0x02,
51735     0x00}}, /* 0x3f */
51736 -#if 0
51737 - {{0x81,0x69,0x69,0x85,0x70,0x00,0x0F,0x3E,  /* TW: New, 848x480-60, not in BIOS - incorrect for Philips panel */
51738 -   0xEB,0x8E,0xDF,0xDF,0x10,0x00,0x00,0x02,
51739 -   0x00}}, /* 0x40 */
51740 -#endif
51741 - {{0x83,0x69,0x69,0x87,0x6f,0x1d,0x03,0x3E,  /* TW: New, 848x480-60, not in BIOS */
51742 + {{0x83,0x69,0x69,0x87,0x6f,0x1d,0x03,0x3E,  /* 848x480-60  */
51743     0xE5,0x8d,0xDF,0xe4,0x04,0x00,0x00,0x06,
51744     0x00}}, /* 0x40 */
51745 - {{0x86,0x6A,0x6A,0x8A,0x74,0x06,0x8C,0x15,  /* TW: New, 856x480-38i, not in BIOS */
51746 + {{0x86,0x6A,0x6A,0x8A,0x74,0x06,0x8C,0x15,  /* 856x480-38i */
51747     0x4F,0x83,0xEF,0xEF,0x8D,0x30,0x00,0x02,
51748     0x00}}, /* 0x41 */
51749 - {{0x81,0x6A,0x6A,0x85,0x70,0x00,0x0F,0x3E,  /* TW: New, 856x480-60, not in BIOS */
51750 + {{0x81,0x6A,0x6A,0x85,0x70,0x00,0x0F,0x3E,  /* 856x480-60  */
51751     0xEB,0x8E,0xDF,0xDF,0x10,0x00,0x00,0x02,
51752     0x00}}, /* 0x42 */
51753 - {{0xdd,0xa9,0xa9,0x81,0xb4,0x97,0x26,0xfd,  /* TW: New, 1360x768-60, not in BIOS */
51754 + {{0xdd,0xa9,0xa9,0x81,0xb4,0x97,0x26,0xfd,  /* 1360x768-60 */
51755     0x01,0x8d,0xff,0x00,0x27,0x10,0x00,0x03,
51756     0x01}}, /* 0x43 */
51757 - {{0xd9,0x8f,0x8f,0x9d,0xba,0x0a,0x8a,0xff,  /* TW: New, 1152x864-84 (not in any BIOS)   */
51758 + {{0xd9,0x8f,0x8f,0x9d,0xba,0x0a,0x8a,0xff,  /* 1152x864-84 */
51759     0x60,0x8b,0x5f,0x5f,0x8b,0x10,0x00,0x03,
51760 -   0x01}}, /* 0x44 */   
51761 - {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0xf1,0xff,  /* TW: New, 1280x960-85 (not in any BIOS)   */
51762 +   0x01}}, /* 0x44 */
51763 + {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0xf1,0xff,  /* 1280x960-85 */
51764     0xc0,0x83,0xbf,0xbf,0xf2,0x10,0x00,0x07,
51765 -   0x01}}  /* 0x45 */
51766 +   0x01}}, /* 0x45 */
51767 + {{0xce,0x9f,0x9f,0x92,0xa9,0x17,0x20,0xf5,  /* 1280x768-60 */
51768 +   0x03,0x88,0xff,0xff,0x21,0x10,0x00,0x07,
51769 +   0x01}},  /* 0x46 */
51770 + {{0x7b,0x5f,0x63,0x9f,0x6a,0x93,0x6f,0xf0,  /* 768x576 */
51771 +   0x58,0x8a,0x3f,0x57,0x70,0x20,0x00,0x05,
51772 +   0x01}},  /* 0x47 */
51773 + {{0xce,0xa9,0xa9,0x92,0xb1,0x07,0x28,0x52,  /* 1360x1024 (Barco iQ Pro R300) */
51774 +   0x02,0x8e,0xff,0x00,0x29,0x0d,0x00,0x03,
51775 +   0x00}}   /* 0x48 */
51776  };
51777  
51778  typedef struct _SiS300_MCLKDataStruct
51779 @@ -913,8 +598,8 @@ typedef struct _SiS300_MCLKDataStruct
51780         USHORT CLOCK;
51781  } SiS300_MCLKDataStruct;
51782  
51783 -static const SiS300_MCLKDataStruct  SiS300_MCLKData_630[] =    /* 630 */
51784 -{ /* TW: at 0x54 in BIOS */
51785 +static const SiS300_MCLKDataStruct  SiS300_MCLKData_630[] =
51786 +{
51787         { 0x5a,0x64,0x80, 66},
51788         { 0xb3,0x45,0x80, 83},
51789         { 0x37,0x61,0x80,100},
51790 @@ -925,8 +610,8 @@ static const SiS300_MCLKDataStruct  SiS3
51791         { 0x37,0x61,0x80,100}
51792  };
51793  
51794 -static const SiS300_MCLKDataStruct  SiS300_MCLKData_300[] =  /* 300 */
51795 -{ /* TW: at 0x54 in BIOS */
51796 +static const SiS300_MCLKDataStruct  SiS300_MCLKData_300[] =
51797 +{
51798         { 0x68,0x43,0x80,125},
51799         { 0x68,0x43,0x80,125},
51800         { 0x68,0x43,0x80,125},
51801 @@ -937,6 +622,7 @@ static const SiS300_MCLKDataStruct  SiS3
51802         { 0x37,0x61,0x80,100}
51803  };
51804  
51805 +#ifdef LINUXBIOS
51806  typedef struct _SiS300_ECLKDataStruct
51807  {
51808         UCHAR SR2E,SR2F,SR30;
51809 @@ -954,6 +640,7 @@ static const SiS300_ECLKDataStruct  SiS3
51810         { 0x54,0x43,0x80,100},
51811         { 0x54,0x43,0x80,100}
51812  };
51813 +#endif
51814  
51815  typedef struct _SiS300_VCLKDataStruct
51816  {
51817 @@ -964,71 +651,77 @@ typedef struct _SiS300_VCLKDataStruct
51818  static const SiS300_VCLKDataStruct  SiS300_VCLKData[] =
51819  {
51820         { 0x1b,0xe1, 25}, /* 0x00 */
51821 -       { 0x4e,0xe4, 28},
51822 +       { 0x4e,0xe4, 28}, /* 0x01 */
51823         { 0x57,0xe4, 32}, /* 0x02 */
51824 -       { 0xc3,0xc8, 36},
51825 +       { 0xc3,0xc8, 36}, /* 0x03 */
51826         { 0x42,0xc3, 40}, /* 0x04 */
51827 -       { 0x5d,0xc4, 45},
51828 +       { 0x5d,0xc4, 45}, /* 0x05 */
51829         { 0x52,0x65, 50}, /* 0x06 */
51830 -       { 0x53,0x65, 50},
51831 +       { 0x53,0x65, 50}, /* 0x07 */
51832         { 0x6d,0x66, 56}, /* 0x08 */
51833 -       { 0x5a,0x64, 65},
51834 +       { 0x5a,0x64, 65}, /* 0x09 */
51835         { 0x46,0x44, 68}, /* 0x0a */
51836 -       { 0x3e,0x43, 75},
51837 -       { 0x6d,0x46, 76}, /* 0x0c: 800x600 | LVDS_2(CH), MITAC(CH);  - 730, A901(301B): 0xb1,0x46, 76 */
51838 -       { 0x41,0x43, 79},
51839 +       { 0x3e,0x43, 75}, /* 0x0b */
51840 +       { 0x6d,0x46, 76}, /* 0x0c */  /* 800x600 | LVDS_2(CH), MITAC(CH);  - 730, A901(301B): 0xb1,0x46, 76 */
51841 +       { 0x41,0x43, 79}, /* 0x0d */
51842         { 0x31,0x42, 79}, /* 0x0e */
51843 -       { 0x46,0x25, 85},
51844 +       { 0x46,0x25, 85}, /* 0x0f */
51845         { 0x78,0x29, 87}, /* 0x10 */
51846 -       { 0x62,0x44, 95},
51847 +       { 0x62,0x44, 95}, /* 0x11 */
51848         { 0x2b,0x22,105}, /* 0x12 */
51849 -       { 0x49,0x24,106},
51850 +       { 0x49,0x24,106}, /* 0x13 */
51851         { 0xc3,0x28,108}, /* 0x14 */
51852 -       { 0x3c,0x23,109},
51853 +       { 0x3c,0x23,109}, /* 0x15 */
51854         { 0xf7,0x2c,132}, /* 0x16 */
51855 -       { 0xd4,0x28,136},
51856 +       { 0xd4,0x28,136}, /* 0x17 */
51857         { 0x41,0x05,158}, /* 0x18 */
51858 -       { 0x43,0x05,162},
51859 +       { 0x43,0x05,162}, /* 0x19 */
51860         { 0xe1,0x0f,175}, /* 0x1a */
51861         { 0xfc,0x12,189}, /* 0x1b */
51862         { 0xde,0x26,194}, /* 0x1c */
51863 -       { 0x54,0x05,203},
51864 +       { 0x54,0x05,203}, /* 0x1d */
51865         { 0x3f,0x03,230}, /* 0x1e */
51866 -       { 0x30,0x02,234},
51867 +       { 0x30,0x02,234}, /* 0x1f */
51868         { 0x24,0x01,266}, /* 0x20 */
51869 -       { 0x52,0x2a, 54}, /* 301 TV */
51870 -       { 0x52,0x6a, 27}, /* 301 TV */
51871 -       { 0x62,0x24, 70}, /* 301 TV */
51872 -       { 0x62,0x64, 70}, /* 301 TV */
51873 -       { 0xa8,0x4c, 30}, /* 301 TV */
51874 -       { 0x20,0x26, 33}, /* 301 TV */
51875 -       { 0x31,0xc2, 39},
51876 -       { 0xbf,0xc8, 35}, /* 0x28 - 856x480 */
51877 -       { 0x60,0x36, 30}, /* 0x29  CH/UNTSC TEXT | LVDS_2(CH) - 730, A901(301B), Mitac(CH): 0xe0, 0xb6, 30 */
51878 -       { 0x40,0x4a, 28},
51879 -       { 0x9f,0x46, 44},
51880 -       { 0x97,0x2c, 26},
51881 -       { 0x44,0xe4, 25},
51882 -       { 0x7e,0x32, 47},
51883 -       { 0x8a,0x24, 31}, /* 0x2f  CH/PAL TEXT | LVDS_2(CH), Mitac(CH) -  730, A901(301B): 0x57, 0xe4, 31 */
51884 -       { 0x97,0x2c, 26},
51885 -       { 0xce,0x3c, 39},
51886 -       { 0x52,0x4a, 36}, /* 0x32  CH/PAL 800x600 5/6 */
51887 -       { 0x34,0x61, 95},
51888 -       { 0x78,0x27,108},
51889 -       { 0xce,0x25,189}, /* 0x35 */
51890 -       { 0x45,0x6b, 21}, /* 0x36 */  /* TW: Added from Mitac */
51891 -       { 0x52,0xe2, 49}, /* 0x37 - added for 16:9 modes (not in any BIOS) */
51892 -       { 0x2b,0x61, 78}, /* 0x38 - added for 16:9 modes (not in any BIOS) */
51893 -       { 0x70,0x44,108}, /* 0x39 - added for 16:9 modes (not in any BIOS) */
51894 -       { 0x54,0x42,135}, /* 0x3a - added for 16:9 modes (not in any BIOS) */
51895 -       { 0x41,0x22,157}, /* 0x3b - added for 16:9 modes (not in any BIOS) */
51896 -       { 0x52,0x07,149}, /* 0x3c - added for 1280x960-85 (not in any BIOS)*/
51897 -       { 0x62,0xc6, 34}, /* 0x3d - added for 848x480-60 (not in any BIOS) */
51898 -       { 0x30,0x23, 88}, /* 0x3e - added for 1360x768-60 (not in any BIOS)*/
51899 -       { 0x3f,0x64, 46}, /* 0x3f - added for 640x480-100 (not in any BIOS)*/
51900 -       { 0x72,0x2a, 76}, /* 0x40 - test for SiS730 */
51901 -       { 0x15,0x21, 79}, /* 0x41 - test for SiS730 */
51902 +       { 0x52,0x2a, 54}, /* 0x21 */  /* 301 TV */
51903 +       { 0x52,0x6a, 27}, /* 0x22 */  /* 301 TV */
51904 +       { 0x62,0x24, 70}, /* 0x23 */  /* 301 TV */
51905 +       { 0x62,0x64, 70}, /* 0x24 */  /* 301 TV */
51906 +       { 0xa8,0x4c, 30}, /* 0x25 */  /* 301 TV */
51907 +       { 0x20,0x26, 33}, /* 0x26 */  /* 301 TV */
51908 +       { 0x31,0xc2, 39}, /* 0x27 */
51909 +       { 0xbf,0xc8, 35}, /* 0x28 */  /* 856x480 */
51910 +       { 0x60,0x36, 30}, /* 0x29 */  /* CH/UNTSC TEXT | LVDS_2(CH) - 730, A901(301B), Mitac(CH): 0xe0, 0xb6, 30 */
51911 +       { 0x40,0x4a, 28}, /* 0x2a */
51912 +       { 0x9f,0x46, 44}, /* 0x2b */
51913 +       { 0x97,0x2c, 26}, /* 0x2c */
51914 +       { 0x44,0xe4, 25}, /* 0x2d */
51915 +       { 0x7e,0x32, 47}, /* 0x2e */
51916 +       { 0x8a,0x24, 31}, /* 0x2f */  /* CH/PAL TEXT | LVDS_2(CH), Mitac(CH) -  730, A901(301B): 0x57, 0xe4, 31 */
51917 +       { 0x97,0x2c, 26}, /* 0x30 */
51918 +       { 0xce,0x3c, 39}, /* 0x31 */
51919 +       { 0x52,0x4a, 36}, /* 0x32 */  /* CH/PAL 800x600 5/6 */
51920 +       { 0x34,0x61, 95}, /* 0x33 */
51921 +       { 0x78,0x27,108}, /* 0x34 */  /* Replacement for index 0x14 for 630 (?) */
51922 +       { 0xce,0x25,189}, /* 0x35 */  /* Replacement for index 0x1b for 730 (and 540?) */
51923 +       { 0x45,0x6b, 21}, /* 0x36 */
51924 +       { 0x52,0xe2, 49}, /* 0x37 */  /* 16:9 modes  */
51925 +       { 0x2b,0x61, 78}, /* 0x38 */  /* 16:9 modes  */
51926 +       { 0x70,0x44,108}, /* 0x39 */  /* 16:9 modes  */
51927 +       { 0x54,0x42,135}, /* 0x3a */  /* 16:9 modes  */
51928 +       { 0x41,0x22,157}, /* 0x3b */  /* 16:9 modes  */
51929 +       { 0x52,0x07,149}, /* 0x3c */  /* 1280x960-85 */
51930 +       { 0x62,0xc6, 34}, /* 0x3d */  /* 848x480-60  */
51931 +       { 0x30,0x23, 88}, /* 0x3e */  /* 1360x768-60 */
51932 +#if 0
51933 +       { 0x3f,0x64, 46}, /* 0x3f */  /* 640x480-100 */
51934 +#endif
51935 +        { 0x70,0x29, 81}, /* 0x3f */  /* 1280x768-60 */
51936 +       { 0x72,0x2a, 76}, /* 0x40 */  /* test for SiS730 */
51937 +       { 0x15,0x21, 79}, /* 0x41 */  /* test for SiS730 */
51938 +       { 0xa1,0x42,108}, /* 0x42 */  /* 1280x960 LCD */
51939 +       { 0x37,0x61,100}, /* 0x43 */  /* 1280x960 LCD */
51940 +       { 0xe3,0x9a,106}, /* 0x44 */  /* 1360x1024 - special for Barco iQ R300 */
51941         { 0xff,0x00,  0}   
51942  };
51943  
51944 @@ -1089,66 +782,10 @@ static const SiS300_VCLKDataStruct  SiS3
51945  static const UCHAR  SiS300_ScreenOffset[] =
51946  {
51947         0x14,0x19,0x20,0x28,0x32,0x40,0x50,
51948 -        0x64,0x78,0x80,0x2d,0x35,0x48,0x35,  /* 0x35 for 848 and 856 */
51949 -       0x55,0xff                            /* 0x55 for 1360 */        
51950 +        0x64,0x78,0x80,0x2d,0x35,0x48,0x35,
51951 +       0x55,0x30,0xff
51952  };
51953  
51954 -typedef struct _SiS300_StResInfoStruct
51955 -{
51956 -       USHORT HTotal;
51957 -       USHORT VTotal;
51958 -} SiS300_StResInfoStruct;
51959 -
51960 -static const SiS300_StResInfoStruct  SiS300_StResInfo[] =
51961 -{
51962 -       { 640,400},
51963 -       { 640,350},
51964 -       { 720,400},
51965 -       { 720,350},
51966 -       { 640,480}
51967 -};
51968 -
51969 -typedef struct _SiS300_ModeResInfoStruct
51970 -{
51971 -       USHORT HTotal;
51972 -       USHORT VTotal;
51973 -       UCHAR  XChar;
51974 -       UCHAR  YChar;
51975 -} SiS300_ModeResInfoStruct;
51976 -
51977 -static const SiS300_ModeResInfoStruct  SiS300_ModeResInfo[] =
51978 -{
51979 -       {  320, 200, 8, 8},  /* 0x00 */
51980 -       {  320, 240, 8, 8},  /* 0x01 */
51981 -       {  320, 400, 8, 8},  /* 0x02 */
51982 -       {  400, 300, 8, 8},  /* 0x03 */
51983 -       {  512, 384, 8, 8},  /* 0x04 */
51984 -       {  640, 400, 8,16},  /* 0x05 */
51985 -       {  640, 480, 8,16},  /* 0x06 */
51986 -       {  800, 600, 8,16},  /* 0x07 */
51987 -       { 1024, 768, 8,16},  /* 0x08 */
51988 -       { 1280,1024, 8,16},  /* 0x09 */
51989 -       { 1600,1200, 8,16},  /* 0x0a */
51990 -       { 1920,1440, 8,16},  /* 0x0b */
51991 -       {  720, 480, 8,16},  /* 0x0c */
51992 -       {  720, 576, 8,16},  /* 0x0d */
51993 -       { 1280, 960, 8,16},  /* 0x0e */
51994 -       { 1024, 600, 8,16},  /* 0x0f */
51995 -       { 1152, 768, 8,16},  /* 0x10 */
51996 -       { 2048,1536, 8,16},  /* 0x11 - TW: Not in BIOS! */
51997 -       {  800, 480, 8,16},  /* 0x12 - TW: New, not in any BIOS */
51998 -       { 1024, 576, 8,16},  /* 0x13 - TW: New, not in any BIOS */
51999 -       { 1280, 720, 8,16},  /* 0x14 - TW: New, not in any BIOS */
52000 -       { 1152, 864, 8,16},  /* 0x15 - TW: New, not in any BIOS */
52001 -       {  848, 480, 8,16},  /* 0x16 - TW: New, not in any BIOS */
52002 -       {  856, 480, 8,16},  /* 0x17 - TW: New, not in any BIOS */
52003 -       { 1360, 768, 8,16}   /* 0x18 - TW: New, not in any BIOS */
52004 -};
52005 -
52006 -static const UCHAR SiS300_OutputSelect = 0x40;
52007 -
52008 -static const UCHAR SiS300_SoftSetting  = 0x30;
52009 -
52010  #ifndef LINUX_XF86
52011  static UCHAR SiS300_SR07 = 0x10;
52012  #endif
52013 @@ -1183,7 +820,7 @@ static UCHAR SiS300_CRT2Data_4_10 = 0x80
52014  static const USHORT SiS300_RGBSenseData = 0xd1;
52015  static const USHORT SiS300_VideoSenseData = 0xb3;
52016  static const USHORT SiS300_YCSenseData = 0xb9;
52017 -static const USHORT SiS300_RGBSenseData2 = 0x0190;     /*301b*/
52018 +static const USHORT SiS300_RGBSenseData2 = 0x0190;
52019  static const USHORT SiS300_VideoSenseData2 = 0x0174;
52020  static const USHORT SiS300_YCSenseData2 = 0x016b;
52021  
52022 @@ -1192,15 +829,6 @@ static const UCHAR SiS300_CR40[5][4];
52023  static UCHAR SiS300_CR49[2];
52024  #endif
52025  
52026 -static const UCHAR SiS300_NTSCPhase[]  = {0x21,0xed,0xba,0x08};  /* TW: Was {0x21,0xed,0x8a,0x08}; */
52027 -static const UCHAR SiS300_PALPhase[]   = {0x2a,0x05,0xe3,0x00};  /* TW: Was {0x2a,0x05,0xd3,0x00};  */
52028 -static const UCHAR SiS300_PALMPhase[]  = {0x21,0xE4,0x2E,0x9B};  /* palmn */
52029 -static const UCHAR SiS300_PALNPhase[]  = {0x21,0xF4,0x3E,0xBA};
52030 -static const UCHAR SiS300_NTSCPhase2[] = {0x21,0xF0,0x7B,0xD6};  /* 301b */
52031 -static const UCHAR SiS300_PALPhase2[]  = {0x2a,0x09,0x86,0xe9};  /* 301b */
52032 -static const UCHAR SiS300_PALMPhase2[] = {0x21,0xE6,0xEF,0xA4}; /* TW: palm 301b*/
52033 -static const UCHAR SiS300_PALNPhase2[] = {0x21,0xF6,0x94,0x46}; /* TW: paln 301b*/
52034 -
52035  typedef struct _SiS300_PanelDelayTblStruct
52036  {
52037         UCHAR timer[2];
52038 @@ -1208,7 +836,7 @@ typedef struct _SiS300_PanelDelayTblStru
52039  
52040  static const SiS300_PanelDelayTblStruct  SiS300_PanelDelayTbl[] =
52041  {
52042 -       {{0x05,0xaa}}, /* TW: From 2.04.5a */
52043 +       {{0x05,0xaa}},
52044         {{0x05,0x14}},
52045         {{0x05,0x36}},
52046         {{0x05,0x14}},
52047 @@ -1355,309 +983,6 @@ static const SiS300_LCDDataStruct  SiS30
52048         {    1,   1,1688,1066,1688,1066}
52049  };
52050  
52051 -static const SiS300_LCDDataStruct  SiS300_LCD1280x960Data[] =
52052 -{
52053 -       {    9,   2, 800, 500,1800,1000},
52054 -       {    9,   2, 800, 500,1800,1000},
52055 -       {    4,   1, 900, 500,1800,1000},
52056 -       {    4,   1, 900, 500,1800,1000},
52057 -       {    9,   2, 800, 500,1800,1000},
52058 -       {   30,  11,1056, 625,1800,1000},
52059 -       {    5,   3,1350, 800,1800,1000},
52060 -       {    1,   1,1576,1050,1576,1050},
52061 -       {    1,   1,1800,1000,1800,1000}
52062 -};
52063 -
52064 -static const SiS300_LCDDataStruct  SiS300_ExtLCD1400x1050Data[] =  /* TW: New */
52065 -{
52066 -       {    0,   0,   0,   0,   0,   0},
52067 -       {    0,   0,   0,   0,   0,   0},
52068 -       {    0,   0,   0,   0,   0,   0},
52069 -       {    0,   0,   0,   0,   0,   0},
52070 -       {    0,   0,   0,   0,   0,   0},
52071 -       {    0,   0,   0,   0,   0,   0},
52072 -       {    0,   0,   0,   0,   0,   0},
52073 -       {    0,   0,   0,   0,   0,   0},
52074 -       {    0,   0,   0,   0,   0,   0},
52075 -       {    0,   0,   0,   0,   0,   0}
52076 -};
52077 -
52078 -static const SiS300_LCDDataStruct  SiS300_ExtLCD1600x1200Data[] =  /* TW: New */
52079 -{
52080 -       {    0,   0,   0,   0,   0,   0},
52081 -       {    0,   0,   0,   0,   0,   0},
52082 -       {    0,   0,   0,   0,   0,   0},
52083 -       {    0,   0,   0,   0,   0,   0},
52084 -       {    0,   0,   0,   0,   0,   0},
52085 -       {    0,   0,   0,   0,   0,   0},
52086 -       {    0,   0,   0,   0,   0,   0},
52087 -       {    0,   0,   0,   0,   0,   0},
52088 -       {    0,   0,   0,   0,   0,   0},
52089 -       {    0,   0,   0,   0,   0,   0}
52090 -};
52091 -
52092 -static const SiS300_LCDDataStruct  SiS300_StLCD1400x1050Data[] =  /* TW: New */
52093 -{
52094 -       {    0,   0,   0,   0,   0,   0},
52095 -       {    0,   0,   0,   0,   0,   0},
52096 -       {    0,   0,   0,   0,   0,   0},
52097 -       {    0,   0,   0,   0,   0,   0},
52098 -       {    0,   0,   0,   0,   0,   0},
52099 -       {    0,   0,   0,   0,   0,   0},
52100 -       {    0,   0,   0,   0,   0,   0},
52101 -       {    0,   0,   0,   0,   0,   0},
52102 -       {    0,   0,   0,   0,   0,   0},
52103 -       {    0,   0,   0,   0,   0,   0}
52104 -};
52105 -
52106 -static const SiS300_LCDDataStruct  SiS300_StLCD1600x1200Data[] =  /* TW: New */
52107 -{
52108 -       {    0,   0,   0,   0,   0,   0},
52109 -       {    0,   0,   0,   0,   0,   0},
52110 -       {    0,   0,   0,   0,   0,   0},
52111 -       {    0,   0,   0,   0,   0,   0},
52112 -       {    0,   0,   0,   0,   0,   0},
52113 -       {    0,   0,   0,   0,   0,   0},
52114 -       {    0,   0,   0,   0,   0,   0},
52115 -       {    0,   0,   0,   0,   0,   0},
52116 -       {    0,   0,   0,   0,   0,   0},
52117 -       {    0,   0,   0,   0,   0,   0}
52118 -};
52119 -
52120 -static const SiS300_LCDDataStruct  SiS300_NoScaleData1400x1050[] =  /* TW: New */
52121 -{
52122 -       {    0,   0,   0,   0,   0,   0},
52123 -       {    0,   0,   0,   0,   0,   0},
52124 -       {    0,   0,   0,   0,   0,   0},
52125 -       {    0,   0,   0,   0,   0,   0},
52126 -       {    0,   0,   0,   0,   0,   0},
52127 -       {    0,   0,   0,   0,   0,   0},
52128 -       {    0,   0,   0,   0,   0,   0},
52129 -       {    0,   0,   0,   0,   0,   0},
52130 -       {    0,   0,   0,   0,   0,   0},
52131 -       {    0,   0,   0,   0,   0,   0}
52132 -};
52133 -
52134 -static const SiS300_LCDDataStruct  SiS300_NoScaleData1600x1200[] =  /* TW: New */
52135 -{
52136 -       {    0,   0,   0,   0,   0,   0},
52137 -       {    0,   0,   0,   0,   0,   0},
52138 -       {    0,   0,   0,   0,   0,   0},
52139 -       {    0,   0,   0,   0,   0,   0},
52140 -       {    0,   0,   0,   0,   0,   0},
52141 -       {    0,   0,   0,   0,   0,   0},
52142 -       {    0,   0,   0,   0,   0,   0},
52143 -       {    0,   0,   0,   0,   0,   0},
52144 -       {    0,   0,   0,   0,   0,   0},
52145 -       {    0,   0,   0,   0,   0,   0}
52146 -};
52147 -
52148 -
52149 -typedef struct _SiS300_TVDataStruct
52150 -{
52151 -       USHORT RVBHCMAX;
52152 -       USHORT RVBHCFACT;
52153 -       USHORT VGAHT;
52154 -       USHORT VGAVT;
52155 -       USHORT TVHDE;
52156 -       USHORT TVVDE;
52157 -       USHORT RVBHRS;
52158 -       UCHAR FlickerMode;
52159 -       USHORT HALFRVBHRS;
52160 -       UCHAR RY1COE;
52161 -       UCHAR RY2COE;
52162 -       UCHAR RY3COE;
52163 -       UCHAR RY4COE;
52164 -} SiS300_TVDataStruct;
52165 -
52166 -static const SiS300_TVDataStruct  SiS300_StPALData[] =
52167 -{
52168 -       {    1,   1, 864, 525,1270, 400, 100,   0, 760,0xf4,0xff,0x1c,0x22},
52169 -       {    1,   1, 864, 525,1270, 350, 100,   0, 760,0xf4,0xff,0x1c,0x22},
52170 -       {    1,   1, 864, 525,1270, 400,   0,   0, 720,0xf1,0x04,0x1f,0x18},
52171 -       {    1,   1, 864, 525,1270, 350,   0,   0, 720,0xf4,0x0b,0x1c,0x0a},
52172 -       {    1,   1, 864, 525,1270, 480,  50,   0, 760,0xf4,0xff,0x1c,0x22},
52173 -       {    1,   1, 864, 525,1270, 600,  50,   0,   0,0xf4,0xff,0x1c,0x22}
52174 -};
52175 -
52176 -static const SiS300_TVDataStruct  SiS300_ExtPALData[] =
52177 -{
52178 -       {   27,  10, 848, 448,1270, 530,  50,   0,  50,0xf4,0xff,0x1c,0x22},
52179 -       {  108,  35, 848, 398,1270, 530,  50,   0,  50,0xf4,0xff,0x1c,0x22},
52180 -       {   12,   5, 954, 448,1270, 530,  50,   0,  50,0xf1,0x04,0x1f,0x18},
52181 -       {    9,   4, 960, 463,1644, 438,  50,   0,  50,0xf4,0x0b,0x1c,0x0a},
52182 -       {    9,   4, 848, 528,1270, 530,   0,   0,  50,0xf5,0xfb,0x1b,0x2a},
52183 -       {   36,  25,1060, 648,1316, 530, 438,   0, 438,0xeb,0x05,0x25,0x16},
52184 -       {    3,   2,1080, 619,1270, 540, 438,   0, 438,0xf3,0x00,0x1d,0x20},
52185 -       {    1,   1,1170, 821,1270, 520, 686,   0, 686,0xF3,0x00,0x1D,0x20}
52186 -
52187 -};
52188 -
52189 -static const SiS300_TVDataStruct  SiS300_StNTSCData[] =
52190 -{
52191 -       {    1,   1, 858, 525,1270, 400,  50,   0, 760,0xf1,0x04,0x1f,0x18},
52192 -       {    1,   1, 858, 525,1270, 350,  50,   0, 640,0xf1,0x04,0x1f,0x18},
52193 -       {    1,   1, 858, 525,1270, 400,   0,   0, 720,0xf1,0x04,0x1f,0x18},
52194 -       {    1,   1, 858, 525,1270, 350,   0,   0, 720,0xf4,0x0b,0x1c,0x0a},
52195 -       {    1,   1, 858, 525,1270, 480,   0,   0, 760,0xf1,0x04,0x1f,0x18}
52196 -};
52197 -
52198 -static const SiS300_TVDataStruct  SiS300_ExtNTSCData[] =
52199 -{
52200 -       {  143,  65, 858, 443,1270, 440, 171,   0, 171,0xf1,0x04,0x1f,0x18},
52201 -       {   88,  35, 858, 393,1270, 440, 171,   0, 171,0xf1,0x04,0x1f,0x18},
52202 -       {  143,  70, 924, 443,1270, 440,  92,   0,  92,0xf1,0x04,0x1f,0x18},
52203 -       {  143,  70, 924, 393,1270, 440,  92,   0,  92,0xf4,0x0b,0x1c,0x0a},
52204 -       {  143,  76, 836, 523,1270, 440, 224,   0,   0,0xf1,0x05,0x1f,0x16},
52205 -       {  143, 120,1056, 643,1270, 440,   0, 128,   0,0xf4,0x10,0x1c,0x00},
52206 -       {  143,  76, 836, 523,1270, 440,   0, 128,   0,0xee,0x0c,0x22,0x08},
52207 -       {   65,  64,1056, 791,1270, 480, 638,   0,   0,0xf1,0x04,0x1f,0x18}
52208 -};
52209 -
52210 -#if 0
52211 -static const SiS300_TVDataStruct  SiS300_St1HiTVData[]=
52212 -{
52213 -  
52214 -};
52215 -#endif
52216 -
52217 -static const SiS300_TVDataStruct  SiS300_St2HiTVData[]=
52218 -{
52219 - {    3,   1, 0x348,0x1e3,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},
52220 - {    1,   1, 0x37c,0x233,0x2b2,0x2bc,           0,  0, 0, 0x00,0x00,0x00,0x00},
52221 - {    3,   1, 0x348,0x1e3,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},
52222 - {    1,   1, 0x3e8,0x233,0x311,0x2bc,    0,  0, 0, 0x00,0x00,0x00,0x00},
52223 - {    5,   2, 0x348,0x233,0x670,0x3c0,0x08d,128, 0, 0x00,0x00,0x00,0x00},
52224 - {    8,   5, 0x41a,0x2ab,0x670,0x3c0,0x17c,128, 0, 0x00,0x00,0x00,0x00}
52225 -};
52226 -
52227 -static const SiS300_TVDataStruct  SiS300_ExtHiTVData[]=
52228 -{
52229 - {    6,   1, 0x348,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
52230 - {    3,   1, 0x3c0,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
52231 - {    3,   1, 0x348,0x1e3,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
52232 - {    3,   1, 0x3c0,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
52233 - {    5,   1, 0x348,0x233,0x670,0x3c0,0x166,128, 0, 0x00,0x00,0x00,0x00},
52234 - {   16,   5, 0x41a,0x2ab,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00},
52235 - {   25,  12, 0x4ec,0x353,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},
52236 - {    5,   4, 0x627,0x464,0x670,0x3c0,0x128,  0, 0, 0x00,0x00,0x00,0x00},
52237 - {    4,   1, 0x41a,0x233,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00},
52238 - {    5,   2, 0x578,0x293,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},
52239 - {    8,   5, 0x6d6,0x323,0x670,0x3c0,0x128,  0, 0, 0x00,0x00,0x00,0x00}
52240 -};
52241 -
52242 -static const UCHAR SiS300_NTSCTiming[] =
52243 -{
52244 -       0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c,
52245 -       0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a,
52246 -       0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b,
52247 -       0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17,  /* (in 2.06.50) */
52248 -/*     0x0c,0x50,0x00,0x99,0x00,0xec,0x4a,0x17,     (in 2.04.5a) */
52249 -       0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02,  /* (in 2.06.50) */
52250 -/*     0x88,0x00,0x4b,0x00,0x00,0xe2,0x00,0x02,     (in 2.04.5a) */
52251 -       0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40,
52252 -       0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x50,
52253 -       0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00
52254 -};
52255 -
52256 -static const UCHAR SiS300_PALTiming[] =
52257 -{
52258 -       0x19,0x52,0x35,0x6e,0x04,0x38,0x3d,0x70,
52259 -       0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d,
52260 -       0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b,
52261 -        0x70,0x50,0x00,0x9b,0x00,0xd9,0x5d,0x17,  /* (in 2.06.50) */
52262 -/*     0x70,0x50,0x00,0x97,0x00,0xd7,0x5d,0x17,     (in 2.04.5a) */
52263 -       0x7d,0x05,0x45,0x00,0x00,0xe8,0x00,0x02,  /* (in 2.06.50) */
52264 -/*     0x88,0x00,0x45,0x00,0x00,0xe8,0x00,0x02,     (in 2.04.5a) */
52265 -       0x0d,0x00,0x68,0xb0,0x0b,0x92,0x8f,0x40,
52266 -       0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63,
52267 -       0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00
52268 -};
52269 -
52270 -static const UCHAR SiS300_HiTVExtTiming[] =     /* TW: New */
52271 -{
52272 -        0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64,
52273 -       0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
52274 -       0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
52275 -       0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13,
52276 -       0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40,
52277 -       0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40,
52278 -       0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d,
52279 -       0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00
52280 -};
52281 -
52282 -static const UCHAR SiS300_HiTVSt1Timing[] =    /* TW: New */
52283 -{
52284 -        0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65,
52285 -       0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
52286 -       0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
52287 -       0x65,0x90,0x7b,0xa8,0x03,0xf0,0x87,0x03,
52288 -       0x11,0x15,0x11,0xcf,0x10,0x11,0xcf,0x10,
52289 -       0x35,0x35,0x3b,0x69,0x1d,0x92,0x0f,0x40,
52290 -       0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x86,
52291 -       0xaf,0x5d,0x0e,0x00,0xfc,0xff,0x2d,0x00
52292 -};
52293 -
52294 -static const UCHAR SiS300_HiTVSt2Timing[] =    /* TW: New */
52295 -{
52296 -        0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64,
52297 -       0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
52298 -       0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
52299 -       0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13,
52300 -       0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40,
52301 -       0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40,
52302 -       0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d,
52303 -       0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00
52304 -};
52305 -
52306 -static const UCHAR SiS300_HiTVTextTiming[] =           /* TW: New */
52307 -{
52308 -        0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65,
52309 -       0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
52310 -       0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
52311 -       0x65,0x90,0xe7,0xbc,0x03,0x0c,0x97,0x03,
52312 -       0x14,0x78,0x14,0x08,0x20,0x14,0x08,0x20,
52313 -       0xc8,0xc8,0x3b,0xd2,0x26,0x92,0x0f,0x40,
52314 -        0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x96,
52315 -       0x72,0x5c,0x11,0x00,0xfc,0xff,0x32,0x00
52316 -};
52317 -
52318 -static const UCHAR SiS300_HiTVGroup3Data[] =           /* TW: New */
52319 -{
52320 -        0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f,
52321 -       0x05,0x21,0xb2,0xb2,0x55,0x77,0x2a,0xa6,
52322 -       0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
52323 -       0x8c,0x6e,0x60,0x2e,0x58,0x48,0x72,0x44,
52324 -       0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
52325 -       0x4f,0x7f,0x03,0xa8,0x7d,0x20,0x1a,0xa9,
52326 -       0x14,0x05,0x03,0x7e,0x64,0x31,0x14,0x75,
52327 -       0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
52328 -};
52329 -
52330 -static const UCHAR SiS300_HiTVGroup3Simu[] =           /* TW: New */
52331 -{
52332 -        0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x95,
52333 -       0xdb,0x20,0xb8,0xb8,0x55,0x47,0x2a,0xa6,
52334 -       0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
52335 -       0x8c,0x6e,0x60,0x15,0x26,0xd3,0xe4,0x11,
52336 -       0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
52337 -       0x67,0x36,0x01,0x47,0x0e,0x10,0xbe,0xb4,
52338 -       0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75,
52339 -       0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
52340 -};
52341 -
52342 -static const UCHAR SiS300_HiTVGroup3Text[] =           /* TW: New */
52343 -{
52344 -        0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0xa7,
52345 -       0xf5,0x20,0xce,0xce,0x55,0x47,0x2a,0xa6,
52346 -       0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
52347 -       0x8c,0x6e,0x60,0x18,0x2c,0x0c,0x20,0x22,
52348 -       0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
52349 -       0x93,0x3c,0x01,0x50,0x2f,0x10,0xf4,0xca,
52350 -       0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75,
52351 -       0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
52352 -};
52353 -
52354  typedef struct _SiS300_LVDSDataStruct
52355  {
52356         USHORT VGAHT;
52357 @@ -1666,366 +991,14 @@ typedef struct _SiS300_LVDSDataStruct
52358         USHORT LCDVT;
52359  } SiS300_LVDSDataStruct;
52360  
52361 -static const SiS300_LVDSDataStruct  SiS300_LVDS320x480Data_1[] =
52362 -{
52363 -       {848, 433,400, 525},
52364 -       {848, 389,400, 525},
52365 -       {848, 433,400, 525},
52366 -       {848, 389,400, 525},
52367 -       {848, 518,400, 525},
52368 -       {1056,628,400, 525},
52369 -       {400, 525,400, 525},
52370 -       {800, 449,1000, 644},
52371 -       {800, 525,1000, 635}
52372 -};
52373 -
52374 -static const SiS300_LVDSDataStruct  SiS300_LVDS800x600Data_1[] =
52375 -{
52376 -       {848, 433,1060, 629},
52377 -       {848, 389,1060, 629},
52378 -       {848, 433,1060, 629},
52379 -       {848, 389,1060, 629},
52380 -       {848, 518,1060, 629},
52381 -       {1056, 628,1056, 628},
52382 -       {1056, 628,1056, 628},
52383 -       {800, 449,1000, 644},
52384 -       {800, 525,1000, 635}
52385 -};
52386 -
52387 -static const SiS300_LVDSDataStruct  SiS300_LVDS800x600Data_2[] =
52388 -{
52389 -       {1056, 628,1056, 628},
52390 -       {1056, 628,1056, 628},
52391 -       {1056, 628,1056, 628},
52392 -       {1056, 628,1056, 628},
52393 -       {1056, 628,1056, 628},
52394 -       {1056, 628,1056, 628},
52395 -       {1056, 628,1056, 628},
52396 -       {800, 449,1000, 644},
52397 -       {800, 525,1000, 635}
52398 -};
52399 -
52400 -static const SiS300_LVDSDataStruct  SiS300_LVDS1024x768Data_1[] =
52401 -{
52402 -       {840, 438,1344, 806},
52403 -       {840, 409,1344, 806},
52404 -       {840, 438,1344, 806},
52405 -       {840, 409,1344, 806},
52406 -       {840, 518,1344, 806},
52407 -       {1050, 638,1344, 806},
52408 -       {1344, 806,1344, 806},
52409 -       {800, 449,1280, 801},
52410 -       {800, 525,1280, 813}
52411 -};
52412 -
52413 -static const SiS300_LVDSDataStruct  SiS300_LVDS1024x768Data_2[] =
52414 -{
52415 -       {1344, 806,1344, 806},
52416 -       {1344, 806,1344, 806},
52417 -       {1344, 806,1344, 806},
52418 -       {1344, 806,1344, 806},
52419 -       {1344, 806,1344, 806},
52420 -       {1344, 806,1344, 806},
52421 -       {1344, 806,1344, 806},
52422 -       {800, 449,1280, 801},
52423 -       {800, 525,1280, 813}
52424 -};
52425 -
52426 -static const SiS300_LVDSDataStruct  SiS300_LVDS1280x1024Data_1[]=  
52427 -{      
52428 -       {1048, 442,1688,1066},
52429 -       {1048, 392,1688,1066},
52430 -       {1048, 442,1688,1066},
52431 -       {1048, 392,1688,1066},
52432 -       {1048, 522,1688,1066},
52433 -       {1208, 642,1688,1066},
52434 -       {1432, 810,1688,1066},
52435 -       {1688,1066,1688,1066}
52436 -};
52437 -
52438 -static const SiS300_LVDSDataStruct  SiS300_LVDS1280x1024Data_2[]=  
52439 -{      
52440 -       {1688,1066,1688,1066},
52441 -       {1688,1066,1688,1066},
52442 -       {1688,1066,1688,1066},
52443 -       {1688,1066,1688,1066},
52444 -       {1688,1066,1688,1066},
52445 -       {1688,1066,1688,1066},
52446 -       {1688,1066,1688,1066},
52447 -       {1688,1066,1688,1066}
52448 -};
52449 -
52450 -static const SiS300_LVDSDataStruct  SiS300_LVDS1400x1050Data_1[] =   
52451 -{
52452 -        {928, 416, 1688, 1066},
52453 -       {928, 366, 1688, 1066},
52454 -       {928, 416, 1688, 1066},
52455 -       {928, 366, 1688, 1066},
52456 -       {928, 496, 1688, 1066},
52457 -       {1088, 616, 1688, 1066},
52458 -       {1312, 784, 1688, 1066},
52459 -       {1568, 1040, 1688, 1066},
52460 -       {1688, 1066, 1688, 1066}
52461 -};
52462 -
52463 -static const SiS300_LVDSDataStruct  SiS300_LVDS1400x1050Data_2[] =  
52464 -{
52465 -        {1688,1066, 1688,1066},
52466 -       {1688,1066, 1688,1066},
52467 -       {1688,1066, 1688,1066},
52468 -       {1688,1066, 1688,1066},
52469 -       {1688,1066, 1688,1066},
52470 -       {1688,1066, 1688,1066},
52471 -       {1688,1066, 1688,1066},
52472 -       {1688,1066, 1688,1066},
52473 -       {1688,1066, 1688,1066},
52474 -};
52475 -
52476 -static const SiS300_LVDSDataStruct  SiS300_LVDS1600x1200Data_1[]=  
52477 -{
52478 -        {1088, 450, 2048,1250},
52479 -       {1088, 400, 2048,1250},
52480 -       {1088, 450, 2048,1250},
52481 -       {1088, 400, 2048,1250},
52482 -       {1088, 530, 2048,1250},
52483 -       {1248, 650, 2048,1250},
52484 -       {1472, 818, 2048,1250},
52485 -       {1728,1066, 2048,1250},
52486 -       {1848,1066, 2048,1250},
52487 -       {2048,1250, 2048,1250}
52488 -};
52489 -
52490 -static const SiS300_LVDSDataStruct  SiS300_LVDS1600x1200Data_2[]= 
52491 -{
52492 -        {2048,1250, 2048,1250},
52493 -       {2048,1250, 2048,1250},
52494 -       {2048,1250, 2048,1250},
52495 -       {2048,1250, 2048,1250},
52496 -       {2048,1250, 2048,1250},
52497 -       {2048,1250, 2048,1250},
52498 -       {2048,1250, 2048,1250},
52499 -       {2048,1250, 2048,1250},
52500 -       {2048,1250, 2048,1250},
52501 -       {2048,1250, 2048,1250}
52502 -};
52503 -
52504 -static const SiS300_LVDSDataStruct  SiS300_LVDS1280x768Data_1[]= 
52505 -{      
52506 -       { 768, 438, 1408, 806},
52507 -       { 768, 388, 1408, 806},
52508 -       { 768, 438, 1408, 806},
52509 -       { 768, 388, 1408, 806},
52510 -       { 768, 518, 1408, 806},
52511 -       { 928, 638, 1408, 806},
52512 -       {1152, 806, 1408, 806},
52513 -       {1408, 806, 1408, 806},
52514 -       {1408, 806, 1408, 806}
52515 -};
52516 -
52517 -static const SiS300_LVDSDataStruct  SiS300_LVDS1280x768Data_2[]=  
52518 -{      
52519 -       {1408, 806, 1408, 806},
52520 -       {1408, 806, 1408, 806},
52521 -       {1408, 806, 1408, 806},
52522 -       {1408, 806, 1408, 806},
52523 -       {1408, 806, 1408, 806},
52524 -       {1408, 806, 1408, 806},
52525 -       {1408, 806, 1408, 806},
52526 -       {1408, 806, 1408, 806},
52527 -       {1408, 806, 1408, 806}
52528 -};
52529 -
52530 -static const SiS300_LVDSDataStruct  SiS300_LVDS1024x600Data_1[] =
52531 -{
52532 -       {840, 604,1344, 800},
52533 -       {840, 560,1344, 800},
52534 -       {840, 604,1344, 800},
52535 -       {840, 560,1344, 800},
52536 -       {840, 689,1344, 800},
52537 -       {1050, 800,1344, 800},
52538 -       {1344, 800,1344, 800},
52539 -       {800, 449,1280, 789},
52540 -       {800, 525,1280, 785}
52541 -};
52542 -
52543 -static const SiS300_LVDSDataStruct  SiS300_LVDS1024x600Data_2[] =
52544 -{
52545 -       {1344, 800,1344, 800},
52546 -       {1344, 800,1344, 800},
52547 -       {1344, 800,1344, 800},
52548 -       {1344, 800,1344, 800},
52549 -       {1344, 800,1344, 800},
52550 -       {1344, 800,1344, 800},
52551 -       {1344, 800,1344, 800},
52552 -       {800, 449,1280, 801},
52553 -       {800, 525,1280, 813}
52554 -};
52555 -
52556 -static const SiS300_LVDSDataStruct  SiS300_LVDS1152x768Data_1[] =
52557 -{
52558 -       {840, 438,1344, 806},
52559 -       {840, 409,1344, 806},
52560 -       {840, 438,1344, 806},
52561 -       {840, 409,1344, 806},
52562 -       {840, 518,1344, 806},
52563 -       {1050, 638,1344, 806},
52564 -       {1344, 806,1344, 806},
52565 -       {800, 449,1280, 801},
52566 -       {800, 525,1280, 813}
52567 -};
52568 -
52569 -static const SiS300_LVDSDataStruct  SiS300_LVDS1152x768Data_2[] =
52570 -{
52571 -       {1344, 806,1344, 806},
52572 -       {1344, 806,1344, 806},
52573 -       {1344, 806,1344, 806},
52574 -       {1344, 806,1344, 806},
52575 -       {1344, 806,1344, 806},
52576 -       {1344, 806,1344, 806},
52577 -       {1344, 806,1344, 806},
52578 -       {800, 449,1280, 801},
52579 -       {800, 525,1280, 813}
52580 -};
52581 -
52582 -/* TW: pass 1:1 data */
52583 -static const SiS300_LVDSDataStruct  SiS300_LVDSXXXxXXXData_1[]=  
52584 -{
52585 -        { 800, 449,  800, 449},
52586 -       { 800, 449,  800, 449},
52587 -       { 900, 449,  900, 449},
52588 -       { 900, 449,  900, 449},
52589 -       { 800, 525,  800, 525},  /*  640x480   */
52590 -       {1056, 628, 1056, 628},  /*  800x600   */
52591 -       {1344, 806, 1344, 806},  /* 1024x768   */
52592 -       {1344,1066, 1344,1066},  /* 1280x1024  */  /* INSERTED ! */
52593 -       {1688, 806, 1688, 806},  /* 1280x768 ! */
52594 -       /* No other panels ! */
52595 -};
52596 -
52597 -static const SiS300_LVDSDataStruct  SiS300_LVDS640x480Data_1[] =
52598 -{
52599 -       {800, 449, 800, 449},
52600 -       {800, 449, 800, 449},
52601 -       {800, 449, 800, 449},
52602 -       {800, 449, 800, 449},
52603 -       {800, 525, 800, 525},
52604 -       {1056, 628,1056, 628},
52605 -       {1056, 628,1056, 628},
52606 -       {1056, 628,1056, 628},
52607 -       {1056, 628,1056, 628}
52608 -};
52609 -
52610 -static const SiS300_LVDSDataStruct  SiS300_LVDS1280x960Data_1[] =   /* TW: New */
52611 -{
52612 -       {840, 438,1344, 806},
52613 -       {840, 409,1344, 806},
52614 -       {840, 438,1344, 806},
52615 -       {840, 409,1344, 806},
52616 -       {840, 518,1344, 806},
52617 -       {1050, 638,1344, 806},
52618 -       {1344, 806,1344, 806},
52619 -       {800, 449,1280, 801},
52620 -       {800, 525,1280, 813}
52621 -};
52622 -
52623 -static const SiS300_LVDSDataStruct  SiS300_LVDS1280x960Data_2[] =   /* TW: New */
52624 -{
52625 -       {1344, 806,1344, 806},
52626 -       {1344, 806,1344, 806},
52627 -       {1344, 806,1344, 806},
52628 -       {1344, 806,1344, 806},
52629 -       {1344, 806,1344, 806},
52630 -       {1344, 806,1344, 806},
52631 -       {1344, 806,1344, 806},
52632 -       {800, 449,1280, 801},
52633 -       {800, 525,1280, 813}
52634 -};
52635 -
52636 -static const SiS300_LVDSDataStruct  SiS300_LCDA1400x1050Data_1[] =   /* TW: New */
52637 -{      /* TW: Might be temporary (invalid) data */
52638 -        {928, 416, 1688, 1066},
52639 -       {928, 366, 1688, 1066},
52640 -       {1008, 416, 1688, 1066},
52641 -       {1008, 366, 1688, 1066},
52642 -       {1200, 530, 1688, 1066},
52643 -       {1088, 616, 1688, 1066},
52644 -       {1312, 784, 1688, 1066},
52645 -       {1568, 1040, 1688, 1066},
52646 -       {1688, 1066, 1688, 1066}
52647 -};
52648 -
52649 -static const SiS300_LVDSDataStruct  SiS300_LCDA1400x1050Data_2[] =   /* TW: New */
52650 -{      /* TW: Temporary data. Not valid */
52651 -       {1344, 806,1344, 806},
52652 -       {1344, 806,1344, 806},
52653 -       {1344, 806,1344, 806},
52654 -       {1344, 806,1344, 806},
52655 -       {1344, 806,1344, 806},
52656 -       {1344, 806,1344, 806},
52657 -       {1344, 806,1344, 806},
52658 -       {800, 449,1280, 801},
52659 -       {800, 525,1280, 813}
52660 -};
52661 -
52662 -static const SiS300_LVDSDataStruct  SiS300_LCDA1600x1200Data_1[] =   /* TW: New */
52663 -{      /* TW: Temporary data. Not valid */
52664 -       {1344, 806,1344, 806},
52665 -       {1344, 806,1344, 806},
52666 -       {1344, 806,1344, 806},
52667 -       {1344, 806,1344, 806},
52668 -       {1344, 806,1344, 806},
52669 -       {1344, 806,1344, 806},
52670 -       {1344, 806,1344, 806},
52671 -       {800, 449,1280, 801},
52672 -       {800, 525,1280, 813}
52673 -};
52674 -
52675 -static const SiS300_LVDSDataStruct  SiS300_LCDA1600x1200Data_2[] =   /* TW: New */
52676 -{      /* TW: Temporary data. Not valid */
52677 -       {0, 0, 0, 0},
52678 -       {0, 0, 0, 0},
52679 -       {0, 0, 0, 0},
52680 -       {0, 0, 0, 0},
52681 -       {0, 0, 0, 0},
52682 -       {0, 0, 0, 0},
52683 -       {0, 0, 0, 0},
52684 -       {0, 0, 0, 0},
52685 -       {0, 0, 0, 0},
52686 -       {0, 0, 0, 0},
52687 -       {0, 0, 0, 0},
52688 -       {0, 0, 0, 0}
52689 -};
52690 -
52691 -
52692 -/* TW: New: */
52693 -static const SiS300_LVDSDataStruct  SiS300_CHTVUNTSCData[] =
52694 -{
52695 -       {840, 600, 840, 600},
52696 -       {840, 600, 840, 600},
52697 -       {840, 600, 840, 600},
52698 -       {840, 600, 840, 600},
52699 -       {784, 600, 784, 600},
52700 -       {1064, 750,1064, 750}
52701 -};
52702 -
52703 -static const SiS300_LVDSDataStruct  SiS300_CHTVONTSCData[] =
52704 -{
52705 -       {840, 525, 840, 525},
52706 -       {840, 525, 840, 525},
52707 -       {840, 525, 840, 525},
52708 -       {840, 525, 840, 525},
52709 -       {784, 525, 784, 525},
52710 -       {1040, 700,1040, 700}
52711 -};
52712 -
52713  static const SiS300_LVDSDataStruct  SiS300_CHTVUPALData[] =
52714  {
52715         {1008, 625,1008, 625},
52716         {1008, 625,1008, 625},
52717         {1008, 625,1008, 625},
52718         {1008, 625,1008, 625},
52719 -       {840, 750, 840, 750},
52720 -       {936, 836, 936, 836}
52721 +       { 840, 750, 840, 750},
52722 +       { 936, 836, 936, 836}
52723  };
52724  
52725  static const SiS300_LVDSDataStruct  SiS300_CHTVOPALData[] =
52726 @@ -2034,8 +1007,8 @@ static const SiS300_LVDSDataStruct  SiS3
52727         {1008, 625,1008, 625},
52728         {1008, 625,1008, 625},
52729         {1008, 625,1008, 625},
52730 -       {840, 625, 840, 625},
52731 -       {960, 750, 960, 750}
52732 +       { 840, 625, 840, 625},
52733 +       { 960, 750, 960, 750}
52734  };
52735  
52736  static const SiS300_LVDSDataStruct  SiS300_CHTVSOPALData[] =
52737 @@ -2044,12 +1017,10 @@ static const SiS300_LVDSDataStruct  SiS3
52738         {1008, 625,1008, 625},
52739         {1008, 625,1008, 625},
52740         {1008, 625,1008, 625},
52741 -       {840, 500, 840, 500},
52742 -       {944, 625, 944, 625}
52743 +       { 840, 500, 840, 500},
52744 +       { 944, 625, 944, 625}
52745  };
52746  
52747 -/* TW: new end */
52748 -
52749  typedef struct _SiS300_LVDSDesStruct
52750  {
52751         USHORT LCDHDES;
52752 @@ -2058,57 +1029,90 @@ typedef struct _SiS300_LVDSDesStruct
52753  
52754  static const SiS300_LVDSDesStruct  SiS300_PanelType00_1[] =
52755  {
52756 +       { 1059, 626 },   /* 2.08 */
52757 +       { 1059, 624 },
52758 +       { 1059, 626 },
52759 +       { 1059, 624 },
52760 +       { 1059, 624 },
52761 +       {    0, 627 },
52762 +       {    0, 627 },
52763 +       {    0,   0 },
52764 +       {    0,   0 }
52765 +#if 0
52766         {0, 626},
52767         {0, 624},
52768         {0, 626},
52769         {0, 624},
52770         {0, 624},
52771 -       { 0, 627},
52772 -       { 0, 627},
52773 -       { 0,   0},
52774 -       { 0,   0}
52775 +       {0, 627},
52776 +       {0, 627},
52777 +       {0,   0},
52778 +       {0,   0}
52779 +#endif
52780  };
52781  
52782  static const SiS300_LVDSDesStruct  SiS300_PanelType01_1[] =
52783  {
52784 +       {   0,   0 },  /* 2.08 */
52785 +       {   0,   0 },
52786 +       {   0,   0 },
52787 +       {   0,   0 },
52788 +       {   0,   0 },
52789 +       {   0,   0 },
52790 +       {   0,   0 },
52791 +       {   0,   0 },
52792 +       {   0,   0 }
52793 +#if 0
52794         {1343, 798},
52795         {1343, 794},
52796         {1343, 798},
52797         {1343, 794},
52798         {1343,   0},
52799         {1343,   0},
52800 -       { 0, 805},
52801 -       { 0, 794},
52802 -       { 0,   0}
52803 +       {   0, 805},
52804 +       {   0, 794},
52805 +       {   0,   0}
52806 +#endif
52807  };
52808  
52809  static const SiS300_LVDSDesStruct  SiS300_PanelType02_1[] =
52810  {
52811 +       { 1059, 626 },  /* 2.08 */
52812 +       { 1059, 624 },
52813 +       { 1059, 626 },
52814 +       { 1059, 624 },
52815 +       { 1059, 624 },
52816 +       {    0, 627 },
52817 +       {    0, 627 },
52818 +       {    0,   0 },
52819 +       {    0,   0 }
52820 +#if 0
52821         {0, 626},
52822         {0, 624},
52823         {0, 626},
52824         {0, 624},
52825         {0, 624},
52826 -       { 0, 627},
52827 -       { 0, 627},
52828 -       { 0,   0},
52829 -       { 0,   0}
52830 +       {0, 627},
52831 +       {0, 627},
52832 +       {0,   0},
52833 +       {0,   0}
52834 +#endif
52835  };
52836  
52837  static const SiS300_LVDSDesStruct  SiS300_PanelType03_1[] =
52838  {
52839 -       { 8, 436},
52840 -       { 8, 440},
52841 -       { 8, 436},
52842 -       { 8, 440},
52843 -       { 8, 512},
52844 +       {   8, 436},
52845 +       {   8, 440},
52846 +       {   8, 436},
52847 +       {   8, 440},
52848 +       {   8, 512},
52849         {1343, 798},
52850         {1343, 794},
52851         {1343, 798},
52852         {1343, 794}
52853  };
52854  
52855 -static const SiS300_LVDSDesStruct  SiS300_PanelType04_1[] =
52856 +static const SiS300_LVDSDesStruct  SiS300_PanelType04_1[] =    /* 1280x1024 */
52857  {
52858         {1343, 798},
52859         {1343, 794},
52860 @@ -2116,9 +1120,9 @@ static const SiS300_LVDSDesStruct  SiS30
52861         {1343, 794},
52862         {1343,   0},
52863         {1343,   0},
52864 -       { 0, 805},
52865 -       { 0, 794},
52866 -       { 0,   0}
52867 +       {   0, 805},
52868 +       {   0, 794},
52869 +       {   0,   0}
52870  };
52871  
52872  static const SiS300_LVDSDesStruct  SiS300_PanelType05_1[] =
52873 @@ -2129,9 +1133,9 @@ static const SiS300_LVDSDesStruct  SiS30
52874         {1343, 794},
52875         {1343,   0},
52876         {1343,   0},
52877 -       { 0, 805},
52878 -       { 0, 794},
52879 -       { 0,   0}
52880 +       {   0, 805},
52881 +       {   0, 794},
52882 +       {   0,   0}
52883  };
52884  
52885  static const SiS300_LVDSDesStruct  SiS300_PanelType06_1[] =
52886 @@ -2142,9 +1146,9 @@ static const SiS300_LVDSDesStruct  SiS30
52887         {1343, 794},
52888         {1343,   0},
52889         {1343,   0},
52890 -       { 0, 805},
52891 -       { 0, 794},
52892 -       { 0,   0}
52893 +       {   0, 805},
52894 +       {   0, 794},
52895 +       {   0,   0}
52896  };
52897  
52898  static const SiS300_LVDSDesStruct  SiS300_PanelType07_1[] =
52899 @@ -2155,9 +1159,9 @@ static const SiS300_LVDSDesStruct  SiS30
52900         {1343, 794},
52901         {1343,   0},
52902         {1343,   0},
52903 -       { 0, 805},
52904 -       { 0, 794},
52905 -       { 0,   0}
52906 +       {   0, 805},
52907 +       {   0, 794},
52908 +       {   0,   0}
52909  };
52910  
52911  static const SiS300_LVDSDesStruct  SiS300_PanelType08_1[] =
52912 @@ -2167,10 +1171,10 @@ static const SiS300_LVDSDesStruct  SiS30
52913         {1059, 626},
52914         {1059, 624},
52915         {1059, 624},
52916 -       { 0, 627},
52917 -       { 0, 627},
52918 -       { 0,   0},
52919 -       { 0,   0}
52920 +       {   0, 627},
52921 +       {   0, 627},
52922 +       {   0,   0},
52923 +       {   0,   0}
52924  };
52925  
52926  static const SiS300_LVDSDesStruct  SiS300_PanelType09_1[] =
52927 @@ -2181,9 +1185,9 @@ static const SiS300_LVDSDesStruct  SiS30
52928         {1343, 794},
52929         {1343,   0},
52930         {1343,   0},
52931 -       { 0, 805},
52932 -       { 0, 794},
52933 -       { 0,   0}
52934 +       {   0, 805},
52935 +       {   0, 794},
52936 +       {   0,   0}
52937  };
52938  
52939  static const SiS300_LVDSDesStruct  SiS300_PanelType0a_1[] =
52940 @@ -2193,23 +1197,23 @@ static const SiS300_LVDSDesStruct  SiS30
52941         {1059, 626},
52942         {1059, 624},
52943         {1059, 624},
52944 -       { 0, 627},
52945 -       { 0, 627},
52946 -       { 0,   0},
52947 -       { 0,   0}
52948 +       {   0, 627},
52949 +       {   0, 627},
52950 +       {   0,   0},
52951 +       {   0,   0}
52952  };
52953  
52954  static const SiS300_LVDSDesStruct  SiS300_PanelType0b_1[] =
52955  {
52956 -       {1343, 0},
52957 -       {1343, 0},
52958 -       {1343, 0},
52959 -       {1343, 0},
52960 -       {1343, 0},   /* 640x480 - BIOS 1343, 0 */
52961 -       {1343, 0},
52962 -       { 0, 799},
52963 -       { 0, 0},
52964 -       { 0, 0}
52965 +       {1343,   0},
52966 +       {1343,   0},
52967 +       {1343,   0},
52968 +       {1343,   0},
52969 +       {1343,   0},
52970 +       {1343,   0},
52971 +       {   0, 799},
52972 +       {   0,   0},
52973 +       {   0,   0}
52974  };
52975  
52976  static const SiS300_LVDSDesStruct  SiS300_PanelType0c_1[] =
52977 @@ -2220,9 +1224,9 @@ static const SiS300_LVDSDesStruct  SiS30
52978         {1343, 794},
52979         {1343,   0},
52980         {1343,   0},
52981 -       { 0, 805},
52982 -       { 0, 794},
52983 -       { 0,   0}
52984 +       {   0, 805},
52985 +       {   0, 794},
52986 +       {   0,   0}
52987  };
52988  
52989  static const SiS300_LVDSDesStruct  SiS300_PanelType0d_1[] =
52990 @@ -2233,9 +1237,9 @@ static const SiS300_LVDSDesStruct  SiS30
52991         {1343, 794},
52992         {1343,   0},
52993         {1343,   0},
52994 -       { 0, 805},
52995 -       { 0, 794},
52996 -       { 0,   0}
52997 +       {   0, 805},
52998 +       {   0, 794},
52999 +       {   0,   0}
53000  };
53001  
53002  static const SiS300_LVDSDesStruct  SiS300_PanelType0e_1[] =
53003 @@ -2244,11 +1248,11 @@ static const SiS300_LVDSDesStruct  SiS30
53004         {1343, 794},
53005         {1343, 798},
53006         {1343, 794},
53007 -       {1343,   0},  /* 640x480 */
53008 -       {1343,   0},  /* 800x600 */
53009 -       { 0, 805},    /* 1024x768 */
53010 -       { 0, 794},    /* 1280x1024 */
53011 -       { 0,   0}     /* 1280x960 - not applicable */
53012 +       {1343,   0},    /* 640x480 */
53013 +       {1343,   0},    /* 800x600 */
53014 +       {   0, 805},    /* 1024x768 */
53015 +       {   0, 794},    /* 1280x1024 */
53016 +       {   0,   0}     /* 1280x960 - not applicable */
53017  };
53018  
53019  static const SiS300_LVDSDesStruct  SiS300_PanelType0f_1[] =
53020 @@ -2259,9 +1263,9 @@ static const SiS300_LVDSDesStruct  SiS30
53021         {1343, 794},
53022         {1343,   0},
53023         {1343,   0},
53024 -       { 0, 805},
53025 -       { 0, 794},
53026 -       { 0,   0}
53027 +       {   0, 805},
53028 +       {   0, 794},
53029 +       {   0,   0}
53030  };
53031  
53032  static const SiS300_LVDSDesStruct  SiS300_PanelType00_2[] =
53033 @@ -2271,10 +1275,10 @@ static const SiS300_LVDSDesStruct  SiS30
53034         {976, 527},
53035         {976, 502},
53036         {976, 567},
53037 -       { 0, 627},
53038 -       { 0, 627},
53039 -       { 0,   0},
53040 -       { 0,   0}
53041 +       {  0, 627},
53042 +       {  0, 627},
53043 +       {  0,   0},
53044 +       {  0,   0}
53045  };
53046  
53047  static const SiS300_LVDSDesStruct  SiS300_PanelType01_2[] =
53048 @@ -2285,9 +1289,9 @@ static const SiS300_LVDSDesStruct  SiS30
53049         {1152, 597},
53050         {1152, 662},
53051         {1232, 722},
53052 -       { 0, 805},
53053 -       { 0, 794},
53054 -       { 0,   0}
53055 +       {   0, 805},
53056 +       {   0, 794},
53057 +       {   0,   0}
53058  };
53059  
53060  static const SiS300_LVDSDesStruct  SiS300_PanelType02_2[] =
53061 @@ -2297,10 +1301,10 @@ static const SiS300_LVDSDesStruct  SiS30
53062         {976, 527},
53063         {976, 502},
53064         {976, 567},
53065 -       { 0, 627},
53066 -       { 0, 627},
53067 -       { 0,   0},
53068 -       { 0,   0}
53069 +       {  0, 627},
53070 +       {  0, 627},
53071 +       {  0,   0},
53072 +       {  0,   0}
53073  };
53074  
53075  static const SiS300_LVDSDesStruct  SiS300_PanelType03_2[] =
53076 @@ -2472,156 +1476,57 @@ static const SiS300_LVDSDesStruct  SiS30
53077         {   0,   0}
53078  };
53079  
53080 -static const SiS300_LVDSDesStruct  SiS300_PanelTypeNS_1[]= 
53081 +/* Custom data for Barco iQ R200/300/400 (BIOS 2.00.07) */
53082 +static const SiS300_LVDSDesStruct  SiS300_PanelType04_1a[] =   /* 1280x1024 (1366x1024) */
53083  {
53084 -       { 8,   0},
53085 -       { 8,   0},
53086 -       { 8,   0},
53087 -       { 8,   0},
53088 -       { 8,   0},
53089 -       { 0,   0},
53090 -       { 0,   0},
53091 -       { 0,   0},
53092 -       { 0, 806},
53093 -       { 0, 0 }
53094 -};
53095 -
53096 -static const SiS300_LVDSDesStruct  SiS300_PanelTypeNS_2[] = 
53097 -{
53098 -       { 0 , 0},
53099 -       { 0 , 0},
53100 -       { 0 , 0},
53101 -       { 0 , 0},
53102 -       { 0 , 0},
53103 -       { 0 , 0},
53104 -       { 0 , 0},
53105 -       { 0 , 0},
53106 -       { 0 , 0},
53107 -       { 0 , 0}
53108 -};
53109 -
53110 -static const SiS300_LVDSDesStruct SiS300_PanelType1076_1[] =   /* TW: New */
53111 -{
53112 -       { 0 , 0},
53113 -       { 0 , 0},
53114 -       { 0 , 0},
53115 -       { 0 , 0},
53116 -       { 0 , 0},
53117 -       { 0 , 0},
53118 -       { 0 , 0},
53119 -       { 0 , 0},
53120 -       { 0 , 0}
53121 -};
53122 -
53123 -static const SiS300_LVDSDesStruct SiS300_PanelType1076_2[] =   /* TW: New */
53124 -{
53125 -       { 1152, 622 },
53126 -       { 1152, 597 },
53127 -       { 1152, 622 },
53128 -       { 1152, 597 },
53129 -       { 1152, 622 },
53130 -       { 1232, 722 },
53131 -       {    0, 0   },
53132 -       {    0, 794 },
53133 -       {    0, 0   }
53134 -};
53135 -
53136 -static const SiS300_LVDSDesStruct SiS300_PanelType1210_1[] =   /* TW: New */
53137 -{
53138 -       { 0 , 0},
53139 -       { 0 , 0},
53140 -       { 0 , 0},
53141 -       { 0 , 0},
53142 -       { 0 , 0},
53143 -       { 0 , 0},
53144 -       { 0 , 0},
53145 -       { 0 , 0},
53146 -       { 0 , 0}
53147 -};
53148 -
53149 -static const SiS300_LVDSDesStruct SiS300_PanelType1210_2[] =   /* TW: New */
53150 -{
53151 -       { 0 , 0},
53152 -       { 0 , 0},
53153 -       { 0 , 0},
53154 -       { 0 , 0},
53155 -       { 0 , 0},
53156 -       { 0 , 0},
53157 -       { 0 , 0},
53158 -       { 0 , 0},
53159 -       { 0 , 0}
53160 -};
53161 -
53162 -static const SiS300_LVDSDesStruct SiS300_PanelType1296_1[] =   /* TW: New */
53163 -{
53164 -       { 0 , 0},
53165 -       { 0 , 0},
53166 -       { 0 , 0},
53167 -       { 0 , 0},
53168 -       { 0 , 0},
53169 -       { 0 , 0},
53170 -       { 0 , 0},
53171 -       { 0 , 0},
53172 -       { 0 , 0}
53173 -};
53174 -
53175 -static const SiS300_LVDSDesStruct SiS300_PanelType1296_2[] =   /* TW: New */
53176 -{
53177 -       { 0 , 0},
53178 -       { 0 , 0},
53179 -       { 0 , 0},
53180 -       { 0 , 0},
53181 -       { 0 , 0},
53182 -       { 0 , 0},
53183 -       { 0 , 0},
53184 -       { 0 , 0},
53185 -       { 0 , 0}
53186 -};
53187 -
53188 -
53189 -/* TW: New */
53190 -static const SiS300_LVDSDesStruct  SiS300_CHTVUNTSCDesData[] =
53191 -{
53192 -       { 0,   0},
53193 -       { 0,   0},
53194 -       { 0,   0},
53195 -       { 0,   0},
53196 -       { 0,   0},
53197 -       { 0,   0}
53198 -};
53199 -
53200 -static const SiS300_LVDSDesStruct  SiS300_CHTVONTSCDesData[] =
53201 -{
53202 -       { 0,   0},
53203 -       { 0,   0},
53204 -       { 0,   0},
53205 -       { 0,   0},
53206 -       { 0,   0},
53207 -       { 0,   0}
53208 -};
53209 -
53210 -static const SiS300_LVDSDesStruct  SiS300_CHTVUPALDesData[] =
53211 -{
53212 -       {256,   0},
53213 -       {256,   0},
53214 -       {256,   0},
53215 -       {256,   0},
53216 -       {  0,   0},
53217 -       {  0,   0}
53218 +       {1330, 798},  /* 320x200 */
53219 +       {1330, 794},
53220 +       {1330, 798},
53221 +       {1330, 794},
53222 +       {1330,   0},  /* 640x480 / 320x240  */
53223 +       {1343,   0},  /* 800x600 / 400x300  */
53224 +       {   0, 805},  /* 1024x768 / 512x384 */
53225 +       {1688,1066},  /* 1280x1024          */
53226 +       {   0,   0}   /* 1360x1024          */
53227  };
53228  
53229 -static const SiS300_LVDSDesStruct  SiS300_CHTVOPALDesData[] =
53230 +static const SiS300_LVDSDesStruct  SiS300_PanelType04_2a[] =
53231  {
53232 -       {256,   0},
53233 -       {256,   0},
53234 -       {256,   0},
53235 -       {256,   0},
53236 -       {  0,   0},
53237 -       {  0,   0}
53238 +       {1152, 622},
53239 +       {1152, 597},
53240 +       {1152, 622},
53241 +       {1152, 597},
53242 +       {1152, 662},
53243 +       {1232, 722},
53244 +       {   0, 805},
53245 +       {1688,1066},
53246 +       {   0,   0}
53247 +};
53248 +
53249 +/* Custom data for Barco iQ G200/300/400 (BIOS 2.00.07) */
53250 +static const SiS300_LVDSDesStruct  SiS300_PanelType04_1b[] =   /* 1024x768 */
53251 +{
53252 +       {1330, 798},  /* 320x200 */
53253 +       {1330, 794},
53254 +       {1330, 798},
53255 +       {1330, 794},
53256 +       {1330,   0},  /* 640x480 / 320x240  */
53257 +       {1343,   0},  /* 800x600 / 400x300  */
53258 +       {   0, 805}   /* 1024x768 / 512x384 */
53259 +};
53260 +
53261 +static const SiS300_LVDSDesStruct  SiS300_PanelType04_2b[] =
53262 +{
53263 +       {1152, 622},
53264 +       {1152, 597},
53265 +       {1152, 622},
53266 +       {1152, 597},
53267 +       {1152, 662},
53268 +       {1232, 722},
53269 +       {   0, 805}
53270  };
53271 -/* TW: New end */
53272  
53273 -/* TW: New for SiS300+301LV */
53274 +
53275  typedef struct _SiS300_Part2PortTblStruct
53276  {
53277         UCHAR CR[12];
53278 @@ -2726,6 +1631,28 @@ static const SiS300_LVDSCRT1DataStruct  
53279           0x01 }}
53280  };
53281  
53282 +static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT1800x600_1_H[] =
53283 +{
53284 +       {{0x30,0x27,0x94,0x2c,0x92,0xaf,0x1f,
53285 +         0x90,0x85,0x8f,0xab,0x30,0x00,0x04,
53286 +         0x00 }},
53287 +       {{0x30,0x27,0x94,0x2c,0x92,0x83,0x1f,
53288 +         0x5e,0x83,0x5d,0x79,0x10,0x00,0x04,
53289 +         0x00 }},
53290 +       {{0x30,0x27,0x94,0x2c,0x92,0xaf,0x1f,
53291 +         0x90,0x85,0x8f,0xab,0x30,0x00,0x04,
53292 +         0x00 }},
53293 +       {{0x30,0x27,0x94,0x2c,0x92,0x83,0x1f,
53294 +         0x5e,0x83,0x5d,0x79,0x10,0x00,0x04,
53295 +         0x00 }},
53296 +       {{0x30,0x27,0x94,0x2c,0x92,0x04,0x3e,
53297 +         0xe0,0x85,0xdf,0xfb,0x10,0x00,0x04,
53298 +         0x00 }},
53299 +       {{0x3d,0x31,0x81,0x37,0x1f,0x72,0xf0,
53300 +         0x58,0x8c,0x57,0x73,0x20,0x00,0x05,
53301 +         0x01 }}
53302 +};
53303 +
53304  static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11024x768_1[] =
53305  { 
53306         {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f,
53307 @@ -2751,55 +1678,31 @@ static const SiS300_LVDSCRT1DataStruct  
53308           0x01}}
53309  };
53310  
53311 -static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11280x1024_1[] =
53312 -{
53313 -       {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f,
53314 -         0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
53315 -         0x00 }},
53316 -       {{0x63,0x4f,0x87,0x54,0x9f,0x82,0x1f,
53317 -         0x60,0x87,0x5d,0x83,0x10,0x00,0x01,
53318 -         0x00 }},
53319 -       {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f,
53320 -         0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
53321 -         0x00 }},
53322 -       {{0x63,0x4f,0x87,0x54,0x9f,0x82,0x1f,
53323 -         0x60,0x87,0x5d,0x83,0x10,0x00,0x01,
53324 -         0x00 }},
53325 -       {{0x63,0x4f,0x87,0x54,0x9f,0x04,0x3e,
53326 -         0xe2,0x89,0xdf,0x05,0x00,0x00,0x01,
53327 -         0x00 }},
53328 -       {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0,
53329 -         0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26,
53330 -         0x01 }},
53331 -       {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
53332 -         0x02,0x88,0xff,0x25,0x10,0x00,0x02,
53333 -         0x01 }}
53334 -};
53335 -
53336 -static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT1800x600_1_H[] =
53337 +static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11024x768_1_H[] =
53338  {
53339 -       {{0x30,0x27,0x94,0x2c,0x92,0xaf,0x1f,
53340 -         0x90,0x85,0x8f,0xab,0x30,0x00,0x04,
53341 -         0x00 }},
53342 -       {{0x30,0x27,0x94,0x2c,0x92,0x83,0x1f,
53343 -         0x5e,0x83,0x5d,0x79,0x10,0x00,0x04,
53344 -         0x00 }},
53345 -       {{0x30,0x27,0x94,0x2c,0x92,0xaf,0x1f,
53346 -         0x90,0x85,0x8f,0xab,0x30,0x00,0x04,
53347 -         0x00 }},
53348 -       {{0x30,0x27,0x94,0x2c,0x92,0x83,0x1f,
53349 -         0x5e,0x83,0x5d,0x79,0x10,0x00,0x04,
53350 -         0x00 }},
53351 -       {{0x30,0x27,0x94,0x2c,0x92,0x04,0x3e,
53352 -         0xe0,0x85,0xdf,0xfb,0x10,0x00,0x04,
53353 +       {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
53354 +         0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
53355           0x00 }},
53356 -       {{0x3d,0x31,0x81,0x37,0x1f,0x72,0xf0,
53357 -         0x58,0x8c,0x57,0x73,0x20,0x00,0x05,
53358 +       {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
53359 +         0x60,0x87,0x5D,0x83,0x10,0x00,0x44,
53360 +         0x00}},
53361 +       {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
53362 +         0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
53363 +         0x00}},
53364 +       {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
53365 +         0x60,0x87,0x5D,0x83,0x10,0x00,0x44,
53366 +         0x00}},
53367 +       {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e,
53368 +         0xE2,0x89,0xdf,0x05,0x00,0x00,0x44,
53369 +         0x00}},
53370 +       {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0,
53371 +         0x5A,0x8F,0x57,0x7D,0x20,0x00,0x55,
53372 +         0x01}},
53373 +       {{0x4f,0x3F,0x93,0x45,0x0D,0x24,0xf5,
53374 +         0x02,0x88,0xff,0x25,0x10,0x00,0x01,
53375           0x01 }}
53376 -};
53377  
53378 -static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11024x768_1_H[] =
53379 -{
53380 +#if 0
53381         {{0x37,0x27,0x9B,0x2b,0x94,0xc4,0x1f,
53382           0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
53383           0x00 }},
53384 @@ -2821,6 +1724,32 @@ static const SiS300_LVDSCRT1DataStruct  
53385         {{0x4f,0x3F,0x93,0x45,0x0D,0x24,0xf5,
53386           0x02,0x88,0xFf,0x25,0x10,0x00,0x01,
53387           0x01 }}
53388 +#endif
53389 +};
53390 +
53391 +static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11280x1024_1[] =
53392 +{
53393 +       {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f,
53394 +         0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
53395 +         0x00 }},
53396 +       {{0x63,0x4f,0x87,0x54,0x9f,0x82,0x1f,
53397 +         0x60,0x87,0x5d,0x83,0x10,0x00,0x01,
53398 +         0x00 }},
53399 +       {{0x63,0x4f,0x87,0x54,0x9f,0xb4,0x1f,
53400 +         0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
53401 +         0x00 }},
53402 +       {{0x63,0x4f,0x87,0x54,0x9f,0x82,0x1f,
53403 +         0x60,0x87,0x5d,0x83,0x10,0x00,0x01,
53404 +         0x00 }},
53405 +       {{0x63,0x4f,0x87,0x54,0x9f,0x04,0x3e,
53406 +         0xe2,0x89,0xdf,0x05,0x00,0x00,0x01,
53407 +         0x00 }},
53408 +       {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0,
53409 +         0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26,
53410 +         0x01 }},
53411 +       {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
53412 +         0x02,0x88,0xff,0x25,0x10,0x00,0x02,
53413 +         0x01 }}
53414  };
53415  
53416  static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11280x1024_1_H[] =
53417 @@ -2870,32 +1799,29 @@ static const SiS300_LVDSCRT1DataStruct  
53418           0x01 }}
53419  };
53420  
53421 -static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11024x768_2[] =
53422 +static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT1800x600_2_H[] =
53423  {
53424 -       {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53425 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
53426 +       {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e,
53427 +         0xf4,0x88,0x8f,0x73,0x20,0x00,0x05,
53428           0x00 }},
53429 -       {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53430 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
53431 +       {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e,
53432 +         0xdb,0x8f,0x5d,0x73,0x20,0x00,0x05,
53433           0x00 }},
53434 -       {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53435 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
53436 +       {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e,
53437 +         0xf4,0x88,0x8f,0x73,0x20,0x00,0x05,
53438           0x00 }},
53439 -       {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53440 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
53441 +       {{0x3d,0x27,0x81,0x3a,0x1a,0x72,0x3e,
53442 +         0xdb,0x8f,0x5d,0x73,0x20,0x00,0x05,
53443           0x00 }},
53444 -       {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53445 -         0x72,0x88,0xdf,0x25,0x30,0x00,0x06,
53446 +       {{0x3d,0x27,0x81,0x32,0x1a,0x72,0xba,
53447 +         0x1c,0x80,0xdf,0x73,0x00,0x00,0x05,
53448           0x00 }},
53449 -       {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1,
53450 -         0xae,0x84,0x57,0x25,0x30,0x00,0x02,
53451 -         0x01 }},
53452 -       {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
53453 -         0x02,0x88,0xff,0x25,0x10,0x00,0x02,
53454 +       {{0x3d,0x31,0x81,0x37,0x1f,0x72,0xf0,
53455 +         0x58,0x8c,0x57,0x73,0x20,0x00,0x05,
53456           0x01 }}
53457  };
53458  
53459 -static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11280x1024_2[] =
53460 +static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11024x768_2[] =
53461  {
53462         {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53463           0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
53464 @@ -2920,28 +1846,6 @@ static const SiS300_LVDSCRT1DataStruct  
53465           0x01 }}
53466  };
53467  
53468 -static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT1800x600_2_H[] =
53469 -{
53470 -       {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e,
53471 -         0xf4,0x88,0x8f,0x73,0x20,0x00,0x05,
53472 -         0x00 }},
53473 -       {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e,
53474 -         0xdb,0x8f,0x5d,0x73,0x20,0x00,0x05,
53475 -         0x00 }},
53476 -       {{0x3d,0x27,0x81,0x32,0x1a,0x72,0x3e,
53477 -         0xf4,0x88,0x8f,0x73,0x20,0x00,0x05,
53478 -         0x00 }},
53479 -       {{0x3d,0x27,0x81,0x3a,0x1a,0x72,0x3e,
53480 -         0xdb,0x8f,0x5d,0x73,0x20,0x00,0x05,
53481 -         0x00 }},
53482 -       {{0x3d,0x27,0x81,0x32,0x1a,0x72,0xba,
53483 -         0x1c,0x80,0xdf,0x73,0x00,0x00,0x05,
53484 -         0x00 }},
53485 -       {{0x3d,0x31,0x81,0x37,0x1f,0x72,0xf0,
53486 -         0x58,0x8c,0x57,0x73,0x20,0x00,0x05,
53487 -         0x01 }}
53488 -};
53489 -
53490  static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11024x768_2_H[] =
53491  {
53492         {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
53493 @@ -2967,6 +1871,31 @@ static const SiS300_LVDSCRT1DataStruct  
53494           0x01 }}
53495  };
53496  
53497 +static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11280x1024_2[] =
53498 +{
53499 +       {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53500 +         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
53501 +         0x00 }},
53502 +       {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53503 +         0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
53504 +         0x00 }},
53505 +       {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53506 +         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
53507 +         0x00 }},
53508 +       {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53509 +         0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
53510 +         0x00 }},
53511 +       {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53512 +         0x72,0x88,0xdf,0x25,0x30,0x00,0x06,
53513 +         0x00 }},
53514 +       {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1,
53515 +         0xae,0x84,0x57,0x25,0x30,0x00,0x02,
53516 +         0x01 }},
53517 +       {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
53518 +         0x02,0x88,0xff,0x25,0x10,0x00,0x02,
53519 +         0x01 }}
53520 +};
53521 +
53522  static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11280x1024_2_H[] =
53523  {
53524         {{0x4f,0x27,0x93,0x39,0x81,0x24,0xbb,
53525 @@ -2992,207 +1921,6 @@ static const SiS300_LVDSCRT1DataStruct  
53526           0x01}}
53527  };
53528  
53529 -static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11024x600_1[] =
53530 -{
53531 -        {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e,
53532 -         0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01,
53533 -         0x00}},
53534 -        {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e,
53535 -         0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01,
53536 -         0x00}},
53537 -        {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e,
53538 -         0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01,
53539 -         0x00}},
53540 -        {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e,
53541 -         0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01,
53542 -         0x00}},
53543 -        {{0x64,0x4f,0x88,0x54,0x9f,0xaf,0xba,
53544 -         0x3b,0x82,0xdf,0xb0,0x00,0x00,0x01,
53545 -         0x00}},
53546 -        {{0x7e,0x63,0x82,0x68,0x15,0x1e,0xf1,
53547 -         0xae,0x85,0x57,0x1f,0x30,0x00,0x26,
53548 -         0x01}},
53549 -        {{0xa3,0x7f,0x87,0x86,0x97,0x1e,0xf1,
53550 -         0xae,0x85,0x57,0x1f,0x30,0x00,0x02,
53551 -         0x01}}
53552 -};
53553 -
53554 -static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11024x600_1_H[] =
53555 -{
53556 -        {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
53557 -         0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
53558 -         0x00}},
53559 -        {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
53560 -         0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
53561 -          0x00}},
53562 -        {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
53563 -         0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
53564 -         0x00}},
53565 -        {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
53566 -         0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
53567 -         0x00}},
53568 -        {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e,
53569 -         0xe2,0x89,0xdf,0x05,0x00,0x00,0x44,
53570 -         0x00}},
53571 -        {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0,
53572 -         0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55,
53573 -         0x01}},
53574 -        {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
53575 -         0x02,0x88,0xff,0x25,0x10,0x00,0x01,
53576 -         0x01}}
53577 -};
53578 -
53579 -static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11024x600_2[] =
53580 -{
53581 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53582 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
53583 -         0x00}},
53584 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53585 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
53586 -         0x00}},
53587 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53588 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
53589 -         0x00}},
53590 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53591 -          0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
53592 -         0x00}},
53593 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53594 -         0x72,0x88,0xdf,0x25,0x30,0x00,0x06,
53595 -         0x00}},
53596 -        {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1,
53597 -         0xae,0x84,0x57,0x25,0x30,0x00,0x02,
53598 -         0x01}},
53599 -        {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
53600 -         0x02,0x88,0xff,0x25,0x10,0x00,0x02,
53601 -         0x01}}
53602 -};
53603 -
53604 -static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11024x600_2_H[] =
53605 -{
53606 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
53607 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
53608 -         0x00}},
53609 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
53610 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
53611 -         0x00}},
53612 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
53613 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
53614 -         0x00}},
53615 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
53616 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
53617 -         0x00}},
53618 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
53619 -         0x72,0x88,0xdf,0x25,0x30,0x00,0x01,
53620 -         0x00}},
53621 -        {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1,
53622 -         0xae,0x84,0x57,0x25,0x30,0x00,0x01,
53623 -         0x01}},
53624 -        {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
53625 -         0x02,0x88,0xff,0x25,0x10,0x00,0x01,
53626 -         0x01}}
53627 -};
53628 -
53629 -static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11152x768_1[] =
53630 -{
53631 -        {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f,
53632 -         0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
53633 -         0x00}},
53634 -        {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f,
53635 -         0x60,0x87,0x5d,0x83,0x10,0x00,0x01,
53636 -         0x00}},
53637 -        {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f,
53638 -         0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
53639 -         0x00}},
53640 -        {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f,
53641 -         0x60,0x87,0x5d,0x83,0x10,0x00,0x01,
53642 -         0x00}},
53643 -        {{0x64,0x4f,0x88,0x54,0x9f,0x04,0x3e,
53644 -         0xe2,0x89,0xdf,0x05,0x00,0x00,0x01,
53645 -         0x00}},
53646 -        {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0,
53647 -         0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26,
53648 -         0x01}},
53649 -        {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
53650 -         0x02,0x88,0xff,0x25,0x10,0x00,0x02,
53651 -         0x01}}
53652 -};
53653 -
53654 -static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11152x768_1_H[] =
53655 -{
53656 -        {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
53657 -         0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
53658 -         0x00}},
53659 -        {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
53660 -         0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
53661 -         0x00}},
53662 -        {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
53663 -         0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
53664 -         0x00}},
53665 -        {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
53666 -         0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
53667 -         0x00}},
53668 -        {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e,
53669 -         0xe2,0x89,0xdf,0x05,0x00,0x00,0x44,
53670 -         0x00}},
53671 -        {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0,
53672 -         0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55,
53673 -         0x01}},
53674 -        {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
53675 -         0x02,0x88,0xff,0x25,0x10,0x00,0x01,
53676 -         0x01}}
53677 -};
53678 -
53679 -static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11152x768_2[] =
53680 -{
53681 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53682 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
53683 -         0x00}},
53684 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53685 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
53686 -         0x00}},
53687 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53688 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
53689 -         0x00}},
53690 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53691 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
53692 -         0x00}},
53693 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
53694 -         0x72,0x88,0xdf,0x25,0x30,0x00,0x06,
53695 -         0x00}},
53696 -        {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1,
53697 -         0xae,0x84,0x57,0x25,0x30,0x00,0x02,
53698 -         0x01}},
53699 -        {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
53700 -         0x02,0x88,0xff,0x25,0x10,0x00,0x02,
53701 -         0x01}}
53702 -};
53703 -
53704 -static const SiS300_LVDSCRT1DataStruct  SiS300_LVDSCRT11152x768_2_H[] =
53705 -{
53706 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
53707 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
53708 -         0x00}},
53709 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
53710 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
53711 -         0x00}},
53712 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
53713 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
53714 -         0x00}},
53715 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
53716 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
53717 -         0x00}},
53718 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
53719 -         0x72,0x88,0xdf,0x25,0x30,0x00,0x01,
53720 -         0x00}},
53721 -        {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1,
53722 -         0xae,0x84,0x57,0x25,0x30,0x00,0x01,
53723 -         0x01}},
53724 -        {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
53725 -         0x02,0x88,0xff,0x25,0x10,0x00,0x01,
53726 -         0x01}}
53727 -};
53728 -
53729 -/* TW: New */
53730  static const SiS300_LVDSCRT1DataStruct  SiS300_CHTVCRT1UNTSC[] =
53731  {
53732         {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e,
53733 @@ -3302,9 +2030,7 @@ static const SiS300_LVDSCRT1DataStruct  
53734           0x90,0x8c,0x57,0xed,0x20,0x00,0x05,
53735           0x01 }}
53736  };
53737 -/* TW: New end */
53738  
53739 -/* TW: New */
53740  typedef struct _SiS300_CHTVRegDataStruct
53741  {
53742         UCHAR Reg[16];
53743 @@ -3361,9 +2087,7 @@ static const SiS300_CHTVRegDataStruct Si
53744         {{0x60,0x30,0x00,0x10,0x00,0,0,0,0,0,0,0,0,0,0,0}}, /* TW: Mode 13: 640x480 PAL 5/4 */
53745         {{0x81,0x50,0x00,0x1b,0x00,0,0,0,0,0,0,0,0,0,0,0}}  /* TW: Mode 19: 800x600 PAL 1/1 */
53746  };
53747 -/* TW: New end */
53748  
53749 -/* TW: New */
53750  static const UCHAR SiS300_CHTVVCLKUNTSC[]  = {0x29,0x29,0x29,0x29,0x2a,0x2e};
53751  
53752  static const UCHAR SiS300_CHTVVCLKONTSC[]  = {0x2c,0x2c,0x2c,0x2c,0x2d,0x2b};
53753 @@ -3375,6 +2099,5 @@ static const UCHAR SiS300_CHTVVCLKUPAL[]
53754  static const UCHAR SiS300_CHTVVCLKOPAL[]   = {0x2f,0x2f,0x2f,0x2f,0x30,0x32};
53755  
53756  static const UCHAR SiS300_CHTVVCLKSOPAL[]  = {0x2f,0x2f,0x2f,0x2f,0x36,0x29};
53757 -/* TW: New end */
53758  
53759  
53760 --- linux-2.6.0-test6/drivers/video/sis/310vtbl.h       2003-06-14 12:18:23.000000000 -0700
53761 +++ 25/drivers/video/sis/310vtbl.h      2003-10-05 00:34:22.000000000 -0700
53762 @@ -1,7 +1,37 @@
53763 -
53764 -
53765 -/* Register settings for SiS 310/325/330 series */
53766 -
53767 +/* $XFree86$ */
53768 +/*
53769 + * Register settings for SiS 315/330 series
53770 + *
53771 + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
53772 + *
53773 + * If distributed as part of the linux kernel, the contents of this file
53774 + * is entirely covered by the GPL.
53775 + *
53776 + * Otherwise, the following terms apply:
53777 + *
53778 + * Permission to use, copy, modify, distribute, and sell this software and its
53779 + * documentation for any purpose is hereby granted without fee, provided that
53780 + * the above copyright notice appear in all copies and that both that
53781 + * copyright notice and this permission notice appear in supporting
53782 + * documentation, and that the name of the copyright holder not be used in
53783 + * advertising or publicity pertaining to distribution of the software without
53784 + * specific, written prior permission.  The copyright holder makes no representations
53785 + * about the suitability of this software for any purpose.  It is provided
53786 + * "as is" without express or implied warranty.
53787 + *
53788 + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
53789 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
53790 + * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
53791 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
53792 + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
53793 + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
53794 + * PERFORMANCE OF THIS SOFTWARE.
53795 + *
53796 + * Author:     Thomas Winischhofer <thomas@winischhofer.net>
53797 + *
53798 + * Based on code by Silicon Intergrated Systems
53799 + *
53800 + */
53801  
53802  typedef struct _SiS310_StStruct
53803  {
53804 @@ -39,466 +69,12 @@ static const SiS310_StStruct SiS310_SMod
53805         {0xff,0x0000,0x00,0x00,0x00,0x00,0x00,0x00}
53806  };
53807  
53808 -typedef struct _SiS310_StandTableStruct
53809 -{
53810 -       UCHAR CRT_COLS;
53811 -       UCHAR ROWS;
53812 -       UCHAR CHAR_HEIGHT;
53813 -       USHORT CRT_LEN;
53814 -       UCHAR SR[4];
53815 -       UCHAR MISC;
53816 -       UCHAR CRTC[0x19];
53817 -       UCHAR ATTR[0x14];
53818 -       UCHAR GRC[9];
53819 -} SiS310_StandTableStruct;
53820 -
53821 -static const SiS310_StandTableStruct SiS310_StandTable[]=
53822 -{
53823 -/* 0x00: MD_0_200 */
53824 - {
53825 -  0x28,0x18,0x08,0x0800,
53826 -  {0x09,0x03,0x00,0x02},
53827 -  0x63,
53828 -  {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
53829 -   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
53830 -   0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
53831 -   0xff},
53832 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
53833 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
53834 -   0x08,0x00,0x0f,0x00},
53835 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
53836 -   0xff}
53837 - },
53838 -/* 0x01: MD_1_200 */
53839 - {
53840 -  0x28,0x18,0x08,0x0800,
53841 -  {0x09,0x03,0x00,0x02},
53842 -  0x63,
53843 -  {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
53844 -   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
53845 -   0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
53846 -   0xff},
53847 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
53848 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
53849 -   0x08,0x00,0x0f,0x00},
53850 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
53851 -   0xff}
53852 - },
53853 -/* 0x02: MD_2_200 */
53854 - {
53855 -  0x50,0x18,0x08,0x1000,
53856 -  {0x01,0x03,0x00,0x02},
53857 -  0x63,
53858 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
53859 -   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
53860 -   0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
53861 -   0xff},
53862 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
53863 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
53864 -   0x08,0x00,0x0f,0x00},
53865 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
53866 -   0xff}
53867 - },
53868 -/* 0x03: MD_3_200 - mode 0x03 - 0 */
53869 - {
53870 -  0x50,0x18,0x08,0x1000,
53871 -  {0x01,0x03,0x00,0x02},
53872 -  0x63,
53873 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
53874 -   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
53875 -   0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
53876 -   0xff},
53877 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
53878 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
53879 -   0x08,0x00,0x0f,0x00},
53880 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
53881 -   0xff}
53882 - },
53883 -/* 0x04: MD_4 */
53884 - {
53885 -  0x28,0x18,0x08,0x4000,
53886 -  {0x09,0x03,0x00,0x02},
53887 -  0x63,
53888 -  {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,
53889 -   0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
53890 -   0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2,
53891 -   0xff},
53892 -  {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07,
53893 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
53894 -   0x01,0x00,0x03,0x00},
53895 -  {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,
53896 -   0xff}
53897 - },
53898 -/* 0x05: MD_5 */
53899 - {
53900 -  0x28,0x18,0x08,0x4000,
53901 -  {0x09,0x03,0x00,0x02},
53902 -  0x63,
53903 -  {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,
53904 -   0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
53905 -   0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2,
53906 -   0xff},
53907 -  {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07,
53908 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
53909 -   0x01,0x00,0x03,0x00},
53910 -  {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,
53911 -   0xff}
53912 - },
53913 -/* 0x06: MD_6 */
53914 - {
53915 -  0x50,0x18,0x08,0x4000,
53916 -  {0x01,0x01,0x00,0x06},
53917 -  0x63,
53918 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
53919 -   0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
53920 -   0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xc2,
53921 -   0xff},
53922 -  {0x00,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
53923 -   0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
53924 -   0x01,0x00,0x01,0x00},
53925 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00,
53926 -   0xff}
53927 - },
53928 -/* 0x07: MD_7 */
53929 - {
53930 -  0x50,0x18,0x0e,0x1000,
53931 -  {0x00,0x03,0x00,0x03},
53932 -  0xa6,
53933 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
53934 -   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
53935 -   0x83,0x85,0x5d,0x28,0x0d,0x63,0xba,0xa3,
53936 -   0xff},
53937 -  {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
53938 -   0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
53939 -   0x0e,0x00,0x0f,0x08},
53940 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,
53941 -   0xff}
53942 - },
53943 -/* 0x08: MDA_DAC */
53944 - {
53945 -  0x00,0x00,0x00,0x0000,
53946 -  {0x00,0x00,0x00,0x15},
53947 -  0x15,
53948 -  {0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
53949 -   0x15,0x15,0x15,0x15,0x15,0x15,0x3f,0x3f,
53950 -   0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,
53951 -   0x00},
53952 -  {0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15,
53953 -   0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
53954 -   0x15,0x15,0x15,0x15},
53955 -  {0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
53956 -   0x3f}
53957 - },
53958 -/* 0x09: CGA_DAC */
53959 - {
53960 -  0x00,0x10,0x04,0x0114,
53961 -  {0x11,0x09,0x15,0x00},
53962 -  0x10,
53963 -  {0x04,0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,
53964 -   0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x2a,0x3a,
53965 -   0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x10,
53966 -   0x04},
53967 -  {0x14,0x01,0x11,0x09,0x15,0x00,0x10,0x04,
53968 -   0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,0x2e,
53969 -   0x3e,0x2b,0x3b,0x2f},
53970 -  {0x3f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f,
53971 -   0x3f}
53972 - },
53973 -/* 0x0a: EGA_DAC */
53974 - {
53975 -  0x00,0x10,0x04,0x0114,
53976 -  {0x11,0x05,0x15,0x20},
53977 -  0x30,
53978 -  {0x24,0x34,0x21,0x31,0x25,0x35,0x08,0x18,
53979 -   0x0c,0x1c,0x09,0x19,0x0d,0x1d,0x28,0x38,
53980 -   0x2c,0x3c,0x29,0x39,0x2d,0x3d,0x02,0x12,
53981 -   0x06},
53982 -  {0x16,0x03,0x13,0x07,0x17,0x22,0x32,0x26,
53983 -   0x36,0x23,0x33,0x27,0x37,0x0a,0x1a,0x0e,
53984 -   0x1e,0x0b,0x1b,0x0f},
53985 -  {0x1f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f,
53986 -   0x3f}
53987 - },
53988 -/* 0x0b: VGA_DAC */
53989 - {
53990 -  0x00,0x10,0x04,0x0114,
53991 -  {0x11,0x09,0x15,0x2a},
53992 -  0x3a,
53993 -  {0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x05,
53994 -   0x08,0x0b,0x0e,0x11,0x14,0x18,0x1c,0x20,
53995 -   0x24,0x28,0x2d,0x32,0x38,0x3f,0x00,0x10,
53996 -   0x1f},
53997 -  {0x2f,0x3f,0x1f,0x27,0x2f,0x37,0x3f,0x2d,
53998 -   0x31,0x36,0x3a,0x3f,0x00,0x07,0x0e,0x15,
53999 -   0x1c,0x0e,0x11,0x15},
54000 -  {0x18,0x1c,0x14,0x16,0x18,0x1a,0x1c,0x00,
54001 -   0x04}
54002 - },
54003 -/* 0x0c */ 
54004 - {
54005 -  0x08,0x0c,0x10,0x0a08,
54006 -  {0x0c,0x0e,0x10,0x0b},
54007 -  0x0c,
54008 -  {0x0d,0x0f,0x10,0x10,0x01,0x08,0x00,0x00,
54009 -   0x00,0x00,0x01,0x00,0x02,0x02,0x01,0x00,
54010 -   0x04,0x04,0x01,0x00,0x05,0x02,0x05,0x00,
54011 -   0x06},
54012 -  {0x01,0x06,0x05,0x06,0x00,0x08,0x01,0x08,
54013 -   0x00,0x07,0x02,0x07,0x06,0x07,0x00,0x00,
54014 -   0x00,0x00,0x00,0x00},
54015 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
54016 -   0x00}
54017 - },
54018 -/* 0x0d: MD_D */
54019 - {
54020 -  0x28,0x18,0x08,0x2000,
54021 -  {0x09,0x0f,0x00,0x06},
54022 -  0x63,
54023 -  {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,
54024 -   0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
54025 -   0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xe3,
54026 -   0xff},
54027 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
54028 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
54029 -   0x01,0x00,0x0f,0x00},
54030 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
54031 -   0xff}
54032 - },
54033 -/* 0x0e: MD_E */
54034 - {
54035 -  0x50,0x18,0x08,0x4000,
54036 -  {0x01,0x0f,0x00,0x06},
54037 -  0x63,
54038 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
54039 -   0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
54040 -   0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xe3,
54041 -   0xff},
54042 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
54043 -   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
54044 -   0x01,0x00,0x0f,0x00},
54045 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
54046 -   0xff}
54047 - },
54048 -/* 0x0f: ExtVGATable - modes > 0x13 */
54049 - {
54050 -  0x00,0x00,0x00,0x0000,
54051 -  {0x01,0x0f,0x00,0x0e},
54052 -  0x23,
54053 -  {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e,
54054 -   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
54055 -   0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3,
54056 -   0xff},
54057 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
54058 -   0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
54059 -   0x01,0x00,0x00,0x00},
54060 -  {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,
54061 -   0xff}
54062 - },
54063 -/* 0x10: ROM_SAVEPTR */
54064 - {
54065 -  0x9f,0x3b,0x00,0x00c0,
54066 -  {0x00,0x00,0x00,0x00},
54067 -  0x00,
54068 -  {0x00,0x00,0x00,0x00,0x00,0x00,0xbb,0x3f,
54069 -   0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
54070 -   0x00,0x00,0x1a,0x00,0xac,0x3e,0x00,0xc0,
54071 -   0x00},
54072 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
54073 -   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
54074 -   0x00,0x00,0x00,0x00},
54075 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
54076 -   0x00}
54077 - },
54078 -/* 0x11: MD_F */
54079 - {
54080 -  0x50,0x18,0x0e,0x8000,
54081 -  {0x01,0x0f,0x00,0x06},
54082 -  0xa2,
54083 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
54084 -   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
54085 -   0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3,
54086 -   0xff},
54087 -  {0x00,0x08,0x00,0x00,0x18,0x18,0x00,0x00,
54088 -   0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00,
54089 -   0x0b,0x00,0x05,0x00},
54090 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,
54091 -   0xff}
54092 - },
54093 -/* 0x12: MD_10 */
54094 - {
54095 -  0x50,0x18,0x0e,0x8000,
54096 -  {0x01,0x0f,0x00,0x06},
54097 -  0xa3,
54098 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
54099 -   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
54100 -   0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3,
54101 -   0xff},
54102 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
54103 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
54104 -   0x01,0x00,0x0f,0x00},
54105 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
54106 -   0xff}
54107 - },
54108 -/* 0x13: MD_0_350 */
54109 - {
54110 -  0x28,0x18,0x0e,0x0800,
54111 -  {0x09,0x03,0x00,0x02},
54112 -  0xa3,
54113 -  {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f,
54114 -   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
54115 -   0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3,
54116 -   0xff},
54117 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
54118 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
54119 -   0x08,0x00,0x0f,0x00},
54120 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
54121 -   0xff}
54122 - },
54123 -/* 0x14: MD_1_350 */
54124 - {
54125 -  0x28,0x18,0x0e,0x0800,
54126 -  {0x09,0x03,0x00,0x02},
54127 -  0xa3,
54128 -  {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
54129 -   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
54130 -   0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3,
54131 -   0xff},
54132 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
54133 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
54134 -   0x08,0x00,0x0f,0x00},
54135 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
54136 -   0xff}
54137 - },
54138 -/* 0x15: MD_2_350 */
54139 - {
54140 -  0x50,0x18,0x0e,0x1000,
54141 -  {0x01,0x03,0x00,0x02},
54142 -  0xa3,
54143 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
54144 -   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
54145 -   0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3,
54146 -   0xff},
54147 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
54148 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
54149 -   0x08,0x00,0x0f,0x00},
54150 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
54151 -   0xff}
54152 - },
54153 -/* 0x16: MD_3_350 - mode 0x03 - 1 */
54154 - {
54155 -  0x50,0x18,0x0e,0x1000,
54156 -  {0x01,0x03,0x00,0x02},
54157 -  0xa3,
54158 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
54159 -   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
54160 -   0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3,
54161 -   0xff},
54162 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
54163 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
54164 -   0x08,0x00,0x0f,0x00},
54165 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
54166 -   0xff}
54167 - },
54168 -/* 0x17: MD_0_1_400 */
54169 - {
54170 -  0x28,0x18,0x10,0x0800,
54171 -  {0x08,0x03,0x00,0x02},
54172 -  0x67,
54173 -  {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f,
54174 -   0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
54175 -   0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
54176 -   0xff},
54177 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
54178 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
54179 -   0x0c,0x00,0x0f,0x08},
54180 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
54181 -   0xff}
54182 - },
54183 -/* 0x18: MD_2_3_400 - mode 0x03 - 2 */
54184 - {
54185 -  0x50,0x18,0x10,0x1000,
54186 -  {0x00,0x03,0x00,0x02},
54187 -  0x67,
54188 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
54189 -   0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
54190 -   0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
54191 -   0xff},
54192 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
54193 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
54194 -   0x0c,0x00,0x0f,0x08},
54195 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
54196 -   0xff}
54197 - },
54198 -/* 0x19: MD_7_400 */
54199 - {
54200 -  0x50,0x18,0x10,0x1000,
54201 -  {0x00,0x03,0x00,0x02},
54202 -  0x66,
54203 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
54204 -   0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
54205 -   0x9c,0x8e,0x8f,0x28,0x0f,0x96,0xb9,0xa3,
54206 -   0xff},
54207 -  {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
54208 -   0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
54209 -   0x0e,0x00,0x0f,0x08},
54210 -  {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,
54211 -   0xff}
54212 - },
54213 -/* 0x1a: MD_11 */
54214 - {
54215 -  0x50,0x1d,0x10,0xa000,
54216 -  {0x01,0x0f,0x00,0x06},
54217 -  0xe3,
54218 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e,
54219 -   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
54220 -   0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xc3,
54221 -   0xff},
54222 -  {0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
54223 -   0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
54224 -   0x01,0x00,0x0f,0x00},
54225 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01,
54226 -   0xff}
54227 - },
54228 -/* 0x1b: ExtEGATable - Modes <= 0x02 */
54229 - {
54230 -  0x50,0x1d,0x10,0xa000,
54231 -  {0x01,0x0f,0x00,0x06},
54232 -  0xe3,
54233 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e,
54234 -   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
54235 -   0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xe3,
54236 -   0xff},
54237 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
54238 -   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
54239 -   0x01,0x00,0x0f,0x00},
54240 -  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
54241 -   0xff}
54242 - },
54243 -/* 0x1c: MD_13 */
54244 - {
54245 -  0x28,0x18,0x08,0x2000,
54246 -  {0x01,0x0f,0x00,0x0e},
54247 -  0x63,
54248 -  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
54249 -   0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,
54250 -   0x9c,0x8e,0x8f,0x28,0x40,0x96,0xb9,0xa3,
54251 -   0xff},
54252 -  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
54253 -   0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
54254 -   0x41,0x00,0x0f,0x00},
54255 -  {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,
54256 -   0xff}
54257 - }
54258 -};
54259 -
54260  typedef struct _SiS310_ExtStruct
54261  {
54262         UCHAR Ext_ModeID;
54263         USHORT Ext_ModeFlag;
54264         USHORT Ext_ModeInfo;
54265 -       USHORT Ext_Point;    /* TW: Address of table entry in (older) BIOS image */
54266         USHORT Ext_VESAID;
54267 -       UCHAR Ext_VESAMEMSize;
54268         UCHAR Ext_RESINFO;
54269         UCHAR VB_ExtTVFlickerIndex;
54270         UCHAR VB_ExtTVEdgeIndex;
54271 @@ -506,93 +82,93 @@ typedef struct _SiS310_ExtStruct
54272         UCHAR REFindex;
54273  } SiS310_ExtStruct;
54274  
54275 -/* TW: Checked with 650/LVDS and 650/301LVx 1.10.6s */
54276  static const SiS310_ExtStruct  SiS310_EModeIDTable[]=
54277  {
54278 -       {0x6a,0x2212,0x0407,0x3a81,0x0102,0x08,0x07,0x00,0x00,0x07,0x00},          /* 800x600x? */
54279 -       {0x2e,0x0a1b,0x0306,0x3a57,0x0101,0x08,0x06,0x00,0x00,0x05,0x08},          /* 640x480x8 */
54280 -/*     {0x2e,0x021b,0x0306,0x3a57,0x0101,0x08,0x06,0x00,0x00,0x05,0x08},    */    /* 640x480x8 - 650/LVDS BIOS (no CRt2Mode) */
54281 -       {0x2f,0x0a1b,0x0305,0x3a50,0x0100,0x08,0x05,0x00,0x00,0x05,0x10},          /* 640x400x8 */
54282 -/*     {0x2f,0x021b,0x0305,0x3a50,0x0100,0x08,0x05,0x00,0x00,0x05,0x10},    */    /* 640x400x8 - 650/LVDS BIOS (no CRt2Mode) */
54283 -       {0x30,0x2a1b,0x0407,0x3a81,0x0103,0x08,0x07,0x00,0x00,0x07,0x00},          /* 800x600x8 */
54284 -/*     {0x30,0x221b,0x0407,0x3a81,0x0103,0x08,0x07,0x00,0x00,0x07,0x00},    */    /* 800x600x8 - 650/LVDS BIOS (no CRt2Mode) */
54285 -/*      {0x31,0x0a1b,0x030d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x11},    */    /* 720x480x8 */
54286 -        {0x31,0x0a1b,0x0a0d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x11},          /* 720x480x8 BIOS (301/LVDS) */
54287 -       {0x32,0x0a1b,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x12},          /* 720x576x8 */
54288 -       {0x33,0x0a1d,0x0a0d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x11},          /* 720x480x16 */
54289 -       {0x34,0x2a1d,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x12},          /* 720x576x16 */
54290 -       {0x35,0x0a1f,0x0a0d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x11},          /* 720x480x32 */
54291 -       {0x36,0x2a1f,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x12},          /* 720x576x32 */
54292 -       {0x37,0x0212,0x0508,0x3aab,0x0104,0x08,0x08,0x00,0x00,0x08,0x13},          /* 1024x768x? */
54293 -       {0x38,0x0a1b,0x0508,0x3aab,0x0105,0x08,0x08,0x00,0x00,0x08,0x13},          /* 1024x768x8 */
54294 -       {0x3a,0x0e3b,0x0609,0x3adc,0x0107,0x08,0x09,0x00,0x00,0x00,0x1a},          /* 1280x1024x8 */
54295 -       {0x3c,0x0e3b,0x070a,0x3af2,0x0130,0x08,0x0a,0x00,0x00,0x00,0x1e},          /* 1600x1200x8 */
54296 -       {0x3d,0x0e7d,0x070a,0x3af2,0x0131,0x08,0x0a,0x00,0x00,0x00,0x1e},          /* 1600x1200x16 - 650/301LVx - no CRT2Mode? */
54297 -       {0x40,0x9a1c,0x0000,0x3a34,0x010d,0x08,0x00,0x00,0x00,0x04,0x25},
54298 -       {0x41,0x9a1d,0x0000,0x3a34,0x010e,0x08,0x00,0x00,0x00,0x04,0x25},
54299 -       {0x43,0x0a1c,0x0306,0x3a57,0x0110,0x08,0x06,0x00,0x00,0x05,0x08},
54300 -       {0x44,0x0a1d,0x0306,0x3a57,0x0111,0x08,0x06,0x00,0x00,0x05,0x08},          /* 640x480x16 */
54301 -       {0x46,0x2a1c,0x0407,0x3a81,0x0113,0x08,0x07,0x00,0x00,0x07,0x00},
54302 -       {0x47,0x2a1d,0x0407,0x3a81,0x0114,0x08,0x07,0x00,0x00,0x07,0x00},          /* 800x600x16 */
54303 -       {0x49,0x0a3c,0x0508,0x3aab,0x0116,0x08,0x08,0x00,0x00,0x00,0x13},
54304 -       {0x4a,0x0a3d,0x0508,0x3aab,0x0117,0x08,0x08,0x00,0x00,0x08,0x13},          /* 1024x768x16 */
54305 -       {0x4c,0x0e7c,0x0609,0x3adc,0x0119,0x08,0x09,0x00,0x00,0x00,0x1a},
54306 -       {0x4d,0x0e7d,0x0609,0x3adc,0x011a,0x08,0x09,0x00,0x00,0x00,0x1a},          /* 1280x1024x16 */
54307 -       {0x50,0x9a1b,0x0001,0x3a3b,0x0132,0x08,0x01,0x00,0x00,0x04,0x26},          /* 320x240 */
54308 -       {0x51,0xba1b,0x0103,0x3a42,0x0133,0x08,0x03,0x00,0x00,0x07,0x27},
54309 -       {0x52,0xba1b,0x0204,0x3a49,0x0134,0x08,0x04,0x00,0x00,0x00,0x28},          /* 650/301 BIOS */
54310 -       {0x56,0x9a1d,0x0001,0x3a3b,0x0135,0x08,0x01,0x00,0x00,0x04,0x26},
54311 -       {0x57,0xba1d,0x0103,0x3a42,0x0136,0x08,0x03,0x00,0x00,0x07,0x27},
54312 -       {0x58,0xba1d,0x0204,0x3a49,0x0137,0x08,0x04,0x00,0x00,0x00,0x28},          /* BIOS (301+LVDS) */
54313 -       {0x59,0x9a1b,0x0000,0x3a34,0x0138,0x08,0x00,0x00,0x00,0x04,0x25},          /* 320x200 */
54314 -       {0x5A,0x021b,0x0014,0x3b83,0x0138,0x08,0x01,0x00,0x00,0x04,0x3f},          /* 320x480x8 fstn add new mode*/
54315 -       {0x5B,0x0a1d,0x0014,0x3b83,0x0135,0x08,0x01,0x00,0x00,0x04,0x3f},          /* 320x480x16 fstn add new mode*/
54316 -       {0x5c,0xba1f,0x0204,0x3a49,0x0000,0x08,0x04,0x00,0x00,0x00,0x28},          /* TW: inserted 512x384x32 */
54317 -       {0x5d,0x0a1d,0x0305,0x3a50,0x0139,0x08,0x05,0x00,0x00,0x07,0x10},
54318 -       {0x5e,0x0a1f,0x0305,0x3a50,0x0000,0x08,0x05,0x00,0x00,0x07,0x10},          /* TW: Inserted 640x400x32 */
54319 -       {0x62,0x0a3f,0x0306,0x3a57,0x013a,0x08,0x06,0x00,0x00,0x05,0x08},          /* 640x480x32 */
54320 -       {0x63,0x2a3f,0x0407,0x3a81,0x013b,0x08,0x07,0x00,0x00,0x07,0x00},          /* 800x600x32 */
54321 -       {0x64,0x0a7f,0x0508,0x3aab,0x013c,0x08,0x08,0x00,0x00,0x08,0x13},          /* 1024x768x32 */
54322 -       {0x65,0x0eff,0x0609,0x3adc,0x013d,0x08,0x09,0x00,0x00,0x00,0x1a},          /* 1280x1024x32 */
54323 -       {0x66,0x0eff,0x070a,0x3af2,0x013e,0x08,0x0a,0x00,0x00,0x00,0x1e},          /* 1600x1200x32 */
54324 -       {0x68,0x067b,0x080b,0x3b17,0x013f,0x08,0x0b,0x00,0x00,0x00,0x29},          /* 1920x1440x8 */
54325 -       {0x69,0x06fd,0x080b,0x3b17,0x0140,0x08,0x0b,0x00,0x00,0x00,0x29},          /* 1920x1440x16 */
54326 -       {0x6b,0x07ff,0x080b,0x3b17,0x0141,0x10,0x0b,0x00,0x00,0x00,0x29},          /* 1920x1440x32 */
54327 -       {0x6c,0x067b,0x090c,0x3b37,0x0000,0x08,0x0c,0x00,0x00,0x00,0x2f},          /* 2048x1536x8 */
54328 -       {0x6d,0x06fd,0x090c,0x3b37,0x0000,0x10,0x0c,0x00,0x00,0x00,0x2f},          /* 2048x1536x16 */
54329 -       {0x6e,0x07ff,0x090c,0x3b37,0x0000,0x10,0x0c,0x00,0x00,0x00,0x2f},          /* 2048x1536x32 */
54330 -       {0x70,0x2a1b,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34},          /* 800x480x8 */
54331 -       {0x71,0x0a1b,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37},          /* 1024x576x8 */
54332 -       {0x74,0x0a1d,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37},          /* 1024x576x16 */
54333 -       {0x75,0x0a3d,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a},          /* 1280x720x16 */
54334 -       {0x76,0x2a1f,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34},          /* 800x480x32 */
54335 -       {0x77,0x0a1f,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37},          /* 1024x576x32 */
54336 -       {0x78,0x0a3f,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a},          /* 1280x720x32 */
54337 -       {0x79,0x0a3b,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a},          /* 1280x720x8 */
54338 -       {0x7a,0x2a1d,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34},          /* 800x480x16 */
54339 -       {0x7c,0x0e3b,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x3d},          /* 1280x960x8 - TW */
54340 -       {0x7d,0x0e7d,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x3d},          /* 1280x960x16 - TW */
54341 -       {0x7e,0x0eff,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x3d},          /* 1280x960x32 - TW */
54342 -        /* TW: 650/LVDS BIOS new modes */
54343 -       {0x23,0x0e3b,0x0614,0x36f7,0x0000,0x08,0x14,0x00,0x00,0x00,0x40},          /* 1280x768x8 */
54344 -       {0x24,0x0e7d,0x0614,0x36f7,0x0000,0x08,0x14,0x00,0x00,0x00,0x40},          /* 1280x768x16 */
54345 -       {0x25,0x0eff,0x0614,0x36f7,0x0000,0x08,0x14,0x00,0x00,0x00,0x40},          /* 1280x768x32 */
54346 -       {0x26,0x0e3b,0x0c15,0x36fe,0x0000,0x08,0x15,0x00,0x00,0x00,0x41},          /* 1400x1050x8 */
54347 -       {0x27,0x0e7d,0x0c15,0x36fe,0x0000,0x08,0x15,0x00,0x00,0x00,0x41},          /* 1400x1050x16 */
54348 -       {0x28,0x0eff,0x0c15,0x36fe,0x0000,0x08,0x15,0x00,0x00,0x00,0x41},          /* 1400x1050x32*/
54349 -       {0x29,0x0e1b,0x0d16,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x43},    /* TW: NEW 1152x864 - not in BIOS */
54350 -       {0x2a,0x0e3d,0x0d16,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x43},
54351 -       {0x2b,0x0e7f,0x0d16,0x0000,0x0000,0x08,0x16,0x00,0x00,0x00,0x43},
54352 -       {0x39,0x2a1b,0x0b17,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x45},    /* TW: NEW 848x480 - not in BIOS */
54353 -       {0x3b,0x2a3d,0x0b17,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x45},
54354 -       {0x3e,0x2a7f,0x0b17,0x0000,0x0000,0x08,0x17,0x00,0x00,0x00,0x45},
54355 -       {0x3f,0x2a1b,0x0b13,0x0000,0x0000,0x08,0x13,0x00,0x00,0x00,0x47},    /* TW: NEW 856x480 - not in BIOS */
54356 -       {0x42,0x2a3d,0x0b13,0x0000,0x0000,0x08,0x13,0x00,0x00,0x00,0x47},
54357 -       {0x45,0x2a7f,0x0b13,0x0000,0x0000,0x08,0x13,0x00,0x00,0x00,0x47},
54358 -       {0x48,0x2a1b,0x0e18,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x49},    /* TW: NEW 1360x768 - not in BIOS */
54359 -       {0x4b,0x2a3d,0x0e18,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x49},
54360 -       {0x4e,0x2a7f,0x0e18,0x0000,0x0000,0x08,0x18,0x00,0x00,0x00,0x49},
54361 -       {0xff,0x0000,0x0000,0x0000,0x0000,0x00,0x00,0x00,0x00,0x00,0x00}
54362 +       {0x6a,0x2212,0x0407,0x0102,SIS_RI_800x600,  0x00,0x00,0x07,0x00}, /* 800x600x? */
54363 +       {0x2e,0x0a1b,0x0306,0x0101,SIS_RI_640x480,  0x00,0x00,0x05,0x08}, /* 640x480x8 */
54364 +        {0x2f,0x0a1b,0x0305,0x0100,SIS_RI_640x400,  0x00,0x00,0x05,0x10}, /* 640x400x8 */
54365 +       {0x30,0x2a1b,0x0407,0x0103,SIS_RI_800x600,  0x00,0x00,0x07,0x00}, /* 800x600x8 */
54366 +        {0x31,0x0a1b,0x0a0d,0x0000,SIS_RI_720x480,  0x00,0x00,0x06,0x11}, /* 720x480x8 */
54367 +       {0x32,0x0a1b,0x0a0e,0x0000,SIS_RI_720x576,  0x00,0x00,0x06,0x12}, /* 720x576x8 */
54368 +       {0x33,0x0a1d,0x0a0d,0x0000,SIS_RI_720x480,  0x00,0x00,0x06,0x11}, /* 720x480x16 */
54369 +       {0x34,0x2a1d,0x0a0e,0x0000,SIS_RI_720x576,  0x00,0x00,0x06,0x12}, /* 720x576x16 */
54370 +       {0x35,0x0a1f,0x0a0d,0x0000,SIS_RI_720x480,  0x00,0x00,0x06,0x11}, /* 720x480x32 */
54371 +       {0x36,0x2a1f,0x0a0e,0x0000,SIS_RI_720x576,  0x00,0x00,0x06,0x12}, /* 720x576x32 */
54372 +       {0x37,0x0212,0x0508,0x0104,SIS_RI_1024x768, 0x00,0x00,0x08,0x13}, /* 1024x768x? */
54373 +       {0x38,0x0a1b,0x0508,0x0105,SIS_RI_1024x768, 0x00,0x00,0x08,0x13}, /* 1024x768x8 */
54374 +       {0x3a,0x0e3b,0x0609,0x0107,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a}, /* 1280x1024x8 */
54375 +       {0x3c,0x0e3b,0x070a,0x0130,SIS_RI_1600x1200,0x00,0x00,0x00,0x1e}, /* 1600x1200x8 */
54376 +       {0x3d,0x0e7d,0x070a,0x0131,SIS_RI_1600x1200,0x00,0x00,0x00,0x1e}, /* 1600x1200x16 */
54377 +       {0x40,0x9a1c,0x0000,0x010d,SIS_RI_320x200,  0x00,0x00,0x04,0x25}, /* 320x200x15 */
54378 +       {0x41,0x9a1d,0x0000,0x010e,SIS_RI_320x200,  0x00,0x00,0x04,0x25}, /* 320x200x16 */
54379 +       {0x43,0x0a1c,0x0306,0x0110,SIS_RI_640x480,  0x00,0x00,0x05,0x08},
54380 +       {0x44,0x0a1d,0x0306,0x0111,SIS_RI_640x480,  0x00,0x00,0x05,0x08}, /* 640x480x16 */
54381 +       {0x46,0x2a1c,0x0407,0x0113,SIS_RI_800x600,  0x00,0x00,0x07,0x00},
54382 +       {0x47,0x2a1d,0x0407,0x0114,SIS_RI_800x600,  0x00,0x00,0x07,0x00}, /* 800x600x16 */
54383 +       {0x49,0x0a3c,0x0508,0x0116,SIS_RI_1024x768, 0x00,0x00,0x00,0x13},
54384 +       {0x4a,0x0a3d,0x0508,0x0117,SIS_RI_1024x768, 0x00,0x00,0x08,0x13}, /* 1024x768x16 */
54385 +       {0x4c,0x0e7c,0x0609,0x0119,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a},
54386 +       {0x4d,0x0e7d,0x0609,0x011a,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a}, /* 1280x1024x16 */
54387 +       {0x50,0x9a1b,0x0001,0x0132,SIS_RI_320x240,  0x00,0x00,0x04,0x26}, /* 320x240x8  */
54388 +       {0x51,0xba1b,0x0103,0x0133,SIS_RI_400x300,  0x00,0x00,0x07,0x27}, /* 400x300x8  */
54389 +       {0x52,0xba1b,0x0204,0x0134,SIS_RI_512x384,  0x00,0x00,0x00,0x28}, /* 512x384x8  */
54390 +       {0x56,0x9a1d,0x0001,0x0135,SIS_RI_320x240,  0x00,0x00,0x04,0x26}, /* 320x240x16 */
54391 +       {0x57,0xba1d,0x0103,0x0136,SIS_RI_400x300,  0x00,0x00,0x07,0x27}, /* 400x300x16 */
54392 +       {0x58,0xba1d,0x0204,0x0137,SIS_RI_512x384,  0x00,0x00,0x00,0x28}, /* 512x384x16 */
54393 +       {0x59,0x9a1b,0x0000,0x0138,SIS_RI_320x200,  0x00,0x00,0x04,0x25}, /* 320x200x8  */
54394 +       {0x5a,0x021b,0x0014,0x0138,SIS_RI_320x240,  0x00,0x00,0x04,0x3f}, /* 320x240x8  fstn */
54395 +       {0x5b,0x0a1d,0x0014,0x0135,SIS_RI_320x240,  0x00,0x00,0x04,0x3f}, /* 320x240x16 fstn */
54396 +       {0x5c,0xba1f,0x0204,0x0000,SIS_RI_512x384,  0x00,0x00,0x00,0x28}, /* 512x384x32 */
54397 +       {0x5d,0x0a1d,0x0305,0x0139,SIS_RI_640x400,  0x00,0x00,0x07,0x10},
54398 +       {0x5e,0x0a1f,0x0305,0x0000,SIS_RI_640x400,  0x00,0x00,0x07,0x10}, /* 640x400x32 */
54399 +       {0x62,0x0a3f,0x0306,0x013a,SIS_RI_640x480,  0x00,0x00,0x05,0x08}, /* 640x480x32 */
54400 +       {0x63,0x2a3f,0x0407,0x013b,SIS_RI_800x600,  0x00,0x00,0x07,0x00}, /* 800x600x32 */
54401 +       {0x64,0x0a7f,0x0508,0x013c,SIS_RI_1024x768, 0x00,0x00,0x08,0x13}, /* 1024x768x32 */
54402 +       {0x65,0x0eff,0x0609,0x013d,SIS_RI_1280x1024,0x00,0x00,0x00,0x1a}, /* 1280x1024x32 */
54403 +       {0x66,0x0eff,0x070a,0x013e,SIS_RI_1600x1200,0x00,0x00,0x00,0x1e}, /* 1600x1200x32 */
54404 +       {0x68,0x067b,0x080b,0x013f,SIS_RI_1920x1440,0x00,0x00,0x00,0x29}, /* 1920x1440x8 */
54405 +       {0x69,0x06fd,0x080b,0x0140,SIS_RI_1920x1440,0x00,0x00,0x00,0x29}, /* 1920x1440x16 */
54406 +       {0x6b,0x07ff,0x080b,0x0141,SIS_RI_1920x1440,0x00,0x00,0x00,0x29}, /* 1920x1440x32 */
54407 +       {0x6c,0x067b,0x090c,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x2f}, /* 2048x1536x8 */
54408 +       {0x6d,0x06fd,0x090c,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x2f}, /* 2048x1536x16 */
54409 +       {0x6e,0x07ff,0x090c,0x0000,SIS_RI_2048x1536,0x00,0x00,0x00,0x2f}, /* 2048x1536x32 */
54410 +       {0x70,0x2a1b,0x0410,0x0000,SIS_RI_800x480,  0x00,0x00,0x07,0x34}, /* 800x480x8 */
54411 +       {0x71,0x0a1b,0x0511,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x37}, /* 1024x576x8 */
54412 +       {0x74,0x0a1d,0x0511,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x37}, /* 1024x576x16 */
54413 +       {0x75,0x0a3d,0x0612,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x3a}, /* 1280x720x16 */
54414 +       {0x76,0x2a1f,0x0410,0x0000,SIS_RI_800x480,  0x00,0x00,0x07,0x34}, /* 800x480x32 */
54415 +       {0x77,0x0a1f,0x0511,0x0000,SIS_RI_1024x576, 0x00,0x00,0x00,0x37}, /* 1024x576x32 */
54416 +       {0x78,0x0a3f,0x0612,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x3a}, /* 1280x720x32 */
54417 +       {0x79,0x0a3b,0x0612,0x0000,SIS_RI_1280x720, 0x00,0x00,0x00,0x3a}, /* 1280x720x8 */
54418 +       {0x7a,0x2a1d,0x0410,0x0000,SIS_RI_800x480,  0x00,0x00,0x07,0x34}, /* 800x480x16 */
54419 +       {0x7c,0x0e3b,0x060f,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x3d}, /* 1280x960x8 */
54420 +       {0x7d,0x0e7d,0x060f,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x3d}, /* 1280x960x16 */
54421 +       {0x7e,0x0eff,0x060f,0x0000,SIS_RI_1280x960, 0x00,0x00,0x00,0x3d}, /* 1280x960x32 */
54422 +       {0x23,0x0e3b,0x0614,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x40}, /* 1280x768x8 */
54423 +       {0x24,0x0e7d,0x0614,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x40}, /* 1280x768x16 */
54424 +       {0x25,0x0eff,0x0614,0x0000,SIS_RI_1280x768, 0x00,0x00,0x00,0x40}, /* 1280x768x32 */
54425 +       {0x26,0x0e3b,0x0c15,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x41}, /* 1400x1050x8 */
54426 +       {0x27,0x0e7d,0x0c15,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x41}, /* 1400x1050x16 */
54427 +       {0x28,0x0eff,0x0c15,0x0000,SIS_RI_1400x1050,0x00,0x00,0x00,0x41}, /* 1400x1050x32*/
54428 +       {0x29,0x0e1b,0x0d16,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x43}, /* 1152x864 */
54429 +       {0x2a,0x0e3d,0x0d16,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x43},
54430 +       {0x2b,0x0e7f,0x0d16,0x0000,SIS_RI_1152x864, 0x00,0x00,0x00,0x43},
54431 +       {0x39,0x2a1b,0x0b17,0x0000,SIS_RI_848x480,  0x00,0x00,0x00,0x45}, /* 848x480 */
54432 +       {0x3b,0x2a3d,0x0b17,0x0000,SIS_RI_848x480,  0x00,0x00,0x00,0x45},
54433 +       {0x3e,0x2a7f,0x0b17,0x0000,SIS_RI_848x480,  0x00,0x00,0x00,0x45},
54434 +       {0x3f,0x2a1b,0x0b13,0x0000,SIS_RI_856x480,  0x00,0x00,0x00,0x47}, /* 856x480 */
54435 +       {0x42,0x2a3d,0x0b13,0x0000,SIS_RI_856x480,  0x00,0x00,0x00,0x47},
54436 +       {0x45,0x2a7f,0x0b13,0x0000,SIS_RI_856x480,  0x00,0x00,0x00,0x47},
54437 +       {0x48,0x2a1b,0x0e18,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x49}, /* 1360x768 */
54438 +       {0x4b,0x2a3d,0x0e18,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x49},
54439 +       {0x4e,0x2a7f,0x0e18,0x0000,SIS_RI_1360x768, 0x00,0x00,0x00,0x49},
54440 +       {0x4f,0x9a1f,0x0000,0x0000,SIS_RI_320x200,  0x00,0x00,0x04,0x25}, /* 320x200x32 */
54441 +       {0x53,0x9a1f,0x0001,0x0000,SIS_RI_320x240,  0x00,0x00,0x04,0x26}, /* 320x240x32 */
54442 +       {0x54,0xba1f,0x0103,0x0000,SIS_RI_400x300,  0x00,0x00,0x07,0x27}, /* 400x300x32 */
54443 +       {0x5f,0x2a1b,0x0f0e,0x0000,SIS_RI_768x576,  0x00,0x00,0x00,0x4a}, /* 768x576x8 */
54444 +       {0x60,0x2a1d,0x0f0e,0x0000,SIS_RI_768x576,  0x00,0x00,0x00,0x4a}, /* 768x576x16 */
54445 +       {0x61,0x2a1f,0x0f0e,0x0000,SIS_RI_768x576,  0x00,0x00,0x00,0x4a}, /* 768x576x32 */
54446 +       {0xff,0x0000,0x0000,0x0000,0x00,            0x00,0x00,0x00,0x00}
54447  };
54448  
54449  typedef struct _SiS310_Ext2Struct
54450 @@ -604,89 +180,87 @@ typedef struct _SiS310_Ext2Struct
54451         UCHAR  ModeID;
54452         USHORT XRes;
54453         USHORT YRes;
54454 -       USHORT ROM_OFFSET;
54455  } SiS310_Ext2Struct;
54456  
54457  static const SiS310_Ext2Struct SiS310_RefIndex[]=
54458  {
54459 -/*     {0x005f,0x0d,0x03,0x05,0x6a, 800, 600,0x3a81},    0x0 - TW: Patch for Chrontel 7019  */
54460 -       {0x085f,0x0d,0x03,0x05,0x6a, 800, 600,0x3a81}, /* 0x0 */
54461 -       {0x0467,0x0e,0x04,0x05,0x6a, 800, 600,0x3a86}, /* 0x1 */
54462 -       {0x0067,0x0f,0x08,0x48,0x6a, 800, 600,0x3a8b}, /* 0x2 */
54463 -       {0x0067,0x10,0x07,0x8b,0x6a, 800, 600,0x3a90}, /* 0x3 */
54464 -       {0x0147,0x11,0x0a,0x00,0x6a, 800, 600,0x3a95}, /* 0x4 */
54465 -       {0x0147,0x12,0x0d,0x00,0x6a, 800, 600,0x3a9a}, /* 0x5 - 4147 TW: Test sync change */
54466 -       {0x0047,0x13,0x13,0x00,0x6a, 800, 600,0x3a9f}, /* 0x6 - 4047 */
54467 -       {0x0047,0x14,0x1c,0x00,0x6a, 800, 600,0x3aa4}, /* 0x7 - 4047 */
54468 -/*     {0xc05f,0x05,0x00,0x04,0x2e, 640, 480,0x3a57},    0x8 - TW: Patch for Chrontel 7019  */
54469 -       {0xc85f,0x05,0x00,0x04,0x2e, 640, 480,0x3a57}, /* 0x8 */
54470 -       {0xc067,0x06,0x02,0x04,0x2e, 640, 480,0x3a5c}, /* 0x9 */
54471 -       {0xc067,0x07,0x02,0x47,0x2e, 640, 480,0x3a61}, /* 0xa */
54472 -       {0xc067,0x08,0x03,0x8a,0x2e, 640, 480,0x3a66}, /* 0xb */
54473 -       {0xc047,0x09,0x05,0x00,0x2e, 640, 480,0x3a6b}, /* 0xc - 4047 */
54474 -       {0xc047,0x0a,0x09,0x00,0x2e, 640, 480,0x3a70}, /* 0xd - 4047 */
54475 -       {0xc047,0x0b,0x0e,0x00,0x2e, 640, 480,0x3a75}, /* 0xe - 4047 */
54476 -       {0xc047,0x0c,0x15,0x00,0x2e, 640, 480,0x3a7a}, /* 0xf */
54477 -       {0x407f,0x04,0x00,0x00,0x2f, 640, 400,0x3a50}, /* 0x10 */
54478 -       {0xc00f,0x3c,0x01,0x06,0x31, 720, 480,0x3b85}, /* 0x11 */
54479 -       {0x000f,0x3d,0x03,0x06,0x32, 720, 576,0x3b8c}, /* 0x12 */
54480 -       {0x0187,0x15,0x06,0x00,0x37,1024, 768,0x3aab}, /* 0x13 */
54481 -       {0xc877,0x16,0x0b,0x06,0x37,1024, 768,0x3ab0}, /* 0x14 */
54482 -       {0xc067,0x17,0x0f,0x49,0x37,1024, 768,0x3ab5}, /* 0x15 */
54483 -       {0x0267,0x18,0x11,0x00,0x37,1024, 768,0x3aba}, /* 0x16 */
54484 -       {0x0047,0x19,0x16,0x8c,0x37,1024, 768,0x3abf}, /* 0x17 */
54485 -       {0x0047,0x1a,0x1b,0x00,0x37,1024, 768,0x3ac4}, /* 0x18 - 4047 */
54486 -       {0x0007,0x1b,0x1f,0x00,0x37,1024, 768,0x3ac9}, /* 0x19 - 4047 */
54487 -       {0x0387,0x1c,0x11,0x00,0x3a,1280,1024,0x3adc}, /* 0x1a */
54488 -       {0x0077,0x1d,0x19,0x07,0x3a,1280,1024,0x3ae1}, /* 0x1b */
54489 -       {0x0047,0x1e,0x1e,0x00,0x3a,1280,1024,0x3ae6}, /* 0x1c */
54490 -       {0x0007,0x1f,0x20,0x00,0x3a,1280,1024,0x3aeb}, /* 0x1d */
54491 -       {0x0027,0x20,0x21,0x09,0x3c,1600,1200,0x3af2}, /* 0x1e */
54492 -       {0x0007,0x21,0x22,0x00,0x3c,1600,1200,0x3af7}, /* 0x1f */
54493 -       {0x0007,0x22,0x23,0x00,0x3c,1600,1200,0x3afc}, /* 0x20 */
54494 -       {0x0007,0x23,0x25,0x00,0x3c,1600,1200,0x3b01}, /* 0x21 */
54495 -       {0x0007,0x24,0x26,0x00,0x3c,1600,1200,0x3b06}, /* 0x22 */
54496 -       {0x0007,0x25,0x2c,0x00,0x3c,1600,1200,0x3b0b}, /* 0x23 */
54497 -       {0x0007,0x26,0x34,0x00,0x3c,1600,1200,0x3b10}, /* 0x24 */
54498 -       {0x407f,0x00,0x00,0x00,0x40, 320, 200,0x3a34}, /* 0x25 */
54499 -       {0xc07f,0x01,0x00,0x04,0x50, 320, 240,0x3a3b}, /* 0x26 */
54500 -       {0x007f,0x02,0x04,0x05,0x51, 400, 300,0x3a42}, /* 0x27 */
54501 -       {0xc077,0x03,0x0b,0x06,0x52, 512, 384,0x3a49}, /* 0x28 */
54502 -       {0x8007,0x27,0x27,0x00,0x68,1920,1440,0x3b17}, /* 0x29 */
54503 -       {0x4007,0x28,0x29,0x00,0x68,1920,1440,0x3b1c}, /* 0x2a */
54504 -       {0x4007,0x29,0x2e,0x00,0x68,1920,1440,0x3b21}, /* 0x2b */
54505 -       {0x4007,0x2a,0x30,0x00,0x68,1920,1440,0x3b26}, /* 0x2c */
54506 -       {0x4007,0x2b,0x35,0x00,0x68,1920,1440,0x3b2b}, /* 0x2d */
54507 -       {0x4005,0x2c,0x39,0x00,0x68,1920,1440,0x3b30}, /* 0x2e */
54508 -       {0x4007,0x2d,0x2b,0x00,0x6c,2048,1536,0x3b37}, /* 0x2f */
54509 -       {0x4007,0x2e,0x31,0x00,0x6c,2048,1536,0x3b3c}, /* 0x30 */
54510 -       {0x4007,0x2f,0x33,0x00,0x6c,2048,1536,0x3b41}, /* 0x31 */
54511 -       {0x4007,0x30,0x37,0x00,0x6c,2048,1536,0x3b46}, /* 0x32 */
54512 -       {0x4005,0x31,0x38,0x00,0x6c,2048,1536,0x3b4b}, /* 0x33 */
54513 -       {0x0057,0x32,0x40,0x08,0x70, 800, 480,0x3b52}, /* 0x34 */
54514 -       {0x0047,0x33,0x07,0x08,0x70, 800, 480,0x3b57}, /* 0x35 */
54515 -       {0x0047,0x34,0x0a,0x08,0x70, 800, 480,0x3b5c}, /* 0x36 */
54516 -       {0x0057,0x35,0x0b,0x09,0x71,1024, 576,0x3b63}, /* 0x37 */
54517 -       {0x0047,0x36,0x11,0x09,0x71,1024, 576,0x3b68}, /* 0x38 */
54518 -       {0x0047,0x37,0x16,0x09,0x71,1024, 576,0x3b6d}, /* 0x39 */
54519 -       {0x0057,0x38,0x19,0x0a,0x75,1280, 720,0x3b74}, /* 0x3a */
54520 -       {0x0047,0x39,0x1e,0x0a,0x75,1280, 720,0x3b79}, /* 0x3b */
54521 -       {0x0007,0x3a,0x20,0x0a,0x75,1280, 720,0x3b7e}, /* 0x3c */
54522 -       {0x0067,0x3b,0x19,0x08,0x7c,1280, 960,0x3ad0}, /* 0x3d */
54523 -       {0x0027,0x4c,0x59,0x08,0x7c,1280, 960,0x3ad0}, /* 0x3e */
54524 -       {0xc07f,0x01,0x00,0x06,0x5a, 320, 480,0x3b83}, /* 0x3f */    /* FSTN mode */
54525 -        {0x0077,0x42,0x12,0x08,0x23,1280, 768,0x0000}, /* 0x40 */  
54526 -       {0x0067,0x43,0x4d,0x08,0x26,1400,1050,0x0000}, /* 0x41 */  
54527 -       {0x0007,0x4b,0x5a,0x08,0x26,1400,1050,0x0000}, /* 0x42 */    /* TW: new, not in any BIOS */
54528 -       {0x0047,0x44,0x19,0x00,0x29,1152, 864,0x0000}, /* 0x43 TW: Non-BIOS, new */
54529 -       {0x0047,0x4a,0x1e,0x00,0x29,1152, 864,0x0000}, /* 0x44 TW: Non-BIOS, new */
54530 -       {0x00c7,0x45,0x57,0x00,0x39, 848, 480,0x0000}, /* 0x45 TW: 848x480-38Hzi - Non-BIOS, new */
54531 -       {0xc047,0x46,0x55,0x00,0x39, 848, 480,0x0000}, /* 0x46 TW: 848x480-60Hz  - Non-BIOS, new */
54532 -       {0x00c7,0x47,0x57,0x00,0x3f, 856, 480,0x0000}, /* 0x47 TW: 856x480-38Hzi - Non-BIOS, new */
54533 -       {0xc047,0x48,0x57,0x00,0x3f, 856, 480,0x0000}, /* 0x48 TW: 856x480-60Hz  - Non-BIOS, new */
54534 -       {0x0047,0x49,0x58,0x00,0x48,1360, 768,0x0000}, /* 0x49 TW: 1360x768-60Hz - Non-BIOS, new */
54535 -       {0xffff,0x00,0x00,0x00,0x00,   0,   0,0x0000}
54536 -}; 
54537 +       {0x085f,0x0d,0x03,0x05,0x6a, 800, 600}, /* 0x0 */
54538 +       {0x0467,0x0e,0x04,0x05,0x6a, 800, 600}, /* 0x1 */
54539 +       {0x0067,0x0f,0x08,0x48,0x6a, 800, 600}, /* 0x2 */
54540 +       {0x0067,0x10,0x07,0x8b,0x6a, 800, 600}, /* 0x3 */
54541 +       {0x0147,0x11,0x0a,0x00,0x6a, 800, 600}, /* 0x4 */
54542 +       {0x0147,0x12,0x0d,0x00,0x6a, 800, 600}, /* 0x5 - TW: Test sync change */
54543 +       {0x0047,0x13,0x13,0x00,0x6a, 800, 600}, /* 0x6 */
54544 +       {0x0047,0x14,0x1c,0x00,0x6a, 800, 600}, /* 0x7 */
54545 +       {0xc85f,0x05,0x00,0x04,0x2e, 640, 480}, /* 0x8 */
54546 +       {0xc067,0x06,0x02,0x04,0x2e, 640, 480}, /* 0x9 */
54547 +       {0xc067,0x07,0x02,0x47,0x2e, 640, 480}, /* 0xa */
54548 +       {0xc067,0x08,0x03,0x8a,0x2e, 640, 480}, /* 0xb */
54549 +       {0xc047,0x09,0x05,0x00,0x2e, 640, 480}, /* 0xc */
54550 +       {0xc047,0x0a,0x09,0x00,0x2e, 640, 480}, /* 0xd */
54551 +       {0xc047,0x0b,0x0e,0x00,0x2e, 640, 480}, /* 0xe */
54552 +       {0xc047,0x0c,0x15,0x00,0x2e, 640, 480}, /* 0xf */
54553 +       {0x407f,0x04,0x00,0x00,0x2f, 640, 400}, /* 0x10 */
54554 +       {0xc00f,0x3c,0x01,0x06,0x31, 720, 480}, /* 0x11 */
54555 +       {0x000f,0x3d,0x03,0x06,0x32, 720, 576}, /* 0x12 */
54556 +       {0x0187,0x15,0x06,0x00,0x37,1024, 768}, /* 0x13 */
54557 +       {0xc877,0x16,0x0b,0x06,0x37,1024, 768}, /* 0x14 */
54558 +       {0xc067,0x17,0x0f,0x49,0x37,1024, 768}, /* 0x15 */
54559 +       {0x0267,0x18,0x11,0x00,0x37,1024, 768}, /* 0x16 */
54560 +       {0x0047,0x19,0x16,0x8c,0x37,1024, 768}, /* 0x17 */
54561 +       {0x0047,0x1a,0x1b,0x00,0x37,1024, 768}, /* 0x18 */
54562 +       {0x0007,0x1b,0x1f,0x00,0x37,1024, 768}, /* 0x19 */
54563 +       {0x0387,0x1c,0x11,0x00,0x3a,1280,1024}, /* 0x1a */
54564 +       {0x0077,0x1d,0x19,0x07,0x3a,1280,1024}, /* 0x1b */
54565 +       {0x0047,0x1e,0x1e,0x00,0x3a,1280,1024}, /* 0x1c */
54566 +       {0x0007,0x1f,0x20,0x00,0x3a,1280,1024}, /* 0x1d */
54567 +       {0x0867,0x20,0x21,0x09,0x3c,1600,1200}, /* 0x1e */
54568 +       {0x0007,0x21,0x22,0x00,0x3c,1600,1200}, /* 0x1f */
54569 +       {0x0007,0x22,0x23,0x00,0x3c,1600,1200}, /* 0x20 */
54570 +       {0x0007,0x23,0x25,0x00,0x3c,1600,1200}, /* 0x21 */
54571 +       {0x0007,0x24,0x26,0x00,0x3c,1600,1200}, /* 0x22 */
54572 +       {0x0007,0x25,0x2c,0x00,0x3c,1600,1200}, /* 0x23 */
54573 +       {0x0007,0x26,0x34,0x00,0x3c,1600,1200}, /* 0x24 */
54574 +       {0x407f,0x00,0x00,0x00,0x40, 320, 200}, /* 0x25 */
54575 +       {0xc07f,0x01,0x00,0x04,0x50, 320, 240}, /* 0x26 */
54576 +       {0x007f,0x02,0x04,0x05,0x51, 400, 300}, /* 0x27 */
54577 +       {0xc077,0x03,0x0b,0x06,0x52, 512, 384}, /* 0x28 */
54578 +       {0x8007,0x27,0x27,0x00,0x68,1920,1440}, /* 0x29 */
54579 +       {0x4007,0x28,0x29,0x00,0x68,1920,1440}, /* 0x2a */
54580 +       {0x4007,0x29,0x2e,0x00,0x68,1920,1440}, /* 0x2b */
54581 +       {0x4007,0x2a,0x30,0x00,0x68,1920,1440}, /* 0x2c */
54582 +       {0x4007,0x2b,0x35,0x00,0x68,1920,1440}, /* 0x2d */
54583 +       {0x4005,0x2c,0x39,0x00,0x68,1920,1440}, /* 0x2e */
54584 +       {0x4007,0x2d,0x2b,0x00,0x6c,2048,1536}, /* 0x2f */
54585 +       {0x4007,0x2e,0x31,0x00,0x6c,2048,1536}, /* 0x30 */
54586 +       {0x4007,0x2f,0x33,0x00,0x6c,2048,1536}, /* 0x31 */
54587 +       {0x4007,0x30,0x37,0x00,0x6c,2048,1536}, /* 0x32 */
54588 +       {0x4005,0x31,0x38,0x00,0x6c,2048,1536}, /* 0x33 */
54589 +       {0x0057,0x32,0x40,0x08,0x70, 800, 480}, /* 0x34 */
54590 +       {0x0047,0x33,0x07,0x08,0x70, 800, 480}, /* 0x35 */
54591 +       {0x0047,0x34,0x0a,0x08,0x70, 800, 480}, /* 0x36 */
54592 +       {0x0057,0x35,0x0b,0x09,0x71,1024, 576}, /* 0x37 */
54593 +       {0x0047,0x36,0x11,0x09,0x71,1024, 576}, /* 0x38 */
54594 +       {0x0047,0x37,0x16,0x09,0x71,1024, 576}, /* 0x39 */
54595 +       {0x0057,0x38,0x19,0x0a,0x75,1280, 720}, /* 0x3a */
54596 +       {0x0047,0x39,0x1e,0x0a,0x75,1280, 720}, /* 0x3b */
54597 +       {0x0007,0x3a,0x20,0x0a,0x75,1280, 720}, /* 0x3c */
54598 +       {0x0067,0x3b,0x19,0x08,0x7c,1280, 960}, /* 0x3d */
54599 +       {0x0027,0x4c,0x59,0x08,0x7c,1280, 960}, /* 0x3e */
54600 +       {0xc07f,0x4e,0x00,0x06,0x5a, 320, 240}, /* 0x3f */    /* FSTN 320x240 */
54601 +        {0x0077,0x42,0x5b,0x08,0x23,1280, 768}, /* 0x40 */    /* TW: 0x5b was 0x12 */
54602 +       {0x0067,0x43,0x4d,0x08,0x26,1400,1050}, /* 0x41 */
54603 +       {0x0007,0x4b,0x5a,0x08,0x26,1400,1050}, /* 0x42 TW: not in any BIOS */
54604 +       {0x0047,0x44,0x19,0x00,0x29,1152, 864}, /* 0x43 TW: Non-BIOS, new */
54605 +       {0x0047,0x4a,0x1e,0x00,0x29,1152, 864}, /* 0x44 TW: Non-BIOS, new */
54606 +       {0x00c7,0x45,0x57,0x00,0x39, 848, 480}, /* 0x45 TW: 848x480-38Hzi - Non-BIOS, new */
54607 +       {0xc067,0x46,0x55,0x0b,0x39, 848, 480}, /* 0x46 TW: 848x480-60Hz  - Non-BIOS, new */
54608 +       {0x00c7,0x47,0x57,0x00,0x3f, 856, 480}, /* 0x47 TW: 856x480-38Hzi - Non-BIOS, new */
54609 +       {0xc047,0x48,0x57,0x00,0x3f, 856, 480}, /* 0x48 TW: 856x480-60Hz  - Non-BIOS, new */
54610 +       {0x0067,0x49,0x58,0x0c,0x48,1360, 768}, /* 0x49 TW: 1360x768-60Hz - Non-BIOS, new */
54611 +       {0x000f,0x4d,0x03,0x06,0x5f, 768, 576}, /* 0x4a TW: 768x576 */
54612 +       {0xffff,0x00,0x00,0x00,0x00,   0,   0}
54613 +};
54614  
54615  typedef struct _SiS310_CRT1TableStruct
54616  {
54617 @@ -710,7 +284,7 @@ static const SiS310_CRT1TableStruct SiS3
54618   {{0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
54619     0x9c,0x8e,0x8f,0x96,0xb9,0x30,0x00,0x05,
54620     0x00}}, /* 0x4 */
54621 -#if 0   
54622 +#if 0
54623   {{0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e,
54624     0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x05,
54625     0x00}}, /* 0x5 */
54626 @@ -940,19 +514,25 @@ static const SiS310_CRT1TableStruct SiS3
54627     0x00}},  /* 0x4b */ 
54628   {{0xd3,0x9f,0x9f,0x97,0xab,0x1f,0xf1,0xff, /* TW: New, 1280x960-85, not in any BIOS */
54629     0xc0,0x83,0xbf,0xbf,0xf2,0x10,0x00,0x07,
54630 -   0x01}}   /* 0x4c */
54631 +   0x01}},  /* 0x4c */
54632 + {{0x7b,0x5f,0x63,0x9f,0x6a,0x93,0x6f,0xf0, /* 768x576 */
54633 +   0x58,0x8a,0x3f,0x57,0x70,0x20,0x00,0x05,
54634 +   0x01}},  /* 0x4d */
54635 + {{0x2d,0x27,0x28,0x90,0x2c,0x80,0x0b,0x3e, /* FSTN 320x480, TEMP - possibly invalid */
54636 +   0xe9,0x8b,0xdf,0xe7,0x04,0x00,0x00,0x00,
54637 +   0x00}}   /* 0x4e */
54638  };
54639  
54640 -
54641  typedef struct _SiS310_MCLKDataStruct
54642  {
54643         UCHAR SR28,SR29,SR2A;
54644         USHORT CLOCK;
54645  } SiS310_MCLKDataStruct;
54646  
54647 +#ifdef LINUXBIOS
54648  static const SiS310_MCLKDataStruct SiS310_MCLKData_0_315[] =
54649  {
54650 -       { 0x3b,0x22,0x01,143},   /* TW: Was { 0x5c,0x23,0x01,166}, */
54651 +       { 0x3b,0x22,0x01,143},
54652         { 0x5c,0x23,0x01,166},
54653         { 0x5c,0x23,0x01,166},
54654         { 0x5c,0x23,0x01,166},
54655 @@ -962,7 +542,7 @@ static const SiS310_MCLKDataStruct SiS31
54656         { 0x5c,0x23,0x01,166}
54657  };
54658  
54659 -static const SiS310_MCLKDataStruct SiS310_MCLKData_0_650[] =   /* @ 0x54 */
54660 +static const SiS310_MCLKDataStruct SiS310_MCLKData_0_650[] =
54661  {
54662         { 0x5a,0x64,0x82, 66},
54663         { 0xb3,0x45,0x82, 83},
54664 @@ -973,8 +553,22 @@ static const SiS310_MCLKDataStruct SiS31
54665         { 0x37,0x22,0x82,133},
54666         { 0x37,0x22,0x82,133}
54667  };
54668 +#endif
54669 +
54670 +static const SiS310_MCLKDataStruct SiS310_MCLKData_0_330[] =
54671 +{
54672 +       { 0x5c,0x23,0x01,166},
54673 +       { 0x5c,0x23,0x01,166},
54674 +       { 0x7c,0x08,0x01,200},
54675 +       { 0x79,0x06,0x01,250},
54676 +       { 0x7c,0x08,0x01,200},
54677 +       { 0x7c,0x08,0x01,200},
54678 +       { 0x7c,0x08,0x01,200},
54679 +       { 0x79,0x06,0x01,250}
54680 +};
54681  
54682 -static const SiS310_MCLKDataStruct SiS310_MCLKData_0_330[] =   /* @ 0x54 */
54683 +#ifdef LINUXBIOS
54684 +static const SiS310_MCLKDataStruct SiS310_MCLKData_0_660[] =  /* TODO */
54685  {
54686         { 0x5c,0x23,0x01,166},
54687         { 0x5c,0x23,0x01,166},
54688 @@ -985,8 +579,9 @@ static const SiS310_MCLKDataStruct SiS31
54689         { 0x7c,0x08,0x01,200},
54690         { 0x79,0x06,0x01,250}
54691  };
54692 +#endif
54693  
54694 -static const SiS310_MCLKDataStruct SiS310_MCLKData_1[] =       /* @ 0x155 */
54695 +static const SiS310_MCLKDataStruct SiS310_MCLKData_1[] =
54696  {
54697          { 0x29,0x21,0x82,150},
54698         { 0x5c,0x23,0x82,166},
54699 @@ -998,6 +593,7 @@ static const SiS310_MCLKDataStruct SiS31
54700         { 0x37,0x22,0x82,133}
54701  };
54702  
54703 +#ifdef LINUXBIOS
54704  typedef struct _SiS310_ECLKDataStruct
54705  {
54706         UCHAR SR2E,SR2F,SR30;
54707 @@ -1011,6 +607,7 @@ static const SiS310_ECLKDataStruct SiS31
54708         { 0x5c,0x23,0x01,166},
54709         { 0x5c,0x23,0x01,166}
54710  };
54711 +#endif
54712  
54713  typedef struct _SiS310_VCLKDataStruct
54714  {
54715 @@ -1020,22 +617,22 @@ typedef struct _SiS310_VCLKDataStruct
54716  
54717  static const SiS310_VCLKDataStruct SiS310_VCLKData[]=
54718  {
54719 -       { 0x1b,0xe1, 25}, /* 0x0 */   /* 650/LVDS BIOS: @ 0x5647 */
54720 -       { 0x4e,0xe4, 28}, /* 0x1 */
54721 -       { 0x57,0xe4, 31}, /* 0x2 */
54722 -       { 0xc3,0xc8, 36}, /* 0x3 */
54723 -       { 0x42,0xe2, 40}, /* 0x4 */
54724 -       { 0xfe,0xcd, 43}, /* 0x5 */
54725 -       { 0x5d,0xc4, 44}, /* 0x6 */
54726 -       { 0x52,0xe2, 49}, /* 0x7 */
54727 -       { 0x53,0xe2, 50}, /* 0x8 */
54728 -       { 0x74,0x67, 52}, /* 0x9 */
54729 -       { 0x6d,0x66, 56}, /* 0xa */
54730 -       { 0x5a,0x64, 65}, /* 0xb */   /* TW: was 6c c3 - WRONG */
54731 -       { 0x46,0x44, 67}, /* 0xc */
54732 -       { 0xb1,0x46, 68}, /* 0xd */
54733 -       { 0xd3,0x4a, 72}, /* 0xe */
54734 -       { 0x29,0x61, 75}, /* 0xf */
54735 +       { 0x1b,0xe1, 25}, /* 0x00 */
54736 +       { 0x4e,0xe4, 28}, /* 0x01 */
54737 +       { 0x57,0xe4, 31}, /* 0x02 */
54738 +       { 0xc3,0xc8, 36}, /* 0x03 */
54739 +       { 0x42,0xe2, 40}, /* 0x04 */
54740 +       { 0xfe,0xcd, 43}, /* 0x05 */
54741 +       { 0x5d,0xc4, 44}, /* 0x06 */
54742 +       { 0x52,0xe2, 49}, /* 0x07 */
54743 +       { 0x53,0xe2, 50}, /* 0x08 */
54744 +       { 0x74,0x67, 52}, /* 0x09 */
54745 +       { 0x6d,0x66, 56}, /* 0x0a */
54746 +       { 0x5a,0x64, 65}, /* 0x0b */  /* TW: was 6c c3 - WRONG */
54747 +       { 0x46,0x44, 67}, /* 0x0c */
54748 +       { 0xb1,0x46, 68}, /* 0x0d */
54749 +       { 0xd3,0x4a, 72}, /* 0x0e */
54750 +       { 0x29,0x61, 75}, /* 0x0f */
54751         { 0x6e,0x46, 76}, /* 0x10 */
54752         { 0x2b,0x61, 78}, /* 0x11 */
54753         { 0x31,0x42, 79}, /* 0x12 */
54754 @@ -1045,7 +642,7 @@ static const SiS310_VCLKDataStruct SiS31
54755         { 0x62,0x44, 94}, /* 0x16 */
54756         { 0x2b,0x41,104}, /* 0x17 */
54757         { 0x3a,0x23,105}, /* 0x18 */
54758 -       { 0x70,0x44,108}, /* 0x19 */
54759 +       { 0x70,0x44,108}, /* 0x19 */  /* 1400x1050 LCD */
54760         { 0x3c,0x23,109}, /* 0x1a */
54761         { 0x5e,0x43,113}, /* 0x1b */
54762         { 0xbc,0x44,116}, /* 0x1c */
54763 @@ -1078,12 +675,12 @@ static const SiS310_VCLKDataStruct SiS31
54764         { 0xea,0x08,340}, /* 0x37 */
54765         { 0xe8,0x07,376}, /* 0x38 */
54766         { 0xde,0x06,389}, /* 0x39 */
54767 -       { 0x52,0x2a, 54}, /* 0x3a */
54768 -       { 0x52,0x6a, 27}, /* 0x3b */
54769 -       { 0x62,0x24, 70}, /* 0x3c */
54770 -       { 0x62,0x64, 70}, /* 0x3d */
54771 -       { 0xa8,0x4c, 30}, /* 0x3e */
54772 -       { 0x20,0x26, 33}, /* 0x3f */
54773 +       { 0x52,0x2a, 54}, /* 0x3a */  /* 301 TV */
54774 +       { 0x52,0x6a, 27}, /* 0x3b */  /* 301 TV */
54775 +       { 0x62,0x24, 70}, /* 0x3c */  /* 301 TV */
54776 +       { 0x62,0x64, 70}, /* 0x3d */  /* 301 TV */
54777 +       { 0xa8,0x4c, 30}, /* 0x3e */  /* 301 TV */
54778 +       { 0x20,0x26, 33}, /* 0x3f */  /* 301 TV */
54779         { 0x31,0xc2, 39}, /* 0x40 */
54780         { 0x60,0x36, 30}, /* 0x41 */  /* Chrontel */
54781         { 0x40,0x4a, 28}, /* 0x42 */  /* Chrontel */
54782 @@ -1096,7 +693,7 @@ static const SiS310_VCLKDataStruct SiS31
54783         { 0xce,0x3c, 39}, /* 0x49 */
54784         { 0x52,0x4a, 36}, /* 0x4a */  /* Chrontel */
54785         { 0x34,0x61, 95}, /* 0x4b */
54786 -       { 0x78,0x27,108}, /* 0x4c - was 102 */  /* TW: Last entry in 650/301 BIOS */
54787 +       { 0x78,0x27,108}, /* 0x4c - was 102 */
54788         { 0x66,0x43,123}, /* 0x4d */  /* Modes 0x26-0x28 (1400x1050) */
54789         { 0x41,0x4e, 21}, /* 0x4e */
54790         { 0xa1,0x4a, 29}, /* 0x4f */  /* Chrontel */
54791 @@ -1110,7 +707,8 @@ static const SiS310_VCLKDataStruct SiS31
54792         { 0xbf,0xc8, 35}, /* 0x57 - added for 856x480-38i,60 (not in any BIOS) */
54793         { 0x30,0x23, 88}, /* 0x58 - added for 1360x768-62 (is 60Hz!) (not in any BIOS) */
54794         { 0x52,0x07,149}, /* 0x59 - added for 1280x960-85 (Not in any BIOS) */
54795 -       { 0x56,0x07,156}  /* 0x5a - added for 1400x1050-75 */
54796 +       { 0x56,0x07,156}, /* 0x5a - added for 1400x1050-75 */
54797 +       { 0x70,0x29, 81}  /* 0x5b */  /* 1280x768 LCD */
54798  };
54799  
54800  typedef struct _SiS310_VBVCLKDataStruct
54801 @@ -1121,22 +719,22 @@ typedef struct _SiS310_VBVCLKDataStruct
54802  
54803  static const SiS310_VBVCLKDataStruct SiS310_VBVCLKData[]=
54804  {
54805 -       { 0x1b,0xe1, 25}, /* 0x0 */   /* 650/LVDS BIOS: @ 0x579c */
54806 -       { 0x4e,0xe4, 28}, /* 0x1 */
54807 -       { 0x57,0xe4, 31}, /* 0x2 */
54808 -       { 0xc3,0xc8, 36}, /* 0x3 */
54809 -       { 0x42,0x47, 40}, /* 0x4 */
54810 -       { 0xfe,0xcd, 43}, /* 0x5 */
54811 -       { 0x5d,0xc4, 44}, /* 0x6 */
54812 -       { 0x52,0x47, 49}, /* 0x7 */
54813 -       { 0x53,0x47, 50}, /* 0x8 */
54814 -       { 0x74,0x67, 52}, /* 0x9 */
54815 -       { 0x6d,0x66, 56}, /* 0xa */
54816 -       { 0x35,0x62, 65}, /* 0xb */  /* Was 0x5a,0x64 - 650/LVDS+301 bios: 35,62  */
54817 -       { 0x46,0x44, 67}, /* 0xc */
54818 -       { 0xb1,0x46, 68}, /* 0xd */
54819 -       { 0xd3,0x4a, 72}, /* 0xe */
54820 -       { 0x29,0x61, 75}, /* 0xf */
54821 +       { 0x1b,0xe1, 25}, /* 0x00 */
54822 +       { 0x4e,0xe4, 28}, /* 0x01 */
54823 +       { 0x57,0xe4, 31}, /* 0x02 */
54824 +       { 0xc3,0xc8, 36}, /* 0x03 */
54825 +       { 0x42,0x47, 40}, /* 0x04 */
54826 +       { 0xfe,0xcd, 43}, /* 0x05 */
54827 +       { 0x5d,0xc4, 44}, /* 0x06 */
54828 +       { 0x52,0x47, 49}, /* 0x07 */
54829 +       { 0x53,0x47, 50}, /* 0x08 */
54830 +       { 0x74,0x67, 52}, /* 0x09 */
54831 +       { 0x6d,0x66, 56}, /* 0x0a */
54832 +       { 0x35,0x62, 65}, /* 0x0b */  /* Was 0x5a,0x64 - 650/LVDS+301 bios: 35,62  */
54833 +       { 0x46,0x44, 67}, /* 0x0c */
54834 +       { 0xb1,0x46, 68}, /* 0x0d */
54835 +       { 0xd3,0x4a, 72}, /* 0x0e */
54836 +       { 0x29,0x61, 75}, /* 0x0f */
54837         { 0x6d,0x46, 75}, /* 0x10 */
54838         { 0x41,0x43, 78}, /* 0x11 */
54839         { 0x31,0x42, 79}, /* 0x12 */
54840 @@ -1146,7 +744,7 @@ static const SiS310_VBVCLKDataStruct SiS
54841         { 0x62,0x44, 94}, /* 0x16 */
54842         { 0x2b,0x22,104}, /* 0x17 */
54843         { 0x49,0x24,105}, /* 0x18 */
54844 -       { 0xf8,0x2f,108}, /* 0x19 */
54845 +       { 0xf8,0x2f,108}, /* 0x19 */  /* 1400x1050 LCD */
54846         { 0x3c,0x23,109}, /* 0x1a */
54847         { 0x5e,0x43,113}, /* 0x1b */
54848         { 0xbc,0x44,116}, /* 0x1c */
54849 @@ -1179,19 +777,19 @@ static const SiS310_VBVCLKDataStruct SiS
54850         { 0xea,0x08,340}, /* 0x37 */
54851         { 0xe8,0x07,376}, /* 0x38 */
54852         { 0xde,0x06,389}, /* 0x39 */
54853 -       { 0x52,0x2a, 54}, /* 0x3a */
54854 -       { 0x52,0x6a, 27}, /* 0x3b */
54855 -       { 0x62,0x24, 70}, /* 0x3c */
54856 -       { 0x62,0x64, 70}, /* 0x3d */
54857 -       { 0xa8,0x4c, 30}, /* 0x3e */
54858 -       { 0x20,0x26, 33}, /* 0x3f */
54859 +       { 0x52,0x2a, 54}, /* 0x3a */  /* 301 TV */
54860 +       { 0x52,0x6a, 27}, /* 0x3b */  /* 301 TV */
54861 +       { 0x62,0x24, 70}, /* 0x3c */  /* 301 TV */
54862 +       { 0x62,0x64, 70}, /* 0x3d */  /* 301 TV */
54863 +       { 0xa8,0x4c, 30}, /* 0x3e */  /* 301 TV */
54864 +       { 0x20,0x26, 33}, /* 0x3f */  /* 301 TV */
54865         { 0x31,0xc2, 39}, /* 0x40 */
54866 -       { 0x2e,0x48, 25}, /* 0x41 */
54867 -       { 0x24,0x46, 25}, /* 0x42 */
54868 -       { 0x26,0x64, 28}, /* 0x43 */
54869 -       { 0x37,0x64, 40}, /* 0x44 */
54870 -       { 0xa1,0x42,108}, /* 0x45 */
54871 -       { 0x37,0x61,100}, /* 0x46 */
54872 +       { 0x2e,0x48, 25}, /* 0x41 */  /* Replacement for LCD on 315 for index 0 */
54873 +       { 0x24,0x46, 25}, /* 0x42 */  /* Replacement for LCD on 315 for modes 0x01, 0x03, 0x0f, 0x10, 0x12 */
54874 +       { 0x26,0x64, 28}, /* 0x43 */  /* Replacement for LCD on 315 for index 1 */
54875 +       { 0x37,0x64, 40}, /* 0x44 */  /* Replacement for LCD on 315 for index 4 */
54876 +       { 0xa1,0x42,108}, /* 0x45 */  /* 1280x960 LCD */
54877 +       { 0x37,0x61,100}, /* 0x46 */  /* 1280x960 LCD */
54878         { 0x78,0x27,108}, /* 0x47 */
54879         { 0x97,0x2c, 26}, /* 0x48 */  /* UNUSED - Entries from here new, not in any BIOS */
54880         { 0xce,0x3c, 39}, /* 0x49 */  /* UNUSED */
54881 @@ -1211,72 +809,17 @@ static const SiS310_VBVCLKDataStruct SiS
54882         { 0xbf,0xc8, 35}, /* 0x57 */  /* 856x480-38i,60  */
54883         { 0x30,0x23, 88}, /* 0x58 */  /* 1360x768-62 (is 60Hz!) TEMP, UNUSED */
54884         { 0x52,0x07,149}, /* 0x59 */  /* 1280x960-85  - UNUSED */
54885 -       { 0x56,0x07,156}  /* 0x5a */  /* 1400x1050-75 - UNUSED */
54886 +       { 0x56,0x07,156}, /* 0x5a */  /* 1400x1050-75 - UNUSED */
54887 +       { 0x70,0x29, 81}  /* 0x5b */  /* 1280x768 LCD */
54888  };
54889  
54890  static const UCHAR SiS310_ScreenOffset[] = 
54891  {
54892          0x14,0x19,0x20,0x28,0x32,0x40,0x50,0x64,
54893 -       0x78,0x80,0x2d,0x35,0x57,0x48,0x55,
54894 +       0x78,0x80,0x2d,0x35,0x57,0x48,0x55,0x30,
54895         0xff
54896 -};      /* TW: Added 1400x1050, 1152x864, 848/856x480, 1360x768 */
54897 -
54898 -typedef struct _SiS310_StResInfoStruct
54899 -{
54900 -       USHORT HTotal;
54901 -       USHORT VTotal;
54902 -} SiS310_StResInfoStruct;
54903 -
54904 -static const SiS310_StResInfoStruct SiS310_StResInfo[]=
54905 -{
54906 -       { 640,400},
54907 -       { 640,350},
54908 -       { 720,400},
54909 -       { 720,350},
54910 -       { 640,480}
54911 -};
54912 -
54913 -typedef struct _SiS310_ModeResInfoStruct
54914 -{
54915 -       USHORT HTotal;
54916 -       USHORT VTotal;
54917 -       UCHAR  XChar;
54918 -       UCHAR  YChar;
54919 -} SiS310_ModeResInfoStruct;
54920 -
54921 -static const SiS310_ModeResInfoStruct SiS310_ModeResInfo[] =
54922 -{
54923 -       {  320, 200, 8, 8},   /* 0x00 */
54924 -       {  320, 240, 8, 8},   /* 0x01 */
54925 -       {  320, 400, 8, 8},   /* 0x02 */
54926 -       {  400, 300, 8, 8},   /* 0x03 */
54927 -       {  512, 384, 8, 8},   /* 0x04 */
54928 -       {  640, 400, 8,16},   /* 0x05 */
54929 -       {  640, 480, 8,16},   /* 0x06 */
54930 -       {  800, 600, 8,16},   /* 0x07 */
54931 -       { 1024, 768, 8,16},   /* 0x08 */
54932 -       { 1280,1024, 8,16},   /* 0x09 */
54933 -       { 1600,1200, 8,16},   /* 0x0a */
54934 -       { 1920,1440, 8,16},   /* 0x0b */
54935 -       { 2048,1536, 8,16},   /* 0x0c */
54936 -       {  720, 480, 8,16},   /* 0x0d */
54937 -       {  720, 576, 8,16},   /* 0x0e */
54938 -       { 1280, 960, 8,16},   /* 0x0f */
54939 -       {  800, 480, 8,16},   /* 0x10 */
54940 -       { 1024, 576, 8,16},   /* 0x11 */
54941 -       { 1280, 720, 8,16},   /* 0x12 */
54942 -       {  856, 480, 8,16},   /* 0x13 - TW: New, not in any BIOS */
54943 -       { 1280, 768, 8,16},   /* 0x14 20; TW: New */
54944 -       { 1400,1050, 8,16},   /* 0x15 21; TW: New */
54945 -       { 1152, 864, 8,16},   /* 0x16 - TW: New, not in any BIOS */
54946 -       {  848, 480, 8,16},   /* 0x17 - TW: New, not in any BIOS */
54947 -       { 1360, 768, 8,16}    /* 0x18 - TW: New, not in any BIOS */
54948  };
54949  
54950 -static const UCHAR SiS310_OutputSelect = 0x40;
54951 -
54952 -static const UCHAR SiS310_SoftSetting  = 0x30;   /* TW: RAM setting */
54953 -
54954  static const UCHAR SiS310_SR15[8][4]={
54955         {0x00,0x04,0x60,0x60},
54956         {0x0f,0x0f,0x0f,0x0f},
54957 @@ -1322,16 +865,6 @@ static const USHORT SiS310_VideoSenseDat
54958  static const USHORT SiS310_YCSenseData2    = 0x016b;
54959  #endif
54960  
54961 -static const UCHAR SiS310_NTSCPhase[]    = {0x21,0xed,0xba,0x08};  /* TW: Was {0x21,0xed,0x8a,0x08}; */
54962 -static const UCHAR SiS310_PALPhase[]     = {0x2a,0x05,0xe3,0x00};  /* TW: Was {0x2a,0x05,0xd3,0x00}; */
54963 -static const UCHAR SiS310_PALMPhase[]    = {0x21,0xE4,0x2E,0x9B};  /* TW: palm*/
54964 -static const UCHAR SiS310_PALNPhase[]    = {0x21,0xF4,0x3E,0xBA};  /* TW: paln*/
54965 -static const UCHAR SiS310_NTSCPhase2[]   = {0x21,0xF0,0x7B,0xD6};
54966 -static const UCHAR SiS310_PALPhase2[]    = {0x2a,0x09,0x86,0xe9};
54967 -static const UCHAR SiS310_PALMPhase2[]   = {0x21,0xE6,0xEF,0xA4};  /* TW: palm 301b*/
54968 -static const UCHAR SiS310_PALNPhase2[]   = {0x21,0xF6,0x94,0x46};  /* TW: paln 301b*/
54969 -static const UCHAR SiS310_SpecialPhase[] = {0x1e,0x8c,0x5c,0x7a};
54970 -
54971  typedef struct _SiS310_LCDDataStruct
54972  {
54973         USHORT RVBHCMAX;
54974 @@ -1353,25 +886,6 @@ static const SiS310_LCDDataStruct  SiS31
54975         {    1,   1,1344, 806,1344, 806}
54976  };
54977  
54978 -#if 0   /* Seems out-dated, all BIOSes since 03/27/2002 have the other version */
54979 -static const SiS310_LCDDataStruct  SiS310_ExtLCD1024x768Data[] = 
54980 -{
54981 -       {   12,   5, 896, 512,1344, 806},
54982 -       {   12,   5, 896, 510,1344, 806},
54983 -       {   32,  15,1008, 505,1344, 806},
54984 -       {   32,  15,1008, 514,1344, 806},
54985 -       {   12,   5, 896, 500,1344, 806},
54986 -       {   42,  25,1024, 625,1344, 806},
54987 -       {    1,   1,1344, 806,1344, 806},
54988 -       {   12,   5, 896, 500,1344, 806},
54989 -       {   42,  25,1024, 625,1344, 806},
54990 -       {    1,   1,1344, 806,1344, 806},
54991 -       {   12,   5, 896, 500,1344, 806},
54992 -       {   42,  25,1024, 625,1344, 806},
54993 -       {    1,   1,1344, 806,1344, 806}
54994 -};
54995 -#endif
54996 -
54997  static const SiS310_LCDDataStruct  SiS310_ExtLCD1024x768Data[] =   
54998  {
54999         {   42,  25,1536, 419,1344, 806},
55000 @@ -1413,7 +927,7 @@ static const SiS310_LCDDataStruct  SiS31
55001         {    1,   1,1688,1066,1688,1066}
55002  };
55003  
55004 -static const SiS310_LCDDataStruct  SiS310_ExtLCD1280x1024Data[] = 
55005 +static const SiS310_LCDDataStruct  SiS310_ExtLCD1280x1024Data[] =
55006  {
55007         {  211,  60,1024, 501,1688,1066},
55008         {  211,  60,1024, 508,1688,1066},
55009 @@ -1450,7 +964,7 @@ static const SiS310_LCDDataStruct  SiS31
55010         {    1,   1,1344, 806,1344, 806}
55011  };
55012  
55013 -static const SiS310_LCDDataStruct  SiS310_NoScaleData1280x1024[] =  
55014 +static const SiS310_LCDDataStruct  SiS310_NoScaleData1280x1024[] =
55015  {
55016          {    1,   1,1688,1066,1688,1066},
55017         {    1,   1,1688,1066,1688,1066},
55018 @@ -1463,272 +977,15 @@ static const SiS310_LCDDataStruct  SiS31
55019         {    1,   1,1688,1066,1688,1066}
55020  };
55021  
55022 -static const SiS310_LCDDataStruct  SiS310_LCD1280x960Data[] =
55023 -{
55024 -       {    9,   2, 800, 500,1800,1000},
55025 -       {    9,   2, 800, 500,1800,1000},
55026 -       {    4,   1, 900, 500,1800,1000},
55027 -       {    4,   1, 900, 500,1800,1000},
55028 -       {    9,   2, 800, 500,1800,1000},
55029 -       {   30,  11,1056, 625,1800,1000},
55030 -       {    5,   3,1350, 800,1800,1000},
55031 -       {    1,   1,1576,1050,1576,1050},
55032 -       {    1,   1,1800,1000,1800,1000}
55033 -};
55034 -
55035 -static const SiS310_LCDDataStruct  SiS310_StLCD1400x1050Data[] = 
55036 -{  /* TW: New from 1.11.6s */
55037 -       { 211,  100, 2100,  408, 1688, 1066 },
55038 -       { 211,   64, 1536,  358, 1688, 1066 },
55039 -       { 211,  100, 2100,  408, 1688, 1066 },
55040 -       { 211,   64, 1536,  358, 1688, 1066 },
55041 -       { 211,   48,  840,  488, 1688, 1066 },
55042 -       { 211,   72, 1008,  609, 1688, 1066 },
55043 -       { 211,  128, 1400,  776, 1688, 1066 },
55044 -       { 211,  205, 1680, 1041, 1688, 1066 },
55045 -       {   1,    1, 1688, 1066, 1688, 1066 }
55046 -};
55047 -
55048 -static const SiS310_LCDDataStruct  SiS310_ExtLCD1400x1050Data[] = 
55049 -{  /* TW: New from 1.11.6s */
55050 -       { 211,  100, 2100,  408, 1688, 1066 },
55051 -       { 211,   64, 1536,  358, 1688, 1066 },
55052 -       { 211,  100, 2100,  408, 1688, 1066 },
55053 -       { 211,   64, 1536,  358, 1688, 1066 },
55054 -       { 211,   48,  840,  488, 1688, 1066 },
55055 -       { 211,   72, 1008,  609, 1688, 1066 },
55056 -       { 211,  128, 1400,  776, 1688, 1066 },
55057 -       { 211,  205, 1680, 1041, 1688, 1066 },
55058 -       {   1,    1, 1688, 1066, 1688, 1066 }
55059 -};
55060 -
55061 -static const SiS310_LCDDataStruct  SiS310_NoScaleData1400x1050[] = 
55062 -{  /* TW: To be checked (BIOS uses 1280x1024 data, one line too short) */
55063 -       { 1, 1, 1688, 1066, 1688, 1066 },
55064 -       { 1, 1, 1688, 1066, 1688, 1066 },
55065 -       { 1, 1, 1688, 1066, 1688, 1066 },
55066 -       { 1, 1, 1688, 1066, 1688, 1066 },
55067 -       { 1, 1, 1688, 1066, 1688, 1066 },
55068 -       { 1, 1, 1688, 1066, 1688, 1066 },
55069 -       { 1, 1, 1688, 1066, 1688, 1066 },
55070 -       { 1, 1, 1688, 1066, 1688, 1066 },
55071 -       { 1, 1, 1688, 1066, 1688, 1066 }
55072 -};
55073 -
55074 -static const SiS310_LCDDataStruct  SiS310_StLCD1600x1200Data[] = 
55075 -{  /* TODO */
55076 -       {    0,   0,   0,   0,   0,   0}
55077 -};
55078 -
55079 -static const SiS310_LCDDataStruct  SiS310_ExtLCD1600x1200Data[] = 
55080 -{  /* TODO */
55081 -       {    0,   0,   0,   0,   0,   0}
55082 -};
55083 -
55084 -static const SiS310_LCDDataStruct  SiS310_NoScaleData1600x1200[] = 
55085 -{  /* TODO */
55086 -       {    0,   0,   0,   0,   0,   0}
55087 -};
55088 -
55089 -typedef struct _SiS310_TVDataStruct
55090 -{
55091 -       USHORT RVBHCMAX;
55092 -       USHORT RVBHCFACT;
55093 -       USHORT VGAHT;
55094 -       USHORT VGAVT;
55095 -       USHORT TVHDE;
55096 -       USHORT TVVDE;
55097 -       USHORT RVBHRS;
55098 -       UCHAR FlickerMode;
55099 -       USHORT HALFRVBHRS;
55100 -       UCHAR RY1COE;
55101 -       UCHAR RY2COE;
55102 -       UCHAR RY3COE;
55103 -       UCHAR RY4COE;
55104 -} SiS310_TVDataStruct;
55105 -
55106 -static const SiS310_TVDataStruct  SiS310_StPALData[]=
55107 -{
55108 - {    1,   1, 864, 525,1270, 400, 100,   0, 760,0xf4,0xff,0x1c,0x22},
55109 - {    1,   1, 864, 525,1270, 350, 100,   0, 760,0xf4,0xff,0x1c,0x22},
55110 - {    1,   1, 864, 525,1270, 400,   0,   0, 720,0xf1,0x04,0x1f,0x18},
55111 - {    1,   1, 864, 525,1270, 350,   0,   0, 720,0xf4,0x0b,0x1c,0x0a},
55112 - {    1,   1, 864, 525,1270, 480,  50,   0, 760,0xf4,0xff,0x1c,0x22},
55113 - {    1,   1, 864, 525,1270, 600,  50,   0,   0,0xf4,0xff,0x1c,0x22}
55114 -};
55115 -
55116 -static const SiS310_TVDataStruct  SiS310_ExtPALData[] =   
55117 -{
55118 - {   27,  10, 848, 448,1270, 530,  50,   0,  50,0xf4,0xff,0x1c,0x22},
55119 - {  108,  35, 848, 398,1270, 530,  50,   0,  50,0xf4,0xff,0x1c,0x22},
55120 - {   12,   5, 954, 448,1270, 530,  50,   0,  50,0xf1,0x04,0x1f,0x18},
55121 - {    9,   4, 960, 463,1644, 438,  50,   0,  50,0xf4,0x0b,0x1c,0x0a},
55122 - {    9,   4, 848, 528,1270, 530,   0,   0,  50,0xf5,0xfb,0x1b,0x2a},  /* 640x480 */
55123 - {   36,  25,1060, 648,1316, 530, 438,   0, 438,0xeb,0x05,0x25,0x16},  /* 800x600 */
55124 - {    3,   2,1080, 619,1270, 540, 438,   0, 438,0xf3,0x00,0x1d,0x20},  /* 720x480/576 */
55125 - {    1,   1,1170, 821,1270, 520, 686,   0, 686,0xF3,0x00,0x1D,0x20}   /* 1024x768 */
55126 -};
55127 -
55128 -static const SiS310_TVDataStruct  SiS310_StNTSCData[]=
55129 -{
55130 - {    1,   1, 858, 525,1270, 400,  50,   0, 760,0xf1,0x04,0x1f,0x18},
55131 - {    1,   1, 858, 525,1270, 350,  50,   0, 640,0xf1,0x04,0x1f,0x18},
55132 - {    1,   1, 858, 525,1270, 400,   0,   0, 720,0xf1,0x04,0x1f,0x18},
55133 - {    1,   1, 858, 525,1270, 350,   0,   0, 720,0xf4,0x0b,0x1c,0x0a},
55134 - {    1,   1, 858, 525,1270, 480,   0,   0, 760,0xf1,0x04,0x1f,0x18}
55135 -};
55136 -
55137 -static const SiS310_TVDataStruct  SiS310_ExtNTSCData[]=
55138 -{
55139 - {  143,  65, 858, 443,1270, 440, 171,   0, 171,0xf1,0x04,0x1f,0x18},
55140 - {   88,  35, 858, 393,1270, 440, 171,   0, 171,0xf1,0x04,0x1f,0x18},
55141 - {  143,  70, 924, 443,1270, 440,  92,   0,  92,0xf1,0x04,0x1f,0x18},
55142 - {  143,  70, 924, 393,1270, 440,  92,   0,  92,0xf4,0x0b,0x1c,0x0a},
55143 - {  143,  76, 836, 523,1270, 440, 224,   0,   0,0xf1,0x05,0x1f,0x16},  /* 640x480 */
55144 - {  143, 120,1056, 643,1270, 440,   0, 128,   0,0xf4,0x10,0x1c,0x00},  /* 800x600  */
55145 - {    2,   1, 858, 503,1270, 480,   0, 128,   0,0xee,0x0c,0x22,0x08},  /* 720x480/576 */
55146 - {   65,  64,1056, 791,1270, 480, 638,   0,   0,0xEE,0x0C,0x22,0x08}   /* 1024x768 */
55147 -};
55148 -
55149 -#if 0
55150 -static const SiS310_TVDataStruct  SiS310_St1HiTVData[]=
55151 -{
55152 -  
55153 -};
55154 -#endif
55155 -
55156 -static const SiS310_TVDataStruct  SiS310_St2HiTVData[]=
55157 -{
55158 - {    3,   1, 0x348,0x1e3,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},
55159 - {    1,   1, 0x37c,0x233,0x2b2,0x2bc,           0,  0, 0, 0x00,0x00,0x00,0x00},
55160 - {    3,   1, 0x348,0x1e3,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},
55161 - {    1,   1, 0x3e8,0x233,0x311,0x2bc,    0,  0, 0, 0x00,0x00,0x00,0x00},
55162 - {    5,   2, 0x348,0x233,0x670,0x3c0,0x08d,128, 0, 0x00,0x00,0x00,0x00},
55163 - {    8,   5, 0x41a,0x2ab,0x670,0x3c0,0x17c,128, 0, 0x00,0x00,0x00,0x00}
55164 -};
55165 -
55166 -static const SiS310_TVDataStruct  SiS310_ExtHiTVData[]=
55167 -{
55168 - {    6,   1, 0x348,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
55169 - {    3,   1, 0x3c0,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
55170 - {    3,   1, 0x348,0x1e3,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
55171 - {    3,   1, 0x3c0,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
55172 - {    5,   1, 0x348,0x233,0x670,0x3c0,0x166,128, 0, 0x00,0x00,0x00,0x00},
55173 - {   16,   5, 0x41a,0x2ab,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00},
55174 - {   25,  12, 0x4ec,0x353,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},
55175 - {    5,   4, 0x627,0x464,0x670,0x3c0,0x128,  0, 0, 0x00,0x00,0x00,0x00},
55176 - {    4,   1, 0x41a,0x233,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00},
55177 - {    5,   2, 0x578,0x293,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},
55178 - {    8,   5, 0x6d6,0x323,0x670,0x3c0,0x128,  0, 0, 0x00,0x00,0x00,0x00}
55179 -};
55180 -
55181 -static const UCHAR SiS310_NTSCTiming[] = { 
55182 -       0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c,
55183 -       0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a,
55184 -       0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b,
55185 -       0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17,
55186 -       0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02,
55187 -       0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40,
55188 -       0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x50,
55189 -       0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00
55190 -};
55191 -
55192 -static const UCHAR SiS310_PALTiming[] = {  
55193 -       0x19,0x52,0x35,0x6e,0x04,0x38,0x3d,0x70,
55194 -       0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d,
55195 -       0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b,
55196 -       0x70,0x50,0x00,0x9b,0x00,0xd9,0x5d,0x17,
55197 -       0x7d,0x05,0x45,0x00,0x00,0xe8,0x00,0x02,
55198 -       0x0d,0x00,0x68,0xb0,0x0b,0x92,0x8f,0x40,
55199 -       0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63,
55200 -       0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00
55201 -};
55202 -
55203 -static const UCHAR SiS310_HiTVExtTiming[] = {  
55204 -        0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64,
55205 -       0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
55206 -       0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
55207 -       0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13,
55208 -       0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40,
55209 -       0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40,
55210 -       0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d,
55211 -       0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00
55212 -};
55213 -
55214 -static const UCHAR SiS310_HiTVSt1Timing[] = {  
55215 -        0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65,
55216 -       0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
55217 -       0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
55218 -       0x65,0x90,0x7b,0xa8,0x03,0xf0,0x87,0x03,
55219 -       0x11,0x15,0x11,0xcf,0x10,0x11,0xcf,0x10,
55220 -       0x35,0x35,0x3b,0x69,0x1d,0x92,0x0f,0x40,
55221 -       0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x86,
55222 -       0xaf,0x5d,0x0e,0x00,0xfc,0xff,0x2d,0x00
55223 -};
55224 -
55225 -static const UCHAR SiS310_HiTVSt2Timing[] = {  
55226 -        0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64,
55227 -       0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
55228 -       0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
55229 -       0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13,
55230 -       0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40,
55231 -       0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40,
55232 -       0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d,
55233 -       0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00
55234 -};
55235 -
55236 -static const UCHAR SiS310_HiTVTextTiming[] = {  
55237 -        0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65,
55238 -       0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
55239 -       0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
55240 -       0x65,0x90,0xe7,0xbc,0x03,0x0c,0x97,0x03,
55241 -       0x14,0x78,0x14,0x08,0x20,0x14,0x08,0x20,
55242 -       0xc8,0xc8,0x3b,0xd2,0x26,0x92,0x0f,0x40,
55243 -        0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x96,
55244 -       0x72,0x5c,0x11,0x00,0xfc,0xff,0x32,0x00
55245 -};
55246 -
55247 -static const UCHAR SiS310_HiTVGroup3Data[] = {  
55248 -        0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f,
55249 -       0x05,0x21,0xb2,0xb2,0x55,0x77,0x2a,0xa6,
55250 -       0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
55251 -       0x8c,0x6e,0x60,0x2e,0x58,0x48,0x72,0x44,
55252 -       0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
55253 -       0x4f,0x7f,0x03,0xa8,0x7d,0x20,0x1a,0xa9,
55254 -       0x14,0x05,0x03,0x7e,0x64,0x31,0x14,0x75,
55255 -       0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
55256 -};
55257 -
55258 -static const UCHAR SiS310_HiTVGroup3Simu[] = {  
55259 -        0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x95,
55260 -       0xdb,0x20,0xb8,0xb8,0x55,0x47,0x2a,0xa6,
55261 -       0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
55262 -       0x8c,0x6e,0x60,0x15,0x26,0xd3,0xe4,0x11,
55263 -       0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
55264 -       0x67,0x36,0x01,0x47,0x0e,0x10,0xbe,0xb4,
55265 -       0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75,
55266 -       0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
55267 -};
55268 -
55269 -static const UCHAR SiS310_HiTVGroup3Text[] = {  
55270 -        0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0xa7,
55271 -       0xf5,0x20,0xce,0xce,0x55,0x47,0x2a,0xa6,
55272 -       0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
55273 -       0x8c,0x6e,0x60,0x18,0x2c,0x0c,0x20,0x22,
55274 -       0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
55275 -       0x93,0x3c,0x01,0x50,0x2f,0x10,0xf4,0xca,
55276 -       0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75,
55277 -       0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
55278 -};
55279  
55280  typedef struct _SiS310_PanelDelayTblStruct
55281  {
55282         UCHAR timer[2];
55283  } SiS310_PanelDelayTblStruct;
55284  
55285 -static const SiS310_PanelDelayTblStruct SiS310_PanelDelayTbl[]=  
55286 +static const SiS310_PanelDelayTblStruct SiS310_PanelDelayTbl[]=
55287  {
55288 -        {{0x10,0x40}},         /* TW: from 650/301LVx 1.10.6s BIOS */
55289 +        {{0x10,0x40}},
55290         {{0x10,0x40}},
55291         {{0x10,0x40}},
55292         {{0x10,0x40}},
55293 @@ -1744,24 +1001,6 @@ static const SiS310_PanelDelayTblStruct 
55294         {{0x10,0x40}},
55295         {{0x10,0x40}},
55296         {{0x10,0x40}}
55297 -#if 0
55298 -       {{0x28,0xc8}},          /* TW: from 650/301LV BIOS */
55299 -       {{0x28,0xc8}},
55300 -       {{0x28,0xc8}},
55301 -       {{0x28,0xc8}},
55302 -       {{0x28,0xc8}},
55303 -       {{0x28,0xc8}},
55304 -       {{0x28,0xc8}},
55305 -       {{0x28,0xc8}},
55306 -       {{0x28,0xc8}},
55307 -       {{0x28,0xc8}},
55308 -       {{0x28,0xc8}},
55309 -       {{0x28,0xc8}},
55310 -       {{0x28,0xc8}},
55311 -       {{0x28,0xc8}},
55312 -       {{0x28,0xc8}},
55313 -       {{0x28,0xc8}}
55314 -#endif
55315  };
55316  
55317  static const SiS310_PanelDelayTblStruct SiS310_PanelDelayTblLVDS[]=
55318 @@ -1792,363 +1031,7 @@ typedef struct _SiS310_LVDSDataStruct
55319         USHORT LCDVT;
55320  } SiS310_LVDSDataStruct;
55321  
55322 -static const SiS310_LVDSDataStruct  SiS310_LVDS320x480Data_1[]=
55323 -{
55324 -       { 848, 433, 400, 525},
55325 -       { 848, 389, 400, 525},
55326 -       { 848, 433, 400, 525},
55327 -       { 848, 389, 400, 525},
55328 -       { 848, 518, 400, 525},
55329 -       {1056, 628, 400, 525},
55330 -       { 400, 525, 400, 525},
55331 -       { 800, 449,1000, 644},
55332 -       { 800, 525,1000, 635}
55333 -};
55334 -
55335 -static const SiS310_LVDSDataStruct  SiS310_LVDS800x600Data_1[]= 
55336 -{
55337 -       { 848, 433,1060, 629},
55338 -       { 848, 389,1060, 629},
55339 -       { 848, 433,1060, 629},
55340 -       { 848, 389,1060, 629},
55341 -       { 848, 518,1060, 629},
55342 -       {1056, 628,1056, 628},
55343 -       {1056, 628,1056, 628},
55344 -       { 800, 449,1000, 644},
55345 -       { 800, 525,1000, 635}
55346 -};
55347 -
55348 -static const SiS310_LVDSDataStruct  SiS310_LVDS800x600Data_2[]=  
55349 -{
55350 -       {1056, 628,1056, 628},
55351 -       {1056, 628,1056, 628},
55352 -       {1056, 628,1056, 628},
55353 -       {1056, 628,1056, 628},
55354 -       {1056, 628,1056, 628},
55355 -       {1056, 628,1056, 628},
55356 -       {1056, 628,1056, 628},
55357 -       { 800, 449,1000, 644},
55358 -       { 800, 525,1000, 635}
55359 -};
55360 -
55361 -static const SiS310_LVDSDataStruct  SiS310_LVDS1024x768Data_1[]=  
55362 -{
55363 -       { 840, 438,1344, 806},
55364 -       { 840, 409,1344, 806},
55365 -       { 840, 438,1344, 806},
55366 -       { 840, 409,1344, 806},
55367 -       { 840, 518,1344, 806},   /* 640x480 */
55368 -       {1050, 638,1344, 806},   /* 800x600 */
55369 -       {1344, 806,1344, 806},   /* 1024x768 */
55370 -       { 800, 449,1280, 801},
55371 -       { 800, 525,1280, 813}
55372 -};
55373 -
55374 -static const SiS310_LVDSDataStruct  SiS310_LVDS1024x768Data_2[]= 
55375 -{
55376 -       {1344, 806,1344, 806},
55377 -       {1344, 806,1344, 806},
55378 -       {1344, 806,1344, 806},
55379 -       {1344, 806,1344, 806},
55380 -       {1344, 806,1344, 806},
55381 -       {1344, 806,1344, 806},
55382 -       {1344, 806,1344, 806},
55383 -       { 800, 449,1280, 801},
55384 -       { 800, 525,1280, 813}
55385 -};
55386 -
55387 -static const SiS310_LVDSDataStruct  SiS310_LVDS1280x1024Data_1[]=  
55388 -{      
55389 -       {1048, 442,1688,1066},
55390 -       {1048, 392,1688,1066},
55391 -       {1048, 442,1688,1066},
55392 -       {1048, 392,1688,1066},
55393 -       {1048, 522,1688,1066},
55394 -       {1208, 642,1688,1066},
55395 -       {1432, 810,1688,1066},
55396 -       {1688,1066,1688,1066}
55397 -};
55398 -
55399 -static const SiS310_LVDSDataStruct  SiS310_LVDS1280x1024Data_2[]=  
55400 -{      
55401 -       {1688,1066,1688,1066},
55402 -       {1688,1066,1688,1066},
55403 -       {1688,1066,1688,1066},
55404 -       {1688,1066,1688,1066},
55405 -       {1688,1066,1688,1066},
55406 -       {1688,1066,1688,1066},
55407 -       {1688,1066,1688,1066},
55408 -       {1688,1066,1688,1066}
55409 -};
55410 -
55411 -static const SiS310_LVDSDataStruct  SiS310_LVDS1400x1050Data_1[]=  
55412 -{
55413 -        { 928, 416, 1688,1066},
55414 -       { 928, 366, 1688,1066},
55415 -       { 928, 416, 1688,1066},
55416 -       { 928, 366, 1688,1066},
55417 -       { 928, 496, 1688,1066},
55418 -       {1088, 616, 1688,1066},
55419 -       {1312, 784, 1688,1066},
55420 -       {1568,1040, 1688,1066},
55421 -       {1688,1066, 1688,1066}
55422 -};
55423 -
55424 -static const SiS310_LVDSDataStruct  SiS310_LVDS1400x1050Data_2[]= 
55425 -{
55426 -        {1688,1066, 1688,1066},
55427 -       {1688,1066, 1688,1066},
55428 -       {1688,1066, 1688,1066},
55429 -       {1688,1066, 1688,1066},
55430 -       {1688,1066, 1688,1066},
55431 -       {1688,1066, 1688,1066},
55432 -       {1688,1066, 1688,1066},
55433 -       {1688,1066, 1688,1066},
55434 -       {1688,1066, 1688,1066},
55435 -};
55436 -
55437 -static const SiS310_LVDSDataStruct  SiS310_LVDS1600x1200Data_1[]=  
55438 -{
55439 -        {1088, 450, 2048,1250},
55440 -       {1088, 400, 2048,1250},
55441 -       {1088, 450, 2048,1250},
55442 -       {1088, 400, 2048,1250},
55443 -       {1088, 530, 2048,1250},
55444 -       {1248, 650, 2048,1250},
55445 -       {1472, 818, 2048,1250},
55446 -       {1728,1066, 2048,1250},
55447 -       {1848,1066, 2048,1250},
55448 -       {2048,1250, 2048,1250}
55449 -};
55450 -
55451 -static const SiS310_LVDSDataStruct  SiS310_LVDS1600x1200Data_2[]= 
55452 -{
55453 -        {2048,1250, 2048,1250},
55454 -       {2048,1250, 2048,1250},
55455 -       {2048,1250, 2048,1250},
55456 -       {2048,1250, 2048,1250},
55457 -       {2048,1250, 2048,1250},
55458 -       {2048,1250, 2048,1250},
55459 -       {2048,1250, 2048,1250},
55460 -       {2048,1250, 2048,1250},
55461 -       {2048,1250, 2048,1250},
55462 -       {2048,1250, 2048,1250}
55463 -};
55464 -
55465 -static const SiS310_LVDSDataStruct  SiS310_LVDS1280x768Data_1[]= 
55466 -{      
55467 -       { 768, 438, 1408, 806},
55468 -       { 768, 388, 1408, 806},
55469 -       { 768, 438, 1408, 806},
55470 -       { 768, 388, 1408, 806},
55471 -       { 768, 518, 1408, 806},
55472 -       { 928, 638, 1408, 806},
55473 -       {1152, 806, 1408, 806},
55474 -       {1408, 806, 1408, 806},
55475 -       {1408, 806, 1408, 806}
55476 -};
55477 -
55478 -static const SiS310_LVDSDataStruct  SiS310_LVDS1280x768Data_2[]=  
55479 -{      
55480 -       {1408, 806, 1408, 806},
55481 -       {1408, 806, 1408, 806},
55482 -       {1408, 806, 1408, 806},
55483 -       {1408, 806, 1408, 806},
55484 -       {1408, 806, 1408, 806},
55485 -       {1408, 806, 1408, 806},
55486 -       {1408, 806, 1408, 806},
55487 -       {1408, 806, 1408, 806},
55488 -       {1408, 806, 1408, 806}
55489 -};
55490 -
55491 -static const SiS310_LVDSDataStruct  SiS310_LVDS1024x600Data_1[]=
55492 -{
55493 -       { 840, 604, 1344, 800},
55494 -       { 840, 560, 1344, 800},
55495 -       { 840, 604, 1344, 800},
55496 -       { 840, 560, 1344, 800},
55497 -       { 840, 689, 1344, 800},
55498 -       {1050, 800, 1344, 800},
55499 -       {1344, 800, 1344, 800},
55500 -       { 800, 449, 1280, 801},
55501 -       { 800, 525, 1280, 813}
55502 -};
55503 -
55504 -static const SiS310_LVDSDataStruct  SiS310_LVDS1024x600Data_2[]=
55505 -{
55506 -       {1344, 800, 1344, 800},
55507 -       {1344, 800, 1344, 800},
55508 -       {1344, 800, 1344, 800},
55509 -       {1344, 800, 1344, 800},
55510 -       {1344, 800, 1344, 800},
55511 -       {1344, 800, 1344, 800},
55512 -       {1344, 800, 1344, 800},
55513 -       { 800, 449, 1280, 801},
55514 -       { 800, 525, 1280, 813}
55515 -};
55516 -
55517 -static const SiS310_LVDSDataStruct  SiS310_LVDS1152x768Data_1[]=
55518 -{
55519 -       { 840, 438, 1344, 806},
55520 -       { 840, 409, 1344, 806},
55521 -       { 840, 438, 1344, 806},
55522 -       { 840, 409, 1344, 806},
55523 -       { 840, 518, 1344, 806},
55524 -       {1050, 638, 1344, 806},
55525 -       {1344, 806, 1344, 806},
55526 -       { 800, 449, 1280, 801},
55527 -       { 800, 525, 1280, 813}
55528 -};
55529 -
55530 -static const SiS310_LVDSDataStruct  SiS310_LVDS1152x768Data_2[]=
55531 -{
55532 -       {1344, 806, 1344, 806},
55533 -       {1344, 806, 1344, 806},
55534 -       {1344, 806, 1344, 806},
55535 -       {1344, 806, 1344, 806},
55536 -       {1344, 806, 1344, 806},
55537 -       {1344, 806, 1344, 806},
55538 -       {1344, 806, 1344, 806},
55539 -       { 800, 449, 1280, 801},
55540 -       { 800, 525, 1280, 813}
55541 -};
55542 -
55543 -/* TW: Pass 1:1 data */
55544 -static const SiS310_LVDSDataStruct  SiS310_LVDSXXXxXXXData_1[]=  
55545 -{
55546 -        { 800, 449,  800, 449},
55547 -       { 800, 449,  800, 449},
55548 -       { 900, 449,  900, 449},
55549 -       { 900, 449,  900, 449},
55550 -       { 800, 525,  800, 525},  /*  640x480   */
55551 -       {1056, 628, 1056, 628},  /*  800x600   */
55552 -       {1344, 806, 1344, 806},  /* 1024x768   */
55553 -       {1344,1066, 1344,1066},  /* 1280x1024  */  /* INSERTED ! */
55554 -       {1688, 806, 1688, 806},  /* 1280x768 ! */
55555 -       /* No other panels ! */
55556 -};
55557 -
55558 -static const SiS310_LVDSDataStruct  SiS310_LVDS640x480Data_1[]=  
55559 -{
55560 -       { 800, 449, 800, 449},
55561 -       { 800, 449, 800, 449},
55562 -       { 800, 449, 800, 449},
55563 -       { 800, 449, 800, 449},
55564 -       { 800, 525, 800, 525},
55565 -       {1056, 628,1056, 628},
55566 -       {1056, 628,1056, 628},
55567 -       {1056, 628,1056, 628},
55568 -       {1056, 628,1056, 628}
55569 -};
55570 -
55571 -static const SiS310_LVDSDataStruct  SiS310_LVDS1280x960Data_1[]=   
55572 -{
55573 -       { 840, 438,1344, 806},
55574 -       { 840, 409,1344, 806},
55575 -       { 840, 438,1344, 806},
55576 -       { 840, 409,1344, 806},
55577 -       { 840, 518,1344, 806},
55578 -       {1050, 638,1344, 806},
55579 -       {1344, 806,1344, 806},
55580 -       { 800, 449,1280, 801},
55581 -       { 800, 525,1280, 813}
55582 -};
55583 -
55584 -static const SiS310_LVDSDataStruct  SiS310_LVDS1280x960Data_2[]=  
55585 -{
55586 -       {1344, 806,1344, 806},
55587 -       {1344, 806,1344, 806},
55588 -       {1344, 806,1344, 806},
55589 -       {1344, 806,1344, 806},
55590 -       {1344, 806,1344, 806},
55591 -       {1344, 806,1344, 806},
55592 -       {1344, 806,1344, 806},
55593 -       { 800, 449,1280, 801},
55594 -       { 800, 525,1280, 813}
55595 -};
55596 -
55597 -/* LCDA */
55598 -
55599 -static const SiS310_LVDSDataStruct  SiS310_LCDA1400x1050Data_1[]=   
55600 -{      /* TW: Might be temporary (invalid) data */
55601 -        { 928, 416, 1688,1066},
55602 -       { 928, 366, 1688,1066},
55603 -       {1008, 416, 1688,1066},
55604 -       {1008, 366, 1688,1066},
55605 -       {1200, 530, 1688,1066},
55606 -       {1088, 616, 1688,1066},
55607 -       {1312, 784, 1688,1066},
55608 -       {1568,1040, 1688,1066},
55609 -       {1688,1066, 1688,1066}
55610 -};
55611 -
55612 -static const SiS310_LVDSDataStruct  SiS310_LCDA1400x1050Data_2[]=   
55613 -{      /* TW: Temporary data. Not valid */
55614 -       {1344, 806,1344, 806},
55615 -       {1344, 806,1344, 806},
55616 -       {1344, 806,1344, 806},
55617 -       {1344, 806,1344, 806},
55618 -       {1344, 806,1344, 806},
55619 -       {1344, 806,1344, 806},
55620 -       {1344, 806,1344, 806},
55621 -       { 800, 449,1280, 801},
55622 -       { 800, 525,1280, 813}
55623 -};
55624 -
55625 -static const SiS310_LVDSDataStruct  SiS310_LCDA1600x1200Data_1[]=  
55626 -{      /* TW: Temporary data. Not valid */
55627 -       {1344, 806,1344, 806},
55628 -       {1344, 806,1344, 806},
55629 -       {1344, 806,1344, 806},
55630 -       {1344, 806,1344, 806},
55631 -       {1344, 806,1344, 806},
55632 -       {1344, 806,1344, 806},
55633 -       {1344, 806,1344, 806},
55634 -       { 800, 449,1280, 801},
55635 -       { 800, 525,1280, 813}
55636 -};
55637 -
55638 -static const SiS310_LVDSDataStruct  SiS310_LCDA1600x1200Data_2[]=  
55639 -{      /* TW: Temporary data. Not valid */
55640 -       {0, 0, 0, 0},
55641 -       {0, 0, 0, 0},
55642 -       {0, 0, 0, 0},
55643 -       {0, 0, 0, 0},
55644 -       {0, 0, 0, 0},
55645 -       {0, 0, 0, 0},
55646 -       {0, 0, 0, 0},
55647 -       {0, 0, 0, 0},
55648 -       {0, 0, 0, 0},
55649 -       {0, 0, 0, 0},
55650 -       {0, 0, 0, 0},
55651 -       {0, 0, 0, 0}
55652 -};
55653 -
55654 -/* Chrontel TV */
55655 -
55656 -static const SiS310_LVDSDataStruct  SiS310_CHTVUNTSCData[]=   
55657 -{
55658 -       { 840, 600, 840, 600},
55659 -       { 840, 600, 840, 600},
55660 -       { 840, 600, 840, 600},
55661 -       { 840, 600, 840, 600},
55662 -       { 784, 600, 784, 600},
55663 -       {1064, 750,1064, 750},
55664 -        {1160, 945,1160, 945}           /* TW: For Ch7019 1024 */
55665 -};
55666 -
55667 -static const SiS310_LVDSDataStruct  SiS310_CHTVONTSCData[]=   
55668 -{
55669 -       { 840, 525, 840, 525},
55670 -       { 840, 525, 840, 525},
55671 -       { 840, 525, 840, 525},
55672 -       { 840, 525, 840, 525},
55673 -       { 784, 525, 784, 525},
55674 -       {1040, 700,1040, 700},
55675 -        {1160, 840,1160, 840}                  /* TW: For Ch7019 1024 */
55676 -};
55677 -
55678 -static const SiS310_LVDSDataStruct  SiS310_CHTVUPALData[]=   
55679 +static const SiS310_LVDSDataStruct  SiS310_CHTVUPALData[]=
55680  {
55681         {1008, 625,1008, 625},
55682         {1008, 625,1008, 625},
55683 @@ -2156,7 +1039,7 @@ static const SiS310_LVDSDataStruct  SiS3
55684         {1008, 625,1008, 625},
55685         { 840, 625, 840, 625},
55686         { 960, 750, 960, 750},
55687 -       {1400,1000,1400,1000}           /*  TW: For Ch7019 1024 */
55688 +       {1400,1000,1400,1000}
55689  };
55690  
55691  static const SiS310_LVDSDataStruct  SiS310_CHTVOPALData[]= 
55692 @@ -2167,7 +1050,7 @@ static const SiS310_LVDSDataStruct  SiS3
55693         {1008, 625,1008, 625},
55694         { 840, 625, 840, 625},
55695         { 944, 625, 944, 625},
55696 -        {1400, 875,1400, 875}          /*  TW: For Ch7019 1024 */
55697 +        {1400, 875,1400, 875}
55698  };
55699  
55700  static const SiS310_LVDSDataStruct  SiS310_CHTVUPALMData[]=  
55701 @@ -2178,7 +1061,7 @@ static const SiS310_LVDSDataStruct  SiS3
55702         { 840, 600, 840, 600},
55703         { 784, 600, 784, 600},
55704         {1064, 750,1064, 750},
55705 -        {1160, 945,1160, 945}           /* TW: For Ch7019 1024 */
55706 +        {1160, 945,1160, 945}
55707  };
55708  
55709  static const SiS310_LVDSDataStruct  SiS310_CHTVOPALMData[]=  
55710 @@ -2189,7 +1072,7 @@ static const SiS310_LVDSDataStruct  SiS3
55711         { 840, 525, 840, 525},
55712         { 784, 525, 784, 525},
55713         {1040, 700,1040, 700},
55714 -        {1160, 840,1160, 840}                  /* TW: For Ch7019 1024 */
55715 +        {1160, 840,1160, 840}
55716  };
55717  
55718  static const SiS310_LVDSDataStruct  SiS310_CHTVUPALNData[]=  
55719 @@ -2200,7 +1083,7 @@ static const SiS310_LVDSDataStruct  SiS3
55720         {1008, 625,1008, 625},
55721         { 840, 625, 840, 625},
55722         { 960, 750, 960, 750},
55723 -       {1400,1000,1400,1000}           /*  TW: For Ch7019 1024 */
55724 +       {1400,1000,1400,1000}
55725  };
55726  
55727  static const SiS310_LVDSDataStruct  SiS310_CHTVOPALNData[]= 
55728 @@ -2211,7 +1094,7 @@ static const SiS310_LVDSDataStruct  SiS3
55729         {1008, 625,1008, 625},
55730         { 840, 625, 840, 625},
55731         { 944, 625, 944, 625},
55732 -        {1400, 875,1400, 875}          /*  TW: For Ch7019 1024 */
55733 +        {1400, 875,1400, 875}
55734  };
55735  
55736  static const SiS310_LVDSDataStruct  SiS310_CHTVSOPALData[]=   /* TW: (super overscan - no effect on 7019) */
55737 @@ -2231,7 +1114,7 @@ typedef struct _SiS310_LVDSDesStruct
55738         USHORT LCDVDES;
55739  } SiS310_LVDSDesStruct;
55740  
55741 -static const SiS310_LVDSDesStruct  SiS310_PanelType00_1[]=  
55742 +static const SiS310_LVDSDesStruct  SiS310_PanelType00_1[]=  /* 800x600 */
55743  {
55744         { 0, 0},
55745         { 0, 0},
55746 @@ -2244,7 +1127,7 @@ static const SiS310_LVDSDesStruct  SiS31
55747         { 0, 0}
55748  };
55749  
55750 -static const SiS310_LVDSDesStruct  SiS310_PanelType01_1[]=   
55751 +static const SiS310_LVDSDesStruct  SiS310_PanelType01_1[]=  /* 1024x768 */
55752  {
55753         { 0, 0},
55754         { 0, 0},
55755 @@ -2257,7 +1140,7 @@ static const SiS310_LVDSDesStruct  SiS31
55756         { 0, 0}
55757  };
55758  
55759 -static const SiS310_LVDSDesStruct  SiS310_PanelType02_1[]=  
55760 +static const SiS310_LVDSDesStruct  SiS310_PanelType02_1[]=  /* 1280x1024 */
55761  {
55762         { 0, 0},
55763         { 0, 0},
55764 @@ -2382,33 +1265,31 @@ static const SiS310_LVDSDesStruct  SiS31
55765         { 0, 0}
55766  };
55767  
55768 -static const SiS310_LVDSDesStruct  SiS310_PanelType0b_1[]= 
55769 -{
55770 -       {1343, 798},
55771 -       {1343, 794},
55772 -       {1343, 798},
55773 -       {1343, 794},
55774 -       {1343,   0},
55775 -       {1343,   0},
55776 -       { 0, 805},
55777 -       { 0, 794},
55778 -       { 0,   0}
55779 -};
55780 -
55781 -static const SiS310_LVDSDesStruct  SiS310_PanelType0c_1[]=  
55782 +static const SiS310_LVDSDesStruct  SiS310_PanelType0b_1[]=  /* 640x480_2 */
55783  {
55784 -       {1343, 798},
55785 -       {1343, 794},
55786 -       {1343, 798},
55787 -       {1343, 794},
55788 -       {1343,   0},
55789 -       {1343,   0},
55790 -       { 0, 805},
55791 -       { 0, 794},
55792 -       { 0,   0}
55793 +       { 0, 524},
55794 +       { 0, 524},
55795 +       { 0, 524},
55796 +       { 0, 524},
55797 +       { 0, 524},
55798 +       { 0, 524},
55799 +       { 8, 524},
55800 +       { 0, 524}
55801 +};
55802 +
55803 +static const SiS310_LVDSDesStruct  SiS310_PanelType0c_1[]=  /* 640x480_3 */
55804 +{
55805 +       { 0, 524},
55806 +       { 0, 524},
55807 +       { 0, 524},
55808 +       { 0, 524},
55809 +       { 0, 524},
55810 +       { 0, 524},
55811 +       { 8, 524},
55812 +       { 0, 524}
55813  };
55814  
55815 -static const SiS310_LVDSDesStruct  SiS310_PanelType0d_1[]= 
55816 +static const SiS310_LVDSDesStruct  SiS310_PanelType0d_1[]=
55817  {
55818         {1343, 798},
55819         {1343, 794},
55820 @@ -2604,7 +1485,7 @@ static const SiS310_LVDSDesStruct  SiS31
55821         {   0,   0}
55822  };
55823  
55824 -static const SiS310_LVDSDesStruct  SiS310_PanelType0b_2[]=  
55825 +static const SiS310_LVDSDesStruct  SiS310_PanelType0b_2[]=  /* 640x480_2 */
55826  {
55827         {1152, 622},
55828         {1152, 597},
55829 @@ -2617,7 +1498,7 @@ static const SiS310_LVDSDesStruct  SiS31
55830         { 0,   0}
55831  };
55832  
55833 -static const SiS310_LVDSDesStruct  SiS310_PanelType0c_2[]= 
55834 +static const SiS310_LVDSDesStruct  SiS310_PanelType0c_2[]=  /* 640x480_3 */
55835  {
55836         {1152, 622},
55837         {1152, 597},
55838 @@ -2669,184 +1550,6 @@ static const SiS310_LVDSDesStruct  SiS31
55839         { 0,   0}
55840  };
55841  
55842 -static const SiS310_LVDSDesStruct  SiS310_PanelTypeNS_1[]= 
55843 -{
55844 -       { 8,   0},
55845 -       { 8,   0},
55846 -       { 8,   0},
55847 -       { 8,   0},
55848 -       { 8,   0},
55849 -       { 0,   0},
55850 -       { 0,   0},
55851 -       { 0,   0},
55852 -       { 0, 806},
55853 -       { 0, 0 }
55854 -};
55855 -
55856 -static const SiS310_LVDSDesStruct  SiS310_PanelTypeNS_2[] = 
55857 -{
55858 -       { 0 , 0},
55859 -       { 0 , 0},
55860 -       { 0 , 0},
55861 -       { 0 , 0},
55862 -       { 0 , 0},
55863 -       { 0 , 0},
55864 -       { 0 , 0},
55865 -       { 0 , 0},
55866 -       { 0 , 0},
55867 -       { 0 , 0}
55868 -};
55869 -
55870 -static const SiS310_LVDSDesStruct SiS310_PanelType1076_1[]=  
55871 -{  /* 1024x768 - Checked (1.10.6s) */
55872 -       { 0 , 0},
55873 -       { 0 , 0},
55874 -       { 0 , 0},
55875 -       { 0 , 0},
55876 -       { 0 , 0},
55877 -       { 0 , 0},
55878 -       { 0 , 0},
55879 -       { 0 , 0},
55880 -       { 0 , 0}
55881 -};
55882 -
55883 -static const SiS310_LVDSDesStruct SiS310_PanelType1076_2[]=  
55884 -{  /* 1024x768 - Checked (1.10.6s) */
55885 -       { 1184, 622 },
55886 -       { 1184, 597 },
55887 -       { 1184, 622 },
55888 -       { 1184, 597 },
55889 -       { 1152, 622 },
55890 -       { 1232, 722 },
55891 -       {    0, 0   },
55892 -       {    0, 794 },
55893 -       {    0, 0   }
55894 -};
55895 -
55896 -static const SiS310_LVDSDesStruct SiS310_PanelType1210_1[]=  
55897 -{  /* 1280x1024 - Checked (1.10.6s) */
55898 -       { 0 , 0},
55899 -       { 0 , 0},
55900 -       { 0 , 0},
55901 -       { 0 , 0},
55902 -       { 0 , 0},
55903 -       { 0 , 0},
55904 -       { 0 , 0},
55905 -       { 0 , 0},
55906 -       { 0 , 0}
55907 -};
55908 -
55909 -static const SiS310_LVDSDesStruct SiS310_PanelType1210_2[]=  
55910 -{  /* 1280x1024 - Checked (1.10.6s) */
55911 -       { 0 , 0},
55912 -       { 0 , 0},
55913 -       { 0 , 0},
55914 -       { 0 , 0},
55915 -       { 0 , 0},
55916 -       { 0 , 0},
55917 -       { 0 , 0},
55918 -       { 0 , 0},
55919 -       { 0 , 0}
55920 -};
55921 -
55922 -static const SiS310_LVDSDesStruct SiS310_PanelType1296_1[]=  
55923 -{  /* 1400x1050 - Checked (1.10.6s) */
55924 -       { 0 , 0},
55925 -       { 0 , 0},
55926 -       { 0 , 0},
55927 -       { 0 , 0},
55928 -       { 0 , 0},
55929 -       { 0 , 0},
55930 -       { 0 , 0},
55931 -       { 0 , 0},
55932 -       { 0 , 0}
55933 -};
55934 -
55935 -static const SiS310_LVDSDesStruct SiS310_PanelType1296_2[]=  
55936 -{  /* 1400x1050 - Checked (1.10.6s) - looks heavily invalid */
55937 -       { 808 , 740},
55938 -       { 0   , 715},
55939 -       { 632 , 740},
55940 -       { 632 , 715},
55941 -       { 1307, 780},
55942 -       { 1387,1157},
55943 -       { 1499, 924},
55944 -       { 1627,1052},
55945 -       { 0 , 0}
55946 -};
55947 -
55948 -static const SiS310_LVDSDesStruct SiS310_PanelType1600_1[]= 
55949 -{  /* 1600x1200 - Checked (1.10.6s) */
55950 -       { 0 , 0},
55951 -       { 0 , 0},
55952 -       { 0 , 0},
55953 -       { 0 , 0},
55954 -       { 0 , 0},
55955 -       { 0 , 0},
55956 -       { 0 , 0},
55957 -       { 0 , 0},
55958 -       { 0 , 0},
55959 -       { 0 , 0}
55960 -};
55961 -
55962 -static const SiS310_LVDSDesStruct SiS310_PanelType1600_2[]= 
55963 -{  /* 1600x1200 - Checked (1.10.6s) - looks heavily invalid, not copied */
55964 -       { 0 , 0},
55965 -       { 0 , 0},
55966 -       { 0 , 0},
55967 -       { 0 , 0},
55968 -       { 0 , 0},
55969 -       { 0 , 0},
55970 -       { 0 , 0},
55971 -       { 0 , 0},
55972 -       { 0 , 0},
55973 -       { 0 , 0}
55974 -};
55975 -
55976 -static const SiS310_LVDSDesStruct  SiS310_CHTVUNTSCDesData[]=
55977 -{
55978 -       { 0,   0},
55979 -       { 0,   0},
55980 -       { 0,   0},
55981 -       { 0,   0},
55982 -       { 0,   0},
55983 -       { 0,   0},
55984 -       { 0,   0}
55985 -};
55986 -
55987 -static const SiS310_LVDSDesStruct  SiS310_CHTVONTSCDesData[]=
55988 -{
55989 -       { 0,   0},
55990 -       { 0,   0},
55991 -       { 0,   0},
55992 -       { 0,   0},
55993 -       { 0,   0},
55994 -       { 0,   0},
55995 -       { 0,   0}
55996 -};
55997 -
55998 -static const SiS310_LVDSDesStruct  SiS310_CHTVUPALDesData[]=
55999 -{
56000 -       {256,   0},
56001 -       {256,   0},
56002 -       {256,   0},
56003 -       {256,   0},
56004 -       { 0,   0},
56005 -       { 0,   0},
56006 -       { 0,   0}
56007 -};
56008 -
56009 -static const SiS310_LVDSDesStruct  SiS310_CHTVOPALDesData[]=
56010 -{
56011 -       {256,   0},
56012 -       {256,   0},
56013 -       {256,   0},
56014 -       {256,   0},
56015 -       { 0,   0},
56016 -       { 0,   0},
56017 -       { 0,   0}
56018 -};
56019 -
56020  typedef struct _SiS310_Part2PortTblStruct
56021  {
56022         UCHAR CR[12];
56023 @@ -2866,16 +1569,15 @@ static const SiS310_Part2PortTblStruct S
56024  };
56025  
56026  static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_1[] =
56027 -{      /* TW: Temporary data, invalid */
56028 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56029 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56030 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56031 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56032 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56033 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56034 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56035 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56036 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}
56037 +{      /* TW: BIOS data invalid, last row taken from _3 */
56038 + {{0x25,0x12,0x51,0x6E,0x48,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}},
56039 + {{0x2C,0x12,0x38,0x55,0x2F,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}},
56040 + {{0x25,0x12,0x51,0x6E,0x48,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}},
56041 + {{0x2C,0x12,0x38,0x55,0x2F,0xC1,0x35,0xB1,0x47,0xE9,0x71,0x33}},
56042 + {{0x2D,0x12,0x79,0x96,0x70,0x99,0x35,0x89,0x47,0xC1,0x49,0x33}},
56043 + {{0x29,0x12,0xB5,0xD2,0xAC,0xE9,0x35,0xD9,0x47,0x11,0x99,0x33}},
56044 + {{0x36,0x13,0x02,0x25,0xFF,0x03,0x45,0x09,0x07,0xF9,0x00,0x24}},
56045 + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}
56046  };
56047  
56048  static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1400x1050_1[] =
56049 @@ -2892,16 +1594,17 @@ static const SiS310_Part2PortTblStruct S
56050  };
56051  
56052  static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_1[] =
56053 -{      /* TW: Temporary data, invalid */
56054 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56055 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56056 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56057 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56058 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56059 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56060 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56061 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56062 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}
56063 +{
56064 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56065 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56066 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56067 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56068 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56069 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56070 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56071 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56072 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56073 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}
56074  };
56075  
56076  static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_2[] =
56077 @@ -2912,7 +1615,8 @@ static const SiS310_Part2PortTblStruct S
56078   {{0x2c,0x12,0x38,0x55,0x2f,0xc1,0x35,0xb1,0x47,0xe9,0x71,0x33}},
56079   {{0x2d,0x12,0x79,0x96,0x70,0x99,0x35,0x89,0x47,0xc1,0x49,0x33}},
56080   {{0x29,0x12,0xb5,0xd2,0xac,0xe9,0x35,0xd9,0x47,0x11,0x99,0x33}},
56081 - {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}},
56082 + {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}},  /* old  */
56083 +/* 0x36,0x13,0x02,0x25,0xff,0x03,0x45,0x09,0x07,0xf9,0x00,0x24        new? */
56084   {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
56085   {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}
56086  };
56087 @@ -2944,21 +1648,23 @@ static const SiS310_Part2PortTblStruct S
56088  };
56089  
56090  static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_2[] =
56091 -{      /* TW: Temporary data, invalid */
56092 - {{0x2b,0x12,0xd9,0xe5,0xd5,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}},
56093 - {{0x22,0x12,0xc0,0xcc,0xbc,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}},
56094 - {{0x2b,0x12,0xd9,0xe5,0xd5,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}},
56095 - {{0x22,0x12,0xc0,0xcc,0xbc,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}},
56096 - {{0x33,0x13,0x01,0x0d,0xfd,0x2c,0x23,0x98,0x27,0x3e,0x08,0x42}},
56097 - {{0x3f,0x1b,0x3d,0x49,0x39,0x54,0x23,0xc0,0x27,0x66,0x30,0x42}},
56098 - {{0x33,0x1b,0x91,0x9d,0x8d,0x8c,0x23,0xf8,0x27,0x9e,0x68,0x42}},
56099 - {{0x43,0x24,0x11,0x1d,0x0d,0xcc,0x23,0x38,0x37,0xde,0xa8,0x42}},
56100 - {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}}
56101 +{
56102 + {{0x32,0x1B,0x2C,0x52,0x20,0x80,0x20,0x52,0x30,0xA3,0x3A,0x02}},
56103 + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
56104 + {{0x32,0x1B,0x2C,0x52,0x20,0x80,0x20,0x52,0x30,0xA3,0x3A,0x02}},
56105 + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
56106 + {{0x3A,0x1B,0x54,0x7A,0x48,0x80,0x24,0x52,0x30,0xA3,0x3A,0x02}},
56107 + {{0x36,0x1B,0x90,0xB6,0x84,0xA8,0x24,0x7A,0x30,0xCB,0x62,0x02}},
56108 + {{0x3A,0x1C,0xE4,0x0A,0xD8,0xE0,0x24,0xB2,0x30,0x03,0x9A,0x02}},
56109 + {{0x4A,0x24,0x64,0x8A,0x58,0x20,0x34,0xF2,0x30,0x43,0xDA,0x52}},
56110 + {{0x47,0x24,0x71,0x97,0x65,0x3E,0x34,0x10,0x40,0x61,0xF8,0x02}},
56111 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}
56112  };
56113  
56114  
56115  static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1024x768_3[] =
56116  {      /* TW: Data from 650/301LVx 1.10.6s */
56117 +#if 0
56118   {{0x25,0x13,0xc9,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}},
56119   {{0x2c,0x13,0x9a,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}},
56120   {{0x25,0x13,0xc9,0x24,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}},
56121 @@ -2968,56 +1674,56 @@ static const SiS310_Part2PortTblStruct S
56122   {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}},
56123   {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
56124   {{0x25,0x13,0xc9,0x25,0xff,0xf9,0x45,0x09,0x07,0xf9,0x09,0x24}}
56125 -#if 0  /* TW: Data from 650/301LV */
56126 - {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}},
56127 - {{0x2c,0x12,0x9a,0xae,0x88,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}},
56128 - {{0x25,0x12,0xc9,0xdc,0xb6,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}},
56129 - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
56130 - {{0x38,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}},
56131 - {{0x38,0x18,0x16,0x00,0x00,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}},
56132 - {{0x36,0x13,0x13,0x25,0xff,0x59,0x45,0x09,0x07,0xf9,0x09,0x24}},
56133 - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}
56134 -#endif
56135 +#endif /* Data from my 301LV */
56136 + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}},   /* @@@@@ TEST */
56137 + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}},
56138 + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}},
56139 + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}},
56140 + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}},
56141 + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}},
56142 + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}},
56143 + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}},
56144 + {{0x36,0x13,0x02,0x25,0xff,0x21,0x45,0x09,0x07,0x88,0x09,0x24}}
56145  };
56146  
56147  /*   1     2    4    5    6   1c   1d   1f   20   21   23   25   */
56148  static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1280x1024_3[] =
56149 -{      /* TW: Temporary data, invalid */
56150 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56151 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56152 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56153 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56154 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56155 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56156 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56157 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56158 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}
56159 +{
56160 + {{0x31,0x1B,0xC4,0xDA,0xB0,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}},
56161 + {{0x34,0x1B,0x9F,0xC0,0x80,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}},
56162 + {{0x3E,0x1B,0xCF,0xF0,0xB0,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}},
56163 + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}},
56164 + {{0x48,0x1C,0x15,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}},
56165 + {{0x48,0x1C,0x15,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}},
56166 + {{0x48,0x1C,0x15,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}},
56167 + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}
56168  };
56169  
56170  static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1400x1050_3[] =
56171  {      
56172 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56173 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56174 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56175 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56176 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56177 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56178 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56179 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56180 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}
56181 + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56182 + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56183 + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56184 + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56185 + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56186 + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56187 + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56188 + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56189 + {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}
56190  };
56191  
56192  static const SiS310_Part2PortTblStruct SiS310_CRT2Part2_1600x1200_3[] =
56193 -{      /* TW: Temporary data, invalid */
56194 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56195 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56196 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56197 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x42}},
56198 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56199 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56200 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56201 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}},
56202 -  {{0x43,0x24,0x21,0x29,0x19,0xea,0x23,0x0a,0x07,0x32,0xc6,0x32}}
56203 +{
56204 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56205 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56206 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56207 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56208 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56209 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56210 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56211 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56212 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}},
56213 + {{0x4C,0x24,0xC8,0xE1,0xAF,0x70,0x34,0x0A,0x07,0xFC,0x2A,0x53}}
56214  };
56215  
56216  typedef struct _SiS310_LCDACRT1DataStruct
56217 @@ -3054,7 +1760,7 @@ static const SiS310_LCDACRT1DataStruct  
56218  };
56219  
56220  static const SiS310_LCDACRT1DataStruct  SiS310_LCDACRT11024x768_1[]=
56221 -{  /* TW: Checked (1.10.6s) */
56222 +{
56223   {{0x73,0x4f,0x4f,0x97,0x55,0x86,0xc4,0x1f,
56224     0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x05,
56225     0x00}},
56226 @@ -3079,7 +1785,7 @@ static const SiS310_LCDACRT1DataStruct  
56227  };
56228  
56229  static const SiS310_LCDACRT1DataStruct  SiS310_LCDACRT11280x1024_1[]=
56230 -{  /* Checked (1.10.6s) */
56231 +{
56232   {{0x7e,0x4f,0x4f,0x82,0x58,0x06,0xb8,0x1f,
56233     0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x06,
56234     0x00}},
56235 @@ -3107,7 +1813,7 @@ static const SiS310_LCDACRT1DataStruct  
56236  };
56237  
56238  static const SiS310_LCDACRT1DataStruct  SiS310_LCDACRT11400x1050_1[]=
56239 -{    /* Checked (1.10.6s) */
56240 +{
56241   {{0x6f,0x4f,0x4f,0x93,0x54,0x82,0x9e,0x1f,
56242     0x93,0x86,0x8f,0x8f,0x9f,0x30,0x00,0x05,
56243     0x00}},
56244 @@ -3200,7 +1906,7 @@ static const SiS310_LCDACRT1DataStruct  
56245  };
56246  
56247  static const SiS310_LCDACRT1DataStruct  SiS310_LCDACRT11024x768_1_H[]=
56248 -{  /* TW: Checked (1.10.6s) */
56249 +{
56250   {{0x4b,0x27,0x27,0x8f,0x2b,0x03,0xc4,0x1f,
56251     0x92,0x89,0x8f,0x8f,0xb5,0x30,0x00,0x44,
56252     0x00}},
56253 @@ -3225,7 +1931,7 @@ static const SiS310_LCDACRT1DataStruct  
56254  };
56255  
56256  static const SiS310_LCDACRT1DataStruct  SiS310_LCDACRT11280x1024_1_H[]=
56257 -{   /* Checked (1.10.6s) */
56258 +{
56259   {{0x56,0x27,0x27,0x9a,0x30,0x1e,0xb8,0x1f,
56260     0x90,0x84,0x8f,0x8f,0xb9,0x30,0x00,0x05,
56261     0x00}},
56262 @@ -3250,7 +1956,7 @@ static const SiS310_LCDACRT1DataStruct  
56263  };
56264  
56265  static const SiS310_LCDACRT1DataStruct  SiS310_LCDACRT11400x1050_1_H[]=
56266 -{   /* Checked (1.10.6s) */
56267 +{
56268    {{0x47,0x27,0x27,0x8b,0x2c,0x1a,0x9e,0x1f,
56269      0x93,0x86,0x8f,0x8f,0x9f,0x30,0x00,0x05,
56270      0x00}},
56271 @@ -3343,7 +2049,7 @@ static const SiS310_LCDACRT1DataStruct  
56272  };
56273  
56274  static const SiS310_LCDACRT1DataStruct  SiS310_LCDACRT11024x768_2[]=
56275 -{   /* Checked (1.10.6s) */
56276 +{
56277   {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
56278     0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06,
56279     0x00}},
56280 @@ -3368,7 +2074,7 @@ static const SiS310_LCDACRT1DataStruct  
56281  };
56282  
56283  static const SiS310_LCDACRT1DataStruct  SiS310_LCDACRT11280x1024_2[]=
56284 -{   /* Checked (1.10.6s) */
56285 +{
56286   {{0xa3,0x4f,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
56287     0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x06,
56288     0x00}},
56289 @@ -3393,7 +2099,7 @@ static const SiS310_LCDACRT1DataStruct  
56290  };
56291  
56292  static const SiS310_LCDACRT1DataStruct  SiS310_LCDACRT11400x1050_2[]=
56293 -{    /* Checked (1.10.6s) */
56294 +{
56295   {{0xce,0x4f,0x4f,0x92,0x8c,0x1a,0x28,0x9a,
56296     0xdb,0x8f,0x8f,0x8f,0x29,0x21,0x00,0x03,
56297     0x00}},
56298 @@ -3486,7 +2192,7 @@ static const SiS310_LCDACRT1DataStruct  
56299  };
56300  
56301  static const SiS310_LCDACRT1DataStruct  SiS310_LCDACRT11024x768_2_H[]=
56302 -{   /* Checked (1.10.6s) */
56303 +{
56304   {{0x4f,0x27,0x27,0x93,0x39,0x01,0x24,0xbb,
56305     0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01,
56306     0x00 }},
56307 @@ -3511,7 +2217,7 @@ static const SiS310_LCDACRT1DataStruct  
56308  };
56309  
56310  static const SiS310_LCDACRT1DataStruct  SiS310_LCDACRT11280x1024_2_H[]=
56311 -{   /* Checked (1.10.6s) */
56312 +{
56313   {{0x4f,0x27,0x27,0x93,0x39,0x81,0x24,0xbb,
56314     0x4a,0x80,0x8f,0x8f,0x25,0x30,0x00,0x01,
56315     0x00 }},
56316 @@ -3536,7 +2242,7 @@ static const SiS310_LCDACRT1DataStruct  
56317  };
56318  
56319  static const SiS310_LCDACRT1DataStruct  SiS310_LCDACRT11400x1050_2_H[]=
56320 -{  /* Checked (1.10.6s) */
56321 +{
56322   {{0xa6,0x27,0x27,0x8a,0x64,0x92,0x28,0x9a,
56323     0xdb,0x8f,0x8f,0x8f,0x29,0x21,0x00,0x06,
56324     0x00}},
56325 @@ -3605,32 +2311,7 @@ typedef struct _SiS310_LVDSCRT1DataStruc
56326         UCHAR CR[15];
56327  } SiS310_LVDSCRT1DataStruct;
56328  
56329 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT1320x480_1[] =
56330 -{
56331 - {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f,
56332 -   0x90,0x85,0x8f,0xab,0x30,0x00,0x05,
56333 -   0x00 }},
56334 - {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
56335 -   0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
56336 -   0x00 }},
56337 - {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f,
56338 -   0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
56339 -   0x00 }},
56340 - {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
56341 -   0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
56342 -   0x00 }},
56343 - {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e,
56344 -   0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05,
56345 -   0x00 }},
56346 - {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
56347 -   0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
56348 -   0x01 }},
56349 - {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
56350 -   0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
56351 -   0x00 }}
56352 -};
56353 -
56354 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT1800x600_1[] =   
56355 +static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT1800x600_1[] =
56356  {
56357   {{0x6b,0x4f,0x8f,0x55,0x85,0xaa,0x1f,
56358     0x90,0x85,0x8f,0xab,0x30,0x00,0x05,
56359 @@ -3924,63 +2605,7 @@ static const SiS310_LVDSCRT1DataStruct  
56360     0x01}}
56361  };
56362  
56363 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT1XXXxXXX_1[] =  
56364 -{
56365 - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f,
56366 -   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05,
56367 -   0x00}},
56368 - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f,
56369 -   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05,
56370 -   0x00}},
56371 - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f,
56372 -   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05,
56373 -   0x00}},
56374 - {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f,
56375 -   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05,
56376 -   0x00}},
56377 - {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
56378 -   0xe9,0x8b,0xe7,0x04,0x00,0x00,0x05,
56379 -   0x00}},
56380 - {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
56381 -   0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
56382 -   0x01}},
56383 - {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
56384 -   0x02,0x88,0xff,0x25,0x10,0x00,0x02,
56385 -   0x01}},
56386 - {{0xce,0x9f,0x92,0xa8,0x14,0x28,0x5a,
56387 -   0x00,0x84,0xff,0x29,0x09,0x00,0x07,
56388 -   0x01}},
56389 - {{0xce,0x9f,0x92,0xa9,0x17,0x24,0xf5,
56390 -   0x02,0x88,0xff,0x25,0x10,0x00,0x07,
56391 -   0x01}}
56392 -};
56393 -
56394 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT1XXXxXXX_1_H[] = 
56395 -{
56396 - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f,
56397 -   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00,
56398 -   0x00}},
56399 - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f,
56400 -   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00,
56401 -   0x00}},
56402 - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f,
56403 -   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00,
56404 -   0x00}},
56405 - {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f,
56406 -   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00,
56407 -   0x00}},
56408 - {{0x38,0x27,0x9c,0x2c,0x80,0x0b,0x3e,
56409 -   0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
56410 -   0x00}},
56411 - {{0x4d,0x31,0x91,0x3b,0x03,0x72,0xf0,
56412 -   0x58,0x8c,0x57,0x73,0x20,0x00,0x01,
56413 -   0x01}},
56414 - {{0x63,0x3f,0x87,0x4a,0x92,0x24,0xf5,
56415 -   0x02,0x88,0xff,0x25,0x10,0x00,0x01,
56416 -   0x01}}
56417 -};
56418 -
56419 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11400x1050_1[] =  
56420 +static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11400x1050_1[] =
56421  {
56422    {{0x6f,0x4f,0x93,0x54,0x82,0x9e,0x1f,
56423      0x8f,0x81,0x8f,0x9f,0x30,0x00,0x05,
56424 @@ -4220,332 +2845,8 @@ static const SiS310_LVDSCRT1DataStruct  
56425  #endif   
56426  };
56427  
56428 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11280x768_1[] =  
56429 -{      
56430 - {{0x5b,0x4f,0x9f,0x55,0x19,0xb4,0x1f,
56431 -   0x9c,0x8e,0x8f,0xb5,0x10,0x00,0x01,
56432 -   0x00}},
56433 - {{0x5b,0x4f,0x9f,0x55,0x19,0x82,0x1f,
56434 -   0x6a,0x8c,0x5d,0x83,0x30,0x00,0x01,
56435 -   0x00}},
56436 - {{0x5b,0x4f,0x9f,0x55,0x19,0xb4,0x1f,
56437 -   0x9c,0x8e,0x8f,0xb5,0x10,0x00,0x01,
56438 -   0x00}},
56439 - {{0x5b,0x4f,0x9f,0x55,0x19,0x82,0x1f,
56440 -   0x6a,0x8c,0x5d,0x83,0x30,0x00,0x01,
56441 -   0x00}},
56442 - {{0x5b,0x4f,0x9f,0x55,0x19,0x04,0x3e,
56443 -   0xec,0x8e,0xdf,0x05,0x20,0x00,0x01,
56444 -   0x00}},
56445 - {{0x6f,0x63,0x93,0x69,0x8d,0x7c,0xf0,
56446 -   0x64,0x86,0x57,0x7d,0x20,0x00,0x05,
56447 -   0x01}},
56448 - {{0x8b,0x7f,0x8f,0x85,0x09,0x24,0xf5,
56449 -   0x0c,0x8e,0xff,0x25,0x30,0x00,0x02,
56450 -   0x01}},
56451 - {{0xab,0x9f,0x8f,0xa5,0x89,0x24,0xf5,
56452 -   0x0c,0x8e,0xff,0x25,0x30,0x00,0x06,
56453 -   0x01}},
56454 - {{0xab,0x9f,0x8f,0xa5,0x89,0x24,0xf5,
56455 -   0x0c,0x8e,0xff,0x25,0x30,0x00,0x06,
56456 -   0x01}}
56457 -};
56458 -
56459 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11280x768_1_H[] = 
56460 -{
56461 - {{0x47,0x27,0x8b,0x2c,0x1a,0x9e,0x1f,
56462 -   0x93,0x86,0x8f,0x9f,0x30,0x00,0x05,
56463 -   0x00}},
56464 - {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f,
56465 -   0x60,0x84,0x5d,0x6d,0x10,0x00,0x05,
56466 -   0x00}},
56467 - {{0x47,0x27,0x8b,0x30,0x1e,0x9e,0x1f,
56468 -   0x92,0x86,0x8f,0x9f,0x30,0x00,0x05,
56469 -   0x00}},
56470 - {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f,
56471 -   0x60,0x84,0x5d,0x6d,0x10,0x00,0x05,
56472 -   0x00}},
56473 - {{0x47,0x27,0x8b,0x2c,0x1a,0xee,0x1f,
56474 -   0xe2,0x86,0xdf,0xef,0x10,0x00,0x05,
56475 -   0x00}},
56476 - {{0x51,0x31,0x95,0x36,0x04,0x66,0xf0,
56477 -   0x5a,0x8e,0x57,0x67,0x20,0x00,0x01,
56478 -   0x01}},
56479 - {{0x5f,0x3f,0x83,0x44,0x92,0x0e,0xf5,
56480 -   0x02,0x86,0xff,0x0f,0x10,0x00,0x01,
56481 -   0x01}},
56482 - {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a,
56483 -   0x02,0x86,0xff,0x0f,0x09,0x00,0x05,
56484 -   0x01}},
56485 - {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a,
56486 -   0x02,0x86,0xff,0x0f,0x09,0x00,0x05,
56487 -   0x01}}
56488 -};
56489 -
56490 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11280x768_2[] = 
56491 +static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11600x1200_1[] =
56492  {
56493 - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb,
56494 -   0x54,0x86,0xdb,0xda,0x00,0x00,0x02,
56495 -   0x00}},
56496 - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb,
56497 -   0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x02,
56498 -   0x00}},
56499 - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb,
56500 -   0x54,0x86,0xdb,0xda,0x00,0x00,0x02,
56501 -   0x00}},
56502 - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb,
56503 -   0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x02,
56504 -   0x00}},
56505 - {{0xab,0x60,0x9f,0x80,0x04,0x24,0xb3,
56506 -   0x7c,0x8e,0x03,0x02,0x10,0x00,0x02,
56507 -   0x01}},
56508 - {{0xab,0x63,0x8f,0x8a,0x8e,0x24,0xf1,
56509 -   0xb6,0x88,0x57,0x25,0x10,0x00,0x02,
56510 -   0x01}},
56511 - {{0xab,0x7f,0x8f,0x98,0x9c,0x24,0xf5,
56512 -   0x0a,0x8c,0xff,0x25,0x30,0x00,0x02,
56513 -   0x01}},
56514 - {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5,
56515 -   0x0a,0x8c,0xff,0x25,0x30,0x00,0x06,
56516 -   0x01}},
56517 - {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5,
56518 -   0x0a,0x8c,0xff,0x25,0x30,0x00,0x06,
56519 -   0x01}}
56520 -};
56521 -
56522 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11280x768_2_H[] =
56523 -{
56524 - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb,
56525 -   0x54,0x86,0xdb,0xda,0x00,0x00,0x01,
56526 -   0x00}},
56527 - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb,
56528 -   0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x01,
56529 -   0x00}},
56530 - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb,
56531 -   0x54,0x86,0xdb,0xda,0x00,0x00,0x01,
56532 -   0x00}},
56533 - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb,
56534 -   0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x01,
56535 -   0x00}},
56536 - {{0x83,0x38,0x97,0x58,0x9c,0x24,0xb3,
56537 -   0x7c,0x8e,0x03,0x02,0x10,0x00,0x01,
56538 -   0x01}},
56539 - {{0x79,0x31,0x9d,0x58,0x9c,0x24,0xf1,
56540 -   0xb6,0x88,0x57,0x25,0x10,0x00,0x01,
56541 -   0x01}},
56542 - {{0x6b,0x3f,0x8f,0x58,0x9c,0x24,0xf5,
56543 -   0x0a,0x8c,0xff,0x25,0x30,0x00,0x01,
56544 -   0x01}},
56545 - {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5,
56546 -   0x0a,0x8c,0xff,0x25,0x30,0x00,0x06,
56547 -   0x01}},
56548 - {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5,
56549 -   0x0a,0x8c,0xff,0x25,0x30,0x00,0x06,
56550 -   0x01}}
56551 -};
56552 -
56553 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11024x600_1[] =
56554 -{
56555 -        {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e,
56556 -         0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01,
56557 -         0x00}},
56558 -        {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e,
56559 -         0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01,
56560 -         0x00}},
56561 -        {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e,
56562 -         0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01,
56563 -         0x00}},
56564 -        {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e,
56565 -         0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01,
56566 -         0x00}},
56567 -        {{0x64,0x4f,0x88,0x54,0x9f,0xaf,0xba,
56568 -         0x3b,0x82,0xdf,0xb0,0x00,0x00,0x01,
56569 -         0x00}},
56570 -        {{0x7e,0x63,0x82,0x68,0x15,0x1e,0xf1,
56571 -         0xae,0x85,0x57,0x1f,0x30,0x00,0x26,
56572 -         0x01}},
56573 -        {{0xa3,0x7f,0x87,0x86,0x97,0x1e,0xf1,
56574 -         0xae,0x85,0x57,0x1f,0x30,0x00,0x02,
56575 -         0x01}}
56576 -};
56577 -
56578 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11024x600_1_H[] =
56579 -{
56580 -        {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
56581 -         0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
56582 -         0x00}},
56583 -        {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
56584 -         0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
56585 -          0x00}},
56586 -        {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
56587 -         0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
56588 -         0x00}},
56589 -        {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
56590 -         0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
56591 -         0x00}},
56592 -        {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e,
56593 -         0xe2,0x89,0xdf,0x05,0x00,0x00,0x44,
56594 -         0x00}},
56595 -        {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0,
56596 -         0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55,
56597 -         0x01}},
56598 -        {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
56599 -         0x02,0x88,0xff,0x25,0x10,0x00,0x01,
56600 -         0x01}}
56601 -};
56602 -
56603 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11024x600_2[] =
56604 -{
56605 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
56606 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
56607 -         0x00}},
56608 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
56609 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
56610 -         0x00}},
56611 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
56612 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
56613 -         0x00}},
56614 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
56615 -          0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
56616 -         0x00}},
56617 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
56618 -         0x72,0x88,0xdf,0x25,0x30,0x00,0x06,
56619 -         0x00}},
56620 -        {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1,
56621 -         0xae,0x84,0x57,0x25,0x30,0x00,0x02,
56622 -         0x01}},
56623 -        {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
56624 -         0x02,0x88,0xff,0x25,0x10,0x00,0x02,
56625 -         0x01}}
56626 -};
56627 -
56628 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11024x600_2_H[] =
56629 -{
56630 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
56631 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
56632 -         0x00}},
56633 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
56634 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
56635 -         0x00}},
56636 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
56637 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
56638 -         0x00}},
56639 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
56640 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
56641 -         0x00}},
56642 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
56643 -         0x72,0x88,0xdf,0x25,0x30,0x00,0x01,
56644 -         0x00}},
56645 -        {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1,
56646 -         0xae,0x84,0x57,0x25,0x30,0x00,0x01,
56647 -         0x01}},
56648 -        {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
56649 -         0x02,0x88,0xff,0x25,0x10,0x00,0x01,
56650 -         0x01}}
56651 -};
56652 -
56653 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11152x768_1[] =
56654 -{
56655 -        {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f,
56656 -         0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
56657 -         0x00}},
56658 -        {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f,
56659 -         0x60,0x87,0x5d,0x83,0x10,0x00,0x01,
56660 -         0x00}},
56661 -        {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f,
56662 -         0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
56663 -         0x00}},
56664 -        {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f,
56665 -         0x60,0x87,0x5d,0x83,0x10,0x00,0x01,
56666 -         0x00}},
56667 -        {{0x64,0x4f,0x88,0x54,0x9f,0x04,0x3e,
56668 -         0xe2,0x89,0xdf,0x05,0x00,0x00,0x01,
56669 -         0x00}},
56670 -        {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0,
56671 -         0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26,
56672 -         0x01}},
56673 -        {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
56674 -         0x02,0x88,0xff,0x25,0x10,0x00,0x02,
56675 -         0x01}}
56676 -};
56677 -
56678 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11152x768_1_H[] =
56679 -{
56680 -        {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
56681 -         0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
56682 -         0x00}},
56683 -        {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
56684 -         0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
56685 -         0x00}},
56686 -        {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
56687 -         0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
56688 -         0x00}},
56689 -        {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
56690 -         0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
56691 -         0x00}},
56692 -        {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e,
56693 -         0xe2,0x89,0xdf,0x05,0x00,0x00,0x44,
56694 -         0x00}},
56695 -        {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0,
56696 -         0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55,
56697 -         0x01}},
56698 -        {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
56699 -         0x02,0x88,0xff,0x25,0x10,0x00,0x01,
56700 -         0x01}}
56701 -};
56702 -
56703 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11152x768_2[] =
56704 -{
56705 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
56706 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
56707 -         0x00}},
56708 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
56709 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
56710 -         0x00}},
56711 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
56712 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
56713 -         0x00}},
56714 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
56715 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
56716 -         0x00}},
56717 -        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
56718 -         0x72,0x88,0xdf,0x25,0x30,0x00,0x06,
56719 -         0x00}},
56720 -        {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1,
56721 -         0xae,0x84,0x57,0x25,0x30,0x00,0x02,
56722 -         0x01}},
56723 -        {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
56724 -         0x02,0x88,0xff,0x25,0x10,0x00,0x02,
56725 -         0x01}}
56726 -};
56727 -
56728 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11152x768_2_H[] =
56729 -{
56730 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
56731 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
56732 -         0x00}},
56733 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
56734 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
56735 -         0x00}},
56736 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
56737 -         0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
56738 -         0x00}},
56739 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
56740 -         0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
56741 -         0x00}},
56742 -        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
56743 -         0x72,0x88,0xdf,0x25,0x30,0x00,0x01,
56744 -         0x00}},
56745 -        {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1,
56746 -         0xae,0x84,0x57,0x25,0x30,0x00,0x01,
56747 -         0x01}},
56748 -        {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
56749 -         0x02,0x88,0xff,0x25,0x10,0x00,0x01,
56750 -         0x01}}
56751 -};
56752 -
56753 -static const SiS310_LVDSCRT1DataStruct  SiS310_LVDSCRT11600x1200_1[] =  
56754 -{    
56755   {{0x83,0x4f,0x87,0x51,0x09,0xc0,0x1f,
56756     0x90,0x84,0x8f,0xc1,0x30,0x00,0x06,
56757     0x00}},
56758 @@ -4701,7 +3002,7 @@ static const SiS310_LVDSCRT1DataStruct  
56759         {{0x80,0x63,0x84,0x6d,0x0f,0xec,0xf0,
56760           0x7a,0x8f,0x57,0xed,0x20,0x00,0x06,
56761           0x01 }},
56762 -       {{0x8c,0x7f,0x90,0x86,0x09,0xaf,0xf5,  /* TW: 1024x768 */
56763 +       {{0x8c,0x7f,0x90,0x86,0x09,0xaf,0xf5,
56764           0x36,0x88,0xff,0xb0,0x10,0x00,0x02,
56765           0x01}}
56766  };
56767 @@ -4726,7 +3027,7 @@ static const SiS310_LVDSCRT1DataStruct  
56768         {{0x7d,0x63,0x81,0x68,0x0e,0xba,0xf0,
56769           0x78,0x8a,0x57,0xbb,0x20,0x00,0x06,
56770           0x01 }},
56771 -       {{0x8c,0x7f,0x90,0x82,0x06,0x46,0xf5,   /* TW: 1024x768 */
56772 +       {{0x8c,0x7f,0x90,0x82,0x06,0x46,0xf5,
56773           0x15,0x88,0xff,0x47,0x70,0x00,0x02,
56774           0x01 }}
56775  };
56776 @@ -4751,7 +3052,7 @@ static const SiS310_LVDSCRT1DataStruct  
56777         {{0x73,0x63,0x97,0x69,0x8b,0xec,0xf0,
56778           0x90,0x8c,0x57,0xed,0x20,0x00,0x05,
56779           0x01 }},
56780 -       {{0xaa,0x7f,0x8e,0x8e,0x96,0xe6,0xf5,   /* TW: 1024x768 */
56781 +       {{0xaa,0x7f,0x8e,0x8e,0x96,0xe6,0xf5,
56782           0x50,0x88,0xff,0xe7,0x10,0x00,0x02,
56783           0x01}}
56784  };
56785 @@ -4776,7 +3077,7 @@ static const SiS310_LVDSCRT1DataStruct  
56786         {{0x71,0x63,0x95,0x69,0x8c,0x6f,0xf0,
56787           0x5a,0x8b,0x57,0x70,0x20,0x00,0x05,
56788           0x01 }},
56789 -       {{0xaa,0x7f,0x8e,0x8f,0x96,0x69,0xf5,   /* TW:  1024x768 */
56790 +       {{0xaa,0x7f,0x8e,0x8f,0x96,0x69,0xf5,
56791           0x28,0x88,0xff,0x6a,0x10,0x00,0x02,
56792           0x01 }}
56793  };
56794 @@ -4801,12 +3102,11 @@ static const SiS310_LVDSCRT1DataStruct  
56795         {{0x71,0x63,0x95,0x69,0x8c,0x6f,0xf0,
56796           0x5a,0x8b,0x57,0x70,0x20,0x00,0x05,
56797           0x01 }},
56798 -       {{0xaa,0x7f,0x8e,0x8f,0x96,0x69,0xf5,   /* TW:  1024x768 */
56799 +       {{0xaa,0x7f,0x8e,0x8f,0x96,0x69,0xf5,
56800           0x28,0x88,0xff,0x6a,0x10,0x00,0x02,
56801           0x01 }}
56802  };
56803  
56804 -/* TW: Data for Chrontel 7019  */
56805  typedef struct _SiS310_CHTVRegDataStruct
56806  {
56807         UCHAR Reg[16];
56808 --- linux-2.6.0-test6/drivers/video/sis/init301.c       2003-07-13 21:44:34.000000000 -0700
56809 +++ 25/drivers/video/sis/init301.c      2003-10-05 00:34:22.000000000 -0700
56810 @@ -1,27 +1,16 @@
56811  /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.c,v 1.3 2002/22/04 01:16:16 dawes Exp $ */
56812  /*
56813 - * Mode switching code (CRT2 section) for SiS 300/540/630/730/315/550/650/740/330
56814 - * (Universal module for Linux kernel framebuffer, XFree86 4.x)
56815 + * Mode switching code (CRT2 section) for SiS 300/540/630/730/315/550/650/740/330/660
56816 + * (Universal module for Linux kernel framebuffer and XFree86 4.x)
56817   *
56818   * Assembler-To-C translation
56819   * Copyright 2002, 2003 by Thomas Winischhofer <thomas@winischhofer.net>
56820 - * Minor parts Copyright SiS, Inc.
56821 + * Formerly based on non-functional code-fragements by SiS, Inc.
56822   *
56823 - * Based on BIOS
56824 - *     1.10.07, 1.10a for 650/CH7019
56825 - *     1.11.21a for 740/CH7019
56826 - *     1.11.05 for 650/LVDS (w/o Chrontel)
56827 - *     1.07.1b, 1.10.6s, 1.11.6w, 1.11.7w, 1.11.8r for 650/301(B/LV), 650/302LV
56828 - *     2.04.50 (I) and 2.04.5c (II) for 630/301(B)
56829 - *     2.02.3b, 2.03.02, 2.04.2c, 2.04.5c, 2.07a and 2.08.b3 for 630/LVDS/LVDS+CH7005
56830 - *     2.04.5c, 2.04.6c for 730+LVDS+CH7005
56831 - *     1.09b for 315/301(B)
56832 - *     1.16.51 for 300+301LV (ECS A907)
56833 - *     1.01.03 for 330 (Xabre 400)
56834 + * If distributed as part of the linux kernel, the contents of this file
56835 + * is entirely covered by the GPL.
56836   *
56837 - * Known bugs:
56838 - *   1024x768 panel, expanding (CR37=1): Mode 640x480 does not work on SOME panels
56839 - *       therefore, we always do the scaling ourselves for now.
56840 + * Otherwise, the following terms apply:
56841   *
56842   * Permission to use, copy, modify, distribute, and sell this software and its
56843   * documentation for any purpose is hereby granted without fee, provided that
56844 @@ -73,8 +62,8 @@
56845  #define SiS_I2CDELAYSHORT  150
56846  
56847  BOOLEAN
56848 -SiS_SetCRT2Group301(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
56849 -                    PSIS_HW_DEVICE_INFO HwDeviceExtension)
56850 +SiS_SetCRT2Group(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
56851 +                 PSIS_HW_DEVICE_INFO HwDeviceExtension)
56852  {
56853     USHORT ModeIdIndex;
56854     USHORT RefreshRateTableIndex;
56855 @@ -85,9 +74,9 @@ SiS_SetCRT2Group301(SiS_Private *SiS_Pr,
56856        SiS_SearchModeID(SiS_Pr,ROMAddr,&ModeNo,&ModeIdIndex);
56857     } else {
56858        ModeIdIndex = 0;
56859 -   }      
56860 +   }
56861  
56862 -   /* TW: Used for shifting CR33 */
56863 +   /* Used for shifting CR33 */
56864     SiS_Pr->SiS_SelectCRT2Rate = 4;
56865  
56866     SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr);
56867 @@ -110,8 +99,6 @@ SiS_SetCRT2Group301(SiS_Private *SiS_Pr,
56868        return(TRUE);
56869     }
56870  
56871 -   if(SiS_Pr->UseCustomMode) return(FALSE);
56872 -   
56873     SiS_GetCRT2Data(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
56874                     HwDeviceExtension);
56875  
56876 @@ -153,9 +140,9 @@ SiS_SetCRT2Group301(SiS_Private *SiS_Pr,
56877            SiS_SetGroup5(SiS_Pr,HwDeviceExtension, BaseAddr,ROMAddr,
56878                          ModeNo,ModeIdIndex);
56879  
56880 -          /* TW: For 301BDH (Panel link initialization): */
56881 +          /* For 301BDH (Panel link initialization): */
56882            if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
56883 -             if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) {   
56884 +             if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) {
56885                  if(!((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo = 0x10)))) {
56886                     if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
56887                        SiS_ModCRT1CRTC(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
56888 @@ -176,10 +163,10 @@ SiS_SetCRT2Group301(SiS_Private *SiS_Pr,
56889                               RefreshRateTableIndex,HwDeviceExtension);
56890            }
56891         }
56892 -        if(SiS_Pr->SiS_IF_DEF_FSTN == 0) {
56893 -          SiS_SetCRT2ECLK(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
56894 -                          RefreshRateTableIndex,HwDeviceExtension);
56895 -       }
56896 +
56897 +        SiS_SetCRT2ECLK(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
56898 +                       RefreshRateTableIndex,HwDeviceExtension);
56899 +
56900         if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) {
56901            if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
56902               if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
56903 @@ -199,74 +186,64 @@ SiS_SetCRT2Group301(SiS_Private *SiS_Pr,
56904     }
56905  
56906  #ifdef SIS300
56907 -   if ( (HwDeviceExtension->jChipType == SIS_540) ||
56908 -        (HwDeviceExtension->jChipType == SIS_630) ||
56909 -        (HwDeviceExtension->jChipType == SIS_730) ||
56910 -        (HwDeviceExtension->jChipType == SIS_300) )
56911 -    {
56912 -       if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) {
56913 -          if(SiS_Pr->SiS_UseOEM) {
56914 -             if((SiS_Pr->SiS_UseROM) && ROMAddr && (SiS_Pr->SiS_UseOEM == -1)) {
56915 -                if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
56916 -                   SiS_OEM300Setting(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo);
56917 -                }
56918 -             } else {
56919 -                        SiS_OEM300Setting(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo);
56920 -             }
56921 -          }
56922 -       }
56923 -    }
56924 -#endif
56925 -
56926 -#ifdef SIS315H
56927 -   if ( (HwDeviceExtension->jChipType == SIS_315H)  ||
56928 -        (HwDeviceExtension->jChipType == SIS_315)   ||
56929 -       (HwDeviceExtension->jChipType == SIS_315PRO)||
56930 -        (HwDeviceExtension->jChipType == SIS_550)   ||
56931 -        (HwDeviceExtension->jChipType == SIS_740)   ||
56932 -        (HwDeviceExtension->jChipType == SIS_650)   ||
56933 -       (HwDeviceExtension->jChipType == SIS_330) )
56934 -   {
56935 -        if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) {
56936 -          SiS_FinalizeLCD(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, HwDeviceExtension);
56937 -#if 0      /* Instead of FinalizeLCD(), older BIOSes (A92x) used OEMLCD() */
56938 -          SiS_OEMLCD(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
56939 -#endif
56940 -           if(SiS_Pr->SiS_UseOEM) {
56941 -              SiS_OEM310Setting(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
56942 -           }
56943 -           SiS_CRT2AutoThreshold(SiS_Pr,BaseAddr);
56944 -        }
56945 -   }
56946 -#endif
56947 -
56948     if(HwDeviceExtension->jChipType < SIS_315H) {
56949 +      if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) {
56950 +        if(SiS_Pr->SiS_UseOEM) {
56951 +           if((SiS_Pr->SiS_UseROM) && ROMAddr && (SiS_Pr->SiS_UseOEM == -1)) {
56952 +              if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
56953 +                 SiS_OEM300Setting(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,
56954 +                                   RefreshRateTableIndex);
56955 +              }
56956 +           } else {
56957 +                      SiS_OEM300Setting(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,
56958 +                                RefreshRateTableIndex);
56959 +           }
56960 +        }
56961 +        if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
56962 +            if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) ||
56963 +              (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) {
56964 +              SetOEMLCDData2(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,
56965 +                             ModeIdIndex,RefreshRateTableIndex);
56966 +           }
56967 +            if(HwDeviceExtension->jChipType == SIS_730) {
56968 +               SiS_DisplayOn(SiS_Pr);
56969 +           }
56970 +         }
56971 +      }
56972        if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
56973            if(HwDeviceExtension->jChipType != SIS_730) {
56974               SiS_DisplayOn(SiS_Pr);
56975           }
56976        }
56977     }
56978 +#endif
56979  
56980 -   if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) {
56981 -      if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
56982 -         if(HwDeviceExtension->jChipType == SIS_730) {
56983 -            SiS_DisplayOn(SiS_Pr);
56984 -        }
56985 +#ifdef SIS315H
56986 +   if(HwDeviceExtension->jChipType >= SIS_315H) {
56987 +      if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) {
56988 +        SiS_FinalizeLCD(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex, HwDeviceExtension);
56989 +         if(SiS_Pr->SiS_UseOEM) {
56990 +            SiS_OEM310Setting(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
56991 +         }
56992 +         SiS_CRT2AutoThreshold(SiS_Pr,BaseAddr);
56993        }
56994 +   }
56995 +#endif
56996 +
56997 +   if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) {
56998        SiS_EnableBridge(SiS_Pr,HwDeviceExtension,BaseAddr);
56999     }
57000  
57001     SiS_DisplayOn(SiS_Pr);
57002  
57003     if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
57004 -       if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
57005 -            /* TW: Disable LCD panel when using TV */
57006 -            SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x11,0x0C);
57007 -       } else {
57008 -            /* TW: Disable TV when using LCD */
57009 -            SiS_SetCH70xxANDOR(SiS_Pr,0x010E,0xF8);
57010 -       }
57011 +      if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
57012 +        /* Disable LCD panel when using TV */
57013 +        SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x11,0x0C);
57014 +      } else {
57015 +        /* Disable TV when using LCD */
57016 +        SiS_SetCH70xxANDOR(SiS_Pr,0x010E,0xF8);
57017 +      }
57018     }
57019  
57020     if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) {
57021 @@ -283,7 +260,7 @@ SiS_LowModeStuff(SiS_Private *SiS_Pr, US
57022      USHORT temp,temp1,temp2;
57023  
57024      if((ModeNo != 0x03) && (ModeNo != 0x10) && (ModeNo != 0x12))
57025 -         return(1);
57026 +       return(1);
57027      temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x11);
57028      SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x11,0x80);
57029      temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x00);
57030 @@ -304,7 +281,7 @@ SiS_LowModeStuff(SiS_Private *SiS_Pr, US
57031      }
57032  }
57033  
57034 -/* TW: Set Part1 registers */
57035 +/* Set Part1 registers */
57036  void
57037  SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
57038                USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension,
57039 @@ -313,31 +290,35 @@ SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT
57040    USHORT  temp=0, tempax=0, tempbx=0, tempcx=0;
57041    USHORT  pushbx=0, CRT1Index=0;
57042  #ifdef SIS315H
57043 -  USHORT  pushcx=0, tempbl=0;
57044 +  USHORT  tempbl=0;
57045  #endif
57046    USHORT  modeflag, resinfo=0;
57047  
57048 -  if(ModeNo<=0x13) {
57049 -       modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
57050 +  if(ModeNo <= 0x13) {
57051 +     modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
57052    } else {
57053 +     if(SiS_Pr->UseCustomMode) {
57054 +       modeflag = SiS_Pr->CModeFlag;
57055 +     } else {
57056         CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
57057         resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
57058         modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
57059 +     }
57060    }
57061  
57062    if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
57063 -
57064 -          SiS_SetCRT2Sync(SiS_Pr,BaseAddr,ROMAddr,ModeNo,
57065 -                           RefreshRateTableIndex,HwDeviceExtension);
57066  #ifdef SIS315H
57067 -          SiS_SetGroup1_LCDA(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,
57068 -                             HwDeviceExtension,RefreshRateTableIndex);
57069 +     SiS_SetCRT2Sync(SiS_Pr,BaseAddr,ROMAddr,ModeNo,
57070 +                     RefreshRateTableIndex,HwDeviceExtension);
57071 +
57072 +     SiS_SetGroup1_LCDA(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,
57073 +                        HwDeviceExtension,RefreshRateTableIndex);
57074  #endif
57075    } else {
57076  
57077       if( (HwDeviceExtension->jChipType >= SIS_315H) &&
57078           (SiS_Pr->SiS_IF_DEF_LVDS == 1) &&
57079 -        (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
57080 +        (SiS_Pr->SiS_VBInfo & SetInSlaveMode) ) {
57081  
57082          SiS_SetCRT2Sync(SiS_Pr,BaseAddr,ROMAddr,ModeNo,
57083                          RefreshRateTableIndex,HwDeviceExtension);
57084 @@ -367,13 +348,13 @@ SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT
57085  #ifdef SIS300   /* ------------- 300 series --------------*/
57086  
57087                 temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF;                         /* BTVGA2HT 0x08,0x09 */
57088 -               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,temp);                   /* TW: CRT2 Horizontal Total */
57089 +               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,temp);                   /* CRT2 Horizontal Total */
57090  
57091                 temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4;
57092 -               SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp);          /* TW: CRT2 Horizontal Total Overflow [7:4] */
57093 +               SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp);          /* CRT2 Horizontal Total Overflow [7:4] */
57094  
57095                 temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF;                       /* BTVGA2HDEE 0x0A,0x0C */
57096 -               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp);                   /* TW: CRT2 Horizontal Display Enable End */
57097 +               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp);                   /* CRT2 Horizontal Display Enable End */
57098  
57099                 pushbx = SiS_Pr->SiS_VGAHDE + 12;                               /* bx  BTVGA@HRS 0x0B,0x0C */
57100                 tempcx = (SiS_Pr->SiS_VGAHT - SiS_Pr->SiS_VGAHDE) >> 2;
57101 @@ -382,108 +363,129 @@ SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT
57102                 tempcx += tempbx;
57103  
57104                 if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
57105 -                       if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){
57106 -                               /* CRT1Index &= 0x3F; - Not any longer */
57107 -                               tempbx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[4];
57108 -                               tempbx |= ((SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14] & 0xC0) << 2);
57109 -                               tempbx = (tempbx - 1) << 3;
57110 -                               tempcx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5];
57111 -                               tempcx &= 0x1F;
57112 -                               temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15];
57113 -                               temp = (temp & 0x04) << (6-2);
57114 -                               tempcx = (tempcx | temp);
57115 -                               tempcx--;
57116 -                               tempcx <<= 3;
57117 -                       }
57118 -
57119 -                       if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == 0x08)){
57120 -                               if(!(SiS_Pr->SiS_VBInfo & SetPALTV)){
57121 -                                       tempbx = 1040;
57122 -                                       tempcx = 1042;
57123 -                               }
57124 -                       }
57125 +
57126 +                  if(SiS_Pr->UseCustomMode) {
57127 +                     tempbx = SiS_Pr->CHSyncStart + 12;
57128 +                     tempcx = SiS_Pr->CHSyncEnd + 12;
57129 +                  }
57130 +
57131 +                  if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
57132 +                     unsigned char cr4, cr14, cr5, cr15;
57133 +                     if(SiS_Pr->UseCustomMode) {
57134 +                        cr4  = SiS_Pr->CCRT1CRTC[4];
57135 +                        cr14 = SiS_Pr->CCRT1CRTC[14];
57136 +                        cr5  = SiS_Pr->CCRT1CRTC[5];
57137 +                        cr15 = SiS_Pr->CCRT1CRTC[15];
57138 +                     } else {
57139 +                        cr4  = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[4];
57140 +                        cr14 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14];
57141 +                        cr5  = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5];
57142 +                        cr15 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15];
57143 +                     }
57144 +                     tempbx = ((cr4 | ((cr14 & 0xC0) << 2)) - 1) << 3;
57145 +                     tempcx = (((cr5 & 0x1F) | ((cr15 & 0x04) << (6-2))) - 1) << 3;
57146 +                  }
57147 +
57148 +                  if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == SIS_RI_1024x768)){
57149 +                     if(!(SiS_Pr->SiS_VBInfo & SetPALTV)){
57150 +                        tempbx = 1040;
57151 +                        tempcx = 1042;
57152 +                     }
57153 +                  }
57154                 }
57155  
57156                 temp = tempbx & 0x00FF;
57157 -               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp);                   /* TW: CRT2 Horizontal Retrace Start */
57158 +               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp);                   /* CRT2 Horizontal Retrace Start */
57159  #endif /* SIS300 */
57160  
57161         } else {
57162  
57163 -#ifdef SIS315H  /* ----------------- 310/325/330 series ------------- */
57164 +#ifdef SIS315H  /* ------------------- 315/330 series --------------- */
57165  
57166                 tempcx = SiS_Pr->SiS_VGAHT;                                    /* BTVGA2HT 0x08,0x09 */
57167 -               pushcx = tempcx;
57168                 if(modeflag & HalfDCLK) {
57169 -#ifndef NEWCH701x              
57170 -                   if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_IF_DEF_CH70xx == 0)) {
57171 -#endif             
57172 +                   if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
57173                           tempax = SiS_Pr->SiS_VGAHDE >> 1;
57174                           tempcx = SiS_Pr->SiS_HT - SiS_Pr->SiS_HDE + tempax;
57175                           if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
57176                               tempcx = SiS_Pr->SiS_HT - tempax;
57177                           }
57178 -#ifndef NEWCH701x                                        
57179                     } else {
57180                           tempcx >>= 1;
57181                     }
57182 -#endif             
57183                 }
57184                 tempcx--;
57185  
57186                 temp = tempcx & 0xff;
57187 -               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,temp);                  /* TW: CRT2 Horizontal Total */
57188 +               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,temp);                  /* CRT2 Horizontal Total */
57189  
57190                 temp = ((tempcx & 0xff00) >> 8) << 4;
57191 -               SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0F,temp);         /* TW: CRT2 Horizontal Total Overflow [7:4] */
57192 +               SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0F,temp);         /* CRT2 Horizontal Total Overflow [7:4] */
57193  
57194 -               tempcx = pushcx;                                               /* BTVGA2HDEE 0x0A,0x0C */
57195 +               tempcx = SiS_Pr->SiS_VGAHT;                                    /* BTVGA2HDEE 0x0A,0x0C */
57196                 tempbx = SiS_Pr->SiS_VGAHDE;
57197                 tempcx -= tempbx;
57198                 tempcx >>= 2;
57199                 if(modeflag & HalfDCLK) {
57200 -                   tempbx >>= 1;
57201 -                   tempcx >>= 1;
57202 +                  tempbx >>= 1;
57203 +                  tempcx >>= 1;
57204                 }
57205                 tempbx += 16;
57206  
57207                 temp = tempbx & 0xff;
57208 -               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp);                  /* TW: CRT2 Horizontal Display Enable End */
57209 +               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp);                  /* CRT2 Horizontal Display Enable End */
57210  
57211                 pushbx = tempbx;
57212                 tempcx >>= 1;
57213                 tempbx += tempcx;
57214                 tempcx += tempbx;
57215  
57216 -               if(SiS_Pr->SiS_IF_DEF_LVDS==0) {
57217 +               if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
57218 +
57219 +                  if(SiS_Pr->UseCustomMode) {
57220 +                     tempbx = SiS_Pr->CHSyncStart + 16;
57221 +                     tempcx = SiS_Pr->CHSyncEnd + 16;
57222 +                     tempax = SiS_Pr->SiS_VGAHT;
57223 +                     if(modeflag & HalfDCLK) tempax >>= 1;
57224 +                     tempax--;
57225 +                     if(tempcx > tempax)  tempcx = tempax;
57226 +                  }
57227 +
57228                    if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
57229 -                       tempbx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[4];
57230 -                       tempbx |= ((SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14] & 0xC0) << 2);
57231 -                       tempbx = (tempbx - 3) << 3;                     /*(VGAHRS-3)*8 */
57232 -                       tempcx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5];
57233 -                               tempcx &= 0x1F;
57234 -                       temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15];
57235 -                       temp = (temp & 0x04) << (5-2);                  /* VGAHRE D[5] */
57236 -                       tempcx = (tempcx | temp);                       /* (VGAHRE-3)*8 */
57237 -                       tempcx -= 3;
57238 -                       tempcx <<= 3;
57239 -                       tempcx &= 0x00FF;
57240 -                       tempcx |= (tempbx & 0xFF00);
57241 -                       tempbx += 16;
57242 -                       tempcx += 16;
57243 -                       tempax = SiS_Pr->SiS_VGAHT;
57244 -                       if(modeflag & HalfDCLK)  tempax >>= 1;
57245 -                       tempax--;
57246 -                       if(tempcx > tempax)  tempcx = tempax;
57247 +                     unsigned char cr4, cr14, cr5, cr15;
57248 +                     if(SiS_Pr->UseCustomMode) {
57249 +                        cr4  = SiS_Pr->CCRT1CRTC[4];
57250 +                        cr14 = SiS_Pr->CCRT1CRTC[14];
57251 +                        cr5  = SiS_Pr->CCRT1CRTC[5];
57252 +                        cr15 = SiS_Pr->CCRT1CRTC[15];
57253 +                     } else {
57254 +                        cr4  = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[4];
57255 +                        cr14 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14];
57256 +                        cr5  = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5];
57257 +                        cr15 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15];
57258 +                     }
57259 +                      tempbx = ((cr4 | ((cr14 & 0xC0) << 2)) - 3) << 3;                /* (VGAHRS-3)*8 */
57260 +                      tempcx = (((cr5 & 0x1f) | ((cr15 & 0x04) << (5-2))) - 3) << 3;   /* (VGAHRE-3)*8 */
57261 +                     tempcx &= 0x00FF;
57262 +                     tempcx |= (tempbx & 0xFF00);
57263 +                      tempbx += 16;
57264 +                      tempcx += 16;
57265 +                     tempax = SiS_Pr->SiS_VGAHT;
57266 +                     if(modeflag & HalfDCLK) tempax >>= 1;
57267 +                     tempax--;
57268 +                     if(tempcx > tempax)  tempcx = tempax;
57269                    }
57270 -                  if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == 0x08)){
57271 -                     if(!(SiS_Pr->SiS_VBInfo & SetPALTV)){
57272 -                        tempbx = 1040;
57273 -                        tempcx = 1042;
57274 -                     }
57275 +                  if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
57276 +                     if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
57277 +                        if(resinfo == SIS_RI_1024x768) {
57278 +                           tempbx = 1040;
57279 +                           tempcx = 1042;
57280 +                        }
57281 +                     }
57282                    }
57283 -                  /* TW: Makes no sense, but is in 650/302LV 1.10.6s */
57284 -                  if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == 0x08)){
57285 +#if 0
57286 +                  /* Makes no sense, but is in 650/30xLV 1.10.6s */
57287 +                  if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (resinfo == SIS_RI_1024x768)){
57288                       if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) {
57289                          if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
57290                             tempbx = 1040;
57291 @@ -491,25 +493,26 @@ SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT
57292                          }
57293                       }
57294                    }
57295 +#endif
57296                  }
57297  
57298                 temp = tempbx & 0xff;
57299 -               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp);                 /* TW: CRT2 Horizontal Retrace Start */
57300 +               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp);                 /* CRT2 Horizontal Retrace Start */
57301  #endif  /* SIS315H */
57302  
57303 -       }  /* 310/325/330 series */
57304 +       }  /* 315/330 series */
57305  
57306 -       /* TW: The following is done for all bridge/chip types/series */
57307 +       /* The following is done for all bridge/chip types/series */
57308  
57309         tempax = tempbx & 0xFF00;
57310         tempbx = pushbx;
57311         tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
57312         tempax |= (tempbx & 0xFF00);
57313         temp = (tempax & 0xFF00) >> 8;
57314 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0C,temp);                        /* TW: Overflow */
57315 +       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0C,temp);                        /* Overflow */
57316  
57317         temp = tempcx & 0x00FF;
57318 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0D,temp);                        /* TW: CRT2 Horizontal Retrace End */
57319 +       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0D,temp);                        /* CRT2 Horizontal Retrace End */
57320  
57321         /* 2. Vertical setup */
57322  
57323 @@ -517,30 +520,30 @@ SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT
57324         temp = tempcx & 0x00FF;
57325  
57326          if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
57327 -            if(HwDeviceExtension->jChipType < SIS_315H) {
57328 -                 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
57329 -                      if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) {
57330 -                          temp--;
57331 -                      }
57332 -                  }
57333 -            } else {
57334 -                     temp--;
57335 -             }
57336 +          if(HwDeviceExtension->jChipType < SIS_315H) {
57337 +             if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
57338 +                if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) {
57339 +                   temp--;
57340 +                }
57341 +              }
57342 +          } else {
57343 +             temp--;
57344 +           }
57345          } else if(HwDeviceExtension->jChipType >= SIS_315H) {
57346 -           /* TW: 650/30xLV 1.10.6s */
57347 -           temp--;
57348 +          /* 650/30xLV 1.10.6s */
57349 +          temp--;
57350         }
57351 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0E,temp);                        /* TW: CRT2 Vertical Total */
57352 +       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0E,temp);                        /* CRT2 Vertical Total */
57353  
57354         tempbx = SiS_Pr->SiS_VGAVDE - 1;
57355         temp = tempbx & 0x00FF;
57356 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0F,temp);                        /* TW: CRT2 Vertical Display Enable End */
57357 +       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0F,temp);                        /* CRT2 Vertical Display Enable End */
57358  
57359         temp = ((tempbx & 0xFF00) << 3) >> 8;
57360         temp |= ((tempcx & 0xFF00) >> 8);
57361 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x12,temp);                        /* TW: Overflow (and HWCursor Test Mode) */
57362 +       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x12,temp);                        /* Overflow (and HWCursor Test Mode) */
57363  
57364 -       /* TW: 650/LVDS (1.10.07), 650/30xLV (1.10.6s) */
57365 +       /* 650/LVDS (1.10.07), 650/30xLV (1.10.6s) */
57366         if(HwDeviceExtension->jChipType >= SIS_315H) {
57367             tempbx++;
57368            tempax = tempbx;
57369 @@ -553,29 +556,44 @@ SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT
57370            tempcx += tempbx;
57371            tempcx++;
57372         } else {
57373 -          /* TW: 300 series, LVDS/301B: */
57374 +          /* 300 series, LVDS/301B: */
57375            tempbx = (SiS_Pr->SiS_VGAVT + SiS_Pr->SiS_VGAVDE) >> 1;                 /*  BTVGA2VRS     0x10,0x11   */
57376            tempcx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) >> 4) + tempbx + 1;  /*  BTVGA2VRE     0x11        */
57377         }
57378  
57379         if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
57380 -          if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){
57381 -               tempbx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[8];
57382 -               temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7];
57383 -               if(temp & 0x04) tempbx |= 0x0100;
57384 -               if(temp & 0x80) tempbx |= 0x0200;
57385 -               temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13];
57386 -               if(temp & 0x08) tempbx |= 0x0400;
57387 -               temp = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[9];
57388 -               tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
57389 +
57390 +          if(SiS_Pr->UseCustomMode) {
57391 +             tempbx = SiS_Pr->CVSyncStart;
57392 +             tempcx = (tempcx & 0xFF00) | (SiS_Pr->CVSyncEnd & 0x00FF);
57393 +          }
57394 +
57395 +          if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
57396 +             unsigned char cr8, cr7, cr13, cr9;
57397 +             if(SiS_Pr->UseCustomMode) {
57398 +                cr8  = SiS_Pr->CCRT1CRTC[8];
57399 +                cr7  = SiS_Pr->CCRT1CRTC[7];
57400 +                cr13 = SiS_Pr->CCRT1CRTC[13];
57401 +                cr9  = SiS_Pr->CCRT1CRTC[9];
57402 +             } else {
57403 +                cr8  = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[8];
57404 +                cr7  = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7];
57405 +                cr13 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13];
57406 +                cr9  = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[9];
57407 +             }
57408 +             tempbx = cr8;
57409 +             if(cr7 & 0x04)  tempbx |= 0x0100;
57410 +             if(cr7 & 0x80)  tempbx |= 0x0200;
57411 +             if(cr13 & 0x08) tempbx |= 0x0400;
57412 +             tempcx = (tempcx & 0xFF00) | (cr9 & 0x00FF);
57413            }
57414         }
57415         temp = tempbx & 0x00FF;
57416 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp);           /* TW: CRT2 Vertical Retrace Start */
57417 +       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp);           /* CRT2 Vertical Retrace Start */
57418  
57419         temp = ((tempbx & 0xFF00) >> 8) << 4;
57420         temp |= (tempcx & 0x000F);
57421 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x11,temp);           /* TW: CRT2 Vert. Retrace End; Overflow; "Enable CRTC Check" */
57422 +       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x11,temp);           /* CRT2 Vert. Retrace End; Overflow; "Enable CRTC Check" */
57423  
57424         /* 3. Panel compensation delay */
57425  
57426 @@ -590,18 +608,18 @@ SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT
57427                    temp = 0x10;
57428                    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)  temp = 0x2c;
57429                    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20;
57430 -                  if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960)  temp = 0x24;
57431                 }
57432                 if(SiS_Pr->SiS_VBType & VB_SIS301) {
57433                    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20;
57434                 }
57435                 if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960)     temp = 0x24;
57436 +               if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom)       temp = 0x2c;
57437                 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)            temp = 0x08;
57438                 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
57439                    if(SiS_Pr->SiS_VBInfo & SetInSlaveMode)      temp = 0x2c;
57440                    else                                         temp = 0x20;
57441                 }
57442 -               if((ROMAddr) && (SiS_Pr->SiS_UseROM) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) {
57443 +               if((ROMAddr) && (SiS_Pr->SiS_UseROM)) {
57444                     if(ROMAddr[0x220] & 0x80) {
57445                         if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV-SetCRT2ToHiVisionTV))
57446                                 temp = ROMAddr[0x221];
57447 @@ -636,19 +654,20 @@ SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT
57448                 }
57449            }
57450  
57451 -          SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x03C,temp);         /* TW: Panel Link Delay Compensation; (Software Command Reset; Power Saving) */
57452 +          SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x03C,temp);         /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */
57453  
57454  #endif  /* SIS300 */
57455  
57456         } else {
57457  
57458 -#ifdef SIS315H   /* ----------- 310/325/330 series ---------------*/
57459 +#ifdef SIS315H   /* --------------- 315/330 series ---------------*/
57460  
57461            if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
57462                  temp = 0x10;
57463                  if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)  temp = 0x2c;
57464                 if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x20;
57465                 if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960)  temp = 0x24;
57466 +               if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom)    temp = 0x2c;
57467                 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
57468                    temp = 0x08;
57469                    if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
57470 @@ -664,7 +683,7 @@ SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT
57471                       }
57472                    }
57473                 }
57474 -               if(SiS_Pr->SiS_VBType & VB_SIS301B302B) {
57475 +               if((SiS_Pr->SiS_VBType & VB_SIS301B302B) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) {
57476                    tempbl = 0x00;
57477                    if((ROMAddr) && (SiS_Pr->SiS_UseROM)) {
57478                       if(HwDeviceExtension->jChipType < SIS_330) {
57479 @@ -689,8 +708,16 @@ SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT
57480                       if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempbl = 0x0F;
57481                    }
57482                 }
57483 +
57484 +               if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) {
57485 +                  temp = 0x08;
57486 +                  tempbl = 0;
57487 +                  if((ROMAddr) && (SiS_Pr->SiS_UseROM)) {
57488 +                     if(ROMAddr[0x13c] & 0x80) tempbl = 0xf0;
57489 +                  }
57490 +               }
57491            }
57492 -          SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,tempbl,temp);         /* TW: Panel Link Delay Compensation */
57493 +          SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,tempbl,temp);         /* Panel Link Delay Compensation */
57494  
57495            tempax = 0;
57496            if (modeflag & DoubleScanMode) tempax |= 0x80;
57497 @@ -705,14 +732,13 @@ SiS_SetGroup1(SiS_Private *SiS_Pr,USHORT
57498  
57499       if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
57500  
57501 -        /* TW: For 301BDH, we set up the Panel Link */
57502 -        if( (SiS_Pr->SiS_VBType & VB_NoLCD) &&
57503 -           (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) {
57504 +        /* For 301BDH with LCD, we set up the Panel Link */
57505 +        if( (SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ) {
57506  
57507             SiS_SetGroup1_LVDS(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,
57508                                HwDeviceExtension,RefreshRateTableIndex);
57509  
57510 -        } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {                             
57511 +        } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
57512  
57513             SiS_SetGroup1_301(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,
57514                               HwDeviceExtension,RefreshRateTableIndex);
57515 @@ -749,23 +775,27 @@ SiS_SetGroup1_301(SiS_Private *SiS_Pr, U
57516    USHORT  push1,push2;
57517    USHORT  tempax,tempbx,tempcx,temp;
57518    USHORT  resinfo,modeflag;
57519 +  unsigned char p1_7, p1_8;
57520  
57521    if(ModeNo <= 0x13) {
57522 -       modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
57523 -       resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
57524 +     modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
57525 +     resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
57526    } else {
57527 +     if(SiS_Pr->UseCustomMode) {
57528 +        modeflag = SiS_Pr->CModeFlag;
57529 +       resinfo = 0;
57530 +     } else {
57531         modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
57532         resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
57533 +     }
57534    }
57535  
57536 -  /* TW: The following is only done if bridge is in slave mode: */
57537 +  /* The following is only done if bridge is in slave mode: */
57538  
57539    tempax = 0xFFFF;
57540    if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV))  tempax = SiS_GetVGAHT2(SiS_Pr);
57541  
57542 -  if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
57543 -       modeflag |= Charx8Dot;
57544 -  }
57545 +  if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)  modeflag |= Charx8Dot;
57546  
57547    if(modeflag & Charx8Dot) tempcx = 0x08;
57548    else                     tempcx = 0x09;
57549 @@ -777,8 +807,7 @@ SiS_SetGroup1_301(SiS_Private *SiS_Pr, U
57550    tempax = (tempax / tempcx) - 5;
57551    tempbx = tempax & 0x00FF;
57552  
57553 -  temp = 0xFF;                                                  /* set MAX HT */
57554 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x03,temp);
57555 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x03,0xff);                 /* set MAX HT */
57556  
57557    tempax = SiS_Pr->SiS_VGAHDE;                                         /* 0x04 Horizontal Display End */
57558    if(modeflag & HalfDCLK) tempax >>= 1;
57559 @@ -789,13 +818,13 @@ SiS_SetGroup1_301(SiS_Private *SiS_Pr, U
57560  
57561    temp = (tempbx & 0xFF00) >> 8;
57562    if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
57563 -        if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) {        
57564 -           temp += 2;
57565 -        }
57566 -  }    
57567 +     if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) {
57568 +        temp += 2;
57569 +     }
57570 +  }
57571    if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
57572       if(SiS_Pr->SiS_HiVision == 3) {
57573 -              if(resinfo == 7) temp -= 2;
57574 +        if(resinfo == SIS_RI_800x600) temp -= 2;
57575       }
57576    }
57577    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x05,temp);                 /* 0x05 Horizontal Display Start */
57578 @@ -804,140 +833,133 @@ SiS_SetGroup1_301(SiS_Private *SiS_Pr, U
57579  
57580    if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) &&
57581       (SiS_Pr->SiS_HiVision == 3)) {
57582 -    temp = (tempbx & 0x00FF) - 1;
57583 -    if(!(modeflag & HalfDCLK)) {
57584 -      temp -= 6;
57585 -      if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
57586 -        temp -= 2;
57587 -        if(ModeNo > 0x13) temp -= 10;
57588 -      }
57589 -    }
57590 +     temp = (tempbx & 0x00FF) - 1;
57591 +     if(!(modeflag & HalfDCLK)) {
57592 +        temp -= 6;
57593 +        if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
57594 +           temp -= 2;
57595 +           if(ModeNo > 0x13) temp -= 10;
57596 +        }
57597 +     }
57598    } else {
57599 -    tempcx = tempbx & 0x00FF;
57600 -    tempbx = (tempbx & 0xFF00) >> 8;
57601 -    tempcx = (tempcx + tempbx) >> 1;
57602 -    temp = (tempcx & 0x00FF) + 2;
57603 -    if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV){
57604 -       temp--;
57605 -       if(!(modeflag & HalfDCLK)){
57606 -          if((modeflag & Charx8Dot)){
57607 -             temp += 4;
57608 -             if(SiS_Pr->SiS_VGAHDE >= 800) temp -= 6;
57609 -             if(HwDeviceExtension->jChipType >= SIS_315H) {
57610 -               if(SiS_Pr->SiS_VGAHDE == 800) temp += 2;
57611 -             }
57612 -          }
57613 -       }
57614 -    } else {
57615 -       if(!(modeflag & HalfDCLK)) {
57616 -          temp -= 4;
57617 -          if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960) {
57618 -             if(SiS_Pr->SiS_VGAHDE >= 800) {
57619 -                temp -= 7;
57620 -               if(HwDeviceExtension->jChipType < SIS_315H) {
57621 -                  /* 650/301LV(x) does not do this, 630/301B, 300/301LV do */
57622 -                   if(SiS_Pr->SiS_ModeType == ModeEGA) {
57623 -                      if(SiS_Pr->SiS_VGAVDE == 1024) {
57624 -                         temp += 15;
57625 -                         if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) 
57626 -                           temp += 7;
57627 -                      }
57628 -                   }
57629 -               }
57630 -                if(SiS_Pr->SiS_VGAHDE >= 1280) {
57631 -                   if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960) {
57632 -                      if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) temp += 28;
57633 -                   }
57634 -                }
57635 -             }
57636 -          }
57637 -       }
57638 -    }
57639 +     tempcx = tempbx & 0x00FF;
57640 +     tempbx = (tempbx & 0xFF00) >> 8;
57641 +     tempcx = (tempcx + tempbx) >> 1;
57642 +     temp = (tempcx & 0x00FF) + 2;
57643 +     if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
57644 +        temp--;
57645 +        if(!(modeflag & HalfDCLK)) {
57646 +           if((modeflag & Charx8Dot)) {
57647 +              temp += 4;
57648 +              if(SiS_Pr->SiS_VGAHDE >= 800) temp -= 6;
57649 +              if(HwDeviceExtension->jChipType >= SIS_315H) {
57650 +                if(SiS_Pr->SiS_VGAHDE == 800) temp += 2;
57651 +              }
57652 +           }
57653 +        }
57654 +     } else {
57655 +        if(!(modeflag & HalfDCLK)) {
57656 +           temp -= 4;
57657 +           if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960) {
57658 +              if(SiS_Pr->SiS_VGAHDE >= 800) {
57659 +                 temp -= 7;
57660 +                if(HwDeviceExtension->jChipType < SIS_315H) {
57661 +                   /* 650/301LV(x) does not do this, 630/301B, 300/301LV do */
57662 +                    if(SiS_Pr->SiS_ModeType == ModeEGA) {
57663 +                       if(SiS_Pr->SiS_VGAVDE == 1024) {
57664 +                          temp += 15;
57665 +                          if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024)
57666 +                            temp += 7;
57667 +                       }
57668 +                    }
57669 +                }
57670 +                 if(SiS_Pr->SiS_VGAHDE >= 1280) {
57671 +                    if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) temp += 28;
57672 +                 }
57673 +              }
57674 +           }
57675 +        }
57676 +     }
57677    }
57678 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,temp);                /* 0x07 Horizontal Retrace Start */
57679  
57680 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x00);                 /* 0x08 Horizontal Retrace End   */
57681 +  p1_7 = temp;
57682 +  p1_8 = 0x00;
57683  
57684    if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
57685       if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
57686 -            if(ModeNo <= 0x01) {
57687 -               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x2a);
57688 -               if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
57689 -                   SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x61);
57690 -               } else {
57691 -                   SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x41);
57692 -               }
57693 -           } else if(SiS_Pr->SiS_ModeType == ModeText) {
57694 -               if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
57695 -                   SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x54);
57696 -               } else {
57697 -                   SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x55);
57698 -               }
57699 -               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x00);
57700 -           } else if(ModeNo <= 0x13) {
57701 -               if(modeflag & HalfDCLK) {
57702 -                   if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
57703 -                       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x30);
57704 -                       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x03);
57705 -                   } else {
57706 -                       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x2f);
57707 -                       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x02);
57708 -                   }
57709 -               } else {
57710 -                   SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x5b);
57711 -                   SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x03);
57712 -               }
57713 -           } else if( ((HwDeviceExtension->jChipType >= SIS_315H) && (ModeNo == 0x50)) ||
57714 -                      ((HwDeviceExtension->jChipType < SIS_315H) && (resinfo == 0 || resinfo == 1)) ) {
57715 -               if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
57716 -                   SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x30);
57717 -                   SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x03);
57718 -               } else {
57719 -                   SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0x2f);
57720 -                   SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,0x03);
57721 -               }
57722 -           }
57723 -
57724 +        if(ModeNo <= 0x01) {
57725 +          p1_7 = 0x2a;
57726 +          if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) p1_8 = 0x61;
57727 +          else                                 p1_8 = 0x41;
57728 +       } else if(SiS_Pr->SiS_ModeType == ModeText) {
57729 +          if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) p1_7 = 0x54;
57730 +          else                                 p1_7 = 0x55;
57731 +          p1_8 = 0x00;
57732 +       } else if(ModeNo <= 0x13) {
57733 +          if(modeflag & HalfDCLK) {
57734 +             if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
57735 +                p1_7 = 0x30;
57736 +                p1_8 = 0x03;
57737 +             } else {
57738 +                p1_7 = 0x2f;
57739 +                p1_8 = 0x02;
57740 +             }
57741 +          } else {
57742 +             p1_7 = 0x5b;
57743 +             p1_8 = 0x03;
57744 +          }
57745 +       } else if( ((HwDeviceExtension->jChipType >= SIS_315H) &&
57746 +                   ((ModeNo == 0x50) || (ModeNo = 0x56) || (ModeNo = 0x53))) ||
57747 +                  ((HwDeviceExtension->jChipType < SIS_315H) &&
57748 +                   (resinfo == SIS_RI_320x200 || resinfo == SIS_RI_320x240)) ) {
57749 +          if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
57750 +             p1_7 = 0x30,
57751 +             p1_8 = 0x03;
57752 +          } else {
57753 +             p1_7 = 0x2f;
57754 +             p1_8 = 0x03;
57755 +          }
57756 +        }
57757       }
57758    }
57759 +
57760    if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
57761       if(SiS_Pr->SiS_HiVision & 0x03) {
57762 -        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0xb2);
57763 +       p1_7 = 0xb2;
57764         if(SiS_Pr->SiS_HiVision & 0x02) {
57765 -          SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,0xab);
57766 +          p1_7 = 0xab;
57767         }
57768       }
57769    }
57770  
57771 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,p1_7);                        /* 0x07 Horizontal Retrace Start */
57772 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x08,p1_8);                        /* 0x08 Horizontal Retrace End   */
57773 +
57774 +
57775    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x03);                        /* 0x18 SR08 (FIFO Threshold?)   */
57776  
57777    SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x19,0xF0);
57778  
57779 -  tempbx = SiS_Pr->SiS_VGAVT;
57780 -  push1 = tempbx;
57781 -
57782    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x09,0xFF);                        /* 0x09 Set Max VT    */
57783  
57784    tempcx = 0x121;
57785    tempbx = SiS_Pr->SiS_VGAVDE;                                 /* 0x0E Vertical Display End */
57786 -  if(tempbx == 357) tempbx = 350;
57787 -  if(tempbx == 360) tempbx = 350;
57788 -  if(tempbx == 375) tempbx = 350;
57789 -  if(tempbx == 405) tempbx = 400;
57790 -  if(tempbx == 420) tempbx = 400;
57791 -  if(tempbx == 525) tempbx = 480;
57792 +  if     (tempbx == 357) tempbx = 350;
57793 +  else if(tempbx == 360) tempbx = 350;
57794 +  else if(tempbx == 375) tempbx = 350;
57795 +  else if(tempbx == 405) tempbx = 400;
57796 +  else if(tempbx == 420) tempbx = 400;
57797 +  else if(tempbx == 525) tempbx = 480;
57798    push2 = tempbx;
57799    if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
57800 -       if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
57801 -               if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
57802 -                       if(tempbx == 350) tempbx += 5;
57803 -                       if(tempbx == 480) tempbx += 5;
57804 -               }
57805 -       }
57806 +     if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
57807 +       if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
57808 +           if     (tempbx == 350) tempbx += 5;
57809 +           else if(tempbx == 480) tempbx += 5;
57810 +       }
57811 +     }
57812    }
57813 -  tempbx--;
57814 -  temp = tempbx & 0x00FF;
57815 -  tempbx--;
57816 +  tempbx -= 2;
57817    temp = tempbx & 0x00FF;
57818    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp);                        /* 0x10 vertical Blank Start */
57819  
57820 @@ -945,126 +967,91 @@ SiS_SetGroup1_301(SiS_Private *SiS_Pr, U
57821    tempbx--;
57822    temp = tempbx & 0x00FF;
57823  #if 0
57824 -  /* TW: Missing code from 630/301B 2.04.5a and 650/302LV 1.10.6s (calles int 2f) */
57825 +  /* Missing code from 630/301B 2.04.5a and 650/302LV 1.10.6s (calles int 2f) */
57826    if(xxx()) {
57827        if(temp == 0xdf) temp = 0xda;
57828    }
57829  #endif
57830    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0E,temp);
57831  
57832 -  if(tempbx & 0x0100) {
57833 -       tempcx |= 0x0002;
57834 -       if(SiS_Pr->SiS_VBType & VB_SIS301) tempcx |= 0x000a;
57835 -  }
57836 +  if(tempbx & 0x0100)  tempcx |= 0x0002;
57837  
57838    tempax = 0x000B;
57839    if(modeflag & DoubleScanMode) tempax |= 0x8000;
57840  
57841 -  if(tempbx & 0x0200) {
57842 -       tempcx |= 0x0040;
57843 -       if(SiS_Pr->SiS_VBType & VB_SIS301) tempax |= 0x2000;
57844 -  }
57845 -
57846 -  if(SiS_Pr->SiS_VBType & VB_SIS301) {
57847 -        if(SiS_Pr->SiS_VBInfo & SetPALTV) {
57848 -             if(SiS_Pr->SiS_VGAVDE == 480) {
57849 -                    tempax = (tempax & 0x00ff) | 0x2000;
57850 -                    if(modeflag & DoubleScanMode)  tempax |= 0x8000;
57851 -             }
57852 -       }
57853 -  }
57854 +  if(tempbx & 0x0200)  tempcx |= 0x0040;
57855  
57856    temp = (tempax & 0xFF00) >> 8;
57857    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0B,temp);
57858  
57859 -  if(tempbx & 0x0400) tempcx |= 0x0600;
57860 +  if(tempbx & 0x0400)  tempcx |= 0x0600;
57861  
57862    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x11,0x00);                        /* 0x11 Vertical Blank End */
57863  
57864 -  tempax = push1;
57865 -  tempax -= tempbx;
57866 -  tempax >>= 2;
57867 -  push1 = tempax;
57868 +  tempax = (SiS_Pr->SiS_VGAVT - tempbx) >> 2;
57869  
57870 -  if(HwDeviceExtension->jChipType >= SIS_315H) {
57871 -        /* TW: 650/30xLV 1.10.6s */
57872 -        if(ModeNo > 0x13) {
57873 -           if(resinfo != 0x09) {  /* 1280x1024 */
57874 -               tempax <<= 1;
57875 -               tempbx += tempax;
57876 -           }
57877 -       } else {
57878 -           if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1400x1050) {
57879 -               tempax <<= 1;
57880 -               tempbx += tempax;
57881 -           }
57882 -       }
57883 -  } else if((resinfo != 0x09) || (SiS_Pr->SiS_VBType & VB_SIS301)) {
57884 -       tempax <<= 1;
57885 -       tempbx += tempax;
57886 +  if((ModeNo > 0x13) || (HwDeviceExtension->jChipType < SIS_315H)) {
57887 +     if(resinfo != SIS_RI_1280x1024) {
57888 +       tempbx += (tempax << 1);
57889 +     }
57890 +  } else if(HwDeviceExtension->jChipType >= SIS_315H) {
57891 +     if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1400x1050) {
57892 +       tempbx += (tempax << 1);
57893 +     }
57894    }
57895  
57896 -  if( (SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) &&
57897 -      (SiS_Pr->SiS_HiVision == 3) ) {
57898 -       tempbx -= 10;
57899 +  if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) &&
57900 +     (SiS_Pr->SiS_HiVision == 3)) {
57901 +     tempbx -= 10;
57902    } else {
57903 -       if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
57904 -          if(SiS_Pr->SiS_VBInfo & SetPALTV) {
57905 -              if(!(SiS_Pr->SiS_HiVision & 0x03)) {
57906 -                    tempbx += 40;
57907 -                   if(HwDeviceExtension->jChipType >= SIS_315H) {
57908 -                      if(SiS_Pr->SiS_VGAHDE == 800) tempbx += 10;
57909 -                   }
57910 -              }
57911 -          }
57912 -       }
57913 +     if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
57914 +        if(SiS_Pr->SiS_VBInfo & SetPALTV) {
57915 +          if(!(SiS_Pr->SiS_HiVision & 0x03)) {
57916 +              tempbx += 40;
57917 +             if(HwDeviceExtension->jChipType >= SIS_315H) {
57918 +                if(SiS_Pr->SiS_VGAHDE == 800) tempbx += 10;
57919 +             }
57920 +          }
57921 +       }
57922 +     }
57923    }
57924 -  tempax = push1;
57925    tempax >>= 2;
57926    tempax++;
57927    tempax += tempbx;
57928    push1 = tempax;
57929    if(SiS_Pr->SiS_VBInfo & SetPALTV) {
57930 -       if(tempbx <= 513)  {
57931 -               if(tempax >= 513) tempbx = 513;
57932 -       }
57933 +     if(tempbx <= 513)  {
57934 +       if(tempax >= 513) tempbx = 513;
57935 +     }
57936    }
57937    temp = tempbx & 0x00FF;
57938    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0C,temp);                        /* 0x0C Vertical Retrace Start */
57939  
57940 -  if(!(SiS_Pr->SiS_VBType & VB_SIS301)) {
57941 -       tempbx--;
57942 -       temp = tempbx & 0x00FF;
57943 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp);
57944 -
57945 -       if(tempbx & 0x0100) tempcx |= 0x0008;
57946 +  tempbx--;
57947 +  temp = tempbx & 0x00FF;
57948 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x10,temp);
57949  
57950 -       if(tempbx & 0x0200) {
57951 -          SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x0B,0x20);
57952 -       }
57953 +  if(tempbx & 0x0100) tempcx |= 0x0008;
57954  
57955 -       tempbx++;
57956 +  if(tempbx & 0x0200) {
57957 +     SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x0B,0x20);
57958    }
57959 +  tempbx++;
57960 +
57961    if(tempbx & 0x0100) tempcx |= 0x0004;
57962    if(tempbx & 0x0200) tempcx |= 0x0080;
57963    if(tempbx & 0x0400) {
57964 -        if(SiS_Pr->SiS_VBType & VB_SIS301) tempcx |= 0x0800;
57965 -       else                               tempcx |= 0x0C00;
57966 +     if(SiS_Pr->SiS_VBType & VB_SIS301) tempcx |= 0x0800;
57967 +     else                               tempcx |= 0x0C00;
57968    }
57969  
57970    tempbx = push1;
57971 -  temp = tempbx & 0x00FF;
57972 -  temp &= 0x0F;
57973 +  temp = tempbx & 0x000F;
57974    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0D,temp);                        /* 0x0D vertical Retrace End */
57975  
57976    if(tempbx & 0x0010) tempcx |= 0x2000;
57977  
57978    temp = tempcx & 0x00FF;
57979 -  if(SiS_Pr->SiS_VBType & VB_SIS301) {
57980 -       if(SiS_Pr->SiS_VBInfo & SetPALTV) {
57981 -             if(SiS_Pr->SiS_VGAVDE == 480)  temp = 0xa3;
57982 -       }
57983 -  }
57984    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0A,temp);                /* 0x0A CR07 */
57985  
57986    temp = (tempcx & 0xFF00) >> 8;
57987 @@ -1074,8 +1061,8 @@ SiS_SetGroup1_301(SiS_Private *SiS_Pr, U
57988    temp = (tempax & 0xFF00) >> 8;
57989    temp = (temp >> 1) & 0x09;
57990    if(!(SiS_Pr->SiS_VBType & VB_SIS301)) {
57991 -       /* Only use 8 dot clock */
57992 -       temp |= 0x01;
57993 +     /* Only use 8 dot clock */
57994 +     temp |= 0x01;
57995    }
57996    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x16,temp);                /* 0x16 SR01 */
57997  
57998 @@ -1084,16 +1071,15 @@ SiS_SetGroup1_301(SiS_Private *SiS_Pr, U
57999    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x12,0x00);                /* 0x12 CR17 */
58000  
58001    if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
58002 -       if(IS_SIS650) {
58003 -           /* TW: 650/30xLV 1.10.6s */
58004 -           if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) {
58005 -              temp = 0x80;
58006 -          }
58007 -       } else temp = 0x80;
58008 -  } else  temp = 0x00;
58009 +     if(IS_SIS650) {
58010 +        /* 650/30xLV 1.10.6s */
58011 +        if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) {
58012 +          temp = 0x80;
58013 +       }
58014 +     } else temp = 0x80;
58015 +  } else temp = 0x00;
58016    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1A,temp);                        /* 0x1A SR0E */
58017  
58018 -  return;
58019  }
58020  
58021  void
58022 @@ -1108,40 +1094,52 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,U
58023  #endif
58024    ULONG  tempeax=0, tempebx, tempecx, tempvcfact=0;
58025  
58026 +  /* This is not supported on LVDS */
58027 +  if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return;
58028 +  if(SiS_Pr->UseCustomMode) return;
58029 +
58030    if(ModeNo <= 0x13) {
58031 -       modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
58032 -       resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
58033 +     modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
58034 +     resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
58035    } else {
58036 -       modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
58037 -       resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
58038 +     modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
58039 +     resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
58040    }
58041  
58042 -  /* TW: Set up Panel Link */
58043 +  /* Set up Panel Link */
58044  
58045    /* 1. Horizontal setup */
58046  
58047    tempax = SiS_Pr->SiS_LCDHDES;
58048  
58049 -  if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) &&
58050 -      (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ) {
58051 -       tempax -= 8;
58052 +  if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) {
58053 +     if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) &&
58054 +         (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ) {
58055 +          tempax -= 8;
58056 +     }
58057    }
58058  
58059    tempcx = SiS_Pr->SiS_HT;                               /* Horiz. Total */
58060  
58061    tempbx = SiS_Pr->SiS_HDE;                               /* Horiz. Display End */
58062  
58063 +  if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 ||
58064 +     SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) {
58065 +     tempbx >>= 1;
58066 +  }
58067 +
58068    if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
58069       if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
58070 -        if((!SiS_Pr->SiS_IF_DEF_DSTN) && (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480)) {
58071 -          if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600)        tempbx =  800;
58072 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600)  tempbx = 1024;  /* TW */
58073 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)  tempbx = 1024;
58074 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768)  tempbx = 1152;  /* TW */
58075 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768)  tempbx = 1280;
58076 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempbx = 1280; 
58077 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempbx = 1400; 
58078 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempbx = 1600; 
58079 +        if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) {
58080 +          tempbx = SiS_Pr->PanelXRes;
58081 +       } else if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) {
58082 +          tempbx = SiS_Pr->PanelXRes;
58083 +          if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) {
58084 +             tempbx = 800;
58085 +             if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel800x600) {
58086 +                tempbx = 1024;
58087 +             }
58088 +          }
58089          }
58090       }
58091    }
58092 @@ -1154,13 +1152,18 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,U
58093    if(tempax >= SiS_Pr->SiS_HT) tempax -= SiS_Pr->SiS_HT;
58094  
58095    push2 = tempax;
58096 -  
58097 -  if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 
58098 -     if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
58099 -        if((!SiS_Pr->SiS_IF_DEF_DSTN) && (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480)) {
58100 -          if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600)        tempcx = 0x0028;
58101 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600)  tempcx = 0x0018;
58102 -          else if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) ||
58103 +
58104 +  if((!SiS_Pr->SiS_IF_DEF_FSTN) &&
58105 +     (!SiS_Pr->SiS_IF_DEF_DSTN) &&
58106 +     (SiS_Pr->SiS_CustomT != CUT_BARCO1366) &&
58107 +     (SiS_Pr->SiS_CustomT != CUT_BARCO1024) &&
58108 +     (SiS_Pr->SiS_CustomT != CUT_PANEL848)) {
58109 +     if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
58110 +        if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
58111 +           if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) {
58112 +             if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600)        tempcx = 0x0028;
58113 +             else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600)  tempcx = 0x0018;
58114 +             else if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) ||
58115                     (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) ) {
58116                    if(HwDeviceExtension->jChipType < SIS_315H) {
58117                       if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
58118 @@ -1174,11 +1177,12 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,U
58119                    } else {
58120                       tempcx = 0x0018;
58121                    }
58122 +             }
58123 +             else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768)  tempcx = 0x0028;
58124 +             else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 0x0030;
58125 +             else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0030;
58126 +             else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x0040;
58127            }
58128 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768)  tempcx = 0x0028;
58129 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempcx = 0x0030;
58130 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempcx = 0x0030;
58131 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempcx = 0x0040;
58132          }
58133       }
58134    }
58135 @@ -1188,14 +1192,18 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,U
58136  
58137    tempax = tempcx >> 3;                          /* BPLHRS */
58138    temp = tempax & 0x00FF;
58139 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,temp);                 /* Part1_14h; TW: Panel Link Horizontal Retrace Start  */
58140 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,temp);                 /* Part1_14h; Panel Link Horizontal Retrace Start  */
58141  
58142    if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
58143       temp = (tempax & 0x00FF) + 2;
58144    } else {
58145       temp = (tempax & 0x00FF) + 10;
58146       if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
58147 -        if(!SiS_Pr->SiS_IF_DEF_DSTN) {
58148 +        if((!SiS_Pr->SiS_IF_DEF_DSTN) &&
58149 +          (!SiS_Pr->SiS_IF_DEF_FSTN) &&
58150 +          (SiS_Pr->SiS_CustomT != CUT_BARCO1366) &&
58151 +          (SiS_Pr->SiS_CustomT != CUT_BARCO1024) &&
58152 +          (SiS_Pr->SiS_CustomT != CUT_PANEL848)) {
58153             if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) {
58154               temp += 6;
58155                if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel800x600) {
58156 @@ -1219,47 +1227,57 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,U
58157  
58158    temp &= 0x1F;
58159    temp |= ((tempcx & 0x0007) << 5);
58160 -  if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0x20;
58161 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x15,temp);         /* Part1_15h; TW: Panel Link Horizontal Retrace End/Skew */
58162 +#if 0
58163 +  if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0x20;       /* WRONG? BIOS loads cl, not ah */
58164 +#endif
58165 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x15,temp);         /* Part1_15h; Panel Link Horizontal Retrace End/Skew */
58166  
58167    tempbx = push2;
58168    tempcx = push1;                                /* lcdhdes  */
58169  
58170    temp = (tempcx & 0x0007);                      /* BPLHDESKEW  */
58171 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1A,temp);         /* Part1_1Ah; TW: Panel Link Vertical Retrace Start (2:0) */
58172 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1A,temp);         /* Part1_1Ah; Panel Link Vertical Retrace Start (2:0) */
58173  
58174    tempcx >>= 3;                                  /* BPLHDES */
58175    temp = (tempcx & 0x00FF);
58176 -  if(ModeNo == 0x5b) temp--;                     
58177 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x16,temp);         /* Part1_16h; TW: Panel Link Horizontal Display Enable Start  */
58178 +#if 0 /* Not 550 FSTN */
58179 +  if(HwDeviceExtension->jChipType >= SIS_315H) {
58180 +     if(ModeNo == 0x5b) temp--; */
58181 +  }
58182 +#endif
58183 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x16,temp);         /* Part1_16h; Panel Link Horizontal Display Enable Start  */
58184  
58185 -  if(HwDeviceExtension->jChipType < SIS_315H) {  
58186 +  if((HwDeviceExtension->jChipType < SIS_315H) ||
58187 +     (SiS_Pr->SiS_IF_DEF_FSTN) ||
58188 +     (SiS_Pr->SiS_IF_DEF_DSTN)) {
58189       if(tempbx & 0x07) tempbx += 8;              
58190    }
58191    tempbx >>= 3;                                  /* BPLHDEE  */
58192    temp = tempbx & 0x00FF;
58193 -  if(ModeNo == 0x5b) temp--;                    
58194 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x17,temp);         /* Part1_17h; TW: Panel Link Horizontal Display Enable End  */
58195 +#if 0 /* Not 550 FSTN */
58196 +  if(HwDeviceExtension->jChipType >= SIS_315H) {
58197 +     if(ModeNo == 0x5b) temp--;
58198 +  }
58199 +#endif
58200 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x17,temp);         /* Part1_17h; Panel Link Horizontal Display Enable End  */
58201  
58202    /* 2. Vertical setup */
58203  
58204    if(HwDeviceExtension->jChipType < SIS_315H) {
58205       tempcx = SiS_Pr->SiS_VGAVT;
58206       tempbx = SiS_Pr->SiS_VGAVDE;
58207 -     if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
58208 -        if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) {
58209 -          if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600)       tempbx =  600;
58210 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) tempbx =  600;
58211 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx =  768;
58212 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) tempbx =  768;
58213 -          else                                                         tempbx = 1024;
58214 -        }
58215 +     if((SiS_Pr->SiS_CustomT != CUT_BARCO1366) && (SiS_Pr->SiS_CustomT != CUT_BARCO1024)) {
58216 +        if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
58217 +           if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) {
58218 +             tempbx = SiS_Pr->PanelYRes;
58219 +           }
58220 +       }
58221       }
58222       tempcx -= tempbx;
58223  
58224    } else {
58225  
58226 -     tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE;          /* VGAVT-VGAVDE  */
58227 +     tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE;           /* VGAVT-VGAVDE  */
58228  
58229    }
58230  
58231 @@ -1268,18 +1286,20 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,U
58232  
58233    tempax = SiS_Pr->SiS_VGAVDE;
58234  
58235 -  if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!SiS_Pr->SiS_IF_DEF_DSTN)) {
58236 -     if( (SiS_Pr->SiS_IF_DEF_TRUMPION == 0)   && 
58237 -         (!(SiS_Pr->SiS_LCDInfo & LCDPass11)) &&
58238 -         (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) ) {
58239 -        if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600)        tempax =  600;
58240 -        else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600)  tempax =  600;  
58241 -        else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)  tempax =  768;
58242 -        else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768)  tempax =  768;  
58243 -        else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768)  tempax =  768;  
58244 -        else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempax = 1024; 
58245 -        else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempax = 1050; 
58246 -        else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempax = 1200; 
58247 +  if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
58248 +     if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) {
58249 +        if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) {
58250 +           tempax = 600;
58251 +          if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel800x600) {
58252 +             tempax = 768;
58253 +          }
58254 +       }
58255 +     } else if( (SiS_Pr->SiS_IF_DEF_TRUMPION == 0)   &&
58256 +                (!(SiS_Pr->SiS_LCDInfo & LCDPass11)) &&
58257 +                ((SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) ||
58258 +                (SiS_Pr->SiS_IF_DEF_FSTN) ||
58259 +                (SiS_Pr->SiS_IF_DEF_DSTN)) ) {
58260 +       tempax = SiS_Pr->PanelYRes;
58261       }
58262    }
58263  
58264 @@ -1290,11 +1310,25 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,U
58265  
58266    tempcx >>= 1;
58267  
58268 -  if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480)) {
58269 -     if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
58270 -        if(!SiS_Pr->SiS_IF_DEF_DSTN) {
58271 -          if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600)        tempcx = 0x0001;
58272 -          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600)  tempcx = 0x0001;
58273 +  if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) &&
58274 +     (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) &&
58275 +     (SiS_Pr->SiS_CustomT != CUT_BARCO1366) &&
58276 +     (SiS_Pr->SiS_CustomT != CUT_BARCO1024) &&
58277 +     (SiS_Pr->SiS_CustomT != CUT_PANEL848)) {
58278 +     if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 ||
58279 +        SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) {
58280 +       tempcx = 0x0017;
58281 +     } else if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
58282 +        if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) {
58283 +          if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600)         tempcx = 0x0003;
58284 +          else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) ||
58285 +                  (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768)) tempcx = 0x0003;
58286 +           else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024)  tempcx = 0x0001;
58287 +           else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050)  tempcx = 0x0001;
58288 +          else                                                           tempcx = 0x0057;
58289 +        } else  {
58290 +          if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600)         tempcx = 0x0001;
58291 +          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600)   tempcx = 0x0001;
58292            else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) ||
58293                    (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768)) {
58294                    if(HwDeviceExtension->jChipType < SIS_315H) {
58295 @@ -1304,7 +1338,7 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,U
58296                             tempcx = 0x0003;
58297  #endif
58298                       } else {
58299 -                           tempcx = 0x0002;   /* TW: A901; sometimes 0x0003; */
58300 +                           tempcx = 0x0002;   /* A901; sometimes 0x0003; */
58301                       }
58302                    } else tempcx = 0x0003;
58303             }
58304 @@ -1319,26 +1353,33 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,U
58305  
58306    tempbx += tempcx;                            /* BPLVRS  */
58307  
58308 -  if(HwDeviceExtension->jChipType < SIS_315H) {
58309 -      tempbx++;
58310 +  if((HwDeviceExtension->jChipType < SIS_315H) ||
58311 +     (SiS_Pr->SiS_IF_DEF_FSTN) ||
58312 +     (SiS_Pr->SiS_IF_DEF_DSTN)) {
58313 +     tempbx++;
58314    }
58315  
58316    if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT;
58317  
58318    temp = tempbx & 0x00FF;
58319 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,temp);         /* Part1_18h; TW: Panel Link Vertical Retrace Start  */
58320 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,temp);         /* Part1_18h; Panel Link Vertical Retrace Start  */
58321  
58322    tempcx >>= 3;
58323  
58324 -  if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
58325 +  if((!(SiS_Pr->SiS_LCDInfo & LCDPass11)) &&
58326 +     (SiS_Pr->SiS_CustomT != CUT_BARCO1366) &&
58327 +     (SiS_Pr->SiS_CustomT != CUT_BARCO1024) &&
58328 +     (SiS_Pr->SiS_CustomT != CUT_PANEL848)) {
58329       if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
58330          if( (HwDeviceExtension->jChipType < SIS_315H) &&
58331              (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) )     tempcx = 0x0001;
58332 +       else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2)  tempcx = 0x0002;
58333 +       else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3)  tempcx = 0x0002;
58334          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600)    tempcx = 0x0003;
58335          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600)   tempcx = 0x0005;
58336          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768)   tempcx = 0x0005;
58337         else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768)   tempcx = 0x0011;
58338 -        else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024)  tempcx = 0x0005;         
58339 +        else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024)  tempcx = 0x0005;
58340          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050)  tempcx = 0x0002;
58341          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)  tempcx = 0x0011;
58342          else if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480)  {
58343 @@ -1360,26 +1401,37 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,U
58344  
58345    tempcx = tempcx + tempbx + 1;                  /* BPLVRE  */
58346    temp = tempcx & 0x000F;
58347 -  SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xf0,temp); /* Part1_19h; TW: Panel Link Vertical Retrace End (3:0); Misc.  */
58348 +  if(SiS_Pr->SiS_IF_DEF_FSTN ||
58349 +     SiS_Pr->SiS_IF_DEF_DSTN ||
58350 +     (SiS_Pr->SiS_CustomT == CUT_BARCO1366) ||
58351 +     (SiS_Pr->SiS_CustomT == CUT_BARCO1024) ||
58352 +     (SiS_Pr->SiS_CustomT == CUT_PANEL848)) {
58353 +     temp |= 0x30;
58354 +  }
58355 +  SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xf0,temp); /* Part1_19h; Panel Link Vertical Retrace End (3:0); Misc.  */
58356  
58357    temp = ((tempbx & 0x0700) >> 8) << 3;          /* BPLDESKEW =0 */
58358 -  if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE)  temp |= 0x40;
58359 -  if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA)    temp |= 0x40;
58360 +  if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) {
58361 +     if(SiS_Pr->SiS_HDE != 640) {
58362 +        if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE)   temp |= 0x40;
58363 +     }
58364 +  } else if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE)  temp |= 0x40;
58365 +  if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA)           temp |= 0x40;
58366    if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
58367 -      if(HwDeviceExtension->jChipType >= SIS_315H) {
58368 -         if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) {
58369 -            temp |= 0x80;
58370 -         }
58371 -      } else {
58372 -        if( (HwDeviceExtension->jChipType == SIS_630) ||
58373 -            (HwDeviceExtension->jChipType == SIS_730) ) {
58374 -           if(HwDeviceExtension->jChipRevision >= 0x30) {
58375 -              temp |= 0x80;
58376 -           }
58377 -        }
58378 -      }
58379 +     if(HwDeviceExtension->jChipType >= SIS_315H) {
58380 +        if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) {
58381 +           temp |= 0x80;
58382 +        }
58383 +     } else {
58384 +       if( (HwDeviceExtension->jChipType == SIS_630) ||
58385 +           (HwDeviceExtension->jChipType == SIS_730) ) {
58386 +          if(HwDeviceExtension->jChipRevision >= 0x30) {
58387 +             temp |= 0x80;
58388 +          }
58389 +       }
58390 +     }
58391    }
58392 -  SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,0x87,temp);  /* Part1_1Ah; TW: Panel Link Control Signal (7:3); Vertical Retrace Start (2:0) */
58393 +  SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,0x87,temp);  /* Part1_1Ah; Panel Link Control Signal (7:3); Vertical Retrace Start (2:0) */
58394  
58395    if (HwDeviceExtension->jChipType < SIS_315H) {
58396  
58397 @@ -1396,19 +1448,19 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,U
58398         }
58399  
58400         temp = (USHORT)(tempebx & 0x00FF);
58401 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1E,temp);      /* Part1_1Eh; TW: Panel Link Vertical Scaling Factor */
58402 +       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1E,temp);      /* Part1_1Eh; Panel Link Vertical Scaling Factor */
58403  
58404  #endif /* SIS300 */
58405  
58406    } else {
58407  
58408 -#ifdef SIS315H  /* 310/325 series */
58409 +#ifdef SIS315H  /* 315 series */
58410  
58411 -#ifdef NEWCH701x
58412 -        SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x03);
58413 -#else
58414 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1E,0x23);
58415 -#endif 
58416 +        if(HwDeviceExtension->jChipType == SIS_740) {
58417 +           SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x03);
58418 +        } else {
58419 +          SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1E,0x23);
58420 +       }
58421  
58422         tempeax = SiS_Pr->SiS_VGAVDE << 18;
58423         temp = (USHORT)(tempeax % (ULONG)SiS_Pr->SiS_VDE);
58424 @@ -1417,12 +1469,13 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,U
58425         tempebx = tempeax;                         /* BPLVCFACT  */
58426          tempvcfact = tempeax;
58427         temp = (USHORT)(tempebx & 0x00FF);
58428 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x37,temp);      /* Part1_37h; TW: Panel Link Vertical Scaling Factor */
58429 +       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x37,temp);      /* Part1_37h; Panel Link Vertical Scaling Factor */
58430         temp = (USHORT)((tempebx & 0x00FF00) >> 8);
58431 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x36,temp);      /* Part1_36h; TW: Panel Link Vertical Scaling Factor */
58432 +       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x36,temp);      /* Part1_36h; Panel Link Vertical Scaling Factor */
58433         temp = (USHORT)((tempebx & 0x00030000) >> 16);
58434 +       temp &= 0x03;
58435         if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04;
58436 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x35,temp);      /* Part1_35h; TW: Panel Link Vertical Scaling Factor */
58437 +       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x35,temp);      /* Part1_35h; Panel Link Vertical Scaling Factor */
58438  
58439  #endif /* SIS315H */
58440  
58441 @@ -1434,47 +1487,50 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,U
58442    push1 = temp;                                           
58443  
58444    if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
58445 -       if(!SiS_Pr->SiS_IF_DEF_DSTN){
58446 +       if(!SiS_Pr->SiS_IF_DEF_FSTN && !SiS_Pr->SiS_IF_DEF_DSTN) {
58447                 if(HwDeviceExtension->jChipType < SIS_315H) {
58448                         if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) {
58449 -                               if(resinfo == 15) tempcx++;
58450 +                               if(resinfo == SIS_RI_1024x600) tempcx++;
58451                                 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
58452 -                                       if(resinfo == 7) tempcx++;
58453 +                                       if(resinfo == SIS_RI_800x600) tempcx++;
58454                                 }
58455                         } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) {
58456 -                               if(resinfo == 7) tempcx++;
58457 -                               if(resinfo == 8) tempcx++; /* TW: Doesnt make sense anyway... */
58458 -                       } else  if(resinfo == 8) tempcx++;
58459 +                               if(resinfo == SIS_RI_800x600)  tempcx++;
58460 +                               if(resinfo == SIS_RI_1024x768) tempcx++; /* Doesnt make sense anyway... */
58461 +                       } else  if(resinfo == SIS_RI_1024x768) tempcx++;
58462                 } else {
58463                         if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) {
58464 -                               if(resinfo == 7) tempcx++;
58465 +                               if(resinfo == SIS_RI_800x600)  tempcx++;
58466                         }
58467                 }
58468         }
58469    }
58470  
58471    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) {
58472 -     tempcx = SiS_Pr->SiS_VGAVDE;
58473 -     tempbx = SiS_Pr->SiS_VGAVDE - 1;
58474 +     if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) {
58475 +        tempcx = SiS_Pr->SiS_VGAVDE;
58476 +        tempbx = SiS_Pr->SiS_VGAVDE - 1;
58477 +     }
58478    }
58479  
58480    temp = ((tempbx & 0x0700) >> 8) << 3;
58481    temp |= ((tempcx & 0x0700) >> 8);
58482 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1D,temp);        /* Part1_1Dh; TW: Vertical Display Overflow; Control Signal */
58483 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1D,temp);        /* Part1_1Dh; Vertical Display Overflow; Control Signal */
58484  
58485    temp = tempbx & 0x00FF;
58486 -  if(SiS_Pr->SiS_IF_DEF_FSTN) temp++;
58487 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1C,temp);        /* Part1_1Ch; TW: Panel Link Vertical Display Enable End  */
58488 +  /* if(SiS_Pr->SiS_IF_DEF_FSTN) temp++;  */
58489 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1C,temp);        /* Part1_1Ch; Panel Link Vertical Display Enable End  */
58490  
58491    temp = tempcx & 0x00FF;
58492 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1B,temp);        /* Part1_1Bh; TW: Panel Link Vertical Display Enable Start  */
58493 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1B,temp);        /* Part1_1Bh; Panel Link Vertical Display Enable Start  */
58494  
58495    /* 3. Additional horizontal setup (scaling, etc) */
58496  
58497    tempecx = SiS_Pr->SiS_VGAHDE;
58498    if(HwDeviceExtension->jChipType >= SIS_315H) {
58499 -     if(modeflag & HalfDCLK)
58500 -        tempecx >>= 1;
58501 +     if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) {
58502 +        if(modeflag & HalfDCLK) tempecx >>= 1;
58503 +     }
58504    }
58505    tempebx = SiS_Pr->SiS_HDE;
58506    if(tempecx == tempebx) tempeax = 0xFFFF;
58507 @@ -1484,139 +1540,165 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr,U
58508       temp = (USHORT)(tempeax % tempebx);
58509       tempeax = tempeax / tempebx;
58510       if(HwDeviceExtension->jChipType >= SIS_315H) {
58511 -         if(temp) tempeax++;
58512 +        if(temp) tempeax++;
58513       }
58514    }
58515    tempecx = tempeax;
58516  
58517    if(HwDeviceExtension->jChipType >= SIS_315H) {
58518 -      tempeax = SiS_Pr->SiS_VGAHDE;
58519 -      if(modeflag & HalfDCLK) tempeax >>= 1;
58520 -      tempeax <<= 16;
58521 -      tempeax = (tempeax / tempecx) - 1;
58522 +     tempeax = SiS_Pr->SiS_VGAHDE;
58523 +     if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) {
58524 +        if(modeflag & HalfDCLK) tempeax >>= 1;
58525 +     }
58526 +     tempeax <<= 16;
58527 +     tempeax = (tempeax / tempecx) - 1;
58528    } else {
58529 -      tempeax = ((SiS_Pr->SiS_VGAHT << 16) / tempecx) - 1;
58530 +     tempeax = ((SiS_Pr->SiS_VGAHT << 16) / tempecx) - 1;
58531    }
58532    tempecx <<= 16;
58533    tempecx |= (tempeax & 0xFFFF);
58534    temp = (USHORT)(tempecx & 0x00FF);
58535 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1F,temp);         /* Part1_1Fh; TW: Panel Link DDA Operational Number in each horiz. line */
58536 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1F,temp);         /* Part1_1Fh; Panel Link DDA Operational Number in each horiz. line */
58537  
58538    tempbx = SiS_Pr->SiS_VDE;
58539    if(HwDeviceExtension->jChipType >= SIS_315H) {
58540 -      tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact;
58541 -      tempbx = (USHORT)(tempeax & 0x0FFFF);
58542 +     tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact;
58543 +     tempbx = (USHORT)(tempeax & 0x0FFFF);
58544    } else {
58545 -      tempax = SiS_Pr->SiS_VGAVDE << 6;
58546 -      tempbx = push1;
58547 -      tempbx &= 0x3f;
58548 -      if(tempbx == 0) tempbx = 64;
58549 -      tempax = tempax / tempbx;
58550 -      tempbx = tempax;
58551 +     tempeax = SiS_Pr->SiS_VGAVDE << 6;
58552 +     tempbx = push1 & 0x3f;
58553 +     if(tempbx == 0) tempbx = 64;
58554 +     tempeax /= tempbx;
58555 +     tempbx = (USHORT)(tempeax & 0x0FFFF);
58556    }
58557    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) tempbx--;
58558 -  if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA)                 tempbx = 1;
58559 +  if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) {
58560 +     if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) tempbx = 1;
58561 +     else if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480)  tempbx = 1;
58562 +  }
58563  
58564    temp = ((tempbx & 0xFF00) >> 8) << 3;
58565    temp |= (USHORT)((tempecx & 0x0700) >> 8);
58566 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x20,temp);        /* Part1_20h; TW: Overflow register */
58567 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x20,temp);        /* Part1_20h; Overflow register */
58568  
58569    temp = tempbx & 0x00FF;
58570 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x21,temp);        /* Part1_21h; TW: Panel Link Vertical Accumulator Register */
58571 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x21,temp);        /* Part1_21h; Panel Link Vertical Accumulator Register */
58572  
58573    tempecx >>= 16;                               /* BPLHCFACT  */
58574 -  if(HwDeviceExtension->jChipType < SIS_315H) {
58575 -      if(modeflag & HalfDCLK) tempecx >>= 1;
58576 +  if((HwDeviceExtension->jChipType < SIS_315H) || (SiS_Pr->SiS_IF_DEF_FSTN) || (SiS_Pr->SiS_IF_DEF_DSTN)) {
58577 +     if(modeflag & HalfDCLK) tempecx >>= 1;
58578    }
58579    temp = (USHORT)((tempecx & 0xFF00) >> 8);
58580 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x22,temp);        /* Part1_22h; TW: Panel Link Horizontal Scaling Factor High */
58581 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x22,temp);        /* Part1_22h; Panel Link Horizontal Scaling Factor High */
58582  
58583    temp = (USHORT)(tempecx & 0x00FF);
58584 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x23,temp);         /* Part1_22h; TW: Panel Link Horizontal Scaling Factor Low */
58585 +  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x23,temp);         /* Part1_22h; Panel Link Horizontal Scaling Factor Low */
58586  
58587    /* 630/301B and 630/LVDS do something for 640x480 panels here */
58588  
58589  #ifdef SIS315H
58590 -  /* TW: DSTN/FSTN initialisation - hardcoded for 320x480 panel */
58591 -  if(SiS_Pr->SiS_IF_DEF_DSTN) {
58592 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1E,0x01);
58593 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x25,0x00);
58594 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x26,0x00);
58595 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x27,0x00);
58596 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x28,0x87);
58597 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x29,0x5A);
58598 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2A,0x4B);
58599 -       SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x007,0x03);
58600 -       tempbx = SiS_Pr->SiS_HDE + 64;                          /*Blps = lcdhdee(lcdhdes+HDE) + 64*/
58601 -       temp = tempbx & 0x00FF;
58602 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x38,temp);
58603 -       temp=((tempbx & 0xFF00) >> 8) << 3;
58604 -       SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,~0x078,temp);
58605 -       tempbx += 32;                                           /*Blpe=lBlps+32*/
58606 -       temp = tempbx & 0x00FF;
58607 -       if(SiS_Pr->SiS_IF_DEF_FSTN)  temp=0;
58608 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x39,temp);
58609 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3A,0x00);           /*Bflml=0*/
58610 -       SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x007,0x00);
58611 -       tempbx = SiS_Pr->SiS_VDE / 2;
58612 -       temp = tempbx & 0x00FF;
58613 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3B,temp);
58614 -       temp = ((tempbx & 0xFF00) >> 8) << 3;
58615 -       SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x038,temp);
58616 -       tempeax = SiS_Pr->SiS_HDE << 2;                         /* BDxFIFOSTOP = (HDE*4)/128 */
58617 -       tempebx = 128;
58618 -       temp = (USHORT)(tempeax % tempebx);
58619 -       tempeax = tempeax / tempebx;
58620 -       if(temp != 0)  tempeax++;
58621 -       temp = (USHORT)(tempeax & 0x003F);
58622 -       SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x45,~0x0FF,temp);
58623 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3F,0x00);           /* BDxWadrst0 */
58624 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3E,0x00);
58625 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3D,0x10);
58626 -       SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x040,0x00);
58627 -       tempax = SiS_Pr->SiS_HDE >> 4;                          /* BDxWadroff = HDE*4/8/8 */
58628 -       pushcx = tempax;
58629 -       temp = tempax & 0x00FF;
58630 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x43,temp);
58631 -       temp = ((tempax & 0xFF00) >> 8) << 3;
58632 -       SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x0F8,temp);
58633 -       tempax = SiS_Pr->SiS_VDE;                             /*BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */
58634 -       tempeax = (tempax * pushcx);
58635 -       tempebx = 0x00100000 + tempeax;
58636 -       temp = (USHORT)tempebx & 0x000000FF;
58637 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x42,temp);
58638 -       temp = (USHORT)((tempebx & 0x0000FF00)>>8);
58639 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x41,temp);
58640 -       temp = (USHORT)((tempebx & 0x00FF0000)>>16);
58641 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x40,temp);
58642 -       temp = (USHORT)(((tempebx & 0x01000000)>>24) << 7);
58643 -       SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x080,temp);
58644 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2F,0x03);
58645 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x03,0x50);
58646 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x04,0x00);
58647 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2F,0x01);
58648 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x13,0x00);
58649 -       SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86);        /* Unlock */
58650 -       SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1e,0x62);
58651 -       if(SiS_Pr->SiS_IF_DEF_FSTN){
58652 -               SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2b,0x1b);
58653 -               SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2c,0xe3);
58654 -               SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1e,0x62);
58655 -               SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2e,0x04);
58656 -               SiS_SetReg1(SiS_Pr->SiS_P3c4,0x2f,0x42);
58657 -               SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,0x01);
58658 -               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2b,0x02);
58659 -               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2c,0x00);
58660 -               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2d,0x00);
58661 -       }
58662 -       SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0f,0x30);
58663 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1e,0x7d);
58664 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2e,0xe0);
58665 +  if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) {
58666 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x25,0x00);
58667 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x26,0x00);
58668 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x27,0x00);
58669 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x28,0x87);
58670 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x29,0x5A);
58671 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2A,0x4B);
58672 +     SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x007,0x03);
58673 +     tempax = SiS_Pr->SiS_HDE;                                 /* Blps = lcdhdee(lcdhdes+HDE) + 64 */
58674 +     if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 ||
58675 +        SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempax >>= 1;
58676 +     tempax += 64;
58677 +     temp = tempax & 0x00FF;
58678 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x38,temp);
58679 +     temp = ((tempax & 0xFF00) >> 8) << 3;
58680 +     SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,~0x078,temp);
58681 +     tempax += 32;                                             /* Blpe=lBlps+32 */
58682 +     temp = tempax & 0x00FF;
58683 +     if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0;
58684 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x39,temp);
58685 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3A,0x00);             /* Bflml=0 */
58686 +     SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x007,0x00);
58687 +
58688 +     tempax = SiS_Pr->SiS_VDE;
58689 +     if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 ||
58690 +        SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempax >>= 1;
58691 +     tempax >>= 1;
58692 +     temp = tempax & 0x00FF;
58693 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3B,temp);
58694 +     temp = ((tempax & 0xFF00) >> 8) << 3;
58695 +     SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x038,temp);
58696 +
58697 +     tempeax = SiS_Pr->SiS_HDE;
58698 +     if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 ||
58699 +        SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempeax >>= 1;
58700 +     tempeax <<= 2;                                            /* BDxFIFOSTOP = (HDE*4)/128 */
58701 +     tempebx = 128;
58702 +     temp = (USHORT)(tempeax % tempebx);
58703 +     tempeax = tempeax / tempebx;
58704 +     if(temp) tempeax++;
58705 +     temp = (USHORT)(tempeax & 0x003F);
58706 +     SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x45,~0x0FF,temp);
58707 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3F,0x00);             /* BDxWadrst0 */
58708 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3E,0x00);
58709 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3D,0x10);
58710 +     SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x040,0x00);
58711 +
58712 +     tempax = SiS_Pr->SiS_HDE;
58713 +     if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 ||
58714 +        SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempax >>= 1;
58715 +     tempax >>= 4;                                             /* BDxWadroff = HDE*4/8/8 */
58716 +     pushcx = tempax;
58717 +     temp = tempax & 0x00FF;
58718 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x43,temp);
58719 +     temp = ((tempax & 0xFF00) >> 8) << 3;
58720 +     SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x0F8,temp);
58721 +
58722 +     tempax = SiS_Pr->SiS_VDE;                                 /* BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */
58723 +     if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 ||
58724 +        SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) tempax >>= 1;
58725 +     tempeax = (tempax * pushcx);
58726 +     tempebx = 0x00100000 + tempeax;
58727 +     temp = (USHORT)tempebx & 0x000000FF;
58728 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x42,temp);
58729 +     temp = (USHORT)((tempebx & 0x0000FF00) >> 8);
58730 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x41,temp);
58731 +     temp = (USHORT)((tempebx & 0x00FF0000) >> 16);
58732 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x40,temp);
58733 +     temp = (USHORT)(((tempebx & 0x01000000) >> 24) << 7);
58734 +     SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x080,temp);
58735 +
58736 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2F,0x03);
58737 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x03,0x50);
58738 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x04,0x00);
58739 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2F,0x01);
58740 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x19,0x38);
58741 +
58742 +     if(SiS_Pr->SiS_IF_DEF_FSTN) {
58743 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2b,0x02);
58744 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2c,0x00);
58745 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2d,0x00);
58746 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x35,0x0c);
58747 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x36,0x00);
58748 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x37,0x00);
58749 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x38,0x80);
58750 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x39,0xA0);
58751 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3a,0x00);
58752 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3b,0xf0);
58753 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3c,0x00);
58754 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3d,0x10);
58755 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3e,0x00);
58756 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x3f,0x00);
58757 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x40,0x10);
58758 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x41,0x25);
58759 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x42,0x80);
58760 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x43,0x14);
58761 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x44,0x03);
58762 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x45,0x0a);
58763 +     }
58764    }
58765  #endif  /* SIS315H */
58766  
58767 -  return;
58768 -
58769  }
58770  
58771  #ifdef SIS315H
58772 @@ -1629,7 +1711,7 @@ SiS_CRT2AutoThreshold(SiS_Private *SiS_P
58773  
58774  
58775  #ifdef SIS315H
58776 -/* TW: For LVDS / 302B/30xLV - LCDA (this must only be called on 310/325 series!) */
58777 +/* For LVDS / 302B/30xLV - LCDA (this must only be called on 315 series!) */
58778  void
58779  SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, USHORT  BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
58780                     PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex)
58781 @@ -1638,6 +1720,10 @@ SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, 
58782    USHORT push1,push2,tempax,tempbx,tempcx,temp;
58783    ULONG tempeax=0,tempebx,tempecx,tempvcfact;
58784  
58785 +  /* This is not supported with LCDA */
58786 +  if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return;
58787 +  if(SiS_Pr->UseCustomMode) return;
58788 +
58789    if(IS_SIS330) {
58790       SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10);                    /* Xabre 1.01.03 */
58791    } else if(IS_SIS740) {
58792 @@ -1645,7 +1731,7 @@ SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, 
58793          SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x04);         /* 740/LVDS */
58794         SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x03);
58795       } else {
58796 -        SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10);                 /* 740/301LV 1.10.1i */
58797 +        SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10);                 /* 740/301LV, 301BDH */
58798       }
58799    } else {
58800       if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {                                        /* 650/LVDS */
58801 @@ -1669,10 +1755,7 @@ SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, 
58802    tempcx = SiS_Pr->SiS_HT;
58803  
58804    if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
58805 -        if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)       tempbx = 1024;
58806 -       else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) tempbx = 1400;
58807 -       else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempbx = 1600;
58808 -       else                                                          tempbx = 1280;
58809 +        tempbx = SiS_Pr->PanelXRes;
58810    }
58811    tempcx -= tempbx;                                            /* HT-HDE  */
58812    push1 = tempax;
58813 @@ -1684,7 +1767,7 @@ SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, 
58814  
58815    tempcx >>= 2;
58816  
58817 -  /* TW: 650/30xLV 1.10.6s, 740/LVDS */
58818 +  /* 650/30xLV 1.10.6s, 740/LVDS */
58819    if( ((SiS_Pr->SiS_IF_DEF_LVDS == 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) ||
58820        ((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) ) {
58821       if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) {
58822 @@ -1748,13 +1831,10 @@ SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, 
58823    tempbx = SiS_Pr->SiS_LCDVDES;                                        /* VGAVDES  */
58824    push1 = tempbx;                                                      
58825    if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) {
58826 -    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)        tempax = 768;
58827 -    else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768)   tempax = 768;
58828 -    else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024)  tempax = 1024;
58829 -    else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050)  tempax = 1050;
58830 -    else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)  tempax = 1200;
58831 -    else                                                           tempax = 960;
58832 -  } else tempax = SiS_Pr->SiS_VGAVDE;  /* Trumpion */
58833 +     tempax = SiS_Pr->PanelYRes;
58834 +  } else {
58835 +     tempax = SiS_Pr->SiS_VGAVDE;
58836 +  }
58837  
58838    tempbx += tempax;
58839    tempax = SiS_Pr->SiS_VT;                                     /* VT  */
58840 @@ -1764,7 +1844,7 @@ SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, 
58841   
58842    tempcx >>= 2;        
58843  
58844 -  /* TW: 650/30xLV 1.10.6s, 740/LVDS */
58845 +  /* 650/30xLV 1.10.6s, 740/LVDS */
58846    if( ((SiS_Pr->SiS_IF_DEF_LVDS == 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) ||
58847        ((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) ) {
58848       if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) {
58849 @@ -1806,7 +1886,7 @@ SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, 
58850    if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
58851       SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp);
58852    } else {
58853 -     /* TW: 650/30xLV 1.10.6s, Xabre */
58854 +     /* 650/30xLV 1.10.6s, Xabre */
58855       temp |= 0xC0;
58856       SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,temp);             /* Part1_19h  */
58857    }
58858 @@ -1823,7 +1903,7 @@ SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, 
58859       }
58860    } else {
58861       if(IS_SIS650) {
58862 -        /* TW: 650/30xLV 1.10.6s */
58863 +        /* 650/30xLV 1.10.6s */
58864          if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
58865             if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) temp |= 0x80;
58866          }
58867 @@ -1839,7 +1919,7 @@ SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, 
58868  
58869    if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
58870      if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) {
58871 -      if(resinfo == 7) tempcx++;
58872 +      if(resinfo == SIS_RI_800x600) tempcx++;
58873      }
58874    }
58875    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) {
58876 @@ -1925,18 +2005,17 @@ SiS_SetGroup1_LCDA(SiS_Private *SiS_Pr, 
58877    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x23,temp);
58878  
58879  #if 0
58880 -  /* TW: Missing code (calles int 2f) (650/302LV 1.10.6s; 1.10.7w doesn't do this) */
58881 +  /* Missing code (calles int 2f) (650/302LV 1.10.6s; 1.10.7w doesn't do this) */
58882    if(xxx()) {
58883        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x0e,0xda);
58884    }
58885  #endif
58886  
58887 -  /* TW: Only for LVDS and 301LV/302LV */
58888 +  /* Only for LVDS and 301LV/302LV */
58889    if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBInfo & VB_SIS301LV302LV)){
58890 -       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1e,0x20);
58891 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1e,0x20);
58892    }
58893  
58894 -  return;
58895  }
58896  #endif  /* SIS 315 */
58897  
58898 @@ -1951,10 +2030,10 @@ void SiS_SetCRT2Offset(SiS_Private *SiS_
58899  
58900    offset = SiS_GetOffset(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
58901                           HwDeviceExtension);
58902 -#if 0
58903 -  if(SiS_Pr->LCDResInfo == 13) offset >>= 1;
58904 -  if(SiS_Pr->LCDResInfo == 12) offset >>= 1;
58905 -#endif                  
58906 +
58907 +  if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 ||
58908 +     SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) offset >>= 1;
58909 +
58910    temp = (UCHAR)(offset & 0xFF);
58911    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x07,temp);
58912    temp = (UCHAR)((offset & 0xFF00) >> 8);
58913 @@ -1976,13 +2055,7 @@ SiS_GetOffset(SiS_Private *SiS_Pr, UCHAR
58914    } else {
58915       infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
58916       modeinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeInfo;
58917 -  
58918 -     if(HwDeviceExtension->jChipType < SIS_315H ) {
58919 -       index = (modeinfo >> 4) & 0xFF;
58920 -     } else {
58921 -       index = (modeinfo >> 8) & 0xFF;
58922 -     }
58923 -
58924 +     index = (modeinfo >> 8) & 0xFF;
58925       temp = SiS_Pr->SiS_ScreenOffset[index];
58926    }
58927    
58928 @@ -1992,9 +2065,8 @@ SiS_GetOffset(SiS_Private *SiS_Pr, UCHAR
58929  
58930    temp *= colordepth;
58931  
58932 -  /* TW: For 1400x1050 and 856x480 */
58933 -  if( ( ((ModeNo >= 0x26) && (ModeNo <= 0x28)) || 
58934 -        ModeNo == 0x3f || 
58935 +  if( ( ((ModeNo >= 0x26) && (ModeNo <= 0x28)) ||
58936 +        ModeNo == 0x3f ||
58937         ModeNo == 0x42 || 
58938         ModeNo == 0x45 ) ||
58939        (SiS_Pr->UseCustomMode && (SiS_Pr->CHDisplay % 16)) ) {
58940 @@ -2012,7 +2084,8 @@ SiS_GetColorDepth(SiS_Private *SiS_Pr, U
58941    SHORT  index;
58942    USHORT modeflag;
58943  
58944 -  if(SiS_Pr->UseCustomMode) {
58945 +  /* Do NOT check UseCustomMode, will skrew up FIFO */
58946 +  if(ModeNo == 0xfe) {
58947       modeflag = SiS_Pr->CModeFlag;
58948    } else {
58949       if(ModeNo <= 0x13)
58950 @@ -2035,7 +2108,11 @@ SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USH
58951    flag = 0;
58952    tempbl = 0xC0;
58953  
58954 -  infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
58955 +  if(SiS_Pr->UseCustomMode) {
58956 +     infoflag = SiS_Pr->CInfoFlag;
58957 +  } else {
58958 +     infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
58959 +  }
58960  
58961    if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {                                   /* LVDS */
58962  
58963 @@ -2044,12 +2121,19 @@ SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USH
58964      } else if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_LCDInfo & LCDSync)) {
58965         tempah = SiS_Pr->SiS_LCDInfo;
58966      } else tempah = infoflag >> 8;
58967 -    
58968 +
58969      tempah &= 0xC0;
58970 -    
58971 +
58972      tempah |= 0x20;
58973      if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
58974  
58975 +    if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
58976 +       if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) ||
58977 +          (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) {
58978 +         tempah |= 0xc0;
58979 +       }
58980 +    }
58981 +
58982      if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
58983         if(HwDeviceExtension->jChipType >= SIS_315H) {
58984            tempah >>= 3;
58985 @@ -2079,9 +2163,11 @@ SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USH
58986              tempah |= 0x20;
58987              if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
58988  
58989 +#if 0
58990              if (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) {
58991 -               /* TW: BIOS does something here @@@ */
58992 +               /* BIOS does something here @@@ */
58993              }
58994 +#endif
58995  
58996             tempah &= 0x3f;
58997             tempah |= tempbl;
58998 @@ -2089,16 +2175,11 @@ SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USH
58999  
59000           } else {                                                      /* 630 - 301 */
59001  
59002 -            if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
59003 -               tempah = SiS_Pr->SiS_LCDInfo;
59004 -              if(SiS_Pr->SiS_LCDInfo & DontExpandLCDShift) { /* ! */
59005 -                 flag = 1;
59006 -              }
59007 -            }
59008 -            if(flag != 1) tempah = infoflag >> 8;
59009 +            tempah = infoflag >> 8;
59010              tempah &= 0xC0;
59011 -            tempah |= 0x30;
59012 -            SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x3F,tempah);
59013 +            tempah |= 0x20;
59014 +           if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
59015 +            SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah);
59016  
59017           }
59018  
59019 @@ -2106,34 +2187,50 @@ SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USH
59020  
59021        } else {
59022  
59023 -#ifdef SIS315H  /* ----- 310/325 series ---- */
59024 +#ifdef SIS315H  /* ------- 315 series ------ */
59025  
59026 -         if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {                   /* 310/325 - 30xLV */
59027 +         if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {                   /* 315 - 30xLV */
59028 +
59029 +           if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
59030 +              tempah = infoflag >> 8;
59031 +              if(SiS_Pr->SiS_LCDInfo & LCDSync) {
59032 +                 tempah = SiS_Pr->SiS_LCDInfo;
59033 +              }
59034 +           } else {
59035 +               tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37);
59036 +           }
59037 +           tempah &= 0xC0;
59038  
59039 -            tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37);
59040 -            tempah &= 0xC0;
59041              tempah |= 0x20;
59042              if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
59043              SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah);
59044  
59045 -         } else {                                                      /* 310/325 - 301, 301B */
59046 +         } else {                                                      /* 315 - 301, 301B */
59047  
59048              tempah = infoflag >> 8;
59049 -            tempah &= 0xC0;
59050 -           if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
59051 -              if(SiS_Pr->SiS_LCDInfo & LCDSync) {
59052 -                 tempah = SiS_Pr->SiS_LCDInfo;
59053 -                 tempah &= 0xC0;
59054 +           if(!SiS_Pr->UseCustomMode) {
59055 +              if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
59056 +                 if(SiS_Pr->SiS_LCDInfo & LCDSync) {
59057 +                    tempah = SiS_Pr->SiS_LCDInfo;
59058 +                 }
59059                }
59060             }
59061 +           tempah &= 0xC0;
59062             
59063              tempah |= 0x20;
59064              if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
59065 +
59066  #if 0
59067              if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) {
59068 -               /* TW: BIOS does something here @@@ */
59069 +               /* BIOS does something here @@@ */
59070              }
59071 -#endif     
59072 +#endif
59073 +
59074 +           if(SiS_Pr->SiS_VBType & VB_NoLCD) {                 /* TEST, imitate BIOS bug */
59075 +              if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
59076 +                 tempah |= 0xc0;
59077 +              }
59078 +           }
59079              SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah);
59080  
59081           } 
59082 @@ -2143,7 +2240,7 @@ SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USH
59083     }
59084  }
59085  
59086 -/* TW: Set CRT2 FIFO on 300/630/730 */
59087 +/* Set CRT2 FIFO on 300/630/730 */
59088  #ifdef SIS300
59089  void
59090  SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,
59091 @@ -2197,7 +2294,7 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,
59092  
59093    if(!SiS_Pr->CRT1UsesCustomMode) {
59094    
59095 -     CRT1ModeNo = SiS_Pr->SiS_CRT1Mode;                                 /* get CRT1 ModeNo */
59096 +     CRT1ModeNo = SiS_Pr->SiS_CRT1Mode;                                        /* get CRT1 ModeNo */
59097       SiS_SearchModeID(SiS_Pr,ROMAddr,&CRT1ModeNo,&modeidindex);
59098       SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2);
59099       SiS_Pr->SiS_SelectCRT2Rate = 0;
59100 @@ -2205,20 +2302,32 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,
59101                                                 modeidindex,HwDeviceExtension);
59102  
59103       if(CRT1ModeNo >= 0x13) {
59104 -       index = SiS_Pr->SiS_RefIndex[refreshratetableindex].Ext_CRTVCLK;
59105 -       index &= 0x3F;
59106 -       VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK;                       /* Get VCLK */
59107 -       data2 = SiS_Pr->SiS_ModeType - 2;
59108 +        index = SiS_Pr->SiS_RefIndex[refreshratetableindex].Ext_CRTVCLK;
59109 +        index &= 0x3F;
59110 +        VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK;                              /* Get VCLK */
59111 +
59112 +       colorth = SiS_GetColorDepth(SiS_Pr,ROMAddr,CRT1ModeNo,modeidindex);     /* Get colordepth */
59113 +        colorth >>= 1;
59114 +        if(!colorth) colorth++;
59115       }
59116 -     
59117 +
59118    } else {
59119    
59120       CRT1ModeNo = 0xfe;
59121 -     VCLK = SiS_Pr->CSRClock;                                          /* Get VCLK */
59122 -     data2 = (SiS_Pr->CModeFlag & ModeInfoFlag) - 2;
59123 -  
59124 -  }                    
59125 -     
59126 +     VCLK = SiS_Pr->CSRClock_CRT1;                                             /* Get VCLK */
59127 +     data2 = (SiS_Pr->CModeFlag_CRT1 & ModeInfoFlag) - 2;
59128 +     switch(data2) {                                                           /* Get color depth */
59129 +        case 0 : colorth = 1; break;
59130 +        case 1 : colorth = 1; break;
59131 +        case 2 : colorth = 2; break;
59132 +        case 3 : colorth = 2; break;
59133 +        case 4 : colorth = 3; break;
59134 +        case 5 : colorth = 4; break;
59135 +        default: colorth = 2;
59136 +     }
59137 +
59138 +  }
59139 +
59140    if(CRT1ModeNo >= 0x13) {
59141      if(HwDeviceExtension->jChipType == SIS_300) {
59142         index = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A);
59143 @@ -2227,22 +2336,8 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,
59144      }
59145      index &= 0x07;
59146      MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK;                                /* Get MCLK */
59147 -    
59148 -#ifdef TWDEBUG
59149 -    xf86DrvMsg(0, X_INFO, "FIFO2: CRT1Mode 0x%x VCLK %d MCLK %d modetype-2 = %d\n",
59150 -       CRT1ModeNo, VCLK, MCLK, data2);
59151 -#endif  
59152 -  
59153 -    switch(data2) {                                                    /* Get color depth */
59154 -      case 0 :         colorth = 1; break;
59155 -      case 1 :         colorth = 1; break;
59156 -      case 2 :         colorth = 2; break;
59157 -      case 3 :         colorth = 2; break;
59158 -      case 4 :         colorth = 3; break;
59159 -      case 5 :         colorth = 4; break;
59160 -      default:  colorth = 2; break;
59161 -    }
59162 -    data2 = (colorth * VCLK) / MCLK;  
59163 +
59164 +    data2 = (colorth * VCLK) / MCLK;
59165  
59166      temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14);
59167      temp = ((temp & 0x00FF) >> 6) << 1;
59168 @@ -2252,22 +2347,12 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,
59169  
59170      data2 = temp - data2;
59171      
59172 -#ifdef TWDEBUG
59173 -    xf86DrvMsg(0, X_INFO, "FIFO2: data2 (step1) = %d\n",
59174 -       data2);
59175 -#endif    
59176 -
59177      if((28 * 16) % data2) {
59178         data2 = (28 * 16) / data2;
59179         data2++;
59180      } else {
59181         data2 = (28 * 16) / data2;
59182      }
59183 -    
59184 -#ifdef TWDEBUG
59185 -    xf86DrvMsg(0, X_INFO, "FIFO2: data2 (step2) = %d\n",
59186 -       data2);
59187 -#endif
59188  
59189      if(HwDeviceExtension->jChipType == SIS_300) {
59190  
59191 @@ -2313,10 +2398,6 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,
59192         temp &= 0x0F;   
59193         tempal |= temp;
59194  
59195 -#ifdef TWDEBUG
59196 -       xf86DrvMsg(0, X_INFO, "FIFO2: Latencyfactorindex = 0x%x\n", tempal);
59197 -#endif
59198 -      
59199         tempbx = tempal;   /* BIOS BUG (2.04.5d, 2.04.6a use ah here, which is unset!) */
59200         tempbx = 0;        /* -- do it like the BIOS anyway... */
59201         tempax = tempbx;
59202 @@ -2341,7 +2422,7 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,
59203         SiS_SetReg4(0xcf8,0x800000A0);
59204         eax = SiS_GetReg3(0xcfc);
59205  #else
59206 -       /* TW: We use pci functions X offers. We use tag 0, because
59207 +       /* We use pci functions X offers. We use tag 0, because
59208          * we want to read/write to the host bridge (which is always
59209          * 00:00.0 on 630, 730 and 540), not the VGA device.
59210          */
59211 @@ -2368,43 +2449,41 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,
59212         if(!(temp & 0x80)) data += 5;
59213      }
59214      
59215 -#ifdef TWDEBUG    
59216 -    xf86DrvMsg(0, X_INFO, "FIFO2: latencyfactor (CRT1) = %d\n", data);
59217 -#endif
59218 -
59219      data += data2;                             /* CRT1 Request Period */
59220      
59221 -#ifdef TWDEBUG    
59222 -    xf86DrvMsg(0, X_INFO, "FIFO2: CRT1 request period = %d\n", data);
59223 -#endif
59224 -
59225 -    CRT2ModeNo = ModeNo;
59226      SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
59227      SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup;
59228 -    SiS_SearchModeID(SiS_Pr,ROMAddr,&CRT2ModeNo,&modeidindex);    
59229  
59230 -    refreshratetableindex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT2ModeNo,
59231 -                                               modeidindex,HwDeviceExtension);
59232 +    if(!SiS_Pr->UseCustomMode) {
59233 +
59234 +       CRT2ModeNo = ModeNo;
59235 +       SiS_SearchModeID(SiS_Pr,ROMAddr,&CRT2ModeNo,&modeidindex);
59236 +
59237 +       refreshratetableindex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT2ModeNo,
59238 +                                                  modeidindex,HwDeviceExtension);
59239 +
59240 +       index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,CRT2ModeNo,modeidindex,
59241 +                               refreshratetableindex,HwDeviceExtension);
59242 +       VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK;                               /* Get VCLK  */
59243 +
59244 +       if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) {
59245 +          if((ROMAddr) && SiS_Pr->SiS_UseROM) {
59246 +            if(ROMAddr[0x220] & 0x01) {
59247 +                VCLK = ROMAddr[0x229] | (ROMAddr[0x22a] << 8);
59248 +            }
59249 +          }
59250 +       }
59251 +
59252 +    } else {
59253 +
59254 +       CRT2ModeNo = 0xfe;
59255 +       VCLK = SiS_Pr->CSRClock;                                                        /* Get VCLK */
59256  
59257 -    index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,CRT2ModeNo,modeidindex,
59258 -                            refreshratetableindex,HwDeviceExtension);
59259 -    VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK;                          /* Get VCLK  */
59260 -    
59261 -    data2 = SiS_Pr->SiS_ModeType - 2;
59262 -    switch(data2) {                                                    /* Get color depth */
59263 -      case 0 :         colorth = 1; break;
59264 -      case 1 :         colorth = 1; break;
59265 -      case 2 :         colorth = 2; break;
59266 -      case 3 :         colorth = 2; break;
59267 -      case 4 :         colorth = 3; break;
59268 -      case 5 :         colorth = 4; break;
59269 -      default:  colorth = 2; break;
59270      }
59271 -    
59272 -#ifdef TWDEBUG    
59273 -    xf86DrvMsg(0, X_INFO, "FIFO2: CRT2Mode 0x%x VCLK %d MCLK %d modetype-2 = %d, colorth %d\n",
59274 -       CRT2ModeNo, VCLK, MCLK, data2, colorth);
59275 -#endif
59276 +
59277 +    colorth = SiS_GetColorDepth(SiS_Pr,ROMAddr,CRT2ModeNo,modeidindex);        /* Get colordepth */
59278 +    colorth >>= 1;
59279 +    if(!colorth) colorth++;
59280  
59281      data = data * VCLK * colorth;
59282      if(data % (MCLK << 4)) {
59283 @@ -2414,10 +2493,6 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,
59284         data = data / (MCLK << 4);
59285      }
59286      
59287 -#ifdef TWDEBUG    
59288 -    xf86DrvMsg(0, X_INFO, "FIFO2: data (unclipped) = 0x%x\n", data);
59289 -#endif    
59290 -    
59291      if(data <= 6) data = 6;
59292      if(data > 0x14) data = 0x14;
59293  
59294 @@ -2456,13 +2531,13 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,
59295  }
59296  #endif
59297  
59298 -/* TW: Set FIFO on 310/325/330 series */
59299 +/* Set FIFO on 315/330 series */
59300  #ifdef SIS315H
59301  void
59302  SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,
59303                      PSIS_HW_DEVICE_INFO HwDeviceExtension)
59304  {
59305 -
59306 +#if 0   /* This code is obsolete */
59307    UCHAR CombCode[]  = { 1, 1, 1, 4, 3, 1, 3, 4,
59308                          4, 1, 4, 4, 5, 1, 5, 4};
59309    UCHAR CRT2ThLow[] = { 39, 63, 55, 79, 78,102, 90,114,
59310 @@ -2474,11 +2549,13 @@ SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr,
59311    USHORT ModeIdIndex;
59312    USHORT RefreshRateTableIndex;
59313    USHORT SelectRate_backup;
59314 -  
59315 +
59316    SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate;
59317 -  
59318 +#endif
59319 +
59320    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x01,0x3B);
59321  
59322 +#if 0
59323    if(!SiS_Pr->CRT1UsesCustomMode) {
59324    
59325       CRT1ModeNo = SiS_Pr->SiS_CRT1Mode;                                 /* get CRT1 ModeNo */
59326 @@ -2489,28 +2566,27 @@ SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr,
59327  
59328       /* Get REFIndex for crt1 refreshrate */
59329       RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT1ModeNo,
59330 -                                             ModeIdIndex,HwDeviceExtension);
59331 +                                                ModeIdIndex,HwDeviceExtension);
59332 +     index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
59333 +     tempax = SiS_Pr->SiS_VCLKData[index].CLOCK;                       /* Get VCLK */
59334  
59335 -     index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,CRT1ModeNo,ModeIdIndex,
59336 -                          RefreshRateTableIndex,HwDeviceExtension);
59337 -     tempax = SiS_Pr->SiS_VCLKData[index].CLOCK;                        /* Get VCLK */
59338 -     
59339       tempbx = SiS_GetColorDepth(SiS_Pr,ROMAddr,CRT1ModeNo,ModeIdIndex); /* Get colordepth */
59340       tempbx >>= 1;
59341 -     if(!tempbx) tempbx++; 
59342 -     
59343 +     if(!tempbx) tempbx++;
59344 +
59345    } else {
59346 -  
59347 -     tempax = SiS_Pr->CSRClock;                                                /* Get VCLK */
59348 -     tempbx = (SiS_Pr->CModeFlag & ModeInfoFlag) - 2;
59349 +
59350 +     CRT1ModeNo = 0xfe;
59351 +     tempax = SiS_Pr->CSRClock_CRT1;                                   /* Get VCLK */
59352 +     tempbx = (SiS_Pr->CModeFlag_CRT1 & ModeInfoFlag) - 2;
59353       switch(tempbx) {                                                  /* Get color depth */
59354 -       case 0 :        tempbx = 1; break;
59355 -       case 1 :        tempbx = 1; break;
59356 -       case 2 :        tempbx = 2; break;
59357 -       case 3 :        tempbx = 2; break;
59358 -       case 4 :        tempbx = 3; break;
59359 -       case 5 :        tempbx = 4; break;
59360 -       default:        tempbx = 2; break;
59361 +       case 0 : tempbx = 1; break;
59362 +       case 1 : tempbx = 1; break;
59363 +       case 2 : tempbx = 2; break;
59364 +       case 3 : tempbx = 2; break;
59365 +       case 4 : tempbx = 3; break;
59366 +       case 5 : tempbx = 4; break;
59367 +       default: tempbx = 2;
59368       }
59369    
59370    }
59371 @@ -2523,13 +2599,6 @@ SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr,
59372  
59373    tempbx = tempax;
59374  
59375 -#if 0 /* TW: BIOS code is skrewed */
59376 -  if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14) & 0x02) {
59377 -       tempax = 16;
59378 -  } else {
59379 -       tempax = 8;
59380 -  }
59381 -#endif
59382    tempax = 16;
59383  
59384    tempax -= tempbx;
59385 @@ -2556,24 +2625,33 @@ SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr,
59386  
59387    tempcx +=  temp3;                                      /* CRT1 Request Period */
59388  
59389 -  CRT2ModeNo = ModeNo;                                                 /* get CRT2 ModeNo */
59390 -  SiS_SearchModeID(SiS_Pr,ROMAddr,&CRT2ModeNo,&ModeIdIndex);           /* Get ModeID Table */
59391 -
59392    SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
59393    SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup;
59394  
59395 -  RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT2ModeNo,
59396 -                                           ModeIdIndex,HwDeviceExtension);
59397 +  if(!SiS_Pr->UseCustomMode) {
59398 +
59399 +     CRT2ModeNo = ModeNo;                                                 /* get CRT2 ModeNo */
59400 +     SiS_SearchModeID(SiS_Pr,ROMAddr,&CRT2ModeNo,&ModeIdIndex);
59401 +
59402 +     RefreshRateTableIndex = SiS_GetRatePtrCRT2(SiS_Pr,ROMAddr,CRT2ModeNo,
59403 +                                                ModeIdIndex,HwDeviceExtension);
59404 +
59405 +     index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,CRT2ModeNo,ModeIdIndex,
59406 +                             RefreshRateTableIndex,HwDeviceExtension);
59407 +     if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
59408 +        tempax = SiS_Pr->SiS_VCLKData[index].CLOCK;                       /* Get VCLK  */
59409 +     } else {
59410 +        tempax = SiS_Pr->SiS_VBVCLKData[index].CLOCK;
59411 +     }
59412  
59413 -  index = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,CRT2ModeNo,ModeIdIndex,
59414 -                          RefreshRateTableIndex,HwDeviceExtension);
59415 -  if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
59416 -     tempax = SiS_Pr->SiS_VCLKData[index].CLOCK;                       /* Get VCLK  */
59417    } else {
59418 -     tempax = SiS_Pr->SiS_VBVCLKData[index].CLOCK;                     /* Get VCLK  */
59419 +
59420 +     CRT2ModeNo = 0xfe;                                                          /* Get VCLK  */
59421 +     tempax = SiS_Pr->CSRClock;
59422 +
59423    }
59424  
59425 -  tempbx = SiS_GetColorDepth(SiS_Pr,ROMAddr,CRT2ModeNo,ModeIdIndex);   /* Get colordepth */
59426 +  tempbx = SiS_GetColorDepth(SiS_Pr,ROMAddr,CRT2ModeNo,ModeIdIndex);             /* Get colordepth */
59427    tempbx >>= 1;
59428    if(!tempbx) tempbx++;
59429  
59430 @@ -2590,12 +2668,16 @@ SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr,
59431  
59432    if (tempax > 0x37)  tempax = 0x37;
59433  
59434 -  /* TW: 650/LVDS (1.10.07, 1.10.00), 650/301LV, 740, 330 overrule calculated value; 315 does not */
59435 +  /* 650/LVDS, 650/301LV, 740, 330 overrule calculated value; 315 does not */
59436    if(HwDeviceExtension->jChipType >= SIS_650) {
59437         tempax = 0x04;
59438    }
59439 -  
59440    SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,~0x3F,tempax);
59441 +#else
59442 +
59443 +  SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,~0x3F,0x04);
59444 +
59445 +#endif
59446  }
59447  
59448  USHORT
59449 @@ -2611,9 +2693,10 @@ SiS_GetMCLK(SiS_Private *SiS_Pr, UCHAR *
59450      return(SiS_Pr->SiS_MCLKData_0[index].CLOCK);
59451    }
59452  }
59453 +
59454  #endif
59455  
59456 -/* TW: Checked against 650/LVDS 1.10.07 BIOS */
59457 +/* Checked against 650/LVDS 1.10.07 BIOS */
59458  void
59459  SiS_GetLVDSDesData(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
59460                     USHORT RefreshRateTableIndex,
59461 @@ -2623,7 +2706,15 @@ SiS_GetLVDSDesData(SiS_Private *SiS_Pr, 
59462    USHORT PanelIndex,ResIndex;
59463    const  SiS_LVDSDesStruct *PanelDesPtr = NULL;
59464  
59465 -  if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) ) {
59466 +  if((SiS_Pr->UseCustomMode) ||
59467 +     (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) ||
59468 +     (SiS_Pr->SiS_CustomT == CUT_PANEL848)) {
59469 +     SiS_Pr->SiS_LCDHDES = 0;
59470 +     SiS_Pr->SiS_LCDVDES = 0;
59471 +     return;
59472 +  }
59473 +
59474 +  if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
59475  
59476  #ifdef SIS315H  
59477       SiS_GetLVDSDesPtrA(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
59478 @@ -2689,11 +2780,11 @@ SiS_GetLVDSDesData(SiS_Private *SiS_Pr, 
59479         case 52: PanelDesPtr = SiS_Pr->SiS_CHTVUPALDesData;    break;
59480         case 53: PanelDesPtr = SiS_Pr->SiS_CHTVOPALDesData;    break;
59481         default:
59482 -               if(HwDeviceExtension->jChipType < SIS_315H)
59483 -                  PanelDesPtr = SiS_Pr->SiS_PanelType0e_1;
59484 -               else
59485 -                  PanelDesPtr = SiS_Pr->SiS_PanelType01_1;
59486 -               break;
59487 +                if(HwDeviceExtension->jChipType < SIS_315H)
59488 +                   PanelDesPtr = SiS_Pr->SiS_PanelType0e_1;
59489 +                else
59490 +                   PanelDesPtr = SiS_Pr->SiS_PanelType01_1;
59491 +                break;
59492       }
59493    }
59494    SiS_Pr->SiS_LCDHDES = (PanelDesPtr+ResIndex)->LCDHDES;
59495 @@ -2710,7 +2801,7 @@ SiS_GetLVDSDesData(SiS_Private *SiS_Pr, 
59496       } else {
59497          if(!(SiS_Pr->SiS_SetFlag & SetDOSMode)) {
59498             if( (HwDeviceExtension->jChipType < SIS_315H) || 
59499 -              (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) ) {  
59500 +              (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) ) {
59501                if(SiS_Pr->SiS_LCDResInfo >= SiS_Pr->SiS_Panel1024x768){
59502                   if(ModeNo <= 0x13) {
59503                     modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
59504 @@ -2737,7 +2828,7 @@ SiS_GetLVDSDesData(SiS_Private *SiS_Pr, 
59505          }
59506       }
59507    }
59508 -  return;
59509 +
59510  }
59511  
59512  void
59513 @@ -2757,11 +2848,11 @@ SiS_GetLVDSDesPtr(SiS_Private *SiS_Pr, U
59514  
59515    tempbx = 0;
59516    if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
59517 -     if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
59518 +     if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
59519          tempbx = 50;
59520          if((SiS_Pr->SiS_VBInfo & SetPALTV) && (!SiS_Pr->SiS_CHPALM)) tempbx += 2;
59521          if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1;
59522 -        /* TW: Nothing special needed for SOverscan    */
59523 +        /* Nothing special needed for SOverscan    */
59524          /*     PALM uses NTSC data, PALN uses PAL data */
59525       }
59526    }
59527 @@ -2773,7 +2864,7 @@ SiS_GetLVDSDesPtr(SiS_Private *SiS_Pr, U
59528          if(modeflag & HalfDCLK) tempbx++;
59529       }
59530    }
59531 -  /* TW: 630/LVDS and 650/LVDS (1.10.07) BIOS */
59532 +  /* 630/LVDS and 650/LVDS (1.10.07) BIOS */
59533    if(SiS_Pr->SiS_SetFlag & SetDOSMode) {
59534       if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480)  {
59535          tempal = 0x07;
59536 @@ -2833,14 +2924,13 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr,
59537       }
59538    }
59539    
59540 -  /* TW: BIOS does not do this (neither 301 nor LVDS) */
59541 +  /* BIOS does not do this (neither 301 nor LVDS) */
59542    /*     (But it's harmless; see SetCRT2Offset) */
59543    SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x03,0x00);   /* fix write part1 index 0  BTDRAM bit Bug */
59544  
59545 -  /* TW: Removed 301B302B301LV302LV check here to match 650/LVDS BIOS */
59546    if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
59547  
59548 -       /* TW:   1. for LVDS/302B/302LV **LCDA** */
59549 +       /*   1. for LVDS/302B/302LV **LCDA** */
59550  
59551        SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xAF,0x40); /* FUNCTION CONTROL */
59552        SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2E,0xF7);
59553 @@ -2855,23 +2945,23 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr,
59554  
59555  #ifdef SIS300    /* ---- 300 series ---- */
59556  
59557 -      /* For 301BDH: */
59558 +      /* For 301BDH: (with LCD via LVDS) */
59559        if(SiS_Pr->SiS_VBType & VB_NoLCD) {
59560 -         temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32);
59561 -         temp &= 0xef;
59562 -         temp |= 0x02;
59563 -         if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) || (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) {
59564 -            temp |= 0x10;
59565 -            temp &= 0xfd;
59566 -         }
59567 -         SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp);
59568 +        temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32);
59569 +        temp &= 0xef;
59570 +        temp |= 0x02;
59571 +        if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) || (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) {
59572 +           temp |= 0x10;
59573 +           temp &= 0xfd;
59574 +        }
59575 +        SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp);
59576        }
59577  
59578        if(ModeNo > 0x13) {
59579 -        tempcl -= ModeVGA;
59580 -        if((tempcl > 0) || (tempcl == 0)) {      /* TW: tempcl is USHORT -> always true! */
59581 -           tempah = ((0x10 >> tempcl) | 0x80);
59582 -        }
59583 +         tempcl -= ModeVGA;
59584 +         if((tempcl > 0) || (tempcl == 0)) {      /* tempcl is USHORT -> always true! */
59585 +            tempah = ((0x10 >> tempcl) | 0x80);
59586 +         }
59587        } else tempah = 0x80;
59588  
59589        if(SiS_Pr->SiS_VBInfo & SetInSlaveMode)  tempah ^= 0xA0;
59590 @@ -2880,7 +2970,7 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr,
59591  
59592      } else {
59593  
59594 -#ifdef SIS315H    /* ---- 310/325/330 series ---- */
59595 +#ifdef SIS315H    /* ------- 315/330 series ------ */
59596  
59597        if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
59598           if(SiS_Pr->SiS_VBInfo & CRT2DisplayFlag) {
59599 @@ -2889,12 +2979,12 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr,
59600        }
59601  
59602        if(ModeNo > 0x13) {
59603 -        tempcl -= ModeVGA;
59604 -        if((tempcl > 0) || (tempcl == 0)) {  /* TW: tempcl is USHORT -> always true! */
59605 -           tempah = (0x08 >> tempcl);
59606 -           if (tempah == 0) tempah = 1;
59607 -           tempah |= 0x40;
59608 -        }
59609 +         tempcl -= ModeVGA;
59610 +         if((tempcl > 0) || (tempcl == 0)) {  /* tempcl is USHORT -> always true! */
59611 +            tempah = (0x08 >> tempcl);
59612 +            if (tempah == 0) tempah = 1;
59613 +            tempah |= 0x40;
59614 +         }
59615        } else tempah = 0x40;
59616  
59617        if(SiS_Pr->SiS_VBInfo & SetInSlaveMode)  tempah ^= 0x50;
59618 @@ -2921,7 +3011,7 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr,
59619  
59620      if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
59621  
59622 -       /* TW:   2. for 301 (301B, 302B 301LV, 302LV non-LCDA) */
59623 +       /*   2. for 301 (301B, 302B 301LV, 302LV non-LCDA) */
59624  
59625         tempah = 0x01;
59626         if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
59627 @@ -2938,7 +3028,7 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr,
59628  
59629         if(HwDeviceExtension->jChipType < SIS_315H) {
59630  
59631 -               /* --- 300 series --- */
59632 +               /* ---- 300 series ---- */
59633  
59634                 tempah = (tempah << 5) & 0xFF;
59635                 SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x01,tempah);
59636 @@ -2946,7 +3036,7 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr,
59637  
59638         } else {
59639  
59640 -               /* --- 310 series --- */
59641 +               /* ---- 315 series ---- */
59642  
59643                 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF8,tempah);
59644  
59645 @@ -2956,9 +3046,9 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr,
59646                 tempah |= 0x10;
59647         }
59648  
59649 -       /* TW: 630/301 BIOS */
59650         if((HwDeviceExtension->jChipType < SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301)) {
59651 -               if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
59652 +               if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) ||
59653 +                  (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960)) {
59654                         tempah |= 0x80;
59655                 }
59656         } else {
59657 @@ -2996,28 +3086,31 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr,
59658               }
59659            }
59660         }
59661 -       /* TW: For 302LV dual-channel */
59662 +
59663 +       /* For 302LV dual-channel */
59664         if(HwDeviceExtension->jChipType >= SIS_315H) {
59665 -           if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
59666 -               if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04)
59667 -                   tempah |= 0x40;
59668 -           }
59669 +          if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
59670 +             if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04)
59671 +                tempah |= 0x40;
59672 +          }
59673         }
59674  
59675         if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) ||
59676 -          (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960)) {
59677 -               tempah |= 0x80;
59678 +          (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960)  ||
59679 +          ((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) &&
59680 +           (SiS_Pr->CP_MaxX >= 1280) && (SiS_Pr->CP_MaxY >= 960))) {
59681 +          tempah |= 0x80;
59682         }
59683  
59684         SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0C,tempah);
59685  
59686      } else {
59687  
59688 -       /* TW: 3. for LVDS */
59689 +       /* 3. for LVDS */
59690  
59691         if(HwDeviceExtension->jChipType >= SIS_315H) {
59692  
59693 -          /* TW: Inserted this entire section (BIOS 650/LVDS); added ModeType check
59694 +          /* Inserted this entire section (BIOS 650/LVDS); added ModeType check
59695             *     (LVDS can only be slave in 8bpp modes)
59696             */
59697            tempah = 0x80;
59698 @@ -3043,7 +3136,7 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr,
59699  
59700         } else {
59701  
59702 -          /* TW: (added ModeType check) */
59703 +          /* (added ModeType check) */
59704            tempah = 0;
59705            if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) {
59706                           tempah |= 0x02;
59707 @@ -3060,50 +3153,69 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr,
59708  
59709    }
59710  
59711 -  /* TW: Inserted the entire following section */
59712 +  /* Inserted the entire following section */
59713  
59714    if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
59715  
59716        if(HwDeviceExtension->jChipType >= SIS_315H) {
59717  
59718  #ifdef SIS315H
59719 +
59720 +         unsigned char bridgerev = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x01);;
59721 +
59722 +        /* The following is nearly unpreditable and varies from machine
59723 +         * to machine. Especially the 301DH seems to be a real trouble
59724 +         * maker. Some BIOSes simply set the registers (like in the
59725 +         * NoLCD-if-statements here), some set them according to the
59726 +         * LCDA stuff. It is very likely that some machines are not
59727 +         * treated correctly in the following, very case-orientated
59728 +         * code. What do I do then...?
59729 +         */
59730 +
59731 +        /* 740 variants match for 30xB, 301B-DH, 30xLV */
59732 +
59733           if(!(IS_SIS740)) {
59734              tempah = 0x04;                                                /* For all bridges */
59735              tempbl = 0xfb;
59736              if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
59737                 tempah = 0x00;
59738 -              if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr))
59739 +              if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr)) {
59740                   tempbl = 0xff;
59741 +              }
59742              }
59743              SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah);   
59744          }
59745 -        
59746 -        if(IS_SIS740) {                                                
59747 +
59748 +        /* The following two are responsible for eventually wrong colors
59749 +         * in TV output. The DH (VB_NoLCD) conditions are unknown; the
59750 +         * b0 was found in some 651 machine (Pim); the b1 version in a
59751 +         * 650 box (Jake). What is the criteria?
59752 +         */
59753 +
59754 +        if(IS_SIS740) {
59755             tempah = 0x30;
59756             tempbl = 0xcf;
59757             if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) {
59758                tempah = 0x00;
59759             }
59760 -           SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah);    
59761 +           SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah);
59762 +        } else if(SiS_Pr->SiS_VBType & VB_SIS301) {
59763 +           /* Fixes "TV-blue-bug" on 315+301 */
59764 +           SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xCF);          /* For 301   */
59765 +        } else if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
59766 +           SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xCF,0x30);   /* For 30xLV */
59767 +        } else if((SiS_Pr->SiS_VBType & VB_NoLCD) && (bridgerev == 0xb0)) {
59768 +           SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xCF,0x30);   /* For 30xB-DH rev b0 (or "DH on 651"?) */
59769          } else {
59770 -           /* TW: This in order to fix "TV-blue-bug" on 315+301 */
59771 -            if(SiS_Pr->SiS_VBType & VB_SIS301) {
59772 -              SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xCF);             /* For 301   */
59773 -           } else {
59774 -              if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
59775 -                 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xCF,0x30);   /* For 30xLV */
59776 -              } else {
59777 -                 tempah = 0x30;                                           /* For 301B  */
59778 -                 tempbl = 0xcf;
59779 -                 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
59780 -                    tempah = 0x00;
59781 -                    if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr)) {
59782 -                       tempbl = 0xff;
59783 -                    }
59784 -                 }
59785 -                 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah);    
59786 +           tempah = 0x30;                                           /* For 30xB (and 301BDH rev b1) */
59787 +           tempbl = 0xcf;
59788 +           if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
59789 +              tempah = 0x00;
59790 +              if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr)) {
59791 +                 tempbl = 0xff;
59792                }
59793             }
59794 +           SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah);
59795          }
59796  
59797          if(IS_SIS740) {
59798 @@ -3111,25 +3223,25 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr,
59799             tempbl = 0x3f;
59800             if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) {
59801                tempah = 0x00;
59802 -           } 
59803 -           SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl,tempah);     
59804 +           }
59805 +           SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl,tempah);
59806 +        } else if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
59807 +           SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,0xc0);      /* For 30xLV */
59808 +        } else if((SiS_Pr->SiS_VBType & VB_NoLCD) && (bridgerev == 0xb0)) {
59809 +           SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,0xc0);      /* For 30xB-DH rev b0 (or "DH on 651"? */
59810          } else {
59811 -           if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {                 /* For 30xLV */
59812 -              SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,0xc0);
59813 -           } else {                                                    /* For 301, 301B */ 
59814 -               tempah = 0xc0;
59815 -               tempbl = 0x3f;
59816 -               if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
59817 -                  tempah = 0x00;
59818 -                  if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr)) {
59819 -                     tempbl = 0xff;
59820 -                  }
59821 -               }
59822 -               SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl,tempah);     
59823 +           tempah = 0xc0;                                              /* For 301, 301B (and 301BDH rev b1) */
59824 +           tempbl = 0x3f;
59825 +           if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
59826 +              tempah = 0x00;
59827 +              if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr)) {
59828 +                 tempbl = 0xff;
59829 +              }
59830             }
59831 +           SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl,tempah);
59832          }
59833  
59834 -        if(IS_SIS740) {                                                
59835 +        if(IS_SIS740) {
59836             tempah = 0x80;
59837             tempbl = 0x7f;
59838             if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) {
59839 @@ -3141,8 +3253,9 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr,
59840              tempbl = 0x7f;
59841              if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
59842                 tempbl = 0xff;
59843 -              if(!(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr)))
59844 +              if(!(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr))) {
59845                   tempah |= 0x80;
59846 +              }
59847              }
59848              SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah);
59849          }
59850 @@ -3174,16 +3287,32 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr,
59851             tempbl = 0xfb;
59852              if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
59853                 tempah = 0x00;
59854 -              if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr))
59855 +              if(SiS_IsDualEdge(SiS_Pr, HwDeviceExtension, BaseAddr)) {
59856                   tempbl = 0xff;
59857 +              }
59858              }
59859             SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah);
59860  
59861 -           if(SiS_Pr->SiS_VBInfo & DisableCRT2Display)
59862 +           if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) {
59863                SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xfb,0x00);
59864 +           }
59865  
59866             SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xcf,0x30);
59867  
59868 +        } else if(HwDeviceExtension->jChipType == SIS_550) {
59869 +
59870 +#if 0
59871 +           tempah = 0x00;
59872 +           tempbl = 0xfb;
59873 +           if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) {
59874 +              tempah = 0x00;
59875 +              tempbl = 0xfb;
59876 +           }
59877 +           SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah);
59878 +#endif
59879 +           SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb);
59880 +
59881 +           SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,0xcf,0x30);
59882          }
59883  
59884        }
59885 @@ -3209,10 +3338,9 @@ SiS_GetCRT2Data(SiS_Private *SiS_Pr, UCH
59886                               HwDeviceExtension);
59887          } else {
59888  
59889 -          if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) &&
59890 -              (SiS_Pr->SiS_VBType & VB_NoLCD) ) {
59891 -              
59892 -             /* TW: Need LVDS Data for LCD on 301BDH */
59893 +          if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_VBType & VB_NoLCD) ) {
59894 +
59895 +             /* Need LVDS Data for LCD on 301B-DH */
59896               SiS_GetCRT2DataLVDS(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
59897                                   HwDeviceExtension);
59898                                   
59899 @@ -3282,18 +3410,16 @@ SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr,
59900  
59901     } else {
59902  
59903 -      /* TW: 301BDH needs LVDS Data */
59904 -      if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) &&
59905 -          (SiS_Pr->SiS_VBType & VB_NoLCD) ) {
59906 +      /* 301BDH needs LVDS Data */
59907 +      if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_VBType & VB_NoLCD) ) {
59908               SiS_Pr->SiS_IF_DEF_LVDS = 1;
59909        }
59910  
59911        SiS_GetCRT2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
59912                       &CRT2Index,&ResIndex,HwDeviceExtension);
59913  
59914 -      /* TW: 301BDH needs LVDS Data */
59915 -      if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) &&
59916 -          (SiS_Pr->SiS_VBType & VB_NoLCD) ) {
59917 +      /* 301BDH needs LVDS Data */
59918 +      if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_VBType & VB_NoLCD) ) {
59919                SiS_Pr->SiS_IF_DEF_LVDS = 0;
59920        }
59921  
59922 @@ -3321,11 +3447,18 @@ SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr,
59923         case 20:  LVDSData = SiS_Pr->SiS_LVDS1280x768Data_2;   break;
59924         case 21:  LVDSData = SiS_Pr->SiS_LVDS1600x1200Data_1;  break;
59925         case 22:  LVDSData = SiS_Pr->SiS_LVDS1600x1200Data_2;  break;
59926 +       case 30:  LVDSData = SiS_Pr->SiS_LVDS640x480Data_2;    break;
59927 +       case 80:  LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_1;  break;
59928 +       case 81:  LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_2;  break;
59929 +       case 82:  LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_1;  break;
59930 +       case 83:  LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_2;  break;
59931 +       case 84:  LVDSData = SiS_Pr->SiS_LVDS848x480Data_1;    break;
59932 +       case 85:  LVDSData = SiS_Pr->SiS_LVDS848x480Data_2;    break;
59933         case 90:  LVDSData = SiS_Pr->SiS_CHTVUPALMData;        break;
59934         case 91:  LVDSData = SiS_Pr->SiS_CHTVOPALMData;        break;
59935         case 92:  LVDSData = SiS_Pr->SiS_CHTVUPALNData;        break;
59936         case 93:  LVDSData = SiS_Pr->SiS_CHTVOPALNData;        break;
59937 -       case 99:  LVDSData = SiS_Pr->SiS_CHTVSOPALData;        break;  /* TW: Super Overscan */
59938 +       case 99:  LVDSData = SiS_Pr->SiS_CHTVSOPALData;        break;  /* Super Overscan */
59939         default:  LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1;   break;
59940       }
59941     }
59942 @@ -3337,67 +3470,36 @@ SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr,
59943  
59944    if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
59945  
59946 -    if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)){
59947 -         if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768){
59948 -           SiS_Pr->SiS_HDE = 1024;
59949 -           SiS_Pr->SiS_VDE =  768;
59950 -         } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024){
59951 -           SiS_Pr->SiS_HDE = 1280;
59952 -           SiS_Pr->SiS_VDE = 1024;
59953 -        } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050){
59954 -           SiS_Pr->SiS_HDE = 1400;
59955 -           SiS_Pr->SiS_VDE = 1050;
59956 -        } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200){
59957 -           SiS_Pr->SiS_HDE = 1600;
59958 -           SiS_Pr->SiS_VDE = 1200;
59959 -         } else {
59960 -          SiS_Pr->SiS_HDE = 1280;
59961 -          SiS_Pr->SiS_VDE =  960;
59962 -        }
59963 -    }
59964 +     if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
59965 +        SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes;
59966 +        SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes;
59967 +     }
59968  
59969    } else {
59970  
59971 -    if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) {
59972 -      if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {
59973 -        if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) {
59974 -          if((!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || (SiS_Pr->SiS_SetFlag & SetDOSMode)) {
59975 -            if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) {
59976 -              SiS_Pr->SiS_HDE =  800;
59977 -              SiS_Pr->SiS_VDE =  600;
59978 -           } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) {
59979 -             SiS_Pr->SiS_HDE = 1024;
59980 -              SiS_Pr->SiS_VDE =  600;  
59981 -            } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
59982 -              SiS_Pr->SiS_HDE = 1024;
59983 -              SiS_Pr->SiS_VDE =  768;
59984 -           } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) {
59985 -             SiS_Pr->SiS_HDE = 1152;
59986 -             SiS_Pr->SiS_VDE =  768;   
59987 -           } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x864) {
59988 -             SiS_Pr->SiS_HDE = 1152;
59989 -             SiS_Pr->SiS_VDE =  864;  
59990 -           } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) {
59991 -             SiS_Pr->SiS_HDE = 1280;
59992 -             SiS_Pr->SiS_VDE =  768;        
59993 -            } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
59994 -              SiS_Pr->SiS_HDE = 1280;
59995 -              SiS_Pr->SiS_VDE = 1024;
59996 -           } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
59997 -             SiS_Pr->SiS_HDE = 1400;
59998 -              SiS_Pr->SiS_VDE = 1050;
59999 -           } else {
60000 -             SiS_Pr->SiS_HDE = 1600;
60001 -             SiS_Pr->SiS_VDE = 1200;
60002 -           }
60003 -            if(SiS_Pr->SiS_IF_DEF_FSTN) {
60004 -              SiS_Pr->SiS_HDE = 320;
60005 -              SiS_Pr->SiS_VDE = 480;
60006 -            }
60007 -          }
60008 +     if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) {
60009 +        if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {
60010 +           if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) {
60011 +              if((!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || (SiS_Pr->SiS_SetFlag & SetDOSMode)) {
60012 +                SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes;
60013 +                 SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes;
60014 +
60015 +                if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
60016 +                   if(ResIndex < 0x08) {
60017 +                      SiS_Pr->SiS_HDE = 1280;
60018 +                       SiS_Pr->SiS_VDE = 1024;
60019 +                   }
60020 +                }
60021 +#if 0
60022 +                 if(SiS_Pr->SiS_IF_DEF_FSTN) {
60023 +                    SiS_Pr->SiS_HDE = 320;
60024 +                    SiS_Pr->SiS_VDE = 480;
60025 +                 }
60026 +#endif
60027 +              }
60028 +           }
60029          }
60030 -      }
60031 -    }
60032 +     }
60033    }
60034  }
60035  
60036 @@ -3413,11 +3515,16 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr, 
60037    const SiS_TVDataStruct  *TVPtr  = NULL;
60038  
60039    if(ModeNo <= 0x13) {
60040 -       modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
60041 -       resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
60042 +     modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
60043 +     resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
60044    } else {
60045 +     if(SiS_Pr->UseCustomMode) {
60046 +        modeflag = SiS_Pr->CModeFlag;
60047 +       resinfo = 0;
60048 +     } else {
60049         modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
60050         resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
60051 +     }
60052    }
60053    
60054    SiS_Pr->SiS_NewFlickerMode = 0;
60055 @@ -3429,17 +3536,26 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr, 
60056  
60057    SiS_GetCRT2ResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension);
60058  
60059 -  /* TW: For VGA2 ("RAMDAC2") */
60060 -
60061    if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){
60062 -     SiS_GetRAMDAC2DATA(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
60063 -                        HwDeviceExtension);
60064 -     return;
60065 -  }
60066  
60067 -  /* TW: For TV */
60068 +     if(SiS_Pr->UseCustomMode) {
60069  
60070 -  if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
60071 +        SiS_Pr->SiS_RVBHCMAX  = 1;
60072 +        SiS_Pr->SiS_RVBHCFACT = 1;
60073 +        SiS_Pr->SiS_VGAHT     = SiS_Pr->CHTotal;
60074 +        SiS_Pr->SiS_VGAVT     = SiS_Pr->CVTotal;
60075 +        SiS_Pr->SiS_HT        = SiS_Pr->CHTotal;
60076 +        SiS_Pr->SiS_VT        = SiS_Pr->CVTotal;
60077 +       SiS_Pr->SiS_HDE       = SiS_Pr->SiS_VGAHDE;
60078 +        SiS_Pr->SiS_VDE       = SiS_Pr->SiS_VGAVDE;
60079 +
60080 +     } else {
60081 +
60082 +        SiS_GetRAMDAC2DATA(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
60083 +                           HwDeviceExtension);
60084 +     }
60085 +
60086 +  } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
60087  
60088      SiS_GetCRT2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
60089                     &CRT2Index,&ResIndex,HwDeviceExtension);
60090 @@ -3452,7 +3568,7 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr, 
60091        case  4:  TVPtr = SiS_Pr->SiS_ExtNTSCData;   break;
60092        case  8:  TVPtr = SiS_Pr->SiS_StPALData;     break;
60093        case  9:  TVPtr = SiS_Pr->SiS_StNTSCData;    break;
60094 -      default:  TVPtr = SiS_Pr->SiS_StPALData;     break;  /* TW: Just to avoid a crash */
60095 +      default:  TVPtr = SiS_Pr->SiS_StPALData;     break;  /* Just to avoid a crash */
60096      }
60097  
60098      SiS_Pr->SiS_RVBHCMAX  = (TVPtr+ResIndex)->RVBHCMAX;
60099 @@ -3464,18 +3580,16 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr, 
60100      SiS_Pr->SiS_RVBHRS    = (TVPtr+ResIndex)->RVBHRS;
60101      SiS_Pr->SiS_NewFlickerMode = (TVPtr+ResIndex)->FlickerMode;
60102      if(modeflag & HalfDCLK) {
60103 -       SiS_Pr->SiS_RVBHRS    = (TVPtr+ResIndex)->HALFRVBHRS;
60104 +       SiS_Pr->SiS_RVBHRS     = (TVPtr+ResIndex)->HALFRVBHRS;
60105      }
60106  
60107      if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {  
60108      
60109         if(SiS_Pr->SiS_HiVision != 3) {
60110 -       
60111 -         if(resinfo == 0x08) SiS_Pr->SiS_NewFlickerMode = 0x40;
60112 -         if(resinfo == 0x09) SiS_Pr->SiS_NewFlickerMode = 0x40;
60113 -         if(resinfo == 0x12) SiS_Pr->SiS_NewFlickerMode = 0x40;
60114 -         
60115 -       } 
60116 +         if(resinfo == SIS_RI_1024x768)  SiS_Pr->SiS_NewFlickerMode = 0x40;
60117 +         if(resinfo == SIS_RI_1280x1024) SiS_Pr->SiS_NewFlickerMode = 0x40;
60118 +         if(resinfo == SIS_RI_1280x720)  SiS_Pr->SiS_NewFlickerMode = 0x40;
60119 +       }
60120         
60121         switch(SiS_Pr->SiS_HiVision) {
60122         case 2:
60123 @@ -3504,119 +3618,136 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr, 
60124  
60125      } else {
60126  
60127 -      SiS_Pr->SiS_RY1COE = (TVPtr+ResIndex)->RY1COE;
60128 -      SiS_Pr->SiS_RY2COE = (TVPtr+ResIndex)->RY2COE;
60129 -      SiS_Pr->SiS_RY3COE = (TVPtr+ResIndex)->RY3COE;
60130 -      SiS_Pr->SiS_RY4COE = (TVPtr+ResIndex)->RY4COE;
60131 -
60132 -      if(modeflag & HalfDCLK) {
60133 -         SiS_Pr->SiS_RY1COE = 0x00;
60134 -         SiS_Pr->SiS_RY2COE = 0xf4;
60135 -         SiS_Pr->SiS_RY3COE = 0x10;
60136 -         SiS_Pr->SiS_RY4COE = 0x38;
60137 -      }
60138 -
60139 -      if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
60140 -        SiS_Pr->SiS_HT = NTSCHT;
60141 -       if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {  
60142 -          if((ModeNo == 0x4a) || (ModeNo == 0x38)) SiS_Pr->SiS_HT = NTSC2HT;
60143 -       }  
60144 -        SiS_Pr->SiS_VT = NTSCVT;
60145 -      } else {
60146 -        SiS_Pr->SiS_HT = PALHT;
60147 -        SiS_Pr->SiS_VT = PALVT;
60148 -      }
60149 +       SiS_Pr->SiS_RY1COE = (TVPtr+ResIndex)->RY1COE;
60150 +       SiS_Pr->SiS_RY2COE = (TVPtr+ResIndex)->RY2COE;
60151 +       SiS_Pr->SiS_RY3COE = (TVPtr+ResIndex)->RY3COE;
60152 +       SiS_Pr->SiS_RY4COE = (TVPtr+ResIndex)->RY4COE;
60153 +
60154 +       if(modeflag & HalfDCLK) {
60155 +          SiS_Pr->SiS_RY1COE = 0x00;
60156 +          SiS_Pr->SiS_RY2COE = 0xf4;
60157 +          SiS_Pr->SiS_RY3COE = 0x10;
60158 +          SiS_Pr->SiS_RY4COE = 0x38;
60159 +       }
60160 +
60161 +       if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
60162 +          SiS_Pr->SiS_HT = NTSCHT;
60163 +         if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
60164 +            if((ModeNo == 0x64) || (ModeNo == 0x4a) || (ModeNo == 0x38)) SiS_Pr->SiS_HT = NTSC2HT;
60165 +         }
60166 +          SiS_Pr->SiS_VT = NTSCVT;
60167 +       } else {
60168 +          SiS_Pr->SiS_HT = PALHT;
60169 +          SiS_Pr->SiS_VT = PALVT;
60170 +       }
60171  
60172      }
60173  
60174 -    return;
60175 -  }
60176 +  } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
60177  
60178 -  /* TW: For LCD */
60179 +     if(SiS_Pr->UseCustomMode) {
60180  
60181 -  if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
60182 +        SiS_Pr->SiS_RVBHCMAX  = 1;
60183 +        SiS_Pr->SiS_RVBHCFACT = 1;
60184 +        SiS_Pr->SiS_VGAHT     = SiS_Pr->CHTotal;
60185 +        SiS_Pr->SiS_VGAVT     = SiS_Pr->CVTotal;
60186 +        SiS_Pr->SiS_HT        = SiS_Pr->CHTotal;
60187 +        SiS_Pr->SiS_VT        = SiS_Pr->CVTotal;
60188 +       SiS_Pr->SiS_HDE       = SiS_Pr->SiS_VGAHDE;
60189 +        SiS_Pr->SiS_VDE       = SiS_Pr->SiS_VGAVDE;
60190  
60191 -    SiS_GetCRT2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
60192 -                   &CRT2Index,&ResIndex,HwDeviceExtension);
60193 +     } else {
60194 +
60195 +        SiS_GetCRT2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
60196 +                      &CRT2Index,&ResIndex,HwDeviceExtension);
60197 +
60198 +        switch(CRT2Index) {
60199 +         case  0: LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data;        break; /* VESA Timing */
60200 +         case  1: LCDPtr = SiS_Pr->SiS_ExtLCD1280x1024Data;       break; /* VESA Timing */
60201 +         case  5: LCDPtr = SiS_Pr->SiS_StLCD1024x768Data;         break; /* Obviously unused */
60202 +         case  6: LCDPtr = SiS_Pr->SiS_StLCD1280x1024Data;        break; /* Obviously unused */
60203 +         case 10: LCDPtr = SiS_Pr->SiS_St2LCD1024x768Data;        break; /* Non-VESA Timing */
60204 +         case 11: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data;       break; /* Non-VESA Timing */
60205 +         case 13: LCDPtr = SiS_Pr->SiS_NoScaleData1024x768;       break; /* Non-expanding */
60206 +         case 14: LCDPtr = SiS_Pr->SiS_NoScaleData1280x1024;      break; /* Non-expanding */
60207 +         case 15: LCDPtr = SiS_Pr->SiS_LCD1280x960Data;           break; /* 1280x960 */
60208 +         case 20: LCDPtr = SiS_Pr->SiS_ExtLCD1400x1050Data;       break; /* VESA Timing */
60209 +         case 21: LCDPtr = SiS_Pr->SiS_NoScaleData1400x1050;      break; /* Non-expanding (let panel scale) */
60210 +         case 22: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data;        break; /* Non-VESA Timing (let panel scale) */
60211 +         case 23: LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data;       break; /* VESA Timing */
60212 +         case 24: LCDPtr = SiS_Pr->SiS_NoScaleData1600x1200;      break; /* Non-expanding */
60213 +         case 25: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data;        break; /* Non-VESA Timing */
60214 +         case 26: LCDPtr = SiS_Pr->SiS_ExtLCD1280x768Data;        break; /* VESA Timing */
60215 +         case 27: LCDPtr = SiS_Pr->SiS_NoScaleData1280x768;       break; /* Non-expanding */
60216 +         case 28: LCDPtr = SiS_Pr->SiS_StLCD1280x768Data;         break; /* Non-VESA Timing */
60217 +         case 29: LCDPtr = SiS_Pr->SiS_NoScaleData;              break; /* Generic no-scale data */
60218 +#ifdef SIS315H
60219 +        case 50: LCDPtr = (SiS_LCDDataStruct *)SiS310_ExtCompaq1280x1024Data;  break;
60220 +        case 51: LCDPtr = SiS_Pr->SiS_NoScaleData1280x1024;                    break;
60221 +        case 52: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data;                     break;
60222 +#endif
60223 +         default: LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data;       break; /* Just to avoid a crash */
60224 +        }
60225 +
60226 +        SiS_Pr->SiS_RVBHCMAX  = (LCDPtr+ResIndex)->RVBHCMAX;
60227 +        SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT;
60228 +        SiS_Pr->SiS_VGAHT     = (LCDPtr+ResIndex)->VGAHT;
60229 +        SiS_Pr->SiS_VGAVT     = (LCDPtr+ResIndex)->VGAVT;
60230 +        SiS_Pr->SiS_HT        = (LCDPtr+ResIndex)->LCDHT;
60231 +        SiS_Pr->SiS_VT        = (LCDPtr+ResIndex)->LCDVT;
60232  
60233 -    switch (CRT2Index) {
60234 -      case  0: LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data;        break; /* VESA Timing */
60235 -      case  1: LCDPtr = SiS_Pr->SiS_ExtLCD1280x1024Data;       break; /* VESA Timing */
60236 -      case  5: LCDPtr = SiS_Pr->SiS_StLCD1024x768Data;         break; /* Obviously unused */
60237 -      case  6: LCDPtr = SiS_Pr->SiS_StLCD1280x1024Data;        break; /* Obviously unused */
60238 -      case 10: LCDPtr = SiS_Pr->SiS_St2LCD1024x768Data;        break; /* Non-VESA Timing */
60239 -      case 11: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data;       break; /* Non-VESA Timing */
60240 -      case 13: LCDPtr = SiS_Pr->SiS_NoScaleData1024x768;       break; /* Non-expanding */
60241 -      case 14: LCDPtr = SiS_Pr->SiS_NoScaleData1280x1024;      break; /* Non-expanding */
60242 -      case 15: LCDPtr = SiS_Pr->SiS_LCD1280x960Data;           break; /* 1280x960 */
60243 -      case 20: LCDPtr = SiS_Pr->SiS_ExtLCD1400x1050Data;       break; /* VESA Timing */
60244 -      case 21: LCDPtr = SiS_Pr->SiS_NoScaleData1400x1050;      break; /* Non-expanding (let panel scale) */
60245 -      case 22: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data;               break; /* Non-VESA Timing (let panel scale) */
60246 -      case 23: LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data;       break; /* VESA Timing */
60247 -      case 24: LCDPtr = SiS_Pr->SiS_NoScaleData1600x1200;      break; /* Non-expanding */
60248 -      case 25: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data;               break; /* Non-VESA Timing */
60249 -      default: LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data;               break; /* Just to avoid a crash */
60250 -    }
60251 -
60252 -    SiS_Pr->SiS_RVBHCMAX  = (LCDPtr+ResIndex)->RVBHCMAX;
60253 -    SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT;
60254 -    SiS_Pr->SiS_VGAHT     = (LCDPtr+ResIndex)->VGAHT;
60255 -    SiS_Pr->SiS_VGAVT     = (LCDPtr+ResIndex)->VGAVT;
60256 -    SiS_Pr->SiS_HT        = (LCDPtr+ResIndex)->LCDHT;
60257 -    SiS_Pr->SiS_VT        = (LCDPtr+ResIndex)->LCDVT;
60258 -    
60259  #ifdef TWDEBUG
60260 -    xf86DrvMsg(0, X_INFO,
60261 -       "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex);
60262 -#endif    
60263 +        xf86DrvMsg(0, X_INFO,
60264 +           "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex);
60265 +#endif
60266  
60267 -    tempax = 1024;
60268 -    if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
60269 -      if(HwDeviceExtension->jChipType < SIS_315H) {
60270 -         if     (SiS_Pr->SiS_VGAVDE == 350) tempbx = 560;
60271 -         else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640;
60272 -         else                               tempbx = 768;
60273 -      } else {      
60274 -         tempbx = 768; 
60275 -      }
60276 -    } else {
60277 -      if     (SiS_Pr->SiS_VGAVDE == 357) tempbx = 527;
60278 -      else if(SiS_Pr->SiS_VGAVDE == 420) tempbx = 620;
60279 -      else if(SiS_Pr->SiS_VGAVDE == 525) tempbx = 775;
60280 -      else if(SiS_Pr->SiS_VGAVDE == 600) tempbx = 775;
60281 -      else if(SiS_Pr->SiS_VGAVDE == 350) tempbx = 560;
60282 -      else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640;
60283 -      else                               tempbx = 768;
60284 -    }
60285 -    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
60286 -      tempax = 1280;
60287 -      if     (SiS_Pr->SiS_VGAVDE == 360) tempbx = 768;
60288 -      else if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 800;
60289 -      else if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 864;
60290 -      else                               tempbx = 1024;
60291 -    }
60292 -    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) {
60293 -      tempax = 1280;
60294 -      if     (SiS_Pr->SiS_VGAVDE == 350)  tempbx = 700;
60295 -      else if(SiS_Pr->SiS_VGAVDE == 400)  tempbx = 800;
60296 -      else if(SiS_Pr->SiS_VGAVDE == 1024) tempbx = 960;
60297 -      else                                tempbx = 960;
60298 -    }
60299 -    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
60300 -      tempax = 1400;
60301 -      tempbx = 1050;
60302 -    }
60303 -    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) {
60304 -      tempax = 1600;
60305 -      tempbx = 1200;
60306 -    }
60307 -    if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
60308 -       tempax = SiS_Pr->SiS_VGAHDE;
60309 -       tempbx = SiS_Pr->SiS_VGAVDE;
60310 -    }
60311 -    SiS_Pr->SiS_HDE = tempax;
60312 -    SiS_Pr->SiS_VDE = tempbx;
60313 -    return;
60314 +       if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
60315 +           tempax = 1024;
60316 +           if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
60317 +              if(HwDeviceExtension->jChipType < SIS_315H) {
60318 +                 if     (SiS_Pr->SiS_VGAVDE == 350) tempbx = 560;
60319 +                 else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640;
60320 +                 else                               tempbx = 768;
60321 +              } else {
60322 +                 tempbx = 768;
60323 +              }
60324 +           } else {
60325 +              if     (SiS_Pr->SiS_VGAVDE == 357) tempbx = 527;
60326 +              else if(SiS_Pr->SiS_VGAVDE == 420) tempbx = 620;
60327 +              else if(SiS_Pr->SiS_VGAVDE == 525) tempbx = 775;
60328 +              else if(SiS_Pr->SiS_VGAVDE == 600) tempbx = 775;
60329 +              else if(SiS_Pr->SiS_VGAVDE == 350) tempbx = 560;
60330 +              else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640;
60331 +              else                               tempbx = 768;
60332 +           }
60333 +       } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
60334 +           tempax = 1280;
60335 +           if     (SiS_Pr->SiS_VGAVDE == 360) tempbx = 768;
60336 +           else if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 800;
60337 +           else if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 864;
60338 +           else                               tempbx = 1024;
60339 +        } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) {
60340 +           tempax = 1280;
60341 +           if     (SiS_Pr->SiS_VGAVDE == 350)  tempbx = 700;
60342 +           else if(SiS_Pr->SiS_VGAVDE == 400)  tempbx = 800;
60343 +           else if(SiS_Pr->SiS_VGAVDE == 1024) tempbx = 960;
60344 +           else                                tempbx = 960;
60345 +        } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) {
60346 +           tempax = 1600;
60347 +           if     (SiS_Pr->SiS_VGAVDE == 350)  tempbx = 875;
60348 +           else if(SiS_Pr->SiS_VGAVDE == 400)  tempbx = 1000;
60349 +           else                                tempbx = 1200;
60350 +        } else {
60351 +          tempax = SiS_Pr->PanelXRes;
60352 +           tempbx = SiS_Pr->PanelYRes;
60353 +       }
60354 +        if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
60355 +           tempax = SiS_Pr->SiS_VGAHDE;
60356 +           tempbx = SiS_Pr->SiS_VGAVDE;
60357 +        }
60358 +        SiS_Pr->SiS_HDE = tempax;
60359 +        SiS_Pr->SiS_VDE = tempbx;
60360 +     }
60361    }
60362  }
60363  
60364 @@ -3626,9 +3757,9 @@ SiS_GetResInfo(SiS_Private *SiS_Pr, UCHA
60365    USHORT resindex;
60366  
60367    if(ModeNo <= 0x13)
60368 -       resindex=SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
60369 +     resindex=SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
60370    else
60371 -       resindex=SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
60372 +     resindex=SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
60373  
60374    return(resindex);
60375  }
60376 @@ -3639,41 +3770,46 @@ SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr, 
60377  {
60378    USHORT xres,yres,modeflag=0,resindex;
60379  
60380 +  if(SiS_Pr->UseCustomMode) {
60381 +     SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = SiS_Pr->CHDisplay;
60382 +     SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = SiS_Pr->CVDisplay;
60383 +     return;
60384 +  }
60385 +
60386    resindex = SiS_GetResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex);
60387  
60388    if(ModeNo <= 0x13) {
60389 -       xres = SiS_Pr->SiS_StResInfo[resindex].HTotal;
60390 -       yres = SiS_Pr->SiS_StResInfo[resindex].VTotal;
60391 +     xres = SiS_Pr->SiS_StResInfo[resindex].HTotal;
60392 +     yres = SiS_Pr->SiS_StResInfo[resindex].VTotal;
60393    } else {
60394 -       xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal;
60395 -       yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal;
60396 -       modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
60397 +     xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal;
60398 +     yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal;
60399 +     modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
60400    }
60401  
60402 -  if((HwDeviceExtension->jChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) {
60403 -      if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & SetDOSMode)) {
60404 -          if(yres == 350) yres = 400;
60405 -      }
60406 -      if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x3a) & 0x01) {
60407 -         if(ModeNo == 0x12) yres = 400;
60408 -      }
60409 -  }
60410 +  if((!SiS_Pr->SiS_IF_DEF_DSTN) && (!SiS_Pr->SiS_IF_DEF_FSTN)) {
60411 +
60412 +     if((HwDeviceExtension->jChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) {
60413 +        if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & SetDOSMode)) {
60414 +           if(yres == 350) yres = 400;
60415 +        }
60416 +        if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x3a) & 0x01) {
60417 +          if(ModeNo == 0x12) yres = 400;
60418 +        }
60419 +     }
60420 +
60421 +     if(ModeNo > 0x13) {
60422 +       if(modeflag & HalfDCLK)       xres *= 2;
60423 +       if(modeflag & DoubleScanMode) yres *= 2;
60424 +     }
60425  
60426 -  if(ModeNo > 0x13) {
60427 -      if(SiS_Pr->SiS_IF_DEF_FSTN == 1){
60428 -            xres *= 2;
60429 -            yres *= 2;
60430 -      } else {
60431 -           if(modeflag & HalfDCLK)       xres *= 2;
60432 -           if(modeflag & DoubleScanMode) yres *= 2;
60433 -      }
60434    }
60435  
60436    if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
60437          if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
60438             if(xres == 720) xres = 640;
60439         } else {
60440 -          if(SiS_Pr->SiS_VBType & VB_NoLCD) {           /* TW: 301BDH */
60441 +          if(SiS_Pr->SiS_VBType & VB_NoLCD) {           /* 301BDH */
60442                 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
60443                     if(xres == 720) xres = 640;
60444                 }
60445 @@ -3694,17 +3830,16 @@ SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr, 
60446                  if(xres == 720) xres = 640;
60447               }
60448               if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
60449 -                if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
60450 -                   if(ModeNo <= 0x13) {
60451 -                      /* TW: This is wrong for 640x400 *graphics* mode */
60452 +                if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
60453 +                   if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
60454 +                      /* BIOS bug - does this regardless of scaling */
60455                        if(yres == 400) yres = 405;
60456                     }
60457                     if(yres == 350) yres = 360;
60458                     if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
60459                        if(yres == 360) yres = 375;
60460                     }
60461 -                }
60462 -                if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768){
60463 +                } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
60464                     if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
60465                        if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
60466                           if(yres == 350) yres = 357;
60467 @@ -3719,12 +3854,15 @@ SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr, 
60468    } else {
60469         if(xres == 720) xres = 640;
60470         if(SiS_Pr->SiS_SetFlag & SetDOSMode) {
60471 -             yres = 400;
60472 -             if(HwDeviceExtension->jChipType >= SIS_315H) {
60473 -                 if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480;
60474 -             } else {
60475 -                 if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480;
60476 -             }
60477 +          yres = 400;
60478 +          if(HwDeviceExtension->jChipType >= SIS_315H) {
60479 +             if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480;
60480 +          } else {
60481 +             if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480;
60482 +          }
60483 +          if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) {
60484 +             yres = 480;
60485 +          }
60486         }
60487    }
60488    SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres;
60489 @@ -3739,6 +3877,13 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr, UCHA
60490    USHORT tempbx=0,tempal=0;
60491    USHORT Flag,resinfo=0;
60492  
60493 +  if(ModeNo <= 0x13) {
60494 +     tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
60495 +  } else {
60496 +     tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
60497 +     resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
60498 +  }
60499 +
60500    if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
60501  
60502         if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {                            /* LCD */
60503 @@ -3753,19 +3898,44 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr, UCHA
60504                         tempbx = 23;
60505                         if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)         tempbx = 24;
60506                         else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 25;
60507 +#if 0
60508 +               } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) {
60509 +                       tempbx = 26;
60510 +                       if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)         tempbx = 27;
60511 +                       else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 28;
60512 +#endif
60513                 } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
60514 -                       tempbx = 13;
60515 -                       if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempbx++;
60516 +                       if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
60517 +                          if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)       tempbx = 13;
60518 +                          else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempbx = 14;
60519 +                          else                                                          tempbx = 29;
60520 +                       } else {
60521 +                          tempbx = 29;
60522 +                          if(ModeNo >= 0x13) {
60523 +                             /* 1280x768 and 1280x960 have same CRT2CRTC,
60524 +                              * so we change it here if 1280x960 is chosen
60525 +                              */
60526 +                             if(resinfo == SIS_RI_1280x960) tempal = 10;
60527 +                          }
60528 +                       }
60529                 } else {
60530                    tempbx = SiS_Pr->SiS_LCDResInfo - SiS_Pr->SiS_Panel1024x768;
60531                    if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
60532                         tempbx += 5;
60533                          /* GetRevisionID();  */
60534 -                       /* TW: BIOS only adds 5 once */
60535 +                       /* BIOS only adds 5 once */
60536                         tempbx += 5;
60537                            }
60538                 }
60539  
60540 +#ifdef SIS315H
60541 +               if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
60542 +                  tempbx = 50;
60543 +                  if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)         tempbx = 51;
60544 +                  else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx = 52;
60545 +               }
60546 +#endif
60547 +
60548         } else {                                                        /* TV */
60549         
60550                         if((SiS_Pr->SiS_VBType & VB_SIS301B302B) &&
60551 @@ -3773,7 +3943,7 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr, UCHA
60552                         if(SiS_Pr->SiS_VGAVDE > 480) SiS_Pr->SiS_SetFlag &= (~TVSimuMode);
60553                         tempbx = 2;
60554                         if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
60555 -                               if(!(SiS_Pr->SiS_SetFlag & TVSimuMode)) tempbx = 12; 
60556 +                               if(!(SiS_Pr->SiS_SetFlag & TVSimuMode)) tempbx = 12;
60557                         }
60558                         } else {
60559                         if(SiS_Pr->SiS_VBInfo & SetPALTV) tempbx = 3;
60560 @@ -3783,34 +3953,18 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr, UCHA
60561                 
60562         }
60563  
60564 -       if(ModeNo <= 0x13) {
60565 -                       tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
60566 -       } else {
60567 -                       tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
60568 -               resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
60569 -        }
60570 -
60571 -       tempal &= 0x3F;
60572 -
60573 -       if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&
60574 -           (SiS_Pr->SiS_VBInfo & (SetCRT2ToTV-SetCRT2ToHiVisionTV))) {
60575 -               if(tempal == 0x06) tempal = 0x07;
60576 -        }
60577 -
60578 -       /* TW: 300/301LV BIOS */
60579 -       if((HwDeviceExtension->jChipType == SIS_300) &&
60580 -          (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) {
60581 -           if(ModeNo > 0x13) {
60582 -               if((resinfo == 0x0c) || (resinfo == 0x0d))  /* 720 (index diff. on 310/325!) */
60583 -                   tempal = 6;
60584 -           }
60585 -       }
60586 +        tempal &= 0x3F;
60587  
60588 -       if(HwDeviceExtension->jChipType != SIS_300) {
60589 -           if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
60590 -              if((ModeNo == 0x31) || (ModeNo == 0x32)) tempal = 6;
60591 +       if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) {
60592 +          if(ModeNo > 0x13) {
60593 +             if(tempal == 6) tempal = 7;
60594 +              if((resinfo == SIS_RI_720x480) ||
60595 +                (resinfo == SIS_RI_720x576) ||
60596 +                (resinfo == SIS_RI_768x576)) {
60597 +                tempal = 6;
60598 +             }
60599            }
60600 -       }
60601 +        }
60602  
60603         *CRT2Index = tempbx;
60604         *ResIndex = tempal;
60605 @@ -3820,25 +3974,22 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr, UCHA
60606         Flag = 1;
60607         tempbx = 0;
60608         if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
60609 -       
60610 -               if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
60611 -                       Flag = 0;
60612 -                       tempbx = 10;
60613 -                       if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1;
60614 -                       if(SiS_Pr->SiS_VBInfo & SetPALTV) {
60615 -                               tempbx += 2;
60616 -                               if(SiS_Pr->SiS_CHSOverScan) tempbx = 99;
60617 -                               if(SiS_Pr->SiS_CHPALM) {
60618 -                                       tempbx = 90;
60619 -                                       if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1;
60620 -                               } else if(SiS_Pr->SiS_CHPALN) {
60621 -                                       tempbx = 92;
60622 -                                       if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1;
60623 -                               }
60624 -                               
60625 -                       }
60626 -               }
60627 -               
60628 +          if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
60629 +              Flag = 0;
60630 +              tempbx = 10;
60631 +             if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1;
60632 +              if(SiS_Pr->SiS_VBInfo & SetPALTV) {
60633 +                tempbx += 2;
60634 +                if(SiS_Pr->SiS_CHSOverScan) tempbx = 99;
60635 +                if(SiS_Pr->SiS_CHPALM) {
60636 +                   tempbx = 90;
60637 +                   if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1;
60638 +                } else if(SiS_Pr->SiS_CHPALN) {
60639 +                   tempbx = 92;
60640 +                   if(SiS_Pr->SiS_VBInfo & SetCHTVOverScan) tempbx += 1;
60641 +                }
60642 +              }
60643 +           }
60644         }
60645  
60646         if(Flag) {
60647 @@ -3846,11 +3997,19 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr, UCHA
60648                 if(SiS_Pr->SiS_LCDResInfo <= SiS_Pr->SiS_Panel1280x1024) {
60649                    tempbx = SiS_Pr->SiS_LCDResInfo - SiS_Pr->SiS_PanelMinLVDS;
60650                    if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)  tempbx += 3;
60651 +                  if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) {
60652 +                     tempbx = 82;
60653 +                     if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)  tempbx++;
60654 +                  }
60655                 } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) {
60656                    tempbx = 18;
60657                    if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)  tempbx++; 
60658 -               } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) { 
60659 +               } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) {
60660                    tempbx = 6;
60661 +               } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2) {
60662 +                  tempbx = 30;
60663 +               } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) {
60664 +                  tempbx = 30;
60665                 } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) {
60666                    tempbx = 15;
60667                    if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)  tempbx += 2;
60668 @@ -3863,27 +4022,30 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr, UCHA
60669                 } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) {
60670                    tempbx = 21;
60671                    if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)  tempbx++;
60672 +               } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelBarco1366) {
60673 +                  tempbx = 80;
60674 +                  if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)  tempbx++;
60675                 }
60676 -               
60677 +
60678                 if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
60679                    tempbx = 7;
60680                 }
60681 -               
60682 -       }
60683  
60684 -       if(ModeNo <= 0x13)
60685 -               tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
60686 -       else {
60687 -               tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
60688 -               resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
60689 +               if(SiS_Pr->SiS_CustomT == CUT_PANEL848) {
60690 +                  tempbx = 84;
60691 +                  if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)  tempbx++;
60692 +               }
60693 +
60694         }
60695  
60696 +#if 0
60697         if(SiS_Pr->SiS_IF_DEF_FSTN){
60698                         if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480){
60699                         tempbx = 14;
60700                         tempal = 6;
60701                 }
60702         }
60703 +#endif
60704  
60705         if(SiS_Pr->SiS_SetFlag & SetDOSMode) {
60706                 if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel640x480) tempal = 7;
60707 @@ -3895,13 +4057,10 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr, UCHA
60708  
60709         if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
60710             if(ModeNo > 0x13) {
60711 -               if(HwDeviceExtension->jChipType < SIS_315H) {
60712 -                  if((resinfo == 0x0c) || (resinfo == 0x0d))  /* 720 */
60713 -                      tempal = 6;
60714 -               } else {
60715 -                  if((resinfo == 0x0d) || (resinfo == 0x0e))  /* 720 */
60716 -                      tempal = 6;
60717 -               }
60718 +              if((resinfo == SIS_RI_720x480) ||
60719 +                 (resinfo == SIS_RI_720x576) ||
60720 +                 (resinfo == SIS_RI_768x576))
60721 +                 tempal = 6;
60722             }
60723         }
60724  
60725 @@ -3940,7 +4099,7 @@ SiS_GetCRT2PtrA(SiS_Private *SiS_Pr, UCH
60726  void
60727  SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
60728                     USHORT RefreshRateTableIndex,USHORT *CRT2Index,
60729 -                   USHORT *ResIndex)
60730 +                   USHORT *ResIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension)
60731  {
60732    USHORT tempbx,tempal;
60733  
60734 @@ -3954,6 +4113,16 @@ SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr,
60735    if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)      tempbx += 16;
60736    else if(SiS_Pr->SiS_SetFlag & LCDVESATiming) tempbx += 32;
60737  
60738 +#ifdef SIS315H
60739 +  if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
60740 +     if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
60741 +        tempbx = 100;
60742 +        if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)      tempbx = 101;
60743 +       else if(SiS_Pr->SiS_SetFlag & LCDVESATiming) tempbx = 102;
60744 +     }
60745 +  }
60746 +#endif
60747 +
60748    *CRT2Index = tempbx;
60749    *ResIndex = tempal & 0x3F;
60750  }
60751 @@ -3962,15 +4131,17 @@ USHORT
60752  SiS_GetRatePtrCRT2(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo, USHORT ModeIdIndex,
60753                     PSIS_HW_DEVICE_INFO HwDeviceExtension)
60754  {
60755 -  SHORT  LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01,
60756 +  SHORT  LCDRefreshIndex[] = { 0x00, 0x00, 0x01, 0x01,
60757                                 0x01, 0x01, 0x01, 0x01,
60758                                0x01, 0x01, 0x01, 0x01,
60759 -                              0x01, 0x01, 0x01, 0x01 };
60760 +                              0x01, 0x01, 0x01, 0x01,
60761 +                              0x00, 0x00, 0x00, 0x00 };
60762    USHORT RefreshRateTableIndex,i,backup_i;
60763    USHORT modeflag,index,temp,backupindex;
60764  
60765 -  if(SiS_Pr->UseCustomMode) return 0;
60766 -  
60767 +  /* Do NOT check for UseCustomMode here, will skrew up FIFO */
60768 +  if(ModeNo == 0xfe) return 0;
60769 +
60770    if(ModeNo <= 0x13)
60771         modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
60772    else
60773 @@ -3984,7 +4155,7 @@ SiS_GetRatePtrCRT2(SiS_Private *SiS_Pr, 
60774  
60775    if(ModeNo < 0x14) return(0xFFFF);
60776  
60777 - /* TW: CR33 holds refresh rate index for CRT1 [3:0] and CRT2 [7:4].
60778 + /* CR33 holds refresh rate index for CRT1 [3:0] and CRT2 [7:4].
60779    *     On LVDS machines, CRT2 index is always 0 and will be
60780    *     set to 0 by the following code; this causes the function
60781    *     to take the first non-interlaced mode in SiS_Ext2Struct
60782 @@ -3998,40 +4169,38 @@ SiS_GetRatePtrCRT2(SiS_Private *SiS_Pr, 
60783    if(index > 0) index--;
60784  
60785    if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) {
60786 -      if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
60787 +     if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
60788          if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))  index = 0;
60789 -      } else {
60790 +     } else {
60791          if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
60792 -           if(SiS_Pr->SiS_VBType & VB_NoLCD)
60793 -                   index = 0;
60794 -           else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)
60795 -                   index = backupindex = 0;
60796 +          if(SiS_Pr->SiS_VBType & VB_NoLCD)
60797 +             index = 0;
60798 +          else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)
60799 +             index = backupindex = 0;
60800         }
60801 -      }
60802 -  }
60803 +     }
60804  
60805 -  if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) {
60806 -       if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
60807 -               if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
60808 -                       index = 0;
60809 -               }
60810 -       }
60811 -       if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
60812 -               if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
60813 -                       if(!(SiS_Pr->SiS_VBType & VB_NoLCD)) {
60814 -                          temp = LCDRefreshIndex[SiS_Pr->SiS_LCDResInfo];
60815 -                          if(index > temp) index = temp;
60816 -                       }
60817 -               } else {
60818 -                       index = 0;
60819 -               }
60820 -       }
60821 +     if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
60822 +        if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
60823 +           index = 0;
60824 +        }
60825 +     }
60826 +     if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
60827 +        if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
60828 +          if(!(SiS_Pr->SiS_VBType & VB_NoLCD)) {
60829 +              temp = LCDRefreshIndex[SiS_Pr->SiS_LCDResInfo];
60830 +              if(index > temp) index = temp;
60831 +          }
60832 +       } else {
60833 +           index = 0;
60834 +       }
60835 +     }
60836    }
60837  
60838    RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex;
60839    ModeNo = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].ModeID;
60840  
60841 -  /* TW: 650/LVDS 1.10.07, 650/30xLV 1.10.6s */
60842 +  /* 650/LVDS 1.10.07, 650/30xLV 1.10.6s */
60843    if(HwDeviceExtension->jChipType >= SIS_315H) {
60844       if(!(SiS_Pr->SiS_VBInfo & DriverMode)) {
60845          if( (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x105) ||
60846 @@ -4066,7 +4235,7 @@ SiS_GetRatePtrCRT2(SiS_Private *SiS_Pr, 
60847         backup_i = i;
60848         if (!(SiS_AdjustCRT2Rate(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
60849                                      RefreshRateTableIndex,&i,HwDeviceExtension))) {
60850 -               /* TW: This is for avoiding random data to be used; i is
60851 +               /* This is for avoiding random data to be used; i is
60852                  *     in an undefined state if no matching CRT2 mode is
60853                  *     found.
60854                  */
60855 @@ -4085,196 +4254,199 @@ SiS_AdjustCRT2Rate(SiS_Private *SiS_Pr, 
60856    USHORT tempax,tempbx,resinfo;
60857    USHORT modeflag,infoflag;
60858  
60859 -  if (ModeNo <= 0x13)
60860 +  if(ModeNo <= 0x13) {
60861         modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
60862 -  else
60863 +       resinfo = 0;
60864 +  } else {
60865         modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
60866 +        resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
60867 +  }
60868  
60869 -  resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
60870    tempbx = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].ModeID;
60871  
60872    tempax = 0;
60873 +
60874    if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
60875 +
60876         if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
60877                 tempax |= SupportRAMDAC2;
60878                 if(HwDeviceExtension->jChipType >= SIS_315H) {
60879 -                   tempax |= SupportTV;
60880 -                   if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
60881 -                       if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
60882 -                           if(resinfo == 0x0a) tempax |= SupportTV1024;
60883 -                       }
60884 -                   }
60885 +                  tempax |= SupportTV;
60886 +                  if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
60887 +                     if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
60888 +                        if(resinfo == SIS_RI_1600x1200) tempax |= SupportTV1024;
60889 +                     }
60890 +                  }
60891                 }
60892 -       }
60893 -       if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
60894 +       } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
60895                 tempax |= SupportLCD;
60896                 if(HwDeviceExtension->jChipType >= SIS_315H) {
60897                     if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) {
60898                       if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1400x1050) {
60899 -                        if((resinfo == 6) && (SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
60900 +                        if((resinfo == SIS_RI_640x480) && (SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
60901                             (*i) = 0;
60902                              return(1);
60903                          } else {
60904                             if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) {
60905 -                             if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960) {
60906 -                               if((resinfo == 6) && (SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
60907 -                                   return(0);
60908 -                               } else {
60909 -                                   if((resinfo >= 9) && (resinfo != 0x14)) {
60910 +                              if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960) {
60911 +                                 if((resinfo == SIS_RI_640x480) && (SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
60912 +                                    return(0);
60913 +                                 } else {
60914 +                                    if((resinfo >= SIS_RI_1280x1024) && (resinfo != SIS_RI_1280x768)) {
60915                                                 return(0);
60916 -                                   }
60917 -                               }
60918 -                             }
60919 +                                    }
60920 +                                 }
60921 +                              }
60922                             }
60923                          }
60924                       }
60925                    }
60926                 } else {
60927                   if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) {
60928 -                    if((resinfo != 0x0f) && ((resinfo == 4) || (resinfo >= 8))) return(0);
60929 +                    if( (resinfo != SIS_RI_1024x600) &&
60930 +                        ((resinfo == SIS_RI_512x384) || (resinfo >= SIS_RI_1024x768))) return(0);
60931                   } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) {
60932 -                    if((resinfo != 0x10) && (resinfo > 8)) return(0);
60933 +                    if((resinfo != SIS_RI_1152x768) && (resinfo > SIS_RI_1024x768)) return(0);
60934                   } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) {
60935 -                    if((resinfo != 0x0e) && (resinfo > 8)) return(0);
60936 +                    if((resinfo != SIS_RI_1280x960) && (resinfo > SIS_RI_1024x768)) return(0);
60937                   } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
60938 -                    if(resinfo > 9) return(0);
60939 +                    if(resinfo > SIS_RI_1280x1024) return(0);
60940                   } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
60941 -                    if(resinfo > 8) return(0);
60942 +                    if(resinfo > SIS_RI_1024x768) return(0);
60943                   } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) {
60944 -                    if((resinfo == 4) || (resinfo > 7)) return(0);
60945 +                    if((resinfo == SIS_RI_512x384) || (resinfo > SIS_RI_800x600)) return(0);
60946                   } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) {
60947 -                    if((resinfo == 4) || (resinfo == 3) || (resinfo > 6)) return(0);
60948 +                    if((resinfo == SIS_RI_512x384) ||
60949 +                       (resinfo == SIS_RI_400x300) ||
60950 +                       (resinfo > SIS_RI_640x480)) return(0);
60951                   }
60952                 }
60953 -       }
60954 -       if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) { 
60955 +       } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
60956                 if(SiS_Pr->SiS_HiVision == 3) {
60957                         tempax |= SupportHiVisionTV2;
60958                         if(SiS_Pr->SiS_VBInfo & SetInSlaveMode){
60959 -                               if(resinfo == 4) return(0);
60960 -                               if(resinfo == 3) return(0);
60961 -                               if(resinfo == 7) {
60962 +                               if(resinfo == SIS_RI_512x384) return(0);
60963 +                               if(resinfo == SIS_RI_400x300) return(0);
60964 +                               if(resinfo == SIS_RI_800x600) {
60965                                         if(SiS_Pr->SiS_SetFlag & TVSimuMode) return(0);
60966                                 }
60967 -                               if(resinfo > 7) return(0);
60968 +                               if(resinfo > SIS_RI_800x600) return(0);
60969                         }
60970                 } else {  
60971                         tempax |= SupportHiVisionTV;
60972                         if(SiS_Pr->SiS_VBInfo & SetInSlaveMode){
60973 -                               if(resinfo == 4) return(0);
60974 -                               if((resinfo == 3) || (resinfo == 7)) {
60975 +                               if(resinfo == SIS_RI_512x384) return(0);
60976 +                               if((resinfo == SIS_RI_400x300) || (resinfo == SIS_RI_800x600)) {
60977                                         if(SiS_Pr->SiS_SetFlag & TVSimuMode) return(0);
60978                                 }
60979 -                               if(resinfo > 7) return(0);
60980 +                               if(resinfo > SIS_RI_800x600) return(0);
60981                         }
60982                 }
60983 -       } else {
60984 -          if(SiS_Pr->SiS_VBInfo & (SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) {
60985 +       } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) {
60986                 tempax |= SupportTV;
60987                 tempax |= SupportTV1024;
60988                 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
60989 -                   if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
60990 -                       if((SiS_Pr->SiS_VBInfo & SetNotSimuMode) && (SiS_Pr->SiS_VBInfo & SetPALTV)) {
60991 -                            if(resinfo != 8) {
60992 -                                if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
60993 -                                    ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 4)) ) {
60994 -                                    tempax &= ~(SupportTV1024);
60995 -                                    if(HwDeviceExtension->jChipType >= SIS_315H) {
60996 -                                         if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
60997 -                                            if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
60998 -                                                ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) {
60999 -                                                if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0);
61000 -                                            }
61001 -                                        }
61002 -                                    } else {
61003 -                                        if( (resinfo != 3) ||
61004 -                                            (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
61005 -                                            (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) {
61006 -                                            if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
61007 -                                                if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61008 -                                                    if(resinfo == 3) return(0);
61009 -                                                    if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0);
61010 -                                                }
61011 -                                            }
61012 -                                         } else return(0);
61013 -                                    }
61014 -                                }
61015 -                            }
61016 -                       } else {
61017 -                           tempax &= ~(SupportTV1024);
61018 -                           if(HwDeviceExtension->jChipType >= SIS_315H) {
61019 -                               if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61020 -                                   if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
61021 -                                       ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) {
61022 +                  if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
61023 +                     if((SiS_Pr->SiS_VBInfo & SetNotSimuMode) && (SiS_Pr->SiS_VBInfo & SetPALTV)) {
61024 +                        if(resinfo != SIS_RI_1024x768) {
61025 +                           if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
61026 +                               ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != SIS_RI_512x384)) ) {
61027 +                              tempax &= ~(SupportTV1024);
61028 +                              if(HwDeviceExtension->jChipType >= SIS_315H) {
61029 +                                  if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61030 +                                    if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
61031 +                                        ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != SIS_RI_800x600)) ) {
61032                                         if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0);
61033 -                                   }
61034 -                               }
61035 -                           } else {
61036 -                               if( (resinfo != 3) ||
61037 -                                   (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
61038 -                                   (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) {
61039 -                                    if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
61040 -                                        if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61041 -                                            if(resinfo == 3) return(0);
61042 -                                            if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0);
61043 -                                        }
61044                                      }
61045 -                                } else return(0);
61046 -                            }
61047 -                       }
61048 -                   } else {  /* slavemode */
61049 -                       if(resinfo != 8) {
61050 -                           if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
61051 -                               ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 4) ) ) {
61052 -                                tempax &= ~(SupportTV1024);
61053 -                                if(HwDeviceExtension->jChipType >= SIS_315H) {
61054 -                                    if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61055 -                                        if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
61056 -                                            ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) {
61057 -                                            if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode))  return(0);
61058 -                                        }
61059 +                                 }
61060 +                              } else {
61061 +                                 if( (resinfo != SIS_RI_400x300) ||
61062 +                                     (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
61063 +                                     (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) {
61064 +                                    if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
61065 +                                       if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61066 +                                          if(resinfo == SIS_RI_400x300) return(0);
61067 +                                          if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0);
61068 +                                       }
61069                                      }
61070 -                               } else {
61071 -                                   if( (resinfo != 3) ||
61072 -                                       (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
61073 -                                       (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) {
61074 -                                        if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
61075 -                                            if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61076 -                                                if(resinfo == 3) return(0);
61077 -                                                if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0);
61078 -                                            }
61079 -                                        }
61080 -                                    } else return(0);
61081 -                               }
61082 +                                  } else return(0);
61083 +                              }
61084                             }
61085 -                       }
61086 -                   }
61087 -               } else {   /* 301 */
61088 -                   tempax &= ~(SupportTV1024);
61089 -                   if(HwDeviceExtension->jChipType >= SIS_315H) {
61090 -                       if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61091 -                           if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
61092 -                               ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != 7)) ) {
61093 -                               if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0);
61094 -                           }
61095 -                       }
61096 -                   } else {
61097 -                       if( (resinfo != 3) ||
61098 -                           (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
61099 -                           (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) {
61100 -                           if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
61101 -                               if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61102 -                                   if(resinfo == 3) return(0);
61103 -                                   if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0);
61104 -                               }
61105 +                        }
61106 +                     } else {
61107 +                        tempax &= ~(SupportTV1024);
61108 +                        if(HwDeviceExtension->jChipType >= SIS_315H) {
61109 +                           if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61110 +                              if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
61111 +                                  ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != SIS_RI_800x600)) ) {
61112 +                                 if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0);
61113 +                              }
61114                             }
61115 -                        } else return(0);
61116 -                   }
61117 -               }
61118 -           }
61119 -       }
61120 -       
61121 -  } else {     /* TW: for LVDS  */
61122 +                        } else {
61123 +                           if( (resinfo != SIS_RI_400x300) ||
61124 +                               (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
61125 +                               (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) {
61126 +                              if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
61127 +                                 if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61128 +                                    if(resinfo == SIS_RI_400x300) return(0);
61129 +                                    if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0);
61130 +                                 }
61131 +                              }
61132 +                            } else return(0);
61133 +                         }
61134 +                     }
61135 +                  } else {  /* slavemode */
61136 +                     if(resinfo != SIS_RI_1024x768) {
61137 +                        if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
61138 +                            ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != SIS_RI_512x384) ) ) {
61139 +                           tempax &= ~(SupportTV1024);
61140 +                           if(HwDeviceExtension->jChipType >= SIS_315H) {
61141 +                              if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61142 +                                 if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
61143 +                                     ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != SIS_RI_800x600)) ) {
61144 +                                    if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode))  return(0);
61145 +                                 }
61146 +                              }
61147 +                           } else {
61148 +                              if( (resinfo != SIS_RI_400x300) ||
61149 +                                  (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
61150 +                                  (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) {
61151 +                                 if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
61152 +                                    if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61153 +                                       if(resinfo == SIS_RI_400x300) return(0);
61154 +                                       if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0);
61155 +                                    }
61156 +                                 }
61157 +                               } else return(0);
61158 +                           }
61159 +                        }
61160 +                     }
61161 +                  }
61162 +               } else {   /* 301 */
61163 +                  tempax &= ~(SupportTV1024);
61164 +                  if(HwDeviceExtension->jChipType >= SIS_315H) {
61165 +                     if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61166 +                        if( (!(SiS_Pr->SiS_VBInfo & SetPALTV)) ||
61167 +                            ((SiS_Pr->SiS_VBInfo & SetPALTV) && (resinfo != SIS_RI_800x600)) ) {
61168 +                           if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return(0);
61169 +                        }
61170 +                     }
61171 +                  } else {
61172 +                     if( (resinfo != SIS_RI_400x300) ||
61173 +                         (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
61174 +                         (SiS_Pr->SiS_VBInfo & SetNotSimuMode) ) {
61175 +                        if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
61176 +                           if((modeflag & NoSupportSimuTV) && (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
61177 +                              if(resinfo == SIS_RI_400x300) return(0);
61178 +                              if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) return (0);
61179 +                           }
61180 +                        }
61181 +                      } else return(0);
61182 +                  }
61183 +               }
61184 +        }
61185 +
61186 +  } else {     /* for LVDS  */
61187  
61188         if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
61189                 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
61190 @@ -4284,24 +4456,33 @@ SiS_AdjustCRT2Rate(SiS_Private *SiS_Pr, 
61191         if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
61192                 tempax |= SupportLCD;
61193                 if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) {
61194 -                    if((resinfo != 0x14) && (resinfo > 0x09)) return(0);
61195 +                    if((resinfo != SIS_RI_1280x768) && (resinfo >= SIS_RI_1280x1024)) return(0);
61196                 } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) {
61197 -                    if((resinfo != 0x0f) && (resinfo > 0x08)) return(0);
61198 +                    if((resinfo != SIS_RI_1024x600) && (resinfo >= SIS_RI_1024x768))  return(0);
61199                 } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) {
61200 -                    if((resinfo != 0x10) && (resinfo > 0x08)) return(0);
61201 +                    if((resinfo != SIS_RI_1152x768) && (resinfo > SIS_RI_1024x768))   return(0);
61202                 } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
61203 -                    if((resinfo != 0x15) && (resinfo > 0x09)) return(0);
61204 +                    if((resinfo != SIS_RI_1400x1050) && (resinfo > SIS_RI_1280x1024)) return(0);
61205 +               } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) {
61206 +                     if(resinfo > SIS_RI_1600x1200) return(0);
61207                 } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
61208 -                     if(resinfo > 0x09) return(0);
61209 +                     if(resinfo > SIS_RI_1280x1024) return(0);
61210                  } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
61211 -                    if(resinfo > 0x08) return(0);
61212 +                    if(resinfo > SIS_RI_1024x768)  return(0);
61213                 } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600){
61214 -                    if(resinfo > 0x07) return(0);
61215 -                    if(resinfo == 0x04) return(0);
61216 +                    if(resinfo > SIS_RI_800x600)   return(0);
61217 +                    if(resinfo == SIS_RI_512x384)  return(0);
61218 +               } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelBarco1366) {
61219 +                     if((resinfo != SIS_RI_1360x1024) && (resinfo > SIS_RI_1280x1024)) return(0);
61220 +               }  else if(SiS_Pr->SiS_LCDResInfo == Panel_848x480) {
61221 +                     if((resinfo != SIS_RI_1360x768) &&
61222 +                       (resinfo != SIS_RI_848x480)  &&
61223 +                       (resinfo > SIS_RI_1024x768)) return(0);
61224                 }
61225         }
61226    }
61227 -  /* TW: Look backwards in table for matching CRT2 mode */
61228 +
61229 +  /* Look backwards in table for matching CRT2 mode */
61230    for(; SiS_Pr->SiS_RefIndex[RefreshRateTableIndex+(*i)].ModeID == tempbx; (*i)--) {
61231         infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex + (*i)].Ext_InfoFlag;
61232         if(infoflag & tempax) {
61233 @@ -4309,7 +4490,7 @@ SiS_AdjustCRT2Rate(SiS_Private *SiS_Pr, 
61234         }
61235         if ((*i) == 0) break;
61236    }
61237 -  /* TW: Look through the whole mode-section of the table from the beginning
61238 +  /* Look through the whole mode-section of the table from the beginning
61239     *     for a matching CRT2 mode if no mode was found yet.
61240     */
61241    for((*i) = 0; ; (*i)++) {
61242 @@ -4329,7 +4510,7 @@ SiS_SaveCRT2Info(SiS_Private *SiS_Pr, US
61243  {
61244    USHORT temp1,temp2;
61245  
61246 -  /* TW: We store CRT1 ModeNo in CR34 */
61247 +  /* We store CRT1 ModeNo in CR34 */
61248    SiS_SetReg1(SiS_Pr->SiS_P3d4,0x34,ModeNo);
61249    temp1 = (SiS_Pr->SiS_VBInfo & SetInSlaveMode) >> 8;
61250    temp2 = ~(SetInSlaveMode >> 8);
61251 @@ -4345,16 +4526,16 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHOR
61252    USHORT modeflag, resinfo=0;
61253    UCHAR  OutputSelect = *SiS_Pr->pSiS_OutputSelect;
61254  
61255 -  if(SiS_Pr->UseCustomMode) {
61256 -        modeflag = SiS_Pr->CModeFlag;
61257 +  if(ModeNo <= 0x13) {
61258 +     modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
61259    } else {
61260 -    if (ModeNo <= 0x13)
61261 -       modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
61262 -    else {
61263 +     if(SiS_Pr->UseCustomMode) {
61264 +        modeflag = SiS_Pr->CModeFlag;
61265 +     } else {
61266         modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
61267         resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
61268 -    }
61269 -  }    
61270 +     }
61271 +  }
61272  
61273    SiS_Pr->SiS_SetFlag = 0;
61274  
61275 @@ -4364,22 +4545,24 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHOR
61276    if(SiS_BridgeIsOn(SiS_Pr,BaseAddr,HwDeviceExtension) == 0) {  
61277         temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
61278  #if 0  
61279 -       /* SiS_HiVision is only used on 310/325/330+30xLV */
61280 +       /* SiS_HiVision is only used on 315/330+30xLV */
61281         if(SiS_Pr->SiS_VBType & (VB_SIS301LV302LV)) {
61282 -          if(SiS_Pr->SiS_HiVision & 0x03) {    /* TW: New from 650/30xLV 1.10.6s */
61283 +          if(SiS_Pr->SiS_HiVision & 0x03) {    /* New from 650/30xLV 1.10.6s */
61284               temp &= (SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode);   /* 0x83 */
61285               temp |= SetCRT2ToHiVisionTV;                                      /* 0x80 */
61286            }
61287 -          if(SiS_Pr->SiS_HiVision & 0x04) {    /* TW: New from 650/30xLV 1.10.6s */
61288 +          if(SiS_Pr->SiS_HiVision & 0x04) {    /* New from 650/30xLV 1.10.6s */
61289               temp &= (SetCRT2ToHiVisionTV | SwitchToCRT2 | SetSimuScanMode);   /* 0x83 */
61290               temp |= SetCRT2ToSVIDEO;                                          /* 0x08 */
61291            }
61292         }
61293 -#endif 
61294 +#endif
61295 +#if 0
61296         if(SiS_Pr->SiS_IF_DEF_FSTN) {   /* fstn must set CR30=0x21 */
61297                         temp = (SetCRT2ToLCD | SetSimuScanMode);
61298                         SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,temp);
61299         }
61300 +#endif
61301         tempbx |= temp;
61302         tempax = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) << 8;
61303          tempax &= (LoadDACFlag | DriverMode | SetDispDevSwitch | SetNotSimuMode | SetPALTV);
61304 @@ -4519,7 +4702,7 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHOR
61305                 tempbx |= SetSimuScanMode;
61306         }
61307  
61308 -       /* TW: LVDS (LCD/TV) and 301BDH (LCD) can only be slave in 8bpp modes */
61309 +       /* LVDS (LCD/TV) and 301BDH (LCD) can only be slave in 8bpp modes */
61310         if(SiS_Pr->SiS_ModeType <= ModeVGA) {
61311            if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) ||
61312                ((tempbx & SetCRT2ToLCD) && (SiS_Pr->SiS_VBType & VB_NoLCD)) ) {
61313 @@ -4527,12 +4710,12 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHOR
61314            }
61315         }
61316         
61317 -       if(!(tempbx & SetSimuScanMode)){
61318 +       if(!(tempbx & SetSimuScanMode)) {
61319             if(tempbx & SwitchToCRT2) {
61320                 if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) {
61321                      if( (HwDeviceExtension->jChipType >= SIS_315H) &&
61322                          (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) {
61323 -                        if(resinfo != 0x0a)
61324 +                        if(resinfo != SIS_RI_1600x1200)
61325                                tempbx |= SetSimuScanMode;
61326                      } else {
61327                               tempbx |= SetSimuScanMode;
61328 @@ -4555,7 +4738,7 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHOR
61329                     if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) {
61330                         if( (HwDeviceExtension->jChipType >= SIS_315H) &&
61331                             (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) {
61332 -                            if(resinfo != 0x0a) {  /* TW: 650/301 BIOS */
61333 +                            if(resinfo != SIS_RI_1600x1200) {  /* 650/301 BIOS */
61334                                   tempbx |= SetInSlaveMode;
61335                                   if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
61336                                      if(tempbx & SetCRT2ToTV) {
61337 @@ -4563,7 +4746,7 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHOR
61338                                              SiS_Pr->SiS_SetFlag |= TVSimuMode;
61339                                      }
61340                                    }
61341 -                            }                      /* TW: 650/301 BIOS */
61342 +                            }                      /* 650/301 BIOS */
61343                         } else {
61344                             tempbx |= SetInSlaveMode;
61345                             if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
61346 @@ -4621,7 +4804,7 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHOR
61347         if(HwDeviceExtension->jChipType >= SIS_315H) {
61348                 if(ROMAddr && SiS_Pr->SiS_UseROM) {
61349                     OutputSelect = ROMAddr[0xf3];
61350 -                   if(HwDeviceExtension->jChipType == SIS_330) {
61351 +                   if(HwDeviceExtension->jChipType >= SIS_330) {
61352                         OutputSelect = ROMAddr[0x11b];
61353                     }
61354                  }
61355 @@ -4652,7 +4835,7 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHOR
61356    SiS_Pr->SiS_VBInfo = tempbx;
61357  
61358    if(HwDeviceExtension->jChipType == SIS_630) {
61359 -       SiS_WhatIsThis(SiS_Pr, SiS_Pr->SiS_VBInfo);
61360 +       SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo);
61361    }
61362  
61363  #ifdef TWDEBUG
61364 @@ -4666,61 +4849,35 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHOR
61365  #endif
61366  #endif
61367  
61368 -#if 0  /* TW: Incomplete! (But does not seem to be required) */
61369 -  if(HwDeviceExtension->jChipType < SIS_315H) {
61370 -     /* TW: From A901/630+301B BIOS */
61371 -     if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
61372 -         if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80)
61373 -     }
61374 -     if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
61375 -         if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x80)
61376 -            if( [si] == 3) ModeIdIndex = 0x3f2b;
61377 -        }
61378 -     }
61379 -     SiS_SetRegAND(SiS_Pr->SiS_P3d4, 0x31, 0xF7);
61380 -     if(ModeNo == 0x13) bp+4 = 0x03;
61381 -  } else {
61382 -     /* From 650/30xLV BIOS: */
61383 -     SiS_SetRegAND(SiS_Pr->SiS_P3d4, 0x31, 0xF7);
61384 -     if(ModeNo == 0x13) bp+4 = 0x03;
61385 -     else bp+4 = ModeNo;
61386 -  }
61387 -#endif
61388 -
61389 -  /* TW: 630/301B and 650/301 (not 301LV!) BIOSes do more here, but this seems for DOS mode */
61390 -
61391  }
61392  
61393 +/* Setup general purpose IO for Chrontel communication */
61394  void
61395 -SiS_WhatIsThis(SiS_Private *SiS_Pr, USHORT myvbinfo)
61396 +SiS_SetChrontelGPIO(SiS_Private *SiS_Pr, USHORT myvbinfo)
61397  {
61398 -   unsigned long eax, temp;
61399 -   unsigned short temp1;
61400 +   unsigned long  acpibase;
61401 +   unsigned short temp;
61402  
61403     if(!(SiS_Pr->SiS_ChSW)) return;
61404  
61405  #ifndef LINUX_XF86
61406 -   SiS_SetReg4(0xcf8,0x80000874);
61407 -   eax = SiS_GetReg3(0xcfc);
61408 +   SiS_SetReg4(0xcf8,0x80000874);                 /* get ACPI base */
61409 +   acpibase = SiS_GetReg3(0xcfc);
61410  #else
61411 -   eax = pciReadLong(0x00000800, 0x74);
61412 +   acpibase = pciReadLong(0x00000800, 0x74);
61413  #endif
61414 -   eax &= 0xFFFF;
61415 -   temp = eax;
61416 -   eax += 0x3c;
61417 -   temp1 = SiS_GetReg4((USHORT)eax);
61418 -   temp1 &= 0xFEFF;
61419 -   SiS_SetReg5((USHORT)eax, temp1);
61420 -   temp1 = SiS_GetReg4((USHORT)eax);
61421 -   eax = temp;
61422 -   eax += 0x3a;
61423 -   temp1 = SiS_GetReg4((USHORT)eax);
61424 -   temp1 &= 0xFEFF;
61425 +   acpibase &= 0xFFFF;
61426 +   temp = SiS_GetReg4((USHORT)(acpibase + 0x3c));  /* ACPI register 0x3c: GP Event 1 I/O mode select */
61427 +   temp &= 0xFEFF;
61428 +   SiS_SetReg5((USHORT)(acpibase + 0x3c), temp);
61429 +   temp = SiS_GetReg4((USHORT)(acpibase + 0x3c));
61430 +   temp = SiS_GetReg4((USHORT)(acpibase + 0x3a));  /* ACPI register 0x3a: GP Pin Level (low/high) */
61431 +   temp &= 0xFEFF;
61432     if(!(myvbinfo & SetCRT2ToTV)) {
61433 -      temp1 |= 0x0100;
61434 +      temp |= 0x0100;
61435     }
61436 -   SiS_SetReg5((USHORT)eax, temp1);
61437 -   temp1 = SiS_GetReg4((USHORT)eax);
61438 +   SiS_SetReg5((USHORT)(acpibase + 0x3a), temp);
61439 +   temp = SiS_GetReg4((USHORT)(acpibase + 0x3a));
61440  }
61441  
61442  void
61443 @@ -4731,14 +4888,14 @@ SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr, 
61444    USHORT temp1=0,modeflag=0,tempcx=0;
61445    USHORT StandTableIndex,CRT1Index;
61446  #ifdef SIS315H   
61447 -  USHORT ResInfo,DisplayType,temp=0;
61448 +  USHORT ResIndex,DisplayType,temp=0;
61449    const  SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr = NULL;
61450  #endif
61451  
61452    SiS_Pr->SiS_RVBHCMAX  = 1;
61453    SiS_Pr->SiS_RVBHCFACT = 1;
61454  
61455 -  if(ModeNo <= 0x13){
61456 +  if(ModeNo <= 0x13) {
61457  
61458         modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
61459         StandTableIndex = SiS_GetModePtr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex);
61460 @@ -4752,7 +4909,7 @@ SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr, 
61461  
61462  #ifdef SIS315H     
61463         temp = SiS_GetLVDSCRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
61464 -                       RefreshRateTableIndex,&ResInfo,&DisplayType);
61465 +                       RefreshRateTableIndex,&ResIndex,&DisplayType);
61466  
61467         if(temp == 0)  return;
61468  
61469 @@ -4795,16 +4952,16 @@ SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr, 
61470                 case 99: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL;                break;
61471                 default: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1;          break;
61472         }
61473 -       tempax = (LVDSCRT1Ptr+ResInfo)->CR[0];
61474 -       tempax |= (LVDSCRT1Ptr+ResInfo)->CR[14] << 8;
61475 +       tempax = (LVDSCRT1Ptr+ResIndex)->CR[0];
61476 +       tempax |= (LVDSCRT1Ptr+ResIndex)->CR[14] << 8;
61477         tempax &= 0x03FF;
61478 -       tempbx = (LVDSCRT1Ptr+ResInfo)->CR[6];
61479 -       tempcx = (LVDSCRT1Ptr+ResInfo)->CR[13] << 8;
61480 +       tempbx = (LVDSCRT1Ptr+ResIndex)->CR[6];
61481 +       tempcx = (LVDSCRT1Ptr+ResIndex)->CR[13] << 8;
61482         tempcx &= 0x0100;
61483         tempcx <<= 2;
61484         tempbx |= tempcx;
61485 -       temp1  = (LVDSCRT1Ptr+ResInfo)->CR[7];
61486 -#endif 
61487 +       temp1  = (LVDSCRT1Ptr+ResIndex)->CR[7];
61488 +#endif
61489  
61490      } else {
61491  
61492 @@ -4840,11 +4997,12 @@ SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr, 
61493    if(modeflag & Charx8Dot) tempax *= 8;
61494    else                     tempax *= 9;
61495  
61496 -  /* TW: From 650/30xLV 1.10.6s */
61497 +  /* From 650/30xLV 1.10.6s */
61498    if(modeflag & HalfDCLK)  tempax <<= 1;
61499  
61500 -  SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax;
61501    tempbx++;
61502 +
61503 +  SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax;
61504    SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = tempbx;
61505  }
61506  
61507 @@ -4852,18 +5010,18 @@ void
61508  SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr)
61509  {
61510    if(HwDeviceExtension->jChipType >= SIS_315H)
61511 -       SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2f,0x01);
61512 +     SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2f,0x01);
61513    else
61514 -       SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01);
61515 +     SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01);
61516  }
61517  
61518  void
61519  SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr)
61520  {
61521    if(HwDeviceExtension->jChipType >= SIS_315H)
61522 -       SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2F,0xFE);
61523 +     SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2F,0xFE);
61524    else
61525 -       SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x24,0xFE);
61526 +     SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x24,0xFE);
61527  }
61528  
61529  void
61530 @@ -4872,7 +5030,6 @@ SiS_EnableCRT2(SiS_Private *SiS_Pr)
61531    SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);
61532  }
61533  
61534 -/* Checked against all BIOSes */
61535  void
61536  SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr)
61537  {
61538 @@ -4882,9 +5039,9 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61539    USHORT temp=0;
61540    UCHAR *ROMAddr = HwDeviceExtension->pjVirtualRomBase;
61541  
61542 -  if (SiS_Pr->SiS_IF_DEF_LVDS == 0) {
61543 +  if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
61544  
61545 -      if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {   /* ===== TW: For 30xB/LV ===== */
61546 +      if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {   /* ===== For 30xB/LV ===== */
61547  
61548          if(HwDeviceExtension->jChipType < SIS_315H) {
61549  
61550 @@ -4940,9 +5097,9 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61551  
61552          } else {
61553  
61554 -#ifdef SIS315H    /* 310/325 series */
61555 +#ifdef SIS315H    /* 315 series */
61556  
61557 -           if(IS_SIS650740) {          /* 650, 740 */
61558 +           if(IS_SIS550650740660) {            /* 550, 650, 740, 660 */
61559  
61560  #if 0
61561               if(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00) != 1) return;  /* From 1.10.7w */
61562 @@ -4950,40 +5107,67 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61563  
61564               modenum = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x34);
61565  
61566 -              if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
61567 +              if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {                      /* LV */
61568               
61569                  SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);
61570                  
61571                  if( (modenum <= 0x13) ||
61572                      (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) ||
61573                      (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ) {
61574 -                     SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00);
61575 +                     SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE);
61576 +                     if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
61577 +                        SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
61578 +                     }
61579                  }
61580 -                SiS_DDC2Delay(SiS_Pr,0xff00);
61581 -                SiS_DDC2Delay(SiS_Pr,0x6000);
61582 -                SiS_DDC2Delay(SiS_Pr,0x8000);
61583  
61584 -                SiS_SetReg3(SiS_Pr->SiS_P3c6,0x00);
61585 +                if(SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) {
61586 +                   SiS_DDC2Delay(SiS_Pr,0xff00);
61587 +                   SiS_DDC2Delay(SiS_Pr,0x6000);
61588 +                   SiS_DDC2Delay(SiS_Pr,0x8000);
61589  
61590 -                 pushax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06);
61591 -                
61592 -                if(IS_SIS740) {
61593 -                   SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3);
61594 +                   SiS_SetReg3(SiS_Pr->SiS_P3c6,0x00);
61595 +
61596 +                    pushax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06);
61597 +
61598 +                   if(IS_SIS740) {
61599 +                      SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3);
61600 +                   }
61601 +
61602 +                   SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
61603 +
61604 +                   if(!(IS_SIS740)) {
61605 +                      if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61606 +                         tempah = 0xef;
61607 +                         if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
61608 +                            tempah = 0xf7;
61609 +                          }
61610 +                         SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah);
61611 +                      }
61612 +                   }
61613                  }
61614  
61615 -                SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
61616 -                
61617 -                if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61618 -                   tempah = 0xef;
61619 -                   if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
61620 -                      tempah = 0xf7;
61621 -                    }
61622 -                   SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah);
61623 -                }
61624 +              } else if(SiS_Pr->SiS_VBType & VB_NoLCD) {                       /* B-DH */
61625 +                /* This is actually bullshit. The B-DH bridge has cetainly no
61626 +                 * Part4 Index 26, since it has no ability to drive LCD panels
61627 +                 * at all. But as the BIOS does it, we do it, too...
61628 +                 */
61629 +                if(HwDeviceExtension->jChipType == SIS_650) {
61630 +                   if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61631 +                      SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,0xef);
61632 +                   }
61633 +                   if((!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) ||
61634 +                      (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ) {
61635 +                      SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00);
61636 +                   }
61637 +                   SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 3);
61638 +                }
61639 +             }
61640  
61641 -              }
61642 +             if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
61643 +                SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,0xef);
61644 +             }
61645  
61646 -              if(SiS_Pr->SiS_VBType & VB_SIS301B302B) {
61647 +              if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280)) {
61648                  tempah = 0x3f;
61649                  if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) {
61650                     tempah = 0x7f;
61651 @@ -4997,7 +5181,7 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61652                if((SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ||
61653                  ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) {
61654  
61655 -                if(SiS_Pr->SiS_VBType & VB_SIS301B302B) {
61656 +                if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280)) {
61657                     SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF);
61658                     SiS_DisplayOff(SiS_Pr);
61659                     SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
61660 @@ -5020,7 +5204,7 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61661  
61662               } else {
61663  
61664 -                if(SiS_Pr->SiS_VBType & VB_SIS301B302B) {
61665 +                if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280)) {
61666                     if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61667                        SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf);
61668                        SiS_DisplayOff(SiS_Pr);
61669 @@ -5044,10 +5228,10 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61670  
61671               }
61672  
61673 -             if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
61674 +             if((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (SiS_Pr->SiS_CustomT != CUT_COMPAQ1280)) {
61675 +
61676 +                SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,~0x10);               /* 1.10.8r, 8m */
61677  
61678 -                SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,~0x10);    /* 1.10.8r */
61679 -                
61680                  tempah = 0x3f;
61681                  if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) {
61682                     tempah = 0x7f;
61683 @@ -5057,9 +5241,9 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61684                  }
61685                  SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah);
61686  
61687 -                if(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr)) {   /* 1.10.8r */
61688 +                if(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr)) {   /* 1.10.8r, 8m */
61689                     SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
61690 -                }                                                              /* 1.10.8r */
61691 +                }                                                              /* 1.10.8r, 8m */
61692  
61693                  if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61694                     SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf);
61695 @@ -5075,80 +5259,47 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61696  
61697                  SiS_SetReg1(SiS_Pr->SiS_P3c4,0x06,pushax);
61698  
61699 -             }
61700 +             } else if(SiS_Pr->SiS_VBType & VB_NoLCD) {
61701  
61702 -#if 0
61703 -          } else if(IS_SIS740) {       /* 740 */
61704 -         
61705 -            if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {   /* 30xLV */
61706 -            
61707 -               if( (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) ||
61708 -                   (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ) {
61709 -                     SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00);
61710 -               }
61711 -               
61712 -               SiS_SetReg3(SiS_Pr->SiS_P3c6,0x00);
61713 +                if(HwDeviceExtension->jChipType == SIS_650) {
61714 +                   if((SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ||
61715 +                      (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)))) {
61716 +                      if((!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) ||
61717 +                         (!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)))) {
61718 +                         SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 2);
61719 +                         SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD);
61720 +                         SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 4);
61721 +                      }
61722 +                   }
61723 +                }
61724  
61725 -                pushax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06);
61726 -               
61727 -               SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3);
61728 +             } else if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280)) {
61729  
61730 -               SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
61731 -               
61732 -               if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
61733 -                  SiS_DisplayOff(SiS_Pr);
61734 -                  SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2);
61735 -                  SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
61736 -                  SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF);
61737 -               } else {
61738 -                  SiS_DisplayOff(SiS_Pr);
61739 -                  SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80);
61740 -                  SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2);
61741 -                  SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
61742 -                  temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00);
61743 -                   SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10);
61744 -                  SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
61745 -                  SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp);
61746 -               }
61747 -               
61748 -               SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,0x3F);
61749 -               SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,0xEF);  /* (from 650) */
61750 -               
61751 -               SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
61752 -               
61753 -               if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61754 -                  SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf);
61755 -               }
61756 -               
61757 -               if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61758 -                  if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61759 -                     if(!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) {
61760 -                        if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61761 -                           SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFD,0x00);
61762 -                         }
61763 -                      }
61764 -                  }
61765 -               }
61766 -               SiS_SetReg1(SiS_Pr->SiS_P3c4,0x06,pushax);
61767 -            
61768 -            } else {   /* (301,) 301B */
61769 -         
61770 -               if(SiS_Is301B(SiS_Pr,BaseAddr)) {
61771 -                  SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,0x3F);
61772 -               }
61773 -            
61774 -               SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF);
61775 -               SiS_DisplayOff(SiS_Pr);
61776 -               SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80);
61777 -               SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
61778 +                if(HwDeviceExtension->jChipType == SIS_650) {
61779 +                   if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61780 +                      tempah = 0xef;
61781 +                      if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) {
61782 +                         if(modenum > 0x13) {
61783 +                            tempah = 0xf7;
61784 +                         }
61785 +                       }
61786 +                      SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah);
61787 +                   }
61788 +                   if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
61789 +                      if((SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ||
61790 +                         (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)))) {
61791 +                         if((!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) ||
61792 +                            (!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)))) {
61793 +                            SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 2);
61794 +                            SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD);
61795 +                            SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 4);
61796 +                         }
61797 +                      }
61798 +                   }
61799 +                }
61800 +
61801 +             }
61802  
61803 -               temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00);
61804 -                SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10);
61805 -               SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
61806 -               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp);
61807 -               
61808 -            }
61809 -#endif   
61810           } else {                      /* 315, 330 - all bridge types */
61811  
61812              if(SiS_Is301B(SiS_Pr,BaseAddr)) {
61813 @@ -5193,13 +5344,13 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61814  
61815         }
61816  
61817 -      } else {     /* ============ TW: For 301 ================ */
61818 +      } else {     /* ============ For 301 ================ */
61819  
61820          if(HwDeviceExtension->jChipType < SIS_315H) {
61821 -            if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) {
61822 -                SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF0,0x0B);
61823 -               SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 1);
61824 -           }
61825 +            if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) {
61826 +             SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08);
61827 +             SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
61828 +          }
61829         }
61830  
61831          SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF);           /* disable VB */
61832 @@ -5218,18 +5369,23 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61833             SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x00,temp);
61834         } else {
61835              SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);            /* disable CRT2 */
61836 +           if( (!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) ||
61837 +               (!(SiS_CR36BIOSWord23d(SiS_Pr,HwDeviceExtension))) ) {
61838 +               SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2);
61839 +               SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xFB,0x04);
61840 +           }
61841         }
61842  
61843        }
61844  
61845 -  } else {     /* ============ TW: For LVDS =============*/
61846 +  } else {     /* ============ For LVDS =============*/
61847  
61848      if(HwDeviceExtension->jChipType < SIS_315H) {
61849  
61850  #ifdef SIS300  /* 300 series */
61851  
61852         if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
61853 -           SiS_SetCH700x(SiS_Pr,0x090E);
61854 +          SiS_SetCH700x(SiS_Pr,0x090E);
61855         }
61856  
61857         if(HwDeviceExtension->jChipType == SIS_730) {
61858 @@ -5245,17 +5401,17 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61859  
61860               if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x40)) {
61861    
61862 -                 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) {
61863 +                if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) {
61864  
61865 -                     SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
61866 +                    SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
61867  
61868 -                    if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06) & 0x1c)) {
61869 -                        SiS_DisplayOff(SiS_Pr);
61870 -                    }
61871 +                   if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06) & 0x1c)) {
61872 +                       SiS_DisplayOff(SiS_Pr);
61873 +                   }
61874  
61875 -                    SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08);
61876 -                    SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
61877 -                  }
61878 +                   SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF7,0x08);
61879 +                   SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
61880 +                 }
61881                }
61882            }
61883         }
61884 @@ -5279,29 +5435,40 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61885  
61886      } else {
61887  
61888 -#ifdef SIS315H /* 310/325 series */
61889 +#ifdef SIS315H /* 315 series */
61890  
61891         if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
61892 -               temp = SiS_GetCH701x(SiS_Pr,0x61);
61893 -               if(temp < 1) {
61894 -                  SiS_SetCH701x(SiS_Pr,0xac76);
61895 -                  SiS_SetCH701x(SiS_Pr,0x0066);
61896 -               }
61897 -               
61898 -               if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61899 +
61900 +               if(HwDeviceExtension->jChipType == SIS_740) {
61901 +                  temp = SiS_GetCH701x(SiS_Pr,0x61);
61902 +                  if(temp < 1) {
61903 +                     SiS_SetCH701x(SiS_Pr,0xac76);
61904 +                     SiS_SetCH701x(SiS_Pr,0x0066);
61905 +                  }
61906 +
61907 +                  if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61908                         SiS_SetCH701x(SiS_Pr,0x3e49);
61909 -               } else if(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwDeviceExtension, BaseAddr))  {
61910 +                  } else if(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwDeviceExtension, BaseAddr))  {
61911                         SiS_SetCH701x(SiS_Pr,0x3e49);
61912 +                  }
61913                 }
61914 -               
61915 +
61916                 if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61917                         SiS_Chrontel701xBLOff(SiS_Pr);
61918 -                       SiS_Chrontel701xOff(SiS_Pr);
61919 +                       SiS_Chrontel701xOff(SiS_Pr,HwDeviceExtension);
61920                 } else if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
61921                         SiS_Chrontel701xBLOff(SiS_Pr);
61922 -                       SiS_Chrontel701xOff(SiS_Pr);
61923 +                       SiS_Chrontel701xOff(SiS_Pr,HwDeviceExtension);
61924                 }
61925 -               
61926 +
61927 +               if(HwDeviceExtension->jChipType != SIS_740) {
61928 +                  if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61929 +                       SiS_SetCH701x(SiS_Pr,0x0149);
61930 +                  } else if(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwDeviceExtension, BaseAddr))  {
61931 +                       SiS_SetCH701x(SiS_Pr,0x0149);
61932 +                  }
61933 +               }
61934 +
61935         }
61936  
61937         if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
61938 @@ -5325,6 +5492,10 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61939                 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80);
61940         }
61941  
61942 +       if(HwDeviceExtension->jChipType == SIS_740) {
61943 +          SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
61944 +       }
61945 +
61946         SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
61947  
61948         if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
61949 @@ -5337,15 +5508,27 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61950  
61951         if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
61952                 if(SiS_CRT2IsLCD(SiS_Pr, BaseAddr,HwDeviceExtension)) {
61953 -                       SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf);
61954 +                  SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf);
61955 +                  if(HwDeviceExtension->jChipType == SIS_550) {
61956 +                     SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xbf);
61957 +                     SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xef);
61958 +                  }
61959 +               }
61960 +       } else {
61961 +          if(HwDeviceExtension->jChipType == SIS_740) {
61962 +               if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension, BaseAddr)) {
61963 +                  SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf);
61964                 }
61965 -       } else if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension, BaseAddr)) {
61966 -               SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf);
61967 +          } else {
61968 +               if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
61969 +                  SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf);
61970 +               }
61971 +          }
61972         }
61973  
61974         if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
61975                 if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) {
61976 -                       SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xff);
61977 +                       /* SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xff); */
61978                 } else {
61979                         SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb);
61980                 }
61981 @@ -5353,7 +5536,10 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61982  
61983         SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr);
61984  
61985 -       if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
61986 +       if(HwDeviceExtension->jChipType == SIS_550) {
61987 +               SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80);
61988 +               SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40);
61989 +       } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
61990                 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7);
61991         } else if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
61992                 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7);
61993 @@ -5361,7 +5547,7 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
61994                 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7);
61995         }
61996  
61997 -#if 0  /* TW: BIOS code makes no sense */
61998 +#if 0  /* BIOS code makes no sense */
61999         if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
62000             if(!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62001                 if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) {
62002 @@ -5387,7 +5573,6 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, P
62003  
62004  }
62005  
62006 -/* TW: Checked against all BIOSes */
62007  void
62008  SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
62009  {
62010 @@ -5400,7 +5585,7 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PS
62011  
62012    if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
62013  
62014 -    if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {   /* TW: ====== For 301B et al  ====== */
62015 +    if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {   /* ====== For 301B et al  ====== */
62016  
62017        if(HwDeviceExtension->jChipType < SIS_315H) {
62018  
62019 @@ -5497,48 +5682,95 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PS
62020  
62021        } else {
62022  
62023 -#ifdef SIS315H    /* 310/325 series */
62024 +#ifdef SIS315H    /* 315 series */
62025  
62026 -        if(IS_SIS650740) {             /* 650 */
62027 +        if(IS_SIS550650740660) {               /* 550, 650, 740, 660 */
62028  
62029  #if 0
62030             if(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00) != 1) return;    /* From 1.10.7w */
62031  #endif
62032  
62033             if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
62034 -           
62035 -              SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0xef);  /* 1.10.7u */
62036 -              SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);    /* 1.10.7u */
62037 +
62038 +              if(SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) {
62039 +                 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0xef);  /* 1.10.7u */
62040 +                 SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);    /* 1.10.7u */
62041 +              }
62042  
62043                if(!(IS_SIS740)) {
62044                    if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62045                      tempah = 0x10;
62046 -                    if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
62047 -                       tempah = 0x08;
62048 -                     }
62049 -                    SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,tempah);
62050 +                    if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
62051 +                       if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x13) & 0x04) {
62052 +                          if((SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) == 0x0c) {
62053 +                             tempah = 0x08;
62054 +                          } else {
62055 +                             tempah = 0x18;
62056 +                          }
62057 +                       }
62058 +                       SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x4c,tempah);
62059 +                    } else {
62060 +                       if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
62061 +                          tempah = 0x08;
62062 +                        }
62063 +                       SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,tempah);
62064 +                    }
62065                   }
62066                }
62067  
62068 -              SiS_SetReg3(SiS_Pr->SiS_P3c6,0x00);
62069 -              SiS_DisplayOff(SiS_Pr);
62070 -              pushax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06);
62071 -              if(IS_SIS740) {
62072 -                 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3);
62073 +              if(SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) {
62074 +                 SiS_SetReg3(SiS_Pr->SiS_P3c6,0x00);
62075 +                 SiS_DisplayOff(SiS_Pr);
62076 +                 pushax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06);
62077 +                 if(IS_SIS740) {
62078 +                    SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3);
62079 +                 }
62080                }
62081  
62082                if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ||
62083                    (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) {
62084 -                   if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) {
62085 -                     SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 2);
62086 -                     SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02);
62087 -                     SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 2);
62088 -                  }
62089 +                  if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) {
62090 +                    if(SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) {
62091 +                       SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 2);
62092 +                    }
62093 +                    SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02);
62094 +                    SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 2);
62095 +                 }
62096 +              }
62097 +
62098 +               if(SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) {
62099 +                 if(!(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x40)) {
62100 +                     SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 10);
62101 +                    delaylong = TRUE;
62102 +                 }
62103 +              }
62104 +
62105 +           } else if(SiS_Pr->SiS_VBType & VB_NoLCD) {
62106 +
62107 +              if(HwDeviceExtension->jChipType == SIS_650) {
62108 +                 if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62109 +                    SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,0x10);
62110 +                 }
62111 +                 if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ||
62112 +                     (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) {
62113 +                    SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02);
62114 +                    SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 0);
62115 +                 }
62116                }
62117  
62118 -              if(!(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x40)) {
62119 -                  SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 10);
62120 -                 delaylong = TRUE;
62121 +           } else if(SiS_Pr->SiS_VBType & VB_SIS301B302B) {
62122 +
62123 +              if(HwDeviceExtension->jChipType == SIS_650) {
62124 +                 if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62125 +                    tempah = 0x10;
62126 +                    if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x13) & 0x04) {
62127 +                       tempah = 0x18;
62128 +                       if((SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) == 0x0c) {
62129 +                          tempah = 0x08;
62130 +                       }
62131 +                    }
62132 +                    SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,tempah);
62133 +                 }
62134                }
62135  
62136             }
62137 @@ -5547,13 +5779,17 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PS
62138                 temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF;
62139                if(SiS_BridgeInSlave(SiS_Pr)) {
62140                    tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
62141 -                  if(!(tempah & SetCRT2ToRAMDAC))  temp |= 0x20;
62142 +                  if(!(tempah & SetCRT2ToRAMDAC)) {
62143 +                    if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
62144 +                       if(!(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x13) & 0x04)) temp |= 0x20;
62145 +                    } else temp |= 0x20;
62146 +                 }
62147                 }
62148                 SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp);
62149  
62150                SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);                   /* enable CRT2 */
62151                
62152 -              if(SiS_Pr->SiS_VBType & VB_SIS301B302B) {
62153 +              if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280)) {
62154                   SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
62155                   temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2e);
62156                   if(!(temp & 0x80)) {
62157 @@ -5565,12 +5801,12 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PS
62158             }
62159  
62160             if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
62161 -                 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x20);
62162 +              SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x20);
62163             }
62164  
62165             SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20);
62166  
62167 -           if(SiS_Pr->SiS_VBType & VB_SIS301B302B) {
62168 +           if((SiS_Pr->SiS_VBType & VB_SIS301B302B) || (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280)) {
62169                temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2e);
62170                if(!(temp & 0x80)) {
62171                   SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80);
62172 @@ -5586,7 +5822,9 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PS
62173             }
62174              SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah);
62175  
62176 -           if(SiS_Pr->SiS_VBType & VB_SIS301B302B) {
62177 +           if((SiS_Pr->SiS_VBType & VB_SIS301B302B) ||
62178 +              ((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) &&
62179 +               (!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))))) {
62180                 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
62181             }
62182  
62183 @@ -5595,186 +5833,144 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PS
62184                SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);    /* All this from 1.10.7u */
62185                SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c);
62186                SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20);
62187 -              SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x05);  
62188 -              SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0x60);  
62189 -              SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x00);  
62190 -              SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); 
62191 -              SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); 
62192 -              
62193 -              SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2);
62194 -           
62195 +
62196 +              if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
62197 +
62198 +                 SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x08);
62199 +                 SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0x10);
62200 +                 SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x4d);
62201 +                 if((SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0x0f) != 0x02) {
62202 +                    SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x0d);
62203 +                    SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0x70);
62204 +                    SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x6b);
62205 +                 }
62206 +                 SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10);
62207 +
62208 +              } else {
62209 +
62210 +                 SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x12);
62211 +                 SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0xd0);
62212 +                 SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x6b);
62213 +                 if((SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0x0f) == 0x02) {   /* @@@@ really == ? */
62214 +                    SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x0d);
62215 +                    SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0x70);
62216 +                    SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x40);
62217 +                    if(((SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xf0) != 0x03)) {
62218 +                       SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x05);
62219 +                       SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0x60);
62220 +                       SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x33);  /* 00 */
62221 +                    }
62222 +                 }
62223 +                 SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10);
62224 +                 if((SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0x0f) != 0x03) {
62225 +                    SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40);
62226 +                 }
62227 +              }
62228 +
62229 +              if(SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) {
62230 +                 SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2);
62231 +              }
62232 +
62233                SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1f,0x10);  /* 1.10.8r */
62234  
62235 -              SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80);
62236 +              if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
62237  
62238 -              if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62239                   if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ||
62240                       ((SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) ) {
62241 -                   SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 10);
62242 -                   if(delaylong) {
62243 -                       SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 10);
62244 -                   }
62245 -                    SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
62246 -                   SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xfe,0x01);
62247 -                }
62248 -             }
62249 +                    SiS_DisplayOn(SiS_Pr);
62250 +                    SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1);
62251 +                    SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
62252 +                    SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
62253 +                    SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40);
62254 +                    if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62255 +                       SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xfe,0x01);
62256 +                    }
62257 +                 }
62258  
62259 -             SiS_SetReg1(SiS_Pr->SiS_P3c4,0x06,pushax);
62260 -             SiS_DisplayOn(SiS_Pr);
62261 -             SiS_SetReg3(SiS_Pr->SiS_P3c6,0xff);
62262 +              } else {
62263  
62264 -             if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62265 -                 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
62266 -             }
62267 -#if 0
62268 -              SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);
62269 -             SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c);
62270 -             SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20);
62271 -             SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x31,0x05);   /* 1.10.8r: 0x0d */
62272 -             SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x32,0x60);   /* 1.10.8r: 0x70 */
62273 -             SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x33,0x00);   /* 1.10.8r: 0x40 */
62274 -             SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10); 
62275 -             SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); 
62276 -#endif       
62277 +                 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80);
62278  
62279 -         }
62280 +                 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62281 +                    if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ||
62282 +                        ((SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) ) {
62283 +                       SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 10);
62284 +                       if(delaylong) {
62285 +                          SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 10);
62286 +                       }
62287 +                        SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
62288 +                       SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xfe,0x01);
62289 +                    }
62290 +                 }
62291  
62292 -#if 0
62293 -         } else if(IS_SIS740) {                /* 740 */
62294 -        
62295 -          if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {  /* 30xLV */
62296 -          
62297 -             SiS_SetReg3(SiS_Pr->SiS_P3c6,0x00);
62298 -             SiS_DisplayOff(SiS_Pr);
62299 -             pushax = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x06);
62300 -             SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3);
62301 -             
62302 -             if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ||
62303 -                 (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) {
62304 -                   if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) {
62305 -                     SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02);
62306 -                     SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 3);
62307 -                  }
62308 -             }
62309 -             
62310 -             if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62311 -                temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF;
62312 -                if(SiS_BridgeInSlave(SiS_Pr)) {
62313 -                    tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
62314 -                    if(!(tempah & SetCRT2ToRAMDAC))  temp |= 0x20;
62315 -                 }
62316 -                 SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp);
62317 +                 SiS_SetReg1(SiS_Pr->SiS_P3c4,0x06,pushax);
62318 +                 SiS_DisplayOn(SiS_Pr);
62319 +                 SiS_SetReg3(SiS_Pr->SiS_P3c6,0xff);
62320  
62321 -                SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);      
62322 -                SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 2);
62323 -             }
62324 -             
62325 -             if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
62326 -                SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20);
62327 -             }
62328 -             
62329 -             SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20);
62330 -             SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0);
62331 -             SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0x10);  /* (taken from 650 1.10.8r) */
62332 -             SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80);
62333 -             
62334 -             if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62335 -                if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ||
62336 -                    (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) {
62337 -                   SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 10);
62338 -                   if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x40) {
62339 -                      SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
62340 -                   }
62341 -                   SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xfe,0x01);
62342 -                   SiS_SetPanelDelayLoop(SiS_Pr,ROMAddr, HwDeviceExtension, 3, 10);
62343 -                   SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
62344 -                }
62345 -              }
62346 -             
62347 -             SiS_SetReg1(SiS_Pr->SiS_P3c4,0x06,pushax);
62348 -             SiS_DisplayOn(SiS_Pr);
62349 -             SiS_SetReg3(SiS_Pr->SiS_P3c6,0xff);
62350 -             
62351 -             if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62352 -                SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
62353 -             }
62354 -          
62355 -          } else {     /* (301), 301B */
62356 -        
62357 -             if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62358 -                temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF;
62359 -                if(SiS_BridgeInSlave(SiS_Pr)) {
62360 -                    tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
62361 -                    if(!(tempah & SetCRT2ToRAMDAC))  temp |= 0x20;
62362 -                 }
62363 -                 SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp);
62364 +                 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62365 +                    SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
62366 +                 }
62367  
62368 -                SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);                   /* enable CRT2 */
62369 +              }
62370  
62371 -                temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E);
62372 -                 if(!(temp & 0x80))
62373 -                    SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80);
62374 -              }
62375 +           } if(SiS_Pr->SiS_VBType & VB_NoLCD) {
62376 +
62377 +              if(HwDeviceExtension->jChipType == SIS_650) {
62378 +                 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62379 +                    if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ||
62380 +                        (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) {
62381 +                       SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1);
62382 +                       SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01);
62383 +                    }
62384 +                 }
62385 +              }
62386  
62387 -             SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20);
62388 +           }
62389  
62390 -             if(SiS_Is301B(SiS_Pr,BaseAddr)) { 
62391 -                SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0);
62392 -                SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
62393 -             } else {
62394 -                SiS_VBLongWait(SiS_Pr);
62395 -                 SiS_DisplayOn(SiS_Pr);
62396 -                SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7F);
62397 -                 SiS_VBLongWait(SiS_Pr);
62398 -             }
62399 -             
62400 -          }
62401 -#endif
62402 -         
62403          } else {                       /* 315, 330 */
62404  
62405 -          if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62406 -             temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF;
62407 -             if(SiS_BridgeInSlave(SiS_Pr)) {
62408 -                 tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
62409 -                 if(!(tempah & SetCRT2ToRAMDAC))  temp |= 0x20;
62410 -              }
62411 -              SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp);
62412 +           if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62413 +              temp = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x32) & 0xDF;
62414 +              if(SiS_BridgeInSlave(SiS_Pr)) {
62415 +                  tempah = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x30);
62416 +                  if(!(tempah & SetCRT2ToRAMDAC))  temp |= 0x20;
62417 +               }
62418 +               SiS_SetReg1(SiS_Pr->SiS_P3c4,0x32,temp);
62419  
62420 -             SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);                   /* enable CRT2 */
62421 +              SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);                   /* enable CRT2 */
62422  
62423 -             temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E);
62424 -              if(!(temp & 0x80))
62425 -                 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80);
62426 -           }
62427 +              temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E);
62428 +               if(!(temp & 0x80))
62429 +                  SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80);
62430 +            }
62431  
62432 -          SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20);
62433 +           SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20);
62434  
62435 -          if(SiS_Is301B(SiS_Pr,BaseAddr)) {
62436 +           if(SiS_Is301B(SiS_Pr,BaseAddr)) {
62437  
62438 -             temp=SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E);
62439 -              if (!(temp & 0x80))
62440 -                 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80);
62441 +              temp=SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E);
62442 +               if(!(temp & 0x80))
62443 +                  SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80);
62444 +
62445 +              tempah = 0xc0;
62446 +              if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) {
62447 +                 tempah = 0x80;
62448 +                 if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62449 +                    tempah = 0x40;
62450 +                  }
62451 +              }
62452 +               SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah);
62453  
62454 -             tempah = 0xc0;
62455 -             if(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr)) {
62456 -                tempah = 0x80;
62457 -                if(!(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62458 -                   tempah = 0x40;
62459 -                 }
62460 -             }
62461 -              SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah);
62462 +              SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
62463  
62464 -             SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
62465 +           } else {
62466  
62467 -          } else {
62468 -          
62469 -             SiS_VBLongWait(SiS_Pr);
62470 -              SiS_DisplayOn(SiS_Pr);
62471 -             SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7F);
62472 -              SiS_VBLongWait(SiS_Pr);
62473 +              SiS_VBLongWait(SiS_Pr);
62474 +               SiS_DisplayOn(SiS_Pr);
62475 +              SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7F);
62476 +               SiS_VBLongWait(SiS_Pr);
62477  
62478 -          }
62479 +           }
62480  
62481          }   /* 315, 330 */
62482  
62483 @@ -5782,11 +5978,11 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PS
62484  
62485        }
62486  
62487 -    } else {   /* ============  TW: For 301 ================ */
62488 +    } else {   /* ============  For 301 ================ */
62489  
62490         if(HwDeviceExtension->jChipType < SIS_315H) {
62491              if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) {
62492 -                SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF0,0x0B);
62493 +                SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xFB);
62494                 SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 0);
62495             }
62496         }
62497 @@ -5818,13 +6014,13 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PS
62498         if(HwDeviceExtension->jChipType < SIS_315H) {
62499              if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) {
62500                 SiS_SetPanelDelay(SiS_Pr, ROMAddr, HwDeviceExtension, 1);
62501 -                SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x11,0xF0,0x03);
62502 +                SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xF7);
62503             }
62504         }
62505  
62506      }
62507  
62508 -  } else {   /* =================== TW: For LVDS ================== */
62509 +  } else {   /* =================== For LVDS ================== */
62510  
62511      if(HwDeviceExtension->jChipType < SIS_315H) {
62512  
62513 @@ -5847,35 +6043,35 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PS
62514        SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension, BaseAddr);
62515        SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF);
62516        if(SiS_BridgeInSlave(SiS_Pr)) {
62517 -       SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F);
62518 +        SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F);
62519        } else {
62520 -       SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40);
62521 +        SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40);
62522        }
62523  
62524        if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
62525 -        if(!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) {
62526 -               SiS_SetCH700x(SiS_Pr,0x0B0E);
62527 -        }
62528 +         if(!(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension))) {
62529 +           SiS_SetCH700x(SiS_Pr,0x0B0E);
62530 +         }
62531        }
62532  
62533        if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) {
62534 -          if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x40)) {
62535 -              if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16) & 0x10)) {
62536 -                 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) {
62537 -                       SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1);
62538 -                       SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1);
62539 -                 }
62540 -                 SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
62541 -                  SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xF7);
62542 -              }
62543 -         }
62544 +         if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x40)) {
62545 +            if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16) & 0x10)) {
62546 +              if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwDeviceExtension))) {
62547 +                 SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1);
62548 +                 SiS_SetPanelDelay(SiS_Pr,ROMAddr, HwDeviceExtension, 1);
62549 +              }
62550 +              SiS_WaitVBRetrace(SiS_Pr,HwDeviceExtension);
62551 +               SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x11,0xF7);
62552 +            }
62553 +        }
62554        }
62555  
62556  #endif  /* SIS300 */
62557  
62558      } else {
62559  
62560 -#ifdef SIS315H    /* 310/325 series */
62561 +#ifdef SIS315H    /* 315 series */
62562  
62563  #if 0  /* BIOS code makes no sense */
62564         if(SiS_IsVAMode()) {
62565 @@ -5902,36 +6098,41 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PS
62566           SiS_Chrontel701xBLOff(SiS_Pr);
62567         }
62568  
62569 -       SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
62570 -       
62571 -#ifdef NEWCH701x
62572 -       if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
62573 -           if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension,BaseAddr)) {
62574 +       if(HwDeviceExtension->jChipType != SIS_550) {
62575 +          SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
62576 +       }
62577 +
62578 +       if(HwDeviceExtension->jChipType == SIS_740) {
62579 +          if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
62580 +             if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension,BaseAddr)) {
62581                 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20);
62582 -          }
62583 +            }
62584 +         }
62585         }
62586 -#endif       
62587  
62588         temp1 = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x2E);
62589 -       if (!(temp1 & 0x80))
62590 +       if(!(temp1 & 0x80))
62591             SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80);
62592  
62593         if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
62594             if(temp) {
62595 -              SiS_Chrontel701xBLOn(SiS_Pr);
62596 +              SiS_Chrontel701xBLOn(SiS_Pr, HwDeviceExtension);
62597            }
62598         }
62599  
62600         if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
62601             if(SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) {
62602                 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20);
62603 +               if(HwDeviceExtension->jChipType == SIS_550) {
62604 +                  SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x40);
62605 +                  SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x10);
62606 +               }
62607 +          }
62608 +       } else if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
62609 +           if(HwDeviceExtension->jChipType != SIS_740) {
62610 +              SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20);
62611            }
62612 -       } 
62613 -#ifndef NEWCH701x       
62614 -         else if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
62615 -           SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20);
62616         }
62617 -#endif       
62618  
62619         if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62620             SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
62621 @@ -5954,10 +6155,10 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PS
62622         if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
62623                         if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
62624                         if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
62625 -                               SiS_Chrontel701xBLOn(SiS_Pr);
62626 +                               SiS_Chrontel701xBLOn(SiS_Pr, HwDeviceExtension);
62627                                 SiS_ChrontelDoSomething4(SiS_Pr,HwDeviceExtension, BaseAddr);
62628                         } else if(SiS_IsLCDOrLCDA(SiS_Pr,HwDeviceExtension, BaseAddr))  {
62629 -                                       SiS_Chrontel701xBLOn(SiS_Pr);
62630 +                                       SiS_Chrontel701xBLOn(SiS_Pr, HwDeviceExtension);
62631                                         SiS_ChrontelDoSomething4(SiS_Pr,HwDeviceExtension, BaseAddr);
62632                         }
62633                         }
62634 @@ -5983,7 +6184,7 @@ SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS
62635  {
62636    USHORT  BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress;
62637  
62638 -  /* TW: Switch on LCD backlight on SiS30xLV */
62639 +  /* Switch on LCD backlight on SiS30xLV */
62640    if( (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ||
62641        (SiS_CRT2IsLCD(SiS_Pr,BaseAddr,HwDeviceExtension)) ) {
62642      if(!(SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) {
62643 @@ -6001,7 +6202,7 @@ SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSI
62644  {
62645    USHORT  BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress;
62646  
62647 -  /* TW: Switch off LCD backlight on SiS30xLV */
62648 +  /* Switch off LCD backlight on SiS30xLV */
62649    if( (!(SiS_IsDualEdge(SiS_Pr,HwDeviceExtension, BaseAddr))) ||
62650        (SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) ) {
62651          SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xFE,0x00);
62652 @@ -6023,12 +6224,14 @@ SiS_CR36BIOSWord23b(SiS_Private *SiS_Pr,
62653    UCHAR *ROMAddr;
62654  
62655    if((ROMAddr = (UCHAR *)HwDeviceExtension->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) {
62656 -     temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xff;
62657 -     temp >>= 4;
62658 -     temp = 1 << temp;
62659 -     temp1 = (ROMAddr[0x23c] << 8) | ROMAddr[0x23b];
62660 -     if(temp1 & temp) return(1);
62661 -     else return(0);
62662 +     if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
62663 +        temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xff;
62664 +        temp >>= 4;
62665 +        temp = 1 << temp;
62666 +        temp1 = (ROMAddr[0x23c] << 8) | ROMAddr[0x23b];
62667 +        if(temp1 & temp) return(1);
62668 +        else return(0);
62669 +     } else return(0);
62670    } else {
62671       return(0);
62672    }
62673 @@ -6041,12 +6244,14 @@ SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr,
62674    UCHAR *ROMAddr;
62675  
62676    if((ROMAddr = (UCHAR *)HwDeviceExtension->pjVirtualRomBase) && SiS_Pr->SiS_UseROM) {
62677 -     temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xff;
62678 -     temp >>= 4;
62679 -     temp = 1 << temp;
62680 -     temp1 = (ROMAddr[0x23e] << 8) | ROMAddr[0x23d];
62681 -     if(temp1 & temp) return(1);
62682 -     else return(0);
62683 +     if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
62684 +        temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xff;
62685 +        temp >>= 4;
62686 +        temp = 1 << temp;
62687 +        temp1 = (ROMAddr[0x23e] << 8) | ROMAddr[0x23d];
62688 +        if(temp1 & temp) return(1);
62689 +        else return(0);
62690 +     } else return(0);
62691    } else {
62692       return(0);
62693    }
62694 @@ -6143,7 +6348,7 @@ SiS_SetPanelDelay(SiS_Private *SiS_Pr, U
62695  
62696  #ifdef SIS315H
62697  
62698 -      if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {                       /* 310/325 series, LVDS */
62699 +      if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {                       /* 315 series, LVDS */
62700  
62701            if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
62702                PanelID = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36);
62703 @@ -6171,7 +6376,7 @@ SiS_SetPanelDelay(SiS_Private *SiS_Pr, U
62704               SiS_ShortDelay(SiS_Pr,Delay);
62705           }
62706  
62707 -      } else {                                                 /* 310/325 series, 301(B) */
62708 +      } else {                                                 /* 315 series, 301(B) */
62709  
62710            PanelID = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36);
62711           DelayIndex = PanelID >> 4;
62712 @@ -6271,14 +6476,7 @@ SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_H
62713    if(HwDeviceExtension->jChipType >= SIS_315H) {
62714       flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38);
62715       if((flag & EnableDualEdge) && (flag & SetToLCDA))   return(1);
62716 -#if 0 /* Not done in 650/30xLV 1.10.6s, but in 650/301LV */
62717 -     else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
62718 -       if(flag) return(1);
62719 -       else     return(0);                              
62720 -     }
62721 -#endif
62722 -     else
62723 -       return(0);
62724 +     else return(0);
62725    } else
62726  #endif
62727       return(0);
62728 @@ -6325,7 +6523,9 @@ SiS_IsNotM650or651(SiS_Private *SiS_Pr, 
62729    if(HwDeviceExtension->jChipType == SIS_650) {
62730       flag = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f);
62731       flag &= 0xF0;
62732 -     if((flag == 0xb0) || (flag == 0x90)) return 0;
62733 +     /* Check for revision != A0 only */
62734 +     if((flag == 0xe0) || (flag == 0xc0) ||
62735 +        (flag == 0xb0) || (flag == 0x90)) return 0;
62736       else return 1;
62737    } else
62738  #endif
62739 @@ -6443,7 +6643,7 @@ SiS_BridgeIsEnable(SiS_Private *SiS_Pr, 
62740        if((flag == 0x80) || (flag == 0x20)) return 0;
62741        else                                return 1;
62742      } else {
62743 -      /* 310/325 series (650/30xLV 1.10.6s) */
62744 +      /* 315 series (650/30xLV 1.10.6s) */
62745        flag &= 0x50;
62746        if((flag == 0x40) || (flag == 0x10)) return 0;
62747        else                                 return 1;
62748 @@ -6487,14 +6687,14 @@ SiS_SetHiVision(SiS_Private *SiS_Pr, USH
62749    }
62750  }
62751  
62752 -BOOLEAN
62753 +void
62754  SiS_GetLCDResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,
62755                    USHORT ModeIdIndex, PSIS_HW_DEVICE_INFO HwDeviceExtension)
62756  {
62757    USHORT temp,modeflag,resinfo=0;
62758    const unsigned char SiS300SeriesLCDRes[] =
62759 -         { 0, 1, 2, 3, 7, 4, 5, 8,
62760 -          0, 0, 0, 0, 0, 0, 0, 0 };
62761 +         { 0,  1,  2,  3,  7,  4,  5,  8,
62762 +          0,  0, 10,  0,  0,  0,  0, 15 };
62763  
62764    SiS_Pr->SiS_LCDResInfo = 0;
62765    SiS_Pr->SiS_LCDTypeInfo = 0;
62766 @@ -6511,17 +6711,19 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, U
62767       }
62768    }
62769  
62770 -  if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))   return 0;
62771 +  if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))   return;
62772  
62773 -  if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2))) return 0;
62774 +  if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2))) return;
62775  
62776    temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36);
62777  
62778 +#if 0
62779    /* FSTN: Fake CR36 (TypeInfo 2, ResInfo SiS_Panel320x480) */
62780    if(SiS_Pr->SiS_IF_DEF_FSTN) {
62781         temp = 0x20 | SiS_Pr->SiS_Panel320x480;
62782         SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,temp);
62783    }
62784 +#endif
62785  
62786    if(HwDeviceExtension->jChipType < SIS_315H) {
62787         SiS_Pr->SiS_LCDTypeInfo = temp >> 4;
62788 @@ -6530,14 +6732,16 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, U
62789    }
62790    temp &= 0x0f;
62791    if(HwDeviceExtension->jChipType < SIS_315H) {
62792 -      /* TW: Translate 300 series LCDRes to 310/325 series for unified usage */
62793 +      /* Translate 300 series LCDRes to 315 series for unified usage */
62794        temp = SiS300SeriesLCDRes[temp];
62795    }
62796    SiS_Pr->SiS_LCDResInfo = temp;
62797  
62798 +#if 0
62799    if(SiS_Pr->SiS_IF_DEF_FSTN){
62800                 SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_Panel320x480;
62801    }
62802 +#endif
62803  
62804    if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
62805         if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMin301)
62806 @@ -6547,75 +6751,115 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, U
62807                 SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_PanelMinLVDS;
62808    }
62809  
62810 -  if(SiS_Pr->SiS_LCDResInfo > SiS_Pr->SiS_PanelMax)
62811 +  if((!SiS_Pr->CP_HaveCustomData) || (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_PanelCustom)) {
62812 +     if(SiS_Pr->SiS_LCDResInfo > SiS_Pr->SiS_PanelMax)
62813         SiS_Pr->SiS_LCDResInfo = SiS_Pr->SiS_Panel1024x768;
62814 +  }
62815 +
62816 +  if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
62817 +     if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
62818 +        SiS_Pr->SiS_LCDResInfo = Panel_Barco1366;
62819 +     } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848) {
62820 +        SiS_Pr->SiS_LCDResInfo = Panel_848x480;
62821 +     }
62822 +  }
62823 +
62824 +  switch(SiS_Pr->SiS_LCDResInfo) {
62825 +     case Panel_800x600:   SiS_Pr->PanelXRes =  800; SiS_Pr->PanelYRes =  600; break;
62826 +     case Panel_1024x768:  SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes =  768; break;
62827 +     case Panel_1280x1024: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 1024; break;
62828 +     case Panel_640x480_3:
62829 +     case Panel_640x480_2:
62830 +     case Panel_640x480:   SiS_Pr->PanelXRes =  640; SiS_Pr->PanelYRes =  480; break;
62831 +     case Panel_1024x600:  SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes =  600; break;
62832 +     case Panel_1152x864:  SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes =  864; break;
62833 +     case Panel_1280x960:  SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes =  960; break;
62834 +     case Panel_1152x768:  SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes =  768; break;
62835 +     case Panel_1400x1050: SiS_Pr->PanelXRes = 1400; SiS_Pr->PanelYRes = 1050; break;
62836 +     case Panel_1280x768:  SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes =  768; break;
62837 +     case Panel_1600x1200: SiS_Pr->PanelXRes = 1600; SiS_Pr->PanelYRes = 1200; break;
62838 +     case Panel_320x480:   SiS_Pr->PanelXRes =  320; SiS_Pr->PanelYRes =  480; break;
62839 +     case Panel_Custom:    SiS_Pr->PanelXRes = SiS_Pr->CP_MaxX;
62840 +                          SiS_Pr->PanelYRes = SiS_Pr->CP_MaxY;
62841 +                          break;
62842 +     case Panel_Barco1366: SiS_Pr->PanelXRes = 1360; SiS_Pr->PanelYRes = 1024; break;
62843 +     case Panel_848x480:   SiS_Pr->PanelXRes =  848; SiS_Pr->PanelYRes =  480; break;
62844 +     default:             SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes =  768; break;
62845 +  }
62846  
62847    temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37);
62848 +#if 0
62849    if(SiS_Pr->SiS_IF_DEF_FSTN){
62850 -        /* TW: Fake LVDS bridge for FSTN */
62851 +        /* Fake LVDS bridge for FSTN */
62852         temp = 0x04;
62853         SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,temp);
62854    }
62855 +#endif
62856    SiS_Pr->SiS_LCDInfo = temp;
62857 -  
62858 +
62859 +  if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
62860 +     if(SiS_Pr->SiS_CustomT == CUT_PANEL848) {
62861 +        SiS_Pr->SiS_LCDInfo = 0x80 | 0x40 | 0x20;   /* neg sync, RGB24 */
62862 +     }
62863 +  }
62864 +
62865    if(!(SiS_Pr->UsePanelScaler))        SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD;
62866    else if(SiS_Pr->UsePanelScaler == 1) SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
62867  
62868 -  /* TW: Inserted entire 315-block from 650/LVDS/30xLV BIOSes */
62869 +  if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
62870 +     if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
62871 +        if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) {
62872 +          /* For non-standard LCD resolution, we let the panel scale */
62873 +           SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
62874 +        } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
62875 +          if(ModeNo == 0x7c || ModeNo == 0x7d || ModeNo == 0x7e) {
62876 +             /* Bridge does not scale to 1280x960 */
62877 +              SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
62878 +          }
62879 +        } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) {
62880 +           /* TEMP - no idea about the timing and zoom factors */
62881 +           SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
62882 +        } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
62883 +          if(ModeNo == 0x3a || ModeNo == 0x4d || ModeNo == 0x65) {
62884 +             /* Bridge does not scale to 1280x1024 */
62885 +             SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
62886 +          }
62887 +       } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) {
62888 +          /* TEMP - no idea about the timing and zoom factors */
62889 +          SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
62890 +       }
62891 +     }
62892 +  }
62893 +
62894 +
62895    if(HwDeviceExtension->jChipType >= SIS_315H) {
62896  #ifdef SIS315H
62897 -     if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
62898 -         if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
62899 -            if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
62900 -                if(ModeNo == 0x3a || ModeNo == 0x4d || ModeNo == 0x65) {
62901 -                    /* Bridge does not scale to 1280x1024 */
62902 -                    SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
62903 -                }
62904 -            }
62905 -            if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
62906 -                if(ModeNo == 0x7c || ModeNo == 0x7d || ModeNo == 0x7e) {
62907 -                    /* TW: Bridge does not scale to 1280x960 */
62908 -                    SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
62909 -                }
62910 -                if(ModeNo == 0x2f || ModeNo == 0x5d || ModeNo == 0x5e) {
62911 -                    /* TW: Bridge does not scale to 640x400 */
62912 -                    SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
62913 -                }
62914 -            }
62915 -            if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
62916 -                if(ModeNo == 0x2f || ModeNo == 0x5d || ModeNo == 0x5e) {
62917 -                    /* TW: Most panels can't scale to 640x400 */
62918 -                    SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD;
62919 -                }
62920 -            }
62921 -        }
62922 -     }
62923       if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x01) {
62924 -         SiS_Pr->SiS_LCDInfo &= 0xFFEF;    
62925 -        SiS_Pr->SiS_LCDInfo |= LCDPass11;
62926 +        SiS_Pr->SiS_LCDInfo &= 0xFFEF;
62927 +       SiS_Pr->SiS_LCDInfo |= LCDPass11;
62928       }
62929  #endif
62930    } else {
62931  #ifdef SIS300
62932       if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
62933          if((ROMAddr) && SiS_Pr->SiS_UseROM) {
62934 -           if(!(ROMAddr[0x235] & 0x02)) {
62935 -             SiS_Pr->SiS_LCDInfo &= 0xEF;
62936 +          if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
62937 +              if(!(ROMAddr[0x235] & 0x02)) {
62938 +                SiS_Pr->SiS_LCDInfo &= 0xEF;
62939 +             }
62940            }
62941          }
62942 -     } else {
62943 -        if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
62944 -          if((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10))) {
62945 -               SiS_Pr->SiS_LCDInfo &= 0xEF;
62946 -          }
62947 +     } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
62948 +       if((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10))) {
62949 +           SiS_Pr->SiS_LCDInfo &= 0xEF;
62950         }
62951       }
62952  #endif
62953    }
62954 -  
62955 -  /* TW: With Trumpion, always Expanding */
62956 -  if(SiS_Pr->SiS_IF_DEF_TRUMPION != 0){
62957 -       SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD);
62958 +
62959 +  /* Trumpion: Assume non-expanding */
62960 +  if(SiS_Pr->SiS_IF_DEF_TRUMPION != 0) {
62961 +     SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD);
62962    }
62963  
62964    if(!((HwDeviceExtension->jChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & SetDOSMode))) {
62965 @@ -6624,7 +6868,7 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, U
62966          if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) {
62967            if(ModeNo > 0x13) {
62968               if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
62969 -                 if((resinfo == 7) || (resinfo == 3)) {
62970 +                 if((resinfo == SIS_RI_800x600) || (resinfo == SIS_RI_400x300)) {
62971                      SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
62972                  }
62973                }
62974 @@ -6644,9 +6888,9 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, U
62975                                               (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480))) {
62976                   if(ModeNo > 0x13) {
62977                      if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
62978 -                       if(resinfo == 4) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;     /* 512x384  */
62979 +                       if(resinfo == SIS_RI_512x384) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
62980                      } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) {
62981 -                       if(resinfo == 3) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;     /* 400x300  */
62982 +                       if(resinfo == SIS_RI_400x300) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
62983                      }
62984                   }
62985               } else SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
62986 @@ -6665,19 +6909,21 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, U
62987    }
62988  
62989  #ifdef SIS315H
62990 -  /* TW: 650/30xLV 1.10.6s */
62991 +  /* 650/30xLV 1.10.6s */
62992    if(HwDeviceExtension->jChipType >= SIS_315H) {
62993 -    if(SiS_Pr->SiS_VBType & (VB_SIS302B | VB_SIS302LV)) {
62994 -      /* Enable 302B/302LV dual link mode */
62995 -      /* (302B is a theory - not in any BIOS */
62996 -      temp = 0x00;
62997 -      if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) temp = 0x04;
62998 -      if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) temp = 0x04;
62999 -      if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) temp = 0x04;
63000 -      SiS_SetReg1(SiS_Pr->SiS_P3d4,0x39,temp);
63001 -    } else if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
63002 -      SiS_SetReg1(SiS_Pr->SiS_P3d4,0x39,0x00);
63003 -    }
63004 +     if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
63005 +        SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x39,~0x04);
63006 +        if(SiS_Pr->SiS_VBType & (VB_SIS302B | VB_SIS302LV)) {
63007 +           /* Enable 302B/302LV dual link mode.
63008 +            * (302B is a theory - not in any BIOS)
63009 +           */
63010 +           if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) ||
63011 +              (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) ||
63012 +              (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) {
63013 +             SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x39,0x04);
63014 +          }
63015 +       }
63016 +     }
63017    }
63018  #endif
63019  
63020 @@ -6693,20 +6939,6 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, U
63021         SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo, SiS_Pr->SiS_SetFlag);
63022  #endif
63023  
63024 -  return 1;
63025 -}
63026 -
63027 -void
63028 -SiS_PresetScratchregister(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
63029 -{
63030 -  return;
63031 -  /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x30,0x21);  */
63032 -  /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x31,0x41);  */
63033 -  /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x32,0x28);  */
63034 -  /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x33,0x22);  */
63035 -  /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x35,0x43);  */
63036 -  /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x36,0x01);  */
63037 -  /*SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,0x00);  */
63038  }
63039  
63040  void
63041 @@ -6736,7 +6968,6 @@ SiS_VBLongWait(SiS_Private *SiS_Pr)
63042    } else {
63043      SiS_LongWait(SiS_Pr);
63044    }
63045 -  return;
63046  }
63047  
63048  void
63049 @@ -6803,7 +7034,7 @@ SiS_WaitRetrace1(SiS_Private *SiS_Pr, PS
63050  #endif
63051    } else {
63052  #ifdef SIS300
63053 -#if 0  /* TW: Not done in A901 BIOS */
63054 +#if 0  /* Not done in A901 BIOS */
63055       if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
63056          if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return;
63057       }
63058 @@ -6898,7 +7129,51 @@ void SiS_SetRegOR(USHORT Port,USHORT Ind
63059  
63060  /* ========================================================= */
63061  
63062 -/* TW: Set 301 TV Encoder (and some LCD relevant) registers */
63063 +static void
63064 +SiS_SetTVSpecial(SiS_Private *SiS_Pr, USHORT ModeNo)
63065 +{
63066 +  if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
63067 +     if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
63068 +        if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
63069 +           if((ModeNo == 0x64) || (ModeNo == 0x4a) || (ModeNo == 0x38)) {
63070 +              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1c,0xa7);
63071 +              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1d,0x07);
63072 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1e,0xf2);
63073 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1f,0x6e);
63074 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x20,0x17);
63075 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x21,0x8b);
63076 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x22,0x73);
63077 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,0x53);
63078 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x24,0x13);
63079 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x25,0x40);
63080 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x26,0x34);
63081 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x27,0xf4);
63082 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x28,0x63);
63083 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x29,0xbb);
63084 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2a,0xcc);
63085 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2b,0x7a);
63086 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2c,0x58);   /* 48 */
63087 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2d,0xe4);
63088 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2e,0x73);
63089 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,0xda);   /* de */
63090 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0x13);
63091 +             if((SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38)) & 0x40) {
63092 +                SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x14);
63093 +             } else {
63094 +                SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x15);
63095 +             }
63096 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x1b);
63097 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,0x72);
63098 +           }
63099 +        } else {
63100 +          SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x21);
63101 +          SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x5a);
63102 +       }
63103 +     }
63104 +  }
63105 +}
63106 +
63107 +/* Set 301 TV Encoder (and some LCD relevant) registers */
63108  void
63109  SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr, USHORT ModeNo,
63110                USHORT ModeIdIndex,USHORT RefreshRateTableIndex,
63111 @@ -6911,67 +7186,46 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63112  #ifdef SIS315H   
63113    const       SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL;
63114    USHORT      resindex, CRT2Index;
63115 -#endif  
63116 +#endif
63117    USHORT      modeflag, resinfo, crt2crtc;
63118 -  ULONG       longtemp, tempeax, tempebx, temp2, tempecx;
63119 +  ULONG       longtemp, tempeax;
63120 +#ifdef SIS300
63121    const UCHAR atable[] = {
63122                   0xc3,0x9e,0xc3,0x9e,0x02,0x02,0x02,
63123                  0xab,0x87,0xab,0x9e,0xe7,0x02,0x02
63124    };
63125 +#endif
63126  
63127  #ifdef SIS315H   
63128    if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
63129 -     /* TW: 650/30xLV 1.10.6s: (Is at end of SetGroup2!) */
63130 +     /* 650/30xLV 1.10.6s: (Is at end of SetGroup2!) */
63131       if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
63132          if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
63133            SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xfc,0x03);
63134 -          temp = 1;
63135 -          if(ModeNo <= 0x13) temp = 3;
63136 +          temp = 0x01;
63137 +          if(ModeNo <= 0x13) temp = 0x03;
63138            SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0b,temp);
63139         }
63140       }
63141 -     if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
63142 -       if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
63143 -         if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
63144 -           if((ModeNo == 0x4a) || (ModeNo == 0x38)) {
63145 -               SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1c,0xa7);
63146 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1d,0x07);
63147 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1e,0xf2);
63148 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1f,0x6e);
63149 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x20,0x17);
63150 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x21,0x8b);
63151 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x22,0x73);
63152 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,0x53);
63153 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x24,0x13);
63154 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x25,0x40);
63155 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x26,0x34);
63156 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x27,0xf4);
63157 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x28,0x63);
63158 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x29,0xbb);
63159 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2a,0xcc);
63160 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2b,0x7a);
63161 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2c,0x58);
63162 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2d,0xe4);
63163 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2e,0x73);
63164 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,0xda);
63165 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0x13);
63166 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,0x72);
63167 -           }
63168 -         }
63169 -       }
63170 -     }
63171 +     SiS_SetTVSpecial(SiS_Pr, ModeNo);
63172       return;
63173    }
63174 -#endif  
63175 +#endif
63176  
63177 -  if(ModeNo<=0x13) {
63178 -       modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;      /* si+St_ResInfo */
63179 -       resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
63180 -       crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
63181 +  if(ModeNo <= 0x13) {
63182 +     modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
63183 +     resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
63184 +     crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
63185    } else {
63186 -       modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;     /* si+Ext_ResInfo */
63187 +     if(SiS_Pr->UseCustomMode) {
63188 +        modeflag = SiS_Pr->CModeFlag;
63189 +       resinfo = 0;
63190 +       crt2crtc = 0;
63191 +     } else {
63192 +        modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
63193         resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
63194         crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
63195 +     }
63196    }
63197  
63198    tempcx = SiS_Pr->SiS_VBInfo;
63199 @@ -6984,9 +7238,9 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63200    temp |= ((tempbx & 0x00FF) >> 3);
63201    temp ^= 0x0C;
63202  
63203 -  /* TW: From 1.10.7w (no vb check there; don't care - this only disables SVIDEO and CVBS signal) */
63204 +  /* From 1.10.7w (no vb check there; don't care - this only disables SVIDEO and CVBS signal) */
63205    if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
63206 -       temp |= 0x0c;
63207 +     temp |= 0x0c;
63208    }
63209  
63210    PhasePoint  = SiS_Pr->SiS_PALPhase;
63211 @@ -6994,44 +7248,44 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63212    
63213    if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {          
63214    
63215 -    temp ^= 0x01;
63216 -    if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
63217 -      TimingPoint = SiS_Pr->SiS_HiTVSt2Timing;
63218 -      if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
63219 -        if(modeflag & Charx8Dot) TimingPoint = SiS_Pr->SiS_HiTVSt1Timing;
63220 -        else TimingPoint = SiS_Pr->SiS_HiTVTextTiming;
63221 -      }
63222 -    } else TimingPoint = SiS_Pr->SiS_HiTVExtTiming;
63223 -    
63224 -    if(SiS_Pr->SiS_HiVision & 0x03) temp &= 0xfe;
63225 -    
63226 +     temp ^= 0x01;
63227 +     if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
63228 +        TimingPoint = SiS_Pr->SiS_HiTVSt2Timing;
63229 +        if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
63230 +           if(modeflag & Charx8Dot) TimingPoint = SiS_Pr->SiS_HiTVSt1Timing;
63231 +           else TimingPoint = SiS_Pr->SiS_HiTVTextTiming;
63232 +        }
63233 +     } else TimingPoint = SiS_Pr->SiS_HiTVExtTiming;
63234 +
63235 +     if(SiS_Pr->SiS_HiVision & 0x03) temp &= 0xfe;
63236 +
63237    } else {
63238 -  
63239 -    if(SiS_Pr->SiS_VBInfo & SetPALTV){
63240  
63241 -      TimingPoint = SiS_Pr->SiS_PALTiming;
63242 -      PhasePoint  = SiS_Pr->SiS_PALPhase;
63243 +     if(SiS_Pr->SiS_VBInfo & SetPALTV){
63244  
63245 -      if( (SiS_Pr->SiS_VBType & VB_SIS301B302B) &&
63246 -          ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
63247 -           (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) {
63248 -         PhasePoint = SiS_Pr->SiS_PALPhase2;
63249 -      }
63250 +        TimingPoint = SiS_Pr->SiS_PALTiming;
63251 +        PhasePoint  = SiS_Pr->SiS_PALPhase;
63252  
63253 -    } else {
63254 +        if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&
63255 +            ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
63256 +             (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) {
63257 +           PhasePoint = SiS_Pr->SiS_PALPhase2;
63258 +        }
63259 +
63260 +     } else {
63261  
63262          temp |= 0x10;
63263 -       TimingPoint = SiS_Pr->SiS_NTSCTiming;
63264 -       PhasePoint  = SiS_Pr->SiS_NTSCPhase;
63265 +        TimingPoint = SiS_Pr->SiS_NTSCTiming;
63266 +        PhasePoint  = SiS_Pr->SiS_NTSCPhase;
63267  
63268 -        if( (SiS_Pr->SiS_VBType & VB_SIS301B302B) &&
63269 +        if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&
63270             ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
63271               (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) {
63272 -               PhasePoint = SiS_Pr->SiS_NTSCPhase2;
63273 +           PhasePoint = SiS_Pr->SiS_NTSCPhase2;
63274          }
63275  
63276 -    }
63277 -    
63278 +     }
63279 +
63280    }
63281    SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,temp);
63282  
63283 @@ -7044,36 +7298,35 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63284       temp = 0x38;
63285    }
63286    if(temp) {
63287 -    if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
63288 -      if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) {
63289 -          temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,temp);
63290 -          if(temp1 & EnablePALM) {     /* 0x40 */
63291 -               PhasePoint = SiS_Pr->SiS_PALMPhase;
63292 -               if( (SiS_Pr->SiS_VBType & VB_SIS301B302B) &&
63293 -                   ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
63294 -                     (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) {
63295 -                  PhasePoint = SiS_Pr->SiS_PALMPhase2;
63296 -               }
63297 -         }
63298 -          if(temp1 & EnablePALN) {     /* 0x80 */
63299 -                       PhasePoint = SiS_Pr->SiS_PALNPhase;
63300 -               if( (SiS_Pr->SiS_VBType & VB_SIS301B302B) &&
63301 -                   ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
63302 -                     (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) {
63303 -                  PhasePoint = SiS_Pr->SiS_PALNPhase2;
63304 -               }
63305 -         }
63306 -      }
63307 -    }
63308 +     if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
63309 +        if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) {
63310 +           temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,temp);
63311 +           if(temp1 & EnablePALM) {    /* 0x40 */
63312 +              PhasePoint = SiS_Pr->SiS_PALMPhase;
63313 +             if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&
63314 +                 ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
63315 +                   (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) {
63316 +                PhasePoint = SiS_Pr->SiS_PALMPhase2;
63317 +             }
63318 +          }
63319 +           if(temp1 & EnablePALN) {    /* 0x80 */
63320 +              PhasePoint = SiS_Pr->SiS_PALNPhase;
63321 +             if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&
63322 +                 ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
63323 +                   (SiS_Pr->SiS_SetFlag & TVSimuMode) ) ) {
63324 +                PhasePoint = SiS_Pr->SiS_PALNPhase2;
63325 +             }
63326 +          }
63327 +        }
63328 +     }
63329    }
63330  
63331  #ifdef SIS315H
63332 -  /* TW: 650/301LV BIOS */
63333    if(HwDeviceExtension->jChipType >= SIS_315H) {
63334       if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {  
63335          if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
63336             if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
63337 -              if((ModeNo == 0x4a) || (ModeNo == 0x38)) {
63338 +              if((ModeNo == 0x64) || (ModeNo == 0x4a) || (ModeNo == 0x38)) {
63339                  PhasePoint = SiS_Pr->SiS_SpecialPhase;
63340               }
63341             }
63342 @@ -7094,12 +7347,12 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63343    }
63344  
63345    if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
63346 -    if(HwDeviceExtension->jChipType >= SIS_315H) {
63347 -      if(!(SiS_Pr->SiS_ModeType & 0x07))
63348 +     if(HwDeviceExtension->jChipType >= SIS_315H) {
63349 +        if(!(SiS_Pr->SiS_ModeType & 0x07))
63350 +           SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x3A,0x1F);
63351 +     } else {
63352          SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x3A,0x1F);
63353 -    } else {
63354 -      SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x3A,0x1F);
63355 -    }
63356 +     }
63357    }
63358  
63359    SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x0A,SiS_Pr->SiS_NewFlickerMode);
63360 @@ -7110,11 +7363,11 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63361    SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x38,SiS_Pr->SiS_RY4COE);
63362  
63363    if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
63364 -      if(SiS_Pr->SiS_HiVision == 3) tempax = 950;
63365 -      else tempax = 440;
63366 +     if(SiS_Pr->SiS_HiVision == 3) tempax = 950;
63367 +     else tempax = 440;
63368    } else {
63369 -    if(SiS_Pr->SiS_VBInfo & SetPALTV) tempax = 520;
63370 -    else tempax = 440;
63371 +     if(SiS_Pr->SiS_VBInfo & SetPALTV) tempax = 520;
63372 +     else tempax = 440;
63373    }
63374  
63375    if( ( ( (!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) || (SiS_Pr->SiS_HiVision == 3) ) && (SiS_Pr->SiS_VDE <= tempax) ) ||
63376 @@ -7134,18 +7387,18 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63377       SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,temp);
63378  
63379       if( (SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) &&
63380 -        (SiS_Pr->SiS_HiVision != 3) &&
63381 -        (SiS_Pr->SiS_VGAHDE >= 1024) ) {
63382 +         (SiS_Pr->SiS_HiVision != 3) &&
63383 +         (SiS_Pr->SiS_VGAHDE >= 1024) ) {
63384          if(SiS_Pr->SiS_VBInfo & SetPALTV) {
63385             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x19);
63386             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x52);
63387          } else {
63388             if(HwDeviceExtension->jChipType >= SIS_315H) {
63389 -             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x17);
63390 -             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x1d);
63391 +              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x17);
63392 +              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x1d);
63393            } else {
63394 -             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x0b);
63395 -             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x11);
63396 +              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x0b);
63397 +              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x11);
63398            }
63399          }
63400       }
63401 @@ -7154,7 +7407,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63402  
63403    tempcx = SiS_Pr->SiS_HT;
63404  
63405 -  /* TW: 650/30xLV 1.10.6s */
63406 +  /* 650/30xLV 1.10.6s */
63407    if(HwDeviceExtension->jChipType >= SIS_315H) {
63408        if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) {
63409            tempcx >>= 1;
63410 @@ -7181,7 +7434,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63411    tempcx += 7;
63412    if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) &&
63413       (SiS_Pr->SiS_HiVision == 3)) {
63414 -       tempcx -= 4;
63415 +     tempcx -= 4;
63416    }
63417    temp = (tempcx & 0x00FF) << 4;
63418    SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x22,0x0F,temp);
63419 @@ -7201,8 +7454,8 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63420    tempbx += 8;
63421    if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) &&
63422       (SiS_Pr->SiS_HiVision == 3)) {
63423 -    tempbx -= 4;
63424 -    tempcx = tempbx;
63425 +     tempbx -= 4;
63426 +     tempcx = tempbx;
63427    }
63428    temp = (tempbx & 0x00FF) << 4;
63429    SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x29,0x0F,temp);
63430 @@ -7231,8 +7484,8 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63431  
63432    tempcx -= 11;
63433    if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
63434 -    tempax = SiS_GetVGAHT2(SiS_Pr) - 1;
63435 -    tempcx = tempax;
63436 +     tempax = SiS_GetVGAHT2(SiS_Pr) - 1;
63437 +     tempcx = tempax;
63438    }
63439    temp = tempcx & 0x00FF;
63440    SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2E,temp);
63441 @@ -7242,38 +7495,38 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63442    if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 746;
63443    if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 853;
63444    if(HwDeviceExtension->jChipType < SIS_315H) {
63445 -       if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempbx >>= 1;
63446 +     if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempbx >>= 1;
63447    } else {
63448 -       if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_HiVision & 0x03))) {
63449 -          tempbx >>= 1;
63450 -          if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
63451 -             if(ModeNo <= 0x13) {
63452 -                if(crt2crtc == 1) {
63453 -                   tempbx++;
63454 -                 }
63455 -             }
63456 -          } else {
63457 -              if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
63458 -                if(crt2crtc == 4)   /* TW: BIOS calls GetRatePtrCRT2 here - does not make sense */
63459 -                    if(SiS_Pr->SiS_ModeType <= 3) tempbx++;
63460 -             }
63461 +     if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_HiVision & 0x03))) {
63462 +       tempbx >>= 1;
63463 +       if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
63464 +          if(ModeNo <= 0x13) {
63465 +             if(crt2crtc == 1) {
63466 +                tempbx++;
63467 +              }
63468            }
63469 -        }
63470 +       } else {
63471 +           if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
63472 +             if(crt2crtc == 4)   /* BIOS calls GetRatePtrCRT2 here - does not make sense */
63473 +                 if(SiS_Pr->SiS_ModeType <= 3) tempbx++;
63474 +          }
63475 +       }
63476 +     }
63477    }
63478    tempbx -= 2;
63479    temp = tempbx & 0x00FF;
63480    if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) &&
63481       (SiS_Pr->SiS_HiVision == 3)) {
63482 -    if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
63483 -      if(ModeNo == 0x2f) temp++;
63484 -    }
63485 +     if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
63486 +        if((ModeNo == 0x2f) || (ModeNo == 0x5d) || (ModeNo == 0x5e)) temp++;
63487 +     }
63488    }
63489 -  /* TW: From 1.10.7w - doesn't make sense */
63490 +  /* From 1.10.7w - doesn't make sense */
63491    if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
63492       if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
63493          if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
63494            if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {   /* SetFlag?? */
63495 -              if(ModeNo == 0x03) temp++;
63496 +             if(ModeNo == 0x03) temp++;
63497            }
63498         }
63499       }
63500 @@ -7285,15 +7538,15 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63501    tempax |= (tempbx & 0xFF00);
63502    if(HwDeviceExtension->jChipType < SIS_315H) {
63503       if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) {
63504 -        if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART)) {           /* TW: New from 630/301B (II) BIOS */
63505 +        if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART)) {           /* New from 630/301B (II) BIOS */
63506             tempax |= 0x1000;
63507             if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO))  tempax |= 0x2000;
63508          }
63509       }
63510    } else {
63511       /* TODO Check this with other BIOSes */
63512 -     if((!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV)) && 
63513 -        (SiS_Pr->SiS_HiVision == 3)) {
63514 +     if((!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV))
63515 +         /* && (SiS_Pr->SiS_HiVision == 3) */ ) {
63516         tempax |= 0x1000;
63517          if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToSVIDEO))  tempax |= 0x2000;
63518       }
63519 @@ -7301,12 +7554,12 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63520    temp = (tempax & 0xFF00) >> 8;
63521    SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,temp);
63522  
63523 -  /* TW: 650/30xLV 1.10.6s */
63524 +  /* 650/30xLV 1.10.6s */
63525    if(HwDeviceExtension->jChipType > SIS_315H) {
63526       if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
63527          if( (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) ||
63528              (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) ) {
63529 -            SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x10,0x60);
63530 +           SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x10,0x60);
63531          }
63532       }
63533    }
63534 @@ -7322,79 +7575,70 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63535       }
63536    }
63537  
63538 -  if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {     
63539 -    tempbx = SiS_Pr->SiS_VDE;
63540 -    if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_HiVision & 0x03))) {
63541 -         tempbx >>= 1;
63542 -    }
63543 -    tempbx -= 3;
63544 -    tempbx &= 0x03ff;
63545 -    temp = ((tempbx & 0xFF00) >> 8) << 5;
63546 -    temp |= 0x18;
63547 -    SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x46,temp);
63548 -    temp = tempbx & 0x00FF;
63549 -    SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x47,temp);      /* tv gatingno */
63550 -    if(HwDeviceExtension->jChipType >= SIS_315H) {     /* TW: 650/30xLV 1.10.6s */
63551 -       if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
63552 -          tempax = 0;
63553 -          if(SiS_Pr->SiS_HiVision & 0x03) {
63554 -            tempax = 0x3000;
63555 -            if(SiS_Pr->SiS_HiVision & 0x01) tempax = 0x5000;
63556 -         }
63557 -         temp = (tempax & 0xFF00) >> 8;
63558 -          SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4d,temp);
63559 -       }
63560 -    }
63561 +  if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
63562 +     tempbx = SiS_Pr->SiS_VDE;
63563 +     if((SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && (!(SiS_Pr->SiS_HiVision & 0x03))) {
63564 +        tempbx >>= 1;
63565 +     }
63566 +     tempbx -= 3;
63567 +     tempbx &= 0x03ff;
63568 +     temp = ((tempbx & 0xFF00) >> 8) << 5;
63569 +     temp |= 0x18;
63570 +     SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x46,temp);
63571 +     temp = tempbx & 0x00FF;
63572 +     SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x47,temp);     /* tv gatingno */
63573 +     if(HwDeviceExtension->jChipType >= SIS_315H) {
63574 +        if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
63575 +           tempax = 0;
63576 +           if(SiS_Pr->SiS_HiVision & 0x03) {
63577 +             tempax = 0x3000;
63578 +             if(SiS_Pr->SiS_HiVision & 0x01) tempax = 0x5000;
63579 +          }
63580 +          temp = (tempax & 0xFF00) >> 8;
63581 +           SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4d,temp);
63582 +        }
63583 +     }
63584    }
63585  
63586    tempbx &= 0x00FF;
63587    if(!(modeflag & HalfDCLK)) {
63588 -    tempcx = SiS_Pr->SiS_VGAHDE;
63589 -    if(tempcx >= SiS_Pr->SiS_HDE) {
63590 -      tempbx |= 0x2000;
63591 -      tempax &= 0x00FF;
63592 -    }
63593 +     if(SiS_Pr->SiS_VGAHDE >= SiS_Pr->SiS_HDE) {
63594 +        tempbx |= 0x2000;
63595 +        tempax &= 0x00FF;
63596 +     }
63597    }
63598  
63599    tempcx = 0x0101;
63600 -/*if(SiS_Pr->SiS_VBInfo & (SetPALTV | SetCRT2ToTV)) {  */ /*301b- TW: BIOS BUG? */
63601 +/*if(SiS_Pr->SiS_VBInfo & (SetPALTV | SetCRT2ToTV)) {  */ /* BIOS BUG? */
63602    if(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) {
63603 -    if(!(SiS_Pr->SiS_HiVision & 0x03)) {
63604 -      if(SiS_Pr->SiS_VGAHDE >= 1024) {
63605 -        if((!(modeflag & HalfDCLK)) || (HwDeviceExtension->jChipType < SIS_315H)) {   /* TW: This check not in 630/301B */
63606 -          tempcx = 0x1920;
63607 -          if(SiS_Pr->SiS_VGAHDE >= 1280) {
63608 -            tempcx = 0x1420;
63609 -            tempbx &= 0xDFFF;
63610 -          }
63611 +     if(!(SiS_Pr->SiS_HiVision & 0x03)) {
63612 +        if(SiS_Pr->SiS_VGAHDE >= 1024) {
63613 +           if((!(modeflag & HalfDCLK)) || (HwDeviceExtension->jChipType < SIS_315H)) {
63614 +              tempcx = 0x1920;
63615 +              if(SiS_Pr->SiS_VGAHDE >= 1280) {
63616 +                 tempcx = 0x1420;
63617 +                 tempbx &= 0xDFFF;
63618 +              }
63619 +           }
63620          }
63621 -      }
63622 -    }
63623 +     }
63624    }
63625  
63626    if(!(tempbx & 0x2000)) {
63627 -    if(modeflag & HalfDCLK) {
63628 -         tempcx = (tempcx & 0xFF00) | (((tempcx & 0x00FF) << 1) & 0xff);
63629 -    }
63630 -    push1 = tempbx;
63631 -    tempeax = SiS_Pr->SiS_VGAHDE;
63632 -    tempebx = (tempcx & 0xFF00) >> 8;
63633 -    longtemp = tempeax * tempebx;
63634 -    tempecx = tempcx & 0x00FF;
63635 -    longtemp /= tempecx;
63636 -    longtemp <<= 0x0d;
63637 -    if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
63638 +     if(modeflag & HalfDCLK) {
63639 +        tempcx = (tempcx & 0xFF00) | ((tempcx << 1) & 0x00FF);
63640 +     }
63641 +     longtemp = (SiS_Pr->SiS_VGAHDE * ((tempcx & 0xFF00) >> 8)) / (tempcx & 0x00FF);
63642 +     longtemp <<= 13;
63643 +     if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
63644         longtemp <<= 3;
63645 -    }
63646 -    tempecx = SiS_Pr->SiS_HDE;
63647 -    temp2 = longtemp % tempecx;
63648 -    tempeax = longtemp / tempecx;
63649 -    if(temp2 != 0) tempeax++;
63650 -    tempax = (USHORT)tempeax;
63651 -    tempbx = push1;
63652 -    tempcx = (tempcx & 0xff00) | (((tempax & 0xFF00) >> 8) >> 5);
63653 -    tempbx |= (tempax & 0x1F00);
63654 -    tempax = ((tempax & 0x00FF) << 8) | (tempax & 0x00FF);
63655 +     }
63656 +     tempeax = longtemp / SiS_Pr->SiS_HDE;
63657 +     if(longtemp % SiS_Pr->SiS_HDE) tempeax++;
63658 +     tempax = (USHORT)tempeax;
63659 +     tempcx = (tempcx & 0xFF00) | ((tempax & 0xFF00) >> (8 + 5));
63660 +     tempbx |= (tempax & 0x1F00);
63661 +     tempax = ((tempax & 0x00FF) << 8) | (tempax & 0x00FF);
63662    }
63663  
63664    temp = (tempax & 0xFF00) >> 8;
63665 @@ -7403,33 +7647,32 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63666    SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x45,0xC0,temp);
63667  
63668    if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
63669 -       temp = tempcx & 0x00FF;
63670 -       if(tempbx & 0x2000) temp = 0;
63671 -       temp |= 0x18;
63672 -       SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x46,0xE0,temp);
63673 -       if(SiS_Pr->SiS_VBInfo & SetPALTV) {
63674 -             tempbx = 0x0382;  
63675 -             tempcx = 0x007e;  
63676 -       } else {
63677 -             tempbx = 0x0369;  
63678 -             tempcx = 0x0061;  
63679 -       }
63680 -       temp = (tempbx & 0x00FF) ;
63681 -       SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4B,temp);
63682 -       temp = (tempcx & 0x00FF) ;
63683 -       SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4C,temp);
63684 -       tempbx &= 0x03FF;
63685 -       temp = (tempcx & 0xFF00) >> 8;
63686 -       temp = (temp & 0x0003) << 2;
63687 -       temp |= (tempbx >> 8);
63688 -       if(HwDeviceExtension->jChipType < SIS_315H) {
63689 -          SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4D,temp);
63690 -       } else {
63691 -          SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4D,0xF0,temp);
63692 -       }
63693 +     temp = tempcx & 0x00FF;
63694 +     if(tempbx & 0x2000) temp = 0;
63695 +     temp |= 0x18;
63696 +     SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x46,0xE0,temp);
63697  
63698 -       temp = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x43);
63699 -       SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,(USHORT)(temp - 3));
63700 +     if(SiS_Pr->SiS_VBInfo & SetPALTV) {
63701 +        tempbx = 0x0382;
63702 +        tempcx = 0x007e;
63703 +     } else {
63704 +        tempbx = 0x0369;
63705 +        tempcx = 0x0061;
63706 +     }
63707 +     temp = (tempbx & 0x00FF) ;
63708 +     SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4B,temp);
63709 +     temp = (tempcx & 0x00FF) ;
63710 +     SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4C,temp);
63711 +     temp = (tempcx & 0x0300) >> (8 - 2);
63712 +     temp |= ((tempbx >> 8) & 0x03);
63713 +     if(HwDeviceExtension->jChipType < SIS_315H) {
63714 +        SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x4D,temp);
63715 +     } else {
63716 +        SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4D,0xF0,temp);
63717 +     }
63718 +
63719 +     temp = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x43);
63720 +     SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,(USHORT)(temp - 3));
63721    }
63722  
63723    temp = 0;
63724 @@ -7440,23 +7683,33 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63725       temp = 0x38;
63726    }
63727    if(temp) {
63728 -      if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
63729 -          if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) {
63730 -               if(SiS_GetReg1(SiS_Pr->SiS_P3d4,temp) & EnablePALM) {  /* 0x40 */
63731 -                     SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xEF);
63732 -                     temp = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x01);
63733 -                     SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,temp - 1);
63734 -               }
63735 -          }
63736 -      }
63737 +     if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
63738 +        if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) {
63739 +           if(SiS_GetReg1(SiS_Pr->SiS_P3d4,temp) & EnablePALM) {  /* 0x40 */
63740 +              SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xEF);
63741 +              temp = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x01);
63742 +              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,temp - 1);
63743 +           }
63744 +        }
63745 +     }
63746    }
63747  
63748 +  if(HwDeviceExtension->jChipType >= SIS_315H) {
63749 +     if((SiS_Pr->SiS_VBType & VB_SIS301B302B) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) {
63750 +        if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
63751 +           SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0B,0x00);
63752 +        }
63753 +     }
63754 +  }
63755 +
63756 +#if 0  /* Old: Why HiVision? */
63757    if( (SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) &&
63758        (!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) ) {
63759 -    if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
63760 -      SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0B,0x00);
63761 -    }
63762 +     if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
63763 +        SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0B,0x00);
63764 +     }
63765    }
63766 +#endif
63767  
63768    if(HwDeviceExtension->jChipType < SIS_315H) {
63769       if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
63770 @@ -7465,74 +7718,43 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63771         return;
63772       }
63773    } else {
63774 -     /* TW: !!! The following is a duplicate, done for LCDA as well (see above) */
63775 +     /* !!! The following is a duplicate, done for LCDA as well (see above) */
63776       if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
63777 -       if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {    
63778 -         if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
63779 -           if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
63780 -             if((ModeNo == 0x4a) || (ModeNo == 0x38)) {
63781 -               SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1c,0xa7);
63782 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1d,0x07);
63783 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1e,0xf2);
63784 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1f,0x6e);
63785 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x20,0x17);
63786 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x21,0x8b);
63787 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x22,0x73);
63788 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,0x53);
63789 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x24,0x13);
63790 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x25,0x40);
63791 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x26,0x34);
63792 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x27,0xf4);
63793 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x28,0x63);
63794 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x29,0xbb);
63795 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2a,0xcc);
63796 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2b,0x7a);
63797 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2c,0x58);
63798 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2d,0xe4);
63799 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2e,0x73);
63800 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,0xda);
63801 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0x13);
63802 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x43,0x72);
63803 -            }
63804 -           }
63805 -         }
63806 -       }
63807 -       return;
63808 +        SiS_SetTVSpecial(SiS_Pr, ModeNo);
63809 +        return;
63810       }
63811    }
63812  
63813 -  /* TW: From here: Part2 LCD setup */
63814 +  /* From here: Part2 LCD setup */
63815  
63816    tempbx = SiS_Pr->SiS_HDE;
63817    if(HwDeviceExtension->jChipType >= SIS_315H) {
63818 -      /* TW: 650/30xLV 1.10.6s */
63819 -      if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempbx >>= 1;
63820 +     /* 650/30xLV 1.10.6s */
63821 +     if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempbx >>= 1;
63822    }
63823    tempbx--;                                    /* RHACTE=HDE-1 */
63824    temp = tempbx & 0x00FF;
63825    SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2C,temp);
63826 -  temp = (tempbx & 0xFF00) >> 8;
63827 -  temp <<= 4;
63828 +  temp = (tempbx & 0xFF00) >> 4;
63829    SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2B,0x0F,temp);
63830  
63831    temp = 0x01;
63832    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
63833 -    if(SiS_Pr->SiS_ModeType == ModeEGA) {
63834 -      if(SiS_Pr->SiS_VGAHDE >= 1024) {
63835 -        temp = 0x02;
63836 -       if(HwDeviceExtension->jChipType >= SIS_315H) {
63837 -           if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
63838 -             temp = 0x01;
63839 +     if(SiS_Pr->SiS_ModeType == ModeEGA) {
63840 +        if(SiS_Pr->SiS_VGAHDE >= 1024) {
63841 +           temp = 0x02;
63842 +          if(HwDeviceExtension->jChipType >= SIS_315H) {
63843 +              if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
63844 +                 temp = 0x01;
63845 +             }
63846            }
63847 -       }
63848 -      }
63849 -    }
63850 +        }
63851 +     }
63852    }
63853    SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x0B,temp);
63854  
63855 -  tempbx = SiS_Pr->SiS_VDE;                    /* RTVACTEO=(VDE-1)&0xFF */
63856 -  push1 = tempbx;
63857 -
63858 +  tempbx = SiS_Pr->SiS_VDE;                    /* RTVACTEO = VDE - 1 */
63859 +  /* push1 = tempbx; */
63860    tempbx--;
63861    temp = tempbx & 0x00FF;
63862    SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x03,temp);
63863 @@ -7540,10 +7762,9 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63864    SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x0C,0xF8,temp);
63865  
63866    tempcx = SiS_Pr->SiS_VT;
63867 -  push2 = tempcx;
63868 -
63869 +  /* push2 = tempcx; */
63870    tempcx--;
63871 -  temp = tempcx & 0x00FF;                       /* RVTVT=VT-1 */
63872 +  temp = tempcx & 0x00FF;                       /* RVTVT = VT - 1 */
63873    SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x19,temp);
63874  
63875    temp = (tempcx & 0xFF00) >> 8;
63876 @@ -7551,40 +7772,42 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63877    
63878    /* Enable dithering; newer versions only do this for 32bpp mode */
63879    if((HwDeviceExtension->jChipType == SIS_300) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) {
63880 -    if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) temp |= 0x10;
63881 +     if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) temp |= 0x10;
63882    } else if(HwDeviceExtension->jChipType < SIS_315H) {
63883 -    if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp |= 0x10;
63884 -    else {
63885 -      if(SiS_Pr->SiS_LCDInfo & LCDSync)       /* TW: 630/301 BIOS checks this */
63886 -         temp |= 0x10;
63887 -    }
63888 +     temp |= 0x10;
63889    } else {
63890 -      if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
63891 -         /* TW: 650/30xLV 1.10.6s */
63892 -         if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
63893 -            if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) {  /* 32bpp mode? */
63894 -              temp |= 0x10;
63895 -           }
63896 -         }
63897 -      } else {
63898 -         temp |= 0x10;
63899 -      }
63900 +     if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
63901 +        /* 650/30xLV 1.10.6s */
63902 +        if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
63903 +           if(SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x01) {  /* 32bpp mode? */
63904 +              temp |= 0x10;
63905 +          }
63906 +        }
63907 +     } else {
63908 +        temp |= 0x10;
63909 +     }
63910    }
63911  
63912    /* 630/301 does not do all this */
63913    if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
63914       if((HwDeviceExtension->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) {
63915 -        /* TW: 650/30xLV 1.10.6s */
63916 -        temp |= (SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37) >> 6);
63917 -       temp |= 0x08;                                           /* From 1.10.7w */
63918 -       if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) temp |= 0x04;  /* From 1.10.7w */
63919 -     } else {
63920 -        tempbx = (tempbx & 0xFF00) | (SiS_Pr->SiS_LCDInfo & 0x0FF);
63921 -        if(tempbx & LCDSync) {
63922 -           tempbx &= 0xFFE0;
63923 -           tempbx = (tempbx & 0xFF00) | ((tempbx & 0x00FF) >> 6);
63924 -           temp |= (tempbx & 0x00FF);
63925 -        }
63926 +       if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) &&
63927 +          (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024)) {
63928 +#ifdef SIS315H
63929 +          if(SiS_Pr->SiS_LCDInfo & LCDSync) {
63930 +             temp |= (SiS_Pr->SiS_LCDInfo >> 6);
63931 +          }
63932 +#endif
63933 +       } else {
63934 +          /* 650/30xLV 1.10.6s */
63935 +           temp |= (SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37) >> 6);
63936 +          temp |= 0x08;                                                /* From 1.10.7w */
63937 +          if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) temp |= 0x04;       /* From 1.10.7w */
63938 +       }
63939 +     } else {
63940 +        if(SiS_Pr->SiS_LCDInfo & LCDSync) {
63941 +          temp |= (SiS_Pr->SiS_LCDInfo >> 6);
63942 +       }
63943       }
63944    }
63945    SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1A,temp);
63946 @@ -7595,24 +7818,22 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63947    SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x17,0xFB);
63948    SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x18,0xDF);
63949  
63950 -  /* 1280x960, 1280x1024 and 1600x1200 data invalid/missing in tables, use old calculation */
63951 -  if((HwDeviceExtension->jChipType >= SIS_315H)             && 
63952 -     (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)                &&  
63953 -     (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) &&
63954 -     (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) &&
63955 -     (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x960)) {
63956 +  if((HwDeviceExtension->jChipType >= SIS_315H)         &&
63957 +     (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)            &&
63958 +     ((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)  ||
63959 +      (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) ||
63960 +      (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) ||
63961 +      (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) ) {
63962       
63963 -#ifdef SIS315H                                                         /* ------------- 310/325/330 series ------------ */
63964 +#ifdef SIS315H                                                         /* ------------- 315/330 series ------------ */
63965  
63966 -      /* TW: Inserted this entire section from 650/301LV(x) BIOS */
63967 -      
63968        /* Using this on the 301B with an auto-expanding 1024 panel (CR37=1) results
63969         * in a black bar in modes < 1024; if the panel is non-expanding, the bridge
63970         * scales all modes to 1024. All modes in both variants (exp/non-exp) work.
63971         */
63972  
63973        SiS_GetCRT2Part2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
63974 -                         &CRT2Index,&resindex);
63975 +                         &CRT2Index,&resindex,HwDeviceExtension);
63976  
63977        switch(CRT2Index) {
63978          case Panel_1024x768      : CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1;  break;  /* "Normal" */
63979 @@ -7627,6 +7848,9 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63980          case Panel_1280x1024 + 32: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1280x1024_3; break;
63981         case Panel_1400x1050 + 32: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1400x1050_3; break;
63982         case Panel_1600x1200 + 32: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1600x1200_3; break;
63983 +       case 100:                  CRT2Part2Ptr = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_Compaq1280x1024_1; break;  /* Custom */
63984 +       case 101:                  CRT2Part2Ptr = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_Compaq1280x1024_2; break;
63985 +       case 102:                  CRT2Part2Ptr = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_Compaq1280x1024_3; break;
63986         default:                   CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_3;  break;
63987        }
63988  
63989 @@ -7653,8 +7877,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
63990           }
63991           SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp);
63992           SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0xb3);
63993 -       }
63994 -       if(SiS_Pr->SiS_VGAVDE == 420) {
63995 +       } else if(SiS_Pr->SiS_VGAVDE == 420) {
63996           temp = 0x4d;
63997           if(SiS_Pr->SiS_ModeType <= ModeVGA) {
63998              temp++;
63999 @@ -7664,7 +7887,6 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
64000         }
64001       }
64002  
64003 -     /* TW: 650/30xLV 1.10.6s: */
64004       /* !!! This is a duplicate, done for LCDA as well - see above */
64005       if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
64006          if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
64007 @@ -7683,59 +7905,46 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
64008         * the bridge scales all modes to 1024.
64009         * !!! Malfunction at 640x480 and 640x400 when panel is auto-expanding - black screen !!!
64010         */
64011 -  
64012 +
64013 +    /* cx = VT - 1 */
64014 +
64015      tempcx++;
64016 -    
64017 -    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)       tempbx =  768;
64018 -    else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) tempbx = 1024;
64019 -    else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) tempbx = 1200;
64020 -    else if(SiS_Pr->SiS_VDE != 1024)                             tempbx =  960;
64021 -    else                                                         tempbx = 1024;
64022 -    
64023 -#if 0  /* old */
64024 -    tempbx = 768;
64025 -    if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1024x768) {
64026 -      tempbx = 1024;
64027 -      if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024) {
64028 -         tempbx = 1200;
64029 -         if(SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1600x1200) {
64030 -            if(tempbx != SiS_Pr->SiS_VDE) {
64031 -               tempbx = 960;
64032 -            }
64033 -         }
64034 -      }
64035 -    }
64036 -#endif
64037 -    
64038 +
64039 +    tempbx = SiS_Pr->PanelYRes;
64040 +
64041      if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
64042 -      tempbx = SiS_Pr->SiS_VDE - 1;
64043 -      tempcx--;
64044 +       tempbx = SiS_Pr->SiS_VDE - 1;
64045 +       tempcx--;
64046      }
64047 -    
64048 +
64049      tempax = 1;
64050      if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
64051 -      if(tempbx != SiS_Pr->SiS_VDE) {
64052 -        tempax = tempbx;
64053 -/*     if(SiS_Pr->SiS_VGAVDE == 525) tempax += 60;   in 650/301B BIOS */
64054 -        if(tempax < SiS_Pr->SiS_VDE) {
64055 -          tempax = 0;
64056 -          tempcx = 0;
64057 -        } else {
64058 -          tempax -= SiS_Pr->SiS_VDE;
64059 -        }
64060 -        tempax >>= 1;
64061 -      }
64062 -      tempcx -= tempax; /* lcdvdes */
64063 -      tempbx -= tempax; /* lcdvdee */
64064 -    } else {
64065 -      tempax >>= 1;
64066 -      tempcx -= tempax; /* lcdvdes */
64067 -      tempbx -= tempax; /* lcdvdee */
64068 +       if(tempbx != SiS_Pr->SiS_VDE) {
64069 +          tempax = tempbx;
64070 +          if(tempax < SiS_Pr->SiS_VDE) {
64071 +             tempax = 0;
64072 +             tempcx = 0;
64073 +          } else {
64074 +             tempax -= SiS_Pr->SiS_VDE;
64075 +          }
64076 +          tempax >>= 1;
64077 +       }
64078 +       tempcx -= tempax; /* lcdvdes */
64079 +       tempbx -= tempax; /* lcdvdee */
64080      }
64081 -    
64082 +#if 0  /* meaningless: 1 / 2 = 0... */
64083 +    else {
64084 +       tempax >>= 1;
64085 +       tempcx -= tempax; /* lcdvdes */
64086 +       tempbx -= tempax; /* lcdvdee */
64087 +    }
64088 +#endif
64089 +
64090 +    /* Non-expanding: lcdvdees = tempcx = VT-1; lcdvdee = tempbx = VDE-1 */
64091 +
64092  #ifdef TWDEBUG
64093 -    xf86DrvMsg(0, X_INFO, "lcdvds 0x%x lcdvde 0x%x\n", tempcx, tempbx);
64094 -#endif    
64095 +    xf86DrvMsg(0, X_INFO, "lcdvdes 0x%x lcdvdee 0x%x\n", tempcx, tempbx);
64096 +#endif
64097  
64098      temp = tempcx & 0x00FF;                            /* RVEQ1EQ=lcdvdes */
64099      SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x05,temp);
64100 @@ -7746,140 +7955,178 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHOR
64101      temp |= ((tempcx & 0xFF00) >> 8);
64102      SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,temp);
64103  
64104 -    tempbx = push2;
64105 -    tempax = push1;
64106 -    tempcx = tempbx;
64107 -    tempcx -= tempax;
64108 -    tempcx >>= 4;
64109 +    tempbx = SiS_Pr->SiS_VT;    /* push2; */
64110 +    tempax = SiS_Pr->SiS_VDE;   /* push1; */
64111 +    tempcx = (tempbx - tempax) >> 4;
64112      tempbx += tempax;
64113      tempbx >>= 1;
64114      if(SiS_Pr->SiS_LCDInfo & DontExpandLCD)  tempbx -= 10;
64115 -    
64116 +
64117 +    /* non-expanding: lcdvrs = tempbx = ((VT + VDE) / 2) - 10 */
64118 +
64119 +    if(SiS_Pr->UseCustomMode) {
64120 +       tempbx = SiS_Pr->CVSyncStart;
64121 +    }
64122 +
64123  #ifdef TWDEBUG
64124      xf86DrvMsg(0, X_INFO, "lcdvrs 0x%x\n", tempbx);
64125  #endif
64126  
64127 -    temp = tempbx & 0x00FF;                            /* RTVACTEE=lcdvrs */
64128 +    temp = tempbx & 0x00FF;                            /* RTVACTEE = lcdvrs */
64129      SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,temp);
64130  
64131      temp = ((tempbx & 0xFF00) >> 8) << 4;
64132      tempbx += (tempcx + 1);
64133      temp |= (tempbx & 0x000F);
64134 +
64135 +    if(SiS_Pr->UseCustomMode) {
64136 +       temp &= 0xf0;
64137 +       temp |= (SiS_Pr->CVSyncEnd & 0x0f);
64138 +    }
64139 +
64140 +#ifdef TWDEBUG
64141 +    xf86DrvMsg(0, X_INFO, "lcdvre[3:0] 0x%x\n", (temp & 0x0f));
64142 +#endif
64143 +
64144      SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,temp);
64145  
64146 -    /* TW: Code from 630/301B (I+II) BIOS */
64147 +    /* Code from 630/301B (I+II) BIOS */
64148  
64149 -    if( ( ( (HwDeviceExtension->jChipType == SIS_630) ||
64150 -            (HwDeviceExtension->jChipType == SIS_730) ) &&
64151 -          (HwDeviceExtension->jChipRevision > 2) )  &&
64152 -        (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) &&
64153 -        (!(SiS_Pr->SiS_SetFlag & LCDVESATiming))  &&
64154 -        (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) {
64155 -            if(ModeNo == 0x13) {
64156 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,0xB9);
64157 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x05,0xCC);
64158 -              SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,0xA6);
64159 -            } else {
64160 -              if((crt2crtc & 0x3F) == 4) {
64161 +    if(!SiS_Pr->UseCustomMode) {
64162 +       if( ( ( (HwDeviceExtension->jChipType == SIS_630) ||
64163 +               (HwDeviceExtension->jChipType == SIS_730) ) &&
64164 +             (HwDeviceExtension->jChipRevision > 2) )  &&
64165 +           (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) &&
64166 +           (!(SiS_Pr->SiS_SetFlag & LCDVESATiming))  &&
64167 +           (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) {
64168 +          if(ModeNo == 0x13) {
64169 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,0xB9);
64170 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x05,0xCC);
64171 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,0xA6);
64172 +          } else {
64173 +             if((crt2crtc & 0x3F) == 4) {
64174                  SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x2B);
64175                  SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x13);
64176                  SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,0xE5);
64177                  SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x05,0x08);
64178                  SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,0xE2);
64179 -              }
64180 -            }
64181 +             }
64182 +          }
64183 +       }
64184      }
64185  
64186 -    /* TW: Inserted missing code from 630/301B BIOS;
64187 -     *     Strangely, this is done in all 650 BIOSes as
64188 -     *     well (although LCDTypeInfo is not used there
64189 -     *     in the same way as on 300 series)
64190 -     */
64191 -
64192 -    if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) {
64193 -         crt2crtc &= 0x1f;
64194 -         tempcx = 0;
64195 -         if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) {
64196 -           if (SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
64197 -              tempcx += 7;
64198 -           }
64199 -         }
64200 -         tempcx += crt2crtc;
64201 -         if (crt2crtc >= 4) {
64202 -           SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,0xff);
64203 -         }
64204 +#ifdef SIS300
64205 +    if(HwDeviceExtension->jChipType < SIS_315H) {
64206 +       if(!SiS_Pr->UseCustomMode) {
64207 +          if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) {
64208 +             crt2crtc &= 0x1f;
64209 +             tempcx = 0;
64210 +             if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) {
64211 +                if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
64212 +                   tempcx += 7;
64213 +                }
64214 +             }
64215 +             tempcx += crt2crtc;
64216 +             if(crt2crtc >= 4) {
64217 +                SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x06,0xff);
64218 +             }
64219  
64220 -         if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) {
64221 -           if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
64222 -             if(crt2crtc == 4) {
64223 -                SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x28);
64224 +             if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) {
64225 +                if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
64226 +                   if(crt2crtc == 4) {
64227 +                      SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x01,0x28);
64228 +                   }
64229 +                }
64230               }
64231 -           }
64232 -         }
64233 -         SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x18);
64234 -         SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]);
64235 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x02,0x18);
64236 +             SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]);
64237 +          }
64238 +       }
64239      }
64240 +#endif
64241  
64242 -    tempcx = (SiS_Pr->SiS_HT - SiS_Pr->SiS_HDE) >> 2;     /* (HT-HDE)>>2     */
64243 +    tempcx = (SiS_Pr->SiS_HT - SiS_Pr->SiS_HDE) >> 2;     /* (HT - HDE) >> 2 */
64244      tempbx = SiS_Pr->SiS_HDE + 7;                        /* lcdhdee         */
64245      if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
64246 -         tempbx += 2;
64247 +       tempbx += 2;
64248      }
64249      push1 = tempbx;
64250 +
64251  #ifdef TWDEBUG
64252 -    xf86DrvMsg(0, X_INFO, "lcdhde 0x%x\n", tempbx);
64253 -#endif    
64254 -    temp = tempbx & 0x00FF;                                      /* RHEQPLE=lcdhdee */
64255 +    xf86DrvMsg(0, X_INFO, "lcdhdee 0x%x\n", tempbx);
64256 +#endif
64257 +
64258 +    temp = tempbx & 0x00FF;                                      /* RHEQPLE = lcdhdee */
64259      SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x23,temp);
64260      temp = (tempbx & 0xFF00) >> 8;
64261      SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0xF0,temp);
64262  
64263      temp = 7;
64264      if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
64265 -         temp += 2;
64266 +       temp += 2;
64267      }
64268 -    SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1F,temp);        /* RHBLKE=lcdhdes[7:0] */
64269 +    SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1F,temp);        /* RHBLKE = lcdhdes[7:0] */
64270      SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x20,0x0F);      /* lcdhdes [11:8] */
64271  
64272      tempbx += tempcx;
64273      push2 = tempbx;
64274 +
64275 +    if(SiS_Pr->UseCustomMode) {
64276 +       tempbx = SiS_Pr->CHSyncStart + 7;
64277 +       if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
64278 +          tempbx += 2;
64279 +       }
64280 +    }
64281 +
64282  #ifdef TWDEBUG
64283      xf86DrvMsg(0, X_INFO, "lcdhrs 0x%x\n", tempbx);
64284  #endif
64285 -    temp = tempbx & 0x00FF;                                      /* RHBURSTS=lcdhrs */
64286 -    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
64287 -       if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 
64288 -          if(SiS_Pr->SiS_HDE == 1280) temp = 0x47;
64289 +
64290 +    temp = tempbx & 0x00FF;                                      /* RHBURSTS = lcdhrs */
64291 +    if(!SiS_Pr->UseCustomMode) {
64292 +       if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
64293 +          if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
64294 +             if(SiS_Pr->SiS_HDE == 1280) temp = 0x47;
64295 +          }
64296         }
64297      }
64298      SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x1C,temp);
64299 -    temp = ((tempbx & 0xFF00) >> 8) << 4;
64300 +    temp = (tempbx & 0x0F00) >> 4;
64301      SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,temp);
64302  
64303      tempbx = push2;
64304      tempcx <<= 1;
64305      tempbx += tempcx;
64306 +
64307 +    if(SiS_Pr->UseCustomMode) {
64308 +       tempbx = SiS_Pr->CHSyncEnd + 7;
64309 +       if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
64310 +          tempbx += 2;
64311 +       }
64312 +    }
64313 +
64314  #ifdef TWDEBUG
64315      xf86DrvMsg(0, X_INFO, "lcdhre 0x%x\n", tempbx);
64316 -#endif    
64317 -    temp = tempbx & 0x00FF;                                      /* RHSYEXP2S=lcdhre */
64318 +#endif
64319 +
64320 +    temp = tempbx & 0x00FF;                                      /* RHSYEXP2S = lcdhre */
64321      SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x21,temp);
64322  
64323      if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
64324 -      if(SiS_Pr->SiS_VGAVDE == 525) {
64325 -        if(SiS_Pr->SiS_ModeType <= ModeVGA)
64326 -          temp=0xC6;
64327 -        else
64328 -                  temp=0xC3;
64329 -        SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp);
64330 -        SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0xB3);
64331 -      } else if(SiS_Pr->SiS_VGAVDE == 420) {
64332 -        if(SiS_Pr->SiS_ModeType <= ModeVGA)
64333 -          temp=0x4F;
64334 -        else
64335 -                  temp=0x4D;   
64336 -        SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp);
64337 -      }
64338 +       if(SiS_Pr->SiS_VGAVDE == 525) {
64339 +          if(SiS_Pr->SiS_ModeType <= ModeVGA)
64340 +            temp=0xC6;
64341 +          else
64342 +                    temp=0xC3;
64343 +          SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp);
64344 +          SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x30,0xB3);
64345 +       } else if(SiS_Pr->SiS_VGAVDE == 420) {
64346 +          if(SiS_Pr->SiS_ModeType <= ModeVGA)
64347 +            temp=0x4F;
64348 +          else
64349 +                    temp=0x4D;
64350 +          SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x2f,temp);
64351 +       }
64352      }
64353      SiS_Set300Part2Regs(SiS_Pr, HwDeviceExtension, ModeIdIndex,
64354                          RefreshRateTableIndex, BaseAddr, ModeNo);
64355 @@ -7898,7 +8145,7 @@ SiS_GetVGAHT2(SiS_Private *SiS_Pr)
64356    return((USHORT) tempax);
64357  }
64358  
64359 -/* TW: New from 300/301LV BIOS 1.16.51 for ECS A907. Seems highly preliminary. */
64360 +/* New from 300/301LV BIOS 1.16.51 for ECS A907. Seems highly preliminary. */
64361  void
64362  SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
64363                         USHORT ModeIdIndex, USHORT RefreshRateTableIndex,
64364 @@ -7910,18 +8157,19 @@ SiS_Set300Part2Regs(SiS_Private *SiS_Pr,
64365  
64366    if(HwDeviceExtension->jChipType != SIS_300) return;
64367    if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return;
64368 +  if(SiS_Pr->UseCustomMode) return;
64369  
64370 -  if(ModeNo<=0x13) {
64371 -       crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
64372 +  if(ModeNo <= 0x13) {
64373 +     crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
64374    } else {
64375 -       crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
64376 +     crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
64377    }
64378  
64379    resindex = crt2crtc & 0x3F;
64380    if(SiS_Pr->SiS_SetFlag & LCDVESATiming) CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1;
64381    else                                    CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_2;
64382  
64383 -  /* TW: The BIOS code (1.16.51) is obviously a fragment! */
64384 +  /* The BIOS code (1.16.51) is obviously a fragment! */
64385    if(ModeNo > 0x13) {
64386       CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1;
64387       resindex = 4;
64388 @@ -7942,7 +8190,6 @@ SiS_Set300Part2Regs(SiS_Private *SiS_Pr,
64389    SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]);
64390  }
64391  
64392 -/* TW: Set 301 Macrovision(tm) registers */
64393  void
64394  SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT  BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
64395                USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension)
64396 @@ -7954,24 +8201,35 @@ SiS_SetGroup3(SiS_Private *SiS_Pr, USHOR
64397  
64398    if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return;
64399  
64400 -  if(ModeNo<=0x13)
64401 -       modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
64402 -  else
64403 +  if(ModeNo<=0x13) {
64404 +     modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
64405 +  } else {
64406 +     if(SiS_Pr->UseCustomMode) {
64407 +        modeflag = SiS_Pr->CModeFlag;
64408 +     } else {
64409         modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
64410 +     }
64411 +  }
64412  
64413 +#ifndef SIS_CP
64414    SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x00,0x00);
64415 +#endif
64416 +
64417 +#ifdef SIS_CP
64418 +  SIS_CP_INIT301_CP
64419 +#endif
64420  
64421    if(SiS_Pr->SiS_VBInfo & SetPALTV) {
64422 -    SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xFA);
64423 -    SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xC8);
64424 +     SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xFA);
64425 +     SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xC8);
64426    } else {
64427 -    if(HwDeviceExtension->jChipType >= SIS_315H) {
64428 -      SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xF5);
64429 -      SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xB7);
64430 -    } else {
64431 -      SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xF6);
64432 -      SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xBf);
64433 -    }
64434 +     if(HwDeviceExtension->jChipType >= SIS_315H) {
64435 +        SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xF5);
64436 +        SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xB7);
64437 +     } else {
64438 +        SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xF6);
64439 +        SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xBf);
64440 +     }
64441    }
64442  
64443    temp = 0;
64444 @@ -7982,38 +8240,41 @@ SiS_SetGroup3(SiS_Private *SiS_Pr, USHOR
64445       temp = 0x38;
64446    }
64447    if(temp) {
64448 -      if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
64449 -          if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) {
64450 -              if(SiS_GetReg1(SiS_Pr->SiS_P3d4,temp) & EnablePALM){  /* 0x40 */
64451 -                  SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xFA);
64452 -                  SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xC8);
64453 -                  SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x3D,0xA8);
64454 -              }
64455 -          }
64456 -      }
64457 +     if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
64458 +        if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x31) & 0x01) {
64459 +           if(SiS_GetReg1(SiS_Pr->SiS_P3d4,temp) & EnablePALM){  /* 0x40 */
64460 +              SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x13,0xFA);
64461 +              SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x14,0xC8);
64462 +              SiS_SetReg1(SiS_Pr->SiS_Part3Port,0x3D,0xA8);
64463 +           }
64464 +        }
64465 +     }
64466    }
64467  
64468    if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
64469 -    tempdi = SiS_Pr->SiS_HiTVGroup3Data;
64470 -    if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
64471 -      tempdi = SiS_Pr->SiS_HiTVGroup3Simu;
64472 -      if(!(modeflag & Charx8Dot)) {
64473 -        tempdi = SiS_Pr->SiS_HiTVGroup3Text;
64474 -      }
64475 -    }
64476 -    if(SiS_Pr->SiS_HiVision & 0x03) {
64477 -       tempdi = SiS_HiTVGroup3_1;
64478 -       if(SiS_Pr->SiS_HiVision & 0x02) tempdi = SiS_HiTVGroup3_2;
64479 -    }
64480 -    for(i=0; i<=0x3E; i++){
64481 -       SiS_SetReg1(SiS_Pr->SiS_Part3Port,i,tempdi[i]);
64482 -    }
64483 +     tempdi = SiS_Pr->SiS_HiTVGroup3Data;
64484 +     if(SiS_Pr->SiS_SetFlag & TVSimuMode) {
64485 +        tempdi = SiS_Pr->SiS_HiTVGroup3Simu;
64486 +        if(!(modeflag & Charx8Dot)) {
64487 +           tempdi = SiS_Pr->SiS_HiTVGroup3Text;
64488 +        }
64489 +     }
64490 +     if(SiS_Pr->SiS_HiVision & 0x03) {
64491 +        tempdi = SiS_HiTVGroup3_1;
64492 +        if(SiS_Pr->SiS_HiVision & 0x02) tempdi = SiS_HiTVGroup3_2;
64493 +     }
64494 +     for(i=0; i<=0x3E; i++){
64495 +        SiS_SetReg1(SiS_Pr->SiS_Part3Port,i,tempdi[i]);
64496 +     }
64497    }
64498  
64499 -  return;
64500 +#ifdef SIS_CP
64501 +  SIS_CP_INIT301_CP2
64502 +#endif
64503 +
64504  }
64505  
64506 -/* TW: Set 301 VGA2 registers */
64507 +/* Set 301 VGA2 registers */
64508  void
64509  SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT  BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
64510                USHORT ModeIdIndex,USHORT RefreshRateTableIndex,
64511 @@ -8022,17 +8283,20 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHOR
64512    USHORT tempax,tempcx,tempbx,modeflag,temp,temp2,resinfo;
64513    ULONG tempebx,tempeax,templong;
64514  
64515 -
64516 -  if(ModeNo<=0x13) {
64517 -       modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
64518 -       resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
64519 +  if(ModeNo <= 0x13) {
64520 +     modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
64521 +     resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
64522    } else {
64523 +     if(SiS_Pr->UseCustomMode) {
64524 +        modeflag = SiS_Pr->CModeFlag;
64525 +       resinfo = 0;
64526 +     } else {
64527         modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
64528         resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
64529 +     }
64530    }
64531  
64532    if(HwDeviceExtension->jChipType >= SIS_315H) {
64533 -      /* TW: From 650/302LV 1.10.6s (not for 300/301LV - no LCDA on this combination) */
64534       if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
64535          if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
64536             SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x24,0x0e);
64537 @@ -8049,10 +8313,10 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHOR
64538    if(HwDeviceExtension->jChipType >= SIS_315H) {
64539       if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
64540          if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
64541 -          /* TW: From 650/301LV (any, incl. 1.10.6s, 1.10.7w) */
64542 -          /* TW: This is a duplicate; done at the end, too */
64543 +          /* From 650/301LV (any, incl. 1.10.6s, 1.10.7w) */
64544 +          /* This is a duplicate; done at the end, too */
64545            if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) {
64546 -               SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c);
64547 +             SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c);
64548            }
64549            SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00);
64550            SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);
64551 @@ -8090,39 +8354,33 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHOR
64552    tempbx = SiS_Pr->SiS_VGAHDE;
64553    if(modeflag & HalfDCLK)  tempbx >>= 1;
64554  
64555 -  /* TW: New for 650/301LV and 630/301B */
64556    temp = 0xA0;
64557    if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVisionTV) {
64558 -       temp = 0;
64559 -       if(tempbx > 800) {
64560 -          temp = 0xA0;
64561 -          if(tempbx != 1024) {
64562 -             temp = 0xC0;
64563 -             if(tempbx != 1280) temp = 0;
64564 -         }
64565 -       }
64566 -  } else
64567 -    if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
64568 -      if(tempbx <= 800) {
64569 -         temp = 0x80;
64570 -        if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
64571 -            temp = 0;
64572 -            if(tempbx > 800) temp = 0x60;
64573 -         }
64574 -      }
64575 +     temp = 0;
64576 +     if(tempbx > 800) {
64577 +        temp = 0xA0;
64578 +        if(tempbx != 1024) {
64579 +           temp = 0xC0;
64580 +           if(tempbx != 1280) temp = 0;
64581 +       }
64582 +     }
64583 +  } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
64584 +     if(tempbx <= 800) {
64585 +        temp = 0x80;
64586 +     }
64587    } else {
64588 -      temp = 0x80;
64589 -      if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
64590 -            temp = 0;
64591 -            if(tempbx > 800) temp = 0x60;
64592 -      }
64593 +     temp = 0x80;
64594 +     if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
64595 +        temp = 0;
64596 +        if(tempbx > 800) temp = 0x60;
64597 +     }
64598    }
64599    if(SiS_Pr->SiS_HiVision & 0x03) {
64600          temp = 0;
64601         if(SiS_Pr->SiS_VGAHDE == 1024) temp = 0x20;
64602    }
64603    if(HwDeviceExtension->jChipType >= SIS_315H) {
64604 -       if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) temp = 0;
64605 +     if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) temp = 0;
64606    }
64607  
64608    if(SiS_Pr->SiS_VBType & VB_SIS301) {
64609 @@ -8144,10 +8402,10 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHOR
64610  
64611    tempeax = SiS_Pr->SiS_VGAVDE;
64612    tempcx |= 0x4000;
64613 -  if(tempeax <= tempebx){
64614 -    tempcx ^= 0x4000;
64615 +  if(tempeax <= tempebx) {
64616 +     tempcx ^= 0x4000;
64617    } else {
64618 -    tempeax -= tempebx;
64619 +     tempeax -= tempebx;
64620    }
64621  
64622    templong = (tempeax * 256 * 1024) % tempebx;
64623 @@ -8173,64 +8431,64 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHOR
64624           tempax = SiS_Pr->SiS_VGAHDE;
64625           if(modeflag & HalfDCLK) tempax >>= 1;
64626           if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) || (SiS_Pr->SiS_HiVision & 0x03)) {
64627 -            if(HwDeviceExtension->jChipType >= SIS_315H) {
64628 -                if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempax >>= 1;
64629 -                else if(tempax > 800) tempax -= 800;
64630 -            } else {
64631 -                 if(tempax > 800) tempax -= 800;
64632 -             }
64633 +           if(HwDeviceExtension->jChipType >= SIS_315H) {
64634 +              if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempax >>= 1;
64635 +              else if(tempax > 800) tempax -= 800;
64636 +           } else {
64637 +               if(tempax > 800) tempax -= 800;
64638 +            }
64639           }
64640  
64641  /*       if((SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetPALTV)) && (!(SiS_Pr->SiS_HiVision & 0x03))) {  */
64642          if((SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) && (!(SiS_Pr->SiS_HiVision & 0x03))) {
64643 -           if(tempax > 800) {
64644 -             tempbx = 8;
64645 -              if(tempax == 1024)
64646 -               tempax *= 25;
64647 -              else
64648 -               tempax *= 20;
64649 -
64650 -             temp = tempax % 32;
64651 -             tempax /= 32;
64652 -             tempax--;
64653 -             if (temp!=0) tempax++;
64654 -           }
64655 +            if(tempax > 800) {
64656 +              tempbx = 8;
64657 +               if(tempax == 1024)
64658 +                 tempax *= 25;
64659 +               else
64660 +                 tempax *= 20;
64661 +
64662 +              temp = tempax % 32;
64663 +              tempax /= 32;
64664 +              tempax--;
64665 +              if (temp!=0) tempax++;
64666 +            }
64667           }
64668          tempax--;
64669           temp = (tempax & 0xFF00) >> 8;
64670           temp &= 0x03;
64671 -        if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {         /* From 1.10.7w */
64672 -               if(ModeNo > 0x13) {                     /* From 1.10.7w */
64673 -                       if(resinfo == 8) tempax = 0x1f; /* From 1.10.7w */
64674 -               }                                       /* From 1.10.7w */
64675 -        }                                              /* From 1.10.7w */
64676 +        if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {                 /* From 1.10.7w */
64677 +           if(ModeNo > 0x13) {                                 /* From 1.10.7w */
64678 +              if(resinfo == SIS_RI_1024x768) tempax = 0x1f;    /* From 1.10.7w */
64679 +           }                                                   /* From 1.10.7w */
64680 +        }                                                      /* From 1.10.7w */
64681          SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1D,tempax & 0x00FF);
64682          temp <<= 4;
64683          temp |= tempbx;
64684          SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1E,temp);
64685  
64686          if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
64687 -           if(IS_SIS650740) {
64688 -               temp = 0x0026;  /* 1.10.7w; 1.10.8r; needs corresponding code in Dis/EnableBridge! */
64689 +           if(IS_SIS550650740660) {
64690 +              temp = 0x0026;  /* 1.10.7w; 1.10.8r; needs corresponding code in Dis/EnableBridge! */
64691             } else {
64692 -               temp = 0x0036;
64693 +              temp = 0x0036;
64694             }
64695          } else {
64696 -            temp = 0x0036;
64697 +           temp = 0x0036;
64698          }
64699           if((SiS_Pr->SiS_VBInfo & (SetCRT2ToTV - SetCRT2ToHiVisionTV)) &&
64700                                        (!(SiS_Pr->SiS_HiVision & 0x03))) {
64701 -               temp |= 0x01;
64702 -               if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
64703 -                 if(!(SiS_Pr->SiS_SetFlag & TVSimuMode))
64704 -                         temp &= 0xFE;
64705 -               }
64706 +           temp |= 0x01;
64707 +           if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
64708 +              if(!(SiS_Pr->SiS_SetFlag & TVSimuMode))
64709 +                 temp &= 0xFE;
64710 +           }
64711           }
64712           SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0,temp);
64713  
64714          tempbx = SiS_Pr->SiS_HT;
64715          if(HwDeviceExtension->jChipType >= SIS_315H) {
64716 -               if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempbx >>= 1;
64717 +           if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) tempbx >>= 1;
64718          }
64719           tempbx >>= 1;
64720          tempbx -= 2;
64721 @@ -8238,7 +8496,7 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHOR
64722           SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0xC0,temp);
64723           temp = tempbx & 0x00FF;
64724           SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x22,temp);
64725 -        
64726 +
64727           if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
64728             if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
64729                 SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x24,0x0e);
64730 @@ -8246,24 +8504,24 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHOR
64731          }
64732  
64733          if(HwDeviceExtension->jChipType >= SIS_315H) {
64734 -            /* TW: 650/LV BIOS does this for all bridge types - assumingly wrong */
64735 -            /* 315, 330, 650+301B BIOS don't do this at all */
64736 -             /* TW: This is a duplicate; done for LCDA as well (see above) */
64737 -            if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
64738 -               if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) {
64739 -                  SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c);
64740 -               }
64741 -               SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00);
64742 -               SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);
64743 -               SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10);
64744 -            }
64745 +           /* 650/LV BIOS does this for all bridge types - assumingly wrong */
64746 +           /* 315, 330, 650+301B BIOS don't do this at all */
64747 +            /* This is a duplicate; done for LCDA as well (see above) */
64748 +           if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
64749 +              if(SiS_GetReg1(SiS_Pr->SiS_P3d4,0x39) & 0x04) {
64750 +                 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c);
64751 +              }
64752 +              SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00);
64753 +              SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);
64754 +              SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10);
64755 +           }
64756           } else if(HwDeviceExtension->jChipType == SIS_300) {
64757 -            /* TW: 300/301LV BIOS does this for all bridge types - assumingly wrong */
64758 -            if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
64759 -               SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00);
64760 -               SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);
64761 -               SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10);
64762 -            }
64763 +           /* 300/301LV BIOS does this for all bridge types - assumingly wrong */
64764 +           if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) {
64765 +              SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00);
64766 +              SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);
64767 +              SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10);
64768 +           }
64769          }
64770  
64771    }  /* 301B */
64772 @@ -8278,21 +8536,26 @@ SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USH
64773                   USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension)
64774  {
64775    USHORT vclkindex;
64776 -  USHORT tempah;
64777 +  USHORT temp, reg1, reg2;
64778  
64779 -  vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
64780 -                              HwDeviceExtension);
64781 +  if(SiS_Pr->UseCustomMode) {
64782 +     reg1 = SiS_Pr->CSR2B;
64783 +     reg2 = SiS_Pr->CSR2C;
64784 +  } else {
64785 +     vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
64786 +                                 HwDeviceExtension);
64787 +     reg1 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A;
64788 +     reg2 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B;
64789 +  }
64790  
64791    if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
64792 -     tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A;
64793 -     SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,tempah);
64794 -     tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B;
64795 -     SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0B,tempah);
64796 +     SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,reg1);
64797 +     SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0B,reg2);
64798       if(HwDeviceExtension->jChipType >= SIS_315H) {
64799         if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
64800             if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
64801               if(!(SiS_Pr->SiS_VBInfo & SetPALTV)) {
64802 -                 if((ModeNo == 0x4a) || (ModeNo == 0x38)) {
64803 +                 if((ModeNo == 0x64) || (ModeNo == 0x4a) || (ModeNo == 0x38)) {
64804                     SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0a,0x57);
64805                     SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0b,0x46);
64806                     SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x1f,0xf6);
64807 @@ -8303,15 +8566,13 @@ SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USH
64808       }
64809    } else {     
64810       SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,0x01);
64811 -     tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B;
64812 -     SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0B,tempah);
64813 -     tempah = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A;
64814 -     SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,tempah);
64815 +     SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0B,reg2);
64816 +     SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x0A,reg1);
64817    }
64818    SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x12,0x00);
64819 -  tempah = 0x08;
64820 -  if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) tempah |= 0x20;
64821 -  SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x12,tempah);
64822 +  temp = 0x08;
64823 +  if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) temp |= 0x20;
64824 +  SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x12,temp);
64825  }
64826  
64827  USHORT
64828 @@ -8319,23 +8580,24 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, UCH
64829                  USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension)
64830  {
64831    USHORT tempbx;
64832 -  const USHORT LCDXlat0VCLK[4]    = {VCLK40, VCLK40, VCLK40, VCLK40};
64833 -  const USHORT LVDSXlat1VCLK[4]   = {VCLK40, VCLK40, VCLK40, VCLK40};
64834 +  const USHORT LCDXlat0VCLK[4]    = {VCLK40,       VCLK40,       VCLK40,       VCLK40};
64835 +  const USHORT LVDSXlat1VCLK[4]   = {VCLK40,       VCLK40,       VCLK40,       VCLK40};
64836 +  const USHORT LVDSXlat4VCLK[4]   = {VCLK28,       VCLK28,       VCLK28,       VCLK28};
64837  #ifdef SIS300
64838 -  const USHORT LCDXlat1VCLK300[4] = {VCLK65,   VCLK65,   VCLK65,   VCLK65};
64839 -  const USHORT LCDXlat2VCLK300[4] = {VCLK108_2,VCLK108_2,VCLK108_2,VCLK108_2};
64840 -  const USHORT LVDSXlat2VCLK300[4]= {VCLK65,   VCLK65,   VCLK65,   VCLK65};
64841 -  const USHORT LVDSXlat3VCLK300[4]= {VCLK65,   VCLK65,   VCLK65,   VCLK65};
64842 +  const USHORT LCDXlat1VCLK300[4] = {VCLK65_300,   VCLK65_300,   VCLK65_300,   VCLK65_300};
64843 +  const USHORT LCDXlat2VCLK300[4] = {VCLK108_2_300,VCLK108_2_300,VCLK108_2_300,VCLK108_2_300};
64844 +  const USHORT LVDSXlat2VCLK300[4]= {VCLK65_300,   VCLK65_300,   VCLK65_300,   VCLK65_300};
64845 +  const USHORT LVDSXlat3VCLK300[4]= {VCLK65_300,   VCLK65_300,   VCLK65_300,   VCLK65_300};
64846  #endif
64847  #ifdef SIS315H
64848 -  const USHORT LCDXlat1VCLK310[4] = {VCLK65+2,   VCLK65+2,   VCLK65+2,   VCLK65+2};
64849 -  const USHORT LCDXlat2VCLK310[4] = {VCLK108_2+5,VCLK108_2+5,VCLK108_2+5,VCLK108_2+5};
64850 -  const USHORT LVDSXlat2VCLK310[4]= {VCLK65+2,   VCLK65+2,   VCLK65+2,   VCLK65+2};
64851 -  const USHORT LVDSXlat3VCLK310[4]= {VCLK108_2+5,VCLK108_2+5,VCLK108_2+5,VCLK108_2+5};
64852 +  const USHORT LCDXlat1VCLK310[4] = {VCLK65_315,   VCLK65_315,   VCLK65_315,   VCLK65_315};
64853 +  const USHORT LCDXlat2VCLK310[4] = {VCLK108_2_315,VCLK108_2_315,VCLK108_2_315,VCLK108_2_315};
64854 +  const USHORT LVDSXlat2VCLK310[4]= {VCLK65_315,   VCLK65_315,   VCLK65_315,   VCLK65_315};
64855 +  const USHORT LVDSXlat3VCLK310[4]= {VCLK108_2_315,VCLK108_2_315,VCLK108_2_315,VCLK108_2_315};
64856  #endif
64857    USHORT CRT2Index,VCLKIndex=0;
64858    USHORT modeflag,resinfo;
64859 -  const UCHAR *CHTVVCLKPtr=NULL;
64860 +  const UCHAR  *CHTVVCLKPtr = NULL;
64861    const USHORT *LCDXlatVCLK1 = NULL;
64862    const USHORT *LCDXlatVCLK2 = NULL;
64863    const USHORT *LVDSXlatVCLK2 = NULL;
64864 @@ -8372,33 +8634,40 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, UCH
64865       if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) {
64866  
64867          CRT2Index >>= 6;
64868 -        if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)){      /*  LCD */
64869 +        if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {      /*  LCD */
64870              if(HwDeviceExtension->jChipType < SIS_315H) {
64871 -              if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600)
64872 +              if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) {
64873                         VCLKIndex = LCDXlat0VCLK[CRT2Index];
64874 -              else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)
64875 +              } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
64876                         VCLKIndex = LCDXlatVCLK1[CRT2Index];
64877 -              else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600)
64878 +              } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600) {
64879                         VCLKIndex = LCDXlatVCLK1[CRT2Index];
64880 -              else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768)
64881 +              } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1152x768) {
64882                         VCLKIndex = LCDXlatVCLK1[CRT2Index];
64883 -              else
64884 +              } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) {
64885 +                       VCLKIndex = VCLK81_300; /* guessed */
64886 +              } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) {
64887 +                       VCLKIndex = VCLK108_3_300;
64888 +                       if(resinfo == SIS_RI_1280x1024) VCLKIndex = VCLK100_300;
64889 +              } else {
64890                         VCLKIndex = LCDXlatVCLK2[CRT2Index];
64891 +              }
64892             } else {
64893 -               /* TW: 330, 650/301LV BIOS does not check expanding, 315 does  */
64894 -              if( (HwDeviceExtension->jChipType > SIS_315PRO) ||
64895 +              if( (SiS_Pr->SiS_VBType & VB_SIS301LV302LV) ||
64896                    (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) {
64897                   if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
64898 -                    VCLKIndex = 0x19;
64899 +                    VCLKIndex = VCLK108_2_315;
64900 +                 } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x768) {
64901 +                    VCLKIndex = VCLK81_315;    /* guessed */
64902                   } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
64903 -                    VCLKIndex = 0x19;
64904 +                    VCLKIndex = VCLK108_2_315;
64905                   } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) {
64906 -                    VCLKIndex = 0x21;
64907 +                    VCLKIndex = VCLK162_315;
64908 +                 } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) {
64909 +                    VCLKIndex = VCLK108_3_315;
64910 +                    if(resinfo == SIS_RI_1280x1024) VCLKIndex = VCLK100_315;
64911                   } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
64912                      VCLKIndex = LCDXlatVCLK1[CRT2Index];
64913 -                  } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x960) {
64914 -                    VCLKIndex = 0x45;  /* TW: in VBVCLK table */
64915 -                    if(resinfo == 0x09) VCLKIndex++;
64916                   } else {
64917                      VCLKIndex = LCDXlatVCLK2[CRT2Index];
64918                   }
64919 @@ -8408,12 +8677,18 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, UCH
64920                    if(ModeNo > 0x13) {
64921                         VCLKIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
64922                    }
64923 -                  if(ModeNo <= 0x13) {  /* TW: 315 BIOS */
64924 -                     if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x42;
64925 +                  if(ModeNo <= 0x13) {
64926 +                     if(HwDeviceExtension->jChipType <= SIS_315PRO) {
64927 +                        if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x42;
64928 +                     } else {
64929 +                        if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x00;
64930 +                     }
64931 +                  }
64932 +                  if(HwDeviceExtension->jChipType <= SIS_315PRO) {
64933 +                     if(VCLKIndex == 0) VCLKIndex = 0x41;
64934 +                     if(VCLKIndex == 1) VCLKIndex = 0x43;
64935 +                     if(VCLKIndex == 4) VCLKIndex = 0x44;
64936                    }
64937 -                  if(VCLKIndex == 0) VCLKIndex = 0x41;
64938 -                  if(VCLKIndex == 1) VCLKIndex = 0x43;
64939 -                  if(VCLKIndex == 4) VCLKIndex = 0x44;
64940                }
64941             }
64942          } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {                 /*  TV */
64943 @@ -8429,9 +8704,11 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, UCH
64944                                 if(SiS_Pr->SiS_SetFlag & RPLLDIV2XO)  VCLKIndex = TVVCLKDIV2;
64945                         else                                  VCLKIndex = TVVCLK;
64946                 }
64947 -               if(HwDeviceExtension->jChipType >= SIS_315H) {
64948 -                       VCLKIndex += 25;
64949 -               }
64950 +               if(HwDeviceExtension->jChipType < SIS_315H) {
64951 +                       VCLKIndex += TVCLKBASE_300;
64952 +               } else {
64953 +                       VCLKIndex += TVCLKBASE_315;
64954 +               }
64955          } else {                                               /* RAMDAC2 */
64956                 VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02));
64957                 VCLKIndex = ((VCLKIndex >> 2) & 0x03);
64958 @@ -8441,7 +8718,11 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, UCH
64959                                 VCLKIndex &= 0x3f;
64960                                 if( (HwDeviceExtension->jChipType == SIS_630) &&
64961                                     (HwDeviceExtension->jChipRevision >= 0x30)) {
64962 -                                    if(VCLKIndex == 0x14) VCLKIndex = 0x2e;
64963 +                                    /* This is certainly wrong: It replaces clock
64964 +                                     * 108 by 47...
64965 +                                     */
64966 +                                    /* if(VCLKIndex == 0x14) VCLKIndex = 0x2e; */
64967 +                                    if(VCLKIndex == 0x14) VCLKIndex = 0x34;
64968                                 }
64969                         }
64970                 }
64971 @@ -8505,6 +8786,10 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, UCH
64972                 if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel800x600) ||
64973                    (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480))
64974                         VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
64975 +               else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480   ||
64976 +                       SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2 ||
64977 +                       SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3)
64978 +                       VCLKIndex = LVDSXlat4VCLK[VCLKIndex];
64979                 else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768)
64980                         VCLKIndex = LVDSXlatVCLK2[VCLKIndex];
64981                 else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x600)
64982 @@ -8513,6 +8798,21 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, UCH
64983                          VCLKIndex = LVDSXlatVCLK2[VCLKIndex];                  
64984                 else    VCLKIndex = LVDSXlatVCLK3[VCLKIndex];
64985  
64986 +               if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
64987 +                  /* Special Timing: Barco iQ Pro R300/400/... */
64988 +                  VCLKIndex = 0x44;
64989 +               }
64990 +
64991 +               if(SiS_Pr->SiS_CustomT == CUT_PANEL848) {
64992 +                  if(HwDeviceExtension->jChipType < SIS_315H) {
64993 +                     VCLKIndex = VCLK34_300;
64994 +                     /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */
64995 +                  } else {
64996 +                     VCLKIndex = VCLK34_315;
64997 +                     /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */
64998 +                  }
64999 +               }
65000 +
65001            } else {
65002  
65003                 VCLKIndex = (UCHAR)SiS_GetReg2((USHORT)(SiS_Pr->SiS_P3ca+0x02));
65004 @@ -8556,11 +8856,11 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, UCH
65005  #ifdef TWDEBUG
65006    xf86DrvMsg(0, X_INFO, "VCLKIndex %d (0x%x)\n", VCLKIndex, VCLKIndex);
65007  #endif
65008 -  return (VCLKIndex);
65009 +  return(VCLKIndex);
65010  }
65011  
65012 -/* TW: Set 301 Palette address port registers */
65013 -/* TW: Checked against 650/301LV BIOS */
65014 +/* Set 301 Palette address port registers */
65015 +/* Checked against 650/301LV BIOS */
65016  void
65017  SiS_SetGroup5(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr,
65018                UCHAR *ROMAddr, USHORT ModeNo, USHORT ModeIdIndex)
65019 @@ -8568,7 +8868,7 @@ SiS_SetGroup5(SiS_Private *SiS_Pr, PSIS_
65020  
65021    if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)  return;
65022  
65023 -  if(SiS_Pr->SiS_ModeType == ModeVGA){
65024 +  if(SiS_Pr->SiS_ModeType == ModeVGA) {
65025       if(!(SiS_Pr->SiS_VBInfo & (SetInSlaveMode | LoadDACFlag))){
65026          SiS_EnableCRT2(SiS_Pr);
65027          SiS_LoadDAC(SiS_Pr,HwDeviceExtension,ROMAddr,ModeNo,ModeIdIndex);
65028 @@ -8581,17 +8881,22 @@ SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, UCH
65029                  USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension)
65030  {
65031    USHORT temp,tempah,i,modeflag,j;
65032 -  USHORT ResInfo,DisplayType;
65033 +  USHORT ResIndex,DisplayType;
65034    const SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr=NULL;
65035  
65036    if(ModeNo <= 0x13) {
65037 -       modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
65038 +     modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
65039    } else {
65040 -       modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
65041 +     modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
65042    }
65043  
65044 +  if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) ||
65045 +     (SiS_Pr->SiS_CustomT == CUT_BARCO1024) ||
65046 +     (SiS_Pr->SiS_CustomT == CUT_PANEL848))
65047 +     return;
65048 +
65049    temp = SiS_GetLVDSCRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
65050 -                            &ResInfo,&DisplayType);
65051 +                            &ResIndex,&DisplayType);
65052  
65053    if(temp == 0) return;
65054  
65055 @@ -8639,47 +8944,53 @@ SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, UCH
65056      case 41: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_1_H;        break;
65057      case 42: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_2;          break;
65058      case 43: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_2_H;        break;
65059 +    case 50: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1;           break;
65060 +    case 51: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1_H;         break;
65061 +    case 52: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_2;           break;
65062 +    case 53: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_2_H;         break;
65063 +    case 54: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_3;           break;
65064 +    case 55: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_3_H;         break;
65065      case 99: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1SOPAL;               break;
65066      default: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1;          break;
65067    }
65068  
65069    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f);                        /*unlock cr0-7  */
65070  
65071 -  tempah = (LVDSCRT1Ptr+ResInfo)->CR[0];
65072 +  tempah = (LVDSCRT1Ptr + ResIndex)->CR[0];
65073    SiS_SetReg1(SiS_Pr->SiS_P3d4,0x00,tempah);
65074  
65075    for(i=0x02,j=1;i<=0x05;i++,j++){
65076 -    tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
65077 +    tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
65078      SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
65079    }
65080    for(i=0x06,j=5;i<=0x07;i++,j++){
65081 -    tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
65082 +    tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
65083      SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
65084    }
65085    for(i=0x10,j=7;i<=0x11;i++,j++){
65086 -    tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
65087 +    tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
65088      SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
65089    }
65090    for(i=0x15,j=9;i<=0x16;i++,j++){
65091 -    tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
65092 +    tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
65093      SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
65094    }
65095    for(i=0x0A,j=11;i<=0x0C;i++,j++){
65096 -    tempah = (LVDSCRT1Ptr+ResInfo)->CR[j];
65097 +    tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
65098      SiS_SetReg1(SiS_Pr->SiS_P3c4,i,tempah);
65099    }
65100  
65101 -  tempah = (LVDSCRT1Ptr+ResInfo)->CR[14];
65102 +  tempah = (LVDSCRT1Ptr + ResIndex)->CR[14];
65103    tempah &= 0xE0;
65104 -  SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah);     
65105 +  SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah);
65106  
65107 -  tempah = (LVDSCRT1Ptr+ResInfo)->CR[14];
65108 +  tempah = (LVDSCRT1Ptr + ResIndex)->CR[14];
65109    tempah &= 0x01;
65110    tempah <<= 5;
65111    if(modeflag & DoubleScanMode)  tempah |= 0x080;
65112    SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah);
65113  
65114 -  /* TW: 650/LVDS BIOS - doesn't make sense */
65115 +  /* 650/LVDS BIOS - doesn't make sense */
65116    if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
65117       if(modeflag & HalfDCLK)
65118          SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f);
65119 @@ -8688,7 +8999,7 @@ SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, UCH
65120  
65121  BOOLEAN
65122  SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
65123 -                  USHORT RefreshRateTableIndex,USHORT *ResInfo,
65124 +                  USHORT RefreshRateTableIndex,USHORT *ResIndex,
65125                    USHORT *DisplayType)
65126   {
65127    USHORT tempbx,modeflag=0;
65128 @@ -8757,19 +9068,33 @@ SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, 
65129             tempbx = 40;
65130            if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 2;
65131            if(modeflag & HalfDCLK) tempbx++;
65132 +        } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_3) {
65133 +           tempbx = 54;
65134 +          if(modeflag & HalfDCLK) tempbx++;
65135 +       } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480_2) {
65136 +           tempbx = 52;
65137 +          if(modeflag & HalfDCLK) tempbx++;
65138 +       } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) {
65139 +           tempbx = 50;
65140 +          if(modeflag & HalfDCLK) tempbx++;
65141          }
65142 +
65143       }
65144       if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
65145          tempbx = 12;
65146         if(modeflag & HalfDCLK) tempbx++;
65147       }
65148    }
65149 -  if(SiS_Pr->SiS_IF_DEF_FSTN){
65150 +
65151 +#if 0
65152 +  if(SiS_Pr->SiS_IF_DEF_FSTN) {
65153       if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480){
65154          tempbx = 22;
65155       }
65156    }
65157 -  *ResInfo = CRT2CRTC & 0x3F;
65158 +#endif
65159 +
65160 +  *ResIndex = CRT2CRTC & 0x3F;
65161    *DisplayType = tempbx;
65162    return 1;
65163  }
65164 @@ -8778,54 +9103,54 @@ void
65165  SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex,
65166             USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension)
65167  {
65168 -  USHORT tempah,tempal,pushax;
65169 -  USHORT vclkindex=0;
65170 -    
65171 +  USHORT clkbase, vclkindex=0;
65172 +  UCHAR  sr2b, sr2c;
65173 +
65174    if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel640x480) || (SiS_Pr->SiS_IF_DEF_TRUMPION == 1)) {
65175         SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2);
65176 -        tempal = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
65177 -       tempal &= 0x3F;
65178 -       if(tempal == 2) RefreshRateTableIndex--;
65179 +        if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK & 0x3f) == 2) {
65180 +          RefreshRateTableIndex--;
65181 +       }
65182         vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
65183 -                               RefreshRateTableIndex,HwDeviceExtension);
65184 +                                    RefreshRateTableIndex,HwDeviceExtension);
65185         SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
65186    } else {
65187          vclkindex = SiS_GetVCLK2Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
65188 -                               RefreshRateTableIndex,HwDeviceExtension);
65189 +                                    RefreshRateTableIndex,HwDeviceExtension);
65190    }
65191 -  
65192 -  tempal = 0x02B;
65193 +
65194 +  sr2b = SiS_Pr->SiS_VCLKData[vclkindex].SR2B;
65195 +  sr2c = SiS_Pr->SiS_VCLKData[vclkindex].SR2C;
65196 +
65197 +  if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) {
65198 +     if((ROMAddr) && SiS_Pr->SiS_UseROM) {
65199 +       if(ROMAddr[0x220] & 0x01) {
65200 +           sr2b = ROMAddr[0x227];
65201 +          sr2c = ROMAddr[0x228];
65202 +       }
65203 +     }
65204 +  }
65205 +
65206 +  clkbase = 0x02B;
65207    if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
65208       if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
65209 -       tempal += 3;
65210 +       clkbase += 3;
65211       }
65212    }
65213 +
65214    SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86);
65215 -  pushax = tempal;
65216    SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x20);
65217 -  tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2B;
65218 -  SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah);
65219 -  tempal++;
65220 -  tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2C;
65221 -  SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah);
65222 +  SiS_SetReg1(SiS_Pr->SiS_P3c4,clkbase,sr2b);
65223 +  SiS_SetReg1(SiS_Pr->SiS_P3c4,clkbase+1,sr2c);
65224    SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x10);
65225 -  tempal = pushax;
65226 -  tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2B;
65227 -  SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah);
65228 -  tempal++;
65229 -  tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2C;
65230 -  SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah);
65231 +  SiS_SetReg1(SiS_Pr->SiS_P3c4,clkbase,sr2b);
65232 +  SiS_SetReg1(SiS_Pr->SiS_P3c4,clkbase+1,sr2c);
65233    SiS_SetReg1(SiS_Pr->SiS_P3c4,0x31,0x00);
65234 -  tempal = pushax;
65235 -  tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2B;
65236 -  SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah);
65237 -  tempal++;
65238 -  tempah = SiS_Pr->SiS_VCLKData[vclkindex].SR2C;
65239 -  SiS_SetReg1(SiS_Pr->SiS_P3c4,tempal,tempah);
65240 -  return;
65241 +  SiS_SetReg1(SiS_Pr->SiS_P3c4,clkbase,sr2b);
65242 +  SiS_SetReg1(SiS_Pr->SiS_P3c4,clkbase+1,sr2c);
65243  }
65244  
65245 -#if 0  /* TW: Not used */
65246 +#if 0  /* Not used */
65247  void
65248  SiS_SetDefCRT2ExtRegs(SiS_Private *SiS_Pr, USHORT BaseAddr)
65249  {
65250 @@ -8844,7 +9169,7 @@ SiS_SetDefCRT2ExtRegs(SiS_Private *SiS_P
65251  }
65252  #endif
65253  
65254 -/* TW: Start of Chrontel 70xx functions ---------------------- */
65255 +/* Start of Chrontel 70xx functions ---------------------- */
65256  
65257  /* Set-up the Chrontel Registers */
65258  void
65259 @@ -8890,44 +9215,44 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHA
65260    if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
65261  
65262  #ifdef SIS300
65263 -  
65264 -     /* Chrontel 7005 - I assume that it does not come with a 310/325 series chip */
65265  
65266 -     /* TW: We don't support modes >800x600 */
65267 +     /* Chrontel 7005 - I assume that it does not come with a 315 series chip */
65268 +
65269 +     /* We don't support modes >800x600 */
65270       if (resindex > 5) return;
65271  
65272       if(SiS_Pr->SiS_VBInfo & SetPALTV) {
65273 -       SiS_SetCH700x(SiS_Pr,0x4304);   /* TW: 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/
65274 -       SiS_SetCH700x(SiS_Pr,0x6909);   /* TW: Black level for PAL (105)*/
65275 +       SiS_SetCH700x(SiS_Pr,0x4304);   /* 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/
65276 +       SiS_SetCH700x(SiS_Pr,0x6909);   /* Black level for PAL (105)*/
65277       } else {
65278 -       SiS_SetCH700x(SiS_Pr,0x0304);   /* TW: upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/
65279 -       SiS_SetCH700x(SiS_Pr,0x7109);   /* TW: Black level for NTSC (113)*/
65280 +       SiS_SetCH700x(SiS_Pr,0x0304);   /* upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/
65281 +       SiS_SetCH700x(SiS_Pr,0x7109);   /* Black level for NTSC (113)*/
65282       }
65283  
65284       temp = CHTVRegData[resindex].Reg[0];
65285 -     tempbx=((temp&0x00FF)<<8)|0x00;   /* TW: Mode register */
65286 +     tempbx=((temp&0x00FF)<<8)|0x00;   /* Mode register */
65287       SiS_SetCH700x(SiS_Pr,tempbx);
65288       temp = CHTVRegData[resindex].Reg[1];
65289 -     tempbx=((temp&0x00FF)<<8)|0x07;   /* TW: Start active video register */
65290 +     tempbx=((temp&0x00FF)<<8)|0x07;   /* Start active video register */
65291       SiS_SetCH700x(SiS_Pr,tempbx);
65292       temp = CHTVRegData[resindex].Reg[2];
65293 -     tempbx=((temp&0x00FF)<<8)|0x08;   /* TW: Position overflow register */
65294 +     tempbx=((temp&0x00FF)<<8)|0x08;   /* Position overflow register */
65295       SiS_SetCH700x(SiS_Pr,tempbx);
65296       temp = CHTVRegData[resindex].Reg[3];
65297 -     tempbx=((temp&0x00FF)<<8)|0x0A;   /* TW: Horiz Position register */
65298 +     tempbx=((temp&0x00FF)<<8)|0x0A;   /* Horiz Position register */
65299       SiS_SetCH700x(SiS_Pr,tempbx);
65300       temp = CHTVRegData[resindex].Reg[4];
65301 -     tempbx=((temp&0x00FF)<<8)|0x0B;   /* TW: Vertical Position register */
65302 +     tempbx=((temp&0x00FF)<<8)|0x0B;   /* Vertical Position register */
65303       SiS_SetCH700x(SiS_Pr,tempbx);
65304  
65305 -     /* TW: Set minimum flicker filter for Luma channel (SR1-0=00),
65306 +     /* Set minimum flicker filter for Luma channel (SR1-0=00),
65307                  minimum text enhancement (S3-2=10),
65308                 maximum flicker filter for Chroma channel (S5-4=10)
65309                 =00101000=0x28 (When reading, S1-0->S3-2, and S3-2->S1-0!)
65310        */
65311       SiS_SetCH700x(SiS_Pr,0x2801);
65312  
65313 -     /* TW: Set video bandwidth
65314 +     /* Set video bandwidth
65315              High bandwith Luma composite video filter(S0=1)
65316              low bandwith Luma S-video filter (S2-1=00)
65317             disable peak filter in S-video channel (S3=0)
65318 @@ -8936,22 +9261,24 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHA
65319       */
65320       SiS_SetCH700x(SiS_Pr,0xb103);       /* old: 3103 */
65321  
65322 -     /* TW: Register 0x3D does not exist in non-macrovision register map
65323 +     /* Register 0x3D does not exist in non-macrovision register map
65324              (Maybe this is a macrovision register?)
65325        */
65326 -     /* SiS_SetCH70xx(SiS_Pr,0x003D); */
65327 +#ifndef SIS_CP
65328 +     SiS_SetCH70xx(SiS_Pr,0x003D);
65329 +#endif
65330  
65331 -     /* TW: Register 0x10 only contains 1 writable bit (S0) for sensing,
65332 +     /* Register 0x10 only contains 1 writable bit (S0) for sensing,
65333              all other bits a read-only. Macrovision?
65334        */
65335       SiS_SetCH70xxANDOR(SiS_Pr,0x0010,0x1F);
65336  
65337 -     /* TW: Register 0x11 only contains 3 writable bits (S0-S2) for
65338 +     /* Register 0x11 only contains 3 writable bits (S0-S2) for
65339              contrast enhancement (set to 010 -> gain 1 Yout = 17/16*(Yin-30) )
65340        */
65341       SiS_SetCH70xxANDOR(SiS_Pr,0x0211,0xF8);
65342  
65343 -     /* TW: Clear DSEN
65344 +     /* Clear DSEN
65345        */
65346       SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xEF);
65347  
65348 @@ -8994,7 +9321,7 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHA
65349           }
65350         }
65351       } else {                          /* ---- PAL ---- */
65352 -           /* TW: We don't play around with FSCI in PAL mode */
65353 +           /* We don't play around with FSCI in PAL mode */
65354           if (resindex == 0x04) {
65355             SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF);     /* loop filter off */
65356             SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE);      /* ACIV on */
65357 @@ -9012,7 +9339,7 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHA
65358  
65359  #ifdef SIS315H
65360  
65361 -     /* TW: We don't support modes >1024x768 */
65362 +     /* We don't support modes >1024x768 */
65363       if (resindex > 6) return;
65364  
65365       temp = CHTVRegData[resindex].Reg[0];
65366 @@ -9082,26 +9409,29 @@ SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHA
65367  #endif /* 315 */
65368  
65369    }
65370 +
65371 +#ifdef SIS_CP
65372 +  SIS_CP_INIT301_CP3
65373 +#endif
65374 +
65375  }
65376  
65377 -/* TW: Chrontel 701x functions ================================= */
65378 +/* Chrontel 701x functions ================================= */
65379  
65380  void
65381 -SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr)
65382 +SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
65383  {
65384 -#ifndef NEWCH701x
65385    USHORT temp;
65386 -#endif  
65387  
65388 -  /* TW: Enable Chrontel 7019 LCD panel backlight */
65389 +  /* Enable Chrontel 7019 LCD panel backlight */
65390    if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
65391 -#ifdef NEWCH701x
65392 +     if(HwDeviceExtension->jChipType == SIS_740) {
65393          SiS_SetCH701x(SiS_Pr,0x6566);
65394 -#else  
65395 +     } else {
65396          temp = SiS_GetCH701x(SiS_Pr,0x66);
65397          temp |= 0x20;
65398         SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66);
65399 -#endif 
65400 +     }
65401    }
65402  }
65403  
65404 @@ -9110,7 +9440,7 @@ SiS_Chrontel701xBLOff(SiS_Private *SiS_P
65405  {
65406    USHORT temp;
65407  
65408 -  /* TW: Disable Chrontel 7019 LCD panel backlight */
65409 +  /* Disable Chrontel 7019 LCD panel backlight */
65410    if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
65411          temp = SiS_GetCH701x(SiS_Pr,0x66);
65412          temp &= 0xDF;
65413 @@ -9118,47 +9448,54 @@ SiS_Chrontel701xBLOff(SiS_Private *SiS_P
65414    }
65415  }
65416  
65417 -#ifdef SIS315H  /* -------- 310/325 series only --------- */
65418 +#ifdef SIS315H  /* ----------- 315 series only ---------- */
65419  
65420  void
65421  SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr)
65422  {
65423 -#ifdef NEWCH701x  
65424 -  UCHAR regtable[]  = { 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71,
65425 -                        0x72, 0x73, 0x74, 0x76, 0x78, 0x7d, 0x66 };
65426 -  UCHAR table1024[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed,
65427 -                        0xa3, 0xc8, 0xc7, 0xac, 0xe0, 0x02, 0x44 }; 
65428 -  UCHAR table1280[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,
65429 -                       0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 };                     
65430 -  UCHAR table1400[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,         
65431 -                        0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 }; 
65432 -  UCHAR table1600[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3,
65433 -                       0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a, 0x44 };
65434 -#else
65435 -  UCHAR regtable[]  = { 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71,
65436 -                        0x72, 0x73, 0x74, 0x76, 0x78, 0x7d };
65437 -  UCHAR table1024[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed,
65438 -                        0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02 }; 
65439 -  UCHAR table1280[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,
65440 -                       0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02 };                   
65441 -  UCHAR table1400[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xef,   
65442 -                        0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02 }; 
65443 -  UCHAR table1600[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3,
65444 -                       0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a };
65445 -#endif                 
65446 +  UCHAR regtable[]      = { 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71,
65447 +                            0x72, 0x73, 0x74, 0x76, 0x78, 0x7d, 0x66 };
65448 +  UCHAR table1024_740[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed,
65449 +                            0xa3, 0xc8, 0xc7, 0xac, 0xe0, 0x02, 0x44 };
65450 +  UCHAR table1280_740[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,
65451 +                           0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 };
65452 +  UCHAR table1400_740[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,
65453 +                            0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 };
65454 +  UCHAR table1600_740[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3,
65455 +                           0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a, 0x44 };
65456 +  UCHAR table1024_650[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed,
65457 +                            0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02 };
65458 +  UCHAR table1280_650[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,
65459 +                           0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02 };
65460 +  UCHAR table1400_650[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xef,
65461 +                            0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02 };
65462 +  UCHAR table1600_650[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3,
65463 +                           0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a };
65464    UCHAR *tableptr = NULL;
65465    USHORT tempbh;
65466    int i;
65467  
65468 -  if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
65469 -     tableptr = table1024;
65470 -  } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
65471 -     tableptr = table1280;
65472 -  } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
65473 -     tableptr = table1400;
65474 -  } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) {
65475 -     tableptr = table1600;
65476 -  } else return;
65477 +  if(HwDeviceExtension->jChipType == SIS_740) {
65478 +     if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
65479 +        tableptr = table1024_740;
65480 +     } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
65481 +        tableptr = table1280_740;
65482 +     } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
65483 +        tableptr = table1400_740;
65484 +     } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) {
65485 +        tableptr = table1600_740;
65486 +     } else return;
65487 +  } else {
65488 +     if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
65489 +        tableptr = table1024_650;
65490 +     } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
65491 +        tableptr = table1280_650;
65492 +     } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
65493 +        tableptr = table1400_650;
65494 +     } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) {
65495 +        tableptr = table1600_650;
65496 +     } else return;
65497 +  }
65498  
65499    tempbh = SiS_GetCH701x(SiS_Pr,0x74);
65500    if((tempbh == 0xf6) || (tempbh == 0xc7)) {
65501 @@ -9172,54 +9509,64 @@ SiS_SetCH701xForLCD(SiS_Private *SiS_Pr,
65502          if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) return;
65503       }
65504    }
65505 -#ifdef NEWCH701x     /* New from 740/LVDS: */    
65506 -  for(i=0; i<0x0d; i++) {      
65507 -#else
65508 -  for(i=0; i<0x0c; i++) {
65509 -#endif  
65510 +
65511 +  if(HwDeviceExtension->jChipType == SIS_740) {
65512 +     tempbh = 0x0d;
65513 +  } else {
65514 +     tempbh = 0x0c;
65515 +  }
65516 +  for(i = 0; i < tempbh; i++) {
65517       SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]);
65518    }
65519 -  SiS_ChrontelPowerSequencing(SiS_Pr);
65520 +  SiS_ChrontelPowerSequencing(SiS_Pr,HwDeviceExtension);
65521    tempbh = SiS_GetCH701x(SiS_Pr,0x1e);
65522    tempbh |= 0xc0;
65523    SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1e);
65524 -  
65525 -#ifdef NEWCH701x     /* 740/LVDS: */
65526 -  tempbh = SiS_GetCH701x(SiS_Pr,0x1c);
65527 -  tempbh &= 0xfb;
65528 -  SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1c);
65529 -  SiS_SetReg1(SiS_Pr->SiS_Part1Port, 0x2d, 0x03);
65530 -  tempbh = SiS_GetCH701x(SiS_Pr,0x64);
65531 -  tempbh |= 0x40;
65532 -  SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x64);
65533 -  tempbh = SiS_GetCH701x(SiS_Pr,0x03);
65534 -  tempbh &= 0x3f;
65535 -  SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x03);
65536 -#endif  /* End 740/LVDS */
65537 +
65538 +  if(HwDeviceExtension->jChipType == SIS_740) {
65539 +     tempbh = SiS_GetCH701x(SiS_Pr,0x1c);
65540 +     tempbh &= 0xfb;
65541 +     SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1c);
65542 +     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2d,0x03);
65543 +     tempbh = SiS_GetCH701x(SiS_Pr,0x64);
65544 +     tempbh |= 0x40;
65545 +     SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x64);
65546 +     tempbh = SiS_GetCH701x(SiS_Pr,0x03);
65547 +     tempbh &= 0x3f;
65548 +     SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x03);
65549 +  }
65550  }
65551  
65552  void
65553 -SiS_ChrontelPowerSequencing(SiS_Private *SiS_Pr)
65554 -{
65555 -  UCHAR regtable[]  = { 0x67, 0x68, 0x69, 0x6a, 0x6b };
65556 -#ifdef NEWCH701x  
65557 -  UCHAR table1024[] = { 0x01, 0x02, 0x01, 0x01, 0x01 };
65558 -  UCHAR table1400[] = { 0x01, 0x6e, 0x01, 0x01, 0x01 };
65559 -#else
65560 -  UCHAR table1024[] = { 0x01, 0x02, 0x01, 0x01, 0x02 };
65561 -  UCHAR table1400[] = { 0x01, 0x02, 0x01, 0x01, 0x02 };
65562 -#endif  
65563 +SiS_ChrontelPowerSequencing(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
65564 +{
65565 +  UCHAR regtable[]      = { 0x67, 0x68, 0x69, 0x6a, 0x6b };
65566 +  UCHAR table1024_740[] = { 0x01, 0x02, 0x01, 0x01, 0x01 };
65567 +  UCHAR table1400_740[] = { 0x01, 0x6e, 0x01, 0x01, 0x01 };
65568 +  UCHAR table1024_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 };
65569 +  UCHAR table1400_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 };
65570    UCHAR *tableptr = NULL;
65571    int i;
65572  
65573    /* Set up Power up/down timing */
65574 -  if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
65575 -     tableptr = table1024;
65576 -  } else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) ||
65577 -            (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) ||
65578 -           (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) {
65579 -     tableptr = table1400;
65580 -  } else return;
65581 +
65582 +  if(HwDeviceExtension->jChipType == SIS_740) {
65583 +     if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
65584 +        tableptr = table1024_740;
65585 +     } else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) ||
65586 +               (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) ||
65587 +              (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) {
65588 +        tableptr = table1400_740;
65589 +     } else return;
65590 +  } else {
65591 +     if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
65592 +        tableptr = table1024_650;
65593 +     } else if((SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) ||
65594 +               (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) ||
65595 +              (SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200)) {
65596 +        tableptr = table1400_650;
65597 +     } else return;
65598 +  }
65599    
65600    for(i=0; i<5; i++) {
65601       SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]);
65602 @@ -9232,66 +9579,72 @@ SiS_Chrontel701xOn(SiS_Private *SiS_Pr, 
65603    USHORT temp;
65604  
65605    if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
65606 -#ifdef NEWCH701x
65607 -     temp = SiS_GetCH701x(SiS_Pr,0x1c);
65608 -     temp |= 0x04;
65609 -     SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c);
65610 -#endif 
65611 +     if(HwDeviceExtension->jChipType == SIS_740) {
65612 +        temp = SiS_GetCH701x(SiS_Pr,0x1c);
65613 +        temp |= 0x04;
65614 +        SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c);
65615 +     }
65616       if(SiS_IsYPbPr(SiS_Pr,HwDeviceExtension, BaseAddr)) {
65617          temp = SiS_GetCH701x(SiS_Pr,0x01);
65618         temp &= 0x3f;
65619 -       temp |= 0x80;   /* TW: Enable YPrPb (HDTV) */
65620 +       temp |= 0x80;   /* Enable YPrPb (HDTV) */
65621         SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01);
65622       }
65623       if(SiS_IsChScart(SiS_Pr,HwDeviceExtension, BaseAddr)) {
65624          temp = SiS_GetCH701x(SiS_Pr,0x01);
65625         temp &= 0x3f;
65626 -       temp |= 0xc0;   /* TW: Enable SCART + CVBS */
65627 +       temp |= 0xc0;   /* Enable SCART + CVBS */
65628         SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01);
65629       }
65630 -#ifdef NEWCH701x
65631 -     SiS_ChrontelDoSomething5(SiS_Pr);
65632 -     SiS_SetCH701x(SiS_Pr,0x2049);                     /* TW: Enable TV path */
65633 -#else      
65634 -     SiS_SetCH701x(SiS_Pr,0x2049);                     /* TW: Enable TV path */
65635 -     temp = SiS_GetCH701x(SiS_Pr,0x49);
65636 -     if(SiS_IsYPbPr(SiS_Pr,HwDeviceExtension, BaseAddr)) {
65637 -        temp = SiS_GetCH701x(SiS_Pr,0x73);
65638 -       temp |= 0x60;
65639 -       SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x73);
65640 +     if(HwDeviceExtension->jChipType == SIS_740) {
65641 +        SiS_ChrontelDoSomething5(SiS_Pr);
65642 +        SiS_SetCH701x(SiS_Pr,0x2049);                          /* Enable TV path */
65643 +     } else {
65644 +        SiS_SetCH701x(SiS_Pr,0x2049);                          /* Enable TV path */
65645 +        temp = SiS_GetCH701x(SiS_Pr,0x49);
65646 +        if(SiS_IsYPbPr(SiS_Pr,HwDeviceExtension, BaseAddr)) {
65647 +           temp = SiS_GetCH701x(SiS_Pr,0x73);
65648 +          temp |= 0x60;
65649 +          SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x73);
65650 +        }
65651 +        temp = SiS_GetCH701x(SiS_Pr,0x47);
65652 +        temp &= 0x7f;
65653 +        SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);
65654 +        SiS_LongDelay(SiS_Pr,2);
65655 +        temp = SiS_GetCH701x(SiS_Pr,0x47);
65656 +        temp |= 0x80;
65657 +        SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);
65658       }
65659 -     temp = SiS_GetCH701x(SiS_Pr,0x47);
65660 -     temp &= 0x7f;
65661 -     SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);
65662 -     SiS_LongDelay(SiS_Pr,2);
65663 -     temp = SiS_GetCH701x(SiS_Pr,0x47);
65664 -     temp |= 0x80;
65665 -     SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);
65666 -#endif     
65667    }
65668  }
65669  
65670  void
65671 -SiS_Chrontel701xOff(SiS_Private *SiS_Pr)
65672 +SiS_Chrontel701xOff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
65673  {
65674    USHORT temp;
65675  
65676 +  /* Complete power down of LVDS */
65677    if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
65678 +     if(HwDeviceExtension->jChipType == SIS_740) {
65679 +        SiS_LongDelay(SiS_Pr,1);
65680 +       SiS_GenericDelay(SiS_Pr,0x16ff);
65681 +       SiS_SetCH701x(SiS_Pr,0xac76);
65682 +       SiS_SetCH701x(SiS_Pr,0x0066);
65683 +     } else {
65684          SiS_LongDelay(SiS_Pr,2);
65685 -       /* TW: Complete power down of LVDS */
65686         temp = SiS_GetCH701x(SiS_Pr,0x76);
65687         temp &= 0xfc;
65688         SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76);
65689         SiS_SetCH701x(SiS_Pr,0x0066);
65690 +     }
65691    }
65692  }
65693  
65694 -#ifdef NEWCH701x
65695  void
65696  SiS_ChrontelDoSomething5(SiS_Private *SiS_Pr)
65697  {
65698       unsigned char temp, temp1;
65699 -     
65700 +
65701       temp1 = SiS_GetCH701x(SiS_Pr,0x49);
65702       SiS_SetCH701x(SiS_Pr,0x3e49);
65703       temp = SiS_GetCH701x(SiS_Pr,0x47);
65704 @@ -9303,130 +9656,134 @@ SiS_ChrontelDoSomething5(SiS_Private *Si
65705       SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);
65706       SiS_SetCH701x(SiS_Pr,(temp1 << 8) | 0x49);
65707  }
65708 -#endif
65709  
65710  void
65711  SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
65712  {
65713 -#ifdef NEWCH701x
65714       USHORT temp;
65715 -     
65716 -     /* 740/LVDS: */
65717 -     temp = SiS_GetCH701x(SiS_Pr,0x4a);
65718 -     temp &= 0x01;
65719 -     if(!(temp)) {
65720 -     
65721 -        if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) {
65722 -          temp = SiS_GetCH701x(SiS_Pr,0x49);
65723 -          SiS_SetCH701x(SiS_Pr,0x3e49);
65724 -       }
65725 -       /* TW: Reset Chrontel 7019 datapath */
65726 +
65727 +     if(HwDeviceExtension->jChipType == SIS_740) {
65728 +        temp = SiS_GetCH701x(SiS_Pr,0x4a);
65729 +        temp &= 0x01;
65730 +        if(!(temp)) {
65731 +
65732 +           if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) {
65733 +             temp = SiS_GetCH701x(SiS_Pr,0x49);
65734 +             SiS_SetCH701x(SiS_Pr,0x3e49);
65735 +          }
65736 +          /* Reset Chrontel 7019 datapath */
65737 +           SiS_SetCH701x(SiS_Pr,0x1048);
65738 +           SiS_LongDelay(SiS_Pr,1);
65739 +           SiS_SetCH701x(SiS_Pr,0x1848);
65740 +
65741 +          if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) {
65742 +             SiS_ChrontelDoSomething5(SiS_Pr);
65743 +             SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x49);
65744 +          }
65745 +
65746 +        } else {
65747 +
65748 +           temp = SiS_GetCH701x(SiS_Pr,0x5c);
65749 +          temp &= 0xef;
65750 +          SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c);
65751 +          temp = SiS_GetCH701x(SiS_Pr,0x5c);
65752 +          temp |= 0x10;
65753 +          SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c);
65754 +          temp = SiS_GetCH701x(SiS_Pr,0x5c);
65755 +          temp &= 0xef;
65756 +          SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c);
65757 +          temp = SiS_GetCH701x(SiS_Pr,0x61);
65758 +          if(!temp) {
65759 +             SiS_SetCH701xForLCD(SiS_Pr,HwDeviceExtension,BaseAddr);
65760 +          }
65761 +        }
65762 +     } else { /* 650 */
65763 +        /* Reset Chrontel 7019 datapath */
65764          SiS_SetCH701x(SiS_Pr,0x1048);
65765          SiS_LongDelay(SiS_Pr,1);
65766          SiS_SetCH701x(SiS_Pr,0x1848);
65767 -       
65768 -       if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) {
65769 -          SiS_ChrontelDoSomething5(SiS_Pr);
65770 -          SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x49);
65771 -       }    
65772 -     } else {
65773 -     
65774 -        temp = SiS_GetCH701x(SiS_Pr,0x5c);
65775 -       temp &= 0xef;
65776 -       SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c);
65777 -       temp = SiS_GetCH701x(SiS_Pr,0x5c);
65778 -       temp |= 0x10;
65779 -       SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c);
65780 -       temp = SiS_GetCH701x(SiS_Pr,0x5c);
65781 -       temp &= 0xef;
65782 -       SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c);
65783 -       temp = SiS_GetCH701x(SiS_Pr,0x61);
65784 -       if(!temp) {
65785 -          SiS_SetCH701xForLCD(SiS_Pr,HwDeviceExtension,BaseAddr);
65786 -       }
65787 -     }
65788 -#else /* pre 740/LVDS code */     
65789 -     /* TW: Reset Chrontel 7019 datapath */
65790 -     SiS_SetCH701x(SiS_Pr,0x1048);
65791 -     SiS_LongDelay(SiS_Pr,1);
65792 -     SiS_SetCH701x(SiS_Pr,0x1848);
65793 -#endif     
65794 +     }
65795  }
65796  
65797  void
65798  SiS_ChrontelDoSomething4(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
65799  {
65800 -#ifdef NEWCH701x
65801 -     if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr))) {
65802 -        SiS_ChrontelDoSomething5(SiS_Pr);
65803 -     }
65804 -#else
65805       USHORT temp;
65806  
65807 -     SiS_SetCH701x(SiS_Pr,0xaf76);  /* Power up LVDS block */
65808 -     temp = SiS_GetCH701x(SiS_Pr,0x49);
65809 -     temp &= 1;
65810 -     if(temp != 1) {  /* TV block powered? (0 = yes, 1 = no) */
65811 -       temp = SiS_GetCH701x(SiS_Pr,0x47);
65812 -       temp &= 0x70;
65813 -       SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);  /* enable VSYNC */
65814 -       SiS_LongDelay(SiS_Pr,3);
65815 -       temp = SiS_GetCH701x(SiS_Pr,0x47);
65816 -       temp |= 0x80;
65817 -       SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);  /* disable VSYNC */
65818 +     if(HwDeviceExtension->jChipType == SIS_740) {
65819 +
65820 +        if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) {
65821 +           SiS_ChrontelDoSomething5(SiS_Pr);
65822 +        }
65823 +
65824 +     } else {
65825 +
65826 +        SiS_SetCH701x(SiS_Pr,0xaf76);  /* Power up LVDS block */
65827 +        temp = SiS_GetCH701x(SiS_Pr,0x49);
65828 +        temp &= 1;
65829 +        if(temp != 1) {  /* TV block powered? (0 = yes, 1 = no) */
65830 +          temp = SiS_GetCH701x(SiS_Pr,0x47);
65831 +          temp &= 0x70;
65832 +          SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);  /* enable VSYNC */
65833 +          SiS_LongDelay(SiS_Pr,3);
65834 +          temp = SiS_GetCH701x(SiS_Pr,0x47);
65835 +          temp |= 0x80;
65836 +          SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47);  /* disable VSYNC */
65837 +        }
65838 +
65839       }
65840 -#endif     
65841  }
65842  
65843  void
65844  SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_DEVICE_INFO HwDeviceExtension,
65845                           USHORT BaseAddr)
65846  {
65847 -#ifdef NEWCH701x
65848 -     USHORT temp;
65849 -     
65850 -     temp = SiS_GetCH701x(SiS_Pr,0x61);
65851 -     if(temp < 1) {
65852 -          temp++;
65853 -         SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61);
65854 -     }
65855 -     SiS_SetCH701x(SiS_Pr,0x4566);
65856 -     SiS_SetCH701x(SiS_Pr,0xaf76);
65857 -     SiS_LongDelay(SiS_Pr,1);
65858 -     SiS_GenericDelay(SiS_Pr,0x16ff);
65859 -
65860 -#else
65861       USHORT temp,temp1;
65862 -     
65863 -     temp1 = 0;
65864 -     temp = SiS_GetCH701x(SiS_Pr,0x61);
65865 -     if(temp < 2) {
65866 -          temp++;
65867 -         SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61);
65868 -         temp1 = 1;
65869 -     }
65870 -     SiS_SetCH701x(SiS_Pr,0xac76);
65871 -     temp = SiS_GetCH701x(SiS_Pr,0x66);
65872 -     temp |= 0x5f;
65873 -     SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66);
65874 -     if(ModeNo > 0x13) {
65875 -         if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) {
65876 -           SiS_GenericDelay(SiS_Pr,0x3ff);
65877 -        } else {
65878 -           SiS_GenericDelay(SiS_Pr,0x2ff);
65879 -        }
65880 -     } else {
65881 -         if(!temp1)
65882 -           SiS_GenericDelay(SiS_Pr,0x2ff);
65883 +
65884 +     if(HwDeviceExtension->jChipType == SIS_740) {
65885 +
65886 +        temp = SiS_GetCH701x(SiS_Pr,0x61);
65887 +        if(temp < 1) {
65888 +           temp++;
65889 +          SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61);
65890 +        }
65891 +        SiS_SetCH701x(SiS_Pr,0x4566);
65892 +        SiS_SetCH701x(SiS_Pr,0xaf76);
65893 +        SiS_LongDelay(SiS_Pr,1);
65894 +        SiS_GenericDelay(SiS_Pr,0x16ff);
65895 +
65896 +     } else {  /* 650 */
65897 +
65898 +        temp1 = 0;
65899 +        temp = SiS_GetCH701x(SiS_Pr,0x61);
65900 +        if(temp < 2) {
65901 +           temp++;
65902 +          SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61);
65903 +          temp1 = 1;
65904 +        }
65905 +        SiS_SetCH701x(SiS_Pr,0xac76);
65906 +        temp = SiS_GetCH701x(SiS_Pr,0x66);
65907 +        temp |= 0x5f;
65908 +        SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66);
65909 +        if(ModeNo > 0x13) {
65910 +           if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwDeviceExtension, BaseAddr)) {
65911 +             SiS_GenericDelay(SiS_Pr,0x3ff);
65912 +          } else {
65913 +             SiS_GenericDelay(SiS_Pr,0x2ff);
65914 +          }
65915 +        } else {
65916 +           if(!temp1)
65917 +             SiS_GenericDelay(SiS_Pr,0x2ff);
65918 +        }
65919 +        temp = SiS_GetCH701x(SiS_Pr,0x76);
65920 +        temp |= 0x03;
65921 +        SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76);
65922 +        temp = SiS_GetCH701x(SiS_Pr,0x66);
65923 +        temp &= 0x7f;
65924 +        SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66);
65925 +        SiS_LongDelay(SiS_Pr,1);
65926 +
65927       }
65928 -     temp = SiS_GetCH701x(SiS_Pr,0x76);
65929 -     temp |= 0x03;
65930 -     SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76);
65931 -     temp = SiS_GetCH701x(SiS_Pr,0x66);
65932 -     temp &= 0x7f;
65933 -     SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66);
65934 -     SiS_LongDelay(SiS_Pr,1);
65935 -#endif     
65936  }
65937  
65938  void
65939 @@ -9443,9 +9800,9 @@ SiS_ChrontelDoSomething2(SiS_Private *Si
65940         temp &= 0x04;
65941         if(temp == 0x04) break;
65942         
65943 -#ifdef NEWCH701x
65944 -       SiS_SetCH701x(SiS_Pr,0xac76);    /* 740/LVDS */
65945 -#endif       
65946 +       if(HwDeviceExtension->jChipType == SIS_740) {
65947 +          SiS_SetCH701x(SiS_Pr,0xac76);
65948 +       }
65949  
65950         SiS_SetCH701xForLCD(SiS_Pr,HwDeviceExtension,BaseAddr);
65951  
65952 @@ -9463,11 +9820,11 @@ SiS_ChrontelDoSomething2(SiS_Private *Si
65953         temp = SiS_GetCH701x(SiS_Pr,0x76);
65954         temp |= 0x04;
65955         SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76);
65956 -#ifdef NEWCH701x
65957 -       SiS_SetCH701x(SiS_Pr,0xe078);
65958 -#else       
65959 -       SiS_SetCH701x(SiS_Pr,0x6078);
65960 -#endif       
65961 +       if(HwDeviceExtension->jChipType == SIS_740) {
65962 +          SiS_SetCH701x(SiS_Pr,0xe078);
65963 +       } else {
65964 +          SiS_SetCH701x(SiS_Pr,0x6078);
65965 +       }
65966         SiS_LongDelay(SiS_Pr,2);
65967      } while(0);
65968  
65969 @@ -9485,51 +9842,52 @@ SiS_ChrontelDoSomething1(SiS_Private *Si
65970       temp &= 0xbf;     /* Set datapath 2 to LVDS */
65971       SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03);
65972       
65973 -#ifdef NEWCH701x   /* 740/LVDS: */
65974 +     if(HwDeviceExtension->jChipType == SIS_740) {
65975 +
65976 +        temp = SiS_GetCH701x(SiS_Pr,0x1c);
65977 +        temp &= 0xfb;
65978 +        SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c);
65979 +
65980 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2d,0x03);
65981 +
65982 +        temp = SiS_GetCH701x(SiS_Pr,0x64);
65983 +        temp |= 0x40;
65984 +        SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x64);
65985 +
65986 +        temp = SiS_GetCH701x(SiS_Pr,0x03);
65987 +        temp &= 0x3f;
65988 +        SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03);
65989 +
65990 +        temp = SiS_GetCH701x(SiS_Pr,0x66);
65991 +        if(temp != 0x45) {
65992 +           SiS_ChrontelResetDB(SiS_Pr,HwDeviceExtension,BaseAddr);
65993 +           SiS_ChrontelDoSomething2(SiS_Pr,HwDeviceExtension,BaseAddr);
65994 +          temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x34);
65995 +           SiS_ChrontelDoSomething3(SiS_Pr,temp,HwDeviceExtension,BaseAddr);
65996 +        }
65997 +
65998 +     } else { /* 650 */
65999  
66000 -     temp = SiS_GetCH701x(SiS_Pr,0x1c);
66001 -     temp &= 0xfb;
66002 -     SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c);
66003 -     
66004 -     SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2d,0x03);
66005 -     
66006 -     temp = SiS_GetCH701x(SiS_Pr,0x64);
66007 -     temp |= 0x40;
66008 -     SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x64);
66009 -     
66010 -     temp = SiS_GetCH701x(SiS_Pr,0x03);
66011 -     temp &= 0x3f;     
66012 -     SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03);
66013 -     
66014 -     temp = SiS_GetCH701x(SiS_Pr,0x66);
66015 -     if(temp != 0x45) {
66016          SiS_ChrontelResetDB(SiS_Pr,HwDeviceExtension,BaseAddr);
66017 -        SiS_ChrontelDoSomething2(SiS_Pr,HwDeviceExtension,BaseAddr);
66018 -       temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x34);
66019 -        SiS_ChrontelDoSomething3(SiS_Pr,temp,HwDeviceExtension,BaseAddr);
66020 -     }     
66021  
66022 -#else  /* pre-740/LVDS: */     
66023 +        SiS_ChrontelDoSomething2(SiS_Pr,HwDeviceExtension,BaseAddr);
66024  
66025 -     SiS_ChrontelResetDB(SiS_Pr);
66026 +        temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x34);
66027 +        SiS_ChrontelDoSomething3(SiS_Pr,temp,HwDeviceExtension,BaseAddr);
66028  
66029 -     SiS_ChrontelDoSomething2(SiS_Pr,HwDeviceExtension,BaseAddr);
66030 +        SiS_SetCH701x(SiS_Pr,0xaf76);
66031  
66032 -     temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x34);
66033 -     SiS_ChrontelDoSomething3(SiS_Pr,temp,HwDeviceExtension,BaseAddr);
66034 +     }
66035  
66036 -     SiS_SetCH701x(SiS_Pr,0xaf76);
66037 -     
66038 -#endif  /* End of pre-740/LVDS */
66039  }
66040  
66041 -#endif  /* 310/325 series --------------------------------- */
66042 +#endif  /* 315 series ------------------------------------ */
66043  
66044 -/* TW: End of Chrontel 701x functions ==================================== */
66045 +/* End of Chrontel 701x functions ==================================== */
66046  
66047 -/* TW: Generic Read/write routines for Chrontel ========================== */
66048 +/* Generic Read/write routines for Chrontel ========================== */
66049  
66050 -/* TW: The Chrontel is connected to the 630/730 via
66051 +/* The Chrontel is connected to the 630/730 via
66052   * the 630/730's DDC/I2C port.
66053   *
66054   * On 630(S)T chipset, the index changed from 0x11 to 0x0a,
66055 @@ -9539,13 +9897,13 @@ SiS_ChrontelDoSomething1(SiS_Private *Si
66056  void
66057  SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx)
66058  {
66059 -   if (SiS_Pr->SiS_IF_DEF_CH70xx == 1)
66060 +   if(SiS_Pr->SiS_IF_DEF_CH70xx == 1)
66061        SiS_SetCH700x(SiS_Pr,tempbx);
66062     else
66063        SiS_SetCH701x(SiS_Pr,tempbx);
66064  }
66065  
66066 -/* TW: Write to Chrontel 700x */
66067 +/* Write to Chrontel 700x */
66068  /* Parameter is [Data (S15-S8) | Register no (S7-S0)] */
66069  void
66070  SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempbx)
66071 @@ -9553,100 +9911,100 @@ SiS_SetCH700x(SiS_Private *SiS_Pr, USHOR
66072    USHORT tempah,temp,i;
66073  
66074    if(!(SiS_Pr->SiS_ChrontelInit)) {
66075 -     SiS_Pr->SiS_DDC_Index = 0x11;                /* TW: Bit 0 = SC;  Bit 1 = SD */
66076 +     SiS_Pr->SiS_DDC_Index = 0x11;                /* Bit 0 = SC;  Bit 1 = SD */
66077       SiS_Pr->SiS_DDC_Data  = 0x02;                 /* Bitmask in IndexReg for Data */
66078       SiS_Pr->SiS_DDC_Clk   = 0x01;                 /* Bitmask in IndexReg for Clk */
66079       SiS_Pr->SiS_DDC_DataShift = 0x00;
66080 -     SiS_Pr->SiS_DDC_DeviceAddr = 0xEA;           /* TW: DAB (Device Address Byte) */
66081 +     SiS_Pr->SiS_DDC_DeviceAddr = 0xEA;           /* DAB (Device Address Byte) */
66082    }
66083  
66084 -  for(i=0;i<10;i++) {  /* TW: Do only 10 attempts to write */
66085 +  for(i=0;i<10;i++) {  /* Do only 10 attempts to write */
66086      /* SiS_SetSwitchDDC2(SiS_Pr); */
66087 -    if(SiS_SetStart(SiS_Pr)) continue;         /* TW: Set start condition */
66088 +    if(SiS_SetStart(SiS_Pr)) continue;         /* Set start condition */
66089      tempah = SiS_Pr->SiS_DDC_DeviceAddr;
66090 -    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* TW: Write DAB (S0=0=write) */
66091 -    if(temp) continue;                         /* TW:    (ERROR: no ack) */
66092 -    tempah = tempbx & 0x00FF;                  /* TW: Write RAB */
66093 -    tempah |= 0x80;                             /* TW: (set bit 7, see datasheet) */
66094 +    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* Write DAB (S0=0=write) */
66095 +    if(temp) continue;                         /*    (ERROR: no ack) */
66096 +    tempah = tempbx & 0x00FF;                  /* Write RAB */
66097 +    tempah |= 0x80;                             /* (set bit 7, see datasheet) */
66098      temp = SiS_WriteDDC2Data(SiS_Pr,tempah);
66099 -    if(temp) continue;                         /* TW:    (ERROR: no ack) */
66100 +    if(temp) continue;                         /*    (ERROR: no ack) */
66101      tempah = (tempbx & 0xFF00) >> 8;
66102 -    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* TW: Write data */
66103 -    if(temp) continue;                         /* TW:    (ERROR: no ack) */
66104 -    if(SiS_SetStop(SiS_Pr)) continue;          /* TW: Set stop condition */
66105 +    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* Write data */
66106 +    if(temp) continue;                         /*    (ERROR: no ack) */
66107 +    if(SiS_SetStop(SiS_Pr)) continue;          /* Set stop condition */
66108      SiS_Pr->SiS_ChrontelInit = 1;
66109      return;
66110    }
66111  
66112 -  /* TW: For 630ST */
66113 +  /* For 630ST */
66114    if(!(SiS_Pr->SiS_ChrontelInit)) {
66115 -     SiS_Pr->SiS_DDC_Index = 0x0a;             /* TW: Bit 7 = SC;  Bit 6 = SD */
66116 +     SiS_Pr->SiS_DDC_Index = 0x0a;             /* Bit 7 = SC;  Bit 6 = SD */
66117       SiS_Pr->SiS_DDC_Data  = 0x80;              /* Bitmask in IndexReg for Data */
66118       SiS_Pr->SiS_DDC_Clk   = 0x40;              /* Bitmask in IndexReg for Clk */
66119       SiS_Pr->SiS_DDC_DataShift = 0x00;
66120 -     SiS_Pr->SiS_DDC_DeviceAddr = 0xEA;        /* TW: DAB (Device Address Byte) */
66121 +     SiS_Pr->SiS_DDC_DeviceAddr = 0xEA;        /* DAB (Device Address Byte) */
66122  
66123 -     for(i=0;i<10;i++) {       /* TW: Do only 10 attempts to write */
66124 +     for(i=0;i<10;i++) {       /* Do only 10 attempts to write */
66125         /* SiS_SetSwitchDDC2(SiS_Pr); */
66126 -       if (SiS_SetStart(SiS_Pr)) continue;     /* TW: Set start condition */
66127 +       if (SiS_SetStart(SiS_Pr)) continue;     /* Set start condition */
66128         tempah = SiS_Pr->SiS_DDC_DeviceAddr;
66129 -       temp = SiS_WriteDDC2Data(SiS_Pr,tempah);        /* TW: Write DAB (S0=0=write) */
66130 -       if(temp) continue;                      /* TW:    (ERROR: no ack) */
66131 -       tempah = tempbx & 0x00FF;               /* TW: Write RAB */
66132 -       tempah |= 0x80;                          /* TW: (set bit 7, see datasheet) */
66133 +       temp = SiS_WriteDDC2Data(SiS_Pr,tempah);        /* Write DAB (S0=0=write) */
66134 +       if(temp) continue;                      /*    (ERROR: no ack) */
66135 +       tempah = tempbx & 0x00FF;               /* Write RAB */
66136 +       tempah |= 0x80;                          /* (set bit 7, see datasheet) */
66137         temp = SiS_WriteDDC2Data(SiS_Pr,tempah);
66138 -       if(temp) continue;                      /* TW:    (ERROR: no ack) */
66139 +       if(temp) continue;                      /*    (ERROR: no ack) */
66140         tempah = (tempbx & 0xFF00) >> 8;
66141 -       temp = SiS_WriteDDC2Data(SiS_Pr,tempah);        /* TW: Write data */
66142 -       if(temp) continue;                      /* TW:    (ERROR: no ack) */
66143 -       if(SiS_SetStop(SiS_Pr)) continue;       /* TW: Set stop condition */
66144 +       temp = SiS_WriteDDC2Data(SiS_Pr,tempah);        /* Write data */
66145 +       if(temp) continue;                      /*    (ERROR: no ack) */
66146 +       if(SiS_SetStop(SiS_Pr)) continue;       /* Set stop condition */
66147         SiS_Pr->SiS_ChrontelInit = 1;
66148         return;
66149      }
66150    }
66151  }
66152  
66153 -/* TW: Write to Chrontel 701x */
66154 +/* Write to Chrontel 701x */
66155  /* Parameter is [Data (S15-S8) | Register no (S7-S0)] */
66156  void
66157  SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx)
66158  {
66159    USHORT tempah,temp,i;
66160  
66161 -  SiS_Pr->SiS_DDC_Index = 0x11;                        /* TW: Bit 0 = SC;  Bit 1 = SD */
66162 +  SiS_Pr->SiS_DDC_Index = 0x11;                        /* Bit 0 = SC;  Bit 1 = SD */
66163    SiS_Pr->SiS_DDC_Data  = 0x08;                 /* Bitmask in IndexReg for Data */
66164    SiS_Pr->SiS_DDC_Clk   = 0x04;                 /* Bitmask in IndexReg for Clk */
66165    SiS_Pr->SiS_DDC_DataShift = 0x00;
66166 -  SiS_Pr->SiS_DDC_DeviceAddr = 0xEA;           /* TW: DAB (Device Address Byte) */
66167 +  SiS_Pr->SiS_DDC_DeviceAddr = 0xEA;           /* DAB (Device Address Byte) */
66168  
66169 -  for(i=0;i<10;i++) {  /* TW: Do only 10 attempts to write */
66170 -    if (SiS_SetStart(SiS_Pr)) continue;                /* TW: Set start condition */
66171 +  for(i=0;i<10;i++) {  /* Do only 10 attempts to write */
66172 +    if (SiS_SetStart(SiS_Pr)) continue;                /* Set start condition */
66173      tempah = SiS_Pr->SiS_DDC_DeviceAddr;
66174 -    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* TW: Write DAB (S0=0=write) */
66175 -    if(temp) continue;                         /* TW:    (ERROR: no ack) */
66176 +    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* Write DAB (S0=0=write) */
66177 +    if(temp) continue;                         /*    (ERROR: no ack) */
66178      tempah = tempbx & 0x00FF;
66179 -    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* TW: Write RAB */
66180 -    if(temp) continue;                         /* TW:    (ERROR: no ack) */
66181 +    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* Write RAB */
66182 +    if(temp) continue;                         /*    (ERROR: no ack) */
66183      tempah = (tempbx & 0xFF00) >> 8;
66184 -    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* TW: Write data */
66185 -    if(temp) continue;                         /* TW:    (ERROR: no ack) */
66186 -    if(SiS_SetStop(SiS_Pr)) continue;          /* TW: Set stop condition */
66187 +    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* Write data */
66188 +    if(temp) continue;                         /*    (ERROR: no ack) */
66189 +    if(SiS_SetStop(SiS_Pr)) continue;          /* Set stop condition */
66190      return;
66191    }
66192  }
66193  
66194 -/* TW: Read from Chrontel 70xx */
66195 +/* Read from Chrontel 70xx */
66196  /* Parameter is [Register no (S7-S0)] */
66197  USHORT
66198  SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx)
66199  {
66200 -   if (SiS_Pr->SiS_IF_DEF_CH70xx == 1)
66201 +   if(SiS_Pr->SiS_IF_DEF_CH70xx == 1)
66202        return(SiS_GetCH700x(SiS_Pr,tempbx));
66203     else
66204        return(SiS_GetCH701x(SiS_Pr,tempbx));
66205  }
66206  
66207 -/* TW: Read from Chrontel 700x */
66208 +/* Read from Chrontel 700x */
66209  /* Parameter is [Register no (S7-S0)] */
66210  USHORT
66211  SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempbx)
66212 @@ -9654,57 +10012,57 @@ SiS_GetCH700x(SiS_Private *SiS_Pr, USHOR
66213    USHORT tempah,temp,i;
66214  
66215    if(!(SiS_Pr->SiS_ChrontelInit)) {
66216 -     SiS_Pr->SiS_DDC_Index = 0x11;             /* TW: Bit 0 = SC;  Bit 1 = SD */
66217 +     SiS_Pr->SiS_DDC_Index = 0x11;             /* Bit 0 = SC;  Bit 1 = SD */
66218       SiS_Pr->SiS_DDC_Data  = 0x02;              /* Bitmask in IndexReg for Data */
66219       SiS_Pr->SiS_DDC_Clk   = 0x01;              /* Bitmask in IndexReg for Clk */
66220       SiS_Pr->SiS_DDC_DataShift = 0x00;
66221 -     SiS_Pr->SiS_DDC_DeviceAddr = 0xEA;                /* TW: DAB */
66222 +     SiS_Pr->SiS_DDC_DeviceAddr = 0xEA;                /* DAB */
66223    }
66224  
66225    SiS_Pr->SiS_DDC_ReadAddr = tempbx;
66226  
66227 -  for(i=0;i<20;i++) {  /* TW: Do only 20 attempts to read */
66228 +  for(i=0;i<20;i++) {  /* Do only 20 attempts to read */
66229      /* SiS_SetSwitchDDC2(SiS_Pr); */
66230 -    if(SiS_SetStart(SiS_Pr)) continue;         /* TW: Set start condition */
66231 +    if(SiS_SetStart(SiS_Pr)) continue;         /* Set start condition */
66232      tempah = SiS_Pr->SiS_DDC_DeviceAddr;
66233 -    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* TW: Write DAB (S0=0=write) */
66234 -    if(temp) continue;                         /* TW:        (ERROR: no ack) */
66235 -    tempah = SiS_Pr->SiS_DDC_ReadAddr | 0x80;  /* TW: Write RAB | 0x80 */
66236 +    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* Write DAB (S0=0=write) */
66237 +    if(temp) continue;                         /*        (ERROR: no ack) */
66238 +    tempah = SiS_Pr->SiS_DDC_ReadAddr | 0x80;  /* Write RAB | 0x80 */
66239      temp = SiS_WriteDDC2Data(SiS_Pr,tempah);
66240 -    if(temp) continue;                         /* TW:        (ERROR: no ack) */
66241 -    if (SiS_SetStart(SiS_Pr)) continue;                /* TW: Re-start */
66242 +    if(temp) continue;                         /*        (ERROR: no ack) */
66243 +    if (SiS_SetStart(SiS_Pr)) continue;                /* Re-start */
66244      tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01; /* DAB | 0x01 = Read */
66245 -    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* TW: DAB (S0=1=read) */
66246 -    if(temp) continue;                         /* TW:        (ERROR: no ack) */
66247 -    tempah = SiS_ReadDDC2Data(SiS_Pr,tempah);  /* TW: Read byte */
66248 -    if (SiS_SetStop(SiS_Pr)) continue;         /* TW: Stop condition */
66249 +    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* DAB (S0=1=read) */
66250 +    if(temp) continue;                         /*        (ERROR: no ack) */
66251 +    tempah = SiS_ReadDDC2Data(SiS_Pr,tempah);  /* Read byte */
66252 +    if (SiS_SetStop(SiS_Pr)) continue;         /* Stop condition */
66253      SiS_Pr->SiS_ChrontelInit = 1;
66254      return(tempah);
66255    }
66256  
66257 -  /* TW: For 630ST */
66258 +  /* For 630ST */
66259    if(!SiS_Pr->SiS_ChrontelInit) {
66260 -     SiS_Pr->SiS_DDC_Index = 0x0a;             /* TW: Bit 0 = SC;  Bit 1 = SD */
66261 +     SiS_Pr->SiS_DDC_Index = 0x0a;             /* Bit 0 = SC;  Bit 1 = SD */
66262       SiS_Pr->SiS_DDC_Data  = 0x80;              /* Bitmask in IndexReg for Data */
66263       SiS_Pr->SiS_DDC_Clk   = 0x40;              /* Bitmask in IndexReg for Clk */
66264       SiS_Pr->SiS_DDC_DataShift = 0x00;
66265 -     SiS_Pr->SiS_DDC_DeviceAddr = 0xEA;        /* TW: DAB (Device Address Byte) */
66266 +     SiS_Pr->SiS_DDC_DeviceAddr = 0xEA;        /* DAB (Device Address Byte) */
66267  
66268 -     for(i=0;i<20;i++) {       /* TW: Do only 20 attempts to read */
66269 +     for(i=0;i<20;i++) {       /* Do only 20 attempts to read */
66270         /* SiS_SetSwitchDDC2(SiS_Pr); */
66271 -       if(SiS_SetStart(SiS_Pr)) continue;              /* TW: Set start condition */
66272 +       if(SiS_SetStart(SiS_Pr)) continue;              /* Set start condition */
66273         tempah = SiS_Pr->SiS_DDC_DeviceAddr;
66274 -       temp = SiS_WriteDDC2Data(SiS_Pr,tempah);                /* TW: Write DAB (S0=0=write) */
66275 -       if(temp) continue;                              /* TW:        (ERROR: no ack) */
66276 -       tempah = SiS_Pr->SiS_DDC_ReadAddr | 0x80;       /* TW: Write RAB | 0x80 */
66277 +       temp = SiS_WriteDDC2Data(SiS_Pr,tempah);                /* Write DAB (S0=0=write) */
66278 +       if(temp) continue;                              /*        (ERROR: no ack) */
66279 +       tempah = SiS_Pr->SiS_DDC_ReadAddr | 0x80;       /* Write RAB | 0x80 */
66280         temp = SiS_WriteDDC2Data(SiS_Pr,tempah);
66281 -       if(temp) continue;                              /* TW:        (ERROR: no ack) */
66282 -       if (SiS_SetStart(SiS_Pr)) continue;             /* TW: Re-start */
66283 +       if(temp) continue;                              /*        (ERROR: no ack) */
66284 +       if (SiS_SetStart(SiS_Pr)) continue;             /* Re-start */
66285         tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01;     /* DAB | 0x01 = Read */
66286 -       temp = SiS_WriteDDC2Data(SiS_Pr,tempah);                /* TW: DAB (S0=1=read) */
66287 -       if(temp) continue;                              /* TW:        (ERROR: no ack) */
66288 -       tempah = SiS_ReadDDC2Data(SiS_Pr,tempah);       /* TW: Read byte */
66289 -       if (SiS_SetStop(SiS_Pr)) continue;              /* TW: Stop condition */
66290 +       temp = SiS_WriteDDC2Data(SiS_Pr,tempah);                /* DAB (S0=1=read) */
66291 +       if(temp) continue;                              /*        (ERROR: no ack) */
66292 +       tempah = SiS_ReadDDC2Data(SiS_Pr,tempah);       /* Read byte */
66293 +       if (SiS_SetStop(SiS_Pr)) continue;              /* Stop condition */
66294         SiS_Pr->SiS_ChrontelInit = 1;
66295         return(tempah);
66296       }
66297 @@ -9712,52 +10070,51 @@ SiS_GetCH700x(SiS_Private *SiS_Pr, USHOR
66298    return(0xFFFF);
66299  }
66300  
66301 -/* TW: Read from Chrontel 701x */
66302 +/* Read from Chrontel 701x */
66303  /* Parameter is [Register no (S7-S0)] */
66304  USHORT
66305  SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempbx)
66306  {
66307    USHORT tempah,temp,i;
66308  
66309 -  SiS_Pr->SiS_DDC_Index = 0x11;                        /* TW: Bit 0 = SC;  Bit 1 = SD */
66310 +  SiS_Pr->SiS_DDC_Index = 0x11;                        /* Bit 0 = SC;  Bit 1 = SD */
66311    SiS_Pr->SiS_DDC_Data  = 0x08;                 /* Bitmask in IndexReg for Data */
66312    SiS_Pr->SiS_DDC_Clk   = 0x04;                 /* Bitmask in IndexReg for Clk */
66313    SiS_Pr->SiS_DDC_DataShift = 0x00;
66314 -  SiS_Pr->SiS_DDC_DeviceAddr = 0xEA;           /* TW: DAB */
66315 +  SiS_Pr->SiS_DDC_DeviceAddr = 0xEA;           /* DAB */
66316    SiS_Pr->SiS_DDC_ReadAddr = tempbx;
66317  
66318 -   for(i=0;i<20;i++) { /* TW: Do only 20 attempts to read */
66319 -    if(SiS_SetStart(SiS_Pr)) continue;         /* TW: Set start condition */
66320 +   for(i=0;i<20;i++) { /* Do only 20 attempts to read */
66321 +    if(SiS_SetStart(SiS_Pr)) continue;         /* Set start condition */
66322      tempah = SiS_Pr->SiS_DDC_DeviceAddr;
66323 -    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* TW: Write DAB (S0=0=write) */
66324 -    if(temp) continue;                         /* TW:        (ERROR: no ack) */
66325 -    tempah = SiS_Pr->SiS_DDC_ReadAddr;         /* TW: Write RAB */
66326 +    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* Write DAB (S0=0=write) */
66327 +    if(temp) continue;                         /*        (ERROR: no ack) */
66328 +    tempah = SiS_Pr->SiS_DDC_ReadAddr;         /* Write RAB */
66329      temp = SiS_WriteDDC2Data(SiS_Pr,tempah);
66330 -    if(temp) continue;                         /* TW:        (ERROR: no ack) */
66331 -    if (SiS_SetStart(SiS_Pr)) continue;                /* TW: Re-start */
66332 +    if(temp) continue;                         /*        (ERROR: no ack) */
66333 +    if (SiS_SetStart(SiS_Pr)) continue;                /* Re-start */
66334      tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01; /* DAB | 0x01 = Read */
66335 -    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* TW: DAB (S0=1=read) */
66336 -    if(temp) continue;                         /* TW:        (ERROR: no ack) */
66337 -    tempah = SiS_ReadDDC2Data(SiS_Pr,tempah);  /* TW: Read byte */
66338 -    SiS_SetStop(SiS_Pr);                       /* TW: Stop condition */
66339 +    temp = SiS_WriteDDC2Data(SiS_Pr,tempah);   /* DAB (S0=1=read) */
66340 +    if(temp) continue;                         /*        (ERROR: no ack) */
66341 +    tempah = SiS_ReadDDC2Data(SiS_Pr,tempah);  /* Read byte */
66342 +    SiS_SetStop(SiS_Pr);                       /* Stop condition */
66343      return(tempah);
66344     }
66345    return 0xFFFF;
66346  }
66347  
66348 -#ifdef LINUX_XF86
66349 -/* TW: Our own DDC functions */
66350 +/* Our own DDC functions */
66351  USHORT
66352 -SiS_InitDDCRegs(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum, USHORT DDCdatatype,
66353 -               BOOLEAN checkcr32)
66354 +SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine,
66355 +                USHORT adaptnum, USHORT DDCdatatype, BOOLEAN checkcr32)
66356  {
66357       unsigned char ddcdtype[] = { 0xa0, 0xa0, 0xa0, 0xa2, 0xa6 };
66358       unsigned char flag, cr32;
66359       USHORT        temp = 0, myadaptnum = adaptnum;
66360  
66361       if(adaptnum != 0) {
66362 -        if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_302B))) return 0xFFFF;
66363 -       if((pSiS->VBFlags & VB_30xBDH) && (adaptnum == 1)) return 0xFFFF;
66364 +        if(!(VBFlags & (VB_301|VB_301B|VB_302B))) return 0xFFFF;
66365 +       if((VBFlags & VB_30xBDH) && (adaptnum == 1)) return 0xFFFF;
66366       } 
66367       
66368       /* adapternum for SiS bridges: 0 = CRT1, 1 = LCD, 2 = VGA2 */
66369 @@ -9771,8 +10128,9 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SIS
66370       flag = 0xff;
66371  
66372       cr32 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x32);
66373 -  
66374 -     if(pSiS->VBFlags & VB_SISBRIDGE) {
66375 +
66376 +#if 0
66377 +     if(VBFlags & VB_SISBRIDGE) {
66378         if(myadaptnum == 0) {
66379            if(!(cr32 & 0x20)) {
66380               myadaptnum = 2;
66381 @@ -9785,18 +10143,19 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SIS
66382            }
66383          }
66384       }
66385 +#endif
66386  
66387 -     if(pSiS->VGAEngine == SIS_300_VGA) {              /* 300 series */
66388 +     if(VGAEngine == SIS_300_VGA) {            /* 300 series */
66389         
66390          if(myadaptnum != 0) {
66391            flag = 0;
66392 -          if(pSiS->VBFlags & VB_SISBRIDGE) {
66393 +          if(VBFlags & VB_SISBRIDGE) {
66394               SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port;
66395                SiS_Pr->SiS_DDC_Index = 0x0f;
66396            }
66397          }
66398  
66399 -       if(!(pSiS->VBFlags & VB_301)) {
66400 +       if(!(VBFlags & VB_301)) {
66401            if((cr32 & 0x80) && (checkcr32)) {
66402                if(myadaptnum >= 1) {
66403                  if(!(cr32 & 0x08)) {
66404 @@ -9810,11 +10169,11 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SIS
66405         temp = 4 - (myadaptnum * 2);
66406         if(flag) temp = 0;
66407  
66408 -     } else {                                          /* 310/325/330 series */
66409 +     } else {                                          /* 315/330 series */
66410  
66411         /* here we simplify: 0 = CRT1, 1 = CRT2 (VGA, LCD) */
66412         
66413 -       if(pSiS->VBFlags & VB_SISBRIDGE) {
66414 +       if(VBFlags & VB_SISBRIDGE) {
66415            if(myadaptnum == 2) {
66416               myadaptnum = 1;
66417             }
66418 @@ -9822,7 +10181,7 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SIS
66419  
66420          if(myadaptnum == 1) {
66421            flag = 0;
66422 -          if(pSiS->VBFlags & VB_SISBRIDGE) {
66423 +          if(VBFlags & VB_SISBRIDGE) {
66424               SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port;
66425                SiS_Pr->SiS_DDC_Index = 0x0f;
66426            }
66427 @@ -9840,7 +10199,7 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SIS
66428          temp = myadaptnum;
66429          if(myadaptnum == 1) {
66430             temp = 0;
66431 -          if(pSiS->VBFlags & VB_LVDS) flag = 0xff;
66432 +          if(VBFlags & VB_LVDS) flag = 0xff;
66433          }
66434  
66435         if(flag) temp = 0;
66436 @@ -9852,7 +10211,7 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, SIS
66437  #ifdef TWDEBUG
66438      xf86DrvMsg(0, X_INFO, "DDC Port %x Index %x Shift %d\n",
66439                 SiS_Pr->SiS_DDC_Port, SiS_Pr->SiS_DDC_Index, temp);
66440 -#endif  
66441 +#endif
66442      
66443      return 0;
66444  }
66445 @@ -9862,15 +10221,9 @@ SiS_WriteDABDDC(SiS_Private *SiS_Pr)
66446  {
66447     if(SiS_SetStart(SiS_Pr)) return 0xFFFF;
66448     if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr)) {
66449 -#ifdef TWDEBUG
66450 -        xf86DrvMsg(0, X_INFO, "WriteDAB 1 failed\n");
66451 -#endif  
66452         return 0xFFFF;
66453     }
66454     if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_SecAddr)) {
66455 -#ifdef TWDEBUG
66456 -        xf86DrvMsg(0, X_INFO, "WriteDAB 2 failed\n");
66457 -#endif  
66458         return 0xFFFF;
66459     }
66460     return(0);
66461 @@ -9881,9 +10234,6 @@ SiS_PrepareReadDDC(SiS_Private *SiS_Pr)
66462  {
66463     if(SiS_SetStart(SiS_Pr)) return 0xFFFF;
66464     if(SiS_WriteDDC2Data(SiS_Pr, (SiS_Pr->SiS_DDC_DeviceAddr | 0x01))) {
66465 -#ifdef TWDEBUG
66466 -        xf86DrvMsg(0, X_INFO, "PrepareReadDDC 1 failed\n");
66467 -#endif  
66468         return 0xFFFF;
66469     }
66470     return(0);
66471 @@ -9921,9 +10271,6 @@ SiS_DoProbeDDC(SiS_Private *SiS_Pr)
66472      SiS_SetSwitchDDC2(SiS_Pr);
66473      if(SiS_PrepareDDC(SiS_Pr)) {
66474           SiS_SetStop(SiS_Pr);
66475 -#ifdef TWDEBUG
66476 -        xf86DrvMsg(0, X_INFO, "DoProbeDDC 1 failed at PrepareDDC\n");
66477 -#endif  
66478           return(0xFFFF);
66479      }
66480      mask = 0xf0;
66481 @@ -9972,7 +10319,7 @@ SiS_ProbeDDC(SiS_Private *SiS_Pr)
66482  }
66483  
66484  USHORT
66485 -SiS_ReadDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT DDCdatatype, unsigned char *buffer)
66486 +SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer)
66487  {
66488     USHORT flag, length, i;
66489     unsigned char chksum,gotcha;
66490 @@ -10004,28 +10351,7 @@ SiS_ReadDDC(SiS_Private *SiS_Pr, SISPtr 
66491     return(flag);
66492  }
66493  
66494 -USHORT
66495 -SiS_ReadLCDDDC(SiS_Private *SiS_Pr, USHORT length, unsigned char *buffer)
66496 -{
66497 -   USHORT i=0, flag=0;
66498 -
66499 -   length--;
66500 -   
66501 -   SiS_SetSwitchDDC2(SiS_Pr);
66502 -   if(!(SiS_PrepareDDC(SiS_Pr))) {
66503 -      for(i=0; i<length; i++) {
66504 -         buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0);
66505 -         SiS_SendACK(SiS_Pr, 0);
66506 -      }
66507 -      buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0);
66508 -      SiS_SendACK(SiS_Pr, 1);
66509 -   } else flag = 0xFFFF;
66510 -   
66511 -   SiS_SetStop(SiS_Pr);
66512 -   return(0);
66513 -}
66514 -
66515 -/* TW: Our private DDC function
66516 +/* Our private DDC functions
66517  
66518     It complies somewhat with the corresponding VESA function
66519     in arguments and return values.
66520 @@ -10036,7 +10362,7 @@ SiS_ReadLCDDDC(SiS_Private *SiS_Pr, USHO
66521  
66522     Arguments:
66523         adaptnum: 0=CRT1, 1=LCD, 2=VGA2
66524 -                 CRT2 DDC is only supported on SiS301, 301B (non-DH version), 302B.
66525 +                 CRT2 DDC is only supported on SiS301, 301B, 302B.
66526         DDCdatatype: 0=Probe, 1=EDID, 2=EDID+VDIF, 3=EDID V2 (P&D), 4=EDID V2 (FPDI-2)
66527         buffer: ptr to 256 data bytes which will be filled with read data.
66528  
66529 @@ -10046,43 +10372,48 @@ SiS_ReadLCDDDC(SiS_Private *SiS_Pr, USHO
66530  
66531   */
66532  USHORT
66533 -SiS_HandleDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum,
66534 -              USHORT DDCdatatype, unsigned char *buffer)
66535 +SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine,
66536 +              USHORT adaptnum, USHORT DDCdatatype, unsigned char *buffer)
66537  {
66538     if(adaptnum > 2) return 0xFFFF;
66539     if(DDCdatatype > 4) return 0xFFFF;
66540 -   if((!(pSiS->VBFlags & VB_VIDEOBRIDGE)) && (adaptnum > 0)) return 0xFFFF;
66541 -   if(SiS_InitDDCRegs(SiS_Pr, pSiS, adaptnum, DDCdatatype, TRUE) == 0xFFFF) return 0xFFFF;
66542 +   if((!(VBFlags & VB_VIDEOBRIDGE)) && (adaptnum > 0)) return 0xFFFF;
66543 +   if(SiS_InitDDCRegs(SiS_Pr, VBFlags, VGAEngine, adaptnum, DDCdatatype, TRUE) == 0xFFFF) return 0xFFFF;
66544     if(DDCdatatype == 0) {
66545         return(SiS_ProbeDDC(SiS_Pr));
66546     } else {
66547 -       return(SiS_ReadDDC(SiS_Pr, pSiS, DDCdatatype, buffer));
66548 +       return(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer));
66549     }
66550  }
66551  
66552 +#ifdef LINUX_XF86
66553  /* Sense the LCD parameters (CR36, CR37) via DDC */
66554  /* SiS30x(B) only */
66555  USHORT
66556  SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS)
66557  {
66558 -   USHORT DDCdatatype, paneltype, flag, xres, yres;
66559 +   USHORT DDCdatatype, paneltype, flag, xres=0, yres=0;
66560     USHORT index, myindex, lumsize, numcodes;
66561     unsigned char cr37=0, seekcode;
66562     BOOLEAN checkexpand = FALSE;
66563     int retry, i;
66564     unsigned char buffer[256];
66565 -   
66566 +
66567 +   for(i=0; i<7; i++) SiS_Pr->CP_DataValid[i] = FALSE;
66568 +   SiS_Pr->CP_HaveCustomData = FALSE;
66569 +   SiS_Pr->CP_MaxX = SiS_Pr->CP_MaxY = SiS_Pr->CP_MaxClock = 0;
66570 +
66571     if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_302B))) return 0;
66572     if(pSiS->VBFlags & VB_30xBDH) return 0;
66573    
66574 -   if(SiS_InitDDCRegs(SiS_Pr, pSiS, 1, 0, FALSE) == 0xFFFF) return 0;
66575 +   if(SiS_InitDDCRegs(SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 1, 0, FALSE) == 0xFFFF) return 0;
66576     
66577     SiS_Pr->SiS_DDC_SecAddr = 0x00;
66578     
66579     /* Probe supported DA's */
66580     flag = SiS_ProbeDDC(SiS_Pr);
66581  #ifdef TWDEBUG   
66582 -   xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, 
66583 +   xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO,
66584         "CRT2 DDC capabilities 0x%x\n", flag);
66585  #endif 
66586     if(flag & 0x10) {
66587 @@ -10099,7 +10430,7 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SIS
66588     /* Read the entire EDID */
66589     retry = 2;
66590     do {
66591 -      if(SiS_ReadDDC(SiS_Pr, pSiS, DDCdatatype, buffer)) {
66592 +      if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) {
66593           xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, 
66594                 "CRT2: DDC read failed (attempt %d), %s\n", 
66595                 (3-retry), (retry == 1) ? "giving up" : "retrying");
66596 @@ -10132,7 +10463,7 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SIS
66597        }
66598        
66599        if((buffer[0x18] & 0x18) != 0x08) {
66600 -         xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED, 
66601 +         xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
66602                 "CRT2: Attached display is not of RGB but of %s type (0x%02x)\n", 
66603                 ((buffer[0x18] & 0x18) == 0x00) ? "monochrome/greyscale" :
66604                   ( ((buffer[0x18] & 0x18) == 0x10) ? "non-RGB multicolor" : 
66605 @@ -10140,103 +10471,226 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SIS
66606                 buffer[0x18]);
66607          return 0;
66608        }
66609 -      
66610 -      /* Now analyze the first Detailed Timing Block and hope
66611 -       * that the preferred timing mode is stored there.
66612 -       */      
66613 -      xres = buffer[0x38] | ((buffer[0x3a] & 0xf0) << 4);
66614 -      yres = buffer[0x3b] | ((buffer[0x3d] & 0xf0) << 4);
66615 +
66616 +      /* Now analyze the first Detailed Timing Block and see
66617 +       * if the preferred timing mode is stored there. If so,
66618 +       * check if this is a standard panel for which we already
66619 +       * know the timing.
66620 +       */
66621 +
66622 +      paneltype = Panel_Custom;
66623        checkexpand = FALSE;
66624 -      switch(xres) {
66625 -         case 800:
66626 -            if(yres == 600) {
66627 -               paneltype = Panel310_800x600;
66628 -               checkexpand = TRUE;
66629 -            }
66630 -            break;
66631 -         case 1024:
66632 -            if(yres == 768) {
66633 -               paneltype = Panel310_1024x768;
66634 -               checkexpand = FALSE;    /* expand causes error at 640x480, should otherwise be TRUE; */
66635 -            }
66636 -            break;
66637 -        case 1280:
66638 -            if(yres == 960) {
66639 -               if(pSiS->VGAEngine == SIS_300_VGA) {
66640 -                  paneltype = Panel300_1280x960;
66641 -               } else {
66642 -                  paneltype = Panel310_1280x960; 
66643 -               }
66644 -            } else if(yres == 1024) {
66645 -               paneltype = Panel310_1280x1024;  
66646 -               checkexpand = TRUE;
66647 -            } else if(pSiS->VGAEngine == SIS_315_VGA) {
66648 +
66649 +      if(buffer[0x18] & 0x02) {
66650 +
66651 +         xres = buffer[0x38] | ((buffer[0x3a] & 0xf0) << 4);
66652 +         yres = buffer[0x3b] | ((buffer[0x3d] & 0xf0) << 4);
66653 +
66654 +        SiS_Pr->CP_PreferredX = xres;
66655 +        SiS_Pr->CP_PreferredY = yres;
66656 +
66657 +         switch(xres) {
66658 +            case 800:
66659 +               if(yres == 600) {
66660 +                  paneltype = Panel_800x600;
66661 +                  checkexpand = TRUE;
66662 +               }
66663 +               break;
66664 +            case 1024:
66665                 if(yres == 768) {
66666 -                  paneltype = Panel310_1280x768;       /* Panel size 1280x768 not supported yet */
66667 -                  checkexpand = TRUE;  
66668 -               }       
66669 -            }
66670 -            break;
66671 -        case 1400:
66672 -            if(pSiS->VGAEngine == SIS_315_VGA) {
66673 -               if(yres == 1050) {
66674 -                  paneltype = Panel310_1400x1050;
66675 -                  checkexpand = TRUE; 
66676 -               } 
66677 -            }
66678 -            break;
66679 -        case 1600:
66680 -            if(pSiS->VGAEngine == SIS_315_VGA) {
66681 -               if(yres == 1200) {
66682 -                  paneltype = Panel310_1600x1200;
66683 +                  paneltype = Panel_1024x768;
66684 +                  checkexpand = TRUE;
66685 +               }
66686 +               break;
66687 +           case 1280:
66688 +               if(yres == 1024) {
66689 +                  paneltype = Panel_1280x1024;
66690                    checkexpand = TRUE;
66691 -               } 
66692 -            }
66693 -            break;
66694 +               } else if(yres == 960) {
66695 +                  if(pSiS->VGAEngine == SIS_300_VGA) {
66696 +                     paneltype = Panel300_1280x960;
66697 +                  } else {
66698 +                     paneltype = Panel310_1280x960;
66699 +                  }
66700 +               } else if(yres == 768) {
66701 +                  paneltype = Panel_1280x768;
66702 +                  checkexpand = FALSE;
66703 +                  cr37 |= 0x10;
66704 +               }
66705 +               break;
66706 +           case 1400:
66707 +               if(pSiS->VGAEngine == SIS_315_VGA) {
66708 +                  if(yres == 1050) {
66709 +                     paneltype = Panel310_1400x1050;
66710 +                     checkexpand = TRUE;
66711 +                  }
66712 +               }
66713 +               break;
66714 +#if 0      /* Treat this as custom, as we have no valid timing data yet */
66715 +           case 1600:
66716 +               if(pSiS->VGAEngine == SIS_315_VGA) {
66717 +                  if(yres == 1200) {
66718 +                     paneltype = Panel310_1600x1200;
66719 +                     checkexpand = TRUE;
66720 +                  }
66721 +               }
66722 +               break;
66723 +#endif
66724 +         }
66725 +
66726 +        if(paneltype != Panel_Custom) {
66727 +           if((buffer[0x47] & 0x18) == 0x18) {
66728 +              cr37 |= ((((buffer[0x47] & 0x06) ^ 0x06) << 5) | 0x20);
66729 +           } else {
66730 +              /* What now? There is no digital separate output timing... */
66731 +              xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING,
66732 +                  "CRT2: Unable to retrieve Sync polarity information\n");
66733 +           }
66734 +        }
66735 +
66736        }
66737  
66738 -      if(buffer[0x18] & 0x02) {
66739 -         /* If the preferred timing mode is stored in the first
66740 -         * detailed timing block, we now can extract the sync
66741 -         * polarisation information as well. This only works
66742 -         * if the Flags indicate a digital separate output.
66743 -         */
66744 -         if((buffer[0x47] & 0x18) == 0x18) {
66745 -            cr37 |= ((((buffer[0x47] & 0x06) ^ 0x06) << 5) | 0x20);
66746 -         } else {
66747 -            /* What now? There is no digital separate output timing... */
66748 -            xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, 
66749 -               "CRT2: Unable to retrieve Sync polarity information\n");
66750 -         }
66751 -         
66752 -      } else {
66753 -         /* If the preferred timing mode is *not* stored in the first
66754 -         * detailed timing block, we need to guess the resolution
66755 -         * from the supported Established Timings and assume the
66756 -         * default sync polarity
66757 -         */
66758 +      /* If we still don't know what panel this is, we take it
66759 +       * as a custom panel and derive the timing data from the
66760 +       * detailed timing blocks
66761 +       */
66762 +      if(paneltype == Panel_Custom) {
66763 +
66764 +         BOOLEAN havesync = FALSE;
66765 +        int i, temp, base = 0x36;
66766 +        unsigned long estpack;
66767 +        unsigned short estx[] = {
66768 +               720, 720, 640, 640, 640, 640, 800, 800,
66769 +               800, 800, 832,1024,1024,1024,1024,1280,
66770 +               1152
66771 +        };
66772 +        unsigned short esty[] = {
66773 +               400, 400, 480, 480, 480, 480, 600, 600,
66774 +               600, 600, 624, 768, 768, 768, 768,1024,
66775 +               870
66776 +        };
66777 +
66778          paneltype = 0;
66779 -        if(buffer[0x24] & 0x01) {      
66780 -               paneltype = Panel310_1280x1024;
66781 -               checkexpand = TRUE;
66782 -               cr37 |= 0x20;
66783 -        } else if(buffer[0x24] & 0x0e) {
66784 -               paneltype = Panel310_1024x768;
66785 -               cr37 |= 0xe0;
66786 -               checkexpand = FALSE;            /* Bug at 640x480 */
66787 -        } else if(buffer[0x23] & 0x01) {
66788 -               paneltype = Panel310_800x600;
66789 -               cr37 |= 0xe0;
66790 -               checkexpand = TRUE;
66791 -         }
66792 +
66793 +        /* Find the maximum resolution */
66794 +
66795 +        /* 1. From Established timings */
66796 +        estpack = (buffer[0x23] << 9) | (buffer[0x24] << 1) | ((buffer[0x25] >> 7) & 0x01);
66797 +        for(i=16; i>=0; i--) {
66798 +            if(estpack & (1 << i)) {
66799 +               if(estx[16 - i] > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = estx[16 - i];
66800 +               if(esty[16 - i] > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = esty[16 - i];
66801 +            }
66802 +        }
66803 +
66804 +        /* 2. From Standard Timings */
66805 +        for(i=0x26; i < 0x36; i+=2) {
66806 +           if((buffer[i] != 0x01) && (buffer[i+1] != 0x01)) {
66807 +              temp = (buffer[i] + 31) * 8;
66808 +              if(temp > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = temp;
66809 +              switch((buffer[i+1] & 0xc0) >> 6) {
66810 +              case 0x03: temp = temp * 9 / 16; break;
66811 +              case 0x02: temp = temp * 4 / 5;  break;
66812 +              case 0x01: temp = temp * 3 / 4;  break;
66813 +              }
66814 +              if(temp > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = temp;
66815 +           }
66816 +        }
66817 +
66818 +        /* Now extract the Detailed Timings and convert them into modes */
66819 +
66820 +         for(i = 0; i < 4; i++, base += 18) {
66821 +
66822 +           /* Is this a detailed timing block or a monitor descriptor? */
66823 +           if(buffer[base] || buffer[base+1] || buffer[base+2]) {
66824 +
66825 +              xres = buffer[base+2] | ((buffer[base+4] & 0xf0) << 4);
66826 +               yres = buffer[base+5] | ((buffer[base+7] & 0xf0) << 4);
66827 +
66828 +              SiS_Pr->CP_HDisplay[i] = xres;
66829 +              SiS_Pr->CP_HSyncStart[i] = xres + (buffer[base+8] | ((buffer[base+11] & 0xc0) << 2));
66830 +               SiS_Pr->CP_HSyncEnd[i]   = SiS_Pr->CP_HSyncStart[i] + (buffer[base+9] | ((buffer[base+11] & 0x30) << 4));
66831 +              SiS_Pr->CP_HTotal[i] = xres + (buffer[base+3] | ((buffer[base+4] & 0x0f) << 8));
66832 +              SiS_Pr->CP_HBlankStart[i] = xres + 1;
66833 +              SiS_Pr->CP_HBlankEnd[i] = SiS_Pr->CP_HTotal[i];
66834 +
66835 +              SiS_Pr->CP_VDisplay[i] = yres;
66836 +               SiS_Pr->CP_VSyncStart[i] = yres + (((buffer[base+10] & 0xf0) >> 4) | ((buffer[base+11] & 0x0c) << 2));
66837 +               SiS_Pr->CP_VSyncEnd[i] = SiS_Pr->CP_VSyncStart[i] + ((buffer[base+10] & 0x0f) | ((buffer[base+11] & 0x03) << 4));
66838 +              SiS_Pr->CP_VTotal[i] = yres + (buffer[base+6] | ((buffer[base+7] & 0x0f) << 8));
66839 +              SiS_Pr->CP_VBlankStart[i] = yres + 1;
66840 +              SiS_Pr->CP_VBlankEnd[i] = SiS_Pr->CP_VTotal[i];
66841 +
66842 +              SiS_Pr->CP_Clock[i] = (buffer[base] | (buffer[base+1] << 8)) * 10;
66843 +
66844 +              SiS_Pr->CP_DataValid[i] = TRUE;
66845 +
66846 +              /* Sort out invalid timings, interlace and too high clocks */
66847 +              if((SiS_Pr->CP_HDisplay[i] > SiS_Pr->CP_HSyncStart[i])  ||
66848 +                 (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HSyncEnd[i])   ||
66849 +                 (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HTotal[i])     ||
66850 +                 (SiS_Pr->CP_HSyncStart[i] >= SiS_Pr->CP_HSyncEnd[i]) ||
66851 +                 (SiS_Pr->CP_HSyncStart[i] > SiS_Pr->CP_HTotal[i])    ||
66852 +                 (SiS_Pr->CP_HSyncEnd[i] > SiS_Pr->CP_HTotal[i])      ||
66853 +                 (SiS_Pr->CP_VDisplay[i] > SiS_Pr->CP_VSyncStart[i])  ||
66854 +                 (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VSyncEnd[i])   ||
66855 +                 (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VTotal[i])     ||
66856 +                 (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VSyncEnd[i])  ||
66857 +                 (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VTotal[i])    ||
66858 +                 (SiS_Pr->CP_VSyncEnd[i] > SiS_Pr->CP_VTotal[i])      ||
66859 +                 (SiS_Pr->CP_Clock[i] > 108000)                       ||
66860 +                 (buffer[base+17] & 0x80)) {
66861 +
66862 +                 SiS_Pr->CP_DataValid[i] = FALSE;
66863 +
66864 +              } else {
66865 +
66866 +                 paneltype = Panel_Custom;
66867 +
66868 +                 SiS_Pr->CP_HaveCustomData = TRUE;
66869 +
66870 +                 if(xres > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = xres;
66871 +                 if(yres > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = yres;
66872 +                 if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i];
66873 +
66874 +                 SiS_Pr->CP_Vendor = buffer[9] | (buffer[8] << 8);
66875 +                 SiS_Pr->CP_Product = buffer[10] | (buffer[11] << 8);
66876 +
66877 +                 /* We must assume the panel can scale, since we have
66878 +                  * no scaling data
66879 +                  */
66880 +                 checkexpand = FALSE;
66881 +                 cr37 |= 0x10;
66882 +
66883 +                 /* Extract the sync polarisation information. This only works
66884 +                  * if the Flags indicate a digital separate output.
66885 +                  */
66886 +                 if((buffer[base+17] & 0x18) == 0x18) {
66887 +                    SiS_Pr->CP_HSync_P[i] = (buffer[base+17] & 0x02) ? TRUE : FALSE;
66888 +                    SiS_Pr->CP_VSync_P[i] = (buffer[base+17] & 0x04) ? TRUE : FALSE;
66889 +                    SiS_Pr->CP_SyncValid[i] = TRUE;
66890 +                    if(!havesync) {
66891 +                       cr37 |= ((((buffer[base+17] & 0x06) ^ 0x06) << 5) | 0x20);
66892 +                       havesync = TRUE;
66893 +                    }
66894 +                 } else {
66895 +                    SiS_Pr->CP_SyncValid[i] = FALSE;
66896 +                 }
66897 +              }
66898 +            }
66899 +        }
66900 +        if(!havesync) {
66901 +           xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING,
66902 +                  "CRT2: Unable to retrieve Sync polarity information\n");
66903 +        }
66904        }
66905 -      
66906 -      if(checkexpand) {
66907 -         /* If any of the Established low-res modes is supported, the 
66908 +
66909 +      if(paneltype && checkexpand) {
66910 +         /* If any of the Established low-res modes is supported, the
66911           * panel can scale automatically. For 800x600 panels, we only 
66912           * check the even lower ones.
66913           */
66914 -        if(paneltype == Panel310_800x600) {
66915 +        if(paneltype == Panel_800x600) {
66916             if(buffer[0x23] & 0xfc) cr37 |= 0x10;
66917          } else {
66918              if(buffer[0x23])       cr37 |= 0x10;
66919 @@ -10262,20 +10716,31 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SIS
66920                 buffer[0x41]);
66921          return 0;
66922        }
66923 -   
66924 -      xres = buffer[0x76] | (buffer[0x77] << 8);
66925 -      yres = buffer[0x78] | (buffer[0x79] << 8);
66926 +
66927 +      paneltype = Panel_Custom;
66928 +      SiS_Pr->CP_MaxX = xres = buffer[0x76] | (buffer[0x77] << 8);
66929 +      SiS_Pr->CP_MaxY = yres = buffer[0x78] | (buffer[0x79] << 8);
66930        switch(xres) {
66931           case 800:
66932              if(yres == 600) {
66933 -               paneltype = Panel310_800x600;
66934 +               paneltype = Panel_800x600;
66935                 checkexpand = TRUE;
66936              }
66937              break;
66938           case 1024:
66939              if(yres == 768) {
66940 -               paneltype = Panel310_1024x768;
66941 -               checkexpand = FALSE;                    /* Bug at 640x480; we do the scaling ourselves */
66942 +               paneltype = Panel_1024x768;
66943 +               checkexpand = TRUE;
66944 +            }
66945 +            break;
66946 +        case 1152:
66947 +            if(yres == 768) {
66948 +               if(pSiS->VGAEngine == SIS_300_VGA) {
66949 +                  paneltype = Panel300_1152x768;
66950 +               } else {
66951 +                  paneltype = Panel310_1152x768;
66952 +               }
66953 +               checkexpand = TRUE;
66954              }
66955              break;
66956          case 1280:
66957 @@ -10286,45 +10751,46 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SIS
66958                    paneltype = Panel300_1280x960;
66959                 }
66960              } else if(yres == 1024) {
66961 -               paneltype = Panel310_1280x1024;  
66962 +               paneltype = Panel_1280x1024;
66963                 checkexpand = TRUE;
66964 -            } else if(pSiS->VGAEngine == SIS_315_VGA) {
66965 -               if(yres == 768) {
66966 -                  paneltype = Panel310_1280x768;       /* Panel size 1280x768 not supported yet */
66967 -                  checkexpand = TRUE;
66968 -               }
66969 -            } 
66970 +            } else if(yres == 768) {
66971 +               paneltype = Panel_1280x768;
66972 +               checkexpand = FALSE;
66973 +               cr37 |= 0x10;
66974 +            }
66975              break;
66976          case 1400:
66977              if(pSiS->VGAEngine == SIS_315_VGA) {
66978                 if(yres == 1050) {
66979                    paneltype = Panel310_1400x1050;
66980                    checkexpand = TRUE;
66981 -               } 
66982 +               }
66983              }
66984              break;
66985 +#if 0    /* Treat this one as custom since we have no timing data yet */
66986          case 1600:
66987              if(pSiS->VGAEngine == SIS_315_VGA) {
66988                 if(yres == 1200) {
66989                    paneltype = Panel310_1600x1200;
66990                    checkexpand = TRUE;
66991 -               } 
66992 +               }
66993              }
66994              break;
66995 +#endif
66996        }
66997 -                 
66998 +
66999        /* Determine if RGB18 or RGB24 */
67000        if(index) {
67001           if((buffer[index] == 0x20) || (buffer[index] == 0x34)) {
67002             cr37 |= 0x01;
67003          }
67004        }
67005 -      
67006 +
67007        if(checkexpand) {
67008           /* TODO - for now, we let the panel scale */
67009          cr37 |= 0x10;
67010        }
67011 -     
67012 +
67013        /* Now seek 4-Byte Timing codes and extract sync pol info */
67014        index = 0x80;
67015        if(buffer[0x7e] & 0x20) {                            /* skip Luminance Table (if provided) */
67016 @@ -10346,28 +10812,117 @@ SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SIS
67017          if(buffer[myindex] == seekcode) {
67018             cr37 |= ((((buffer[myindex + 1] & 0x0c) ^ 0x0c) << 4) | 0x20);
67019          } else {
67020 -           xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, 
67021 -               "CRT2: Unable to retrieve Sync polarity information\n");    
67022 +           xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING,
67023 +               "CRT2: Unable to retrieve Sync polarity information\n");
67024          }
67025        } else {
67026 -         xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING, 
67027 -               "CRT2: Unable to retrieve Sync polarity information\n");
67028 +         xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING,
67029 +            "CRT2: Unable to retrieve Sync polarity information\n");
67030 +      }
67031 +
67032 +      /* Now seek the detailed timing descriptions for custom panels */
67033 +      if(paneltype == Panel_Custom) {
67034 +         index += (numcodes * 4);
67035 +        numcodes = buffer[0x7f] & 0x07;
67036 +        for(i=0; i<numcodes; i++) {
67037 +           xres = buffer[index+2] | ((buffer[index+4] & 0xf0) << 4);
67038 +            yres = buffer[index+5] | ((buffer[index+7] & 0xf0) << 4);
67039 +
67040 +           SiS_Pr->CP_HDisplay[i] = xres;
67041 +           SiS_Pr->CP_HSyncStart[i] = xres + (buffer[index+8] | ((buffer[index+11] & 0xc0) << 2));
67042 +            SiS_Pr->CP_HSyncEnd[i] = SiS_Pr->CP_HSyncStart[i] + (buffer[index+9] | ((buffer[index+11] & 0x30) << 4));
67043 +           SiS_Pr->CP_HTotal[i] = xres + (buffer[index+3] | ((buffer[index+4] & 0x0f) << 8));
67044 +           SiS_Pr->CP_HBlankStart[i] = xres + 1;
67045 +           SiS_Pr->CP_HBlankEnd[i] = SiS_Pr->CP_HTotal[i];
67046 +
67047 +           SiS_Pr->CP_VDisplay[i] = yres;
67048 +            SiS_Pr->CP_VSyncStart[i] = yres + (((buffer[index+10] & 0xf0) >> 4) | ((buffer[index+11] & 0x0c) << 2));
67049 +            SiS_Pr->CP_VSyncEnd[i] = SiS_Pr->CP_VSyncStart[i] + ((buffer[index+10] & 0x0f) | ((buffer[index+11] & 0x03) << 4));
67050 +           SiS_Pr->CP_VTotal[i] = yres + (buffer[index+6] | ((buffer[index+7] & 0x0f) << 8));
67051 +           SiS_Pr->CP_VBlankStart[i] = yres + 1;
67052 +           SiS_Pr->CP_VBlankEnd[i] = SiS_Pr->CP_VTotal[i];
67053 +
67054 +           SiS_Pr->CP_Clock[i] = (buffer[index] | (buffer[index+1] << 8)) * 10;
67055 +
67056 +           SiS_Pr->CP_DataValid[i] = TRUE;
67057 +
67058 +           if((SiS_Pr->CP_HDisplay[i] > SiS_Pr->CP_HSyncStart[i])  ||
67059 +              (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HSyncEnd[i])   ||
67060 +              (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HTotal[i])     ||
67061 +              (SiS_Pr->CP_HSyncStart[i] >= SiS_Pr->CP_HSyncEnd[i]) ||
67062 +              (SiS_Pr->CP_HSyncStart[i] > SiS_Pr->CP_HTotal[i])    ||
67063 +              (SiS_Pr->CP_HSyncEnd[i] > SiS_Pr->CP_HTotal[i])      ||
67064 +              (SiS_Pr->CP_VDisplay[i] > SiS_Pr->CP_VSyncStart[i])  ||
67065 +              (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VSyncEnd[i])   ||
67066 +              (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VTotal[i])     ||
67067 +              (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VSyncEnd[i])  ||
67068 +              (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VTotal[i])    ||
67069 +              (SiS_Pr->CP_VSyncEnd[i] > SiS_Pr->CP_VTotal[i])      ||
67070 +              (SiS_Pr->CP_Clock[i] > 108000)                       ||
67071 +              (buffer[index + 17] & 0x80)) {
67072 +
67073 +              SiS_Pr->CP_DataValid[i] = FALSE;
67074 +
67075 +           } else {
67076 +
67077 +              SiS_Pr->CP_HaveCustomData = TRUE;
67078 +
67079 +              if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i];
67080 +
67081 +              SiS_Pr->CP_HSync_P[i] = (buffer[index + 17] & 0x02) ? TRUE : FALSE;
67082 +              SiS_Pr->CP_VSync_P[i] = (buffer[index + 17] & 0x04) ? TRUE : FALSE;
67083 +              SiS_Pr->CP_SyncValid[i] = TRUE;
67084 +
67085 +              SiS_Pr->CP_Vendor = buffer[2] | (buffer[1] << 8);
67086 +              SiS_Pr->CP_Product = buffer[3] | (buffer[4] << 8);
67087 +
67088 +              /* We must assume the panel can scale, since we have
67089 +               * no scaling data
67090 +               */
67091 +              cr37 |= 0x10;
67092 +
67093 +           }
67094 +        }
67095 +
67096        }
67097  
67098        break;
67099 -     
67100 +
67101     }
67102 -   
67103 +
67104     /* 1280x960 panels are always RGB24, unable to scale and use
67105      * high active sync polarity
67106      */
67107     if(pSiS->VGAEngine == SIS_315_VGA) {
67108 -      if(paneltype == Panel310_1280x960) cr37 &= 0x0e; 
67109 +      if(paneltype == Panel310_1280x960) cr37 &= 0x0e;
67110     } else {
67111 -      if(paneltype == Panel300_1280x960) cr37 &= 0x0e; 
67112 +      if(paneltype == Panel300_1280x960) cr37 &= 0x0e;
67113     }
67114 -   
67115 +
67116 +   for(i = 0; i < 7; i++) {
67117 +      if(SiS_Pr->CP_DataValid[i]) {
67118 +         xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
67119 +            "Non-standard LCD timing data no. %d:\n", i);
67120 +         xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
67121 +           "   HDisplay %d HSync %d HSyncEnd %d HTotal %d\n",
67122 +           SiS_Pr->CP_HDisplay[i], SiS_Pr->CP_HSyncStart[i],
67123 +           SiS_Pr->CP_HSyncEnd[i], SiS_Pr->CP_HTotal[i]);
67124 +         xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
67125 +            "   VDisplay %d VSync %d VSyncEnd %d VTotal %d\n",
67126 +            SiS_Pr->CP_VDisplay[i], SiS_Pr->CP_VSyncStart[i],
67127 +           SiS_Pr->CP_VSyncEnd[i], SiS_Pr->CP_VTotal[i]);
67128 +         xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
67129 +           "   Pixel clock: %3.3fMhz\n", (float)SiS_Pr->CP_Clock[i] / 1000);
67130 +        xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO,
67131 +           "   To use this, add \"%dx%d\" to the list of Modes in the Display section\n",
67132 +           SiS_Pr->CP_HDisplay[i],
67133 +           SiS_Pr->CP_VDisplay[i]);
67134 +      }
67135 +   }
67136 +
67137     if(paneltype) {
67138 +       if(!SiS_Pr->CP_PreferredX) SiS_Pr->CP_PreferredX = SiS_Pr->CP_MaxX;
67139 +       if(!SiS_Pr->CP_PreferredY) SiS_Pr->CP_PreferredY = SiS_Pr->CP_MaxY;
67140         cr37 &= 0xf1;
67141         cr37 |= 0x02;    /* SiS301 */
67142         SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x36,0xf0,paneltype);
67143 @@ -10392,7 +10947,7 @@ SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SI
67144     if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_302B))) return 0;
67145  /* if(pSiS->VBFlags & VB_30xBDH) return 0;  */
67146     
67147 -   if(SiS_InitDDCRegs(SiS_Pr, pSiS, 2, 0, FALSE) == 0xFFFF) return 0;
67148 +   if(SiS_InitDDCRegs(SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 2, 0, FALSE) == 0xFFFF) return 0;
67149     
67150     SiS_Pr->SiS_DDC_SecAddr = 0x00;
67151     
67152 @@ -10416,7 +10971,7 @@ SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SI
67153     /* Read the entire EDID */
67154     retry = 2;
67155     do {
67156 -      if(SiS_ReadDDC(SiS_Pr, pSiS, DDCdatatype, buffer)) {
67157 +      if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) {
67158           xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO, 
67159                 "CRT2: DDC read failed (attempt %d), %s\n", 
67160                 (3-retry), (retry == 1) ? "giving up" : "retrying");
67161 @@ -10435,6 +10990,8 @@ SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SI
67162                 "CRT2: Attached display expects digital input\n");
67163           return 0;     
67164        }
67165 +      SiS_Pr->CP_Vendor = buffer[9] | (buffer[8] << 8);
67166 +      SiS_Pr->CP_Product = buffer[10] | (buffer[11] << 8);
67167        foundcrt = TRUE;
67168        break;
67169     case 3:
67170 @@ -10448,198 +11005,19 @@ SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SI
67171                 buffer[0x41]);
67172           return 0;
67173        }
67174 +      SiS_Pr->CP_Vendor = buffer[2] | (buffer[1] << 8);
67175 +      SiS_Pr->CP_Product = buffer[3] | (buffer[4] << 8);
67176        foundcrt = TRUE;
67177 -      break;     
67178 +      break;
67179     }
67180 -   
67181 +
67182     if(foundcrt) {
67183         SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x10);
67184     }
67185     return(0);
67186  }
67187  
67188 -#if 0
67189 -   /* ----- */
67190 -USHORT
67191 -SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS)
67192 -{
67193 -   USHORT DDCdatatype, paneltype, flag;
67194 -   unsigned char cr36=0, cr37=0;
67195 -   unsigned char tempal, tempah, tempbl, tempbh;
67196 -   USHORT tempax, tempbx, tempcx, push1, push2, push3;
67197 -   unsigned char addresstable[] = { 0x00, 0x22, 0x30, 0x40 };
67198 -   int i;
67199 -   unsigned char buffer[256];
67200 -   
67201 -   if(pSiS->VGAEngine != SIS_315_VGA) return 0xFFFF;
67202 -   if(!(pSiS->VBFlags & (VB_301B|VB_302B))) return 0xFFFF;
67203 -   
67204 -   if(SiS_InitDDCRegs(SiS_Pr, pSiS, 1, 0, FALSE) == 0xFFFF) return 0xFFFF;   
67205 -   
67206 -   flag = SiS_ProbeDDC(SiS_Pr);
67207 -   if(flag & 0x02) {
67208 -      SiS_Pr->SiS_DDC_DeviceAddr = 0xa0;       /* EDID V1 */
67209 -      DDCdatatype = 1;
67210 -      SiS_Pr->SiS_DDC_SecAddr = 0x3a;
67211 -   } else if(flag & 0x08) {
67212 -      SiS_Pr->SiS_DDC_DeviceAddr = 0xa2;       /* EDID V2 (P&D-D Monitor) */
67213 -      DDCdatatype = 3;
67214 -      SiS_Pr->SiS_DDC_SecAddr = 0x76;
67215 -   } else if(flag & 0x10) {
67216 -      SiS_Pr->SiS_DDC_DeviceAddr = 0xa6;       /* EDID V2 (FP) */
67217 -      DDCdatatype = 4;
67218 -      SiS_Pr->SiS_DDC_SecAddr = 0x76;
67219 -   } else return 0xFFFF;
67220 -   
67221 -   
67222 -   SiS_ReadLCDDDC(SiS_Pr, 4, buffer);
67223 -   tempbl = buffer[0];  /* 3a - 76 */
67224 -   tempbh = buffer[1];  /* 3b - 77 */
67225 -   
67226 -   if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) {
67227 -   
67228 -      /* Read and analyze EDID V1 (res) */
67229 -   
67230 -      tempah = 0x02;                           /* 1024x768 by default */
67231 -      tempbl &= 0xf0;
67232 -      if(tempbl != 0x40) {                     
67233 -         tempah = 0x03;                                /* 1280x1024 by default */
67234 -        if(tempbl == 0x50) {
67235 -           if(!tempbh) {
67236 -              tempbh = buffer[3] & 0xf0;
67237 -              if(tempbh == 0x30) {
67238 -                  SiS_Pr->SiS_DDC_DeviceAddr = 0xa0;
67239 -                  SiS_Pr->SiS_DDC_SecAddr = 0x23;
67240 -                  SiS_ReadLCDDDC(SiS_Pr, 2, buffer);
67241 -                  tempbl = buffer[0];  /* 0x23 */
67242 -                  tempbh = buffer[1];  /* 0x24 */
67243 -                  if(tempbl) cr37 |= 0x10;
67244 -                  tempah = 0x0a;               /* 1280x768 */
67245 -              }
67246 -              if(tempbh == 0x40) {
67247 -                  SiS_Pr->SiS_DDC_DeviceAddr = 0xa0;
67248 -                  SiS_Pr->SiS_DDC_SecAddr = 0x23;
67249 -                  SiS_ReadLCDDDC(SiS_Pr, 2, buffer);
67250 -                  tempbl = buffer[0];  /* 0x23 */
67251 -                  tempbh = buffer[1];  /* 0x24 */
67252 -                  if(tempbl) cr37 |= 0x10;
67253 -                  tempah = 0x03;               /* 1280x1024 */
67254 -              }
67255 -              tempbh = 0x00;
67256 -           }
67257 -        }
67258 -        if(tempbh == 0x00) goto cr36ready;
67259 -        tempah = 0x07;                         /* 1280x960 */
67260 -        if(tempbh == 0xc0) goto cr36ready;
67261 -      }
67262 -      SiS_Pr->SiS_DDC_DeviceAddr = 0xa0;
67263 -      SiS_Pr->SiS_DDC_SecAddr = 0x18;          /* feature support */
67264 -      SiS_ReadLCDDDC(SiS_Pr, 2, buffer);
67265 -      tempbl = buffer[0];
67266 -      tempbh = buffer[1];
67267 -      if(tempbl & 0x02) goto cr36ready;
67268 -      SiS_Pr->SiS_DDC_DeviceAddr = 0xa0;
67269 -      SiS_Pr->SiS_DDC_SecAddr = 0x23;          /* Established Timings */
67270 -      SiS_ReadLCDDDC(SiS_Pr, 2, buffer);
67271 -      tempbl = buffer[0];
67272 -      tempbh = buffer[1];
67273 -      tempah = 0x03;
67274 -      if(!(tempbh & 0x01)) tempah = 0x02;
67275 -      if(!tempbl) cr37 |= 0x10;
67276 -      
67277 -  } else {
67278 -  
67279 -      /* Read and analyze EDID V2 (res) */
67280 -      
67281 -      tempah = 0x02;
67282 -      tempbx = tempbl | (tempbh << 8);
67283 -      if(tempbx != 1024) tempah = 0x03;
67284 -      
67285 -  }     
67286 -
67287 -cr36ready:
67288 -  cr36 = tempah;      
67289 -  
67290 -  if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) {
67291 -  
67292 -     /* Read and analyze EDID V1 (pol) */
67293 -  
67294 -     SiS_Pr->SiS_DDC_SecAddr = 0x47;
67295 -     SiS_ReadLCDDDC(SiS_Pr, 2, buffer);
67296 -     tempah = buffer[0];
67297 -     tempah &= 0x06;
67298 -     tempah ^= 0x06;
67299 -     tempah <<= 5;
67300 -     tempah |= 0x20;
67301 -     cr37 &= 0x1f;
67302 -     cr37 |= tempah;
67303 -     if((cr36 & 0x07) == 0x07) cr37 &= 0x0e;
67304 -     
67305 -  } else {
67306 -  
67307 -     /* Read and analyze EDID V2 (depth, pol) */
67308 -  
67309 -     push1 = tempah;
67310 -     SiS_Pr->SiS_DDC_SecAddr = 0x45;
67311 -     SiS_ReadLCDDDC(SiS_Pr, 2, buffer);
67312 -     tempah = 0x01;
67313 -     if((buffer[0] != 0x20) && (buffer[0] != 0x34)) {   /* RGB18 or 24? */
67314 -        tempah = 0x00;
67315 -     }
67316 -     cr37 &= 0xfe;
67317 -     cr37 |= tempah;
67318 -     
67319 -     SiS_Pr->SiS_DDC_SecAddr = 0x7e;
67320 -     SiS_ReadLCDDDC(SiS_Pr, 2, buffer);
67321 -     tempax = (USHORT)(buffer[0] | (buffer[1] << 8));
67322 -     push2 = tempax;
67323 -     tempax &= 0x0003;
67324 -     tempax *= 0x1b;
67325 -     push3 = tempax;
67326 -     tempax = (USHORT)buffer[0];
67327 -     tempax &= 0x001c;
67328 -     tempax >>= 2;
67329 -     tempax *= 8;
67330 -     tempbx = push3;
67331 -     tempbx += tempax;
67332 -     if(buffer[0] & 0x20) {            /* Luminance table provided? */
67333 -        SiS_Pr->SiS_DDC_SecAddr = 0x80;
67334 -       SiS_ReadLCDDDC(SiS_Pr, 2, buffer);
67335 -       tempax = buffer[0] | (buffer[1] << 8);
67336 -       tempax &= 0x1f;
67337 -       if(buffer[0] & 0x70) tempax <<= 1;
67338 -       tempax++;       
67339 -       tempbx += tempax;               /* yes -> skip it */
67340 -     }
67341 -     tempcx = push2;
67342 -     tempax = push1 << 8;
67343 -     tempbx = (tempbx & 0xff00) | (((tempbx & 0x00ff) + 0x80) & 0x00ff);
67344 -     if(tempcx & 0xf800) {
67345 -        tempal = addresstable[((tempax & 0xff00) >> 8)];
67346 -       tempcx &= 0xf8ff;
67347 -       tempcx >>= 11;
67348 -       for(i=0; i<tempcx; i++) {
67349 -          SiS_Pr->SiS_DDC_SecAddr = (tempbx & 0x00ff);
67350 -          SiS_ReadLCDDDC(SiS_Pr, 2, buffer);
67351 -          tempbx += 0x04;
67352 -          if(buffer[0] == tempal) break;
67353 -       }
67354 -       tempah = buffer[1];
67355 -       tempah &= 0x0c;
67356 -       tempah ^= 0x0c;
67357 -       tempah <<= 4;
67358 -       tempah |= 0x20;
67359 -        cr37 &= 0x1f;
67360 -        cr37 |= tempah;
67361 -       if((cr36 & 0x07) == 0x07) cr37 &= 0x0e;
67362 -     }
67363 -  }
67364 -  xf86DrvMsg(0, X_INFO, "DDC: cr36 = 0x%02x, cr37 = 0x%02x\n", cr36, cr37);
67365 -  return 0;
67366 -}
67367 -#endif
67368 -
67369 -/* TW: Generic I2C functions (compliant to i2c library) */
67370 +/* Generic I2C functions (compliant to i2c library) */
67371  
67372  #if 0
67373  USHORT
67374 @@ -10675,16 +11053,14 @@ SiS_I2C_Stop(SiS_Private *SiS_Pr)
67375  void
67376  SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh)
67377  {
67378 -  USHORT tempal,tempah,tempbl;
67379 +  USHORT tempbl;
67380  
67381 -  tempal = tempax & 0x00FF;
67382 -  tempah =(tempax >> 8) & 0x00FF;
67383 -  tempbl = SiS_GetCH70xx(SiS_Pr,tempal);
67384 -  tempbl = (((tempbl & tempbh) | tempah) << 8 | tempal);
67385 +  tempbl = SiS_GetCH70xx(SiS_Pr,(tempax & 0x00FF));
67386 +  tempbl = (((tempbl & tempbh) << 8) | tempax);
67387    SiS_SetCH70xx(SiS_Pr,tempbl);
67388  }
67389  
67390 -/* TW: Generic I2C functions for Chrontel --------- */
67391 +/* Generic I2C functions for Chrontel --------- */
67392  
67393  void
67394  SiS_SetSwitchDDC2(SiS_Private *SiS_Pr)
67395 @@ -10698,37 +11074,37 @@ SiS_SetSwitchDDC2(SiS_Private *SiS_Pr)
67396    SiS_WaitRetraceDDC(SiS_Pr);
67397  }
67398  
67399 -/* TW: Set I2C start condition */
67400 -/* TW: This is done by a SD high-to-low transition while SC is high */
67401 +/* Set I2C start condition */
67402 +/* This is done by a SD high-to-low transition while SC is high */
67403  USHORT
67404  SiS_SetStart(SiS_Private *SiS_Pr)
67405  {
67406 -  if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF;                               /* TW: (SC->low)  */
67407 +  if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF;                               /* (SC->low)  */
67408    SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
67409 -                  ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data);             /* TW: SD->high */
67410 -  if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF;                              /* TW: SC->high */
67411 +                  ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data);             /* SD->high */
67412 +  if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF;                              /* SC->high */
67413    SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
67414 -                  ~SiS_Pr->SiS_DDC_Data,0x00);                             /* TW: SD->low = start condition */
67415 -  if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF;                              /* TW: (SC->low) */
67416 +                  ~SiS_Pr->SiS_DDC_Data,0x00);                             /* SD->low = start condition */
67417 +  if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF;                              /* (SC->low) */
67418    return 0;
67419  }
67420  
67421 -/* TW: Set I2C stop condition */
67422 -/* TW: This is done by a SD low-to-high transition while SC is high */
67423 +/* Set I2C stop condition */
67424 +/* This is done by a SD low-to-high transition while SC is high */
67425  USHORT
67426  SiS_SetStop(SiS_Private *SiS_Pr)
67427  {
67428 -  if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF;                               /* TW: (SC->low) */
67429 +  if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF;                               /* (SC->low) */
67430    SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
67431 -                  ~SiS_Pr->SiS_DDC_Data,0x00);                            /* TW: SD->low   */
67432 -  if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF;                              /* TW: SC->high  */
67433 +                  ~SiS_Pr->SiS_DDC_Data,0x00);                            /* SD->low   */
67434 +  if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF;                              /* SC->high  */
67435    SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
67436 -                  ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data);            /* TW: SD->high = stop condition */
67437 -  if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF;                              /* TW: (SC->high) */
67438 +                  ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data);            /* SD->high = stop condition */
67439 +  if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF;                              /* (SC->high) */
67440    return 0;
67441  }
67442  
67443 -/* TW: Write 8 bits of data */
67444 +/* Write 8 bits of data */
67445  USHORT
67446  SiS_WriteDDC2Data(SiS_Private *SiS_Pr, USHORT tempax)
67447  {
67448 @@ -10736,18 +11112,18 @@ SiS_WriteDDC2Data(SiS_Private *SiS_Pr, U
67449  
67450    flag=0x80;
67451    for(i=0;i<8;i++) {
67452 -    SiS_SetSCLKLow(SiS_Pr);                                                  /* TW: SC->low */
67453 +    SiS_SetSCLKLow(SiS_Pr);                                                  /* SC->low */
67454      if(tempax & flag) {
67455        SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
67456 -                      ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data);            /* TW: Write bit (1) to SD */
67457 +                      ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data);            /* Write bit (1) to SD */
67458      } else {
67459        SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
67460 -                      ~SiS_Pr->SiS_DDC_Data,0x00);                            /* TW: Write bit (0) to SD */
67461 +                      ~SiS_Pr->SiS_DDC_Data,0x00);                            /* Write bit (0) to SD */
67462      }
67463 -    SiS_SetSCLKHigh(SiS_Pr);                                                 /* TW: SC->high */
67464 +    SiS_SetSCLKHigh(SiS_Pr);                                                 /* SC->high */
67465      flag >>= 1;
67466    }
67467 -  temp = SiS_CheckACK(SiS_Pr);                                               /* TW: Check acknowledge */
67468 +  temp = SiS_CheckACK(SiS_Pr);                                               /* Check acknowledge */
67469    return(temp);
67470  }
67471  
67472 @@ -10808,27 +11184,27 @@ SiS_DDC2Delay(SiS_Private *SiS_Pr, USHOR
67473    }
67474  }
67475  
67476 -/* TW: Check I2C acknowledge */
67477 +/* Check I2C acknowledge */
67478  /* Returns 0 if ack ok, non-0 if ack not ok */
67479  USHORT
67480  SiS_CheckACK(SiS_Private *SiS_Pr)
67481  {
67482    USHORT tempah;
67483  
67484 -  SiS_SetSCLKLow(SiS_Pr);                                         /* TW: (SC->low) */
67485 +  SiS_SetSCLKLow(SiS_Pr);                                         /* (SC->low) */
67486    SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index,
67487 -                  ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data);     /* TW: (SD->high) */
67488 -  SiS_SetSCLKHigh(SiS_Pr);                                        /* TW: SC->high = clock impulse for ack */
67489 -  tempah = SiS_GetReg1(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);/* TW: Read SD */
67490 -  SiS_SetSCLKLow(SiS_Pr);                                         /* TW: SC->low = end of clock impulse */
67491 -  if(tempah & SiS_Pr->SiS_DDC_Data) return(1);                    /* TW: Ack OK if bit = 0 */
67492 +                  ~SiS_Pr->SiS_DDC_Data,SiS_Pr->SiS_DDC_Data);     /* (SD->high) */
67493 +  SiS_SetSCLKHigh(SiS_Pr);                                        /* SC->high = clock impulse for ack */
67494 +  tempah = SiS_GetReg1(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);/* Read SD */
67495 +  SiS_SetSCLKLow(SiS_Pr);                                         /* SC->low = end of clock impulse */
67496 +  if(tempah & SiS_Pr->SiS_DDC_Data) return(1);                    /* Ack OK if bit = 0 */
67497    else return(0);
67498  }
67499  
67500 -/* TW: End of I2C functions ----------------------- */
67501 +/* End of I2C functions ----------------------- */
67502  
67503  
67504 -/* =============== SiS 310/325/330 O.E.M. ================= */
67505 +/* =============== SiS 315/330 O.E.M. ================= */
67506  
67507  #ifdef SIS315H
67508  
67509 @@ -10838,11 +11214,11 @@ GetRAMDACromptr(SiS_Private *SiS_Pr, PSI
67510    USHORT romptr;
67511  
67512    if(HwDeviceExtension->jChipType < SIS_330) {
67513 -     romptr = ROMAddr[0x128] | (ROMAddr[0x129] << 8);  
67514 +     romptr = ROMAddr[0x128] | (ROMAddr[0x129] << 8);
67515       if(SiS_Pr->SiS_VBType & VB_SIS301B302B)
67516          romptr = ROMAddr[0x12a] | (ROMAddr[0x12b] << 8);
67517    } else {
67518 -     romptr = ROMAddr[0x1a8] | (ROMAddr[0x1a9] << 8);  
67519 +     romptr = ROMAddr[0x1a8] | (ROMAddr[0x1a9] << 8);
67520       if(SiS_Pr->SiS_VBType & VB_SIS301B302B)
67521          romptr = ROMAddr[0x1aa] | (ROMAddr[0x1ab] << 8);
67522    }
67523 @@ -10855,11 +11231,11 @@ GetLCDromptr(SiS_Private *SiS_Pr, PSIS_H
67524    USHORT romptr;
67525  
67526    if(HwDeviceExtension->jChipType < SIS_330) {
67527 -     romptr = ROMAddr[0x120] | (ROMAddr[0x121] << 8);  
67528 +     romptr = ROMAddr[0x120] | (ROMAddr[0x121] << 8);
67529       if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)
67530          romptr = ROMAddr[0x122] | (ROMAddr[0x123] << 8);
67531    } else {
67532 -     romptr = ROMAddr[0x1a0] | (ROMAddr[0x1a1] << 8);  
67533 +     romptr = ROMAddr[0x1a0] | (ROMAddr[0x1a1] << 8);
67534       if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)
67535          romptr = ROMAddr[0x1a2] | (ROMAddr[0x1a3] << 8);
67536    }
67537 @@ -10884,10 +11260,22 @@ GetTVromptr(SiS_Private *SiS_Pr, PSIS_HW
67538  }
67539  
67540  static USHORT
67541 -GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr)
67542 +GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr)
67543  {
67544    USHORT index;
67545 -  
67546 +
67547 +  if((IS_SIS650) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) {
67548 +     if(!(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr))) {
67549 +        if((index = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xf0)) {
67550 +          index >>= 4;
67551 +          index *= 3;
67552 +          if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2;
67553 +           else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) index++;
67554 +           return index;
67555 +       }
67556 +     }
67557 +  }
67558 +
67559    index = SiS_Pr->SiS_LCDResInfo & 0x0F;
67560    if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050)      index -= 5;
67561    else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1600x1200) index -= 6;
67562 @@ -10895,7 +11283,6 @@ GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr)
67563    index *= 3;
67564    if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2;
67565    else if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) index++;
67566 -
67567    return index;
67568  }
67569  
67570 @@ -10945,8 +11332,9 @@ static void
67571  SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
67572               UCHAR *ROMAddr, USHORT ModeNo)
67573  {
67574 -  USHORT delay,index,myindex,temp,romptr=0;
67575 -  
67576 +  USHORT delay=0,index,myindex,temp,romptr=0;
67577 +  BOOLEAN dochiptest = TRUE;
67578 +
67579    if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {                   /* VGA */
67580       
67581       if((ROMAddr) && SiS_Pr->SiS_UseROM) {
67582 @@ -10969,61 +11357,81 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_H
67583          if(SiS_Pr->SiS_IF_DEF_LVDS == 1)
67584             delay = 0x00;
67585       }
67586 -  
67587 +
67588    } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {               /* LCD */
67589 -  
67590 -     index = GetLCDPtrIndexBIOS(SiS_Pr);
67591 -     myindex = GetLCDPtrIndex(SiS_Pr);
67592 -     
67593 -     if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) {        /* 650+30xLV */
67594 -       if(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr)) {
67595 -          if((ROMAddr) && SiS_Pr->SiS_UseROM) {
67596 -#if 0       /* Always use the second pointer on 650; some BIOSes */
67597 -             /* still carry old 301 data at the first location    */  
67598 -            romptr = ROMAddr[0x120] | (ROMAddr[0x121] << 8); 
67599 -            if(SiS_Pr->SiS_VBType & VB_SIS302LV) 
67600 -#endif         
67601 -               romptr = ROMAddr[0x122] | (ROMAddr[0x123] << 8);
67602 -            if(!romptr) return;
67603 -            delay = ROMAddr[(romptr + index)];
67604 -         } else {
67605 -             delay = SiS310_LCDDelayCompensation_650301B[myindex];   
67606 -#if 0       
67607 +
67608 +     BOOLEAN gotitfrompci = FALSE;
67609 +
67610 +     if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return;
67611 +
67612 +     /* This is a piece of typical SiS crap: They code the OEM LCD
67613 +      * delay into the code, at none defined place in the BIOS.
67614 +      * We now have to start doing a PCI subsystem check here.
67615 +      */
67616 +
67617 +     if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
67618 +       if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {
67619 +          gotitfrompci = TRUE;
67620 +          dochiptest = FALSE;
67621 +          delay = 0x03;
67622 +       }
67623 +     }
67624 +
67625 +     if(!gotitfrompci) {
67626 +
67627 +        index = GetLCDPtrIndexBIOS(SiS_Pr, HwDeviceExtension, BaseAddr);
67628 +        myindex = GetLCDPtrIndex(SiS_Pr);
67629 +
67630 +        if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) {     /* 650+30xLV */
67631 +           if(SiS_IsNotM650or651(SiS_Pr,HwDeviceExtension, BaseAddr)) {
67632 +             if((ROMAddr) && SiS_Pr->SiS_UseROM) {
67633 +#if 0          /* Always use the second pointer on 650; some BIOSes */
67634 +                /* still carry old 301 data at the first location    */
67635 +               romptr = ROMAddr[0x120] | (ROMAddr[0x121] << 8);
67636 +               if(SiS_Pr->SiS_VBType & VB_SIS302LV)
67637 +#endif
67638 +                  romptr = ROMAddr[0x122] | (ROMAddr[0x123] << 8);
67639 +               if(!romptr) return;
67640 +               delay = ROMAddr[(romptr + index)];
67641 +            } else {
67642 +                delay = SiS310_LCDDelayCompensation_650301B[myindex];
67643 +#if 0
67644 +               if(SiS_Pr->SiS_VBType & VB_SIS302LV)
67645 +                  delay = SiS310_LCDDelayCompensation_650301B[myindex];
67646 +#endif
67647 +            }
67648 +          } else {
67649 +             delay = SiS310_LCDDelayCompensation_651301LV[myindex];
67650              if(SiS_Pr->SiS_VBType & VB_SIS302LV)
67651 -               delay = SiS310_LCDDelayCompensation_650301B[myindex];
67652 -#endif         
67653 -         }
67654 -       } else {
67655 -          delay = SiS310_LCDDelayCompensation_651301LV[myindex];     
67656 -         if(SiS_Pr->SiS_VBType & VB_SIS302LV)
67657 -            delay = SiS310_LCDDelayCompensation_651302LV[myindex];  
67658 -       }
67659 -     } else {
67660 -        if((ROMAddr) && SiS_Pr->SiS_UseROM &&                          /* 315, 330, 740, 650+301B */
67661 -          (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024)) { 
67662 -           romptr = GetLCDromptr(SiS_Pr, HwDeviceExtension, ROMAddr);
67663 -          if(!romptr) return;
67664 -          delay = ROMAddr[(romptr + index)];
67665 +               delay = SiS310_LCDDelayCompensation_651302LV[myindex];
67666 +          }
67667          } else {
67668 -           delay = SiS310_LCDDelayCompensation_301[myindex];
67669 -           if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
67670 -#if 0        /* This data is (like the one in the BIOS) wrong. */         
67671 -             if(IS_SIS650740) {  /* V */
67672 -                delay = SiS310_LCDDelayCompensation_650301B[myindex];
67673 -             } else {
67674 -#endif       
67675 -                 delay = SiS310_LCDDelayCompensation_3xx301B[myindex];
67676 -#if 0           
67677 +           if((ROMAddr) && SiS_Pr->SiS_UseROM &&                               /* 315, 330, 740, 650+301B */
67678 +             (SiS_Pr->SiS_LCDResInfo != SiS_Pr->SiS_Panel1280x1024)) {
67679 +              romptr = GetLCDromptr(SiS_Pr, HwDeviceExtension, ROMAddr);
67680 +             if(!romptr) return;
67681 +             delay = ROMAddr[(romptr + index)];
67682 +           } else {
67683 +              delay = SiS310_LCDDelayCompensation_301[myindex];
67684 +              if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
67685 +#if 0           /* This data is (like the one in the BIOS) wrong. */
67686 +                if(IS_SIS550650740660) {
67687 +                   delay = SiS310_LCDDelayCompensation_650301B[myindex];
67688 +                } else {
67689 +#endif
67690 +                    delay = SiS310_LCDDelayCompensation_3xx301B[myindex];
67691 +#if 0
67692 +                }
67693 +#endif
67694               }
67695 -#endif       
67696 -          }
67697 -           if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
67698 -             if(IS_SIS650) {
67699 -                 delay = SiS310_LCDDelayCompensation_LVDS650[myindex];
67700 -             } else {
67701 -                delay = SiS310_LCDDelayCompensation_LVDS740[myindex];
67702 +              if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
67703 +                if(IS_SIS650) {
67704 +                    delay = SiS310_LCDDelayCompensation_LVDS650[myindex];
67705 +                } else {
67706 +                   delay = SiS310_LCDDelayCompensation_LVDS740[myindex];
67707 +                }
67708               }
67709 -          }
67710 +           }
67711          }
67712       }
67713       
67714 @@ -11086,16 +11494,18 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_H
67715          }
67716       }
67717    } else {
67718 -     if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) {
67719 +     if(dochiptest && IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) {
67720          temp = (SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0xf0) >> 4;
67721 -        if(temp == 8) {
67722 +        if(temp == 8) {                /* 1400x1050 BIOS */
67723            delay &= 0x0f;
67724            delay |= 0xb0;
67725          } else if(temp == 6) {
67726             delay &= 0x0f;
67727            delay |= 0xc0;
67728 +        } else if(temp > 7) {  /* 1280x1024 BIOS */
67729 +          delay = 0x35;
67730          }
67731 -        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2D,delay);  /* index 2D D[3:0] */
67732 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2D,delay);
67733       } else {
67734          SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0xF0,delay);
67735       }
67736 @@ -11118,7 +11528,7 @@ SetAntiFlicker(SiS_Private *SiS_Pr, PSIS
67737  
67738    if(ROMAddr && SiS_Pr->SiS_UseROM) {
67739       romptr = ROMAddr[0x112] | (ROMAddr[0x113] << 8);
67740 -     if(HwDeviceExtension->jChipType == SIS_330) {
67741 +     if(HwDeviceExtension->jChipType >= SIS_330) {
67742          romptr = ROMAddr[0x192] | (ROMAddr[0x193] << 8);
67743       }
67744    }
67745 @@ -11150,7 +11560,7 @@ SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS
67746  
67747    if(ROMAddr && SiS_Pr->SiS_UseROM) {
67748       romptr = ROMAddr[0x124] | (ROMAddr[0x125] << 8);
67749 -     if(HwDeviceExtension->jChipType == SIS_330) {
67750 +     if(HwDeviceExtension->jChipType >= SIS_330) {
67751          romptr = ROMAddr[0x1a4] | (ROMAddr[0x1a5] << 8);
67752       }
67753    }
67754 @@ -11198,7 +11608,7 @@ SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_
67755  
67756    if(ROMAddr && SiS_Pr->SiS_UseROM) {
67757         OutputSelect = ROMAddr[0xf3];
67758 -       if(HwDeviceExtension->jChipType == SIS_330) {
67759 +       if(HwDeviceExtension->jChipType >= SIS_330) {
67760             OutputSelect = ROMAddr[0x11b];
67761         }
67762    }
67763 @@ -11220,6 +11630,7 @@ SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_
67764                   }
67765                }
67766           }
67767 +        /* PALN : Is this data correct? */
67768           if(temp == EnablePALN) {
67769                if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
67770                   for(i=0x35, j=0; i<=0x38; i++, j++) {
67771 @@ -11247,13 +11658,13 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_H
67772    if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return;
67773  
67774    temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38);        /* if PALM/N not set */
67775 -  temp1 &=  (EnablePALM | EnablePALN);
67776 +  temp1 &= (EnablePALM | EnablePALN);
67777    if(temp1) return;
67778  
67779 -  if (ModeNo<=0x13) {
67780 -    resinfo =  SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
67781 +  if(ModeNo<=0x13) {
67782 +     resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
67783    } else {
67784 -    resinfo =  SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
67785 +     resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
67786    }
67787  
67788    temp = GetTVPtrIndex(SiS_Pr);
67789 @@ -11262,17 +11673,17 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_H
67790     */
67791    if((ROMAddr) && SiS_Pr->SiS_UseROM) {
67792       romptr = ROMAddr[0x116] | (ROMAddr[0x117] << 8);
67793 -     if(HwDeviceExtension->jChipType == SIS_330) {
67794 +     if(HwDeviceExtension->jChipType >= SIS_330) {
67795          romptr = ROMAddr[0x196] | (ROMAddr[0x197] << 8);
67796       }
67797       if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
67798          romptr = ROMAddr[0x11c] | (ROMAddr[0x11d] << 8);
67799 -       if(HwDeviceExtension->jChipType == SIS_330) {
67800 +       if(HwDeviceExtension->jChipType >= SIS_330) {
67801            romptr = ROMAddr[0x19c] | (ROMAddr[0x19d] << 8);
67802         }
67803         if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (!(SiS_Pr->SiS_SetFlag & TVSimuMode))) {
67804            romptr = ROMAddr[0x116] | (ROMAddr[0x117] << 8);
67805 -          if(HwDeviceExtension->jChipType == SIS_330) {
67806 +          if(HwDeviceExtension->jChipType >= SIS_330) {
67807                romptr = ROMAddr[0x196] | (ROMAddr[0x197] << 8);
67808             }
67809         }
67810 @@ -11296,19 +11707,19 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_H
67811       }
67812    }
67813  
67814 -  if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {    /* TW: 650/301LV: (VB_SIS301LV | VB_SIS302LV)) */
67815 +  if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {    /* 650/301LV: (VB_SIS301LV | VB_SIS302LV)) */
67816       if((!(SiS_Pr->SiS_VBInfo & SetPALTV)) && (ModeNo > 0x13)) {
67817 -        if(resinfo == 6) {
67818 +        if(resinfo == SIS_RI_640x480) {
67819               SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x31,0x21);
67820               SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x32,0xf0);
67821               SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x33,0xf5);
67822               SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x34,0x7f);
67823 -       } else if (resinfo == 7) {
67824 +       } else if (resinfo == SIS_RI_800x600) {
67825               SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x31,0x21);
67826               SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x32,0xf0);
67827               SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x33,0xf5);
67828               SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x34,0x7f);
67829 -       } else if (resinfo == 8) {
67830 +       } else if (resinfo == SIS_RI_1024x768) {
67831               SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x31,0x1e);
67832               SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x32,0x8b);
67833               SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x33,0xfb);
67834 @@ -11323,7 +11734,9 @@ SiS_OEM310Setting(SiS_Private *SiS_Pr, P
67835                    UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
67836  {
67837     SetDelayComp(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo);
67838 -   /* TW: The TV functions are not for LVDS */
67839 +
67840 +   if(SiS_Pr->UseCustomMode) return;
67841 +
67842     if( (SiS_Pr->SiS_IF_DEF_LVDS == 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) {
67843         SetAntiFlicker(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
67844         SetPhaseIncr(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
67845 @@ -11335,7 +11748,7 @@ SiS_OEM310Setting(SiS_Private *SiS_Pr, P
67846  }
67847  
67848  /* FinalizeLCD
67849 - * This finalizes some Part1 registers for the very panel used.
67850 + * This finalizes some CRT2 registers for the very panel used.
67851   * If we have a backup if these registers, we use it; otherwise
67852   * we set the register according to most BIOSes. However, this
67853   * function looks quite different in every BIOS, so you better
67854 @@ -11350,6 +11763,11 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USH
67855  
67856    if(!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) return;
67857  
67858 +  if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return;
67859 +  if(SiS_Pr->UseCustomMode) return;
67860 +
67861 +  if(SiS_Pr->SiS_CustomT == CUT_COMPAQ12802) return;
67862 +
67863    if(ModeNo <= 0x13) {
67864         resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
67865         modeflag =  SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
67866 @@ -11358,20 +11776,34 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USH
67867         modeflag =  SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
67868    }
67869  
67870 +  if(IS_SIS650) {
67871 +     if((SiS_GetReg1(SiS_Pr->SiS_P3d4, 0x5f) & 0xf0)) {
67872 +        SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x03);
67873 +     }
67874 +  }
67875 +
67876    if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
67877       if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
67878          SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x2a,0x00);
67879         SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x30,0x00);
67880         SiS_SetReg1(SiS_Pr->SiS_Part4Port,0x34,0x10);
67881 +     } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1280x1024) {   /* For all panels? */
67882 +        /* Maybe ACER only? */
67883 +        SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,0x01);
67884       }
67885       tempch = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36);
67886       tempch &= 0xf0;
67887       tempch >>= 4;
67888       if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
67889 +        if(tempch == 0x03) {
67890 +          SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x02);
67891 +          SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1b,0x25);
67892 +          SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1c,0x00);
67893 +          SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1d,0x1b);
67894 +       }
67895         if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1400x1050) {
67896            SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x1f,0x76);
67897 -       }
67898 -       if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {       
67899 +       } else if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
67900            if((SiS_Pr->Backup == TRUE) && (SiS_Pr->Backup_Mode == ModeNo)) {
67901               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,SiS_Pr->Backup_14);
67902               SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x15,SiS_Pr->Backup_15);
67903 @@ -11387,14 +11819,14 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USH
67904                SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,0x90);
67905                if(ModeNo <= 0x13) {
67906                   SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x11);
67907 -                 if((resinfo == 0) && (resinfo == 2)) return;
67908 +                 if((resinfo == 0) || (resinfo == 2)) return;
67909                   SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x18);
67910 -                 if((resinfo == 1) && (resinfo == 3)) return;
67911 +                 if((resinfo == 1) || (resinfo == 3)) return;
67912                }
67913                SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x02);
67914 -              if((ModeNo > 0x13) && (resinfo == 8)) {
67915 +              if((ModeNo > 0x13) && (resinfo == SIS_RI_1024x768)) {
67916                   SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,0x02);  /* 1.10.7u */
67917 -#if 0         
67918 +#if 0
67919                   tempbx = 806;  /* 0x326 */                     /* other older BIOSes */
67920                   tempbx--;
67921                   temp = tempbx & 0xff;
67922 @@ -11449,7 +11881,7 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USH
67923         tempbl = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x04);
67924         tempbx = (tempbh << 8) | tempbl;
67925         if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
67926 -          if((resinfo == 8) || (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD))) {
67927 +          if((resinfo == SIS_RI_1024x768) || (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD))) {
67928               if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
67929                 tempbx = 770;
67930               } else {
67931 @@ -11477,67 +11909,56 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USH
67932    }
67933  }
67934  
67935 -#if 0
67936 -/* TW: New and checked from 650/301LV BIOS */
67937 -/* This might clash with newer "FinalizeLCD()" function */
67938 +#endif
67939 +
67940 +
67941 +/*  =================  SiS 300 O.E.M. ================== */
67942 +
67943 +#ifdef SIS300
67944 +
67945  void
67946 -SiS_OEMLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
67947 -                  UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
67948 +SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
67949 +              UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex, USHORT RefTabIndex)
67950  {
67951 -   USHORT tempbx,tempah,tempbl,tempbh,tempcl;
67952 -
67953 -   if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return;
67954 +  USHORT crt2crtc=0, modeflag, myindex=0;
67955 +  UCHAR  temp;
67956 +  int i;
67957  
67958 -   if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
67959 -      SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension,BaseAddr);
67960 -      tempbh = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x1a);
67961 -      tempbh &= 0x38;
67962 -      tempbh >>= 3;
67963 -      tempbl = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x18);
67964 -      tempbx = (tempbh << 8) | tempbl;
67965 -      if(SiS_Pr->SiS_LCDTypeInfo == 1)  tempbx -= 0x12;
67966 -      SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,tempbx & 0x00ff);
67967 -      tempah = (tempbx & 0xff00) >> 8;
67968 -      tempah &= 0x07;
67969 -      tempah <<= 3;
67970 -      SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1a,0xc7,tempah);
67971 -      tempah = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x19);
67972 -      tempah &= 0x0f;
67973 -      if(SiS_Pr->SiS_LCDTypeInfo == 1)  tempah -= 2;
67974 -      tempah &= 0x0f;
67975 -      SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0xF0,tempah);
67976 -      tempah = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x14);
67977 -      if(SiS_Pr->SiS_LCDTypeInfo == 1)  tempah++;
67978 -      tempah -= 8;
67979 -      SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x14,tempah);
67980 -   } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
67981 -      tempcl = tempbh = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x01);
67982 -      tempbh &= 0x70;
67983 -      tempbh >>= 4;
67984 -      tempbl = SiS_GetReg1(SiS_Pr->SiS_Part2Port,0x04);
67985 -      tempbx = (tempbh << 8) | tempbl;
67986 -      if(SiS_Pr->SiS_LCDTypeInfo == 1)  {
67987 -           tempbx -= 0x1e;
67988 -          tempcl &= 0x0f;
67989 -          tempcl -= 4;
67990 -          tempcl &= 0x0f;
67991 -      }
67992 -      tempbl = tempbx & 0x00ff;
67993 -      tempbh = (tempbx >> 8) & 0x00ff;
67994 -      SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x04,tempbl);
67995 -      tempbh <<= 4;
67996 -      tempbh |= tempcl;
67997 -      SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,tempbh);
67998 -   }
67999 -}
68000 -#endif
68001 +  if(ModeNo <= 0x13) {
68002 +        modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
68003 +       crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
68004 +  } else {
68005 +        modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
68006 +       crt2crtc = SiS_Pr->SiS_RefIndex[RefTabIndex].Ext_CRT2CRTC;
68007 +  }
68008  
68009 -#endif
68010 +  crt2crtc &= 0x3f;
68011  
68012 +  if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) {
68013 +     SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xdf);
68014 +  }
68015  
68016 -/*  =================  SiS 300 O.E.M. ================== */
68017 +  if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
68018 +     if(modeflag & HalfDCLK) myindex = 1;
68019  
68020 -#ifdef SIS300
68021 +     if(SiS_LowModeStuff(SiS_Pr,ModeNo,HwDeviceExtension)) {
68022 +        for(i=0; i<7; i++) {
68023 +           if(barco_p1[myindex][crt2crtc][i][0]) {
68024 +             SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,
68025 +                             barco_p1[myindex][crt2crtc][i][0],
68026 +                             barco_p1[myindex][crt2crtc][i][2],
68027 +                             barco_p1[myindex][crt2crtc][i][1]);
68028 +          }
68029 +        }
68030 +     }
68031 +     temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00);
68032 +     if(temp & 0x80) {
68033 +        temp = SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x18);
68034 +        temp++;
68035 +        SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x18,temp);
68036 +     }
68037 +  }
68038 +}
68039  
68040  #if 0   /* Not used */
68041  static USHORT
68042 @@ -11582,7 +12003,7 @@ GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_H
68043  
68044    if(HwDeviceExtension->jChipType == SIS_300) {
68045  
68046 -    tempbx = SiS_Pr->SiS_LCDResInfo - 2;
68047 +    tempbx = (SiS_GetReg1(SiS_Pr->SiS_P3d4,0x36) & 0x0f) - 2;
68048      if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx += 4;
68049      if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel1024x768) {
68050         if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 3;
68051 @@ -11636,24 +12057,29 @@ SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS
68052  {
68053    USHORT index,temp,romptr=0;
68054  
68055 +  if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_PanelCustom) return;
68056 +
68057    if((ROMAddr) && SiS_Pr->SiS_UseROM) {
68058       if(!(ROMAddr[0x237] & 0x01)) return;
68059       if(!(ROMAddr[0x237] & 0x02)) return;
68060       romptr = ROMAddr[0x24b] | (ROMAddr[0x24c] << 8);
68061    }
68062  
68063 -  /* TW: The Panel Compensation Delay should be set according to tables
68064 -   *     here. Unfortunately, various BIOS versions don't case about
68065 -   *     a uniform way using eg. ROM byte 0x220, but use different
68066 -   *     hard coded delays (0x04, 0x20, 0x18) in SetGroup1().
68067 -   *     Thus we don't set this if the user select a custom pdc or if
68068 -   *     we otherwise detected a valid pdc.
68069 +  /* The Panel Compensation Delay should be set according to tables
68070 +   * here. Unfortunately, various BIOS versions don't case about
68071 +   * a uniform way using eg. ROM byte 0x220, but use different
68072 +   * hard coded delays (0x04, 0x20, 0x18) in SetGroup1().
68073 +   * Thus we don't set this if the user select a custom pdc or if
68074 +   * we otherwise detected a valid pdc.
68075     */
68076    if(HwDeviceExtension->pdc) return;
68077  
68078    temp = GetOEMLCDPtr(SiS_Pr,HwDeviceExtension, ROMAddr, 0);
68079  
68080 -  index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_LCDDelayIndex;
68081 +  if(SiS_Pr->UseCustomMode)
68082 +     index = 0;
68083 +  else
68084 +     index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_LCDDelayIndex;
68085  
68086    if(HwDeviceExtension->jChipType != SIS_300) {
68087         if(romptr) {
68088 @@ -11700,9 +12126,9 @@ SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS
68089  
68090  static void
68091  SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
68092 -               UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
68093 +              UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex)
68094  {
68095 -#if 0  /* TW: Unfinished; VData table missing */
68096 +#if 0  /* Unfinished; Data table missing */
68097    USHORT index,temp;
68098  
68099    if((ROMAddr) && SiS_Pr->SiS_UseROM) {
68100 @@ -11899,25 +12325,29 @@ SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_
68101  
68102  void
68103  SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
68104 -                 USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo)
68105 +                 USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
68106 +                 USHORT RefTableIndex)
68107  {
68108 -  USHORT ModeIdIndex;
68109 +  USHORT OEMModeIdIndex=0;
68110  
68111 -  ModeIdIndex = SiS_SearchVBModeID(SiS_Pr,ROMAddr,&ModeNo);
68112 -  if(!(ModeIdIndex)) return;
68113 +  if(!SiS_Pr->UseCustomMode) {
68114 +     OEMModeIdIndex = SiS_SearchVBModeID(SiS_Pr,ROMAddr,&ModeNo);
68115 +     if(!(OEMModeIdIndex)) return;
68116 +  }
68117  
68118    if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
68119 -       SetOEMLCDDelay(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
68120 +       SetOEMLCDDelay(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,OEMModeIdIndex);
68121         if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
68122 -            SetOEMLCDData(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
68123 +            SetOEMLCDData(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,OEMModeIdIndex);
68124         }
68125    }
68126 +  if(SiS_Pr->UseCustomMode) return;
68127    if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
68128 -       SetOEMTVDelay(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
68129 +       SetOEMTVDelay(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,OEMModeIdIndex);
68130         if(SiS_Pr->SiS_IF_DEF_LVDS == 0) {
68131 -                       SetOEMAntiFlicker(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
68132 -               SetOEMPhaseIncr(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
68133 -                       SetOEMYFilter(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,ModeIdIndex);
68134 +                       SetOEMAntiFlicker(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,OEMModeIdIndex);
68135 +               SetOEMPhaseIncr(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,OEMModeIdIndex);
68136 +                       SetOEMYFilter(SiS_Pr,HwDeviceExtension,BaseAddr,ROMAddr,ModeNo,OEMModeIdIndex);
68137         }
68138    }
68139  }
68140 --- linux-2.6.0-test6/drivers/video/sis/init301.h       2003-06-14 12:18:21.000000000 -0700
68141 +++ 25/drivers/video/sis/init301.h      2003-10-05 00:34:22.000000000 -0700
68142 @@ -1,20 +1,47 @@
68143 -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init301.h,v 1.4 2000/12/02 01:16:17 dawes Exp $ */
68144 +/* $XFree86$ */
68145 +/*
68146 + * Data and prototypes for init301.c
68147 + *
68148 + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
68149 + *
68150 + * If distributed as part of the linux kernel, the contents of this file
68151 + * is entirely covered by the GPL.
68152 + *
68153 + * Otherwise, the following terms apply:
68154 + *
68155 + * Permission to use, copy, modify, distribute, and sell this software and its
68156 + * documentation for any purpose is hereby granted without fee, provided that
68157 + * the above copyright notice appear in all copies and that both that
68158 + * copyright notice and this permission notice appear in supporting
68159 + * documentation, and that the name of the copyright holder not be used in
68160 + * advertising or publicity pertaining to distribution of the software without
68161 + * specific, written prior permission.  The copyright holder makes no representations
68162 + * about the suitability of this software for any purpose.  It is provided
68163 + * "as is" without express or implied warranty.
68164 + *
68165 + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
68166 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
68167 + * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
68168 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
68169 + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
68170 + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
68171 + * PERFORMANCE OF THIS SOFTWARE.
68172 + *
68173 + * Author:     Thomas Winischhofer <thomas@winischhofer.net>
68174 + *
68175 + * Based on code by Silicon Intergrated Systems
68176 + *
68177 + */
68178 +
68179  #ifndef  _INIT301_
68180  #define  _INIT301_
68181  
68182  #include "osdef.h"
68183 +
68184  #include "initdef.h"
68185  #include "vgatypes.h"
68186  #include "vstruct.h"
68187  
68188 -#ifdef TC
68189 -#include <stdio.h>
68190 -#include <string.h>
68191 -#include <conio.h>
68192 -#include <dos.h>
68193 -#include <stdlib.h>
68194 -#endif
68195 -
68196  #ifdef LINUX_XF86
68197  #include "xf86.h"
68198  #include "xf86Pci.h"
68199 @@ -24,6 +51,9 @@
68200  #endif
68201  
68202  #ifdef LINUX_KERNEL
68203 +#ifdef SIS_CP
68204 +#undef SIS_CP
68205 +#endif
68206  #include <linux/config.h>
68207  #include <linux/version.h>
68208  #include <asm/io.h>
68209 @@ -35,24 +65,60 @@
68210  #endif
68211  #endif
68212  
68213 -#ifdef WIN2000
68214 -#include <stdio.h>
68215 -#include <string.h>
68216 -#include <miniport.h>
68217 -#include "dderror.h"
68218 -#include "devioctl.h"
68219 -#include "miniport.h"
68220 -#include "ntddvdeo.h"
68221 -#include "video.h"
68222 -#include "sisv.h"
68223 -#endif
68224 +const UCHAR SiS_HiVisionTable[3][64] = {
68225 +  {
68226 +    0x17, 0x1d, 0x03, 0x09, 0x05, 0x06, 0x0c, 0x0c,
68227 +    0x94, 0x49, 0x01, 0x0a, 0x06, 0x0d, 0x04, 0x0a,
68228 +    0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x1b,
68229 +    0x0c, 0x50, 0x00, 0x97, 0x00, 0xd4, 0x4a, 0x17,
68230 +    0x7d, 0x05, 0x4b, 0x00, 0x00, 0xe2, 0x00, 0x02,
68231 +    0x03, 0x0a, 0x65, 0x9d, 0x08, 0x92, 0x8f, 0x40,
68232 +    0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x14, 0x53,
68233 +    0x00, 0x40, 0x44, 0x00, 0xdb, 0x02, 0x3b, 0x00
68234 +  },
68235 +  {
68236 +    0x1d, 0x1d, 0x06, 0x09, 0x0b, 0x0c, 0x0c, 0x0c,
68237 +    0x98, 0x0a, 0x01, 0x0d, 0x06, 0x0d, 0x04, 0x0a,
68238 +    0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x3f,
68239 +    0x0c, 0x50, 0xb2, 0x2e, 0x16, 0xb5, 0xf4, 0x03,
68240 +    0x7d, 0x11, 0x7d, 0xea, 0x30, 0x36, 0x18, 0x96,
68241 +    0x21, 0x0a, 0x58, 0xee, 0x42, 0x92, 0x0f, 0x40,
68242 +    0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x04, 0xf3,
68243 +    0x00, 0x40, 0x11, 0x00, 0xfc, 0xff, 0x32, 0x00
68244 +  },
68245 +  {
68246 +    0x13, 0x1d, 0xe8, 0x09, 0x09, 0xed, 0x0c, 0x0c,
68247 +    0x98, 0x0a, 0x01, 0x0c, 0x06, 0x0d, 0x04, 0x0a,
68248 +    0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x3f,
68249 +    0xed, 0x50, 0x70, 0x9f, 0x16, 0x59, 0x2b, 0x13,
68250 +    0x27, 0x0b, 0x27, 0xfc, 0x30, 0x27, 0x1c, 0xb0,
68251 +    0x4b, 0x4b, 0x6f, 0x2f, 0x63, 0x92, 0x0f, 0x40,
68252 +    0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x14, 0x2a,
68253 +    0x00, 0x40, 0x11, 0x00, 0xfc, 0xff, 0x32, 0x00
68254 +  }
68255 +};
68256  
68257 -#if 0
68258 -extern   const USHORT   SiS_MDA_DAC[];
68259 -extern   const USHORT   SiS_CGA_DAC[];
68260 -extern   const USHORT   SiS_EGA_DAC[];
68261 -extern   const USHORT   SiS_VGA_DAC[];
68262 -#endif
68263 +const UCHAR SiS_HiTVGroup3_1[] = {
68264 +    0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x13,
68265 +    0xb1, 0x41, 0x62, 0x62, 0xff, 0xf4, 0x45, 0xa6,
68266 +    0x25, 0x2f, 0x67, 0xf6, 0xbf, 0xff, 0x8e, 0x20,
68267 +    0xac, 0xda, 0x60, 0xfe, 0x6a, 0x9a, 0x06, 0x10,
68268 +    0xd1, 0x04, 0x18, 0x0a, 0xff, 0x80, 0x00, 0x80,
68269 +    0x3b, 0x77, 0x00, 0xef, 0xe0, 0x10, 0xb0, 0xe0,
68270 +    0x10, 0x4f, 0x0f, 0x0f, 0x05, 0x0f, 0x08, 0x6e,
68271 +    0x1a, 0x1f, 0x25, 0x2a, 0x4c, 0xaa, 0x01
68272 +};
68273 +
68274 +const UCHAR SiS_HiTVGroup3_2[] = {
68275 +    0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x7a,
68276 +    0x54, 0x41, 0xe7, 0xe7, 0xff, 0xf4, 0x45, 0xa6,
68277 +    0x25, 0x2f, 0x67, 0xf6, 0xbf, 0xff, 0x8e, 0x20,
68278 +    0xac, 0x6a, 0x60, 0x2b, 0x52, 0xcd, 0x61, 0x10,
68279 +    0x51, 0x04, 0x18, 0x0a, 0x1f, 0x80, 0x00, 0x80,
68280 +    0xff, 0xa4, 0x04, 0x2b, 0x94, 0x21, 0x72, 0x94,
68281 +    0x26, 0x05, 0x01, 0x0f, 0xed, 0x0f, 0x0a, 0x64,
68282 +    0x18, 0x1d, 0x23, 0x28, 0x4c, 0xaa, 0x01
68283 +};
68284  
68285  extern   BOOLEAN  SiS_SearchVBModeID(SiS_Private *SiS_Pr, UCHAR *RomAddr, USHORT *);
68286  
68287 @@ -77,7 +143,8 @@ void     SiS_GetCRT2PtrA(SiS_Private *Si
68288                           USHORT RefreshRateTableIndex,USHORT *CRT2Index,USHORT *ResIndex);
68289  #endif
68290  void     SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
68291 -                            USHORT RefreshRateTableIndex,USHORT *CRT2Index, USHORT *ResIndex);
68292 +                            USHORT RefreshRateTableIndex,USHORT *CRT2Index, USHORT *ResIndex,
68293 +                            PSIS_HW_DEVICE_INFO HwDeviceExtension);
68294  void     SiS_GetCRT2Data301(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
68295                              USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension);
68296  USHORT   SiS_GetResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex);
68297 @@ -129,7 +196,6 @@ void     SiS_GetVBInfo(SiS_Private *SiS_
68298  BOOLEAN  SiS_BridgeIsOn(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO);
68299  BOOLEAN  SiS_BridgeIsEnable(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO);
68300  BOOLEAN  SiS_BridgeInSlave(SiS_Private *SiS_Pr);
68301 -void     SiS_PresetScratchregister(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension);
68302  void     SiS_SetTVSystem(SiS_Private *SiS_Pr);
68303  void     SiS_LongWait(SiS_Private *SiS_Pr);
68304  USHORT   SiS_GetQueueConfig(SiS_Private *SiS_Pr);
68305 @@ -149,7 +215,7 @@ void     SiS_GetLVDSDesPtrA(SiS_Private 
68306                              USHORT RefreshRateTableIndex,USHORT *PanelIndex,USHORT *ResIndex);
68307  #endif                     
68308  void     SiS_SetTPData(SiS_Private *SiS_Pr);
68309 -void     SiS_WhatIsThis(SiS_Private *SiS_Pr, USHORT myvbinfo);
68310 +void     SiS_SetChrontelGPIO(SiS_Private *SiS_Pr, USHORT myvbinfo);
68311  void     SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
68312                           USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension);
68313  void     SiS_SetCHTVReg(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
68314 @@ -178,30 +244,28 @@ USHORT   SiS_SetSCLKHigh(SiS_Private *Si
68315  USHORT   SiS_ReadDDC2Data(SiS_Private *SiS_Pr, USHORT tempax);
68316  USHORT   SiS_WriteDDC2Data(SiS_Private *SiS_Pr, USHORT tempax);
68317  USHORT   SiS_CheckACK(SiS_Private *SiS_Pr);
68318 -USHORT   SiS_ReadLCDDDC(SiS_Private *SiS_Pr, USHORT length, unsigned char *buffer);
68319 -#ifdef LINUX_XF86
68320 -USHORT   SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS);
68321 -USHORT   SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS);
68322 -#endif
68323 +
68324  #ifdef SIS315H
68325  void     SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
68326                             UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex);
68327  void     SiS_OEMLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
68328 -                    UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex);
68329 +                    UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,USHORT RefreshRateTableIndex);
68330  #endif
68331  #ifdef SIS300
68332  void     SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
68333 -                           UCHAR *ROMAddr,USHORT ModeNo);
68334 +                           UCHAR *ROMAddr,USHORT ModeNo, USHORT ModeIdIndex, USHORT RefTabindex);
68335 +void     SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr,
68336 +                       UCHAR *ROMAddr, USHORT ModeNo, USHORT ModeIdIndex,USHORT RefTableIndex);
68337  #endif
68338  BOOLEAN  SiS_LowModeStuff(SiS_Private *SiS_Pr, USHORT ModeNo,PSIS_HW_DEVICE_INFO HwDeviceExtension);
68339  
68340 -BOOLEAN  SiS_GetLCDResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, USHORT ModeIdIndex,
68341 +void     SiS_GetLCDResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo, USHORT ModeIdIndex,
68342                             PSIS_HW_DEVICE_INFO HwDeviceExtension);
68343  /* void    SiS_CHACRT1CRTC(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
68344                          USHORT RefreshRateTableIndex); */
68345  
68346 -BOOLEAN  SiS_SetCRT2Group301(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
68347 -                             PSIS_HW_DEVICE_INFO HwDeviceExtension);
68348 +BOOLEAN  SiS_SetCRT2Group(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
68349 +                          PSIS_HW_DEVICE_INFO HwDeviceExtension);
68350  void     SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
68351                         PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT RefreshRateTableIndex);
68352  void     SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
68353 @@ -237,19 +301,19 @@ void     SiS_VBWait(SiS_Private *SiS_Pr)
68354  void     SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension);
68355  void     SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension);
68356  
68357 -void     SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr);
68358 +void     SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension);
68359  void     SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr);
68360  #ifdef SIS315H
68361  void     SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
68362                              USHORT BaseAddr);
68363 -void     SiS_Chrontel701xOff(SiS_Private *SiS_Pr);
68364 +void     SiS_Chrontel701xOff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension);
68365  void     SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr);
68366  void     SiS_ChrontelDoSomething4(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr);
68367  void     SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr);
68368  void     SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr);
68369  void     SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr);
68370  BOOLEAN  SiS_WeHaveBacklightCtrl(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr);
68371 -void     SiS_ChrontelPowerSequencing(SiS_Private *SiS_Pr);
68372 +void     SiS_ChrontelPowerSequencing(SiS_Private *SiS_Pr,  PSIS_HW_DEVICE_INFO HwDeviceExtension);
68373  void     SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr);
68374  #ifdef NEWCH701x
68375  void     SiS_ChrontelDoSomething5(SiS_Private *SiS_Pr);
68376 @@ -289,73 +353,21 @@ extern   void     SiS_LoadDAC(SiS_Privat
68377  extern   UCHAR    SiS_Get310DRAMType(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension);
68378  #endif
68379  
68380 -#ifdef LINUX_XF86
68381  /* DDC functions */
68382 -USHORT   SiS_InitDDCRegs(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum, USHORT DDCdatatype, BOOLEAN checkcr32);
68383 +USHORT   SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine,
68384 +                         USHORT adaptnum, USHORT DDCdatatype, BOOLEAN checkcr32);
68385  USHORT   SiS_WriteDABDDC(SiS_Private *SiS_Pr);
68386  USHORT   SiS_PrepareReadDDC(SiS_Private *SiS_Pr);
68387  USHORT   SiS_PrepareDDC(SiS_Private *SiS_Pr);
68388  void     SiS_SendACK(SiS_Private *SiS_Pr, USHORT yesno);
68389  USHORT   SiS_DoProbeDDC(SiS_Private *SiS_Pr);
68390  USHORT   SiS_ProbeDDC(SiS_Private *SiS_Pr);
68391 -USHORT   SiS_ReadDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT DDCdatatype, unsigned char *buffer);
68392 -USHORT   SiS_HandleDDC(SiS_Private *SiS_Pr, SISPtr pSiS, USHORT adaptnum,
68393 -                       USHORT DDCdatatype, unsigned char *buffer);
68394 +USHORT   SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer);
68395 +USHORT   SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine,
68396 +                      USHORT adaptnum, USHORT DDCdatatype, unsigned char *buffer);
68397 +#ifdef LINUX_XF86
68398 +USHORT   SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS);
68399 +USHORT   SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS);
68400  #endif
68401  
68402 -const UCHAR SiS_HiVisionTable[3][64] = {
68403 -  { 
68404 -    0x17, 0x1d, 0x03, 0x09, 0x05, 0x06, 0x0c, 0x0c,
68405 -    0x94, 0x49, 0x01, 0x0a, 0x06, 0x0d, 0x04, 0x0a,
68406 -    0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x1b,
68407 -    0x0c, 0x50, 0x00, 0x97, 0x00, 0xd4, 0x4a, 0x17,
68408 -    0x7d, 0x05, 0x4b, 0x00, 0x00, 0xe2, 0x00, 0x02,
68409 -    0x03, 0x0a, 0x65, 0x9d, 0x08, 0x92, 0x8f, 0x40,
68410 -    0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x14, 0x53,
68411 -    0x00, 0x40, 0x44, 0x00, 0xdb, 0x02, 0x3b, 0x00
68412 -  },
68413 -  { 
68414 -    0x1d, 0x1d, 0x06, 0x09, 0x0b, 0x0c, 0x0c, 0x0c,
68415 -    0x98, 0x0a, 0x01, 0x0d, 0x06, 0x0d, 0x04, 0x0a,
68416 -    0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x3f,
68417 -    0x0c, 0x50, 0xb2, 0x2e, 0x16, 0xb5, 0xf4, 0x03,
68418 -    0x7d, 0x11, 0x7d, 0xea, 0x30, 0x36, 0x18, 0x96,
68419 -    0x21, 0x0a, 0x58, 0xee, 0x42, 0x92, 0x0f, 0x40,
68420 -    0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x04, 0xf3,
68421 -    0x00, 0x40, 0x11, 0x00, 0xfc, 0xff, 0x32, 0x00
68422 -  },
68423 -  { 
68424 -    0x13, 0x1d, 0xe8, 0x09, 0x09, 0xed, 0x0c, 0x0c, 
68425 -    0x98, 0x0a, 0x01, 0x0c, 0x06, 0x0d, 0x04, 0x0a, 
68426 -    0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x3f, 
68427 -    0xed, 0x50, 0x70, 0x9f, 0x16, 0x59, 0x2b, 0x13, 
68428 -    0x27, 0x0b, 0x27, 0xfc, 0x30, 0x27, 0x1c, 0xb0, 
68429 -    0x4b, 0x4b, 0x6f, 0x2f, 0x63, 0x92, 0x0f, 0x40, 
68430 -    0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x14, 0x2a, 
68431 -    0x00, 0x40, 0x11, 0x00, 0xfc, 0xff, 0x32, 0x00 
68432 -  }
68433 -};
68434 -
68435 -const UCHAR SiS_HiTVGroup3_1[] = {
68436 -    0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x13,
68437 -    0xb1, 0x41, 0x62, 0x62, 0xff, 0xf4, 0x45, 0xa6,
68438 -    0x25, 0x2f, 0x67, 0xf6, 0xbf, 0xff, 0x8e, 0x20,
68439 -    0xac, 0xda, 0x60, 0xfe, 0x6a, 0x9a, 0x06, 0x10,
68440 -    0xd1, 0x04, 0x18, 0x0a, 0xff, 0x80, 0x00, 0x80,
68441 -    0x3b, 0x77, 0x00, 0xef, 0xe0, 0x10, 0xb0, 0xe0,
68442 -    0x10, 0x4f, 0x0f, 0x0f, 0x05, 0x0f, 0x08, 0x6e,
68443 -    0x1a, 0x1f, 0x25, 0x2a, 0x4c, 0xaa, 0x01
68444 -};
68445 -
68446 -const UCHAR SiS_HiTVGroup3_2[] = {
68447 -    0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x7a,
68448 -    0x54, 0x41, 0xe7, 0xe7, 0xff, 0xf4, 0x45, 0xa6,
68449 -    0x25, 0x2f, 0x67, 0xf6, 0xbf, 0xff, 0x8e, 0x20,
68450 -    0xac, 0x6a, 0x60, 0x2b, 0x52, 0xcd, 0x61, 0x10,
68451 -    0x51, 0x04, 0x18, 0x0a, 0x1f, 0x80, 0x00, 0x80,
68452 -    0xff, 0xa4, 0x04, 0x2b, 0x94, 0x21, 0x72, 0x94,
68453 -    0x26, 0x05, 0x01, 0x0f, 0xed, 0x0f, 0x0a, 0x64,
68454 -    0x18, 0x1d, 0x23, 0x28, 0x4c, 0xaa, 0x01
68455 -};
68456 -
68457  #endif
68458 --- linux-2.6.0-test6/drivers/video/sis/init.c  2003-06-14 12:18:05.000000000 -0700
68459 +++ 25/drivers/video/sis/init.c 2003-10-05 00:34:22.000000000 -0700
68460 @@ -1,24 +1,17 @@
68461  /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init.c,v 1.3 2002/24/04 01:16:16 dawes Exp $ */
68462  /*
68463 - * Mode switching code (CRT1 section) for SiS 300/540/630/730/315/550/650/740/330
68464 + * Mode switching code (CRT1 section) for
68465 + * SiS 300/540/630/730/315/550/650/M650/651/M652/740/330/660/M660/760
68466   * (Universal module for Linux kernel framebuffer and XFree86 4.x)
68467   *
68468   * Assembler-To-C translation
68469 - * Copyright 2002 by Thomas Winischhofer <thomas@winischhofer.net>
68470 - * Minor parts Copyright SiS, Inc.
68471 + * Copyright 2002, 2003 by Thomas Winischhofer <thomas@winischhofer.net>
68472 + * Formerly based on non-functional code-fragements by SiS, Inc.
68473   *
68474 - * Based on BIOS
68475 - *     1.10.07, 1.10a for 650/CH7019
68476 - *     1.11.21a for 740/CH7019
68477 - *     1.11.05 for 650/LVDS (w/o Chrontel)
68478 - *     1.07.1b, 1.11.6s, 1.11.6w, 1.11.7w, 1.11.8r for 650/301(B/LV)
68479 - *     2.04.50 (I) and 2.04.5c (II) for 630/301(B)
68480 - *     2.06.50 for 630/301B (dual VGA)
68481 - *     2.02.3b, 2.03.02, 2.04.5c, 2.07a and 2.08.b3 for 630/LVDS/LVDS+CH7005
68482 - *     2.04.5c, 2.04.6c for 730+LVDS+CH7005
68483 - *     1.09b for 315/301(B)
68484 - *     1.16.51 for 300+301LV (ECS A907)
68485 - *     1.01.03 for 330 (Xabre 400)
68486 + * If distributed as part of the linux kernel, the contents of this file
68487 + * is entirely covered by the GPL.
68488 + *
68489 + * Otherwise, the following terms apply:
68490   *
68491   * Permission to use, copy, modify, distribute, and sell this software and its
68492   * documentation for any purpose is hereby granted without fee, provided that
68493 @@ -61,12 +54,12 @@
68494  #ifdef LINUX_XF86
68495  BOOLEAN SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
68496                         ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom);
68497 -DisplayModePtr SiSBuildBuiltInModeList(ScrnInfoPtr pScrn);
68498 -#ifdef SISDUALHEAD /* TW: For dual head */
68499 +DisplayModePtr SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfordvi);
68500 +#ifdef SISDUALHEAD
68501  BOOLEAN SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
68502                         ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom);
68503  BOOLEAN SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
68504 -                       ScrnInfoPtr pScrn, DisplayModePtr mode);
68505 +                       ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom);
68506  #endif /* dual head */
68507  #endif /* linux_xf86 */
68508  
68509 @@ -90,49 +83,201 @@ BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, 
68510  static ULONG GetDRAMSize(SiS_Private *SiS_Pr,
68511                           PSIS_HW_DEVICE_INFO HwDeviceExtension);
68512  
68513 -static void DelaySeconds(int seconds);
68514 -void SiS_DebugCode(SiS_Private *SiS_Pr, UCHAR code);
68515 -
68516  static void
68517 -DelaySeconds(int seconds)
68518 -{
68519 -  int i;
68520 -#ifdef WIN2000
68521 -  int j;
68522 -#endif
68523 -
68524 -  for (i=0;i<seconds;i++) {
68525 -#ifdef TC
68526 -    delay(1000);
68527 -#endif
68528 -
68529 -#ifdef WIN2000
68530 -    for (j=0;j<20000;j++)
68531 -      VideoPortStallExecution(50);
68532 -#endif
68533 -
68534 -#ifdef WINCE_HEADER
68535 -#endif
68536 -
68537 -#ifdef LINUX_KERNEL
68538 -#endif
68539 -  }
68540 -}
68541 -
68542 -void
68543 -SiS_DebugCode(SiS_Private *SiS_Pr, UCHAR code)
68544 +InitCommonPointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
68545  {
68546 -  OutPortByte(0x80, code);
68547 -  DelaySeconds(0x3);
68548 +   SiS_Pr->SiS_StResInfo     = SiS_StResInfo;
68549 +   SiS_Pr->SiS_ModeResInfo   = SiS_ModeResInfo;
68550 +   SiS_Pr->SiS_StandTable    = SiS_StandTable;
68551 +   if(HwDeviceExtension->jChipType < SIS_315H) {
68552 +      SiS_StandTable[0x04].CRTC[4] = 0x2b;
68553 +      SiS_StandTable[0x05].CRTC[4] = 0x2b;
68554 +      SiS_StandTable[0x06].CRTC[4] = 0x54;
68555 +      SiS_StandTable[0x06].CRTC[5] = 0x80;
68556 +      SiS_StandTable[0x0d].CRTC[4] = 0x2b;
68557 +      SiS_StandTable[0x0e].CRTC[4] = 0x54;
68558 +      SiS_StandTable[0x0e].CRTC[5] = 0x80;
68559 +      SiS_StandTable[0x11].CRTC[4] = 0x54;
68560 +      SiS_StandTable[0x11].CRTC[5] = 0x80;
68561 +      SiS_StandTable[0x11].CRTC[16] = 0x83;
68562 +      SiS_StandTable[0x11].CRTC[17] = 0x85;
68563 +      SiS_StandTable[0x12].CRTC[4] = 0x54;
68564 +      SiS_StandTable[0x12].CRTC[5] = 0x80;
68565 +      SiS_StandTable[0x12].CRTC[16] = 0x83;
68566 +      SiS_StandTable[0x12].CRTC[17] = 0x85;
68567 +      SiS_StandTable[0x13].CRTC[5] = 0xa0;
68568 +      SiS_StandTable[0x17].CRTC[5] = 0xa0;
68569 +      SiS_StandTable[0x1a].CRTC[4] = 0x54;
68570 +      SiS_StandTable[0x1a].CRTC[5] = 0x80;
68571 +      SiS_StandTable[0x1a].CRTC[16] = 0xea;
68572 +      SiS_StandTable[0x1a].CRTC[17] = 0x8c;
68573 +      SiS_StandTable[0x1b].CRTC[4] = 0x54;
68574 +      SiS_StandTable[0x1b].CRTC[5] = 0x80;
68575 +      SiS_StandTable[0x1b].CRTC[16] = 0xea;
68576 +      SiS_StandTable[0x1b].CRTC[17] = 0x8c;
68577 +      SiS_StandTable[0x1c].CRTC[4] = 0x54;
68578 +      SiS_StandTable[0x1c].CRTC[5] = 0x80;
68579 +   } else {
68580 +      SiS_StandTable[0x04].CRTC[4] = 0x2c;
68581 +      SiS_StandTable[0x05].CRTC[4] = 0x2c;
68582 +      SiS_StandTable[0x06].CRTC[4] = 0x55;
68583 +      SiS_StandTable[0x06].CRTC[5] = 0x81;
68584 +      SiS_StandTable[0x0d].CRTC[4] = 0x2c;
68585 +      SiS_StandTable[0x0e].CRTC[4] = 0x55;
68586 +      SiS_StandTable[0x0e].CRTC[5] = 0x81;
68587 +      SiS_StandTable[0x11].CRTC[4] = 0x55;
68588 +      SiS_StandTable[0x11].CRTC[5] = 0x81;
68589 +      SiS_StandTable[0x11].CRTC[16] = 0x82;
68590 +      SiS_StandTable[0x11].CRTC[17] = 0x84;
68591 +      SiS_StandTable[0x12].CRTC[4] = 0x55;
68592 +      SiS_StandTable[0x12].CRTC[5] = 0x81;
68593 +      SiS_StandTable[0x12].CRTC[16] = 0x82;
68594 +      SiS_StandTable[0x12].CRTC[17] = 0x84;
68595 +      SiS_StandTable[0x13].CRTC[5] = 0xb1;
68596 +      SiS_StandTable[0x17].CRTC[5] = 0xb1;
68597 +      SiS_StandTable[0x1a].CRTC[4] = 0x55;
68598 +      SiS_StandTable[0x1a].CRTC[5] = 0x81;
68599 +      SiS_StandTable[0x1a].CRTC[16] = 0xe9;
68600 +      SiS_StandTable[0x1a].CRTC[17] = 0x8b;
68601 +      SiS_StandTable[0x1b].CRTC[4] = 0x55;
68602 +      SiS_StandTable[0x1b].CRTC[5] = 0x81;
68603 +      SiS_StandTable[0x1b].CRTC[16] = 0xe9;
68604 +      SiS_StandTable[0x1b].CRTC[17] = 0x8b;
68605 +      SiS_StandTable[0x1c].CRTC[4] = 0x55;
68606 +      SiS_StandTable[0x1c].CRTC[5] = 0x81;
68607 +   }
68608 +
68609 +   SiS_Pr->SiS_NTSCPhase    = SiS_NTSCPhase;
68610 +   SiS_Pr->SiS_PALPhase     = SiS_PALPhase;
68611 +   SiS_Pr->SiS_NTSCPhase2   = SiS_NTSCPhase2;
68612 +   SiS_Pr->SiS_PALPhase2    = SiS_PALPhase2;
68613 +   SiS_Pr->SiS_PALMPhase    = SiS_PALMPhase;
68614 +   SiS_Pr->SiS_PALNPhase    = SiS_PALNPhase;
68615 +   SiS_Pr->SiS_PALMPhase2   = SiS_PALMPhase2;
68616 +   SiS_Pr->SiS_PALNPhase2   = SiS_PALNPhase2;
68617 +   SiS_Pr->SiS_SpecialPhase = SiS_SpecialPhase;
68618 +
68619 +   SiS_Pr->SiS_NTSCTiming     = SiS_NTSCTiming;
68620 +   SiS_Pr->SiS_PALTiming      = SiS_PALTiming;
68621 +   SiS_Pr->SiS_HiTVSt1Timing  = SiS_HiTVSt1Timing;
68622 +   SiS_Pr->SiS_HiTVSt2Timing  = SiS_HiTVSt2Timing;
68623 +   SiS_Pr->SiS_HiTVTextTiming = SiS_HiTVTextTiming;
68624 +   SiS_Pr->SiS_HiTVExtTiming  = SiS_HiTVExtTiming;
68625 +   SiS_Pr->SiS_HiTVGroup3Data = SiS_HiTVGroup3Data;
68626 +   SiS_Pr->SiS_HiTVGroup3Simu = SiS_HiTVGroup3Simu;
68627 +   SiS_Pr->SiS_HiTVGroup3Text = SiS_HiTVGroup3Text;
68628 +
68629 +   SiS_Pr->SiS_StPALData   = SiS_StPALData;
68630 +   SiS_Pr->SiS_ExtPALData  = SiS_ExtPALData;
68631 +   SiS_Pr->SiS_StNTSCData  = SiS_StNTSCData;
68632 +   SiS_Pr->SiS_ExtNTSCData = SiS_ExtNTSCData;
68633 +/* SiS_Pr->SiS_St1HiTVData = SiS_St1HiTVData;  */
68634 +   SiS_Pr->SiS_St2HiTVData = SiS_St2HiTVData;
68635 +   SiS_Pr->SiS_ExtHiTVData = SiS_ExtHiTVData;
68636 +
68637 +   SiS_Pr->pSiS_OutputSelect = &SiS_OutputSelect;
68638 +   SiS_Pr->pSiS_SoftSetting  = &SiS_SoftSetting;
68639 +
68640 +   SiS_Pr->SiS_LCD1280x960Data      = SiS_LCD1280x960Data;
68641 +   SiS_Pr->SiS_ExtLCD1400x1050Data  = SiS_ExtLCD1400x1050Data;
68642 +   SiS_Pr->SiS_ExtLCD1600x1200Data  = SiS_ExtLCD1600x1200Data;
68643 +   SiS_Pr->SiS_StLCD1400x1050Data   = SiS_StLCD1400x1050Data;
68644 +   SiS_Pr->SiS_StLCD1600x1200Data   = SiS_StLCD1600x1200Data;
68645 +   SiS_Pr->SiS_NoScaleData1400x1050 = SiS_NoScaleData1400x1050;
68646 +   SiS_Pr->SiS_NoScaleData1600x1200 = SiS_NoScaleData1600x1200;
68647 +   SiS_Pr->SiS_ExtLCD1280x768Data   = SiS_ExtLCD1280x768Data;
68648 +   SiS_Pr->SiS_StLCD1280x768Data    = SiS_StLCD1280x768Data;
68649 +   SiS_Pr->SiS_NoScaleData1280x768  = SiS_NoScaleData1280x768;
68650 +   SiS_Pr->SiS_NoScaleData          = SiS_NoScaleData;
68651 +
68652 +   SiS_Pr->SiS_LVDS320x480Data_1   = SiS_LVDS320x480Data_1;
68653 +   SiS_Pr->SiS_LVDS800x600Data_1   = SiS_LVDS800x600Data_1;
68654 +   SiS_Pr->SiS_LVDS800x600Data_2   = SiS_LVDS800x600Data_2;
68655 +   SiS_Pr->SiS_LVDS1024x768Data_1  = SiS_LVDS1024x768Data_1;
68656 +   SiS_Pr->SiS_LVDS1024x768Data_2  = SiS_LVDS1024x768Data_2;
68657 +   SiS_Pr->SiS_LVDS1280x1024Data_1 = SiS_LVDS1280x1024Data_1;
68658 +   SiS_Pr->SiS_LVDS1280x1024Data_2 = SiS_LVDS1280x1024Data_2;
68659 +   SiS_Pr->SiS_LVDS1400x1050Data_1 = SiS_LVDS1400x1050Data_1;
68660 +   SiS_Pr->SiS_LVDS1400x1050Data_2 = SiS_LVDS1400x1050Data_2;
68661 +   SiS_Pr->SiS_LVDS1600x1200Data_1 = SiS_LVDS1600x1200Data_1;
68662 +   SiS_Pr->SiS_LVDS1600x1200Data_2 = SiS_LVDS1600x1200Data_2;
68663 +   SiS_Pr->SiS_LVDS1280x768Data_1  = SiS_LVDS1280x768Data_1;
68664 +   SiS_Pr->SiS_LVDS1280x768Data_2  = SiS_LVDS1280x768Data_2;
68665 +   SiS_Pr->SiS_LVDS1024x600Data_1  = SiS_LVDS1024x600Data_1;
68666 +   SiS_Pr->SiS_LVDS1024x600Data_2  = SiS_LVDS1024x600Data_2;
68667 +   SiS_Pr->SiS_LVDS1152x768Data_1  = SiS_LVDS1152x768Data_1;
68668 +   SiS_Pr->SiS_LVDS1152x768Data_2  = SiS_LVDS1152x768Data_2;
68669 +   SiS_Pr->SiS_LVDSXXXxXXXData_1   = SiS_LVDSXXXxXXXData_1;
68670 +   SiS_Pr->SiS_LVDS1280x960Data_1  = SiS_LVDS1280x960Data_1;
68671 +   SiS_Pr->SiS_LVDS1280x960Data_2  = SiS_LVDS1280x960Data_2;
68672 +   SiS_Pr->SiS_LVDS640x480Data_1   = SiS_LVDS640x480Data_1;
68673 +   SiS_Pr->SiS_LVDS1280x960Data_1  = SiS_LVDS1280x1024Data_1;
68674 +   SiS_Pr->SiS_LVDS1280x960Data_2  = SiS_LVDS1280x1024Data_2;
68675 +   SiS_Pr->SiS_LVDS640x480Data_1   = SiS_LVDS640x480Data_1;
68676 +   SiS_Pr->SiS_LVDS640x480Data_2   = SiS_LVDS640x480Data_2;
68677 +
68678 +   SiS_Pr->SiS_LVDSBARCO1366Data_1 = SiS_LVDSBARCO1366Data_1;
68679 +   SiS_Pr->SiS_LVDSBARCO1366Data_2 = SiS_LVDSBARCO1366Data_2;
68680 +   SiS_Pr->SiS_LVDSBARCO1024Data_1 = SiS_LVDSBARCO1024Data_1;
68681 +   SiS_Pr->SiS_LVDSBARCO1024Data_2 = SiS_LVDSBARCO1024Data_2;
68682 +   SiS_Pr->SiS_LVDS848x480Data_1   = SiS_LVDS848x480Data_1;
68683 +   SiS_Pr->SiS_LVDS848x480Data_2   = SiS_LVDS848x480Data_2;
68684 +
68685 +   SiS_Pr->SiS_LCDA1400x1050Data_1 = SiS_LCDA1400x1050Data_1;
68686 +   SiS_Pr->SiS_LCDA1400x1050Data_2 = SiS_LCDA1400x1050Data_2;
68687 +   SiS_Pr->SiS_LCDA1600x1200Data_1 = SiS_LCDA1600x1200Data_1;
68688 +   SiS_Pr->SiS_LCDA1600x1200Data_2 = SiS_LCDA1600x1200Data_2;
68689 +   SiS_Pr->SiS_CHTVUNTSCData = SiS_CHTVUNTSCData;
68690 +   SiS_Pr->SiS_CHTVONTSCData = SiS_CHTVONTSCData;
68691 +
68692 +   SiS_Pr->LVDS1024x768Des_1  = SiS_PanelType1076_1;
68693 +   SiS_Pr->LVDS1280x1024Des_1 = SiS_PanelType1210_1;
68694 +   SiS_Pr->LVDS1400x1050Des_1 = SiS_PanelType1296_1;
68695 +   SiS_Pr->LVDS1600x1200Des_1 = SiS_PanelType1600_1;
68696 +   SiS_Pr->LVDS1024x768Des_2  = SiS_PanelType1076_2;
68697 +   SiS_Pr->LVDS1280x1024Des_2 = SiS_PanelType1210_2;
68698 +   SiS_Pr->LVDS1400x1050Des_2 = SiS_PanelType1296_2;
68699 +   SiS_Pr->LVDS1600x1200Des_2 = SiS_PanelType1600_2;
68700 +
68701 +   SiS_Pr->SiS_PanelTypeNS_1 = SiS_PanelTypeNS_1;
68702 +   SiS_Pr->SiS_PanelTypeNS_2 = SiS_PanelTypeNS_2;
68703 +
68704 +   SiS_Pr->SiS_CHTVUNTSCDesData = SiS_CHTVUNTSCDesData;
68705 +   SiS_Pr->SiS_CHTVONTSCDesData = SiS_CHTVONTSCDesData;
68706 +   SiS_Pr->SiS_CHTVUPALDesData  = SiS_CHTVUPALDesData;
68707 +   SiS_Pr->SiS_CHTVOPALDesData  = SiS_CHTVOPALDesData;
68708 +
68709 +   SiS_Pr->SiS_LVDSCRT11280x768_1    = SiS_LVDSCRT11280x768_1;
68710 +   SiS_Pr->SiS_LVDSCRT11024x600_1    = SiS_LVDSCRT11024x600_1;
68711 +   SiS_Pr->SiS_LVDSCRT11152x768_1    = SiS_LVDSCRT11152x768_1;
68712 +   SiS_Pr->SiS_LVDSCRT11280x768_1_H  = SiS_LVDSCRT11280x768_1_H;
68713 +   SiS_Pr->SiS_LVDSCRT11024x600_1_H  = SiS_LVDSCRT11024x600_1_H;
68714 +   SiS_Pr->SiS_LVDSCRT11152x768_1_H  = SiS_LVDSCRT11152x768_1_H;
68715 +   SiS_Pr->SiS_LVDSCRT11280x768_2    = SiS_LVDSCRT11280x768_2;
68716 +   SiS_Pr->SiS_LVDSCRT11024x600_2    = SiS_LVDSCRT11024x600_2;
68717 +   SiS_Pr->SiS_LVDSCRT11152x768_2    = SiS_LVDSCRT11152x768_2;
68718 +   SiS_Pr->SiS_LVDSCRT11280x768_2_H  = SiS_LVDSCRT11280x768_2_H;
68719 +   SiS_Pr->SiS_LVDSCRT11024x600_2_H  = SiS_LVDSCRT11024x600_2_H;
68720 +   SiS_Pr->SiS_LVDSCRT11152x768_2_H  = SiS_LVDSCRT11152x768_2_H;
68721 +   SiS_Pr->SiS_LVDSCRT1320x480_1     = SiS_LVDSCRT1320x480_1;
68722 +   SiS_Pr->SiS_LVDSCRT1XXXxXXX_1     = SiS_LVDSCRT1XXXxXXX_1;
68723 +   SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H   = SiS_LVDSCRT1XXXxXXX_1_H;
68724 +   SiS_Pr->SiS_LVDSCRT1640x480_1     = SiS_LVDSCRT1640x480_1;
68725 +   SiS_Pr->SiS_LVDSCRT1640x480_1_H   = SiS_LVDSCRT1640x480_1_H;
68726 +   SiS_Pr->SiS_LVDSCRT1640x480_2     = SiS_LVDSCRT1640x480_2;
68727 +   SiS_Pr->SiS_LVDSCRT1640x480_2_H   = SiS_LVDSCRT1640x480_2_H;
68728 +   SiS_Pr->SiS_LVDSCRT1640x480_3     = SiS_LVDSCRT1640x480_3;
68729 +   SiS_Pr->SiS_LVDSCRT1640x480_3_H   = SiS_LVDSCRT1640x480_3_H;
68730  }
68731  
68732  #ifdef SIS300
68733  static void
68734  InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
68735  {
68736 +   InitCommonPointer(SiS_Pr, HwDeviceExtension);
68737 +
68738     SiS_Pr->SiS_SModeIDTable  = (SiS_StStruct *)SiS300_SModeIDTable;
68739     SiS_Pr->SiS_VBModeIDTable = (SiS_VBModeStruct *)SiS300_VBModeIDTable;
68740 -   SiS_Pr->SiS_StandTable    = (SiS_StandTableStruct *)SiS300_StandTable;
68741     SiS_Pr->SiS_EModeIDTable  = (SiS_ExtStruct *)SiS300_EModeIDTable;
68742     SiS_Pr->SiS_RefIndex      = (SiS_Ext2Struct *)SiS300_RefIndex;
68743     SiS_Pr->SiS_CRT1Table     = (SiS_CRT1TableStruct *)SiS300_CRT1Table;
68744 @@ -141,15 +286,12 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PS
68745     } else {
68746        SiS_Pr->SiS_MCLKData_0    = (SiS_MCLKDataStruct *)SiS300_MCLKData_630; /* 630, 730 */
68747     }
68748 +#ifdef LINUXBIOS
68749     SiS_Pr->SiS_ECLKData      = (SiS_ECLKDataStruct *)SiS300_ECLKData;
68750 +#endif
68751     SiS_Pr->SiS_VCLKData      = (SiS_VCLKDataStruct *)SiS300_VCLKData;
68752     SiS_Pr->SiS_VBVCLKData    = (SiS_VBVCLKDataStruct *)SiS300_VCLKData;
68753     SiS_Pr->SiS_ScreenOffset  = SiS300_ScreenOffset;
68754 -   SiS_Pr->SiS_StResInfo     = (SiS_StResInfoStruct *)SiS300_StResInfo;
68755 -   SiS_Pr->SiS_ModeResInfo   = (SiS_ModeResInfoStruct *)SiS300_ModeResInfo;
68756 -
68757 -   SiS_Pr->pSiS_OutputSelect = &SiS300_OutputSelect;
68758 -   SiS_Pr->pSiS_SoftSetting  = &SiS300_SoftSetting;
68759  
68760     SiS_Pr->SiS_SR15  = SiS300_SR15;
68761  
68762 @@ -178,15 +320,6 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PS
68763     SiS_Pr->pSiS_YCSenseData2    = &SiS300_YCSenseData2;
68764  #endif
68765  
68766 -   SiS_Pr->SiS_NTSCPhase  = SiS300_NTSCPhase;
68767 -   SiS_Pr->SiS_PALPhase   = SiS300_PALPhase;
68768 -   SiS_Pr->SiS_NTSCPhase2 = SiS300_NTSCPhase2;
68769 -   SiS_Pr->SiS_PALPhase2  = SiS300_PALPhase2;
68770 -   SiS_Pr->SiS_PALMPhase  = SiS300_PALMPhase;
68771 -   SiS_Pr->SiS_PALNPhase  = SiS300_PALNPhase;
68772 -   SiS_Pr->SiS_PALMPhase2 = SiS300_PALMPhase2;
68773 -   SiS_Pr->SiS_PALNPhase2 = SiS300_PALNPhase2;
68774 -
68775     SiS_Pr->SiS_StLCD1024x768Data    = (SiS_LCDDataStruct *)SiS300_StLCD1024x768Data;
68776     SiS_Pr->SiS_ExtLCD1024x768Data   = (SiS_LCDDataStruct *)SiS300_ExtLCD1024x768Data;
68777     SiS_Pr->SiS_St2LCD1024x768Data   = (SiS_LCDDataStruct *)SiS300_St2LCD1024x768Data;
68778 @@ -195,68 +328,18 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PS
68779     SiS_Pr->SiS_St2LCD1280x1024Data  = (SiS_LCDDataStruct *)SiS300_St2LCD1280x1024Data;
68780     SiS_Pr->SiS_NoScaleData1024x768  = (SiS_LCDDataStruct *)SiS300_NoScaleData1024x768;
68781     SiS_Pr->SiS_NoScaleData1280x1024 = (SiS_LCDDataStruct *)SiS300_NoScaleData1280x1024;
68782 -   SiS_Pr->SiS_LCD1280x960Data      = (SiS_LCDDataStruct *)SiS300_LCD1280x960Data;
68783 -   SiS_Pr->SiS_ExtLCD1400x1050Data  = (SiS_LCDDataStruct *)SiS300_ExtLCD1400x1050Data;
68784 -   SiS_Pr->SiS_ExtLCD1600x1200Data  = (SiS_LCDDataStruct *)SiS300_ExtLCD1600x1200Data;
68785 -   SiS_Pr->SiS_StLCD1400x1050Data   = (SiS_LCDDataStruct *)SiS300_StLCD1400x1050Data;
68786 -   SiS_Pr->SiS_StLCD1600x1200Data   = (SiS_LCDDataStruct *)SiS300_StLCD1600x1200Data;
68787 -   SiS_Pr->SiS_NoScaleData1400x1050 = (SiS_LCDDataStruct *)SiS300_NoScaleData1400x1050;
68788 -   SiS_Pr->SiS_NoScaleData1600x1200 = (SiS_LCDDataStruct *)SiS300_NoScaleData1600x1200;
68789 -
68790 -   SiS_Pr->SiS_StPALData   = (SiS_TVDataStruct *)SiS300_StPALData;
68791 -   SiS_Pr->SiS_ExtPALData  = (SiS_TVDataStruct *)SiS300_ExtPALData;
68792 -   SiS_Pr->SiS_StNTSCData  = (SiS_TVDataStruct *)SiS300_StNTSCData;
68793 -   SiS_Pr->SiS_ExtNTSCData = (SiS_TVDataStruct *)SiS300_ExtNTSCData;
68794 -/* SiS_Pr->SiS_St1HiTVData = (SiS_TVDataStruct *)SiS300_St1HiTVData;  */
68795 -   SiS_Pr->SiS_St2HiTVData = (SiS_TVDataStruct *)SiS300_St2HiTVData;
68796 -   SiS_Pr->SiS_ExtHiTVData = (SiS_TVDataStruct *)SiS300_ExtHiTVData;
68797 -
68798 -   SiS_Pr->SiS_NTSCTiming     = SiS300_NTSCTiming;
68799 -   SiS_Pr->SiS_PALTiming      = SiS300_PALTiming;
68800 -   SiS_Pr->SiS_HiTVSt1Timing  = SiS300_HiTVSt1Timing;
68801 -   SiS_Pr->SiS_HiTVSt2Timing  = SiS300_HiTVSt2Timing;
68802 -   SiS_Pr->SiS_HiTVTextTiming = SiS300_HiTVTextTiming;
68803 -   SiS_Pr->SiS_HiTVGroup3Data = SiS300_HiTVGroup3Data;
68804 -   SiS_Pr->SiS_HiTVGroup3Simu = SiS300_HiTVGroup3Simu;
68805 -   SiS_Pr->SiS_HiTVGroup3Text = SiS300_HiTVGroup3Text;
68806  
68807     SiS_Pr->SiS_PanelDelayTbl     = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTbl;
68808     SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTblLVDS;
68809  
68810 -   SiS_Pr->SiS_LVDS800x600Data_1   = (SiS_LVDSDataStruct *)SiS300_LVDS800x600Data_1;
68811 -   SiS_Pr->SiS_LVDS800x600Data_2   = (SiS_LVDSDataStruct *)SiS300_LVDS800x600Data_2;
68812 -   SiS_Pr->SiS_LVDS1024x768Data_1  = (SiS_LVDSDataStruct *)SiS300_LVDS1024x768Data_1;
68813 -   SiS_Pr->SiS_LVDS1024x768Data_2  = (SiS_LVDSDataStruct *)SiS300_LVDS1024x768Data_2;
68814 -   SiS_Pr->SiS_LVDS1280x1024Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1280x1024Data_1;
68815 -   SiS_Pr->SiS_LVDS1280x1024Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1280x1024Data_2;
68816 -   SiS_Pr->SiS_LVDS1280x960Data_1  = (SiS_LVDSDataStruct *)SiS300_LVDS1280x1024Data_1;
68817 -   SiS_Pr->SiS_LVDS1280x960Data_2  = (SiS_LVDSDataStruct *)SiS300_LVDS1280x1024Data_2;
68818 -   SiS_Pr->SiS_LVDS1400x1050Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1400x1050Data_1;
68819 -   SiS_Pr->SiS_LVDS1400x1050Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1400x1050Data_2;
68820 -   SiS_Pr->SiS_LVDS1600x1200Data_1 = (SiS_LVDSDataStruct *)SiS300_LVDS1600x1200Data_1;
68821 -   SiS_Pr->SiS_LVDS1600x1200Data_2 = (SiS_LVDSDataStruct *)SiS300_LVDS1600x1200Data_2;
68822 -   SiS_Pr->SiS_LVDS1280x768Data_1  = (SiS_LVDSDataStruct *)SiS300_LVDS1280x768Data_1;
68823 -   SiS_Pr->SiS_LVDS1280x768Data_2  = (SiS_LVDSDataStruct *)SiS300_LVDS1280x768Data_2;
68824 -   SiS_Pr->SiS_LVDS1024x600Data_1  = (SiS_LVDSDataStruct *)SiS300_LVDS1024x600Data_1;
68825 -   SiS_Pr->SiS_LVDS1024x600Data_2  = (SiS_LVDSDataStruct *)SiS300_LVDS1024x600Data_2;
68826 -   SiS_Pr->SiS_LVDS1152x768Data_1  = (SiS_LVDSDataStruct *)SiS300_LVDS1152x768Data_1;
68827 -   SiS_Pr->SiS_LVDS1152x768Data_2  = (SiS_LVDSDataStruct *)SiS300_LVDS1152x768Data_2;
68828 -   SiS_Pr->SiS_LVDSXXXxXXXData_1   = (SiS_LVDSDataStruct *)SiS300_LVDSXXXxXXXData_1;
68829 -   SiS_Pr->SiS_LVDS320x480Data_1   = (SiS_LVDSDataStruct *)SiS300_LVDS320x480Data_1;
68830 -   SiS_Pr->SiS_LVDS640x480Data_1   = (SiS_LVDSDataStruct *)SiS300_LVDS640x480Data_1;
68831 -   SiS_Pr->SiS_LCDA1400x1050Data_1 = (SiS_LVDSDataStruct *)SiS300_LCDA1400x1050Data_1;
68832 -   SiS_Pr->SiS_LCDA1400x1050Data_2 = (SiS_LVDSDataStruct *)SiS300_LCDA1400x1050Data_2;
68833 -   SiS_Pr->SiS_LCDA1600x1200Data_1 = (SiS_LVDSDataStruct *)SiS300_LCDA1600x1200Data_1;
68834 -   SiS_Pr->SiS_LCDA1600x1200Data_2 = (SiS_LVDSDataStruct *)SiS300_LCDA1600x1200Data_2;
68835 -   SiS_Pr->SiS_CHTVUNTSCData = (SiS_LVDSDataStruct *)SiS300_CHTVUNTSCData;
68836 -   SiS_Pr->SiS_CHTVONTSCData = (SiS_LVDSDataStruct *)SiS300_CHTVONTSCData;
68837     SiS_Pr->SiS_CHTVUPALData  = (SiS_LVDSDataStruct *)SiS300_CHTVUPALData;
68838     SiS_Pr->SiS_CHTVOPALData  = (SiS_LVDSDataStruct *)SiS300_CHTVOPALData;
68839 -   SiS_Pr->SiS_CHTVUPALMData = (SiS_LVDSDataStruct *)SiS300_CHTVUNTSCData; /* not supported on 300 series */
68840 -   SiS_Pr->SiS_CHTVOPALMData = (SiS_LVDSDataStruct *)SiS300_CHTVONTSCData; /* not supported on 300 series */
68841 +   SiS_Pr->SiS_CHTVUPALMData = SiS_CHTVUNTSCData;                         /* not supported on 300 series */
68842 +   SiS_Pr->SiS_CHTVOPALMData = SiS_CHTVONTSCData;                         /* not supported on 300 series */
68843     SiS_Pr->SiS_CHTVUPALNData = (SiS_LVDSDataStruct *)SiS300_CHTVUPALData;  /* not supported on 300 series */
68844     SiS_Pr->SiS_CHTVOPALNData = (SiS_LVDSDataStruct *)SiS300_CHTVOPALData;  /* not supported on 300 series */
68845     SiS_Pr->SiS_CHTVSOPALData = (SiS_LVDSDataStruct *)SiS300_CHTVSOPALData;
68846 +
68847     SiS_Pr->SiS_PanelType00_1 = (SiS_LVDSDesStruct *)SiS300_PanelType00_1;
68848     SiS_Pr->SiS_PanelType01_1 = (SiS_LVDSDesStruct *)SiS300_PanelType01_1;
68849     SiS_Pr->SiS_PanelType02_1 = (SiS_LVDSDesStruct *)SiS300_PanelType02_1;
68850 @@ -289,32 +372,28 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PS
68851     SiS_Pr->SiS_PanelType0d_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0d_2;
68852     SiS_Pr->SiS_PanelType0e_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0e_2;
68853     SiS_Pr->SiS_PanelType0f_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0f_2;
68854 -   SiS_Pr->SiS_PanelTypeNS_1 = (SiS_LVDSDesStruct *)SiS300_PanelTypeNS_1;
68855 -   SiS_Pr->SiS_PanelTypeNS_2 = (SiS_LVDSDesStruct *)SiS300_PanelTypeNS_2;
68856 -   SiS_Pr->SiS_CHTVUNTSCDesData = (SiS_LVDSDesStruct *)SiS300_CHTVUNTSCDesData;
68857 -   SiS_Pr->SiS_CHTVONTSCDesData = (SiS_LVDSDesStruct *)SiS300_CHTVONTSCDesData;
68858 -   SiS_Pr->SiS_CHTVUPALDesData  = (SiS_LVDSDesStruct *)SiS300_CHTVUPALDesData;
68859 -   SiS_Pr->SiS_CHTVOPALDesData  = (SiS_LVDSDesStruct *)SiS300_CHTVOPALDesData;
68860 +
68861 +   if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
68862 +      SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS300_PanelType04_1a;
68863 +      SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS300_PanelType04_2a;
68864 +   }
68865 +   if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) {
68866 +      SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS300_PanelType04_1b;
68867 +      SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS300_PanelType04_2b;
68868 +   }
68869 +
68870     SiS_Pr->SiS_LVDSCRT1800x600_1     = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_1;
68871     SiS_Pr->SiS_LVDSCRT11024x768_1    = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_1;
68872     SiS_Pr->SiS_LVDSCRT11280x1024_1   = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_1;
68873 -   SiS_Pr->SiS_LVDSCRT11024x600_1    = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x600_1;
68874 -   SiS_Pr->SiS_LVDSCRT11152x768_1    = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11152x768_1;
68875     SiS_Pr->SiS_LVDSCRT1800x600_1_H   = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_1_H;
68876     SiS_Pr->SiS_LVDSCRT11024x768_1_H  = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_1_H;
68877     SiS_Pr->SiS_LVDSCRT11280x1024_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_1_H;
68878 -   SiS_Pr->SiS_LVDSCRT11024x600_1_H  = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x600_1_H;
68879 -   SiS_Pr->SiS_LVDSCRT11152x768_1_H  = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11152x768_1_H;
68880     SiS_Pr->SiS_LVDSCRT1800x600_2     = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_2;
68881     SiS_Pr->SiS_LVDSCRT11024x768_2    = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_2;
68882     SiS_Pr->SiS_LVDSCRT11280x1024_2   = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_2;
68883 -   SiS_Pr->SiS_LVDSCRT11024x600_2    = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x600_2;
68884 -   SiS_Pr->SiS_LVDSCRT11152x768_2    = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11152x768_2;
68885     SiS_Pr->SiS_LVDSCRT1800x600_2_H   = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_2_H;
68886     SiS_Pr->SiS_LVDSCRT11024x768_2_H  = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_2_H;
68887     SiS_Pr->SiS_LVDSCRT11280x1024_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_2_H;
68888 -   SiS_Pr->SiS_LVDSCRT11024x600_2_H  = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x600_2_H;
68889 -   SiS_Pr->SiS_LVDSCRT11152x768_2_H  = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11152x768_2_H;
68890     SiS_Pr->SiS_CHTVCRT1UNTSC = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1UNTSC;
68891     SiS_Pr->SiS_CHTVCRT1ONTSC = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1ONTSC;
68892     SiS_Pr->SiS_CHTVCRT1UPAL  = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1UPAL;
68893 @@ -339,7 +418,6 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PS
68894     SiS_Pr->SiS_CHTVVCLKOPALN = SiS300_CHTVVCLKOPAL;   /* not supported on 300 series */
68895     SiS_Pr->SiS_CHTVVCLKSOPAL = SiS300_CHTVVCLKSOPAL;
68896  
68897 -   /* TW: New from 300/301LV BIOS */
68898     SiS_Pr->SiS_CRT2Part2_1024x768_1  = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1024x768_1;
68899     SiS_Pr->SiS_CRT2Part2_1280x1024_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1280x1024_1;
68900     SiS_Pr->SiS_CRT2Part2_1400x1050_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1400x1050_1;
68901 @@ -353,7 +431,7 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PS
68902     SiS_Pr->SiS_CRT2Part2_1400x1050_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1400x1050_3;
68903     SiS_Pr->SiS_CRT2Part2_1600x1200_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1600x1200_3;
68904  
68905 -   /* TW: LCDResInfo will on 300 series be translated to 310/325 series definitions */
68906 +   /* TW: LCDResInfo will on 300 series be translated to 315 series definitions */
68907     SiS_Pr->SiS_Panel320x480   = Panel_320x480;
68908     SiS_Pr->SiS_Panel640x480   = Panel_640x480;
68909     SiS_Pr->SiS_Panel800x600   = Panel_800x600;
68910 @@ -362,13 +440,17 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PS
68911     SiS_Pr->SiS_Panel1280x960  = Panel_1280x960;
68912     SiS_Pr->SiS_Panel1024x600  = Panel_1024x600;
68913     SiS_Pr->SiS_Panel1152x768  = Panel_1152x768;
68914 -   SiS_Pr->SiS_Panel1600x1200 = 16;            /* TW: Something illegal */
68915 -   SiS_Pr->SiS_Panel1400x1050 = 16;            /* TW: Something illegal */
68916 -   SiS_Pr->SiS_Panel1152x864  = 16;            /* TW: Something illegal */
68917 -   SiS_Pr->SiS_Panel1280x768  = 16;            /* TW: Something illegal */
68918 +   SiS_Pr->SiS_Panel1280x768  = Panel_1280x768;
68919 +   SiS_Pr->SiS_Panel1600x1200 = 255;           /* TW: Something illegal */
68920 +   SiS_Pr->SiS_Panel1400x1050 = 255;           /* TW: Something illegal */
68921 +   SiS_Pr->SiS_Panel640x480_2 = 255;           /* TW: Something illegal */
68922 +   SiS_Pr->SiS_Panel640x480_3 = 255;           /* TW: Something illegal */
68923 +   SiS_Pr->SiS_Panel1152x864  = 255;                   /* TW: Something illegal */
68924     SiS_Pr->SiS_PanelMax       = Panel_320x480;     /* TW: highest value */
68925     SiS_Pr->SiS_PanelMinLVDS   = Panel_800x600;     /* TW: Lowest value LVDS */
68926     SiS_Pr->SiS_PanelMin301    = Panel_1024x768;    /* TW: lowest value 301 */
68927 +   SiS_Pr->SiS_PanelCustom    = Panel_Custom;
68928 +   SiS_Pr->SiS_PanelBarco1366 = Panel_Barco1366;
68929  }
68930  #endif
68931  
68932 @@ -376,29 +458,33 @@ InitTo300Pointer(SiS_Private *SiS_Pr, PS
68933  static void
68934  InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
68935  {
68936 +   InitCommonPointer(SiS_Pr, HwDeviceExtension);
68937 +
68938     SiS_Pr->SiS_SModeIDTable  = (SiS_StStruct *)SiS310_SModeIDTable;
68939 -   SiS_Pr->SiS_StandTable    = (SiS_StandTableStruct *)SiS310_StandTable;
68940     SiS_Pr->SiS_EModeIDTable  = (SiS_ExtStruct *)SiS310_EModeIDTable;
68941     SiS_Pr->SiS_RefIndex      = (SiS_Ext2Struct *)SiS310_RefIndex;
68942     SiS_Pr->SiS_CRT1Table     = (SiS_CRT1TableStruct *)SiS310_CRT1Table;
68943     /* TW: MCLK is different */
68944 -   if(HwDeviceExtension->jChipType == SIS_330) {
68945 +#ifdef LINUXBIOS
68946 +   if(HwDeviceExtension->jChipType >= SIS_660) {
68947 +      SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_660;  /* 660/760 */
68948 +   } else if(HwDeviceExtension->jChipType == SIS_330) {
68949 +#endif
68950        SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_330;  /* 330 */
68951 +#ifdef LINUXBIOS
68952     } else if(HwDeviceExtension->jChipType > SIS_315PRO) {
68953        SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_650;  /* 550, 650, 740 */
68954     } else {
68955        SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_315;  /* 315 */
68956     }
68957 +#endif
68958     SiS_Pr->SiS_MCLKData_1    = (SiS_MCLKDataStruct *)SiS310_MCLKData_1;
68959 +#ifdef LINUXBIOS
68960     SiS_Pr->SiS_ECLKData      = (SiS_ECLKDataStruct *)SiS310_ECLKData;
68961 +#endif
68962     SiS_Pr->SiS_VCLKData      = (SiS_VCLKDataStruct *)SiS310_VCLKData;
68963     SiS_Pr->SiS_VBVCLKData    = (SiS_VBVCLKDataStruct *)SiS310_VBVCLKData;
68964     SiS_Pr->SiS_ScreenOffset  = SiS310_ScreenOffset;
68965 -   SiS_Pr->SiS_StResInfo     = (SiS_StResInfoStruct *)SiS310_StResInfo;
68966 -   SiS_Pr->SiS_ModeResInfo   = (SiS_ModeResInfoStruct *)SiS310_ModeResInfo;
68967 -
68968 -   SiS_Pr->pSiS_OutputSelect = &SiS310_OutputSelect;
68969 -   SiS_Pr->pSiS_SoftSetting  = &SiS310_SoftSetting;
68970  
68971     SiS_Pr->SiS_SR15  = SiS310_SR15;
68972  
68973 @@ -427,16 +513,6 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS
68974     SiS_Pr->pSiS_YCSenseData2    = &SiS310_YCSenseData2;
68975  #endif
68976  
68977 -   SiS_Pr->SiS_NTSCPhase    = SiS310_NTSCPhase;
68978 -   SiS_Pr->SiS_PALPhase     = SiS310_PALPhase;
68979 -   SiS_Pr->SiS_NTSCPhase2   = SiS310_NTSCPhase2;
68980 -   SiS_Pr->SiS_PALPhase2    = SiS310_PALPhase2;
68981 -   SiS_Pr->SiS_PALMPhase    = SiS310_PALMPhase;
68982 -   SiS_Pr->SiS_PALNPhase    = SiS310_PALNPhase;
68983 -   SiS_Pr->SiS_PALMPhase2   = SiS310_PALMPhase2;
68984 -   SiS_Pr->SiS_PALNPhase2   = SiS310_PALNPhase2;
68985 -   SiS_Pr->SiS_SpecialPhase = SiS310_SpecialPhase;
68986 -
68987     SiS_Pr->SiS_StLCD1024x768Data    = (SiS_LCDDataStruct *)SiS310_StLCD1024x768Data;
68988     SiS_Pr->SiS_ExtLCD1024x768Data   = (SiS_LCDDataStruct *)SiS310_ExtLCD1024x768Data;
68989     SiS_Pr->SiS_St2LCD1024x768Data   = (SiS_LCDDataStruct *)SiS310_St2LCD1024x768Data;
68990 @@ -445,62 +521,10 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS
68991     SiS_Pr->SiS_St2LCD1280x1024Data  = (SiS_LCDDataStruct *)SiS310_St2LCD1280x1024Data;
68992     SiS_Pr->SiS_NoScaleData1024x768  = (SiS_LCDDataStruct *)SiS310_NoScaleData1024x768;
68993     SiS_Pr->SiS_NoScaleData1280x1024 = (SiS_LCDDataStruct *)SiS310_NoScaleData1280x1024;
68994 -   SiS_Pr->SiS_LCD1280x960Data      = (SiS_LCDDataStruct *)SiS310_LCD1280x960Data;
68995 -   SiS_Pr->SiS_ExtLCD1400x1050Data  = (SiS_LCDDataStruct *)SiS310_ExtLCD1400x1050Data;
68996 -   SiS_Pr->SiS_ExtLCD1600x1200Data  = (SiS_LCDDataStruct *)SiS310_ExtLCD1600x1200Data;
68997 -   SiS_Pr->SiS_StLCD1400x1050Data   = (SiS_LCDDataStruct *)SiS310_StLCD1400x1050Data;
68998 -   SiS_Pr->SiS_StLCD1600x1200Data   = (SiS_LCDDataStruct *)SiS310_StLCD1600x1200Data;
68999 -   SiS_Pr->SiS_NoScaleData1400x1050 = (SiS_LCDDataStruct *)SiS310_NoScaleData1400x1050;
69000 -   SiS_Pr->SiS_NoScaleData1600x1200 = (SiS_LCDDataStruct *)SiS310_NoScaleData1600x1200;
69001 -
69002 -   SiS_Pr->SiS_StPALData   = (SiS_TVDataStruct *)SiS310_StPALData;
69003 -   SiS_Pr->SiS_ExtPALData  = (SiS_TVDataStruct *)SiS310_ExtPALData;
69004 -   SiS_Pr->SiS_StNTSCData  = (SiS_TVDataStruct *)SiS310_StNTSCData;
69005 -   SiS_Pr->SiS_ExtNTSCData = (SiS_TVDataStruct *)SiS310_ExtNTSCData;
69006 -/* SiS_Pr->SiS_St1HiTVData = (SiS_TVDataStruct *)SiS310_St1HiTVData;  */
69007 -   SiS_Pr->SiS_St2HiTVData = (SiS_TVDataStruct *)SiS310_St2HiTVData;
69008 -   SiS_Pr->SiS_ExtHiTVData = (SiS_TVDataStruct *)SiS310_ExtHiTVData;
69009 -
69010 -   SiS_Pr->SiS_NTSCTiming     = SiS310_NTSCTiming;
69011 -   SiS_Pr->SiS_PALTiming      = SiS310_PALTiming;
69012 -   SiS_Pr->SiS_HiTVSt1Timing  = SiS310_HiTVSt1Timing;
69013 -   SiS_Pr->SiS_HiTVSt2Timing  = SiS310_HiTVSt2Timing;
69014 -   SiS_Pr->SiS_HiTVTextTiming = SiS310_HiTVTextTiming;
69015 -   SiS_Pr->SiS_HiTVExtTiming  = SiS310_HiTVExtTiming;
69016 -   SiS_Pr->SiS_HiTVGroup3Data = SiS310_HiTVGroup3Data;
69017 -   SiS_Pr->SiS_HiTVGroup3Simu = SiS310_HiTVGroup3Simu;
69018 -   SiS_Pr->SiS_HiTVGroup3Text = SiS310_HiTVGroup3Text;
69019  
69020 -   SiS_Pr->SiS_PanelDelayTbl = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTbl;
69021 +   SiS_Pr->SiS_PanelDelayTbl     = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTbl;
69022     SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTblLVDS;
69023  
69024 -   SiS_Pr->SiS_LVDS800x600Data_1   = (SiS_LVDSDataStruct *)SiS310_LVDS800x600Data_1;
69025 -   SiS_Pr->SiS_LVDS800x600Data_2   = (SiS_LVDSDataStruct *)SiS310_LVDS800x600Data_2;
69026 -   SiS_Pr->SiS_LVDS1024x768Data_1  = (SiS_LVDSDataStruct *)SiS310_LVDS1024x768Data_1;
69027 -   SiS_Pr->SiS_LVDS1024x768Data_2  = (SiS_LVDSDataStruct *)SiS310_LVDS1024x768Data_2;
69028 -   SiS_Pr->SiS_LVDS1280x1024Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1280x1024Data_1;
69029 -   SiS_Pr->SiS_LVDS1280x1024Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1280x1024Data_2;
69030 -   SiS_Pr->SiS_LVDS1280x960Data_1  = (SiS_LVDSDataStruct *)SiS310_LVDS1280x960Data_1;
69031 -   SiS_Pr->SiS_LVDS1280x960Data_2  = (SiS_LVDSDataStruct *)SiS310_LVDS1280x960Data_2;
69032 -   SiS_Pr->SiS_LVDS1400x1050Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1400x1050Data_1;
69033 -   SiS_Pr->SiS_LVDS1400x1050Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1400x1050Data_2;
69034 -   SiS_Pr->SiS_LVDS1600x1200Data_1 = (SiS_LVDSDataStruct *)SiS310_LVDS1600x1200Data_1;
69035 -   SiS_Pr->SiS_LVDS1600x1200Data_2 = (SiS_LVDSDataStruct *)SiS310_LVDS1600x1200Data_2;
69036 -   SiS_Pr->SiS_LVDS1280x768Data_1  = (SiS_LVDSDataStruct *)SiS310_LVDS1280x768Data_1;
69037 -   SiS_Pr->SiS_LVDS1280x768Data_2  = (SiS_LVDSDataStruct *)SiS310_LVDS1280x768Data_2;
69038 -   SiS_Pr->SiS_LVDS1024x600Data_1  = (SiS_LVDSDataStruct *)SiS310_LVDS1024x600Data_1;
69039 -   SiS_Pr->SiS_LVDS1024x600Data_2  = (SiS_LVDSDataStruct *)SiS310_LVDS1024x600Data_2;
69040 -   SiS_Pr->SiS_LVDS1152x768Data_1  = (SiS_LVDSDataStruct *)SiS310_LVDS1152x768Data_1;
69041 -   SiS_Pr->SiS_LVDS1152x768Data_2  = (SiS_LVDSDataStruct *)SiS310_LVDS1152x768Data_2;
69042 -   SiS_Pr->SiS_LVDSXXXxXXXData_1   = (SiS_LVDSDataStruct *)SiS310_LVDSXXXxXXXData_1;
69043 -   SiS_Pr->SiS_LVDS320x480Data_1   = (SiS_LVDSDataStruct *)SiS310_LVDS320x480Data_1;
69044 -   SiS_Pr->SiS_LVDS640x480Data_1   = (SiS_LVDSDataStruct *)SiS310_LVDS640x480Data_1;
69045 -   SiS_Pr->SiS_LCDA1400x1050Data_1  = (SiS_LVDSDataStruct *)SiS310_LCDA1400x1050Data_1;
69046 -   SiS_Pr->SiS_LCDA1400x1050Data_2  = (SiS_LVDSDataStruct *)SiS310_LCDA1400x1050Data_2;
69047 -   SiS_Pr->SiS_LCDA1600x1200Data_1  = (SiS_LVDSDataStruct *)SiS310_LCDA1600x1200Data_1;
69048 -   SiS_Pr->SiS_LCDA1600x1200Data_2  = (SiS_LVDSDataStruct *)SiS310_LCDA1600x1200Data_2;
69049 -   SiS_Pr->SiS_CHTVUNTSCData = (SiS_LVDSDataStruct *)SiS310_CHTVUNTSCData;
69050 -   SiS_Pr->SiS_CHTVONTSCData = (SiS_LVDSDataStruct *)SiS310_CHTVONTSCData;
69051     SiS_Pr->SiS_CHTVUPALData  = (SiS_LVDSDataStruct *)SiS310_CHTVUPALData;
69052     SiS_Pr->SiS_CHTVOPALData  = (SiS_LVDSDataStruct *)SiS310_CHTVOPALData;
69053     SiS_Pr->SiS_CHTVUPALMData = (SiS_LVDSDataStruct *)SiS310_CHTVUPALMData;
69054 @@ -508,6 +532,7 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS
69055     SiS_Pr->SiS_CHTVUPALNData = (SiS_LVDSDataStruct *)SiS310_CHTVUPALNData;
69056     SiS_Pr->SiS_CHTVOPALNData = (SiS_LVDSDataStruct *)SiS310_CHTVOPALNData;
69057     SiS_Pr->SiS_CHTVSOPALData = (SiS_LVDSDataStruct *)SiS310_CHTVSOPALData;
69058 +
69059     SiS_Pr->SiS_PanelType00_1 = (SiS_LVDSDesStruct *)SiS310_PanelType00_1;
69060     SiS_Pr->SiS_PanelType01_1 = (SiS_LVDSDesStruct *)SiS310_PanelType01_1;
69061     SiS_Pr->SiS_PanelType02_1 = (SiS_LVDSDesStruct *)SiS310_PanelType02_1;
69062 @@ -540,19 +565,7 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS
69063     SiS_Pr->SiS_PanelType0d_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0d_2;
69064     SiS_Pr->SiS_PanelType0e_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0e_2;
69065     SiS_Pr->SiS_PanelType0f_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0f_2;
69066 -   SiS_Pr->SiS_PanelTypeNS_1 = (SiS_LVDSDesStruct *)SiS310_PanelTypeNS_1;
69067 -   SiS_Pr->SiS_PanelTypeNS_2 = (SiS_LVDSDesStruct *)SiS310_PanelTypeNS_2;
69068  
69069 -   SiS_Pr->LVDS1024x768Des_1  = (SiS_LVDSDesStruct *)SiS310_PanelType1076_1;
69070 -   SiS_Pr->LVDS1280x1024Des_1 = (SiS_LVDSDesStruct *)SiS310_PanelType1210_1;
69071 -   SiS_Pr->LVDS1400x1050Des_1 = (SiS_LVDSDesStruct *)SiS310_PanelType1296_1 ;
69072 -   SiS_Pr->LVDS1600x1200Des_1 = (SiS_LVDSDesStruct *)SiS310_PanelType1600_1 ;
69073 -   SiS_Pr->LVDS1024x768Des_2  = (SiS_LVDSDesStruct *)SiS310_PanelType1076_2;
69074 -   SiS_Pr->LVDS1280x1024Des_2 = (SiS_LVDSDesStruct *)SiS310_PanelType1210_2;
69075 -   SiS_Pr->LVDS1400x1050Des_2 = (SiS_LVDSDesStruct *)SiS310_PanelType1296_2;
69076 -   SiS_Pr->LVDS1600x1200Des_2 = (SiS_LVDSDesStruct *)SiS310_PanelType1600_2 ;
69077 -
69078 -   /* TW: New from 650/301LV BIOS */
69079     SiS_Pr->SiS_CRT2Part2_1024x768_1  = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1024x768_1;
69080     SiS_Pr->SiS_CRT2Part2_1280x1024_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1280x1024_1;
69081     SiS_Pr->SiS_CRT2Part2_1400x1050_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1400x1050_1;
69082 @@ -566,51 +579,32 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS
69083     SiS_Pr->SiS_CRT2Part2_1400x1050_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1400x1050_3;
69084     SiS_Pr->SiS_CRT2Part2_1600x1200_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1600x1200_3;
69085  
69086 -   SiS_Pr->SiS_CHTVUNTSCDesData = (SiS_LVDSDesStruct *)SiS310_CHTVUNTSCDesData;
69087 -   SiS_Pr->SiS_CHTVONTSCDesData = (SiS_LVDSDesStruct *)SiS310_CHTVONTSCDesData;
69088 -   SiS_Pr->SiS_CHTVUPALDesData  = (SiS_LVDSDesStruct *)SiS310_CHTVUPALDesData;
69089 -   SiS_Pr->SiS_CHTVOPALDesData  = (SiS_LVDSDesStruct *)SiS310_CHTVOPALDesData;
69090 -
69091     SiS_Pr->SiS_LVDSCRT1800x600_1     = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_1;
69092     SiS_Pr->SiS_LVDSCRT11024x768_1    = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_1;
69093     SiS_Pr->SiS_LVDSCRT11280x1024_1   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_1;
69094     SiS_Pr->SiS_LVDSCRT11400x1050_1   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_1;
69095 -   SiS_Pr->SiS_LVDSCRT11280x768_1    = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x768_1;
69096 -   SiS_Pr->SiS_LVDSCRT11024x600_1    = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x600_1;
69097 -   SiS_Pr->SiS_LVDSCRT11152x768_1    = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11152x768_1;
69098     SiS_Pr->SiS_LVDSCRT11600x1200_1   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_1;
69099     SiS_Pr->SiS_LVDSCRT1800x600_1_H   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_1_H;
69100     SiS_Pr->SiS_LVDSCRT11024x768_1_H  = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_1_H;
69101     SiS_Pr->SiS_LVDSCRT11280x1024_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_1_H;
69102     SiS_Pr->SiS_LVDSCRT11400x1050_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_1_H;
69103 -   SiS_Pr->SiS_LVDSCRT11280x768_1_H  = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x768_1_H;
69104 -   SiS_Pr->SiS_LVDSCRT11024x600_1_H  = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x600_1_H;
69105 -   SiS_Pr->SiS_LVDSCRT11152x768_1_H  = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11152x768_1_H;
69106     SiS_Pr->SiS_LVDSCRT11600x1200_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_1_H;
69107     SiS_Pr->SiS_LVDSCRT1800x600_2     = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_2;
69108     SiS_Pr->SiS_LVDSCRT11024x768_2    = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_2;
69109     SiS_Pr->SiS_LVDSCRT11280x1024_2   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_2;
69110     SiS_Pr->SiS_LVDSCRT11400x1050_2   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_2;
69111 -   SiS_Pr->SiS_LVDSCRT11280x768_2    = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x768_2;
69112 -   SiS_Pr->SiS_LVDSCRT11024x600_2    = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x600_2;
69113 -   SiS_Pr->SiS_LVDSCRT11152x768_2    = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11152x768_2;
69114     SiS_Pr->SiS_LVDSCRT11600x1200_2   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_2;
69115     SiS_Pr->SiS_LVDSCRT1800x600_2_H   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_2_H;
69116     SiS_Pr->SiS_LVDSCRT11024x768_2_H  = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_2_H;
69117     SiS_Pr->SiS_LVDSCRT11280x1024_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_2_H;
69118     SiS_Pr->SiS_LVDSCRT11400x1050_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_2_H;
69119 -   SiS_Pr->SiS_LVDSCRT11280x768_2_H  = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x768_2_H;
69120 -   SiS_Pr->SiS_LVDSCRT11024x600_2_H  = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x600_2_H;
69121 -   SiS_Pr->SiS_LVDSCRT11152x768_2_H  = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11152x768_2_H;
69122     SiS_Pr->SiS_LVDSCRT11600x1200_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_2_H;
69123 -   SiS_Pr->SiS_LVDSCRT1XXXxXXX_1     = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1XXXxXXX_1;
69124 -   SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1XXXxXXX_1_H;
69125 -   SiS_Pr->SiS_LVDSCRT1320x480_1     = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1320x480_1;
69126 -   SiS_Pr->SiS_CHTVCRT1UNTSC = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UNTSC;
69127 -   SiS_Pr->SiS_CHTVCRT1ONTSC = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1ONTSC;
69128 -   SiS_Pr->SiS_CHTVCRT1UPAL  = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UPAL;
69129 -   SiS_Pr->SiS_CHTVCRT1OPAL  = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1OPAL;
69130 -   SiS_Pr->SiS_CHTVCRT1SOPAL = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1SOPAL;
69131 +   SiS_Pr->SiS_CHTVCRT1UNTSC         = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UNTSC;
69132 +   SiS_Pr->SiS_CHTVCRT1ONTSC         = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1ONTSC;
69133 +   SiS_Pr->SiS_CHTVCRT1UPAL          = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UPAL;
69134 +   SiS_Pr->SiS_CHTVCRT1OPAL          = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1OPAL;
69135 +   SiS_Pr->SiS_CHTVCRT1SOPAL         = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1SOPAL;
69136 +
69137     SiS_Pr->SiS_CHTVReg_UNTSC = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UNTSC;
69138     SiS_Pr->SiS_CHTVReg_ONTSC = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_ONTSC;
69139     SiS_Pr->SiS_CHTVReg_UPAL  = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UPAL;
69140 @@ -620,6 +614,7 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS
69141     SiS_Pr->SiS_CHTVReg_UPALN = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UPALN;
69142     SiS_Pr->SiS_CHTVReg_OPALN = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPALN;
69143     SiS_Pr->SiS_CHTVReg_SOPAL = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_SOPAL;
69144 +
69145     SiS_Pr->SiS_LCDACRT1800x600_1     = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT1800x600_1;
69146     SiS_Pr->SiS_LCDACRT11024x768_1    = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_1;
69147     SiS_Pr->SiS_LCDACRT11280x1024_1   = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_1;
69148 @@ -640,6 +635,7 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS
69149     SiS_Pr->SiS_LCDACRT11280x1024_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_2_H;
69150     SiS_Pr->SiS_LCDACRT11400x1050_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_2_H;
69151     SiS_Pr->SiS_LCDACRT11600x1200_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_2_H;
69152 +
69153     SiS_Pr->SiS_CHTVVCLKUNTSC = SiS310_CHTVVCLKUNTSC;
69154     SiS_Pr->SiS_CHTVVCLKONTSC = SiS310_CHTVVCLKONTSC;
69155     SiS_Pr->SiS_CHTVVCLKUPAL  = SiS310_CHTVVCLKUPAL;
69156 @@ -662,9 +658,13 @@ InitTo310Pointer(SiS_Private *SiS_Pr, PS
69157     SiS_Pr->SiS_Panel1152x864  = Panel_1152x864;
69158     SiS_Pr->SiS_Panel1280x768  = Panel_1280x768;
69159     SiS_Pr->SiS_Panel1024x600  = Panel_1024x600;
69160 +   SiS_Pr->SiS_Panel640x480_2 = Panel_640x480_2;
69161 +   SiS_Pr->SiS_Panel640x480_3 = Panel_640x480_3;
69162     SiS_Pr->SiS_PanelMax       = Panel_320x480;    /* TW: highest value */
69163     SiS_Pr->SiS_PanelMinLVDS   = Panel_800x600;    /* TW: lowest value LVDS/LCDA */
69164     SiS_Pr->SiS_PanelMin301    = Panel_1024x768;   /* TW: lowest value 301 */
69165 +   SiS_Pr->SiS_PanelCustom    = Panel_Custom;
69166 +   SiS_Pr->SiS_PanelBarco1366 = 255;
69167  }
69168  #endif
69169  
69170 @@ -727,7 +727,9 @@ SiSInit(SiS_Private *SiS_Pr, PSIS_HW_DEV
69171        (HwDeviceExtension->jChipType == SIS_550) ||
69172        (HwDeviceExtension->jChipType == SIS_650) ||
69173        (HwDeviceExtension->jChipType == SIS_740) ||
69174 -      (HwDeviceExtension->jChipType == SIS_330))
69175 +      (HwDeviceExtension->jChipType == SIS_330) ||
69176 +      (HwDeviceExtension->jChipType == SIS_660) ||
69177 +      (HwDeviceExtension->jChipType == SIS_760))
69178       InitTo310Pointer(SiS_Pr, HwDeviceExtension);
69179  #endif
69180  
69181 @@ -896,7 +898,9 @@ SiSInit(SiS_Private *SiS_Pr, PSIS_HW_DEV
69182        (HwDeviceExtension->jChipType == SIS_550) ||
69183        (HwDeviceExtension->jChipType == SIS_650) ||
69184        (HwDeviceExtension->jChipType == SIS_740) ||
69185 -      (HwDeviceExtension->jChipType == SIS_330)) {
69186 +      (HwDeviceExtension->jChipType == SIS_330) ||
69187 +      (HwDeviceExtension->jChipType == SIS_660) ||
69188 +      (HwDeviceExtension->jChipType == SIS_760)) {
69189         for(i=0x12; i<=0x1B; i++) SiS_SetReg1(SiS_Pr->SiS_P3c4,i,0);
69190         for(i=0x79; i<=0x7C; i++) SiS_SetReg1(SiS_Pr->SiS_P3d4,i,0);
69191     }
69192 @@ -953,14 +957,16 @@ SiSInit(SiS_Private *SiS_Pr, PSIS_HW_DEV
69193     if((HwDeviceExtension->jChipType == SIS_315H)   ||
69194        (HwDeviceExtension->jChipType == SIS_315)    ||
69195        (HwDeviceExtension->jChipType == SIS_315PRO) ||
69196 -      (HwDeviceExtension->jChipType == SIS_330) ) {
69197 +      (HwDeviceExtension->jChipType == SIS_330)) {
69198         if((*SiS_Pr->pSiS_SoftSetting & SoftDRAMType) == 0) {
69199                 temp = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3A) & 0x03;
69200          }
69201     }
69202     if((HwDeviceExtension->jChipType == SIS_550) ||
69203        (HwDeviceExtension->jChipType == SIS_740) ||
69204 -      (HwDeviceExtension->jChipType == SIS_650)) {
69205 +      (HwDeviceExtension->jChipType == SIS_650) ||
69206 +      (HwDeviceExtension->jChipType == SIS_660) ||
69207 +      (HwDeviceExtension->jChipType == SIS_760)) {
69208          if((*SiS_Pr->pSiS_SoftSetting & SoftDRAMType) == 0) {
69209                 temp = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x07;
69210          }
69211 @@ -977,7 +983,7 @@ SiSInit(SiS_Private *SiS_Pr, PSIS_HW_DEV
69212     if((HwDeviceExtension->jChipType != SIS_540) &&
69213        (HwDeviceExtension->jChipType != SIS_630) &&
69214        (HwDeviceExtension->jChipType != SIS_730)){
69215 -       for(i=0x15;i<0x1C;i++) {
69216 +       for(i=0x15; i<0x1C; i++) {
69217                     SiS_SetReg1(SiS_Pr->SiS_P3c4,i,SiS_Pr->SiS_SR15[i-0x15][SiS_Pr->SiS_RAMType]);
69218         }
69219     }
69220 @@ -1023,7 +1029,9 @@ SiSInit(SiS_Private *SiS_Pr, PSIS_HW_DEV
69221        (HwDeviceExtension->jChipType == SIS_550) ||
69222        (HwDeviceExtension->jChipType == SIS_650) ||
69223        (HwDeviceExtension->jChipType == SIS_740) ||
69224 -      (HwDeviceExtension->jChipType == SIS_330))
69225 +      (HwDeviceExtension->jChipType == SIS_330) ||
69226 +      (HwDeviceExtension->jChipType == SIS_660) ||
69227 +      (HwDeviceExtension->jChipType == SIS_760))
69228         SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x2E,0x08);    /* use VB */
69229  #endif
69230  
69231 @@ -1180,7 +1188,9 @@ SiS_Set_LVDS_TRUMPION(SiS_Private *SiS_P
69232  #ifdef SIS315H
69233    if((HwDeviceExtension->jChipType == SIS_650) ||
69234       (HwDeviceExtension->jChipType == SIS_740) ||
69235 -     (HwDeviceExtension->jChipType == SIS_330)) {
69236 +     (HwDeviceExtension->jChipType == SIS_330) ||
69237 +     (HwDeviceExtension->jChipType == SIS_660) ||
69238 +     (HwDeviceExtension->jChipType == SIS_760)) {
69239  #if 0 /* TW: This is not required */
69240          /* TW: Read POWER_ON_TRAP and copy to CR37 */
69241         temp = (UCHAR)SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1A);
69242 @@ -1299,7 +1309,7 @@ SiS_ChkBUSWidth_300(SiS_Private *SiS_Pr,
69243  #endif
69244  /* ===============  SiS 300 dram sizing end    =============== */
69245  
69246 -/* ============  SiS 310/325 dram sizing begin  ============== */
69247 +/* ============  SiS 315 dram sizing begin  ============== */
69248  #ifdef SIS315H
69249  
69250  /* TW: Moved Get310DRAMType further down */
69251 @@ -1893,8 +1903,7 @@ SiS_Get310DRAMType(SiS_Private *SiS_Pr, 
69252     if(*SiS_Pr->pSiS_SoftSetting & SoftDRAMType) {
69253       data = *SiS_Pr->pSiS_SoftSetting & 0x03;
69254     } else {
69255 -     if((HwDeviceExtension->jChipType > SIS_315PRO) &&
69256 -        (HwDeviceExtension->jChipType < SIS_330)) {
69257 +     if(IS_SIS550650740660) {
69258          data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x07;
69259       } else {  /* TW: 315, 330 */
69260          data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3a) & 0x03;
69261 @@ -1934,13 +1943,17 @@ void SiSRegInit(SiS_Private *SiS_Pr, USH
69262     SiS_Pr->SiS_P3c7 = BaseAddr + 0x17;
69263     SiS_Pr->SiS_P3c8 = BaseAddr + 0x18;
69264     SiS_Pr->SiS_P3c9 = BaseAddr + 0x19;
69265 -   SiS_Pr->SiS_P3da = BaseAddr + 0x2A;
69266 -   SiS_Pr->SiS_Part1Port = BaseAddr + SIS_CRT2_PORT_04;   /* Digital video interface registers (LCD) */
69267 -   SiS_Pr->SiS_Part2Port = BaseAddr + SIS_CRT2_PORT_10;   /* 301 TV Encoder registers */
69268 -   SiS_Pr->SiS_Part3Port = BaseAddr + SIS_CRT2_PORT_12;   /* 301 Macrovision registers */
69269 -   SiS_Pr->SiS_Part4Port = BaseAddr + SIS_CRT2_PORT_14;   /* 301 VGA2 (and LCD) registers */
69270 -   SiS_Pr->SiS_Part5Port = BaseAddr + SIS_CRT2_PORT_14+2; /* 301 palette address port registers */
69271 -   SiS_Pr->SiS_DDC_Port = BaseAddr + 0x14;                /* DDC Port ( = P3C4, SR11/0A) */
69272 +   SiS_Pr->SiS_P3cb = BaseAddr + 0x1b;
69273 +   SiS_Pr->SiS_P3cd = BaseAddr + 0x1d;
69274 +   SiS_Pr->SiS_P3da = BaseAddr + 0x2a;
69275 +   SiS_Pr->SiS_Part1Port = BaseAddr + SIS_CRT2_PORT_04;     /* Digital video interface registers (LCD) */
69276 +   SiS_Pr->SiS_Part2Port = BaseAddr + SIS_CRT2_PORT_10;     /* 301 TV Encoder registers */
69277 +   SiS_Pr->SiS_Part3Port = BaseAddr + SIS_CRT2_PORT_12;     /* 301 Macrovision registers */
69278 +   SiS_Pr->SiS_Part4Port = BaseAddr + SIS_CRT2_PORT_14;     /* 301 VGA2 (and LCD) registers */
69279 +   SiS_Pr->SiS_Part5Port = BaseAddr + SIS_CRT2_PORT_14 + 2; /* 301 palette address port registers */
69280 +   SiS_Pr->SiS_DDC_Port = BaseAddr + 0x14;                  /* DDC Port ( = P3C4, SR11/0A) */
69281 +   SiS_Pr->SiS_VidCapt = BaseAddr + SIS_VIDEO_CAPTURE;
69282 +   SiS_Pr->SiS_VidPlay = BaseAddr + SIS_VIDEO_PLAYBACK;
69283  }
69284  
69285  void
69286 @@ -1965,7 +1978,9 @@ SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_
69287        (HwDeviceExtension->jChipType == SIS_550) ||
69288        (HwDeviceExtension->jChipType == SIS_650) ||
69289        (HwDeviceExtension->jChipType == SIS_740) ||
69290 -      (HwDeviceExtension->jChipType == SIS_330)) {
69291 +      (HwDeviceExtension->jChipType == SIS_330) ||
69292 +      (HwDeviceExtension->jChipType == SIS_660) ||
69293 +      (HwDeviceExtension->jChipType == SIS_760)) {
69294        /* TW: This seems to be done the same way on these chipsets */
69295        SiS_SetReg1(SiS_Pr->SiS_P3c4,0x20,0xa1);
69296        SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1E,0xFF,0x5A);
69297 @@ -1987,10 +2002,14 @@ SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_
69298  
69299     SiS_Pr->SiS_ChrontelInit = 0;
69300  
69301 -   if((ModeNo == 0x5a) || (ModeNo == 0x5b)) {
69302 -       SiS_Pr->SiS_IF_DEF_DSTN = 1;   /* for 550 dstn */
69303 -       SiS_Pr->SiS_IF_DEF_FSTN = 1;   /* for fstn */
69304 +#if 0
69305 +   if(HwDeviceExtension->jChipType >= SIS_315H) {
69306 +      if((ModeNo == 0x5a) || (ModeNo == 0x5b)) {
69307 +        SiS_Pr->SiS_IF_DEF_DSTN = 1;   /* for 550 dstn */
69308 +        SiS_Pr->SiS_IF_DEF_FSTN = 1;   /* for fstn */
69309 +      }
69310     }
69311 +#endif
69312  
69313  #ifdef SIS300
69314     if((HwDeviceExtension->jChipType == SIS_540) ||
69315 @@ -2015,11 +2034,15 @@ SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_
69316     if((HwDeviceExtension->jChipType == SIS_550) ||
69317        (HwDeviceExtension->jChipType == SIS_650) ||
69318        (HwDeviceExtension->jChipType == SIS_740) ||
69319 -      (HwDeviceExtension->jChipType == SIS_330))
69320 +      (HwDeviceExtension->jChipType == SIS_330) ||
69321 +      (HwDeviceExtension->jChipType == SIS_660) ||
69322 +      (HwDeviceExtension->jChipType == SIS_760))
69323      {
69324 -        /* TW: CR37 is different on 310/325 series */
69325 +        /* TW: CR37 is different on 315 series */
69326 +#if 0
69327          if(SiS_Pr->SiS_IF_DEF_FSTN)                       /* fstn: set CR37=0x04 */
69328               SiS_SetReg1(SiS_Pr->SiS_P3d4,0x37,0x04);      /* (fake LVDS bridge) */
69329 +#endif
69330  
69331         temp=SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37);
69332         temp = (temp & 0x0E) >> 1;
69333 @@ -2044,7 +2067,9 @@ SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_
69334        (HwDeviceExtension->jChipType == SIS_550) ||
69335        (HwDeviceExtension->jChipType == SIS_650) ||
69336        (HwDeviceExtension->jChipType == SIS_740) ||
69337 -      (HwDeviceExtension->jChipType == SIS_330))
69338 +      (HwDeviceExtension->jChipType == SIS_330) ||
69339 +      (HwDeviceExtension->jChipType == SIS_660) ||
69340 +      (HwDeviceExtension->jChipType == SIS_760))
69341       InitTo310Pointer(SiS_Pr, HwDeviceExtension);
69342  #endif
69343  
69344 @@ -2073,14 +2098,21 @@ SiSDetermineROMUsage(SiS_Private *SiS_Pr
69345               SiS_Pr->SiS_UseROM = TRUE;
69346          else SiS_Pr->SiS_UseROM = FALSE;
69347       } else if(HwDeviceExtension->jChipType < SIS_315H) {
69348 +#if 0
69349          /* TW: Rest of 300 series: We don't use the ROM image if
69350          *     the BIOS version < 2.0.0 as such old BIOSes don't
69351          *     have the needed data at the expected locations.
69352          */
69353          if(ROMAddr[0x06] < '2')  SiS_Pr->SiS_UseROM = FALSE;
69354         else                     SiS_Pr->SiS_UseROM = TRUE;
69355 +#else
69356 +       /* Sony's VAIO BIOS 1.09 follows the standard, so perhaps
69357 +        * the others do as well
69358 +        */
69359 +       SiS_Pr->SiS_UseROM = TRUE;
69360 +#endif
69361       } else {
69362 -        /* TW: 310/325/330 series stick to the standard */
69363 +        /* TW: 315/330 series stick to the standard */
69364         SiS_Pr->SiS_UseROM = TRUE;
69365       }
69366     } else SiS_Pr->SiS_UseROM = FALSE;
69367 @@ -2104,24 +2136,27 @@ SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS
69368     SiS_Pr->UseCustomMode = FALSE;
69369  
69370     if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) {
69371 -   
69372 -         xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting custom mode %dx%d\n", 
69373 -               SiS_Pr->CHDisplay, SiS_Pr->CVDisplay);
69374 -               
69375 +
69376 +         xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting custom mode %dx%d\n",
69377 +               SiS_Pr->CHDisplay,
69378 +               (mode->Flags & V_INTERLACE ? SiS_Pr->CVDisplay * 2 :
69379 +                  (mode->Flags & V_DBLSCAN ? SiS_Pr->CVDisplay / 2 :
69380 +                     SiS_Pr->CVDisplay)));
69381 +
69382          return(SiSSetMode(SiS_Pr, HwDeviceExtension, pScrn, ModeNo, TRUE));
69383 -   
69384 +
69385     }
69386 -   
69387 -   ModeNo = SiS_CalcModeIndex(pScrn, mode);
69388 +
69389 +   ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->HaveCustomModes);
69390     if(!ModeNo) return FALSE;
69391  
69392 -   xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting mode 0x%x\n", ModeNo);
69393 +   xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting standard mode 0x%x\n", ModeNo);
69394  
69395 -   return(SiSSetMode(SiS_Pr, HwDeviceExtension, pScrn, ModeNo, TRUE));   
69396 +   return(SiSSetMode(SiS_Pr, HwDeviceExtension, pScrn, ModeNo, TRUE));
69397  }
69398  
69399  #ifdef SISDUALHEAD
69400 -/* TW: Set CRT1 mode (used for dual head) */
69401 +/* TW: Set CRT1 mode (used for dual head and MergedFB) */
69402  BOOLEAN
69403  SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, ScrnInfoPtr pScrn,
69404                 DisplayModePtr mode, BOOLEAN IsCustom)
69405 @@ -2134,31 +2169,37 @@ SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, 
69406     SISEntPtr pSiSEnt = pSiS->entityPrivate;
69407     unsigned char backupreg=0;
69408     BOOLEAN backupcustom;
69409 -
69410     UShort  ModeNo=0;
69411     
69412     SiS_Pr->UseCustomMode = FALSE;
69413 -   
69414 +
69415     if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) {
69416 -   
69417 +
69418 +         USHORT temptemp = SiS_Pr->CVDisplay;
69419 +
69420 +         if(SiS_Pr->CModeFlag & DoubleScanMode)     temptemp >>= 1;
69421 +         else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1;
69422 +
69423           xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
69424 -               "Setting custom mode %dx%d in CRT1\n", 
69425 -               SiS_Pr->CHDisplay, SiS_Pr->CVDisplay);
69426 +               "Setting custom mode %dx%d on CRT1\n",
69427 +               SiS_Pr->CHDisplay, temptemp);
69428          ModeNo = 0xfe;
69429 -        
69430 +
69431     } else {
69432  
69433 -         ModeNo = SiS_CalcModeIndex(pScrn, mode);
69434 +         ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->HaveCustomModes);
69435           if(!ModeNo) return FALSE;
69436  
69437           xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
69438 -               "Setting mode 0x%x on CRT1\n", ModeNo);
69439 +               "Setting standard mode 0x%x on CRT1\n", ModeNo);
69440     }
69441  
69442     SiSInitPtr(SiS_Pr, HwDeviceExtension);
69443  
69444     SiSRegInit(SiS_Pr, BaseAddr);
69445  
69446 +   SiS_GetSysFlags(SiS_Pr, HwDeviceExtension);
69447 +
69448     SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff);
69449  
69450     SiSInitPCIetc(SiS_Pr, HwDeviceExtension);
69451 @@ -2167,7 +2208,7 @@ SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, 
69452  
69453     SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr);
69454  
69455 -   /* TW: We don't clear the buffer under X */
69456 +   /* We don't clear the buffer under X */
69457     SiS_Pr->SiS_flag_clearbuffer = 0;
69458  
69459     /* 1.Openkey */
69460 @@ -2175,8 +2216,8 @@ SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, 
69461  
69462     SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr);
69463  
69464 +   /* 2.Get ModeID Table  */
69465     if(!SiS_Pr->UseCustomMode) {
69466 -      /* 2.Get ModeID Table  */
69467        temp = SiS_SearchModeID(SiS_Pr, ROMAddr,&ModeNo,&ModeIdIndex);
69468        if(temp == 0)  return(0);
69469     } else {
69470 @@ -2201,53 +2242,65 @@ SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, 
69471     SiS_GetLCDResInfo(SiS_Pr, ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension);
69472  
69473     if(HwDeviceExtension->jChipType >= SIS_315H) {
69474 -      if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
69475 -         if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x08)  {
69476 +      if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x08)  {
69477 +         if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
69478              if(ModeNo != 0x10)  SiS_Pr->SiS_SetFlag |= SetDOSMode;
69479 +         } else if((IS_SIS651) && (SiS_Pr->SiS_VBType & VB_NoLCD)) {
69480 +            SiS_Pr->SiS_SetFlag |= SetDOSMode;
69481           }
69482        }
69483  
69484 -      /* TW: New from 650/LV 1.10.6x */
69485        if(IS_SIS650) {
69486 -          if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
69487 -             SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f);
69488 -             SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7);
69489 -         }
69490 +         if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
69491 +           SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f);
69492 +           if(IS_SIS651) SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x20);
69493 +           SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7);
69494 +        }
69495        }
69496     }
69497  
69498 -   /* TW: Set mode on CRT1 */
69499 +   /* Set mode on CRT1 */
69500     SiS_SetCRT1Group(SiS_Pr, ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex,BaseAddr);
69501  
69502 -   pSiSEnt->CRT1ModeNo = ModeNo;
69503 -   pSiSEnt->CRT1DMode = mode;
69504 -
69505 -   /* TW: SetPitch: Adapt to virtual size & position */
69506 +   /* SetPitch: Adapt to virtual size & position */
69507     SiS_SetPitchCRT1(SiS_Pr, pScrn, BaseAddr);
69508  
69509 +   if(pSiS->DualHeadMode) {
69510 +      pSiSEnt->CRT1ModeNo = ModeNo;
69511 +      pSiSEnt->CRT1DMode = mode;
69512 +   }
69513 +
69514 +   if(SiS_Pr->UseCustomMode) {
69515 +      SiS_Pr->CRT1UsesCustomMode = TRUE;
69516 +      SiS_Pr->CSRClock_CRT1 = SiS_Pr->CSRClock;
69517 +      SiS_Pr->CModeFlag_CRT1 = SiS_Pr->CModeFlag;
69518 +   } else {
69519 +      SiS_Pr->CRT1UsesCustomMode = FALSE;
69520 +   }
69521 +
69522     /* We have to reset CRT2 if changing mode on CRT1 */
69523 -   if(pSiSEnt->CRT2ModeNo != -1) {
69524 -        xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
69525 -                               "(Re-)Setting mode 0x%x on CRT2\n",
69526 -                               pSiSEnt->CRT2ModeNo);
69527 -       backupcustom = SiS_Pr->UseCustomMode;
69528 -       if(SiS_Pr->UseCustomMode) {
69529 -          SiS_Pr->CRT1UsesCustomMode = TRUE;
69530 -       } else {
69531 -          SiS_Pr->CRT1UsesCustomMode = FALSE;
69532 -       }
69533 -       SiSBIOSSetModeCRT2(SiS_Pr, HwDeviceExtension, pSiSEnt->pScrn_1,
69534 -                               pSiSEnt->CRT2DMode);
69535 -       SiS_Pr->UseCustomMode = backupcustom;
69536 -       SiS_Pr->CRT1UsesCustomMode = FALSE;
69537 +   if(pSiS->DualHeadMode) {
69538 +      if(pSiSEnt->CRT2ModeNo != -1) {
69539 +         xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
69540 +                               "(Re-)Setting mode for CRT2\n");
69541 +        backupcustom = SiS_Pr->UseCustomMode;
69542 +        SiSBIOSSetModeCRT2(SiS_Pr, HwDeviceExtension, pSiSEnt->pScrn_1,
69543 +                           pSiSEnt->CRT2DMode, pSiSEnt->CRT2IsCustom);
69544 +        SiS_Pr->UseCustomMode = backupcustom;
69545 +      }
69546     }
69547 -   
69548 +
69549 +   /* Warning: From here, the custom mode entries in SiS_Pr are
69550 +    * possibly overwritten
69551 +    */
69552 +
69553     SiS_HandleCRT1(SiS_Pr);
69554  
69555 +   SiS_StrangeStuff(SiS_Pr, HwDeviceExtension);
69556 +
69557     SiS_DisplayOn(SiS_Pr);
69558     SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF);
69559  
69560 -   /* TW: New from 650/LV 1.10.6x and 1.10.7w, 630/301B 2.06.50 */
69561     if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
69562        if(HwDeviceExtension->jChipType >= SIS_315H) {
69563          SiS_SetReg1(SiS_Pr->SiS_P3d4,0x38,backupreg);
69564 @@ -2266,7 +2319,7 @@ SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, 
69565  /* TW: Set CRT2 mode (used for dual head) */
69566  BOOLEAN
69567  SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, ScrnInfoPtr pScrn,
69568 -               DisplayModePtr mode)
69569 +               DisplayModePtr mode, BOOLEAN IsCustom)
69570  {
69571     ULONG   temp;
69572     USHORT  ModeIdIndex;
69573 @@ -2276,16 +2329,52 @@ SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, 
69574     SISPtr  pSiS     = SISPTR(pScrn);
69575     SISEntPtr pSiSEnt = pSiS->entityPrivate;
69576     unsigned char tempr1, tempr2, backupreg=0;
69577 -   
69578 +
69579     SiS_Pr->UseCustomMode = FALSE;
69580 -   
69581 -   ModeNo = SiS_CalcModeIndex(pScrn, mode);
69582 -   if(!ModeNo) return FALSE;
69583 +
69584 +   /* Remember: Custom modes for CRT2 are ONLY supported
69585 +    *          -) on 315/330 series,
69586 +    *           -) on the 301 and 30xB, and
69587 +    *           -) if CRT2 is LCD or VGA
69588 +    */
69589 +
69590 +   if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) {
69591 +
69592 +        ModeNo = 0xfe;
69593 +
69594 +   } else {
69595 +
69596 +         BOOLEAN havecustommodes = pSiS->HaveCustomModes;
69597 +
69598 +#ifdef SISMERGED
69599 +        if(pSiS->MergedFB) havecustommodes = pSiS->HaveCustomModes2;
69600 +#endif
69601 +
69602 +         ModeNo = SiS_CalcModeIndex(pScrn, mode, havecustommodes);
69603 +         if(!ModeNo) return FALSE;
69604 +
69605 +   }
69606 +
69607 +   /* Save mode info so we can set it from within SetMode for CRT1 */
69608 +   if(pSiS->DualHeadMode) {
69609 +      pSiSEnt->CRT2ModeNo = ModeNo;
69610 +      pSiSEnt->CRT2DMode = mode;
69611 +      pSiSEnt->CRT2IsCustom = IsCustom;
69612 +
69613 +      /* We can't set CRT2 mode before CRT1 mode is set */
69614 +      if(pSiSEnt->CRT1ModeNo == -1) {
69615 +        xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
69616 +               "Setting CRT2 mode delayed until after setting CRT1 mode\n");
69617 +        return TRUE;
69618 +      }
69619 +   }
69620  
69621     SiSInitPtr(SiS_Pr, HwDeviceExtension);
69622  
69623     SiSRegInit(SiS_Pr, BaseAddr);
69624  
69625 +   SiS_GetSysFlags(SiS_Pr, HwDeviceExtension);
69626 +
69627     SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff);
69628  
69629     SiSInitPCIetc(SiS_Pr, HwDeviceExtension);
69630 @@ -2294,22 +2383,26 @@ SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, 
69631  
69632     SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr);
69633  
69634 -   /* TW: We don't clear the buffer under X */
69635 +   /* We don't clear the buffer under X */
69636     SiS_Pr->SiS_flag_clearbuffer=0;
69637  
69638 -   /* TW: Save ModeNo so we can set it from within SetMode for CRT1 */
69639 -   pSiSEnt->CRT2ModeNo = ModeNo;
69640 -   pSiSEnt->CRT2DMode = mode;
69641 -
69642 -   /* TW: We can't set CRT2 mode before CRT1 mode is set */
69643 -   if(pSiSEnt->CRT1ModeNo == -1) {
69644 -       xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
69645 -               "Setting CRT2 mode delayed until after setting CRT1 mode\n");
69646 -       return TRUE;
69647 -   }
69648 +   if(SiS_Pr->UseCustomMode) {
69649 +
69650 +      USHORT temptemp = SiS_Pr->CVDisplay;
69651 +
69652 +      if(SiS_Pr->CModeFlag & DoubleScanMode)     temptemp >>= 1;
69653 +      else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1;
69654 +
69655 +      xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
69656 +         "Setting custom mode %dx%d on CRT2\n",
69657 +         SiS_Pr->CHDisplay, temptemp);
69658  
69659 -   xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
69660 -               "Setting mode 0x%x on CRT2\n", ModeNo);
69661 +   } else {
69662 +
69663 +      xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
69664 +         "Setting standard mode 0x%x on CRT2\n", ModeNo);
69665 +
69666 +   }
69667  
69668     /* 1.Openkey */
69669     SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86);
69670 @@ -2317,10 +2410,14 @@ SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, 
69671     SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr);
69672  
69673     /* 2.Get ModeID */
69674 -   temp = SiS_SearchModeID(SiS_Pr, ROMAddr,&ModeNo,&ModeIdIndex);
69675 -   if(temp == 0)  return(0);
69676 +   if(!SiS_Pr->UseCustomMode) {
69677 +      temp = SiS_SearchModeID(SiS_Pr, ROMAddr,&ModeNo,&ModeIdIndex);
69678 +      if(temp == 0)  return(0);
69679 +   } else {
69680 +      ModeIdIndex = 0;
69681 +   }
69682  
69683 -   /* TW: Determine VBType (301,301B,301LV,302B,302LV) */
69684 +   /* Determine VBType (301,301B,301LV,302B,302LV) */
69685     SiS_GetVBType(SiS_Pr, BaseAddr,HwDeviceExtension);
69686  
69687     if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
69688 @@ -2343,15 +2440,22 @@ SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, 
69689        }
69690     }
69691  
69692 -   /* TW: Get VB information (connectors, connected devices) */
69693 -   SiS_GetVBInfo(SiS_Pr, BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,1);
69694 +   /* Get VB information (connectors, connected devices) */
69695 +   if(!SiS_Pr->UseCustomMode) {
69696 +      SiS_GetVBInfo(SiS_Pr, BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,1);
69697 +   } else {
69698 +      /* If this is a custom mode, we don't check the modeflag for CRT2Mode */
69699 +      SiS_GetVBInfo(SiS_Pr, BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,0);
69700 +   }
69701     SiS_SetHiVision(SiS_Pr, BaseAddr,HwDeviceExtension);
69702     SiS_GetLCDResInfo(SiS_Pr, ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension);
69703  
69704     if(HwDeviceExtension->jChipType >= SIS_315H) {
69705 -      if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
69706 -         if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x08)  {
69707 +      if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x08)  {
69708 +         if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
69709              if(ModeNo != 0x10)  SiS_Pr->SiS_SetFlag |= SetDOSMode;
69710 +         } else if((IS_SIS651) && (SiS_Pr->SiS_VBType & VB_NoLCD)) {
69711 +            SiS_Pr->SiS_SetFlag |= SetDOSMode;
69712           }
69713        }
69714     }
69715 @@ -2364,17 +2468,19 @@ SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, 
69716       case VB_CHIP_302:
69717       case VB_CHIP_302B:
69718       case VB_CHIP_302LV:
69719 -        SiS_SetCRT2Group301(SiS_Pr, BaseAddr,ROMAddr,ModeNo,HwDeviceExtension);
69720 +        SiS_SetCRT2Group(SiS_Pr, BaseAddr,ROMAddr,ModeNo,HwDeviceExtension);
69721          break;
69722       case VB_CHIP_UNKNOWN:
69723 -        if (SiS_Pr->SiS_IF_DEF_LVDS     == 1 ||
69724 -           SiS_Pr->SiS_IF_DEF_CH70xx   != 0 ||
69725 -           SiS_Pr->SiS_IF_DEF_TRUMPION != 0) {
69726 -               SiS_SetCRT2Group301(SiS_Pr,BaseAddr,ROMAddr,ModeNo,HwDeviceExtension);
69727 +        if(SiS_Pr->SiS_IF_DEF_LVDS     == 1 ||
69728 +          SiS_Pr->SiS_IF_DEF_CH70xx   != 0 ||
69729 +          SiS_Pr->SiS_IF_DEF_TRUMPION != 0) {
69730 +           SiS_SetCRT2Group(SiS_Pr,BaseAddr,ROMAddr,ModeNo,HwDeviceExtension);
69731         }
69732          break;
69733     }
69734  
69735 +   SiS_StrangeStuff(SiS_Pr, HwDeviceExtension);
69736 +
69737     SiS_DisplayOn(SiS_Pr);
69738     SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF);
69739  
69740 @@ -2386,7 +2492,6 @@ SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, 
69741        }
69742     }
69743  
69744 -   /* TW: New from 650/LV 1.10.6x and 1.10.7w, 630 2.06.50 */
69745     if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
69746        if(HwDeviceExtension->jChipType >= SIS_315H) {
69747          if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
69748 @@ -2412,7 +2517,7 @@ SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, 
69749        }
69750     }
69751  
69752 -   /* TW: SetPitch: Adapt to virtual size & position */
69753 +   /* SetPitch: Adapt to virtual size & position */
69754     SiS_SetPitchCRT2(SiS_Pr, pScrn, BaseAddr);
69755  
69756     return TRUE;
69757 @@ -2442,12 +2547,14 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_
69758     
69759     if(SiS_Pr->UseCustomMode) {
69760        ModeNo = 0xfe;
69761 -   }      
69762 -   
69763 +   }
69764 +
69765     SiSInitPtr(SiS_Pr, HwDeviceExtension);
69766  
69767     SiSRegInit(SiS_Pr, BaseAddr);
69768  
69769 +   SiS_GetSysFlags(SiS_Pr, HwDeviceExtension);
69770 +
69771  #ifdef LINUX_XF86
69772     if(pScrn) SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff);
69773     else
69774 @@ -2458,7 +2565,7 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_
69775  #ifdef TWDEBUG
69776     xf86DrvMsg(0, X_INFO, "VGAInfo 0x%02x\n", SiS_Pr->SiS_VGAINFO);
69777  #endif
69778 -#endif          
69779 +#endif
69780  
69781     SiSInitPCIetc(SiS_Pr, HwDeviceExtension);
69782  
69783 @@ -2469,10 +2576,10 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_
69784     if(!SiS_Pr->UseCustomMode) {
69785        /* TW: Shift the clear-buffer-bit away */
69786        ModeNo = ((ModeNo & 0x80) << 8) | (ModeNo & 0x7f);
69787 -   }      
69788 +   }
69789  
69790  #ifdef LINUX_XF86
69791 -   /* TW: We never clear the buffer in X */
69792 +   /* We never clear the buffer in X */
69793     ModeNo |= 0x8000;
69794  #endif
69795  
69796 @@ -2490,21 +2597,21 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_
69797     SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr);
69798  
69799     if(!SiS_Pr->UseCustomMode) {
69800 -   
69801 +
69802        /* 2.Get ModeID Table  */
69803        temp = SiS_SearchModeID(SiS_Pr,ROMAddr,&ModeNo,&ModeIdIndex);
69804        if(temp == 0) return(0);
69805 -      
69806 +
69807     } else {
69808 -   
69809 +
69810        ModeIdIndex = 0;
69811 -      
69812 +
69813     }
69814 -    
69815 -   /* TW: Determine VBType (301,301B,301LV,302B,302LV) */
69816 +
69817 +   /* Determine VBType (301,301B,301LV,302B,302LV) */
69818     SiS_GetVBType(SiS_Pr,BaseAddr,HwDeviceExtension);
69819  
69820 -   /* TW: Init/restore some VB registers */
69821 +   /* Init/restore some VB registers */
69822     if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
69823         if(HwDeviceExtension->jChipType >= SIS_315H) {
69824           SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension,BaseAddr);
69825 @@ -2525,8 +2632,12 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_
69826         }
69827     }
69828     
69829 -   /* TW: Get VB information (connectors, connected devices) */
69830 -   SiS_GetVBInfo(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,1);
69831 +   /* Get VB information (connectors, connected devices) */
69832 +   if(SiS_Pr->UseCustomMode) {
69833 +      SiS_GetVBInfo(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,0);
69834 +   } else {
69835 +      SiS_GetVBInfo(SiS_Pr,BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,1);
69836 +   }
69837     SiS_SetHiVision(SiS_Pr,BaseAddr,HwDeviceExtension);
69838     SiS_GetLCDResInfo(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension);
69839  
69840 @@ -2535,22 +2646,32 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_
69841     if(!temp) return(0);
69842  
69843     if(HwDeviceExtension->jChipType >= SIS_315H) {
69844 -      if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
69845 -         if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x08)  {
69846 +      if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x08)  {
69847 +         if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
69848              if(ModeNo != 0x10)  SiS_Pr->SiS_SetFlag |= SetDOSMode;
69849 +         } else if((IS_SIS651) && (SiS_Pr->SiS_VBType & VB_NoLCD)) {
69850 +            SiS_Pr->SiS_SetFlag |= SetDOSMode;
69851           }
69852        }
69853  
69854 -      /* TW: New from 650/LV 1.10.6x; not in any BIOS for other chipsets */
69855        if(IS_SIS650) {
69856 -          if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
69857 -             SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f);
69858 -             SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7);
69859 -         }
69860 +         if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
69861 +           SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f);
69862 +           if(IS_SIS651) SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x20);
69863 +           SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7);
69864 +        }
69865        }
69866     }
69867  
69868 -   /* TW: Set mode on CRT1 */
69869 +   if(SiS_Pr->UseCustomMode) {
69870 +      SiS_Pr->CRT1UsesCustomMode = TRUE;
69871 +      SiS_Pr->CSRClock_CRT1 = SiS_Pr->CSRClock;
69872 +      SiS_Pr->CModeFlag_CRT1 = SiS_Pr->CModeFlag;
69873 +   } else {
69874 +      SiS_Pr->CRT1UsesCustomMode = FALSE;
69875 +   }
69876 +
69877 +   /* Set mode on CRT1 */
69878     if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) {
69879         SiS_SetCRT1Group(SiS_Pr,ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex,BaseAddr);
69880     } else {
69881 @@ -2559,7 +2680,7 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_
69882       }
69883     }
69884  
69885 -   /* TW: Set mode on CRT2 */
69886 +   /* Set mode on CRT2 */
69887     if(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchToCRT2 | SetCRT2ToLCDA)) {
69888       switch (HwDeviceExtension->ujVBChipID) {
69889       case VB_CHIP_301:
69890 @@ -2568,18 +2689,20 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_
69891       case VB_CHIP_302:
69892       case VB_CHIP_302B:
69893       case VB_CHIP_302LV:
69894 -        SiS_SetCRT2Group301(SiS_Pr,BaseAddr,ROMAddr,ModeNo,HwDeviceExtension);
69895 +        SiS_SetCRT2Group(SiS_Pr,BaseAddr,ROMAddr,ModeNo,HwDeviceExtension);
69896          break;
69897       case VB_CHIP_UNKNOWN:
69898         if(SiS_Pr->SiS_IF_DEF_LVDS     == 1 ||
69899            SiS_Pr->SiS_IF_DEF_CH70xx   != 0 ||
69900            SiS_Pr->SiS_IF_DEF_TRUMPION != 0)
69901 -               SiS_SetCRT2Group301(SiS_Pr,BaseAddr,ROMAddr,ModeNo,HwDeviceExtension);
69902 +           SiS_SetCRT2Group(SiS_Pr,BaseAddr,ROMAddr,ModeNo,HwDeviceExtension);
69903          break;
69904       }
69905     }
69906     
69907     SiS_HandleCRT1(SiS_Pr);
69908 +
69909 +   SiS_StrangeStuff(SiS_Pr, HwDeviceExtension);
69910     
69911     SiS_DisplayOn(SiS_Pr);
69912     SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF);
69913 @@ -2592,7 +2715,6 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_
69914        }
69915     }
69916  
69917 -   /* TW: New from 650/LV 1.10.6x and 1.10.7w */
69918     if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
69919        if(HwDeviceExtension->jChipType >= SIS_315H) {
69920          if(SiS_IsVAMode(SiS_Pr,HwDeviceExtension, BaseAddr)) {
69921 @@ -2627,7 +2749,7 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_
69922  
69923  #ifdef LINUX_XF86
69924     if(pScrn) {
69925 -      /* TW: SetPitch: Adapt to virtual size & position */
69926 +      /* SetPitch: Adapt to virtual size & position */
69927        if((ModeNo > 0x13) && (dosetpitch)) {
69928           SiS_SetPitch(SiS_Pr, pScrn, BaseAddr);
69929        }
69930 @@ -2637,7 +2759,7 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_
69931     }
69932  #endif
69933  
69934 -#ifndef LINUX_XF86  /* TW: We never lock registers in XF86 */
69935 +#ifndef LINUX_XF86  /* We never lock registers in XF86 */
69936     if(KeepLockReg == 0xA1) SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86);
69937     else SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x00);
69938  #endif
69939 @@ -2646,10 +2768,15 @@ SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_
69940  }
69941  
69942  void
69943 -SiS_SetEnableDstn(SiS_Private *SiS_Pr) /* TW: Called from sis_main.c */
69944 +SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable)
69945 +{
69946 +   SiS_Pr->SiS_IF_DEF_DSTN = enable ? 1 : 0;
69947 +}
69948 +
69949 +void
69950 +SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable)
69951  {
69952 -   /* For 550 dstn */
69953 -   SiS_Pr->SiS_IF_DEF_DSTN = 1;
69954 +   SiS_Pr->SiS_IF_DEF_FSTN = enable ? 1 : 0;
69955  }
69956  
69957  void
69958 @@ -2663,13 +2790,73 @@ SiS_HandleCRT1(SiS_Private *SiS_Pr)
69959    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x63,0xbf);
69960  
69961  #if 0
69962 -  if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x15) & 0x01))
69963 -     SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x63,0x40);
69964 +  if(!(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x15) & 0x01)) {
69965 +     if((SiS_GetReg1(SiS_Pr->SiS_P3c4,0x15) & 0x0a) ||
69966 +        (SiS_GetReg1(SiS_Pr->SiS_P3c4,0x16) & 0x01)) {
69967 +        SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x63,0x40);
69968 +     }
69969    }
69970  #endif
69971  }
69972  
69973  void
69974 +SiS_GetSysFlags(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
69975 +{
69976 +   unsigned char cr5f, temp1, temp2;
69977 +
69978 +   /* You should use the macros, not these flags directly */
69979 +
69980 +   SiS_Pr->SiS_SysFlags = 0;
69981 +   if(HwDeviceExtension->jChipType == SIS_650) {
69982 +      cr5f = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f) & 0xf0;
69983 +      SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x5c,0x07);
69984 +      temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5c) & 0xf8;
69985 +      SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x5c,0xf8);
69986 +      temp2 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5c) & 0xf8;
69987 +      if((!temp1) || (temp2)) {
69988 +         switch(cr5f) {
69989 +           case 0x80:
69990 +           case 0x90:
69991 +           case 0xc0:
69992 +              SiS_Pr->SiS_SysFlags |= SF_IsM650;  break;
69993 +           case 0xa0:
69994 +           case 0xb0:
69995 +           case 0xe0:
69996 +              SiS_Pr->SiS_SysFlags |= SF_Is651;   break;
69997 +        }
69998 +      } else {
69999 +         switch(cr5f) {
70000 +           case 0x90:
70001 +              temp1 = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5c) & 0xf8;
70002 +              switch(temp1) {
70003 +                 case 0x00: SiS_Pr->SiS_SysFlags |= SF_IsM652; break;
70004 +                 case 0x40: SiS_Pr->SiS_SysFlags |= SF_IsM653; break;
70005 +                 default:   SiS_Pr->SiS_SysFlags |= SF_IsM650; break;
70006 +              }
70007 +              break;
70008 +           case 0xb0:
70009 +              SiS_Pr->SiS_SysFlags |= SF_Is652;  break;
70010 +           default:
70011 +              SiS_Pr->SiS_SysFlags |= SF_IsM650; break;
70012 +        }
70013 +      }
70014 +   }
70015 +}
70016 +
70017 +void
70018 +SiS_StrangeStuff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
70019 +{
70020 +   if((IS_SIS651) || (IS_SISM650)) {
70021 +      SiS_SetReg1(SiS_Pr->SiS_VidCapt, 0x3f, 0x00);   /* Fiddle with capture regs */
70022 +      SiS_SetReg1(SiS_Pr->SiS_VidCapt, 0x00, 0x00);
70023 +      SiS_SetReg1(SiS_Pr->SiS_VidPlay, 0x00, 0x86);   /* (BIOS does NOT unlock) */
70024 +      SiS_SetRegAND(SiS_Pr->SiS_VidPlay, 0x30, 0xfe); /* Fiddle with video regs */
70025 +      SiS_SetRegAND(SiS_Pr->SiS_VidPlay, 0x3f, 0xef);
70026 +   }
70027 +   /* !!! This does not support modes < 0x13 !!! */
70028 +}
70029 +
70030 +void
70031  SiS_SetCRT1Group(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension,
70032                   USHORT ModeNo,USHORT ModeIdIndex,USHORT BaseAddr)
70033  {
70034 @@ -2683,6 +2870,9 @@ SiS_SetCRT1Group(SiS_Private *SiS_Pr, UC
70035      }
70036    }
70037  
70038 +  /* 550, 651 */
70039 +  SiS_WhatTheHellIsThis(SiS_Pr,HwDeviceExtension,BaseAddr);
70040 +
70041    SiS_SetSeqRegs(SiS_Pr,ROMAddr,StandTableIndex);
70042    SiS_SetMiscRegs(SiS_Pr,ROMAddr,StandTableIndex);
70043    SiS_SetCRTCRegs(SiS_Pr,ROMAddr,HwDeviceExtension,StandTableIndex);
70044 @@ -2759,15 +2949,20 @@ void
70045  SiS_SetPitch(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr)
70046  {
70047     SISPtr pSiS = SISPTR(pScrn);
70048 +   BOOLEAN isslavemode = FALSE;
70049 +
70050 +   if( (pSiS->VBFlags & VB_VIDEOBRIDGE) &&
70051 +       ( ((pSiS->VGAEngine == SIS_300_VGA) && (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0xa0) == 0x20) ||
70052 +         ((pSiS->VGAEngine == SIS_315_VGA) && (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x50) == 0x10) ) ) {
70053 +      isslavemode = TRUE;
70054 +   }
70055  
70056 -   /* TW: We need to set pitch for CRT1 if bridge is in SlaveMode, too */
70057 -   if( (pSiS->VBFlags & DISPTYPE_DISP1) ||
70058 -       ( (pSiS->VBFlags & VB_VIDEOBRIDGE) &&
70059 -         ( ((pSiS->VGAEngine == SIS_300_VGA) && (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0xa0) == 0x20) ||
70060 -           ((pSiS->VGAEngine == SIS_315_VGA) && (SiS_GetReg1(SiS_Pr->SiS_Part1Port,0x00) & 0x50) == 0x10) ) ) ) {
70061 +   /* We need to set pitch for CRT1 if bridge is in slave mode, too */
70062 +   if( (pSiS->VBFlags & DISPTYPE_DISP1) || (isslavemode) ) {
70063         SiS_SetPitchCRT1(SiS_Pr, pScrn, BaseAddr);
70064     }
70065 -   if (pSiS->VBFlags & DISPTYPE_DISP2) {
70066 +   /* We must not set the pitch for CRT2 if bridge is in slave mode */
70067 +   if( (pSiS->VBFlags & DISPTYPE_DISP2) && (!isslavemode) ) {
70068         SiS_SetPitchCRT2(SiS_Pr, pScrn, BaseAddr);
70069     }
70070  }
70071 @@ -2790,7 +2985,7 @@ SiS_SetPitchCRT2(SiS_Private *SiS_Pr, Sc
70072      SISPtr pSiS = SISPTR(pScrn);
70073      ULong  HDisplay,temp;
70074  
70075 -    HDisplay = pSiS->scrnPitch / 8;
70076 +    HDisplay = pSiS->scrnPitch2 / 8;
70077  
70078      /* Unlock CRT2 */
70079      if (pSiS->VGAEngine == SIS_315_VGA)
70080 @@ -2880,7 +3075,6 @@ SiS_SearchModeID(SiS_Private *SiS_Pr, UC
70081     return TRUE;
70082  }
70083  
70084 -/* For SiS 300 oem util: Search VBModeID */
70085  BOOLEAN
70086  SiS_SearchVBModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo)
70087  {
70088 @@ -2946,6 +3140,81 @@ SiS_GetModePtr(SiS_Private *SiS_Pr, UCHA
70089     return index;
70090  }
70091  
70092 +static void
70093 +SiS_WhatIsThis1a(SiS_Private *SiS_Pr, USHORT somevalue)
70094 +{
70095 +   USHORT temp, tempbl, tempbh;
70096 +
70097 +   tempbl = tempbh = somevalue;
70098 +   temp = SiS_GetReg2(SiS_Pr->SiS_P3cb);
70099 +   temp &= 0xf0;
70100 +   tempbl >>= 4;
70101 +   temp |= tempbl;
70102 +   SiS_SetReg3(SiS_Pr->SiS_P3cb, temp);
70103 +   temp = SiS_GetReg2(SiS_Pr->SiS_P3cd);
70104 +   temp &= 0xf0;
70105 +   tempbh &= 0x0f;
70106 +   temp |= tempbh;
70107 +   SiS_SetReg3(SiS_Pr->SiS_P3cd, temp);
70108 +}
70109 +
70110 +static void
70111 +SiS_WhatIsThis1b(SiS_Private *SiS_Pr, USHORT somevalue)
70112 +{
70113 +   USHORT temp, tempbl, tempbh;
70114 +
70115 +   tempbl = tempbh = somevalue;
70116 +   temp = SiS_GetReg2(SiS_Pr->SiS_P3cb);
70117 +   temp &= 0x0f;
70118 +   tempbl &= 0xf0;
70119 +   temp |= tempbl;
70120 +   SiS_SetReg3(SiS_Pr->SiS_P3cb, temp);
70121 +   temp = SiS_GetReg2(SiS_Pr->SiS_P3cd);
70122 +   temp &= 0x0f;
70123 +   tempbh <<= 4;
70124 +   temp |= tempbh;
70125 +   SiS_SetReg3(SiS_Pr->SiS_P3cd, temp);
70126 +}
70127 +
70128 +static void
70129 +SiS_WhatIsThis2b(SiS_Private *SiS_Pr, USHORT somevalue)
70130 +{
70131 +   SiS_WhatIsThis1a(SiS_Pr, somevalue);
70132 +   SiS_WhatIsThis1b(SiS_Pr, somevalue);
70133 +}
70134 +
70135 +static void
70136 +SiS_WhatIsThis1(SiS_Private *SiS_Pr)
70137 +{
70138 +   SiS_WhatIsThis2b(SiS_Pr, 0);
70139 +}
70140 +
70141 +static void
70142 +SiS_WhatIsThis2a(SiS_Private *SiS_Pr, USHORT somevalue)
70143 +{
70144 +   USHORT temp = somevalue >> 8;
70145 +
70146 +   temp &= 0x07;
70147 +   temp |= (temp << 4);
70148 +   SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1d,temp);
70149 +   SiS_WhatIsThis2b(SiS_Pr, somevalue);
70150 +}
70151 +
70152 +static void
70153 +SiS_WhatIsThis2(SiS_Private *SiS_Pr)
70154 +{
70155 +   SiS_WhatIsThis2a(SiS_Pr, 0);
70156 +}
70157 +
70158 +void
70159 +SiS_WhatTheHellIsThis(SiS_Private *SiS_Pr,PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr)
70160 +{
70161 +   if(IS_SIS65x) {
70162 +      SiS_WhatIsThis1(SiS_Pr);
70163 +      SiS_WhatIsThis2(SiS_Pr);
70164 +   }
70165 +}
70166 +
70167  void
70168  SiS_SetSeqRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex)
70169  {
70170 @@ -3027,7 +3296,7 @@ SiS_SetCRTCRegs(SiS_Private *SiS_Pr, UCH
70171        (HwDeviceExtension->jChipRevision >= 0x30) ) {              /* for 630S0 */
70172      if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
70173        if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
70174 -        SiS_SetReg1(SiS_Pr->SiS_P3d4,0x18,0xFE);
70175 +         SiS_SetReg1(SiS_Pr->SiS_P3d4,0x18,0xFE);
70176        }
70177      }
70178    }
70179 @@ -3065,7 +3334,7 @@ SiS_SetATTRegs(SiS_Private *SiS_Pr, UCHA
70180        }
70181        if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
70182           if(HwDeviceExtension->jChipType >= SIS_315H) {
70183 -           if(IS_SIS650740 || IS_SIS550) {  
70184 +           if(IS_SIS550650740660) {
70185                /* 315, 330 don't do this */
70186                if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { 
70187                   if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) ARdata=0;
70188 @@ -3148,7 +3417,7 @@ SiS_SetCRT1CRTC(SiS_Private *SiS_Pr, UCH
70189    USHORT tempah,i,modeflag,j;
70190  #ifdef SIS315H
70191    USHORT temp;
70192 -  USHORT ResInfo,DisplayType;
70193 +  USHORT ResIndex,DisplayType;
70194    const SiS_LCDACRT1DataStruct *LCDACRT1Ptr = NULL;
70195  #endif
70196  
70197 @@ -3171,7 +3440,7 @@ SiS_SetCRT1CRTC(SiS_Private *SiS_Pr, UCH
70198       /* LCDA */
70199  
70200       temp = SiS_GetLCDACRT1Ptr(SiS_Pr,ROMAddr,ModeNo,ModeIdIndex,
70201 -                       RefreshRateTableIndex,&ResInfo,&DisplayType);
70202 +                       RefreshRateTableIndex,&ResIndex,&DisplayType);
70203  
70204       switch(DisplayType) {
70205        case Panel_800x600       : LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT1800x600_1;      break;
70206 @@ -3197,30 +3466,30 @@ SiS_SetCRT1CRTC(SiS_Private *SiS_Pr, UCH
70207        default:                   LCDACRT1Ptr = SiS_Pr->SiS_LCDACRT11024x768_1;     break;
70208       }
70209  
70210 -     tempah = (LCDACRT1Ptr+ResInfo)->CR[0];
70211 +     tempah = (LCDACRT1Ptr+ResIndex)->CR[0];
70212       SiS_SetReg1(SiS_Pr->SiS_P3d4,0x00,tempah);
70213       for(i=0x01,j=1;i<=0x07;i++,j++){
70214 -       tempah = (LCDACRT1Ptr+ResInfo)->CR[j];
70215 +       tempah = (LCDACRT1Ptr+ResIndex)->CR[j];
70216         SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
70217       }
70218       for(i=0x10,j=8;i<=0x12;i++,j++){
70219 -       tempah = (LCDACRT1Ptr+ResInfo)->CR[j];
70220 +       tempah = (LCDACRT1Ptr+ResIndex)->CR[j];
70221         SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
70222       }
70223       for(i=0x15,j=11;i<=0x16;i++,j++){
70224 -       tempah =(LCDACRT1Ptr+ResInfo)->CR[j];
70225 +       tempah =(LCDACRT1Ptr+ResIndex)->CR[j];
70226         SiS_SetReg1(SiS_Pr->SiS_P3d4,i,tempah);
70227       }
70228       for(i=0x0A,j=13;i<=0x0C;i++,j++){
70229 -       tempah = (LCDACRT1Ptr+ResInfo)->CR[j];
70230 +       tempah = (LCDACRT1Ptr+ResIndex)->CR[j];
70231         SiS_SetReg1(SiS_Pr->SiS_P3c4,i,tempah);
70232       }
70233  
70234 -     tempah = (LCDACRT1Ptr+ResInfo)->CR[16];
70235 +     tempah = (LCDACRT1Ptr+ResIndex)->CR[16];
70236       tempah &= 0x0E0;
70237       SiS_SetReg1(SiS_Pr->SiS_P3c4,0x0E,tempah);
70238  
70239 -     tempah = (LCDACRT1Ptr+ResInfo)->CR[16];
70240 +     tempah = (LCDACRT1Ptr+ResIndex)->CR[16];
70241       tempah &= 0x01;
70242       tempah <<= 5;
70243       if(modeflag & DoubleScanMode)  tempah |= 0x080;
70244 @@ -3301,7 +3570,7 @@ SiS_SetCRT1CRTC(SiS_Private *SiS_Pr, UCH
70245  
70246  BOOLEAN
70247  SiS_GetLCDACRT1Ptr(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
70248 -                  USHORT RefreshRateTableIndex,USHORT *ResInfo,
70249 +                  USHORT RefreshRateTableIndex,USHORT *ResIndex,
70250                    USHORT *DisplayType)
70251   {
70252    USHORT tempbx=0,modeflag=0;
70253 @@ -3320,7 +3589,7 @@ SiS_GetLCDACRT1Ptr(SiS_Private *SiS_Pr, 
70254    if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx += 32;
70255    if(modeflag & HalfDCLK)                 tempbx += 16;
70256  
70257 -  *ResInfo = CRT2CRTC & 0x3F;
70258 +  *ResIndex = CRT2CRTC & 0x3F;
70259    *DisplayType = tempbx;
70260  
70261    return 1;
70262 @@ -3470,6 +3739,9 @@ SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr,
70263    USHORT data,data2,data3;
70264    USHORT infoflag=0,modeflag;
70265    USHORT resindex,xres;
70266 +#ifdef SIS315H
70267 +  ULONG  longdata;
70268 +#endif
70269  
70270    if(SiS_Pr->UseCustomMode) {
70271       modeflag = SiS_Pr->CModeFlag;
70272 @@ -3490,11 +3762,11 @@ SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr,
70273  
70274    data2 = 0;
70275    if(ModeNo > 0x13) {
70276 -    if(SiS_Pr->SiS_ModeType > 0x02) {
70277 -       data2 |= 0x02;
70278 -       data3 = (SiS_Pr->SiS_ModeType - ModeVGA) << 2;
70279 -       data2 |= data3;
70280 -    }
70281 +     if(SiS_Pr->SiS_ModeType > 0x02) {
70282 +        data2 |= 0x02;
70283 +        data3 = (SiS_Pr->SiS_ModeType - ModeVGA) << 2;
70284 +        data2 |= data3;
70285 +     }
70286    }
70287  #ifdef TWDEBUG
70288    xf86DrvMsg(0, X_INFO, "Debug: Mode infoflag = %x, Chiptype %d\n", 
70289 @@ -3517,7 +3789,8 @@ SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr,
70290    if(HwDeviceExtension->jChipType != SIS_300) {
70291       data = 0x0000;
70292       if(infoflag & InterlaceMode) {
70293 -        if(xres == 1024) data = 0x0035;
70294 +        if(xres <= 800)  data = 0x0020;
70295 +        else if(xres <= 1024) data = 0x0035;
70296          else data = 0x0048;
70297       }
70298       data2 = data & 0x00FF;
70299 @@ -3549,6 +3822,7 @@ SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr,
70300       } else {
70301          SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x0F,0xB7);
70302       }
70303 +     /* 651 BIOS does something for mode 0x12 here */
70304    }
70305  
70306    if(HwDeviceExtension->jChipType != SIS_300) {
70307 @@ -3604,9 +3878,9 @@ SiS_SetCRT1ModeRegs(SiS_Private *SiS_Pr,
70308           data2 *= data3;
70309  
70310           data3 = SiS_GetMCLK(SiS_Pr,ROMAddr, HwDeviceExtension);
70311 -         data3 *= 1024;
70312 +         longdata = data3 * 1024;
70313  
70314 -         data2 = data3 / data2;
70315 +         data2 = longdata / data2;
70316  
70317           if(SiS_Pr->SiS_ModeType != Mode16Bpp) {
70318              if(data2 >= 0x19c)      data = 0xba;
70319 @@ -3679,7 +3953,7 @@ SiS_SetVCLKState(SiS_Private *SiS_Pr, UC
70320      if(VCLK >= 150) data2 |= 0x08;             /* VCLK > 150 */
70321      SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data2);
70322  
70323 -  } else {                                             /* 310/325 series */
70324 +  } else {                                             /* 315 series */
70325  
70326      data = 0;
70327      if(VCLK >= 166) data |= 0x0c;              /* TW: Was 200; is 166 in 650, 315 and 330 BIOSes */
70328 @@ -3688,12 +3962,6 @@ SiS_SetVCLKState(SiS_Private *SiS_Pr, UC
70329      if(VCLK >= 166) {                          /* TW: Was 200, is 166 in 650, 315 and 330 BIOSes */
70330         SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1f,0xe7);
70331      }
70332 -#if 0 /* Not done in 315 and 650/301LV/LVDS BIOSes: */
70333 -    data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x1F);         /* DAC pedestal */
70334 -    data &= 0xE7;
70335 -    if(VCLK<200) data |= 0x10;
70336 -    SiS_SetReg1(SiS_Pr->SiS_P3c4,0x1F,data);           /* DAC pedestal */
70337 -#endif
70338    }
70339  
70340    data2 = 0x03;
70341 @@ -3918,7 +4186,9 @@ GetDRAMSize(SiS_Private *SiS_Pr, PSIS_HW
70342  
70343    } else if((HwDeviceExtension->jChipType == SIS_550) ||
70344              (HwDeviceExtension->jChipType == SIS_740) ||
70345 -            (HwDeviceExtension->jChipType == SIS_650)) {
70346 +            (HwDeviceExtension->jChipType == SIS_650) ||
70347 +           (HwDeviceExtension->jChipType == SIS_660) ||
70348 +           (HwDeviceExtension->jChipType == SIS_760)) {
70349  
70350         counter = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x14) & 0x3F;
70351         counter++;
70352 @@ -4728,7 +4998,7 @@ SiS_GetSenseStatus(SiS_Private *SiS_Pr, 
70353            SiS_Pr->SiS_SetFlag = 0x00;
70354            SiS_Pr->SiS_ModeType = ModeVGA;
70355            SiS_Pr->SiS_VBInfo = SetCRT2ToRAMDAC |LoadDACFlag |SetInSlaveMode;
70356 -          SiS_SetCRT2Group301(SiS_Pr, BaseAddr,ROMAddr,SenseModeNo,HwDeviceExtension);
70357 +          SiS_SetCRT2Group(SiS_Pr, BaseAddr,ROMAddr,SenseModeNo,HwDeviceExtension);
70358            for(i=0;i<20;i++) {
70359              SiS_LongWait(SiS_Pr);
70360            }
70361 @@ -4766,7 +5036,7 @@ SiS_GetSenseStatus(SiS_Private *SiS_Pr, 
70362  #ifdef SIS315H
70363            if(HwDeviceExtension->jChipType >= SIS_315H) {
70364                 OutputSelect = ROMAddr[0xf3];
70365 -               if(HwDeviceExtension->jChipType == SIS_330) {
70366 +               if(HwDeviceExtension->jChipType >= SIS_330) {
70367                      OutputSelect = ROMAddr[0x11b];
70368                 }
70369            }
70370 @@ -4814,7 +5084,7 @@ SiS_GetSenseStatus(SiS_Private *SiS_Pr, 
70371        SiS_SetReg1(SiS_Pr->SiS_Part2Port,0x00,P2reg0);
70372        if(!(P2reg0 & 0x20)) {
70373          SiS_Pr->SiS_VBInfo = DisableCRT2Display;
70374 -        SiS_SetCRT2Group301(SiS_Pr,BaseAddr,ROMAddr,SenseModeNo,HwDeviceExtension);
70375 +        SiS_SetCRT2Group(SiS_Pr,BaseAddr,ROMAddr,SenseModeNo,HwDeviceExtension);
70376        }
70377      }
70378    }
70379 @@ -4884,111 +5154,6 @@ SiS_SenseCHTV(SiS_Private *SiS_Pr)
70380  }
70381  #endif /* LINUXBIOS */
70382  
70383 -/*  ================ for TC only =================  */
70384 -
70385 -#ifdef TC
70386 -
70387 -int
70388 -INT1AReturnCode(union REGS regs)
70389 -{
70390 -  if (regs.x.cflag)
70391 -  {
70392 -    /*printf("Error to find pci device!\n"); */
70393 -    return 1;
70394 -  }
70395 -
70396 -  switch(regs.h.ah)
70397 -  {
70398 -    case 0: return 0;
70399 -            break;
70400 -    case 0x81: printf("Function not support\n");
70401 -               break;
70402 -    case 0x83: printf("bad vendor id\n");
70403 -               break;
70404 -    case 0x86: printf("device not found\n");
70405 -               break;
70406 -    case 0x87: printf("bad register number\n");
70407 -               break;
70408 -    case 0x88: printf("set failed\n");
70409 -               break;
70410 -    case 0x89: printf("buffer too small");
70411 -               break;
70412 -  }
70413 -  return 1;
70414 -}
70415 -
70416 -unsigned
70417 -FindPCIIOBase(unsigned index,unsigned deviceid)
70418 -{
70419 -  union REGS regs;
70420 -
70421 -  regs.h.ah = 0xb1;  /*PCI_FUNCTION_ID */
70422 -  regs.h.al = 0x02;  /*FIND_PCI_DEVICE */
70423 -  regs.x.cx = deviceid;
70424 -  regs.x.dx = 0x1039;
70425 -  regs.x.si = index;  /* find n-th device */
70426 -
70427 -  int86(0x1A, &regs, &regs);
70428 -
70429 -  if (INT1AReturnCode(regs)!=0)
70430 -    return 0;
70431 -
70432 -  /* regs.h.bh *//* bus number */
70433 -  /* regs.h.bl *//* device number */
70434 -  regs.h.ah = 0xb1;  /*PCI_FUNCTION_ID */
70435 -  regs.h.al = 0x09;  /*READ_CONFIG_WORD */
70436 -  regs.x.cx = deviceid;
70437 -  regs.x.dx = 0x1039;
70438 -  regs.x.di = 0x18;  /* register number */
70439 -  int86(0x1A, &regs, &regs);
70440 -
70441 -  if (INT1AReturnCode(regs)!=0)
70442 -    return 0;
70443 -  return regs.x.cx;
70444 -}
70445 -
70446 -
70447 -void
70448 -main(int argc, char *argv[])
70449 -{
70450 -  SIS_HW_DEVICE_INFO  HwDeviceExtension;
70451 -  USHORT temp;
70452 -  USHORT ModeNo;
70453 -
70454 -  /*HwDeviceExtension.pjVirtualRomBase =(PUCHAR) MK_FP(0xC000,0); */
70455 -  /*HwDeviceExtension.pjVideoMemoryAddress = (PUCHAR)MK_FP(0xA000,0);*/
70456 -
70457 -#ifdef SIS300  
70458 -  HwDeviceExtension.ulIOAddress = (FindPCIIOBase(0,0x6300)&0xFF80) + 0x30;
70459 -  HwDeviceExtension.jChipType = SIS_630;
70460 -#endif
70461 -
70462 -#ifdef SIS315H  
70463 -//  HwDeviceExtension.ulIOAddress = (FindPCIIOBase(0,0x5315)&0xFF80) + 0x30;
70464 -//  HwDeviceExtension.jChipType = SIS_550;
70465 -  HwDeviceExtension.ulIOAddress = (FindPCIIOBase(0,0x325)&0xFF80) + 0x30;
70466 -  HwDeviceExtension.jChipType = SIS_315H;
70467 -#endif
70468 -
70469 -  HwDeviceExtension.ujVBChipID = VB_CHIP_301;
70470 -  strcpy(HwDeviceExtension.szVBIOSVer,"0.84");
70471 -  HwDeviceExtension.bSkipDramSizing = FALSE;
70472 -  HwDeviceExtension.ulVideoMemorySize = 0;
70473 -  if(argc==2) {
70474 -    ModeNo=atoi(argv[1]);
70475 -  }
70476 -  else {
70477 -    ModeNo=0x2e;
70478 -    /*ModeNo=0x37; */ /* 1024x768x 4bpp */
70479 -    /*ModeNo=0x38; *//* 1024x768x 8bpp */
70480 -    /*ModeNo=0x4A; *//* 1024x768x 16bpp */
70481 -    /*ModeNo=0x47;*/ /* 800x600x 16bpp */
70482 -  }
70483 - /* SiSInit(SiS_Pr, &HwDeviceExtension);*/
70484 -  SiSSetMode(SiS_Pr, &HwDeviceExtension, ModeNo);
70485 -}
70486 -#endif /* TC END */
70487 -
70488  /* ================ XFREE86 ================= */
70489  
70490  /* Helper functions */
70491 @@ -5000,44 +5165,78 @@ SiS_CheckBuildCustomMode(ScrnInfoPtr pSc
70492     SISPtr pSiS = SISPTR(pScrn);
70493     int    out_n, out_dn, out_div, out_sbit, out_scale;
70494     int    depth = pSiS->CurrentLayout.bitsPerPixel;
70495 -   
70496 -#ifdef SISDUALHEAD
70497 -   if( ((!pSiS->DualHeadMode) && (VBFlags & DISPTYPE_DISP2)) ||
70498 -       ((pSiS->DualHeadMode) && (!pSiS->SecondHead)) ) return 0;
70499 -#else      
70500 -   if(VBFlags & DISPTYPE_DISP2) return 0; 
70501 -#endif   
70502 +   unsigned int vclk[5];
70503 +
70504 +#define Midx         0
70505 +#define Nidx         1
70506 +#define VLDidx       2
70507 +#define Pidx         3
70508 +#define PSNidx       4
70509 +
70510 +   pSiS->SiS_Pr->CModeFlag = 0;
70511     
70512     pSiS->SiS_Pr->CDClock = mode->Clock;
70513 -   
70514 +
70515     pSiS->SiS_Pr->CHDisplay = mode->HDisplay;
70516     pSiS->SiS_Pr->CHSyncStart = mode->HSyncStart;
70517     pSiS->SiS_Pr->CHSyncEnd = mode->HSyncEnd;
70518     pSiS->SiS_Pr->CHTotal = mode->HTotal;
70519 -   pSiS->SiS_Pr->CHBlankStart = pSiS->SiS_Pr->CHDisplay;
70520 -   pSiS->SiS_Pr->CHBlankEnd = pSiS->SiS_Pr->CHTotal;
70521 -   
70522 +
70523     pSiS->SiS_Pr->CVDisplay = mode->VDisplay;
70524     pSiS->SiS_Pr->CVSyncStart = mode->VSyncStart;
70525     pSiS->SiS_Pr->CVSyncEnd = mode->VSyncEnd;
70526     pSiS->SiS_Pr->CVTotal = mode->VTotal;
70527 +
70528 +   pSiS->SiS_Pr->CFlags = mode->Flags;
70529 +
70530 +   if(pSiS->SiS_Pr->CFlags & V_INTERLACE) {
70531 +         pSiS->SiS_Pr->CVDisplay >>= 1;
70532 +        pSiS->SiS_Pr->CVSyncStart >>= 1;
70533 +        pSiS->SiS_Pr->CVSyncEnd >>= 1;
70534 +        pSiS->SiS_Pr->CVTotal >>= 1;
70535 +   }
70536 +   if(pSiS->SiS_Pr->CFlags & V_DBLSCAN) {
70537 +         /* pSiS->SiS_Pr->CDClock <<= 1; */
70538 +        pSiS->SiS_Pr->CVDisplay <<= 1;
70539 +        pSiS->SiS_Pr->CVSyncStart <<= 1;
70540 +        pSiS->SiS_Pr->CVSyncEnd <<= 1;
70541 +        pSiS->SiS_Pr->CVTotal <<= 1;
70542 +   }
70543 +
70544 +   pSiS->SiS_Pr->CHBlankStart = pSiS->SiS_Pr->CHDisplay;
70545 +   pSiS->SiS_Pr->CHBlankEnd = pSiS->SiS_Pr->CHTotal;
70546     pSiS->SiS_Pr->CVBlankStart = pSiS->SiS_Pr->CVSyncStart - 1;
70547     pSiS->SiS_Pr->CVBlankEnd = pSiS->SiS_Pr->CVTotal;
70548 -   
70549 -   pSiS->SiS_Pr->CFlags = mode->Flags;
70550  
70551 -   SiS_compute_vclk(pSiS->SiS_Pr->CDClock, &out_n, &out_dn, &out_div, &out_sbit, &out_scale);
70552 -   
70553 +   if(SiS_compute_vclk(pSiS->SiS_Pr->CDClock, &out_n, &out_dn, &out_div, &out_sbit, &out_scale)) {
70554 +      pSiS->SiS_Pr->CSR2B = (out_div == 2) ? 0x80 : 0x00;
70555 +      pSiS->SiS_Pr->CSR2B |= ((out_n - 1) & 0x7f);
70556 +      pSiS->SiS_Pr->CSR2C = (out_dn - 1) & 0x1f;
70557 +      pSiS->SiS_Pr->CSR2C |= (((out_scale - 1) & 3) << 5);
70558 +      pSiS->SiS_Pr->CSR2C |= ((out_sbit & 0x01) << 7);
70559  #ifdef TWDEBUG
70560 -   xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock %d: n %d dn %d div %d sb %d sc %d\n",
70561 -       pSiS->SiS_Pr->CDClock, out_n, out_dn, out_div, out_sbit, out_scale);
70562 -#endif 
70563 -
70564 -   pSiS->SiS_Pr->CSR2B = (out_div == 2) ? 0x80 : 0x00;
70565 -   pSiS->SiS_Pr->CSR2B |= ((out_n - 1) & 0x7f);
70566 -   pSiS->SiS_Pr->CSR2C = (out_dn - 1) & 0x1f;
70567 -   pSiS->SiS_Pr->CSR2C |= (((out_scale - 1) & 3) << 5);
70568 -   pSiS->SiS_Pr->CSR2C |= ((out_sbit & 0x01) << 7);
70569 +      xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock %d: n %d dn %d div %d sb %d sc %d\n",
70570 +               pSiS->SiS_Pr->CDClock, out_n, out_dn, out_div, out_sbit, out_scale);
70571 +#endif
70572 +   } else {
70573 +      SiSCalcClock(pScrn, pSiS->SiS_Pr->CDClock, 2, vclk);
70574 +      pSiS->SiS_Pr->CSR2B = (vclk[VLDidx] == 2) ? 0x80 : 0x00;
70575 +      pSiS->SiS_Pr->CSR2B |= (vclk[Midx] - 1) & 0x7f;
70576 +      pSiS->SiS_Pr->CSR2C = (vclk[Nidx] - 1) & 0x1f;
70577 +      if(vclk[Pidx] <= 4) {
70578 +         /* postscale 1,2,3,4 */
70579 +         pSiS->SiS_Pr->CSR2C |= ((vclk[Pidx] - 1) & 3) << 5;
70580 +      } else {
70581 +         /* postscale 6,8 */
70582 +         pSiS->SiS_Pr->CSR2C |= (((vclk[Pidx] / 2) - 1) & 3) << 5;
70583 +        pSiS->SiS_Pr->CSR2C |= 0x80;
70584 +      }
70585 +#ifdef TWDEBUG
70586 +      xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock %d: n %d dn %d div %d sc %d\n",
70587 +               pSiS->SiS_Pr->CDClock, vclk[Midx], vclk[Nidx], vclk[VLDidx], vclk[Pidx]);
70588 +#endif
70589 +   }
70590 +
70591     pSiS->SiS_Pr->CSRClock = (pSiS->SiS_Pr->CDClock / 1000) + 1;
70592  
70593     pSiS->SiS_Pr->CCRT1CRTC[0]  =  ((pSiS->SiS_Pr->CHTotal >> 3) - 5) & 0xff;
70594 @@ -5045,9 +5244,9 @@ SiS_CheckBuildCustomMode(ScrnInfoPtr pSc
70595     pSiS->SiS_Pr->CCRT1CRTC[2]  =  (pSiS->SiS_Pr->CHBlankStart >> 3) - 1;
70596     pSiS->SiS_Pr->CCRT1CRTC[3]  =  (((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1) & 0x1F) | 0x80;
70597     pSiS->SiS_Pr->CCRT1CRTC[4]  =  (pSiS->SiS_Pr->CHSyncStart >> 3) + 3;
70598 -   pSiS->SiS_Pr->CCRT1CRTC[5]  =  ((((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1) & 0x20) << 2) | 
70599 +   pSiS->SiS_Pr->CCRT1CRTC[5]  =  ((((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1) & 0x20) << 2) |
70600                                           (((pSiS->SiS_Pr->CHSyncEnd >> 3) + 3) & 0x1F);
70601 -   
70602 +
70603     pSiS->SiS_Pr->CCRT1CRTC[6]  =  (pSiS->SiS_Pr->CVTotal - 2) & 0xFF;
70604     pSiS->SiS_Pr->CCRT1CRTC[7]  =  (((pSiS->SiS_Pr->CVTotal - 2) & 0x100) >> 8)
70605                                 | (((pSiS->SiS_Pr->CVDisplay - 1) & 0x100) >> 7)
70606 @@ -5057,50 +5256,50 @@ SiS_CheckBuildCustomMode(ScrnInfoPtr pSc
70607                                 | (((pSiS->SiS_Pr->CVTotal - 2) & 0x200)   >> 4)
70608                                 | (((pSiS->SiS_Pr->CVDisplay - 1) & 0x200) >> 3)
70609                                 | ((pSiS->SiS_Pr->CVSyncStart & 0x200) >> 2);
70610 -    
70611 +
70612     pSiS->SiS_Pr->CCRT1CRTC[16] = ((((pSiS->SiS_Pr->CVBlankStart - 1) & 0x200) >> 4) >> 5);     /* cr9 */
70613 -    
70614 -#if 0    
70615 +
70616 +#if 0
70617     if (mode->VScan >= 32)
70618         regp->CRTC[9] |= 0x1F;
70619     else if (mode->VScan > 1)
70620         regp->CRTC[9] |= mode->VScan - 1;
70621 -#endif 
70622 +#endif
70623  
70624 -   pSiS->SiS_Pr->CCRT1CRTC[8] =  (pSiS->SiS_Pr->CVSyncStart - 1) & 0xFF;       /* cr10 */
70625 -   pSiS->SiS_Pr->CCRT1CRTC[9] =  ((pSiS->SiS_Pr->CVSyncEnd - 1) & 0x0F) | 0x80;        /* cr11 */
70626 -   pSiS->SiS_Pr->CCRT1CRTC[10] = (pSiS->SiS_Pr->CVDisplay - 1) & 0xFF;         /* cr12 */
70627 -   pSiS->SiS_Pr->CCRT1CRTC[11] = (pSiS->SiS_Pr->CVBlankStart - 1) & 0xFF;      /* cr15 */
70628 -   pSiS->SiS_Pr->CCRT1CRTC[12] = (pSiS->SiS_Pr->CVBlankEnd - 1) & 0xFF;                /* cr16 */
70629 -   
70630 -   pSiS->SiS_Pr->CCRT1CRTC[13] = 
70631 +   pSiS->SiS_Pr->CCRT1CRTC[8] =  (pSiS->SiS_Pr->CVSyncStart     ) & 0xFF;              /* cr10 */
70632 +   pSiS->SiS_Pr->CCRT1CRTC[9] =  ((pSiS->SiS_Pr->CVSyncEnd      ) & 0x0F) | 0x80;      /* cr11 */
70633 +   pSiS->SiS_Pr->CCRT1CRTC[10] = (pSiS->SiS_Pr->CVDisplay    - 1) & 0xFF;              /* cr12 */
70634 +   pSiS->SiS_Pr->CCRT1CRTC[11] = (pSiS->SiS_Pr->CVBlankStart - 1) & 0xFF;              /* cr15 */
70635 +   pSiS->SiS_Pr->CCRT1CRTC[12] = (pSiS->SiS_Pr->CVBlankEnd   - 1) & 0xFF;              /* cr16 */
70636 +
70637 +   pSiS->SiS_Pr->CCRT1CRTC[13] =
70638                          GETBITSTR((pSiS->SiS_Pr->CVTotal     -2), 10:10, 0:0) |
70639                          GETBITSTR((pSiS->SiS_Pr->CVDisplay   -1), 10:10, 1:1) |
70640                          GETBITSTR((pSiS->SiS_Pr->CVBlankStart-1), 10:10, 2:2) |
70641                          GETBITSTR((pSiS->SiS_Pr->CVSyncStart   ), 10:10, 3:3) |
70642                          GETBITSTR((pSiS->SiS_Pr->CVBlankEnd  -1),   8:8, 4:4) |
70643 -                        GETBITSTR((pSiS->SiS_Pr->CVSyncEnd   -1),   4:4, 5:5) ;  
70644 +                        GETBITSTR((pSiS->SiS_Pr->CVSyncEnd     ),   4:4, 5:5) ;
70645  
70646 -   pSiS->SiS_Pr->CCRT1CRTC[14] = 
70647 +   pSiS->SiS_Pr->CCRT1CRTC[14] =
70648                          GETBITSTR((pSiS->SiS_Pr->CHTotal      >> 3) - 5, 9:8, 1:0) |
70649                          GETBITSTR((pSiS->SiS_Pr->CHDisplay    >> 3) - 1, 9:8, 3:2) |
70650                          GETBITSTR((pSiS->SiS_Pr->CHBlankStart >> 3) - 1, 9:8, 5:4) |
70651                          GETBITSTR((pSiS->SiS_Pr->CHSyncStart  >> 3) + 3, 9:8, 7:6) ;
70652  
70653 -        
70654 +
70655     pSiS->SiS_Pr->CCRT1CRTC[15] =
70656                          GETBITSTR((pSiS->SiS_Pr->CHBlankEnd >> 3) - 1, 7:6, 1:0) |
70657 -                        GETBITSTR((pSiS->SiS_Pr->CHSyncEnd  >> 3) + 3, 5:5, 2:2) ; 
70658 -                       
70659 +                        GETBITSTR((pSiS->SiS_Pr->CHSyncEnd  >> 3) + 3, 5:5, 2:2) ;
70660 +
70661     switch(depth) {
70662 -   case 8:                     
70663 -       pSiS->SiS_Pr->CModeFlag = 0x223b;
70664 +   case 8:
70665 +       pSiS->SiS_Pr->CModeFlag |= 0x223b;
70666         break;
70667 -   case 16:                    
70668 -       pSiS->SiS_Pr->CModeFlag = 0x227d;
70669 +   case 16:
70670 +       pSiS->SiS_Pr->CModeFlag |= 0x227d;
70671         break;
70672 -   case 32:                    
70673 -       pSiS->SiS_Pr->CModeFlag = 0x22ff;
70674 +   case 32:
70675 +       pSiS->SiS_Pr->CModeFlag |= 0x22ff;
70676         break;          
70677     default: 
70678         return 0;       
70679 @@ -5114,9 +5313,9 @@ SiS_CheckBuildCustomMode(ScrnInfoPtr pSc
70680         pSiS->SiS_Pr->CModeFlag |= LineCompareOff;
70681     if(pSiS->SiS_Pr->CFlags & V_CLKDIV2)
70682          pSiS->SiS_Pr->CModeFlag |= HalfDCLK;
70683 -   
70684 +
70685     pSiS->SiS_Pr->CInfoFlag = 0x0007;
70686 -   if(pSiS->SiS_Pr->CFlags & V_NHSYNC) 
70687 +   if(pSiS->SiS_Pr->CFlags & V_NHSYNC)
70688         pSiS->SiS_Pr->CInfoFlag |= 0x4000;
70689     if(pSiS->SiS_Pr->CFlags & V_NVSYNC) 
70690         pSiS->SiS_Pr->CInfoFlag |= 0x8000;
70691 @@ -5152,13 +5351,13 @@ SiS_CheckBuildCustomMode(ScrnInfoPtr pSc
70692         pSiS->SiS_Pr->CSR2B,
70693         pSiS->SiS_Pr->CSR2C,
70694         pSiS->SiS_Pr->CSRClock);
70695 -#endif         
70696 +#endif
70697     return 1;
70698  }
70699  
70700  /* TW: Build a list of supported modes */
70701  DisplayModePtr
70702 -SiSBuildBuiltInModeList(ScrnInfoPtr pScrn)
70703 +SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfordvi)
70704  {
70705     SISPtr         pSiS = SISPTR(pScrn);
70706     unsigned short VRE, VBE, VRS, VBS, VDE, VT;
70707 @@ -5166,11 +5365,16 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr
70708     unsigned char  sr_data, cr_data, cr_data2, cr_data3;
70709     unsigned char  sr2b, sr2c;
70710     float          num, denum, postscalar, divider;
70711 -   int            A, B, C, D, E, F, temp, i, j, index, vclkindex;
70712 -   DisplayModePtr new = NULL, current = NULL, first = NULL, backup = NULL;
70713 +   int            A, B, C, D, E, F, temp, i, j, k, l, index, vclkindex;
70714 +   DisplayModePtr new = NULL, current = NULL, first = NULL;
70715 +   BOOLEAN        done = FALSE;
70716 +#if 0
70717 +   DisplayModePtr backup = NULL;
70718 +#endif
70719  
70720     pSiS->backupmodelist = NULL;
70721 -   
70722 +   pSiS->AddedPlasmaModes = FALSE;
70723 +
70724     /* Initialize our pointers */
70725     if(pSiS->VGAEngine == SIS_300_VGA) {
70726  #ifdef SIS300
70727 @@ -5194,15 +5398,20 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr
70728        if(pSiS->VGAEngine == SIS_300_VGA) index &= 0x3F;
70729  #endif      
70730  
70731 -      if(((pSiS->SiS_Pr->SiS_RefIndex[i].XRes < 512) && (!pSiS->DSTN)) ||
70732 -        ((pSiS->DSTN) &&
70733 -         (pSiS->SiS_Pr->SiS_RefIndex[i].XRes < 512) &&
70734 -         (pSiS->SiS_Pr->SiS_RefIndex[i].XRes != 320) &&
70735 -         (pSiS->SiS_Pr->SiS_RefIndex[i].YRes != 480)))  {
70736 +      /* 0x5a (320x240) is a pure FTSN mode, not DSTN! */
70737 +      if((!pSiS->FSTN) &&
70738 +        (pSiS->SiS_Pr->SiS_RefIndex[i].ModeID == 0x5a))  {
70739             i++;
70740            continue;
70741        }
70742 -      
70743 +      if((pSiS->FSTN) &&
70744 +         (pSiS->SiS_Pr->SiS_RefIndex[i].XRes == 320) &&
70745 +        (pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 240) &&
70746 +        (pSiS->SiS_Pr->SiS_RefIndex[i].ModeID != 0x5a)) {
70747 +          i++;
70748 +          continue;
70749 +      }
70750 +
70751        if(!(new = xalloc(sizeof(DisplayModeRec)))) return first;
70752        memset(new, 0, sizeof(DisplayModeRec));
70753        if(!(new->name = xalloc(10))) {
70754 @@ -5216,13 +5425,13 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr
70755        }
70756  
70757        current = new;
70758 -      
70759 +
70760        sprintf(current->name, "%dx%d", pSiS->SiS_Pr->SiS_RefIndex[i].XRes,
70761                                        pSiS->SiS_Pr->SiS_RefIndex[i].YRes);
70762  
70763        current->status = MODE_OK;
70764  
70765 -      current->type = M_T_DEFAULT; 
70766 +      current->type = M_T_DEFAULT;
70767  
70768        vclkindex = pSiS->SiS_Pr->SiS_RefIndex[i].Ext_CRTVCLK;
70769        if(pSiS->VGAEngine == SIS_300_VGA) vclkindex &= 0x3F;
70770 @@ -5235,7 +5444,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr
70771                ( (((sr2c >> 5) & 0x03) == 0x02) ? 6.0 : 8.0) : (((sr2c >> 5) & 0x03) + 1.0);
70772        num = (sr2b & 0x7f) + 1.0;
70773        denum = (sr2c & 0x1f) + 1.0;
70774 -      
70775 +
70776  #ifdef TWDEBUG
70777        xf86DrvMsg(0, X_INFO, "------------\n");
70778        xf86DrvMsg(0, X_INFO, "sr2b: %x sr2c %x div %f ps %f num %f denum %f\n",
70779 @@ -5303,10 +5512,29 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr
70780  
70781        D = B - F - C;
70782  
70783 -      current->HDisplay   = (E * 8);
70784 -      current->HSyncStart = (E * 8) + (F * 8);
70785 -      current->HSyncEnd   = (E * 8) + (F * 8) + (C * 8);
70786 -      current->HTotal     = (E * 8) + (F * 8) + (C * 8) + (D * 8);
70787 +      if((pSiS->SiS_Pr->SiS_RefIndex[i].XRes == 320) &&
70788 +        ((pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 200) ||
70789 +         (pSiS->SiS_Pr->SiS_RefIndex[i].YRes == 240))) {
70790 +
70791 +        /* Terrible hack, but correct CRTC data for
70792 +         * these modes only produces a black screen...
70793 +         * (HRE is 0, leading into a too large C and
70794 +         * a negative D. The CRT controller does not
70795 +         * seem to like correcting HRE to 50
70796 +         */
70797 +        current->HDisplay   = 320;
70798 +         current->HSyncStart = 328;
70799 +         current->HSyncEnd   = 376;
70800 +         current->HTotal     = 400;
70801 +
70802 +      } else {
70803 +
70804 +         current->HDisplay   = (E * 8);
70805 +         current->HSyncStart = (E * 8) + (F * 8);
70806 +         current->HSyncEnd   = (E * 8) + (F * 8) + (C * 8);
70807 +         current->HTotal     = (E * 8) + (F * 8) + (C * 8) + (D * 8);
70808 +
70809 +      }
70810  
70811  #ifdef TWDEBUG
70812        xf86DrvMsg(0, X_INFO,
70813 @@ -5430,7 +5658,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr
70814          current->VSyncStart <<= 1;
70815          current->VSyncEnd <<= 1;
70816          current->VTotal <<= 1;
70817 -        current->VTotal |= 1; 
70818 +        current->VTotal |= 1;
70819        }
70820        if(current->Flags & V_DBLSCAN) {
70821           current->Clock >>= 1;
70822 @@ -5440,6 +5668,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr
70823          current->VTotal >>= 1;
70824        }
70825  
70826 +#if 0
70827        if((backup = xalloc(sizeof(DisplayModeRec)))) {
70828           if(!pSiS->backupmodelist) pSiS->backupmodelist = backup;
70829          else {
70830 @@ -5458,6 +5687,7 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr
70831          backup->Flags = current->Flags;
70832          backup->Clock = current->Clock;
70833        }
70834 +#endif
70835  
70836  #ifdef TWDEBUG
70837        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
70838 @@ -5470,6 +5700,187 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScr
70839        i++;
70840     }
70841  
70842 +   /* Add non-standard LCD modes for panel's detailed timings */
70843 +
70844 +   if(!includelcdmodes) return first;
70845 +
70846 +   xf86DrvMsg(0, X_INFO, "Checking database for vendor %x, product %x\n",
70847 +      pSiS->SiS_Pr->CP_Vendor, pSiS->SiS_Pr->CP_Product);
70848 +
70849 +   i = 0;
70850 +   while((!done) && (SiS_PlasmaTable[i].vendor) && (pSiS->SiS_Pr->CP_Vendor)) {
70851 +
70852 +     if(SiS_PlasmaTable[i].vendor == pSiS->SiS_Pr->CP_Vendor) {
70853 +
70854 +        for(j=0; j<SiS_PlasmaTable[i].productnum; j++) {
70855 +
70856 +           if(SiS_PlasmaTable[i].product[j] == pSiS->SiS_Pr->CP_Product) {
70857 +
70858 +              xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
70859 +                 "Identified %s panel, adding specific modes\n",
70860 +                 SiS_PlasmaTable[i].plasmaname);
70861 +
70862 +              for(k=0; k<SiS_PlasmaTable[i].modenum; k++) {
70863 +
70864 +                 if(isfordvi) {
70865 +                    if(!(SiS_PlasmaTable[i].plasmamodes[k] & 0x80)) continue;
70866 +                 } else {
70867 +                    if(!(SiS_PlasmaTable[i].plasmamodes[k] & 0x40)) continue;
70868 +                 }
70869 +
70870 +                 if(!(new = xalloc(sizeof(DisplayModeRec)))) return first;
70871 +
70872 +                  memset(new, 0, sizeof(DisplayModeRec));
70873 +                  if(!(new->name = xalloc(10))) {
70874 +                    xfree(new);
70875 +                    return first;
70876 +                  }
70877 +                  if(!first) first = new;
70878 +                  if(current) {
70879 +                     current->next = new;
70880 +                    new->prev = current;
70881 +                  }
70882 +
70883 +                  current = new;
70884 +
70885 +                 pSiS->AddedPlasmaModes = TRUE;
70886 +
70887 +                 l = SiS_PlasmaTable[i].plasmamodes[k] & 0x3f;
70888 +
70889 +                 sprintf(current->name, "%dx%d", SiS_PlasmaMode[l].HDisplay,
70890 +                                                  SiS_PlasmaMode[l].VDisplay);
70891 +
70892 +                  current->status = MODE_OK;
70893 +
70894 +                  current->type = M_T_BUILTIN;
70895 +
70896 +                 current->Clock = SiS_PlasmaMode[l].clock;
70897 +                 current->SynthClock = current->Clock;
70898 +
70899 +                  current->HDisplay   = SiS_PlasmaMode[l].HDisplay;
70900 +                  current->HSyncStart = current->HDisplay + SiS_PlasmaMode[l].HFrontPorch;
70901 +                  current->HSyncEnd   = current->HSyncStart + SiS_PlasmaMode[l].HSyncWidth;
70902 +                  current->HTotal     = SiS_PlasmaMode[l].HTotal;
70903 +
70904 +                 current->VDisplay   = SiS_PlasmaMode[l].VDisplay;
70905 +                  current->VSyncStart = current->VDisplay + SiS_PlasmaMode[l].VFrontPorch;
70906 +                  current->VSyncEnd   = current->VSyncStart + SiS_PlasmaMode[l].VSyncWidth;
70907 +                  current->VTotal     = SiS_PlasmaMode[l].VTotal;
70908 +
70909 +                  current->CrtcHDisplay = current->HDisplay;
70910 +                  current->CrtcHBlankStart = current->HSyncStart;
70911 +                  current->CrtcHSyncStart = current->HSyncStart;
70912 +                  current->CrtcHSyncEnd = current->HSyncEnd;
70913 +                  current->CrtcHBlankEnd = current->HSyncEnd;
70914 +                  current->CrtcHTotal = current->HTotal;
70915 +
70916 +                  current->CrtcVDisplay = current->VDisplay;
70917 +                  current->CrtcVBlankStart = current->VSyncStart;
70918 +                  current->CrtcVSyncStart = current->VSyncStart;
70919 +                  current->CrtcVSyncEnd = current->VSyncEnd;
70920 +                  current->CrtcVBlankEnd = current->VSyncEnd;
70921 +                  current->CrtcVTotal = current->VTotal;
70922 +
70923 +                  if(SiS_PlasmaMode[l].SyncFlags & SIS_PL_HSYNCP)
70924 +                     current->Flags |= V_PHSYNC;
70925 +                  else
70926 +                     current->Flags |= V_NHSYNC;
70927 +
70928 +                  if(SiS_PlasmaMode[l].SyncFlags & SIS_PL_VSYNCP)
70929 +                     current->Flags |= V_PVSYNC;
70930 +                  else
70931 +                     current->Flags |= V_NVSYNC;
70932 +
70933 +                 if(current->HDisplay > pSiS->LCDwidth)
70934 +                    pSiS->LCDwidth = pSiS->SiS_Pr->CP_MaxX = current->HDisplay;
70935 +                 if(current->VDisplay > pSiS->LCDheight)
70936 +                    pSiS->LCDheight = pSiS->SiS_Pr->CP_MaxY = current->VDisplay;
70937 +
70938 +               }
70939 +              done = TRUE;
70940 +              break;
70941 +           }
70942 +       }
70943 +     }
70944 +
70945 +     i++;
70946 +
70947 +   }
70948 +
70949 +   if(pSiS->SiS_Pr->CP_HaveCustomData) {
70950 +
70951 +      for(i=0; i<7; i++) {
70952 +
70953 +         if(pSiS->SiS_Pr->CP_DataValid[i]) {
70954 +
70955 +            if(!(new = xalloc(sizeof(DisplayModeRec)))) return first;
70956 +
70957 +            memset(new, 0, sizeof(DisplayModeRec));
70958 +            if(!(new->name = xalloc(10))) {
70959 +               xfree(new);
70960 +               return first;
70961 +            }
70962 +            if(!first) first = new;
70963 +            if(current) {
70964 +               current->next = new;
70965 +              new->prev = current;
70966 +            }
70967 +
70968 +            current = new;
70969 +
70970 +            sprintf(current->name, "%dx%d", pSiS->SiS_Pr->CP_HDisplay[i],
70971 +                                            pSiS->SiS_Pr->CP_VDisplay[i]);
70972 +
70973 +            current->status = MODE_OK;
70974 +
70975 +            current->type = M_T_BUILTIN;
70976 +
70977 +            current->Clock = pSiS->SiS_Pr->CP_Clock[i];
70978 +            current->SynthClock = current->Clock;
70979 +
70980 +            current->HDisplay   = pSiS->SiS_Pr->CP_HDisplay[i];
70981 +            current->HSyncStart = pSiS->SiS_Pr->CP_HSyncStart[i];
70982 +            current->HSyncEnd   = pSiS->SiS_Pr->CP_HSyncEnd[i];
70983 +            current->HTotal     = pSiS->SiS_Pr->CP_HTotal[i];
70984 +
70985 +            current->VDisplay   = pSiS->SiS_Pr->CP_VDisplay[i];
70986 +            current->VSyncStart = pSiS->SiS_Pr->CP_VSyncStart[i];
70987 +            current->VSyncEnd   = pSiS->SiS_Pr->CP_VSyncEnd[i];
70988 +            current->VTotal     = pSiS->SiS_Pr->CP_VTotal[i];
70989 +
70990 +            current->CrtcHDisplay = current->HDisplay;
70991 +            current->CrtcHBlankStart = pSiS->SiS_Pr->CP_HBlankStart[i];
70992 +            current->CrtcHSyncStart = current->HSyncStart;
70993 +            current->CrtcHSyncEnd = current->HSyncEnd;
70994 +            current->CrtcHBlankEnd = pSiS->SiS_Pr->CP_HBlankEnd[i];
70995 +            current->CrtcHTotal = current->HTotal;
70996 +
70997 +            current->CrtcVDisplay = current->VDisplay;
70998 +            current->CrtcVBlankStart = pSiS->SiS_Pr->CP_VBlankStart[i];
70999 +            current->CrtcVSyncStart = current->VSyncStart;
71000 +            current->CrtcVSyncEnd = current->VSyncEnd;
71001 +            current->CrtcVBlankEnd = pSiS->SiS_Pr->CP_VBlankEnd[i];
71002 +            current->CrtcVTotal = current->VTotal;
71003 +
71004 +           if(pSiS->SiS_Pr->CP_SyncValid[i]) {
71005 +               if(pSiS->SiS_Pr->CP_HSync_P[i])
71006 +                  current->Flags |= V_PHSYNC;
71007 +               else
71008 +                  current->Flags |= V_NHSYNC;
71009 +
71010 +               if(pSiS->SiS_Pr->CP_VSync_P[i])
71011 +                  current->Flags |= V_PVSYNC;
71012 +               else
71013 +                  current->Flags |= V_NVSYNC;
71014 +           } else {
71015 +              /* No sync data? Use positive sync... */
71016 +              current->Flags |= V_PHSYNC;
71017 +              current->Flags |= V_PVSYNC;
71018 +           }
71019 +         }
71020 +      }
71021 +   }
71022 +
71023     return first;
71024  
71025  }
71026 @@ -5486,25 +5897,25 @@ sisfb_mode_rate_to_dclock(SiS_Private *S
71027      UCHAR  *ROMAddr  = HwDeviceExtension->pjVirtualRomBase;
71028      ULONG  temp = 0;
71029      int    Clock;
71030 -    
71031 +
71032      if(HwDeviceExtension->jChipType < SIS_315H) {
71033  #ifdef SIS300
71034         InitTo300Pointer(SiS_Pr, HwDeviceExtension);
71035  #else
71036 -       return 65;
71037 +       return 65 * 1000 * 1000;
71038  #endif
71039      } else {
71040  #ifdef SIS315H
71041         InitTo310Pointer(SiS_Pr, HwDeviceExtension);
71042  #else
71043 -       return 65;
71044 +       return 65 * 1000 * 1000;
71045  #endif
71046      }
71047 -    
71048 +
71049      temp = SiS_SearchModeID(SiS_Pr, ROMAddr, &ModeNo, &ModeIdIndex);
71050      if(!temp) {
71051         printk(KERN_ERR "Could not find mode %x\n", ModeNo);
71052 -       return 65;
71053 +       return 65 * 1000 * 1000;
71054      }
71055      
71056      RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex;
71057 @@ -5518,6 +5929,56 @@ sisfb_mode_rate_to_dclock(SiS_Private *S
71058      return(Clock);
71059  }
71060  
71061 +BOOLEAN
71062 +sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
71063 +                      unsigned char modeno, int *htotal, int *vtotal, unsigned char rateindex)
71064 +{
71065 +    USHORT ModeNo = modeno;
71066 +    USHORT ModeIdIndex = 0, CRT1Index = 0;
71067 +    USHORT RefreshRateTableIndex = 0;
71068 +    UCHAR  *ROMAddr  = HwDeviceExtension->pjVirtualRomBase;
71069 +    ULONG  temp = 0;
71070 +    unsigned char  sr_data, cr_data, cr_data2;
71071 +
71072 +    if(HwDeviceExtension->jChipType < SIS_315H) {
71073 +#ifdef SIS300
71074 +       InitTo300Pointer(SiS_Pr, HwDeviceExtension);
71075 +#else
71076 +       return FALSE;
71077 +#endif
71078 +    } else {
71079 +#ifdef SIS315H
71080 +       InitTo310Pointer(SiS_Pr, HwDeviceExtension);
71081 +#else
71082 +       return FALSE;
71083 +#endif
71084 +    }
71085 +
71086 +    temp = SiS_SearchModeID(SiS_Pr, ROMAddr, &ModeNo, &ModeIdIndex);
71087 +    if(!temp) return FALSE;
71088 +
71089 +    RefreshRateTableIndex = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex;
71090 +    RefreshRateTableIndex += (rateindex - 1);
71091 +    CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
71092 +
71093 +    sr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[14];
71094 +    cr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[0];
71095 +    *htotal = (((cr_data & 0xff) | ((unsigned short) (sr_data & 0x03) << 8)) + 5) * 8;
71096 +
71097 +    sr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13];
71098 +    cr_data = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[6];
71099 +    cr_data2 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[7];
71100 +    *vtotal = ((cr_data & 0xFF) |
71101 +               ((unsigned short)(cr_data2 & 0x01) <<  8) |
71102 +              ((unsigned short)(cr_data2 & 0x20) <<  4) |
71103 +              ((unsigned short)(sr_data  & 0x01) << 10)) + 2;
71104 +
71105 +    if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & InterlaceMode)
71106 +       *vtotal *= 2;
71107 +
71108 +    return TRUE;
71109 +}
71110 +
71111  int
71112  sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
71113                          unsigned char modeno, unsigned char rateindex,
71114 @@ -5606,17 +6067,32 @@ sisfb_mode_rate_to_ddata(SiS_Private *Si
71115      C = (temp > 0) ? temp : (temp + 64);
71116  
71117      D = B - F - C;
71118 -    
71119 -    *left_margin = D * 8;
71120 -    *right_margin = F * 8;
71121 -    *hsync_len = C * 8;
71122 +
71123 +    if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes == 320) &&
71124 +       ((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].YRes == 200) ||
71125 +       (SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].YRes == 240))) {
71126 +
71127 +        /* Terrible hack, but the correct CRTC data for
71128 +         * these modes only produces a black screen...
71129 +         */
71130 +       *left_margin = (400 - 376);
71131 +       *right_margin = (328 - 320);
71132 +       *hsync_len = (376 - 328);
71133 +
71134 +    } else {
71135 +
71136 +       *left_margin = D * 8;
71137 +       *right_margin = F * 8;
71138 +       *hsync_len = C * 8;
71139 +
71140 +    }
71141  
71142      sr_data = SiS_Pr->SiS_CRT1Table[index].CR[13];
71143  
71144      cr_data = SiS_Pr->SiS_CRT1Table[index].CR[6];
71145 -    
71146 +
71147      cr_data2 = SiS_Pr->SiS_CRT1Table[index].CR[7];
71148 -    
71149 +
71150      /* Vertical total */
71151      VT = (cr_data & 0xFF) |
71152           ((unsigned short) (cr_data2 & 0x01) << 8) |
71153 @@ -5699,19 +6175,19 @@ sisfb_mode_rate_to_ddata(SiS_Private *Si
71154           j++;
71155        }
71156      }       
71157 -       
71158 -#if 0  /* That's bullshit, only the resolution needs to be shifted */    
71159 +
71160      if((*vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
71161 +#if 0  /* Do this? */
71162         *upper_margin <<= 1;
71163         *lower_margin <<= 1;
71164         *vsync_len <<= 1;
71165 +#endif
71166      } else if((*vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
71167         *upper_margin >>= 1;
71168         *lower_margin >>= 1;
71169         *vsync_len >>= 1;
71170 -    }  
71171 -#endif
71172 -          
71173 +    }
71174 +
71175      return 1;       
71176  }                        
71177  
71178 --- linux-2.6.0-test6/drivers/video/sis/initdef.h       2003-06-14 12:18:24.000000000 -0700
71179 +++ 25/drivers/video/sis/initdef.h      2003-10-05 00:34:22.000000000 -0700
71180 @@ -1,5 +1,37 @@
71181  /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/initdef.h,v 1.4 2000/12/02 01:16:17 dawes Exp $ */
71182 -
71183 +/*
71184 + * Global definitions for init.c and init301.c
71185 + *
71186 + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
71187 + *
71188 + * If distributed as part of the linux kernel, the contents of this file
71189 + * is entirely covered by the GPL.
71190 + *
71191 + * Otherwise, the following terms apply:
71192 + *
71193 + * Permission to use, copy, modify, distribute, and sell this software and its
71194 + * documentation for any purpose is hereby granted without fee, provided that
71195 + * the above copyright notice appear in all copies and that both that
71196 + * copyright notice and this permission notice appear in supporting
71197 + * documentation, and that the name of the copyright holder not be used in
71198 + * advertising or publicity pertaining to distribution of the software without
71199 + * specific, written prior permission.  The copyright holder makes no representations
71200 + * about the suitability of this software for any purpose.  It is provided
71201 + * "as is" without express or implied warranty.
71202 + *
71203 + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
71204 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
71205 + * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
71206 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
71207 + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
71208 + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
71209 + * PERFORMANCE OF THIS SOFTWARE.
71210 + *
71211 + * Author:     Thomas Winischhofer <thomas@winischhofer.net>
71212 + *
71213 + * Based on code by Silicon Intergrated Systems
71214 + *
71215 + */
71216  
71217  #ifndef _INITDEF_
71218  #define _INITDEF_
71219 @@ -22,12 +54,19 @@
71220  #define VB_SIS301B302B          (VB_SIS301B|VB_SIS302B)
71221  #define VB_SIS301LV302LV        (VB_SIS301LV|VB_SIS302LV)
71222  
71223 -#define IS_SIS650740            ((HwDeviceExtension->jChipType >= SIS_650) && (HwDeviceExtension->jChipType < SIS_330))
71224 -
71225  #define IS_SIS650              (HwDeviceExtension->jChipType == SIS_650)
71226  #define IS_SIS740              (HwDeviceExtension->jChipType == SIS_740)
71227  #define IS_SIS330              (HwDeviceExtension->jChipType == SIS_330)
71228  #define IS_SIS550              (HwDeviceExtension->jChipType == SIS_550)
71229 +#define IS_SIS651              (SiS_Pr->SiS_SysFlags & (SF_Is651 | SF_Is652))
71230 +#define IS_SISM650             (SiS_Pr->SiS_SysFlags & (SF_IsM650 | SF_IsM652 | SF_IsM653))
71231 +#define IS_SIS65x               (IS_SIS651 || IS_SISM650)
71232 +#define IS_SIS660              (HwDeviceExtension->jChipType == SIS_660)
71233 +#define IS_SIS760              (HwDeviceExtension->jChipType == SIS_760)
71234 +#define IS_SIS650660            (IS_SIS650 || IS_SIS660)
71235 +#define IS_SIS650740            ((HwDeviceExtension->jChipType >= SIS_650) && (HwDeviceExtension->jChipType < SIS_330))
71236 +#define IS_SIS650740660         (IS_SIS650 || IS_SIS660 || IS_SIS740 || IS_SIS760)
71237 +#define IS_SIS550650740660      (IS_SIS550 || IS_SIS650 || IS_SIS660 || IS_SIS740 || IS_SIS760)
71238  
71239  #define CRT1Len                 17
71240  #define LVDSCRT1Len             15
71241 @@ -63,7 +102,7 @@
71242  #define SupportTV               0x0008
71243  #define SupportHiVisionTV       0x0010
71244  #define SupportLCD              0x0020
71245 -#define SupportRAMDAC2          0x0040  
71246 +#define SupportRAMDAC2          0x0040
71247  #define NoSupportTV             0x0070
71248  #define NoSupportHiVisionTV     0x0060
71249  #define NoSupportLCD            0x0058
71250 @@ -105,6 +144,24 @@
71251  #define HotKeySwitch            0x8000  /* TW: ? */
71252  #define SetCRT2ToLCDA           0x8000
71253  
71254 +/* SetFlag */
71255 +#define ProgrammingCRT2         0x01
71256 +#define TVSimuMode              0x02
71257 +#define RPLLDIV2XO              0x04
71258 +#define LCDVESATiming           0x08
71259 +#define EnableLVDSDDA           0x10
71260 +#define SetDispDevSwitchFlag    0x20
71261 +#define CheckWinDos             0x40
71262 +#define SetDOSMode              0x80
71263 +
71264 +/* SysFlags */
71265 +#define SF_Is651                0x0001
71266 +#define SF_IsM650               0x0002
71267 +#define SF_Is652               0x0004
71268 +#define SF_IsM652              0x0008
71269 +#define SF_IsM653              0x0010
71270 +#define SF_Is660               0x8000
71271 +
71272  #define PanelRGB18Bit           0x0100
71273  #define PanelRGB24Bit           0x0000
71274  
71275 @@ -112,7 +169,7 @@
71276  #define TVOverScanShift         4
71277  #define ClearBufferFlag         0x20
71278  
71279 -/* CR32 (Newer 630, and 310/325 series)
71280 +/* CR32 (Newer 630, and 315 series)
71281  
71282     [0]   VB connected with CVBS
71283     [1]   VB connected with SVHS
71284 @@ -134,7 +191,7 @@
71285             011   LVDS + Tumpion Zurac
71286             100   LVDS + Chrontel 7005
71287             110   Chrontel 7005
71288 -         310/325 series
71289 +         315 series
71290             001   SiS30x (never seen)
71291             010   LVDS
71292             011   LVDS + Chrontel 7019
71293 @@ -163,14 +220,15 @@
71294  #define LCDSyncBit            0x00e0
71295  #define LCDSyncShift               6
71296  
71297 -/* CR38 (310/325 series) */
71298 +/* CR38 (315 series) */
71299  #define EnableDualEdge                 0x01   
71300  #define SetToLCDA              0x02   /* LCD channel A (302B/LV and 650+LVDS only) */
71301  #define EnableSiSHiVision       0x04   /* HiVision (HDTV) on SiS bridge */
71302  #define EnableLVDSScart         0x04   /* Scart on Ch7019 (unofficial definition - TW) */
71303  #define EnableLVDSHiVision      0x08   /* YPbPr color format (480i HDTV); only on 650/Ch7019 systems */
71304 -#define SiSHiVision1            0x10   /* See SetHiVision() */
71305 -#define SiSHiVision2            0x20
71306 +#define EnableHiVision750       0x08   /* Enable 750P HiVision mode (30xLV only) */
71307 +#define EnableHiVision525       0x10   /* Enable 525P HiVision mode (30xLV only) */
71308 +#define SiSHiVision2            0x20   /* ? - |  --- mask 0x38 combinations have different meaning! */
71309  #define EnablePALM              0x40   /* 1 = Set PALM */
71310  #define EnablePALN              0x80   /* 1 = Set PALN */
71311  
71312 @@ -184,7 +242,7 @@
71313  #define Enable302LV_DualLink    0x04   /* 30xNEW (302LV) only; set by mode switching function */
71314  
71315  
71316 -/* CR79 (310/325 series only)
71317 +/* CR79 (315 series only)
71318     [3-0] Notify driver
71319           0001 Mode Switch event (set by BIOS)
71320          0010 Epansion On/Off event
71321 @@ -202,16 +260,6 @@
71322     [7]   TV UnderScan/OverScan (set by BIOS)
71323  */
71324  
71325 -/* SetFlag */
71326 -#define ProgrammingCRT2         0x01
71327 -#define TVSimuMode              0x02
71328 -#define RPLLDIV2XO              0x04
71329 -#define LCDVESATiming           0x08
71330 -#define EnableLVDSDDA           0x10
71331 -#define SetDispDevSwitchFlag    0x20
71332 -#define CheckWinDos             0x40
71333 -#define SetDOSMode              0x80
71334 -
71335  /* LCDResInfo */
71336  #define Panel300_800x600        0x01   /* CR36 */
71337  #define Panel300_1024x768       0x02
71338 @@ -220,7 +268,10 @@
71339  #define Panel300_640x480        0x05
71340  #define Panel300_1024x600       0x06
71341  #define Panel300_1152x768       0x07
71342 -#define Panel300_320x480        0x08   /* fstn - TW: This is fake, can be any */
71343 +#define Panel300_1280x768       0x0a
71344 +#define Panel300_320x480        0x0e   /* fstn - TW: This is fake, can be any */
71345 +#define Panel300_Custom                0x0f
71346 +#define Panel300_Barco1366      0x10
71347  
71348  #define Panel310_800x600        0x01
71349  #define Panel310_1024x768       0x02
71350 @@ -231,9 +282,12 @@
71351  #define Panel310_1280x960       0x07
71352  #define Panel310_1152x768       0x08   /* LVDS only */
71353  #define Panel310_1400x1050      0x09
71354 -#define Panel310_1280x768       0x0a    /* LVDS only */
71355 +#define Panel310_1280x768       0x0a
71356  #define Panel310_1600x1200      0x0b
71357 -#define Panel310_320x480        0x0c    /* fstn - TW: This is fake, can be any */
71358 +#define Panel310_640x480_2      0x0c
71359 +#define Panel310_640x480_3      0x0d
71360 +#define Panel310_320x480        0x0e    /* fstn - TW: This is fake, can be any */
71361 +#define Panel310_Custom                0x0f
71362  
71363  #define Panel_800x600           0x01   /* Unified values */
71364  #define Panel_1024x768          0x02
71365 @@ -246,7 +300,43 @@
71366  #define Panel_1400x1050         0x09
71367  #define Panel_1280x768          0x0a    /* LVDS only */
71368  #define Panel_1600x1200         0x0b
71369 -#define Panel_320x480           0x0c    /* fstn - TW: This is fake, can be any */
71370 +#define Panel_640x480_2                0x0c
71371 +#define Panel_640x480_3                0x0d
71372 +#define Panel_320x480           0x0e    /* fstn - TW: This is fake, can be any */
71373 +#define Panel_Custom           0x0f
71374 +#define Panel_Barco1366         0x10
71375 +#define Panel_848x480          0x11
71376 +
71377 +/* Index in ModeResInfo table */
71378 +#define SIS_RI_320x200 0
71379 +#define SIS_RI_320x240 1
71380 +#define SIS_RI_320x400 2
71381 +#define SIS_RI_400x300 3
71382 +#define SIS_RI_512x384 4
71383 +#define SIS_RI_640x400 5
71384 +#define SIS_RI_640x480 6
71385 +#define SIS_RI_800x600 7
71386 +#define SIS_RI_1024x768 8
71387 +#define SIS_RI_1280x1024 9
71388 +#define SIS_RI_1600x1200 10
71389 +#define SIS_RI_1920x1440 11
71390 +#define SIS_RI_2048x1536 12
71391 +#define SIS_RI_720x480 13
71392 +#define SIS_RI_720x576 14
71393 +#define SIS_RI_1280x960 15
71394 +#define SIS_RI_800x480 16
71395 +#define SIS_RI_1024x576 17
71396 +#define SIS_RI_1280x720 18
71397 +#define SIS_RI_856x480 19
71398 +#define SIS_RI_1280x768 20
71399 +#define SIS_RI_1400x1050 21
71400 +#define SIS_RI_1152x864 22
71401 +#define SIS_RI_848x480 23
71402 +#define SIS_RI_1360x768 24
71403 +#define SIS_RI_1024x600 25
71404 +#define SIS_RI_1152x768 26
71405 +#define SIS_RI_768x576 27
71406 +#define SIS_RI_1360x1024 28
71407  
71408  #define ExtChipType             0x0e
71409  #define ExtChip301              0x02
71410 @@ -278,15 +368,34 @@
71411  #define VCLKStartFreq           25
71412  #define SoftDramType            0x80
71413  
71414 -#define VCLK40                  0x04   /* Index in VCLKData array */
71415 -#define VCLK65                  0x09   /* Index in VCLKData array */
71416 -#define VCLK108_2               0x14   /* Index in VCLKData array */
71417 -#define TVVCLKDIV2              0x21   /* Indices in (VB)VCLKData arrays */
71418 -#define TVVCLK                  0x22
71419 -#define HiTVVCLKDIV2            0x23
71420 -#define HiTVVCLK                0x24
71421 -#define HiTVSimuVCLK            0x25
71422 -#define HiTVTextVCLK            0x26
71423 +/* Indices in (VB)VCLKData tables */
71424 +
71425 +#define VCLK28                  0x00   /* Index in VCLKData table (300 and 315) */
71426 +#define VCLK40                  0x04   /* Index in VCLKData table (300 and 315) */
71427 +#define VCLK65_300              0x09   /* Index in VCLKData table (300) */
71428 +#define VCLK108_2_300           0x14   /* Index in VCLKData table (300) */
71429 +#define VCLK81_300             0x3f   /* Index in VCLKData table (300) */
71430 +#define VCLK108_3_300           0x42   /* Index in VCLKData table (300) */
71431 +#define VCLK100_300             0x43   /* Index in VCLKData table (300) */
71432 +#define VCLK34_300              0x3d   /* Index in VCLKData table (300) */
71433 +#define VCLK65_315              0x0b   /* Index in (VB)VCLKData table (315) */
71434 +#define VCLK108_2_315           0x19   /* Index in (VB)VCLKData table (315) */
71435 +#define VCLK81_315             0x5b   /* Index in (VB)VCLKData table (315) */
71436 +#define VCLK162_315             0x21   /* Index in (VB)VCLKData table (315) */
71437 +#define VCLK108_3_315           0x45   /* Index in VBVCLKData table (315) */
71438 +#define VCLK100_315             0x46   /* Index in VBVCLKData table (315) */
71439 +#define VCLK34_315              0x55   /* Index in VBVCLKData table (315) */
71440 +
71441 +#define TVCLKBASE_300          0x21   /* Indices on TV clocks in VCLKData table (300) */
71442 +#define TVCLKBASE_315          0x3a   /* Indices on TV clocks in (VB)VCLKData table (315) */
71443 +#define TVVCLKDIV2              0x00   /* Index relative to TVCLKBASE */
71444 +#define TVVCLK                  0x01   /* Index relative to TVCLKBASE */
71445 +#define HiTVVCLKDIV2            0x02   /* Index relative to TVCLKBASE */
71446 +#define HiTVVCLK                0x03   /* Index relative to TVCLKBASE */
71447 +#define HiTVSimuVCLK            0x04   /* Index relative to TVCLKBASE */
71448 +#define HiTVTextVCLK            0x05   /* Index relative to TVCLKBASE */
71449 +
71450 +/* ------------------------------ */
71451  
71452  #define LoadDACFlag             0x1000
71453  #define AfterLockCRT2           0x4000
71454 @@ -306,6 +415,8 @@
71455  #define HotPlugFunction         0x08
71456  #define StStructSize            0x06
71457  
71458 +#define SIS_VIDEO_CAPTURE       0x00 - 0x30
71459 +#define SIS_VIDEO_PLAYBACK      0x02 - 0x30
71460  #define SIS_CRT2_PORT_04        0x04 - 0x30
71461  #define SIS_CRT2_PORT_10        0x10 - 0x30
71462  #define SIS_CRT2_PORT_12        0x12 - 0x30
71463 @@ -393,7 +504,7 @@
71464  
71465  /*
71466    =============================================================
71467 -                       for 310/325 series
71468 +                         for 315 series
71469    =============================================================
71470  */
71471  #define SoftDRAMType        0x80
71472 --- linux-2.6.0-test6/drivers/video/sis/init.h  2003-06-14 12:18:30.000000000 -0700
71473 +++ 25/drivers/video/sis/init.h 2003-10-05 00:34:22.000000000 -0700
71474 @@ -1,19 +1,47 @@
71475 +/* $XFree86$ */
71476 +/*
71477 + * Data and prototypes for init.c
71478 + *
71479 + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
71480 + *
71481 + * If distributed as part of the linux kernel, the contents of this file
71482 + * is entirely covered by the GPL.
71483 + *
71484 + * Otherwise, the following terms apply:
71485 + *
71486 + * Permission to use, copy, modify, distribute, and sell this software and its
71487 + * documentation for any purpose is hereby granted without fee, provided that
71488 + * the above copyright notice appear in all copies and that both that
71489 + * copyright notice and this permission notice appear in supporting
71490 + * documentation, and that the name of the copyright holder not be used in
71491 + * advertising or publicity pertaining to distribution of the software without
71492 + * specific, written prior permission.  The copyright holder makes no representations
71493 + * about the suitability of this software for any purpose.  It is provided
71494 + * "as is" without express or implied warranty.
71495 + *
71496 + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
71497 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
71498 + * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
71499 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
71500 + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
71501 + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
71502 + * PERFORMANCE OF THIS SOFTWARE.
71503 + *
71504 + * Author:     Thomas Winischhofer <thomas@winischhofer.net>
71505 + *
71506 + * Based on code by Silicon Intergrated Systems
71507 + *
71508 + */
71509 +
71510  #ifndef _INIT_
71511  #define _INIT_
71512  
71513  #include "osdef.h"
71514 +
71515  #include "initdef.h"
71516  #include "vgatypes.h"
71517  #include "vstruct.h"
71518  
71519 -#ifdef TC
71520 -#include <stdio.h>
71521 -#include <string.h>
71522 -#include <conio.h>
71523 -#include <dos.h>
71524 -#include <stdlib.h>
71525 -#endif
71526 -
71527  #ifdef LINUX_XF86
71528  #include "xf86.h"
71529  #include "xf86Pci.h"
71530 @@ -24,6 +52,9 @@
71531  #endif
71532  
71533  #ifdef LINUX_KERNEL
71534 +#ifdef SIS_CP
71535 +#undef SIS_CP
71536 +#endif
71537  #include <linux/config.h>
71538  #include <linux/version.h>
71539  #include <linux/types.h>
71540 @@ -36,19 +67,6 @@
71541  #endif
71542  #endif
71543  
71544 -#ifdef WIN2000
71545 -#include <stdio.h>
71546 -#include <string.h>
71547 -#include <miniport.h>
71548 -#include "dderror.h"
71549 -#include "devioctl.h"
71550 -#include "miniport.h"
71551 -#include "ntddvdeo.h"
71552 -#include "video.h"
71553 -#include "sisv.h"
71554 -#include "tools.h"
71555 -#endif
71556 -
71557  const USHORT SiS_DRAMType[17][5]={
71558         {0x0C,0x0A,0x02,0x40,0x39},
71559         {0x0D,0x0A,0x01,0x40,0x48},
71560 @@ -144,6 +162,2227 @@ const USHORT SiS_VGA_DAC[] =
71561         0x0B,0x0C,0x0D,0x0F,0x10
71562  };
71563  
71564 +static const SiS_StResInfoStruct SiS_StResInfo[]=
71565 +{
71566 +       { 640,400},
71567 +       { 640,350},
71568 +       { 720,400},
71569 +       { 720,350},
71570 +       { 640,480}
71571 +};
71572 +
71573 +static const SiS_ModeResInfoStruct SiS_ModeResInfo[] =
71574 +{
71575 +       {  320, 200, 8, 8},   /* 0x00 */
71576 +       {  320, 240, 8, 8},   /* 0x01 */
71577 +       {  320, 400, 8, 8},   /* 0x02 */
71578 +       {  400, 300, 8, 8},   /* 0x03 */
71579 +       {  512, 384, 8, 8},   /* 0x04 */
71580 +       {  640, 400, 8,16},   /* 0x05 */
71581 +       {  640, 480, 8,16},   /* 0x06 */
71582 +       {  800, 600, 8,16},   /* 0x07 */
71583 +       { 1024, 768, 8,16},   /* 0x08 */
71584 +       { 1280,1024, 8,16},   /* 0x09 */
71585 +       { 1600,1200, 8,16},   /* 0x0a */
71586 +       { 1920,1440, 8,16},   /* 0x0b */
71587 +       { 2048,1536, 8,16},   /* 0x0c */
71588 +       {  720, 480, 8,16},   /* 0x0d */
71589 +       {  720, 576, 8,16},   /* 0x0e */
71590 +       { 1280, 960, 8,16},   /* 0x0f */
71591 +       {  800, 480, 8,16},   /* 0x10 */
71592 +       { 1024, 576, 8,16},   /* 0x11 */
71593 +       { 1280, 720, 8,16},   /* 0x12 */
71594 +       {  856, 480, 8,16},   /* 0x13 */
71595 +       { 1280, 768, 8,16},   /* 0x14 */
71596 +       { 1400,1050, 8,16},   /* 0x15 */
71597 +       { 1152, 864, 8,16},   /* 0x16 */
71598 +       {  848, 480, 8,16},   /* 0x17 */
71599 +       { 1360, 768, 8,16},   /* 0x18 */
71600 +       { 1024, 600, 8,16},   /* 0x19 */
71601 +       { 1152, 768, 8,16},   /* 0x1a */
71602 +       {  768, 576, 8,16},   /* 0x1b */
71603 +       { 1360,1024, 8,16}    /* 0x1c */
71604 +};
71605 +
71606 +static SiS_StandTableStruct SiS_StandTable[]=
71607 +{
71608 +/* 0x00: MD_0_200 */
71609 + {
71610 +  0x28,0x18,0x08,0x0800,
71611 +  {0x09,0x03,0x00,0x02},
71612 +  0x63,
71613 +  {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
71614 +   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
71615 +   0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
71616 +   0xff},
71617 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
71618 +   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
71619 +   0x08,0x00,0x0f,0x00},
71620 +  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
71621 +   0xff}
71622 + },
71623 +/* 0x01: MD_1_200 */
71624 + {
71625 +  0x28,0x18,0x08,0x0800,
71626 +  {0x09,0x03,0x00,0x02},
71627 +  0x63,
71628 +  {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
71629 +   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
71630 +   0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
71631 +   0xff},
71632 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
71633 +   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
71634 +   0x08,0x00,0x0f,0x00},
71635 +  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
71636 +   0xff}
71637 + },
71638 +/* 0x02: MD_2_200 */
71639 + {
71640 +  0x50,0x18,0x08,0x1000,
71641 +  {0x01,0x03,0x00,0x02},
71642 +  0x63,
71643 +  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
71644 +   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
71645 +   0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
71646 +   0xff},
71647 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
71648 +   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
71649 +   0x08,0x00,0x0f,0x00},
71650 +  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
71651 +   0xff}
71652 + },
71653 +/* 0x03: MD_3_200 - mode 0x03 - 0 */
71654 + {
71655 +  0x50,0x18,0x08,0x1000,
71656 +  {0x01,0x03,0x00,0x02},
71657 +  0x63,
71658 +  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
71659 +   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
71660 +   0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
71661 +   0xff},
71662 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
71663 +   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
71664 +   0x08,0x00,0x0f,0x00},
71665 +  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
71666 +   0xff}
71667 + },
71668 +/* 0x04: MD_4 */
71669 + {
71670 +  0x28,0x18,0x08,0x4000,
71671 +  {0x09,0x03,0x00,0x02},
71672 +  0x63,
71673 +  {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,   /* 0x2c is 2b for 300 */
71674 +   0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
71675 +   0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2,
71676 +   0xff},
71677 +  {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07,
71678 +   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
71679 +   0x01,0x00,0x03,0x00},
71680 +  {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,
71681 +   0xff}
71682 + },
71683 +/* 0x05: MD_5 */
71684 + {
71685 +  0x28,0x18,0x08,0x4000,
71686 +  {0x09,0x03,0x00,0x02},
71687 +  0x63,
71688 +  {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,   /* 0x2c is 2b for 300 */
71689 +   0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
71690 +   0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2,
71691 +   0xff},
71692 +  {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07,
71693 +   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
71694 +   0x01,0x00,0x03,0x00},
71695 +  {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,
71696 +   0xff}
71697 + },
71698 +/* 0x06: MD_6 */
71699 + {
71700 +  0x50,0x18,0x08,0x4000,
71701 +  {0x01,0x01,0x00,0x06},
71702 +  0x63,
71703 +  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,   /* 55,81 is 54,80 for 300 */
71704 +   0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
71705 +   0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xc2,
71706 +   0xff},
71707 +  {0x00,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
71708 +   0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
71709 +   0x01,0x00,0x01,0x00},
71710 +  {0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00,
71711 +   0xff}
71712 + },
71713 +/* 0x07: MD_7 */
71714 + {
71715 +  0x50,0x18,0x0e,0x1000,
71716 +  {0x00,0x03,0x00,0x03},
71717 +  0xa6,
71718 +  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
71719 +   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
71720 +   0x83,0x85,0x5d,0x28,0x0d,0x63,0xba,0xa3,
71721 +   0xff},
71722 +  {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
71723 +   0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
71724 +   0x0e,0x00,0x0f,0x08},
71725 +  {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,
71726 +   0xff}
71727 + },
71728 +/* 0x08: MDA_DAC */
71729 + {
71730 +  0x00,0x00,0x00,0x0000,
71731 +  {0x00,0x00,0x00,0x15},
71732 +  0x15,
71733 +  {0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
71734 +   0x15,0x15,0x15,0x15,0x15,0x15,0x3f,0x3f,
71735 +   0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,
71736 +   0x00},
71737 +  {0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15,
71738 +   0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
71739 +   0x15,0x15,0x15,0x15},
71740 +  {0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
71741 +   0x3f}
71742 + },
71743 +/* 0x09: CGA_DAC */
71744 + {
71745 +  0x00,0x10,0x04,0x0114,
71746 +  {0x11,0x09,0x15,0x00},
71747 +  0x10,
71748 +  {0x04,0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,
71749 +   0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x2a,0x3a,
71750 +   0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x10,
71751 +   0x04},
71752 +  {0x14,0x01,0x11,0x09,0x15,0x00,0x10,0x04,
71753 +   0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,0x2e,
71754 +   0x3e,0x2b,0x3b,0x2f},
71755 +  {0x3f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f,
71756 +   0x3f}
71757 + },
71758 +/* 0x0a: EGA_DAC */
71759 + {
71760 +  0x00,0x10,0x04,0x0114,
71761 +  {0x11,0x05,0x15,0x20},
71762 +  0x30,
71763 +  {0x24,0x34,0x21,0x31,0x25,0x35,0x08,0x18,
71764 +   0x0c,0x1c,0x09,0x19,0x0d,0x1d,0x28,0x38,
71765 +   0x2c,0x3c,0x29,0x39,0x2d,0x3d,0x02,0x12,
71766 +   0x06},
71767 +  {0x16,0x03,0x13,0x07,0x17,0x22,0x32,0x26,
71768 +   0x36,0x23,0x33,0x27,0x37,0x0a,0x1a,0x0e,
71769 +   0x1e,0x0b,0x1b,0x0f},
71770 +  {0x1f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f,
71771 +   0x3f}
71772 + },
71773 +/* 0x0b: VGA_DAC */
71774 + {
71775 +  0x00,0x10,0x04,0x0114,
71776 +  {0x11,0x09,0x15,0x2a},
71777 +  0x3a,
71778 +  {0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x05,
71779 +   0x08,0x0b,0x0e,0x11,0x14,0x18,0x1c,0x20,
71780 +   0x24,0x28,0x2d,0x32,0x38,0x3f,0x00,0x10,
71781 +   0x1f},
71782 +  {0x2f,0x3f,0x1f,0x27,0x2f,0x37,0x3f,0x2d,
71783 +   0x31,0x36,0x3a,0x3f,0x00,0x07,0x0e,0x15,
71784 +   0x1c,0x0e,0x11,0x15},
71785 +  {0x18,0x1c,0x14,0x16,0x18,0x1a,0x1c,0x00,
71786 +   0x04}
71787 + },
71788 +/* 0x0c */
71789 + {
71790 +  0x08,0x0c,0x10,0x0a08,
71791 +  {0x0c,0x0e,0x10,0x0b},
71792 +  0x0c,
71793 +  {0x0d,0x0f,0x10,0x10,0x01,0x08,0x00,0x00,
71794 +   0x00,0x00,0x01,0x00,0x02,0x02,0x01,0x00,
71795 +   0x04,0x04,0x01,0x00,0x05,0x02,0x05,0x00,
71796 +   0x06},
71797 +  {0x01,0x06,0x05,0x06,0x00,0x08,0x01,0x08,
71798 +   0x00,0x07,0x02,0x07,0x06,0x07,0x00,0x00,
71799 +   0x00,0x00,0x00,0x00},
71800 +  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
71801 +   0x00}
71802 + },
71803 +/* 0x0d: MD_D */
71804 + {
71805 +  0x28,0x18,0x08,0x2000,
71806 +  {0x09,0x0f,0x00,0x06},
71807 +  0x63,
71808 +  {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,     /* 2c is 2b for 300 */
71809 +   0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
71810 +   0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xe3,
71811 +   0xff},
71812 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
71813 +   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
71814 +   0x01,0x00,0x0f,0x00},
71815 +  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
71816 +   0xff}
71817 + },
71818 +/* 0x0e: MD_E */
71819 + {
71820 +  0x50,0x18,0x08,0x4000,
71821 +  {0x01,0x0f,0x00,0x06},
71822 +  0x63,
71823 +  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,     /* 55,81 is 54,80 for 300 */
71824 +   0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
71825 +   0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xe3,
71826 +   0xff},
71827 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
71828 +   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
71829 +   0x01,0x00,0x0f,0x00},
71830 +  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
71831 +   0xff}
71832 + },
71833 +/* 0x0f: ExtVGATable - modes > 0x13 */
71834 + {
71835 +  0x00,0x00,0x00,0x0000,
71836 +  {0x01,0x0f,0x00,0x0e},
71837 +  0x23,
71838 +  {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e,
71839 +   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
71840 +   0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3,
71841 +   0xff},
71842 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
71843 +   0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
71844 +   0x01,0x00,0x00,0x00},
71845 +  {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,
71846 +   0xff}
71847 + },
71848 +/* 0x10: ROM_SAVEPTR - totally different for 300 */
71849 + {
71850 +  0x9f,0x3b,0x00,0x00c0,
71851 +  {0x00,0x00,0x00,0x00},
71852 +  0x00,
71853 +  {0x00,0x00,0x00,0x00,0x00,0x00,0xbb,0x3f,
71854 +   0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
71855 +   0x00,0x00,0x1a,0x00,0xac,0x3e,0x00,0xc0,
71856 +   0x00},
71857 +  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
71858 +   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
71859 +   0x00,0x00,0x00,0x00},
71860 +  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
71861 +   0x00}
71862 + },
71863 +/* 0x11: MD_F */
71864 + {
71865 +  0x50,0x18,0x0e,0x8000,
71866 +  {0x01,0x0f,0x00,0x06},
71867 +  0xa2,
71868 +  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,    /* 55,81 is 54,80 on 300 */
71869 +   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
71870 +   0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3,    /* 82,84 is 83,85 on 300 */
71871 +   0xff},
71872 +  {0x00,0x08,0x00,0x00,0x18,0x18,0x00,0x00,
71873 +   0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00,
71874 +   0x0b,0x00,0x05,0x00},
71875 +  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,
71876 +   0xff}
71877 + },
71878 +/* 0x12: MD_10 */
71879 + {
71880 +  0x50,0x18,0x0e,0x8000,
71881 +  {0x01,0x0f,0x00,0x06},
71882 +  0xa3,
71883 +  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,    /* 55,81 is 54,80 on 300 */
71884 +   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
71885 +   0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3,    /* 82,84 is 83,85 on 300 */
71886 +   0xff},
71887 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
71888 +   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
71889 +   0x01,0x00,0x0f,0x00},
71890 +  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
71891 +   0xff}
71892 + },
71893 +/* 0x13: MD_0_350 */
71894 + {
71895 +  0x28,0x18,0x0e,0x0800,
71896 +  {0x09,0x03,0x00,0x02},
71897 +  0xa3,
71898 +  {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f,    /* b1 is a0 on 300 */
71899 +   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
71900 +   0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3,
71901 +   0xff},
71902 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
71903 +   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
71904 +   0x08,0x00,0x0f,0x00},
71905 +  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
71906 +   0xff}
71907 + },
71908 +/* 0x14: MD_1_350 */
71909 + {
71910 +  0x28,0x18,0x0e,0x0800,
71911 +  {0x09,0x03,0x00,0x02},
71912 +  0xa3,
71913 +  {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
71914 +   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
71915 +   0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3,
71916 +   0xff},
71917 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
71918 +   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
71919 +   0x08,0x00,0x0f,0x00},
71920 +  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
71921 +   0xff}
71922 + },
71923 +/* 0x15: MD_2_350 */
71924 + {
71925 +  0x50,0x18,0x0e,0x1000,
71926 +  {0x01,0x03,0x00,0x02},
71927 +  0xa3,
71928 +  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
71929 +   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
71930 +   0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3,
71931 +   0xff},
71932 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
71933 +   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
71934 +   0x08,0x00,0x0f,0x00},
71935 +  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
71936 +   0xff}
71937 + },
71938 +/* 0x16: MD_3_350 - mode 0x03 - 1 */
71939 + {
71940 +  0x50,0x18,0x0e,0x1000,
71941 +  {0x01,0x03,0x00,0x02},
71942 +  0xa3,
71943 +  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
71944 +   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
71945 +   0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3,
71946 +   0xff},
71947 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
71948 +   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
71949 +   0x08,0x00,0x0f,0x00},
71950 +  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
71951 +   0xff}
71952 + },
71953 +/* 0x17: MD_0_1_400 */
71954 + {
71955 +  0x28,0x18,0x10,0x0800,
71956 +  {0x08,0x03,0x00,0x02},
71957 +  0x67,
71958 +  {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f,    /* b1 is a0 on 300 */
71959 +   0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
71960 +   0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
71961 +   0xff},
71962 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
71963 +   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
71964 +   0x0c,0x00,0x0f,0x08},
71965 +  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
71966 +   0xff}
71967 + },
71968 +/* 0x18: MD_2_3_400 - mode 0x03 - 2 */
71969 + {
71970 +  0x50,0x18,0x10,0x1000,
71971 +  {0x00,0x03,0x00,0x02},
71972 +  0x67,
71973 +  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
71974 +   0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
71975 +   0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
71976 +   0xff},
71977 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
71978 +   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
71979 +   0x0c,0x00,0x0f,0x08},
71980 +  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
71981 +   0xff}
71982 + },
71983 +/* 0x19: MD_7_400 */
71984 + {
71985 +  0x50,0x18,0x10,0x1000,
71986 +  {0x00,0x03,0x00,0x02},
71987 +  0x66,
71988 +  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
71989 +   0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
71990 +   0x9c,0x8e,0x8f,0x28,0x0f,0x96,0xb9,0xa3,
71991 +   0xff},
71992 +  {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
71993 +   0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
71994 +   0x0e,0x00,0x0f,0x08},
71995 +  {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,
71996 +   0xff}
71997 + },
71998 +/* 0x1a: MD_11 */
71999 + {
72000 +  0x50,0x1d,0x10,0xa000,
72001 +  {0x01,0x0f,0x00,0x06},
72002 +  0xe3,
72003 +  {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e,    /* 55,81 is 54,80 on 300 */
72004 +   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
72005 +   0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xc3,    /* e9,8b is ea,8c on 300 */
72006 +   0xff},
72007 +  {0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
72008 +   0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
72009 +   0x01,0x00,0x0f,0x00},
72010 +  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01,
72011 +   0xff}
72012 + },
72013 +/* 0x1b: ExtEGATable - Modes <= 0x02 */
72014 + {
72015 +  0x50,0x1d,0x10,0xa000,
72016 +  {0x01,0x0f,0x00,0x06},
72017 +  0xe3,
72018 +  {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e,    /* 55,81 is 54,80 on 300 */
72019 +   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
72020 +   0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xe3,    /* e9,8b is ea,8c on 300 */
72021 +   0xff},
72022 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
72023 +   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
72024 +   0x01,0x00,0x0f,0x00},
72025 +  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
72026 +   0xff}
72027 + },
72028 +/* 0x1c: MD_13 */
72029 + {
72030 +  0x28,0x18,0x08,0x2000,
72031 +  {0x01,0x0f,0x00,0x0e},
72032 +  0x63,
72033 +  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,    /* 55,81 is 54,80 on 300 */
72034 +   0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,
72035 +   0x9c,0x8e,0x8f,0x28,0x40,0x96,0xb9,0xa3,
72036 +   0xff},
72037 +  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
72038 +   0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
72039 +   0x41,0x00,0x0f,0x00},
72040 +  {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,
72041 +   0xff}
72042 + }
72043 +};
72044 +
72045 +static const UCHAR SiS_NTSCTiming[] = {
72046 +       0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c,
72047 +       0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a,
72048 +       0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b,
72049 +       0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17,
72050 +       0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02,
72051 +       0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40,
72052 +       0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x50,
72053 +       0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00
72054 +};
72055 +
72056 +static const UCHAR SiS_PALTiming[] = {
72057 +       0x19,0x52,0x35,0x6e,0x04,0x38,0x3d,0x70,
72058 +       0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d,
72059 +       0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b,
72060 +       0x70,0x50,0x00,0x9b,0x00,0xd9,0x5d,0x17,
72061 +       0x7d,0x05,0x45,0x00,0x00,0xe8,0x00,0x02,
72062 +       0x0d,0x00,0x68,0xb0,0x0b,0x92,0x8f,0x40,
72063 +       0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63,
72064 +       0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00
72065 +};
72066 +
72067 +static const UCHAR SiS_HiTVExtTiming[] = {
72068 +        0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64,
72069 +       0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
72070 +       0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
72071 +       0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13,
72072 +       0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40,
72073 +       0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40,
72074 +       0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d,
72075 +       0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00
72076 +};
72077 +
72078 +static const UCHAR SiS_HiTVSt1Timing[] = {
72079 +        0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65,
72080 +       0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
72081 +       0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
72082 +       0x65,0x90,0x7b,0xa8,0x03,0xf0,0x87,0x03,
72083 +       0x11,0x15,0x11,0xcf,0x10,0x11,0xcf,0x10,
72084 +       0x35,0x35,0x3b,0x69,0x1d,0x92,0x0f,0x40,
72085 +       0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x86,
72086 +       0xaf,0x5d,0x0e,0x00,0xfc,0xff,0x2d,0x00
72087 +};
72088 +
72089 +static const UCHAR SiS_HiTVSt2Timing[] = {
72090 +        0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x64,
72091 +       0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
72092 +       0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
72093 +       0x64,0x90,0x33,0x8c,0x18,0x36,0x3e,0x13,
72094 +       0x2a,0xde,0x2a,0x44,0x40,0x2a,0x44,0x40,
72095 +       0x8e,0x8e,0x82,0x07,0x0b,0x92,0x0f,0x40,
72096 +       0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x3d,
72097 +       0x63,0x4f,0x27,0x00,0xfc,0xff,0x6a,0x00
72098 +};
72099 +
72100 +static const UCHAR SiS_HiTVTextTiming[] = {
72101 +        0x32,0x65,0x2c,0x5f,0x08,0x31,0x3a,0x65,
72102 +       0x28,0x02,0x01,0x3d,0x06,0x3e,0x35,0x6d,
72103 +       0x06,0x14,0x3e,0x35,0x6d,0x00,0xc5,0x3f,
72104 +       0x65,0x90,0xe7,0xbc,0x03,0x0c,0x97,0x03,
72105 +       0x14,0x78,0x14,0x08,0x20,0x14,0x08,0x20,
72106 +       0xc8,0xc8,0x3b,0xd2,0x26,0x92,0x0f,0x40,
72107 +        0x60,0x80,0x14,0x90,0x8c,0x60,0x04,0x96,
72108 +       0x72,0x5c,0x11,0x00,0xfc,0xff,0x32,0x00
72109 +};
72110 +
72111 +static const UCHAR SiS_HiTVGroup3Data[] = {
72112 +        0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x5f,
72113 +       0x05,0x21,0xb2,0xb2,0x55,0x77,0x2a,0xa6,
72114 +       0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
72115 +       0x8c,0x6e,0x60,0x2e,0x58,0x48,0x72,0x44,
72116 +       0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
72117 +       0x4f,0x7f,0x03,0xa8,0x7d,0x20,0x1a,0xa9,
72118 +       0x14,0x05,0x03,0x7e,0x64,0x31,0x14,0x75,
72119 +       0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
72120 +};
72121 +
72122 +static const UCHAR SiS_HiTVGroup3Simu[] = {
72123 +        0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0x95,
72124 +       0xdb,0x20,0xb8,0xb8,0x55,0x47,0x2a,0xa6,
72125 +       0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
72126 +       0x8c,0x6e,0x60,0x15,0x26,0xd3,0xe4,0x11,
72127 +       0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
72128 +       0x67,0x36,0x01,0x47,0x0e,0x10,0xbe,0xb4,
72129 +       0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75,
72130 +       0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
72131 +};
72132 +
72133 +static const UCHAR SiS_HiTVGroup3Text[] = {
72134 +        0x00,0x1a,0x22,0x63,0x62,0x22,0x08,0xa7,
72135 +       0xf5,0x20,0xce,0xce,0x55,0x47,0x2a,0xa6,
72136 +       0x25,0x2f,0x47,0xfa,0xc8,0xff,0x8e,0x20,
72137 +       0x8c,0x6e,0x60,0x18,0x2c,0x0c,0x20,0x22,
72138 +       0x56,0x36,0x4f,0x6e,0x3f,0x80,0x00,0x80,
72139 +       0x93,0x3c,0x01,0x50,0x2f,0x10,0xf4,0xca,
72140 +       0x01,0x05,0x03,0x7e,0x65,0x31,0x14,0x75,
72141 +       0x18,0x05,0x18,0x05,0x4c,0xa8,0x01
72142 +};
72143 +
72144 +static const UCHAR SiS_NTSCPhase[]    = {0x21,0xed,0xba,0x08};  /* Was {0x21,0xed,0x8a,0x08}; */
72145 +static const UCHAR SiS_PALPhase[]     = {0x2a,0x05,0xe3,0x00};  /* Was {0x2a,0x05,0xd3,0x00};  */
72146 +static const UCHAR SiS_PALMPhase[]    = {0x21,0xE4,0x2E,0x9B};
72147 +static const UCHAR SiS_PALNPhase[]    = {0x21,0xF4,0x3E,0xBA};
72148 +static const UCHAR SiS_NTSCPhase2[]   = {0x21,0xF0,0x7B,0xD6};
72149 +static const UCHAR SiS_PALPhase2[]    = {0x2a,0x09,0x86,0xe9};
72150 +static const UCHAR SiS_PALMPhase2[]   = {0x21,0xE6,0xEF,0xA4};
72151 +static const UCHAR SiS_PALNPhase2[]   = {0x21,0xF6,0x94,0x46};
72152 +static const UCHAR SiS_SpecialPhase[] = {0x1e,0x8c,0x5c,0x7a};
72153 +
72154 +static const SiS_TVDataStruct  SiS_StPALData[]=
72155 +{
72156 + {    1,   1, 864, 525,1270, 400, 100,   0, 760,0xf4,0xff,0x1c,0x22},
72157 + {    1,   1, 864, 525,1270, 350, 100,   0, 760,0xf4,0xff,0x1c,0x22},
72158 + {    1,   1, 864, 525,1270, 400,   0,   0, 720,0xf1,0x04,0x1f,0x18},
72159 + {    1,   1, 864, 525,1270, 350,   0,   0, 720,0xf4,0x0b,0x1c,0x0a},
72160 + {    1,   1, 864, 525,1270, 480,  50,   0, 760,0xf4,0xff,0x1c,0x22},
72161 + {    1,   1, 864, 525,1270, 600,  50,   0,   0,0xf4,0xff,0x1c,0x22}
72162 +};
72163 +
72164 +static const SiS_TVDataStruct  SiS_ExtPALData[] =
72165 +{
72166 + {   27,  10, 848, 448,1270, 530,  50,   0,  50,0xf4,0xff,0x1c,0x22},  /* 640x400, 320x200 */
72167 + {  108,  35, 848, 398,1270, 530,  50,   0,  50,0xf4,0xff,0x1c,0x22},
72168 + {   12,   5, 954, 448,1270, 530,  50,   0,  50,0xf1,0x04,0x1f,0x18},
72169 + {    9,   4, 960, 463,1644, 438,  50,   0,  50,0xf4,0x0b,0x1c,0x0a},
72170 + {    9,   4, 848, 528,1270, 530,   0,   0,  50,0xf5,0xfb,0x1b,0x2a},  /* 640x480, 320x240 */
72171 + {   36,  25,1060, 648,1316, 530, 438,   0, 438,0xeb,0x05,0x25,0x16},  /* 800x600, 400x300 */
72172 + {    3,   2,1080, 619,1270, 540, 438,   0, 438,0xf3,0x00,0x1d,0x20},  /* 720x576 */
72173 + {    1,   1,1170, 821,1270, 520, 686,   0, 686,0xF3,0x00,0x1D,0x20}   /* 1024x768 */
72174 +};
72175 +
72176 +static const SiS_TVDataStruct  SiS_StNTSCData[]=
72177 +{
72178 + {    1,   1, 858, 525,1270, 400,  50,   0, 760,0xf1,0x04,0x1f,0x18},
72179 + {    1,   1, 858, 525,1270, 350,  50,   0, 640,0xf1,0x04,0x1f,0x18},
72180 + {    1,   1, 858, 525,1270, 400,   0,   0, 720,0xf1,0x04,0x1f,0x18},
72181 + {    1,   1, 858, 525,1270, 350,   0,   0, 720,0xf4,0x0b,0x1c,0x0a},
72182 + {    1,   1, 858, 525,1270, 480,   0,   0, 760,0xf1,0x04,0x1f,0x18}
72183 +};
72184 +
72185 +static const SiS_TVDataStruct  SiS_ExtNTSCData[]=
72186 +{
72187 + {  143,  65, 858, 443,1270, 440, 171,   0, 171,0xf1,0x04,0x1f,0x18},    /* 640x400, 320x200 */
72188 + {   88,  35, 858, 393,1270, 440, 171,   0, 171,0xf1,0x04,0x1f,0x18},
72189 + {  143,  70, 924, 443,1270, 440,  92,   0,  92,0xf1,0x04,0x1f,0x18},
72190 + {  143,  70, 924, 393,1270, 440,  92,   0,  92,0xf4,0x0b,0x1c,0x0a},
72191 + {  143,  76, 836, 523,1270, 440, 224,   0,   0,0xf1,0x05,0x1f,0x16},    /* 640x480, 320x240 */
72192 + {  143, 120,1056, 643,1270, 440,   0, 128,   0,0xf4,0x10,0x1c,0x00},    /* 800x600, 400x300  */
72193 + {  143,  76, 836, 523,1270, 440,   0, 128,   0,0xee,0x0c,0x22,0x08},    /* 720x480 - BETTER (from 300 series) */
72194 +/*{   2,   1, 858, 503,1270, 480,   0, 128,   0,0xee,0x0c,0x22,0x08},*/  /* 720x480  (old, from 650) */
72195 + {    1,   1,1100, 811,1412, 440,   0, 128,   0,0xee,0x0c,0x22,0x08}     /* 1024x768 CORRECTED */
72196 +/*{  65,  64,1056, 791,1270, 480, 638,   0,   0,0xEE,0x0C,0x22,0x08} */  /* 1024x768 */
72197 +#if 0  /* 300 series was: */
72198 + {  143,  65, 858, 443,1270, 440, 171,   0, 171,0xf1,0x04,0x1f,0x18},
72199 + {   88,  35, 858, 393,1270, 440, 171,   0, 171,0xf1,0x04,0x1f,0x18},
72200 + {  143,  70, 924, 443,1270, 440,  92,   0,  92,0xf1,0x04,0x1f,0x18},
72201 + {  143,  70, 924, 393,1270, 440,  92,   0,  92,0xf4,0x0b,0x1c,0x0a},
72202 + {  143,  76, 836, 523,1270, 440, 224,   0,   0,0xf1,0x05,0x1f,0x16},
72203 + {  143, 120,1056, 643,1270, 440,   0, 128,   0,0xf4,0x10,0x1c,0x00},
72204 + {  143,  76, 836, 523,1270, 440,   0, 128,   0,0xee,0x0c,0x22,0x08},
72205 + {   65,  64,1056, 791,1270, 480, 638,   0,   0,0xf1,0x04,0x1f,0x18}
72206 +#endif
72207 +};
72208 +
72209 +
72210 +static const SiS_TVDataStruct  SiS_St2HiTVData[]=
72211 +{
72212 + {    3,   1, 0x348,0x1e3,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},
72213 + {    1,   1, 0x37c,0x233,0x2b2,0x2bc,           0,  0, 0, 0x00,0x00,0x00,0x00},
72214 + {    3,   1, 0x348,0x1e3,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},
72215 + {    1,   1, 0x3e8,0x233,0x311,0x2bc,    0,  0, 0, 0x00,0x00,0x00,0x00},
72216 + {    5,   2, 0x348,0x233,0x670,0x3c0,0x08d,128, 0, 0x00,0x00,0x00,0x00},
72217 + {    8,   5, 0x41a,0x2ab,0x670,0x3c0,0x17c,128, 0, 0x00,0x00,0x00,0x00}
72218 +};
72219 +
72220 +static const SiS_TVDataStruct  SiS_ExtHiTVData[]=
72221 +{
72222 + {    6,   1, 0x348,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
72223 + {    3,   1, 0x3c0,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
72224 + {    3,   1, 0x348,0x1e3,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
72225 + {    3,   1, 0x3c0,0x233,0x660,0x3c0,    0,  0, 0, 0x00,0x00,0x00,0x00},
72226 + {    5,   1, 0x348,0x233,0x670,0x3c0,0x166,128, 0, 0x00,0x00,0x00,0x00},  /* 640x480   */
72227 + {   16,   5, 0x41a,0x2ab,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00},  /* 800x600   */
72228 + {   25,  12, 0x4ec,0x353,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},  /* 1024x768  */
72229 + {    5,   4, 0x627,0x464,0x670,0x3c0,0x128,  0, 0, 0x00,0x00,0x00,0x00},  /* 1280x1024 */
72230 + {    4,   1, 0x41a,0x233,0x670,0x3c0,0x143,128, 0, 0x00,0x00,0x00,0x00},  /* 800x480   */
72231 + {    5,   2, 0x578,0x293,0x670,0x3c0,0x032,  0, 0, 0x00,0x00,0x00,0x00},  /* 1024x576  */
72232 + {    8,   5, 0x6d6,0x323,0x670,0x3c0,0x128,  0, 0, 0x00,0x00,0x00,0x00}   /* 1280x720  */
72233 +};
72234 +
72235 +static const UCHAR SiS_OutputSelect = 0x40;
72236 +
72237 +static const UCHAR SiS_SoftSetting  = 0x30;   /* RAM setting */
72238 +
72239 +static const SiS_LCDDataStruct  SiS_LCD1280x960Data[] =
72240 +{
72241 +       {    9,   2, 800, 500,1800,1000},
72242 +       {    9,   2, 800, 500,1800,1000},
72243 +       {    4,   1, 900, 500,1800,1000},
72244 +       {    4,   1, 900, 500,1800,1000},
72245 +       {    9,   2, 800, 500,1800,1000},
72246 +       {   30,  11,1056, 625,1800,1000},
72247 +       {    5,   3,1350, 800,1800,1000},
72248 +       {    1,   1,1576,1050,1576,1050},
72249 +       {    1,   1,1800,1000,1800,1000}
72250 +};
72251 +
72252 +static const SiS_LCDDataStruct  SiS_StLCD1280x768Data[] =
72253 +{
72254 +       { 211,  100, 2100,  408, 1688,  802 }, /* These values are *wrong* */
72255 +       { 211,   64, 1536,  358, 1688,  802 }, /* (which is why they aren't used yet) */
72256 +       { 211,  100, 2100,  408, 1688,  802 },
72257 +       { 211,   64, 1536,  358, 1688,  802 },
72258 +       { 211,   48,  840,  488, 1688,  802 },
72259 +       { 211,   72, 1008,  609, 1688,  802 },
72260 +       { 211,  128, 1400,  776, 1688,  802 },
72261 +       { 211,  205, 1680, 1041, 1688,  802 },
72262 +       { 1,      1, 1688,  802, 1688,  802 }  /* That's the only one that *might* be correct */
72263 +};
72264 +
72265 +static const SiS_LCDDataStruct  SiS_ExtLCD1280x768Data[] =
72266 +{
72267 +       { 211,  100, 2100,  408, 1688,  802 }, /* These values are *wrong* */
72268 +       { 211,   64, 1536,  358, 1688,  802 }, /* (which is why they aren't used yet) */
72269 +       { 211,  100, 2100,  408, 1688,  802 },
72270 +       { 211,   64, 1536,  358, 1688,  802 },
72271 +       { 211,   48,  840,  488, 1688,  802 },
72272 +       { 211,   72, 1008,  609, 1688,  802 },
72273 +       { 211,  128, 1400,  776, 1688,  802 },
72274 +       { 211,  205, 1680, 1041, 1688,  802 },
72275 +       { 1,      1, 1688,  802, 1688,  802 }  /* That's the only one that *might* be correct */
72276 +};
72277 +
72278 +static const SiS_LCDDataStruct  SiS_NoScaleData1280x768[] =
72279 +{  /* All values guessed */
72280 +        { 1, 1, 1688,  802, 1688,  802},
72281 +       { 1, 1, 1688,  802, 1688,  802},
72282 +       { 1, 1, 1688,  802, 1688,  802},
72283 +       { 1, 1, 1688,  802, 1688,  802},
72284 +       { 1, 1, 1688,  802, 1688,  802},
72285 +       { 1, 1, 1688,  802, 1688,  802},
72286 +       { 1, 1, 1688,  802, 1688,  802},
72287 +       { 1, 1, 1688,  802, 1688,  802},
72288 +       { 1, 1, 1688,  802, 1688,  802}
72289 +};
72290 +
72291 +static const SiS_LCDDataStruct  SiS_StLCD1400x1050Data[] =
72292 +{
72293 +       { 211,  100, 2100,  408, 1688, 1066 },
72294 +       { 211,   64, 1536,  358, 1688, 1066 },
72295 +       { 211,  100, 2100,  408, 1688, 1066 },
72296 +       { 211,   64, 1536,  358, 1688, 1066 },
72297 +       { 211,   48,  840,  488, 1688, 1066 },
72298 +       { 211,   72, 1008,  609, 1688, 1066 },
72299 +       { 211,  128, 1400,  776, 1688, 1066 },
72300 +       { 211,  205, 1680, 1041, 1688, 1066 },
72301 +       {   1,    1, 1688, 1066, 1688, 1066 }
72302 +};
72303 +
72304 +static const SiS_LCDDataStruct  SiS_ExtLCD1400x1050Data[] =
72305 +{
72306 +       { 211,  100, 2100,  408, 1688, 1066 },
72307 +       { 211,   64, 1536,  358, 1688, 1066 },
72308 +       { 211,  100, 2100,  408, 1688, 1066 },
72309 +       { 211,   64, 1536,  358, 1688, 1066 },
72310 +       { 211,   48,  840,  488, 1688, 1066 },
72311 +       { 211,   72, 1008,  609, 1688, 1066 },
72312 +       { 211,  128, 1400,  776, 1688, 1066 },
72313 +       { 211,  205, 1680, 1041, 1688, 1066 },
72314 +       {   1,    1, 1688, 1066, 1688, 1066 }
72315 +};
72316 +
72317 +static const SiS_LCDDataStruct  SiS_NoScaleData1400x1050[] =
72318 +{
72319 +       { 1, 1, 1688, 1066, 1688, 1066 },
72320 +       { 1, 1, 1688, 1066, 1688, 1066 },
72321 +       { 1, 1, 1688, 1066, 1688, 1066 },
72322 +       { 1, 1, 1688, 1066, 1688, 1066 },
72323 +       { 1, 1, 1688, 1066, 1688, 1066 },
72324 +       { 1, 1, 1688, 1066, 1688, 1066 },
72325 +       { 1, 1, 1688, 1066, 1688, 1066 },
72326 +       { 1, 1, 1688, 1066, 1688, 1066 },
72327 +       { 1, 1, 1688, 1066, 1688, 1066 }
72328 +};
72329 +
72330 +static const SiS_LCDDataStruct  SiS_StLCD1600x1200Data[] =
72331 +{
72332 +       {27,  4, 800, 500, 2160, 1250 },
72333 +       {27,  4, 800, 500, 2160, 1250 },
72334 +       { 6,  1, 900, 500, 2160, 1250 },
72335 +       { 6,  1, 900, 500, 2160, 1250 },
72336 +       {27,  1, 800, 500, 2160, 1250 },
72337 +       { 4,  1,1080, 625, 2160, 1250 },
72338 +       { 5,  2,1350, 800, 2160, 1250 },
72339 +       {135,88,1600,1100, 2160, 1250 },
72340 +       {135,88,1600,1100, 2160, 1250 },
72341 +       { 1,  1,2160,1250, 2160, 1250 }
72342 +};
72343 +
72344 +static const SiS_LCDDataStruct  SiS_ExtLCD1600x1200Data[] =
72345 +{
72346 +       {27, 4, 800, 500, 2160, 1250 },
72347 +       {27, 4, 800, 500, 2160, 1250 },
72348 +       { 6, 1, 900, 500, 2160, 1250 },
72349 +       { 6, 1, 900, 500, 2160, 1250 },
72350 +       {27, 1, 800, 500, 2160, 1250 },
72351 +       { 4, 1,1080, 625, 2160, 1250 },
72352 +       { 5, 2,1350, 800, 2160, 1250 },
72353 +       {27,16,1500,1064, 2160, 1250 },
72354 +       {27,16,1500,1064, 2160, 1250 },
72355 +       { 1, 1,2160,1250, 2160, 1250 }
72356 +};
72357 +
72358 +static const SiS_LCDDataStruct  SiS_NoScaleData1600x1200[] =
72359 +{
72360 +        {1,  1, 2160, 1250, 2048, 1250},
72361 +       {1,  1, 2160, 1250, 2048, 1250},
72362 +       {1,  1, 2160, 1250, 2048, 1250},
72363 +       {1,  1, 2160, 1250, 2048, 1250},
72364 +       {1,  1, 2160, 1250, 2048, 1250},
72365 +       {1,  1, 2160, 1250, 2048, 1250},
72366 +       {1,  1, 2160, 1250, 2048, 1250},
72367 +       {1,  1, 2160, 1250, 2048, 1250},
72368 +       {1,  1, 2160, 1250, 2048, 1250},
72369 +       {1,  1, 2160, 1250, 2048, 1250},
72370 +};
72371 +
72372 +static const SiS_LCDDataStruct  SiS_NoScaleData[] =
72373 +{
72374 +       { 1, 1, 800, 449, 800, 449 },
72375 +       { 1, 1, 800, 449, 800, 449 },
72376 +       { 1, 1, 900, 449, 900, 449 },
72377 +       { 1, 1, 900, 449, 900, 449 },
72378 +       { 1, 1, 800, 525, 800, 525 },
72379 +       { 1, 1,1056, 628,1056, 628 },
72380 +       { 1, 1,1344, 806,1344, 806 },
72381 +       { 1, 1,1688,1066,1688,1066 },
72382 +        { 1, 1,1688, 802,1688, 802 },  /* 1280x768: 802 was 806 in both cases */
72383 +        { 1, 1,2160,1250,2160,1250 },  /* 1600x1200 */
72384 +       { 1, 1,1800,1000,1800,1000 }   /* 1280x960 */
72385 +};
72386 +
72387 +static const SiS_LVDSDataStruct  SiS_LVDS320x480Data_1[]=
72388 +{
72389 +       { 848, 433, 400, 525},
72390 +       { 848, 389, 400, 525},
72391 +       { 848, 433, 400, 525},
72392 +       { 848, 389, 400, 525},
72393 +       { 848, 518, 400, 525},
72394 +       {1056, 628, 400, 525},
72395 +       { 400, 525, 400, 525},
72396 +       { 800, 449,1000, 644},
72397 +       { 800, 525,1000, 635}
72398 +};
72399 +
72400 +static const SiS_LVDSDataStruct  SiS_LVDS800x600Data_1[]=
72401 +{
72402 +       { 848, 433,1060, 629},
72403 +       { 848, 389,1060, 629},
72404 +       { 848, 433,1060, 629},
72405 +       { 848, 389,1060, 629},
72406 +       { 848, 518,1060, 629},
72407 +       {1056, 628,1056, 628},
72408 +       {1056, 628,1056, 628},
72409 +       { 800, 449,1000, 644},
72410 +       { 800, 525,1000, 635}
72411 +};
72412 +
72413 +static const SiS_LVDSDataStruct  SiS_LVDS800x600Data_2[]=
72414 +{
72415 +       {1056, 628,1056, 628},
72416 +       {1056, 628,1056, 628},
72417 +       {1056, 628,1056, 628},
72418 +       {1056, 628,1056, 628},
72419 +       {1056, 628,1056, 628},
72420 +       {1056, 628,1056, 628},
72421 +       {1056, 628,1056, 628},
72422 +       { 800, 449,1000, 644},
72423 +       { 800, 525,1000, 635}
72424 +};
72425 +
72426 +
72427 +
72428 +static const SiS_LVDSDataStruct  SiS_LVDS1280x1024Data_1[]=
72429 +{
72430 +       {1048, 442,1688,1066},
72431 +       {1048, 392,1688,1066},
72432 +       {1048, 442,1688,1066},
72433 +       {1048, 392,1688,1066},
72434 +       {1048, 522,1688,1066},
72435 +       {1208, 642,1688,1066},
72436 +       {1432, 810,1688,1066},
72437 +       {1688,1066,1688,1066}
72438 +};
72439 +
72440 +static const SiS_LVDSDataStruct  SiS_LVDS1280x1024Data_2[]=
72441 +{
72442 +       {1688,1066,1688,1066},
72443 +       {1688,1066,1688,1066},
72444 +       {1688,1066,1688,1066},
72445 +       {1688,1066,1688,1066},
72446 +       {1688,1066,1688,1066},
72447 +       {1688,1066,1688,1066},
72448 +       {1688,1066,1688,1066},
72449 +       {1688,1066,1688,1066}
72450 +};
72451 +
72452 +static const SiS_LVDSDataStruct  SiS_LVDS1024x768Data_1[]=
72453 +{
72454 +       { 840, 438,1344, 806},
72455 +       { 840, 409,1344, 806},
72456 +       { 840, 438,1344, 806},
72457 +       { 840, 409,1344, 806},
72458 +       { 840, 518,1344, 806},   /* 640x480 */
72459 +       {1050, 638,1344, 806},   /* 800x600 */
72460 +       {1344, 806,1344, 806},   /* 1024x768 */
72461 +       { 800, 449,1280, 801},
72462 +       { 800, 525,1280, 813}
72463 +};
72464 +
72465 +static const SiS_LVDSDataStruct  SiS_LVDS1024x768Data_2[]=
72466 +{
72467 +       {1344, 806,1344, 806},
72468 +       {1344, 806,1344, 806},
72469 +       {1344, 806,1344, 806},
72470 +       {1344, 806,1344, 806},
72471 +       {1344, 806,1344, 806},
72472 +       {1344, 806,1344, 806},
72473 +       {1344, 806,1344, 806},
72474 +       { 800, 449,1280, 801},
72475 +       { 800, 525,1280, 813}
72476 +};
72477 +
72478 +/* Custom data for Barco iQ R300 */
72479 +static const SiS_LVDSDataStruct  SiS_LVDSBARCO1366Data_1[]=
72480 +{
72481 +       { 832, 438,1331, 806},
72482 +       { 832, 388,1331, 806},
72483 +       { 832, 438,1331, 806},
72484 +       { 832, 388,1331, 806},
72485 +       { 832, 518,1331, 806},
72486 +       {1050, 638,1344, 806},
72487 +       {1344, 806,1344, 806},
72488 +       {1688,1066,1688,1066},
72489 +       {1688,1066,1688,1066}   /* 1360x1024 */
72490 +};
72491 +
72492 +/* Custom data for Barco iQ R300 */
72493 +static const SiS_LVDSDataStruct  SiS_LVDSBARCO1366Data_2[]=
72494 +{
72495 +       {1344, 806,1344, 806},
72496 +       {1344, 806,1344, 806},
72497 +       {1344, 806,1344, 806},
72498 +       {1344, 806,1344, 806},
72499 +       {1344, 806,1344, 806},
72500 +       {1344, 806,1344, 806},
72501 +       {1344, 806,1344, 806},
72502 +       {1688,1066,1688,1066},
72503 +       {1688,1066,1688,1066}   /* 1360x1024 */
72504 +};
72505 +
72506 +static const SiS_LVDSDataStruct  SiS_LVDSBARCO1024Data_1[]=
72507 +{
72508 +       { 832, 438,1331, 806},
72509 +       { 832, 409,1331, 806},
72510 +       { 832, 438,1331, 806},
72511 +       { 832, 409,1331, 806},
72512 +       { 832, 518,1331, 806},   /* 640x480 */
72513 +       {1050, 638,1344, 806},   /* 800x600 */
72514 +       {1344, 806,1344, 806},   /* 1024x768 */
72515 +};
72516 +
72517 +static const SiS_LVDSDataStruct  SiS_LVDSBARCO1024Data_2[]=
72518 +{
72519 +       {1344, 806,1344, 806},
72520 +       {1344, 806,1344, 806},
72521 +       {1344, 806,1344, 806},
72522 +       {1344, 806,1344, 806},
72523 +       {1344, 806,1344, 806},
72524 +       {1344, 806,1344, 806},
72525 +       {1344, 806,1344, 806},
72526 +};
72527 +
72528 +static const SiS_LVDSDataStruct  SiS_LVDS1400x1050Data_1[]=
72529 +{
72530 +        { 928, 416, 1688,1066},
72531 +       { 928, 366, 1688,1066},
72532 +       { 928, 416, 1688,1066},
72533 +       { 928, 366, 1688,1066},
72534 +       { 928, 496, 1688,1066},
72535 +       {1088, 616, 1688,1066},
72536 +       {1312, 784, 1688,1066},
72537 +       {1568,1040, 1688,1066},
72538 +       {1688,1066, 1688,1066}
72539 +};
72540 +
72541 +static const SiS_LVDSDataStruct  SiS_LVDS1400x1050Data_2[]=
72542 +{
72543 +        {1688,1066, 1688,1066},
72544 +       {1688,1066, 1688,1066},
72545 +       {1688,1066, 1688,1066},
72546 +       {1688,1066, 1688,1066},
72547 +       {1688,1066, 1688,1066},
72548 +       {1688,1066, 1688,1066},
72549 +       {1688,1066, 1688,1066},
72550 +       {1688,1066, 1688,1066},
72551 +       {1688,1066, 1688,1066},
72552 +};
72553 +
72554 +static const SiS_LVDSDataStruct  SiS_LVDS1600x1200Data_1[]=
72555 +{
72556 +        {1088, 450, 2048,1250},
72557 +       {1088, 400, 2048,1250},
72558 +       {1088, 450, 2048,1250},
72559 +       {1088, 400, 2048,1250},
72560 +       {1088, 530, 2048,1250},
72561 +       {1248, 650, 2048,1250},
72562 +       {1472, 818, 2048,1250},
72563 +       {1728,1066, 2048,1250},
72564 +       {1848,1066, 2048,1250},
72565 +       {2048,1250, 2048,1250}
72566 +};
72567 +
72568 +static const SiS_LVDSDataStruct  SiS_LVDS1600x1200Data_2[]=
72569 +{
72570 +        {2048,1250, 2048,1250},
72571 +       {2048,1250, 2048,1250},
72572 +       {2048,1250, 2048,1250},
72573 +       {2048,1250, 2048,1250},
72574 +       {2048,1250, 2048,1250},
72575 +       {2048,1250, 2048,1250},
72576 +       {2048,1250, 2048,1250},
72577 +       {2048,1250, 2048,1250},
72578 +       {2048,1250, 2048,1250},
72579 +       {2048,1250, 2048,1250}
72580 +};
72581 +
72582 +static const SiS_LVDSDataStruct  SiS_LVDS1280x768Data_1[]=
72583 +{
72584 +       { 768, 438, 1408, 806},
72585 +       { 768, 388, 1408, 806},
72586 +       { 768, 438, 1408, 806},
72587 +       { 768, 388, 1408, 806},
72588 +       { 768, 518, 1408, 806},
72589 +       { 928, 638, 1408, 806},
72590 +       {1152, 806, 1408, 806},
72591 +       {1408, 806, 1408, 806},
72592 +       {1408, 806, 1408, 806}
72593 +};
72594 +
72595 +static const SiS_LVDSDataStruct  SiS_LVDS1280x768Data_2[]=
72596 +{
72597 +       {1408, 806, 1408, 806},
72598 +       {1408, 806, 1408, 806},
72599 +       {1408, 806, 1408, 806},
72600 +       {1408, 806, 1408, 806},
72601 +       {1408, 806, 1408, 806},
72602 +       {1408, 806, 1408, 806},
72603 +       {1408, 806, 1408, 806},
72604 +       {1408, 806, 1408, 806},
72605 +       {1408, 806, 1408, 806}
72606 +};
72607 +
72608 +static const SiS_LVDSDataStruct  SiS_LVDS1024x600Data_1[] =
72609 +{
72610 +       {840, 604,1344, 800},
72611 +       {840, 560,1344, 800},
72612 +       {840, 604,1344, 800},
72613 +       {840, 560,1344, 800},
72614 +       {840, 689,1344, 800},
72615 +       {1050, 800,1344, 800},
72616 +       {1344, 800,1344, 800},
72617 +       {800, 449,1280, 789},
72618 +       {800, 525,1280, 785}
72619 +};
72620 +
72621 +static const SiS_LVDSDataStruct  SiS_LVDS1024x600Data_2[] =
72622 +{
72623 +       {1344, 800,1344, 800},
72624 +       {1344, 800,1344, 800},
72625 +       {1344, 800,1344, 800},
72626 +       {1344, 800,1344, 800},
72627 +       {1344, 800,1344, 800},
72628 +       {1344, 800,1344, 800},
72629 +       {1344, 800,1344, 800},
72630 +       { 800, 449,1280, 801},
72631 +       { 800, 525,1280, 813}
72632 +};
72633 +
72634 +static const SiS_LVDSDataStruct  SiS_LVDS1152x768Data_1[] =
72635 +{
72636 +       { 840, 438,1344, 806},
72637 +       { 840, 409,1344, 806},
72638 +       { 840, 438,1344, 806},
72639 +       { 840, 409,1344, 806},
72640 +       { 840, 518,1344, 806},
72641 +       {1050, 638,1344, 806},
72642 +       {1344, 806,1344, 806},
72643 +       { 800, 449,1280, 801},
72644 +       { 800, 525,1280, 813}
72645 +};
72646 +
72647 +static const SiS_LVDSDataStruct  SiS_LVDS1152x768Data_2[] =
72648 +{
72649 +       {1344, 806,1344, 806},
72650 +       {1344, 806,1344, 806},
72651 +       {1344, 806,1344, 806},
72652 +       {1344, 806,1344, 806},
72653 +       {1344, 806,1344, 806},
72654 +       {1344, 806,1344, 806},
72655 +       {1344, 806,1344, 806},
72656 +       { 800, 449,1280, 801},
72657 +       { 800, 525,1280, 813}
72658 +};
72659 +
72660 +/* TW: Pass 1:1 data */
72661 +static const SiS_LVDSDataStruct  SiS_LVDSXXXxXXXData_1[]=
72662 +{
72663 +        { 800, 449,  800, 449},
72664 +       { 800, 449,  800, 449},
72665 +       { 900, 449,  900, 449},
72666 +       { 900, 449,  900, 449},
72667 +       { 800, 525,  800, 525},  /*  640x480   */
72668 +       {1056, 628, 1056, 628},  /*  800x600   */
72669 +       {1344, 806, 1344, 806},  /* 1024x768   */
72670 +       {1344,1066, 1344,1066},  /* 1280x1024  */  /* INSERTED ! */
72671 +       {1688, 806, 1688, 806},  /* 1280x768   */
72672 +       /* No other panels ! */
72673 +};
72674 +
72675 +static const SiS_LVDSDataStruct  SiS_LVDS640x480Data_1[]=
72676 +{
72677 +       { 800, 445, 800, 525},   /* 800, 449, 800, 449 */
72678 +       { 800, 395, 800, 525},
72679 +       { 800, 445, 800, 525},
72680 +       { 800, 395, 800, 525},
72681 +       { 800, 525, 800, 525},
72682 +       { 800, 525, 800, 525},   /* pseudo */
72683 +       { 800, 525, 800, 525}    /* pseudo */
72684 +};
72685 +
72686 +/* FSTN 320x240 */
72687 +static const SiS_LVDSDataStruct  SiS_LVDS640x480Data_2[]=
72688 +{
72689 +       { 800, 445, 800, 525},
72690 +       { 800, 395, 800, 525},
72691 +       { 800, 445, 800, 525},
72692 +       { 800, 395, 800, 525},
72693 +       { 800, 525, 800, 525},
72694 +        { 800, 525, 800, 525},   /* pseudo */
72695 +       { 800, 525, 800, 525}    /* pseudo */
72696 +};
72697 +
72698 +
72699 +static const SiS_LVDSDataStruct  SiS_LVDS1280x960Data_1[]=
72700 +{
72701 +       { 840, 438,1344, 806},
72702 +       { 840, 409,1344, 806},
72703 +       { 840, 438,1344, 806},
72704 +       { 840, 409,1344, 806},
72705 +       { 840, 518,1344, 806},
72706 +       {1050, 638,1344, 806},
72707 +       {1344, 806,1344, 806},
72708 +       { 800, 449,1280, 801},
72709 +       { 800, 525,1280, 813}
72710 +};
72711 +
72712 +static const SiS_LVDSDataStruct  SiS_LVDS1280x960Data_2[]=
72713 +{
72714 +       {1344, 806,1344, 806},
72715 +       {1344, 806,1344, 806},
72716 +       {1344, 806,1344, 806},
72717 +       {1344, 806,1344, 806},
72718 +       {1344, 806,1344, 806},
72719 +       {1344, 806,1344, 806},
72720 +       {1344, 806,1344, 806},
72721 +       { 800, 449,1280, 801},
72722 +       { 800, 525,1280, 813}
72723 +};
72724 +
72725 +static const SiS_LVDSDataStruct  SiS_LVDS848x480Data_1[]=
72726 +{
72727 +       {   0,   0,   0,   0},
72728 +       {   0,   0,   0,   0},
72729 +       {   0,   0,   0,   0},
72730 +       {   0,   0,   0,   0},
72731 +       {1088, 525,1088, 525},  /* 640x480 TODO */
72732 +       {1088, 525,1088, 525},  /* 800x600 TODO */
72733 +       {1088, 525,1088, 525},  /* 1024x768 TODO */
72734 +       {   0,   0,   0,   0},
72735 +       {   0,   0,   0,   0},
72736 +       {   0,   0,   0,   0},
72737 +       {   0,   0,   0,   0},
72738 +       {1088, 525,1088, 525},  /* 848x480 */
72739 +       {1088, 525,1088, 525}   /* 1360x768 TODO */
72740 +};
72741 +
72742 +static const SiS_LVDSDataStruct  SiS_LVDS848x480Data_2[]=
72743 +{
72744 +       {   0,   0,   0,   0},
72745 +       {   0,   0,   0,   0},
72746 +       {   0,   0,   0,   0},
72747 +       {   0,   0,   0,   0},
72748 +       {1088, 525,1088, 525},  /*  640x480 */
72749 +       {1088, 525,1088, 525},  /*  800x600 */
72750 +       {1088, 525,1088, 525},  /* 1024x768 */
72751 +       {   0,   0,   0,   0},
72752 +       {   0,   0,   0,   0},
72753 +       {   0,   0,   0,   0},
72754 +       {   0,   0,   0,   0},
72755 +       {1088, 525,1088, 525},  /* 848x480 */
72756 +       {1088, 525,1088, 525}   /* 1360x768 TODO */
72757 +};
72758 +
72759 +/* LCDA */
72760 +
72761 +static const SiS_LVDSDataStruct  SiS_LCDA1400x1050Data_1[]=
72762 +{      /* TW: Might be temporary (invalid) data */
72763 +        { 928, 416, 1688,1066},
72764 +       { 928, 366, 1688,1066},
72765 +       {1008, 416, 1688,1066},
72766 +       {1008, 366, 1688,1066},
72767 +       {1200, 530, 1688,1066},
72768 +       {1088, 616, 1688,1066},
72769 +       {1312, 784, 1688,1066},
72770 +       {1568,1040, 1688,1066},
72771 +       {1688,1066, 1688,1066}
72772 +};
72773 +
72774 +static const SiS_LVDSDataStruct  SiS_LCDA1400x1050Data_2[]=
72775 +{      /* TW: Temporary data. Not valid */
72776 +       {1344, 806,1344, 806},
72777 +       {1344, 806,1344, 806},
72778 +       {1344, 806,1344, 806},
72779 +       {1344, 806,1344, 806},
72780 +       {1344, 806,1344, 806},
72781 +       {1344, 806,1344, 806},
72782 +       {1344, 806,1344, 806},
72783 +       { 800, 449,1280, 801},
72784 +       { 800, 525,1280, 813}
72785 +};
72786 +
72787 +static const SiS_LVDSDataStruct  SiS_LCDA1600x1200Data_1[]=
72788 +{      /* TW: Temporary data. Not valid */
72789 +       {1344, 806,1344, 806},
72790 +       {1344, 806,1344, 806},
72791 +       {1344, 806,1344, 806},
72792 +       {1344, 806,1344, 806},
72793 +       {1344, 806,1344, 806},
72794 +       {1344, 806,1344, 806},
72795 +       {1344, 806,1344, 806},
72796 +       { 800, 449,1280, 801},
72797 +       { 800, 525,1280, 813}
72798 +};
72799 +
72800 +static const SiS_LVDSDataStruct  SiS_LCDA1600x1200Data_2[]=
72801 +{      /* TW: Temporary data. Not valid */
72802 +       {0, 0, 0, 0},
72803 +       {0, 0, 0, 0},
72804 +       {0, 0, 0, 0},
72805 +       {0, 0, 0, 0},
72806 +       {0, 0, 0, 0},
72807 +       {0, 0, 0, 0},
72808 +       {0, 0, 0, 0},
72809 +       {0, 0, 0, 0},
72810 +       {0, 0, 0, 0},
72811 +       {0, 0, 0, 0},
72812 +       {0, 0, 0, 0},
72813 +       {0, 0, 0, 0}
72814 +};
72815 +
72816 +static const SiS_LVDSDataStruct  SiS_CHTVUNTSCData[]=
72817 +{
72818 +       { 840, 600, 840, 600},
72819 +       { 840, 600, 840, 600},
72820 +       { 840, 600, 840, 600},
72821 +       { 840, 600, 840, 600},
72822 +       { 784, 600, 784, 600},
72823 +       {1064, 750,1064, 750},
72824 +        {1160, 945,1160, 945}
72825 +};
72826 +
72827 +static const SiS_LVDSDataStruct  SiS_CHTVONTSCData[]=
72828 +{
72829 +       { 840, 525, 840, 525},
72830 +       { 840, 525, 840, 525},
72831 +       { 840, 525, 840, 525},
72832 +       { 840, 525, 840, 525},
72833 +       { 784, 525, 784, 525},
72834 +       {1040, 700,1040, 700},
72835 +        {1160, 840,1160, 840}
72836 +};
72837 +
72838 +static const SiS_LVDSDesStruct SiS_PanelType1076_1[]=
72839 +{  /* 1024x768 */
72840 +       { 0 , 0},
72841 +       { 0 , 0},
72842 +       { 0 , 0},
72843 +       { 0 , 0},
72844 +       { 0 , 0},
72845 +       { 0 , 0},
72846 +       { 0 , 0},
72847 +       { 0 , 0},
72848 +       { 0 , 0}
72849 +};
72850 +
72851 +static const SiS_LVDSDesStruct SiS_PanelType1076_2[]=
72852 +{  /* 1024x768 */
72853 +       { 1184, 622 },
72854 +       { 1184, 597 },
72855 +       { 1184, 622 },
72856 +       { 1184, 597 },
72857 +       { 1152, 622 },
72858 +       { 1232, 722 },
72859 +       {    0, 0   },
72860 +       {    0, 794 },
72861 +       {    0, 0   }
72862 +};
72863 +
72864 +static const SiS_LVDSDesStruct SiS_PanelType1210_1[]=
72865 +{  /* 1280x1024 */
72866 +       { 0 , 0},
72867 +       { 0 , 0},
72868 +       { 0 , 0},
72869 +       { 0 , 0},
72870 +       { 0 , 0},
72871 +       { 0 , 0},
72872 +       { 0 , 0},
72873 +       { 0 , 0},
72874 +       { 0 , 0}
72875 +};
72876 +
72877 +static const SiS_LVDSDesStruct SiS_PanelType1210_2[]=
72878 +{  /* 1280x1024 */
72879 +       { 0 , 0},
72880 +       { 0 , 0},
72881 +       { 0 , 0},
72882 +       { 0 , 0},
72883 +       { 0 , 0},
72884 +       { 0 , 0},
72885 +       { 0 , 0},
72886 +       { 0 , 0},
72887 +       { 0 , 0}
72888 +};
72889 +
72890 +static const SiS_LVDSDesStruct SiS_PanelType1296_1[]=
72891 +{  /* 1400x1050 */
72892 +       { 0 , 0},
72893 +       { 0 , 0},
72894 +       { 0 , 0},
72895 +       { 0 , 0},
72896 +       { 0 , 0},
72897 +       { 0 , 0},
72898 +       { 0 , 0},
72899 +       { 0 , 0},
72900 +       { 0 , 0}
72901 +};
72902 +
72903 +static const SiS_LVDSDesStruct SiS_PanelType1296_2[]=
72904 +{  /* 1400x1050 - looks heavily invalid */
72905 +       { 808 , 740},
72906 +       { 0   , 715},
72907 +       { 632 , 740},
72908 +       { 632 , 715},
72909 +       { 1307, 780},
72910 +       { 1387,1157},
72911 +       { 1499, 924},
72912 +       { 1627,1052},
72913 +       { 0 , 0}
72914 +};
72915 +
72916 +static const SiS_LVDSDesStruct SiS_PanelType1600_1[]=
72917 +{  /* 1600x1200 */
72918 +       { 0 , 0},
72919 +       { 0 , 0},
72920 +       { 0 , 0},
72921 +       { 0 , 0},
72922 +       { 0 , 0},
72923 +       { 0 , 0},
72924 +       { 0 , 0},
72925 +       { 0 , 0},
72926 +       { 0 , 0},
72927 +       { 0 , 0}
72928 +};
72929 +
72930 +static const SiS_LVDSDesStruct SiS_PanelType1600_2[]=
72931 +{  /* 1600x1200 - BIOS looks heavily invalid, not copied */
72932 +       { 0 , 0},
72933 +       { 0 , 0},
72934 +       { 0 , 0},
72935 +       { 0 , 0},
72936 +       { 0 , 0},
72937 +       { 0 , 0},
72938 +       { 0 , 0},
72939 +       { 0 , 0},
72940 +       { 0 , 0},
72941 +       { 0 , 0}
72942 +};
72943 +
72944 +static const SiS_LVDSDesStruct  SiS_PanelTypeNS_1[]=
72945 +{
72946 +       { 8,   0},
72947 +       { 8,   0},
72948 +       { 8,   0},
72949 +       { 8,   0},
72950 +       { 8,   0},
72951 +       { 0,   0},
72952 +       { 0,   0},
72953 +       { 0,   0},
72954 +       { 0, 806},
72955 +       { 0, 0 }
72956 +};
72957 +
72958 +static const SiS_LVDSDesStruct  SiS_PanelTypeNS_2[] =
72959 +{
72960 +       { 0 , 0},
72961 +       { 0 , 0},
72962 +       { 0 , 0},
72963 +       { 0 , 0},
72964 +       { 0 , 0},
72965 +       { 0 , 0},
72966 +       { 0 , 0},
72967 +       { 0 , 0},
72968 +       { 0 , 0},
72969 +       { 0 , 0}
72970 +};
72971 +
72972 +static const SiS_LVDSDesStruct  SiS_CHTVUNTSCDesData[]=
72973 +{
72974 +       { 0,   0},
72975 +       { 0,   0},
72976 +       { 0,   0},
72977 +       { 0,   0},
72978 +       { 0,   0},
72979 +       { 0,   0},
72980 +       { 0,   0}
72981 +};
72982 +
72983 +static const SiS_LVDSDesStruct  SiS_CHTVONTSCDesData[]=
72984 +{
72985 +       { 0,   0},
72986 +       { 0,   0},
72987 +       { 0,   0},
72988 +       { 0,   0},
72989 +       { 0,   0},
72990 +       { 0,   0},
72991 +       { 0,   0}
72992 +};
72993 +
72994 +static const SiS_LVDSDesStruct  SiS_CHTVUPALDesData[]=
72995 +{
72996 +       {256,   0},
72997 +       {256,   0},
72998 +       {256,   0},
72999 +       {256,   0},
73000 +       { 0,   0},
73001 +       { 0,   0},
73002 +       { 0,   0}
73003 +};
73004 +
73005 +static const SiS_LVDSDesStruct  SiS_CHTVOPALDesData[]=
73006 +{
73007 +       {256,   0},
73008 +       {256,   0},
73009 +       {256,   0},
73010 +       {256,   0},
73011 +       { 0,   0},
73012 +       { 0,   0},
73013 +       { 0,   0}
73014 +};
73015 +
73016 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1320x480_1[] =
73017 +{
73018 + {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f,
73019 +   0x90,0x85,0x8f,0xab,0x30,0x00,0x05,
73020 +   0x00 }},
73021 + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
73022 +   0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
73023 +   0x00 }},
73024 + {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f,
73025 +   0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
73026 +   0x00 }},
73027 + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
73028 +   0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
73029 +   0x00 }},
73030 + {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e,
73031 +   0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05,
73032 +   0x00 }},
73033 + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
73034 +   0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
73035 +   0x01 }},
73036 + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
73037 +   0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
73038 +   0x00 }}
73039 +};
73040 +
73041 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11024x600_1[] =
73042 +{
73043 +        {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e,
73044 +         0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01,
73045 +         0x00}},
73046 +        {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e,
73047 +         0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01,
73048 +         0x00}},
73049 +        {{0x64,0x4f,0x88,0x54,0x9f,0x5a,0x3e,
73050 +         0xe8,0x8f,0x8f,0x5b,0x00,0x00,0x01,
73051 +         0x00}},
73052 +        {{0x64,0x4f,0x88,0x54,0x9f,0x2e,0x3e,
73053 +         0xb9,0x80,0x5d,0x2f,0x00,0x00,0x01,
73054 +         0x00}},
73055 +        {{0x64,0x4f,0x88,0x54,0x9f,0xaf,0xba,
73056 +         0x3b,0x82,0xdf,0xb0,0x00,0x00,0x01,
73057 +         0x00}},
73058 +        {{0x7e,0x63,0x82,0x68,0x15,0x1e,0xf1,
73059 +         0xae,0x85,0x57,0x1f,0x30,0x00,0x26,
73060 +         0x01}},
73061 +        {{0xa3,0x7f,0x87,0x86,0x97,0x1e,0xf1,
73062 +         0xae,0x85,0x57,0x1f,0x30,0x00,0x02,
73063 +         0x01}}
73064 +};
73065 +
73066 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11024x600_1_H[] =
73067 +{
73068 +        {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
73069 +         0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
73070 +         0x00}},
73071 +        {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
73072 +         0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
73073 +          0x00}},
73074 +        {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
73075 +         0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
73076 +         0x00}},
73077 +        {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
73078 +         0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
73079 +         0x00}},
73080 +        {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e,
73081 +         0xe2,0x89,0xdf,0x05,0x00,0x00,0x44,
73082 +         0x00}},
73083 +        {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0,
73084 +         0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55,
73085 +         0x01}},
73086 +        {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
73087 +         0x02,0x88,0xff,0x25,0x10,0x00,0x01,
73088 +         0x01}}
73089 +};
73090 +
73091 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11024x600_2[] =
73092 +{
73093 +        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
73094 +         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
73095 +         0x00}},
73096 +        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
73097 +         0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
73098 +         0x00}},
73099 +        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
73100 +         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
73101 +         0x00}},
73102 +        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
73103 +          0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
73104 +         0x00}},
73105 +        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
73106 +         0x72,0x88,0xdf,0x25,0x30,0x00,0x06,
73107 +         0x00}},
73108 +        {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1,
73109 +         0xae,0x84,0x57,0x25,0x30,0x00,0x02,
73110 +         0x01}},
73111 +        {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
73112 +         0x02,0x88,0xff,0x25,0x10,0x00,0x02,
73113 +         0x01}}
73114 +};
73115 +
73116 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11024x600_2_H[] =
73117 +{
73118 +        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
73119 +         0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
73120 +         0x00}},
73121 +        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
73122 +         0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
73123 +         0x00}},
73124 +        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
73125 +         0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
73126 +         0x00}},
73127 +        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
73128 +         0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
73129 +         0x00}},
73130 +        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
73131 +         0x72,0x88,0xdf,0x25,0x30,0x00,0x01,
73132 +         0x00}},
73133 +        {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1,
73134 +         0xae,0x84,0x57,0x25,0x30,0x00,0x01,
73135 +         0x01}},
73136 +        {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
73137 +         0x02,0x88,0xff,0x25,0x10,0x00,0x01,
73138 +         0x01}}
73139 +};
73140 +
73141 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11152x768_1[] =
73142 +{
73143 +        {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f,
73144 +         0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
73145 +         0x00}},
73146 +        {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f,
73147 +         0x60,0x87,0x5d,0x83,0x10,0x00,0x01,
73148 +         0x00}},
73149 +        {{0x64,0x4f,0x88,0x54,0x9f,0xc4,0x1f,
73150 +         0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
73151 +         0x00}},
73152 +        {{0x64,0x4f,0x88,0x54,0x9f,0x97,0x1f,
73153 +         0x60,0x87,0x5d,0x83,0x10,0x00,0x01,
73154 +         0x00}},
73155 +        {{0x64,0x4f,0x88,0x54,0x9f,0x04,0x3e,
73156 +         0xe2,0x89,0xdf,0x05,0x00,0x00,0x01,
73157 +         0x00}},
73158 +        {{0x7e,0x63,0x82,0x68,0x15,0x7c,0xf0,
73159 +         0x5a,0x8f,0x57,0x7d,0x20,0x00,0x26,
73160 +         0x01}},
73161 +        {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
73162 +         0x02,0x88,0xff,0x25,0x10,0x00,0x02,
73163 +         0x01}}
73164 +};
73165 +
73166 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11152x768_1_H[] =
73167 +{
73168 +        {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
73169 +         0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
73170 +         0x00}},
73171 +        {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
73172 +         0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
73173 +         0x00}},
73174 +        {{0x2f,0x27,0x93,0x2b,0x90,0xc4,0x1f,
73175 +         0x92,0x89,0x8f,0xb5,0x30,0x00,0x44,
73176 +         0x00}},
73177 +        {{0x2f,0x27,0x93,0x2b,0x90,0x97,0x1f,
73178 +         0x60,0x87,0x5d,0x83,0x10,0x00,0x44,
73179 +         0x00}},
73180 +        {{0x2f,0x27,0x93,0x2b,0x90,0x04,0x3e,
73181 +         0xe2,0x89,0xdf,0x05,0x00,0x00,0x44,
73182 +         0x00}},
73183 +        {{0x3c,0x31,0x80,0x35,0x1c,0x7c,0xf0,
73184 +         0x5a,0x8f,0x57,0x7d,0x20,0x00,0x55,
73185 +         0x01}},
73186 +        {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
73187 +         0x02,0x88,0xff,0x25,0x10,0x00,0x01,
73188 +         0x01}}
73189 +};
73190 +
73191 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11152x768_2[] =
73192 +{
73193 +        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
73194 +         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
73195 +         0x00}},
73196 +        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
73197 +         0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
73198 +         0x00}},
73199 +        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
73200 +         0x4a,0x80,0x8f,0x25,0x30,0x00,0x06,
73201 +         0x00}},
73202 +        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
73203 +         0x31,0x87,0x5d,0x25,0x30,0x00,0x06,
73204 +         0x00}},
73205 +        {{0xa3,0x4f,0x87,0x6e,0x9f,0x24,0xbb,
73206 +         0x72,0x88,0xdf,0x25,0x30,0x00,0x06,
73207 +         0x00}},
73208 +        {{0xa3,0x63,0x87,0x78,0x89,0x24,0xf1,
73209 +         0xae,0x84,0x57,0x25,0x30,0x00,0x02,
73210 +         0x01}},
73211 +        {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
73212 +         0x02,0x88,0xff,0x25,0x10,0x00,0x02,
73213 +         0x01}}
73214 +};
73215 +
73216 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11152x768_2_H[] =
73217 +{
73218 +        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
73219 +         0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
73220 +         0x00}},
73221 +        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
73222 +         0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
73223 +         0x00}},
73224 +        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
73225 +         0x4a,0x80,0x8f,0x25,0x30,0x00,0x01,
73226 +         0x00}},
73227 +        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
73228 +         0x31,0x87,0x5d,0x25,0x30,0x00,0x01,
73229 +         0x00}},
73230 +        {{0x4f,0x27,0x93,0x39,0x01,0x24,0xbb,
73231 +         0x72,0x88,0xdf,0x25,0x30,0x00,0x01,
73232 +         0x00}},
73233 +        {{0x4f,0x31,0x93,0x3e,0x06,0x24,0xf1,
73234 +         0xae,0x84,0x57,0x25,0x30,0x00,0x01,
73235 +         0x01}},
73236 +        {{0x4f,0x3f,0x93,0x45,0x0d,0x24,0xf5,
73237 +         0x02,0x88,0xff,0x25,0x10,0x00,0x01,
73238 +         0x01}}
73239 +};
73240 +
73241 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11280x768_1[] =
73242 +{
73243 + {{0x5b,0x4f,0x9f,0x55,0x19,0xb4,0x1f,
73244 +   0x9c,0x8e,0x8f,0xb5,0x10,0x00,0x01,
73245 +   0x00}},
73246 + {{0x5b,0x4f,0x9f,0x55,0x19,0x82,0x1f,
73247 +   0x6a,0x8c,0x5d,0x83,0x30,0x00,0x01,
73248 +   0x00}},
73249 + {{0x5b,0x4f,0x9f,0x55,0x19,0xb4,0x1f,
73250 +   0x9c,0x8e,0x8f,0xb5,0x10,0x00,0x01,
73251 +   0x00}},
73252 + {{0x5b,0x4f,0x9f,0x55,0x19,0x82,0x1f,
73253 +   0x6a,0x8c,0x5d,0x83,0x30,0x00,0x01,
73254 +   0x00}},
73255 + {{0x5b,0x4f,0x9f,0x55,0x19,0x04,0x3e,
73256 +   0xec,0x8e,0xdf,0x05,0x20,0x00,0x01,
73257 +   0x00}},
73258 + {{0x6f,0x63,0x93,0x69,0x8d,0x7c,0xf0,
73259 +   0x64,0x86,0x57,0x7d,0x20,0x00,0x05,
73260 +   0x01}},
73261 + {{0x8b,0x7f,0x8f,0x85,0x09,0x24,0xf5,
73262 +   0x0c,0x8e,0xff,0x25,0x30,0x00,0x02,
73263 +   0x01}},
73264 + {{0xab,0x9f,0x8f,0xa5,0x89,0x24,0xf5,
73265 +   0x0c,0x8e,0xff,0x25,0x30,0x00,0x06,
73266 +   0x01}},
73267 + {{0xab,0x9f,0x8f,0xa5,0x89,0x24,0xf5,
73268 +   0x0c,0x8e,0xff,0x25,0x30,0x00,0x06,
73269 +   0x01}}
73270 +};
73271 +
73272 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11280x768_1_H[] =
73273 +{
73274 + {{0x47,0x27,0x8b,0x2c,0x1a,0x9e,0x1f,
73275 +   0x93,0x86,0x8f,0x9f,0x30,0x00,0x05,
73276 +   0x00}},
73277 + {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f,
73278 +   0x60,0x84,0x5d,0x6d,0x10,0x00,0x05,
73279 +   0x00}},
73280 + {{0x47,0x27,0x8b,0x30,0x1e,0x9e,0x1f,
73281 +   0x92,0x86,0x8f,0x9f,0x30,0x00,0x05,
73282 +   0x00}},
73283 + {{0x47,0x27,0x8b,0x2c,0x1a,0x6c,0x1f,
73284 +   0x60,0x84,0x5d,0x6d,0x10,0x00,0x05,
73285 +   0x00}},
73286 + {{0x47,0x27,0x8b,0x2c,0x1a,0xee,0x1f,
73287 +   0xe2,0x86,0xdf,0xef,0x10,0x00,0x05,
73288 +   0x00}},
73289 + {{0x51,0x31,0x95,0x36,0x04,0x66,0xf0,
73290 +   0x5a,0x8e,0x57,0x67,0x20,0x00,0x01,
73291 +   0x01}},
73292 + {{0x5f,0x3f,0x83,0x44,0x92,0x0e,0xf5,
73293 +   0x02,0x86,0xff,0x0f,0x10,0x00,0x01,
73294 +   0x01}},
73295 + {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a,
73296 +   0x02,0x86,0xff,0x0f,0x09,0x00,0x05,
73297 +   0x01}},
73298 + {{0x6f,0x4f,0x93,0x54,0x82,0x0e,0x5a,
73299 +   0x02,0x86,0xff,0x0f,0x09,0x00,0x05,
73300 +   0x01}}
73301 +};
73302 +
73303 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11280x768_2[] =
73304 +{
73305 + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb,
73306 +   0x54,0x86,0xdb,0xda,0x00,0x00,0x02,
73307 +   0x00}},
73308 + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb,
73309 +   0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x02,
73310 +   0x00}},
73311 + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb,
73312 +   0x54,0x86,0xdb,0xda,0x00,0x00,0x02,
73313 +   0x00}},
73314 + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xbb,
73315 +   0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x02,
73316 +   0x00}},
73317 + {{0xab,0x60,0x9f,0x80,0x04,0x24,0xb3,
73318 +   0x7c,0x8e,0x03,0x02,0x10,0x00,0x02,
73319 +   0x01}},
73320 + {{0xab,0x63,0x8f,0x8a,0x8e,0x24,0xf1,
73321 +   0xb6,0x88,0x57,0x25,0x10,0x00,0x02,
73322 +   0x01}},
73323 + {{0xab,0x7f,0x8f,0x98,0x9c,0x24,0xf5,
73324 +   0x0a,0x8c,0xff,0x25,0x30,0x00,0x02,
73325 +   0x01}},
73326 + {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5,
73327 +   0x0a,0x8c,0xff,0x25,0x30,0x00,0x06,
73328 +   0x01}},
73329 + {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5,
73330 +   0x0a,0x8c,0xff,0x25,0x30,0x00,0x06,
73331 +   0x01}}
73332 +};
73333 +
73334 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT11280x768_2_H[] =
73335 +{
73336 + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb,
73337 +   0x54,0x86,0xdb,0xda,0x00,0x00,0x01,
73338 +   0x00}},
73339 + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb,
73340 +   0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x01,
73341 +   0x00}},
73342 + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb,
73343 +   0x54,0x86,0xdb,0xda,0x00,0x00,0x01,
73344 +   0x00}},
73345 + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xbb,
73346 +   0x3b,0x8d,0xc2,0xc1,0x00,0x00,0x01,
73347 +   0x00}},
73348 + {{0x83,0x38,0x97,0x58,0x9c,0x24,0xb3,
73349 +   0x7c,0x8e,0x03,0x02,0x10,0x00,0x01,
73350 +   0x01}},
73351 + {{0x79,0x31,0x9d,0x58,0x9c,0x24,0xf1,
73352 +   0xb6,0x88,0x57,0x25,0x10,0x00,0x01,
73353 +   0x01}},
73354 + {{0x6b,0x3f,0x8f,0x58,0x9c,0x24,0xf5,
73355 +   0x0a,0x8c,0xff,0x25,0x30,0x00,0x01,
73356 +   0x01}},
73357 + {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5,
73358 +   0x0a,0x8c,0xff,0x25,0x30,0x00,0x06,
73359 +   0x01}},
73360 + {{0xab,0x9f,0x8f,0xa8,0x8c,0x24,0xf5,
73361 +   0x0a,0x8c,0xff,0x25,0x30,0x00,0x06,
73362 +   0x01}}
73363 +};
73364 +
73365 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1XXXxXXX_1[] =
73366 +{
73367 + {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f,
73368 +   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05,
73369 +   0x00}},
73370 + {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f,
73371 +   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05,
73372 +   0x00}},
73373 + {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f,
73374 +   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05,
73375 +   0x00}},
73376 + {{0x5f,0x4f,0x82,0x55,0x81,0xbf,0x1f,
73377 +   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x05,
73378 +   0x00}},
73379 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73380 +   0xe9,0x8b,0xe7,0x04,0x00,0x00,0x05,
73381 +   0x00}},
73382 + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
73383 +   0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
73384 +   0x01}},
73385 + {{0xa3,0x7f,0x87,0x86,0x97,0x24,0xf5,
73386 +   0x02,0x88,0xff,0x25,0x10,0x00,0x02,
73387 +   0x01}},
73388 + {{0xce,0x9f,0x92,0xa8,0x14,0x28,0x5a,
73389 +   0x00,0x84,0xff,0x29,0x09,0x00,0x07,
73390 +   0x01}},
73391 + {{0xce,0x9f,0x92,0xa9,0x17,0x24,0xf5,
73392 +   0x02,0x88,0xff,0x25,0x10,0x00,0x07,
73393 +   0x01}}
73394 +};
73395 +
73396 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1XXXxXXX_1_H[] =
73397 +{
73398 + {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f,
73399 +   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00,
73400 +   0x00}},
73401 + {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f,
73402 +   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00,
73403 +   0x00}},
73404 + {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f,
73405 +   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00,
73406 +   0x00}},
73407 + {{0x38,0x27,0x9c,0x2c,0x80,0xbf,0x1f,
73408 +   0x9c,0x8e,0x96,0xb9,0x30,0x00,0x00,
73409 +   0x00}},
73410 + {{0x38,0x27,0x9c,0x2c,0x80,0x0b,0x3e,
73411 +   0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
73412 +   0x00}},
73413 + {{0x4d,0x31,0x91,0x3b,0x03,0x72,0xf0,
73414 +   0x58,0x8c,0x57,0x73,0x20,0x00,0x01,
73415 +   0x01}},
73416 + {{0x63,0x3f,0x87,0x4a,0x92,0x24,0xf5,
73417 +   0x02,0x88,0xff,0x25,0x10,0x00,0x01,
73418 +   0x01}}
73419 +};
73420 +
73421 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1640x480_1[] =
73422 +{
73423 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73424 +   0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
73425 +   0x00}},
73426 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73427 +   0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
73428 +   0x00}},
73429 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73430 +   0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
73431 +   0x00}},
73432 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73433 +   0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
73434 +   0x00}},
73435 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73436 +   0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
73437 +   0x00}},
73438 + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
73439 +   0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
73440 +   0x01}}
73441 +};
73442 +
73443 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1640x480_1_H[] =
73444 +{
73445 + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
73446 +   0x9c,0x8e,0x96,0xb9,0x00,0x00,0x00,
73447 +   0x00}},
73448 + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
73449 +   0x83,0x85,0x63,0xba,0x00,0x00,0x00,
73450 +   0x00}},
73451 + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
73452 +   0x9c,0x8e,0x96,0xb9,0x00,0x00,0x00,
73453 +   0x00}},
73454 + {{0x2d,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
73455 +   0x83,0x85,0x63,0xba,0x00,0x00,0x00,
73456 +   0x00}},
73457 + {{0x2d,0x28,0x90,0x2c,0x80,0x0b,0x3e,
73458 +   0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
73459 +   0x00}}
73460 +};
73461 +
73462 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1640x480_2[] =
73463 +{
73464 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73465 +   0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
73466 +   0x00}},
73467 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73468 +   0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
73469 +   0x00}},
73470 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73471 +   0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
73472 +   0x00}},
73473 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73474 +   0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
73475 +   0x00}},
73476 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73477 +   0xe9,0x8b,0xdf,0x04,0x30,0x00,0x05,
73478 +   0x00}},
73479 + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
73480 +   0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
73481 +   0x01}},
73482 + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
73483 +   0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
73484 +   0x00}}
73485 +};
73486 +
73487 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1640x480_2_H[] =
73488 +{
73489 + {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f,
73490 +   0x90,0x85,0x8f,0xab,0x30,0x00,0x05,
73491 +   0x00}},
73492 + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
73493 +   0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
73494 +   0x00}},
73495 + {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f,
73496 +   0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
73497 +   0x00}},
73498 + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
73499 +   0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
73500 +   0x00}},
73501 + {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e,
73502 +   0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05,
73503 +   0x00}},
73504 + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
73505 +   0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
73506 +   0x01}},
73507 + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
73508 +   0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
73509 +   0x00}}
73510 +};
73511 +
73512 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1640x480_3[] =
73513 +{
73514 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73515 +   0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
73516 +   0x00}},
73517 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73518 +   0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
73519 +   0x00}},
73520 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73521 +   0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
73522 +   0x00}},
73523 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73524 +   0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
73525 +   0x00}},
73526 + {{0x5f,0x4f,0x82,0x55,0x81,0x0b,0x3e,
73527 +   0xe9,0x8b,0xdf,0x04,0x00,0x00,0x05,
73528 +   0x00}},
73529 + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
73530 +   0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
73531 +   0x01}},
73532 + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
73533 +   0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
73534 +   0x00}}
73535 +};
73536 +
73537 +static const SiS_LVDSCRT1DataStruct  SiS_LVDSCRT1640x480_3_H[] =
73538 +{
73539 + {{0x65,0x4f,0x89,0x56,0x83,0xaa,0x1f,
73540 +   0x90,0x85,0x8f,0xab,0x30,0x00,0x05,
73541 +   0x00}},
73542 + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
73543 +   0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
73544 +   0x00}},
73545 + {{0x65,0x4f,0x89,0x54,0x9f,0xc4,0x1f,
73546 +   0x92,0x89,0x8f,0xb5,0x30,0x00,0x01,
73547 +   0x00}},
73548 + {{0x65,0x4f,0x89,0x56,0x83,0x83,0x1f,
73549 +   0x5e,0x83,0x5d,0x79,0x10,0x00,0x05,
73550 +   0x00}},
73551 + {{0x65,0x4f,0x89,0x56,0x83,0x04,0x3e,
73552 +   0xe0,0x85,0xdf,0xfb,0x10,0x00,0x05,
73553 +   0x00}},
73554 + {{0x7f,0x63,0x83,0x6c,0x1c,0x72,0xf0,
73555 +   0x58,0x8c,0x57,0x73,0x20,0x00,0x06,
73556 +   0x01}},
73557 + {{0x2d,0x27,0x90,0x2c,0x80,0x0b,0x3e,
73558 +   0xe9,0x8b,0xe7,0x04,0x00,0x00,0x00,
73559 +   0x00}}
73560 +};
73561 +
73562 +#define SIS_PL_HSYNCP 0x01
73563 +#define SIS_PL_HSYNCN 0x02
73564 +#define SIS_PL_VSYNCP 0x04
73565 +#define SIS_PL_VSYNCN 0x08
73566 +#define SIS_PL_DVI    0x80
73567 +
73568 +typedef struct _SiS_PlasmaModes
73569 +{
73570 +  const char *name;
73571 +  ULONG  clock;
73572 +  USHORT HDisplay, HTotal, HFrontPorch, HSyncWidth;
73573 +  USHORT VDisplay, VTotal, VFrontPorch, VSyncWidth;
73574 +  UCHAR  SyncFlags;
73575 +} SiS_PlasmaModes;
73576 +
73577 +
73578 +typedef struct _SiS_PlasmaTables
73579 +{
73580 +   USHORT vendor;
73581 +   UCHAR  productnum;
73582 +   USHORT product[5];
73583 +   const char *plasmaname;
73584 +   UCHAR  modenum;
73585 +   UCHAR  plasmamodes[20];  /* | 0x80 = DVI-capable, | 0x40 = analog */
73586 +} SiS_PlasmaTables;
73587 +
73588 +static const SiS_PlasmaModes SiS_PlasmaMode[] = {
73589 +   {  "640x400",               /* 00: IBM 400@70 */
73590 +      25175,
73591 +       640,  800, 17,  64,
73592 +       400,  449, 13,   2,
73593 +      SIS_PL_HSYNCN | SIS_PL_VSYNCN },
73594 +   {  "640x480",               /* 01: VESA 480@72 */
73595 +      31500,
73596 +       640,  832, 24,  40,
73597 +       480,  520,  9,   3,
73598 +      SIS_PL_HSYNCN | SIS_PL_VSYNCN },
73599 +   {  "800x600",               /* 02: VESA 600@72 */
73600 +      50000,
73601 +       800, 1040, 56, 120,
73602 +       600,  666, 37,   6,
73603 +      SIS_PL_HSYNCP | SIS_PL_VSYNCP },
73604 +   {  "864x480",               /* 03: Cereb wide 1 */
73605 +      42526,
73606 +       864, 1134, 22,  86,
73607 +       480,  500,  1,   3,
73608 +      SIS_PL_HSYNCP | SIS_PL_VSYNCN },
73609 +   {  "848x480",               /* 04: VESA wide (NEC1) */
73610 +      33750,
73611 +       848, 1088, 16, 112,
73612 +       480,  517,  6,   8,
73613 +      SIS_PL_HSYNCP | SIS_PL_VSYNCP },
73614 +   {  "1024x576",              /* 05: VESA wide (NEC2) */
73615 +      47250,
73616 +      1024, 1320, 16, 144,
73617 +       576,  596,  2,   4,
73618 +      SIS_PL_HSYNCP | SIS_PL_VSYNCP },
73619 +   {  "1280x720",              /* 06: VESA wide (NEC3) */
73620 +      76500,
73621 +      1280, 1696, 48, 176,
73622 +       720,  750,  4,   8,
73623 +      SIS_PL_HSYNCP | SIS_PL_VSYNCP },
73624 +   {  "1360x765",              /* 07: VESA wide (NEC4) */
73625 +      85500,
73626 +      1360, 1792, 64, 176,
73627 +       765,  795,  4,   8,
73628 +      SIS_PL_HSYNCP | SIS_PL_VSYNCP },
73629 +   {  "1024x600",              /* 08: CEREB wide 2 */
73630 +      51200,
73631 +      1024, 1352, 51, 164,
73632 +       600,  628,  1,   4,
73633 +      SIS_PL_HSYNCN | SIS_PL_VSYNCP },
73634 +   {  "1024x768",              /* 09: VESA 768@75 */
73635 +      78750,
73636 +      1024, 1312,  16, 96,
73637 +       768,  800,   1,  3,
73638 +      SIS_PL_HSYNCP | SIS_PL_VSYNCP },
73639 +   {  "1152x864",              /* 10: VESA 1152x864@75 */
73640 +      108000,
73641 +      1152, 1600, 64, 128,
73642 +       864,  900,  1,   3,
73643 +      SIS_PL_HSYNCP | SIS_PL_VSYNCP },
73644 +   {  "1280x1024",             /* 11: VESA 1024@60 */
73645 +      108000,
73646 +      1280, 1688, 48, 112,
73647 +      1024, 1066,  1,   3,
73648 +      SIS_PL_HSYNCP | SIS_PL_VSYNCP },
73649 +   {  "1280x768",              /* 12: W_XGA */
73650 +      81000,
73651 +      1280, 1688, 48, 112,
73652 +       768,  802,  3,   6,
73653 +      SIS_PL_HSYNCP | SIS_PL_VSYNCN },
73654 +   {  "1280x768",              /* 13: I/O Data W_XGA@56Hz */
73655 +      76064,
73656 +      1280, 1688, 48, 112,
73657 +       768,  802,  2,   3,
73658 +      SIS_PL_HSYNCP | SIS_PL_VSYNCP },
73659 +   {  "1376x768",              /* 14: I/O Wide XGA */
73660 +      87340,
73661 +      1376, 1808, 32, 128,
73662 +       768,  806,  3,   6,
73663 +      SIS_PL_HSYNCN | SIS_PL_VSYNCP },
73664 +   {  "1280x960",              /* 15: VESA 960@60 */
73665 +      108000,
73666 +      1280, 1800, 96, 112,
73667 +       960, 1000,  1,   3,
73668 +      SIS_PL_HSYNCP | SIS_PL_VSYNCP },
73669 +   {  "1400x1050",             /* 16: VESA 1050@60Hz */
73670 +      108000,
73671 +      1400, 1688, 48, 112,
73672 +      1050, 1066,  1,   3,
73673 +      SIS_PL_HSYNCN | SIS_PL_VSYNCN },
73674 +   {  "1360x768",              /* 17: VESA wide (NEC4/2) */
73675 +      85500,
73676 +      1360, 1792, 64, 112,
73677 +       765,  795,  3,   6,
73678 +      SIS_PL_HSYNCP | SIS_PL_VSYNCP },
73679 +   {  "800x600",               /* 18: VESA 600@56 */
73680 +      36000,
73681 +       800, 1024, 24,   2,
73682 +       600,  625,  1,   2,
73683 +      SIS_PL_HSYNCP | SIS_PL_VSYNCP }
73684 +};
73685 +
73686 +static const SiS_PlasmaTables SiS_PlasmaTable[] = {
73687 +#if 0  /* Product IDs missing */
73688 +   { 0x38a3, 4,
73689 +     { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
73690 +     "NEC PlasmaSync 42VP4/42VP4D/42VP4G/42VP4DG",
73691 +     14,   /* All DVI, except 0, 7, 13; 3, 15, 16 unknown */
73692 +     { 0|0x40, 1|0xc0, 2|0xc0, 3|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,12|0xc0,
73693 +      13|0x40,14|0xc0,15|0xc0,16|0xc0, 0     , 0     , 0     , 0     , 0     , 0 }
73694 +   },
73695 +   { 0x38a3, 3,
73696 +     { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
73697 +     "NEC PlasmaSync 42PD1/50PD1/50PD2",
73698 +     5,   /* DVI entirely unknown */
73699 +     { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0, 0     , 0     , 0     , 0     , 0     ,
73700 +       0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
73701 +   },
73702 +   { 0x38a3, 1,
73703 +     { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
73704 +     "NEC PlasmaSync 42PD3",
73705 +     10,   /* DVI entirely unknown */
73706 +     { 0|0x40, 1|0xc0, 2|0xc0, 3|0xc0, 4|0xc0, 5|0xc0, 6|0xc0, 7|0x40, 8|0xc0, 9|0xc0,
73707 +       0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
73708 +   },
73709 +   { 0x38a3, 2,
73710 +     { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
73711 +     "NEC PlasmaSync 42VM3/61XM1",
73712 +     11,  /* DVI entirely unknown */
73713 +     { 0|0x40, 1|0xc0, 2|0xc0, 3|0xc0, 4|0xc0, 5|0xc0, 6|0xc0, 8|0xc0, 9|0xc0,11|0xc0,
73714 +      17|0xc0, 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
73715 +   },
73716 +   { 0x38a3, 2,
73717 +     { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
73718 +     "NEC PlasmaSync 42MP1/42MP2",
73719 +     6,   /* DVI entirely unknown */
73720 +     { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0,11|0xc0, 0     , 0     , 0     , 0     ,
73721 +       0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
73722 +   },
73723 +   { 0x38a3, 1,
73724 +     { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
73725 +     "NEC PlasmaSync 50MP1",
73726 +     10,   /* DVI entirely unknown */
73727 +     { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,13|0x40,14|0xc0,
73728 +       0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
73729 +   },
73730 +#endif
73731 +   { 0x38a3, 4,
73732 +     { 0xa482, 0xa483, 0x0000, 0x0000, 0x0000 },
73733 +     "NEC PlasmaSync 42MP3/42MP4/50MP2/61MP1",
73734 +     11,   /* All DVI except 0, 7, 13, 17 */
73735 +     { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,10|0xc0,11|0xc0,13|0x40,14|0xc0,
73736 +      17|0x40, 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
73737 +   },
73738 +#if 0  /* Product IDs missing */
73739 +   { 0x38a3, 1,
73740 +     { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
73741 +     "NEC PlasmaSync 3300W",
73742 +     3,
73743 +     { 0|0x40, 1|0xc0,18|0xc0, 0     , 0     , 0     , 0     , 0     , 0     , 0     ,
73744 +       0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
73745 +   },
73746 +   { 0x38a3, 1,
73747 +     { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
73748 +     "NEC PlasmaSync 4200W",
73749 +     4,   /* DVI entirely unknown */
73750 +     { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 0     , 0     , 0     , 0     , 0     , 0     ,
73751 +       0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
73752 +   },
73753 +   { 0x38a3, 1,
73754 +     { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
73755 +     "NEC PlasmaSync 4210W",
73756 +     6,   /* DVI entirely unknown */
73757 +     { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 9|0xc0,11|0xc0, 0     , 0     , 0     , 0     ,
73758 +       0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
73759 +   },
73760 +   { 0x38a3, 1,
73761 +     { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 },
73762 +     "NEC PlasmaSync 5000W",
73763 +     7,   /* DVI entirely unknown */
73764 +     { 0|0x40, 1|0xc0, 2|0xc0, 4|0xc0, 7|0x40, 9|0xc0,11|0xc0, 0     , 0     , 0     ,
73765 +       0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
73766 +   },
73767 +#endif
73768 +   { 0x412f, 2,
73769 +     { 0x000c, 0x000b, 0x0000, 0x0000, 0x0000 },
73770 +     "Pioneer 503CMX/PDA-5002",
73771 +     6,   /* DVI unknown */
73772 +     { 1|0xc0, 2|0xc0, 9|0xc0,11|0xc0,12|0xc0,15|0xc0, 0     , 0     , 0     , 0     ,
73773 +       0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
73774 +   },
73775 +   { 0x34a9, 1,
73776 +     { 0xa00e, 0x0000, 0x0000, 0x0000, 0x0000 },
73777 +     "Panasonic TH-42",
73778 +     5,   /* No DVI output */
73779 +     { 1|0x40, 2|0x40, 4|0x40, 9|0x40,15|0x40, 0     , 0     , 0     , 0     , 0     ,
73780 +       0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0     , 0       }
73781 +   },
73782 +   { 0x0000 }
73783 +};
73784 +
73785  void     SiS_SetReg1(USHORT, USHORT, USHORT);
73786  void     SiS_SetReg2(SiS_Private *, USHORT, USHORT, USHORT);
73787  void     SiS_SetReg3(USHORT, USHORT);
73788 @@ -158,6 +2397,7 @@ void     SiS_SetMemoryClock(SiS_Private 
73789  void     SiS_SetDRAMModeRegister(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension);
73790  BOOLEAN  SiS_SearchVBModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo);
73791  void     SiS_IsLowResolution(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex);
73792 +void     SiS_GetSysFlags(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension);
73793  
73794  #ifdef SIS300
73795  void     SiS_SetDRAMSize_300(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension);
73796 @@ -192,12 +2432,15 @@ void     SiS_VerifyMclk(SiS_Private *SiS
73797  
73798  void     SiS_HandleCRT1(SiS_Private *SiS_Pr);
73799  void     SiS_Handle301B_1400x1050(SiS_Private *SiS_Pr, USHORT ModeNo);
73800 -void     SiS_SetEnableDstn(SiS_Private *SiS_Pr);
73801 +void     SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable);
73802 +void     SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable);
73803  void     SiS_Delay15us(SiS_Private *SiS_Pr);
73804  BOOLEAN  SiS_SearchModeID(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT *ModeNo,USHORT *ModeIdIndex);
73805  BOOLEAN  SiS_CheckMemorySize(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension,
73806                               USHORT ModeNo,USHORT ModeIdIndex);
73807  UCHAR    SiS_GetModePtr(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex);
73808 +void     SiS_WhatTheHellIsThis(SiS_Private *SiS_Pr,PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr);
73809 +void     SiS_StrangeStuff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension);
73810  void     SiS_SetSeqRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex);
73811  void     SiS_SetMiscRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT StandTableIndex);
73812  void     SiS_SetCRTCRegs(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension,
73813 @@ -267,26 +2510,26 @@ void     SiS_SetPitchCRT1(SiS_Private *S
73814  void           SiS_SetPitchCRT2(SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, UShort BaseAddr);
73815  extern int      SiS_compute_vclk(int Clock, int *out_n, int *out_dn, int *out_div,
73816                                     int *out_sbit, int *out_scale);
73817 +extern void    SiSCalcClock(ScrnInfoPtr pScrn, int clock, int max_VLD, unsigned int *vclk);
73818 +
73819  extern unsigned char SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, USHORT offset, unsigned char value);
73820  extern unsigned char SiS_GetSetModeID(ScrnInfoPtr pScrn, unsigned char id);
73821 -extern USHORT       SiS_CalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode);
73822 +extern USHORT       SiS_CalcModeIndex(ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN hcm);
73823  #endif
73824  
73825  extern USHORT    SiS_GetOffset(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex,
73826                         USHORT RefreshRateTableIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension);
73827  extern USHORT    SiS_GetColorDepth(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,USHORT ModeIdIndex);
73828  extern void      SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT BaseAddr);
73829 -extern BOOLEAN   SiS_SetCRT2Group301(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
73830 -                                     PSIS_HW_DEVICE_INFO HwDeviceExtension);
73831 -extern void      SiS_PresetScratchregister(SiS_Private *SiS_Pr, USHORT SiS_P3d4,
73832 -                                           PSIS_HW_DEVICE_INFO HwDeviceExtension);
73833 +extern BOOLEAN   SiS_SetCRT2Group(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
73834 +                                  PSIS_HW_DEVICE_INFO HwDeviceExtension);
73835  extern void      SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr);
73836  extern void      SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT BaseAddr);
73837  extern BOOLEAN   SiS_BridgeIsOn(SiS_Private *SiS_Pr, USHORT BaseAddr);
73838  extern BOOLEAN   SiS_BridgeIsEnable(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO );
73839  extern void      SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT BaseAddr,UCHAR *ROMAddr,USHORT ModeNo,
73840                                 USHORT ModeIdIndex,PSIS_HW_DEVICE_INFO HwDeviceExtension, int chkcrt2mode);
73841 -extern BOOLEAN   SiS_GetLCDResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,
73842 +extern void      SiS_GetLCDResInfo(SiS_Private *SiS_Pr, UCHAR *ROMAddr,USHORT ModeNo,
73843                                     USHORT ModeIdIndex, PSIS_HW_DEVICE_INFO HwDeviceExtension);
73844  extern void      SiS_SetHiVision(SiS_Private *SiS_Pr, USHORT BaseAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension);
73845  extern USHORT    SiS_GetRatePtrCRT2(SiS_Private *SiS_Pr, UCHAR *ROMAddr, USHORT ModeNo,USHORT ModeIdIndex,
73846 @@ -321,10 +2564,12 @@ int    sisfb_mode_rate_to_dclock(SiS_Pri
73847                               unsigned char modeno, unsigned char rateindex);
73848  int    sisfb_mode_rate_to_ddata(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
73849                          unsigned char modeno, unsigned char rateindex,
73850 -                        ULONG *left_margin, ULONG *right_margin, 
73851 +                        ULONG *left_margin, ULONG *right_margin,
73852                          ULONG *upper_margin, ULONG *lower_margin,
73853                          ULONG *hsync_len, ULONG *vsync_len,
73854                          ULONG *sync, ULONG *vmode);
73855 +BOOLEAN sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
73856 +                      unsigned char modeno, int *htotal, int *vtotal, unsigned char rateindex);
73857  #endif
73858  
73859  #endif
73860 --- linux-2.6.0-test6/drivers/video/sis/oem300.h        2003-06-14 12:18:05.000000000 -0700
73861 +++ 25/drivers/video/sis/oem300.h       2003-10-05 00:34:22.000000000 -0700
73862 @@ -1,5 +1,37 @@
73863 -
73864 -/* OEM Data for 300 series */
73865 +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/oem300.h.c,v 1.0 2001/11/30 12:12:01 eich Exp $ */
73866 +/*
73867 + * OEM Data for 300 series
73868 + *
73869 + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
73870 + *
73871 + * If distributed as part of the linux kernel, the contents of this file
73872 + * is entirely covered by the GPL.
73873 + *
73874 + * Otherwise, the following terms apply:
73875 + *
73876 + * Permission to use, copy, modify, distribute, and sell this software and its
73877 + * documentation for any purpose is hereby granted without fee, provided that
73878 + * the above copyright notice appear in all copies and that both that
73879 + * copyright notice and this permission notice appear in supporting
73880 + * documentation, and that the name of the copyright holder not be used in
73881 + * advertising or publicity pertaining to distribution of the software without
73882 + * specific, written prior permission.  The copyright holder makes no representations
73883 + * about the suitability of this software for any purpose.  It is provided
73884 + * "as is" without express or implied warranty.
73885 + *
73886 + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
73887 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
73888 + * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
73889 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
73890 + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
73891 + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
73892 + * PERFORMANCE OF THIS SOFTWARE.
73893 + *
73894 + * Author:     Thomas Winischhofer <thomas@winischhofer.net>
73895 + *
73896 + * Based on code by Silicon Intergrated Systems
73897 + *
73898 + */
73899  
73900  const UCHAR SiS300_OEMTVDelay301[8][4] =
73901  {
73902 @@ -680,325 +712,147 @@ const UCHAR SiS300_Filter2[10][9][7] =
73903      }
73904  };
73905  
73906 -const UCHAR SiS300_LCDHData[24][11][5] = {
73907 +/* Custom data for Barco iQ Pro R300 */
73908 +const UCHAR barco_p1[2][9][7][3] = {
73909      {
73910 -        {0x67,0x91,0x84,0x5e,0x00},
73911 -       {0x67,0x91,0x84,0x5e,0x00},
73912 -       {0x67,0x91,0x84,0x5e,0x00},
73913 -       {0x67,0x91,0x84,0x5e,0x00},
73914 -       {0x67,0x91,0x84,0x5e,0x00},
73915 -       {0x67,0x91,0x84,0x5e,0x00},
73916 -       {0x67,0x91,0x84,0x5e,0x00},
73917 -       {0x65,0xef,0x83,0x5c,0x00},
73918 -       {0x65,0xef,0x83,0x5c,0x00},
73919 -       {0x8a,0x14,0x00,0x80,0x00},
73920 -       {0x8a,0x14,0x00,0x80,0x00}
73921 -    },
73922 -    {
73923 -        {0x4e,0x18,0x90,0x38,0x00},
73924 -       {0x4e,0x18,0x90,0x38,0x00},
73925 -       {0x8e,0x18,0x28,0x78,0x00},
73926 -       {0x8e,0x18,0x28,0x78,0x00},
73927 -       {0x8e,0x18,0x28,0x78,0x00},
73928 -       {0x4e,0x18,0x90,0x38,0x00},
73929 -       {0x4e,0x18,0x90,0x38,0x00},
73930 -       {0x67,0x11,0x9a,0x56,0x00},
73931 -        {0x67,0x11,0x9a,0x56,0x00},
73932 -       {0x8a,0x14,0x00,0x80,0x00},
73933 -       {0x8a,0x14,0x00,0x80,0x00}
73934 -    },
73935 -    {
73936 -        {0x67,0x91,0x84,0x5e,0x00},
73937 -       {0x67,0x91,0x84,0x5e,0x00},
73938 -       {0x67,0x91,0x84,0x5e,0x00},
73939 -       {0x67,0x91,0x84,0x5e,0x00},
73940 -       {0x67,0x91,0x84,0x5e,0x00},
73941 -       {0x67,0x91,0x84,0x5e,0x00},
73942 -       {0x67,0x91,0x84,0x5e,0x00},
73943 -       {0x65,0xef,0x83,0x5c,0x00},
73944 -       {0x65,0xef,0x83,0x5c,0x00},
73945 -       {0x8a,0x14,0x00,0x80,0x00},
73946 -       {0x8a,0x14,0x00,0x80,0x00}
73947 -    },
73948 -    {
73949 -       {0x4e,0x18,0x90,0x38,0x00},
73950 -       {0x4e,0x18,0x90,0x38,0x00},
73951 -       {0x8e,0x18,0x28,0x78,0x00},
73952 -       {0x8e,0x18,0x28,0x78,0x00},
73953 -       {0x8e,0x18,0x28,0x78,0x00},
73954 -       {0x4e,0x18,0x90,0x38,0x00},
73955 -       {0x4e,0x18,0x90,0x38,0x00},
73956 -       {0x67,0x11,0x9a,0x56,0x00},
73957 -       {0x67,0x11,0x9a,0x56,0x00},
73958 -       {0x8a,0x14,0x00,0x80,0x00},
73959 -       {0x8a,0x14,0x00,0x80,0x00}
73960 -    },
73961 -    {
73962 -       {0x67,0x91,0x84,0x5e,0x00},
73963 -       {0x67,0x91,0x84,0x5e,0x00},
73964 -       {0x67,0x91,0x84,0x5e,0x00},
73965 -       {0x67,0x91,0x84,0x5e,0x00},
73966 -       {0x67,0x91,0x84,0x5e,0x00},
73967 -       {0x67,0x91,0x84,0x5e,0x00},
73968 -       {0x67,0x91,0x84,0x5e,0x00},
73969 -       {0x65,0xef,0x83,0x5c,0x00},
73970 -       {0x65,0xef,0x83,0x5c,0x00},
73971 -       {0x8a,0x14,0x00,0x80,0x00},
73972 -       {0x8a,0x14,0x00,0x80,0x00}
73973 -    },
73974 -    {
73975 -        {0x4E,0x18,0x90,0x38,0x00},
73976 -       {0x4E,0x18,0x90,0x38,0x00},
73977 -       {0x8E,0x18,0x28,0x78,0x00},
73978 -       {0x8E,0x18,0x28,0x78,0x00},
73979 -       {0x8E,0x18,0x28,0x78,0x00},
73980 -       {0x4E,0x18,0x90,0x38,0x00},
73981 -       {0x4E,0x18,0x90,0x38,0x00},
73982 -       {0x67,0x11,0x9A,0x56,0x00},
73983 -       {0x67,0x11,0x9A,0x56,0x00},
73984 -       {0x8A,0x14,0x00,0x80,0x00},
73985 -       {0x8A,0x14,0x00,0x80,0x00}
73986 -    },
73987 -    {
73988 -       {0x67,0x91,0x84,0x5E,0x00},
73989 -       {0x67,0x91,0x84,0x5E,0x00},
73990 -       {0x67,0x91,0x84,0x5E,0x00},
73991 -       {0x67,0x91,0x84,0x5E,0x00},
73992 -       {0x67,0x91,0x84,0x5E,0x00},
73993 -       {0x67,0x91,0x84,0x5E,0x00},
73994 -       {0x67,0x91,0x84,0x5E,0x00},
73995 -       {0x65,0xEF,0x83,0x5C,0x00},
73996 -       {0x65,0xEF,0x83,0x5C,0x00},
73997 -       {0x8A,0x14,0x00,0x80,0x00},
73998 -       {0x8A,0x14,0x00,0x80,0x00}
73999 -    },
74000 -    {
74001 -       {0x4E,0x18,0x90,0x38,0x00},
74002 -       {0x4E,0x18,0x90,0x38,0x00},
74003 -       {0x8E,0x18,0x28,0x78,0x00},
74004 -       {0x8E,0x18,0x28,0x78,0x00},
74005 -       {0x8E,0x18,0x28,0x78,0x00},
74006 -       {0x4E,0x18,0x90,0x38,0x00},
74007 -       {0x4E,0x18,0x90,0x38,0x00},
74008 -       {0x67,0x11,0x9A,0x56,0x00},
74009 -       {0x67,0x11,0x9A,0x56,0x00},
74010 -       {0x8A,0x14,0x00,0x80,0x00},
74011 -       {0x8A,0x14,0x00,0x80,0x00}
74012 -    },
74013 -    {
74014 -       {0x67,0x91,0x84,0x5E,0x00},
74015 -       {0x67,0x91,0x84,0x5E,0x00},
74016 -       {0x67,0x91,0x84,0x5E,0x00},
74017 -       {0x67,0x91,0x84,0x5E,0x00},
74018 -       {0x67,0x91,0x84,0x5E,0x00},
74019 -       {0x67,0x91,0x84,0x5E,0x00},
74020 -       {0x67,0x91,0x84,0x5E,0x00},
74021 -       {0x65,0xEF,0x83,0x5C,0x00},
74022 -       {0x65,0xEF,0x83,0x5C,0x00},
74023 -       {0x8A,0x14,0x00,0x80,0x00},
74024 -       {0x8A,0x14,0x00,0x80,0x00}
74025 -    },
74026 -    {
74027 -       {0x4E,0x18,0x90,0x38,0x00},
74028 -       {0x4E,0x18,0x90,0x38,0x00},
74029 -       {0x8E,0x18,0x28,0x78,0x00},
74030 -       {0x8E,0x18,0x28,0x78,0x00},
74031 -       {0x8E,0x18,0x28,0x78,0x00},
74032 -       {0x4E,0x18,0x90,0x38,0x00},
74033 -       {0x4E,0x18,0x90,0x38,0x00},
74034 -       {0x67,0x11,0x9A,0x56,0x00},
74035 -       {0x67,0x11,0x9A,0x56,0x00},
74036 -       {0x8A,0x14,0x00,0x80,0x00},
74037 -       {0x8A,0x14,0x00,0x80,0x00}
74038 -    },
74039 -    {
74040 -       {0x67,0x91,0x84,0x5E,0x00},
74041 -       {0x67,0x91,0x84,0x5E,0x00},
74042 -       {0x67,0x91,0x84,0x5E,0x00},
74043 -       {0x67,0x91,0x84,0x5E,0x00},
74044 -       {0x67,0x91,0x84,0x5E,0x00},
74045 -       {0x67,0x91,0x84,0x5E,0x00},
74046 -       {0x67,0x91,0x84,0x5E,0x00},
74047 -       {0x65,0xEF,0x83,0x5C,0x00},
74048 -       {0x65,0xEF,0x83,0x5C,0x00},
74049 -       {0x8A,0x14,0x00,0x80,0x00},
74050 -       {0x8A,0x14,0x00,0x80,0x00}
74051 -    },
74052 -    {
74053 -       {0x4E,0x18,0x90,0x38,0x00},
74054 -       {0x4E,0x18,0x90,0x38,0x00},
74055 -       {0x8E,0x18,0x28,0x78,0x00},
74056 -       {0x8E,0x18,0x28,0x78,0x00},
74057 -       {0x8E,0x18,0x28,0x78,0x00},
74058 -       {0x4E,0x18,0x90,0x38,0x00},
74059 -       {0x4E,0x18,0x90,0x38,0x00},
74060 -       {0x67,0x11,0x9A,0x56,0x00},
74061 -       {0x67,0x11,0x9A,0x56,0x00},
74062 -       {0x8A,0x14,0x00,0x80,0x00},
74063 -       {0x8A,0x14,0x00,0x80,0x00}
74064 -    },
74065 -    {
74066 -       {0x67,0x91,0x84,0x5E,0x00},
74067 -       {0x67,0x91,0x84,0x5E,0x00},
74068 -       {0x67,0x91,0x84,0x5E,0x00},
74069 -       {0x67,0x91,0x84,0x5E,0x00},
74070 -       {0x67,0x91,0x84,0x5E,0x00},
74071 -       {0x67,0x91,0x84,0x5E,0x00},
74072 -       {0x67,0x91,0x84,0x5E,0x00},
74073 -       {0x65,0xEF,0x83,0x5C,0x00},
74074 -       {0x65,0xEF,0x83,0x5C,0x00},
74075 -       {0x8A,0x14,0x00,0x80,0x00},
74076 -       {0x8A,0x14,0x00,0x80,0x00}
74077 -    },
74078 -    {
74079 -       {0x4E,0x18,0x90,0x38,0x00},
74080 -       {0x4E,0x18,0x90,0x38,0x00},
74081 -       {0x8E,0x18,0x28,0x78,0x00},
74082 -       {0x8E,0x18,0x28,0x78,0x00},
74083 -       {0x8E,0x18,0x28,0x78,0x00},
74084 -       {0x4E,0x18,0x90,0x38,0x00},
74085 -       {0x4E,0x18,0x90,0x38,0x00},
74086 -       {0x67,0x11,0x9A,0x56,0x00},
74087 -       {0x67,0x11,0x9A,0x56,0x00},
74088 -       {0x8A,0x14,0x00,0x80,0x00},
74089 -       {0x8A,0x14,0x00,0x80,0x00}
74090 -    },
74091 -    {
74092 -       {0x67,0x91,0x84,0x5E,0x00},
74093 -       {0x67,0x91,0x84,0x5E,0x00},
74094 -       {0x67,0x91,0x84,0x5E,0x00},
74095 -       {0x67,0x91,0x84,0x5E,0x00},
74096 -       {0x67,0x91,0x84,0x5E,0x00},
74097 -       {0x67,0x91,0x84,0x5E,0x00},
74098 -       {0x67,0x91,0x84,0x5E,0x00},
74099 -       {0x65,0xEF,0x83,0x5C,0x00},
74100 -       {0x65,0xEF,0x83,0x5C,0x00},
74101 -       {0x8A,0x14,0x00,0x80,0x00},
74102 -       {0x8A,0x14,0x00,0x80,0x00}
74103 -    },
74104 -    {
74105 -       {0x4E,0x18,0x90,0x38,0x00},
74106 -       {0x4E,0x18,0x90,0x38,0x00},
74107 -       {0x8E,0x18,0x28,0x78,0x00},
74108 -       {0x8E,0x18,0x28,0x78,0x00},
74109 -       {0x8E,0x18,0x28,0x78,0x00},
74110 -       {0x4E,0x18,0x90,0x38,0x00},
74111 -       {0x4E,0x18,0x90,0x38,0x00},
74112 -       {0x67,0x11,0x9A,0x56,0x00},
74113 -       {0x67,0x11,0x9A,0x56,0x00},
74114 -       {0x8A,0x14,0x00,0x80,0x00},
74115 -       {0x8A,0x14,0x00,0x80,0x00}
74116 -    },
74117 -    {
74118 -       {0x67,0x91,0x84,0x5E,0x00},
74119 -       {0x67,0x91,0x84,0x5E,0x00},
74120 -       {0x67,0x91,0x84,0x5E,0x00},
74121 -       {0x67,0x91,0x84,0x5E,0x00},
74122 -       {0x67,0x91,0x84,0x5E,0x00},
74123 -       {0x67,0x91,0x84,0x5E,0x00},
74124 -       {0x67,0x91,0x84,0x5E,0x00},
74125 -       {0x65,0xEF,0x83,0x5C,0x00},
74126 -       {0x65,0xEF,0x83,0x5C,0x00},
74127 -       {0x8A,0x14,0x00,0x80,0x00},
74128 -       {0x8A,0x14,0x00,0x80,0x00}
74129 -    },
74130 -    {
74131 -       {0x4E,0x18,0x90,0x38,0x00},
74132 -       {0x4E,0x18,0x90,0x38,0x00},
74133 -       {0x8E,0x18,0x28,0x78,0x00},
74134 -       {0x8E,0x18,0x28,0x78,0x00},
74135 -       {0x8E,0x18,0x28,0x78,0x00},
74136 -       {0x4E,0x18,0x90,0x38,0x00},
74137 -       {0x4E,0x18,0x90,0x38,0x00},
74138 -       {0x67,0x11,0x9A,0x56,0x00},
74139 -       {0x67,0x11,0x9A,0x56,0x00},
74140 -       {0x8A,0x14,0x00,0x80,0x00},
74141 -       {0x8A,0x14,0x00,0x80,0x00}
74142 -    },
74143 -    {
74144 -       {0x67,0x91,0x84,0x5E,0x00},
74145 -       {0x67,0x91,0x84,0x5E,0x00},
74146 -       {0x67,0x91,0x84,0x5E,0x00},
74147 -       {0x67,0x91,0x84,0x5E,0x00},
74148 -       {0x67,0x91,0x84,0x5E,0x00},
74149 -       {0x67,0x91,0x84,0x5E,0x00},
74150 -       {0x67,0x91,0x84,0x5E,0x00},
74151 -       {0x65,0xEF,0x83,0x5C,0x00},
74152 -       {0x65,0xEF,0x83,0x5C,0x00},
74153 -       {0x8A,0x14,0x00,0x80,0x00},
74154 -       {0x8A,0x14,0x00,0x80,0x00}
74155 -    },
74156 -    {
74157 -       {0x4E,0x18,0x90,0x38,0x00},
74158 -       {0x4E,0x18,0x90,0x38,0x00},
74159 -       {0x8E,0x18,0x28,0x78,0x00},
74160 -       {0x8E,0x18,0x28,0x78,0x00},
74161 -       {0x8E,0x18,0x28,0x78,0x00},
74162 -       {0x4E,0x18,0x90,0x38,0x00},
74163 -       {0x4E,0x18,0x90,0x38,0x00},
74164 -       {0x67,0x11,0x9A,0x56,0x00},
74165 -       {0x67,0x11,0x9A,0x56,0x00},
74166 -       {0x8A,0x14,0x00,0x80,0x00},
74167 -       {0x8A,0x14,0x00,0x80,0x00}
74168 -    },
74169 -    {
74170 -       {0x67,0x91,0x84,0x5E,0x00},
74171 -       {0x67,0x91,0x84,0x5E,0x00},
74172 -       {0x67,0x91,0x84,0x5E,0x00},
74173 -       {0x67,0x91,0x84,0x5E,0x00},
74174 -       {0x67,0x91,0x84,0x5E,0x00},
74175 -       {0x67,0x91,0x84,0x5E,0x00},
74176 -       {0x67,0x91,0x84,0x5E,0x00},
74177 -       {0x65,0xEF,0x83,0x5C,0x00},
74178 -       {0x65,0xEF,0x83,0x5C,0x00},
74179 -       {0x8A,0x14,0x00,0x80,0x00},
74180 -       {0x8A,0x14,0x00,0x80,0x00}
74181 -    },
74182 -    {
74183 -       {0x4E,0x18,0x90,0x38,0x00},
74184 -       {0x4E,0x18,0x90,0x38,0x00},
74185 -       {0x8E,0x18,0x28,0x78,0x00},
74186 -       {0x8E,0x18,0x28,0x78,0x00},
74187 -       {0x8E,0x18,0x28,0x78,0x00},
74188 -       {0x4E,0x18,0x90,0x38,0x00},
74189 -       {0x4E,0x18,0x90,0x38,0x00},
74190 -       {0x67,0x11,0x9A,0x56,0x00},
74191 -       {0x67,0x11,0x9A,0x56,0x00},
74192 -       {0x8A,0x14,0x00,0x80,0x00},
74193 -       {0x8A,0x14,0x00,0x80,0x00}
74194 -    },
74195 -    {
74196 -       {0x67,0x91,0x84,0x5E,0x00},
74197 -       {0x67,0x91,0x84,0x5E,0x00},
74198 -       {0x67,0x91,0x84,0x5E,0x00},
74199 -       {0x67,0x91,0x84,0x5E,0x00},
74200 -       {0x67,0x91,0x84,0x5E,0x00},
74201 -       {0x67,0x91,0x84,0x5E,0x00},
74202 -       {0x67,0x91,0x84,0x5E,0x00},
74203 -       {0x65,0xEF,0x83,0x5C,0x00},
74204 -       {0x65,0xEF,0x83,0x5C,0x00},
74205 -       {0x8A,0x14,0x00,0x80,0x00},
74206 -       {0x8A,0x14,0x00,0x80,0x00}
74207 -    },
74208 -    {
74209 -       {0x4E,0x18,0x90,0x38,0x00},
74210 -       {0x4E,0x18,0x90,0x38,0x00},
74211 -       {0x8E,0x18,0x28,0x78,0x00},
74212 -       {0x8E,0x18,0x28,0x78,0x00},
74213 -       {0x8E,0x18,0x28,0x78,0x00},
74214 -       {0x4E,0x18,0x90,0x38,0x00},
74215 -       {0x4E,0x18,0x90,0x38,0x00},
74216 -       {0x67,0x11,0x9A,0x56,0x00},
74217 -       {0x67,0x11,0x9A,0x56,0x00},
74218 -       {0x8A,0x14,0x00,0x80,0x00},
74219 -       {0x8A,0x14,0x00,0x80,0x00}
74220 +       {  { 0x16, 0xcf, 0x00 },
74221 +          { 0x18, 0x00, 0x00 },
74222 +          { 0x1a, 0xe7, 0x00 },
74223 +          { 0x1b, 0x26, 0x00 },
74224 +          { 0x1c, 0xff, 0x00 },
74225 +          { 0x1d, 0x1c, 0x00 },
74226 +          { 0x1e, 0x19, 0x00 }
74227 +       },
74228 +       {
74229 +          { 0x16, 0xcf, 0x00 },
74230 +          { 0x18, 0x00, 0x00 },
74231 +          { 0x1a, 0xe7, 0x00 },
74232 +          { 0x1b, 0x1e, 0x00 },
74233 +          { 0x1c, 0xff, 0x00 },
74234 +          { 0x1d, 0x1c, 0x00 },
74235 +          { 0x1e, 0x16, 0x00 }
74236 +       },
74237 +       {
74238 +          { 0x16, 0xcf, 0x00 },
74239 +          { 0x1a, 0xe7, 0x00 },
74240 +          { 0x1b, 0x26, 0x00 },
74241 +          { 0x1c, 0xff, 0x00 },
74242 +          { 0x1d, 0x1c, 0x00 },
74243 +          { 0x1e, 0x19, 0x00 },
74244 +          {    0,    0,    0 }
74245 +       },
74246 +       {
74247 +          {    0,    0,    0 }
74248 +       },
74249 +       {
74250 +          { 0x16, 0xcf, 0x00 },
74251 +          { 0x1a, 0xe7, 0x00 },
74252 +          { 0x1b, 0x26, 0x00 },
74253 +          { 0x1c, 0xff, 0x00 },
74254 +          { 0x1d, 0x1c, 0x00 },
74255 +          { 0x1e, 0x1e, 0x00 },
74256 +          {    0,    0,    0 }
74257 +       },
74258 +       {
74259 +          { 0x16, 0xd1, 0x00 },
74260 +          { 0x18, 0x00, 0x00 },
74261 +          { 0x1a, 0xe7, 0x00 },
74262 +          { 0x1b, 0x11, 0x00 },
74263 +          { 0x1c, 0xff, 0x00 },
74264 +          { 0x1d, 0x1c, 0x00 },
74265 +          { 0x1e, 0x26, 0x00 }
74266 +       },
74267 +       {
74268 +          { 0x16, 0xd1, 0x00 },
74269 +          { 0x1a, 0xe7, 0x00 },
74270 +          { 0x1b, 0x26, 0x00 },
74271 +          { 0x1c, 0xff, 0x00 },
74272 +          { 0x1d, 0x1c, 0x00 },
74273 +          { 0x1e, 0x30, 0x00 },
74274 +          {    0,    0,    0 }
74275 +       },
74276 +       {
74277 +          { 0x16, 0x00, 0x00 },
74278 +          { 0x17, 0xa0, 0x00 },
74279 +          { 0x1a, 0xa0, 0x00 },
74280 +          { 0x1b, 0x2a, 0x00 },
74281 +          { 0x1c, 0xff, 0x00 },
74282 +          { 0x1d, 0x1c, 0x00 },
74283 +          {    0,    0,    0 }
74284 +       },
74285 +       {
74286 +          { 0x16, 0x00, 0x00 },
74287 +          { 0x17, 0xaa, 0x00 },
74288 +          { 0x1a, 0xa0, 0x00 },
74289 +          { 0x1b, 0x2a, 0x00 },
74290 +          { 0x1c, 0xff, 0x00 },
74291 +          { 0x1d, 0x1c, 0x00 },
74292 +          {    0,    0,    0 }
74293 +       }
74294 +    },
74295 +    {
74296 +       {
74297 +          { 0x16, 0xcf, 0x00 },
74298 +          { 0x18, 0x00, 0x00 },
74299 +          { 0x1a, 0xe7, 0x00 },
74300 +          { 0x1b, 0x26, 0x00 },
74301 +          { 0x1c, 0xff, 0x00 },
74302 +          { 0x1d, 0x1c, 0x00 },
74303 +          { 0x1e, 0x19, 0x00 }
74304 +       },
74305 +       {
74306 +          {    0,    0,    0 }
74307 +       },
74308 +       {
74309 +          { 0x16, 0xcf, 0x00 },
74310 +          { 0x18, 0x00, 0x00 },
74311 +          { 0x1a, 0xe7, 0x00 },
74312 +          { 0x1b, 0x26, 0x00 },
74313 +          { 0x1c, 0xff, 0x00 },
74314 +          { 0x1d, 0x1c, 0x00 },
74315 +          { 0x1e, 0x19, 0x00 },
74316 +       },
74317 +       {
74318 +          {    0,    0,    0 }
74319 +       },
74320 +       {
74321 +          { 0x16, 0xcf, 0x00 },
74322 +          { 0x18, 0x00, 0x00 },
74323 +          { 0x1a, 0xe7, 0x00 },
74324 +          { 0x1b, 0x26, 0x00 },
74325 +          { 0x1c, 0xff, 0x00 },
74326 +          { 0x1d, 0x1c, 0x00 },
74327 +          { 0x1e, 0x1e, 0x00 }
74328 +       },
74329 +       {
74330 +          { 0x16, 0xd1, 0x00 },
74331 +          { 0x18, 0x00, 0x00 },
74332 +          { 0x1a, 0xe6, 0x00 },
74333 +          { 0x1b, 0x11, 0x00 },
74334 +          { 0x1c, 0xff, 0x00 },
74335 +          { 0x1d, 0x1c, 0x00 },
74336 +          { 0x1e, 0x26, 0x00 }
74337 +       },
74338 +       {
74339 +          { 0x18, 0x00, 0x00 },
74340 +          { 0x1a, 0xe0, 0x00 },
74341 +          { 0x1b, 0x26, 0x00 },
74342 +          { 0x1c, 0xff, 0x00 },
74343 +          { 0x1d, 0x1c, 0x00 },
74344 +          { 0x1e, 0x30, 0x00 },
74345 +          {    0,    0,    0 }
74346 +       },
74347 +       {
74348 +          {    0,    0,    0 }
74349 +       },
74350 +       {
74351 +          {    0,    0,    0 }
74352 +       }
74353      }
74354  };
74355  
74356 -#if 0
74357 -const UCHAR SiS300_LCDVData[24][11][6] = {
74358 -    {
74359 -        {
74360 -    },
74361 -};
74362 -#endif
74363 +
74364 +
74365 +
74366 +
74367 +
74368 --- linux-2.6.0-test6/drivers/video/sis/oem310.h        2003-06-14 12:17:55.000000000 -0700
74369 +++ 25/drivers/video/sis/oem310.h       2003-10-05 00:34:22.000000000 -0700
74370 @@ -1,5 +1,37 @@
74371 -
74372 -/* OEM Data for 310/325/330 series */
74373 +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/oem300.h.c,v 1.0 2001/11/30 12:12:01 eich Exp $ */
74374 +/*
74375 + * OEM Data for 315/330 series
74376 + *
74377 + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
74378 + *
74379 + * If distributed as part of the linux kernel, the contents of this file
74380 + * is entirely covered by the GPL.
74381 + *
74382 + * Otherwise, the following terms apply:
74383 + *
74384 + * Permission to use, copy, modify, distribute, and sell this software and its
74385 + * documentation for any purpose is hereby granted without fee, provided that
74386 + * the above copyright notice appear in all copies and that both that
74387 + * copyright notice and this permission notice appear in supporting
74388 + * documentation, and that the name of the copyright holder not be used in
74389 + * advertising or publicity pertaining to distribution of the software without
74390 + * specific, written prior permission.  The copyright holder makes no representations
74391 + * about the suitability of this software for any purpose.  It is provided
74392 + * "as is" without express or implied warranty.
74393 + *
74394 + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
74395 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
74396 + * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
74397 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
74398 + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
74399 + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
74400 + * PERFORMANCE OF THIS SOFTWARE.
74401 + *
74402 + * Author:     Thomas Winischhofer <thomas@winischhofer.net>
74403 + *
74404 + * Based on code by Silicon Intergrated Systems
74405 + *
74406 + */
74407  
74408  const UCHAR SiS310_LCDDelayCompensation_301[] =                /* 301 */
74409  {
74410 @@ -100,7 +132,7 @@ const UCHAR SiS310_LCDDelayCompensation_
74411  
74412  const UCHAR SiS310_LCDDelayCompensation_651301LV[] =     /* M650/651 301LV */
74413  {
74414 -                 0x33,0x33,0x33,    /*   800x600 (guessed) */
74415 +                 0x33,0x33,0x33,    /*   800x600 (guessed) - new: PanelType, not PanelRes ! */
74416                  0x33,0x33,0x33,    /*  1024x768 */
74417                  0x33,0x33,0x33,    /* 1280x1024 */
74418                  0x33,0x33,0x33,    /*   640x480 (unknown) */
74419 @@ -361,5 +393,55 @@ const UCHAR SiS310_TVPhaseIncr2[3][2][4]
74420   }
74421  };
74422  
74423 +/* OEM data for Compaq Presario 3045US */
74424 +static const SiS_LCDDataStruct  SiS310_ExtCompaq1280x1024Data[] =
74425 +{
74426 +       {  211,  60,1024, 501,1688,1066},
74427 +       {  211,  60,1024, 508,1688,1066},
74428 +       {  211,  60,1024, 501,1688,1066},
74429 +       {  211,  60,1024, 508,1688,1066},
74430 +       {   32,  15,1696, 501,1696,1066},
74431 +       {  212,  75,1024, 621,1696,1066},
74432 +       {    4,   3,1696, 810,1696,1066},
74433 +       {    1,   1,1696,1066,1696,1066}
74434 +};
74435 +
74436 +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Compaq1280x1024_1[] =
74437 +{
74438 + {{0x3F,0x1B,0xD0,0xF0,0xB0,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}},
74439 + {{0x35,0x1B,0xA0,0xC0,0x80,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}},
74440 + {{0x3F,0x1B,0xD0,0xF0,0xB0,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}},
74441 + {{0x3F,0x1B,0xD0,0xF0,0xB0,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}},
74442 + {{0x45,0x1C,0x20,0x3F,0xFF,0xB8,0x23,0x0A,0x07,0x14,0x8A,0x12}},
74443 + {{0x49,0x1C,0x40,0x7F,0xFF,0xAD,0x23,0x0A,0x07,0xF3,0x8A,0x12}},
74444 + {{0x4C,0x1C,0x18,0x2F,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}},
74445 + {{0x48,0x1C,0x15,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}}
74446 +};
74447 +
74448 +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Compaq1280x1024_2[] =
74449 +{
74450 + {{0x2B,0x12,0xD9,0xE5,0xD5,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}},
74451 + {{0x22,0x12,0xC0,0xCC,0xBC,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}},
74452 + {{0x2B,0x12,0xD9,0xE5,0xD5,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}},
74453 + {{0x22,0x12,0xC0,0xCC,0xBC,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}},
74454 + {{0x33,0x13,0x01,0x0D,0xFD,0x2C,0x23,0x98,0x27,0x3E,0x08,0x42}},
74455 + {{0x3F,0x1B,0x3D,0x49,0x39,0x54,0x23,0xC0,0x27,0x66,0x30,0x42}},
74456 + {{0x33,0x1B,0x91,0x9D,0x8D,0x8C,0x23,0xF8,0x27,0x9E,0x68,0x42}},
74457 + {{0x43,0x24,0x11,0x1D,0x0D,0xCC,0x23,0x38,0x37,0xDE,0xA8,0x42}},
74458 + {{0x43,0x24,0x21,0x29,0x19,0xEA,0x23,0x0A,0x07,0x32,0xC6,0x42}}
74459 +};
74460 +
74461 +static const SiS_Part2PortTblStruct SiS310_CRT2Part2_Compaq1280x1024_3[] =
74462 +{
74463 + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}},
74464 + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}},
74465 + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}},
74466 + {{0x47,0x1C,0x14,0x29,0xFF,0xBD,0x23,0x0A,0x07,0x23,0x8A,0x12}},
74467 + {{0x47,0x1C,0x14,0x29,0xFF,0xBE,0x23,0x0A,0x07,0x26,0x8A,0x42}},
74468 + {{0x47,0x1C,0x14,0x29,0xFF,0xBE,0x23,0x0A,0x07,0x26,0x8A,0x42}},
74469 + {{0x47,0x1C,0x14,0x29,0xFF,0xBE,0x23,0x0A,0x07,0x26,0x8A,0x42}},
74470 + {{0x47,0x1C,0x14,0x29,0xFF,0xBE,0x23,0x0A,0x07,0x26,0x8A,0x42}}
74471 +};
74472 +
74473  
74474  
74475 --- linux-2.6.0-test6/drivers/video/sis/osdef.h 2003-06-14 12:17:56.000000000 -0700
74476 +++ 25/drivers/video/sis/osdef.h        2003-10-05 00:34:22.000000000 -0700
74477 @@ -1,79 +1,43 @@
74478 -/* #define WINCE_HEADER */
74479 -/* #define WIN2000 */
74480 -/* #define TC */
74481 +
74482 +/* OS depending defines */
74483 +
74484 +/* The choices are: */
74485 +
74486  #define LINUX_KERNEL      /* Kernel framebuffer */
74487  /* #define LINUX_XF86 */   /* XFree86 */
74488  
74489  /**********************************************************************/
74490 -#ifdef LINUX_KERNEL
74491 -       #include <linux/config.h>
74492 -       #include <linux/version.h>
74493 -       #ifdef CONFIG_FB_SIS_300
74494 -               #define SIS300
74495 -       #endif
74496 -
74497 -       #ifdef CONFIG_FB_SIS_315
74498 -               #define SIS315H
74499 -       #endif
74500 -       #if 1
74501 -               #define SISFBACCEL      /* Include 2D acceleration */
74502 -       #endif
74503 -       #if 1
74504 -               #define SISFB_PAN       /* Include Y-Panning code */
74505 -       #endif
74506 -#else
74507 -/*     #define SIS300*/
74508 -       #define SIS315H
74509 -#endif
74510 -#ifdef LINUX_XF86
74511 -       #define SIS300
74512 -       /* #define SIS315H */ /* TW: done above */
74513 -#endif
74514 +#ifdef LINUX_KERNEL  /* -------------------------- */
74515 +#include <linux/config.h>
74516 +#include <linux/version.h>
74517  
74518 -/**********************************************************************/
74519 -#ifdef TC
74520 -#endif
74521 -#ifdef WIN2000
74522 -#endif
74523 -#ifdef WINCE_HEADER
74524 -#endif
74525 -#ifdef LINUX_XF86
74526 +#ifdef CONFIG_FB_SIS_300
74527 +#define SIS300
74528  #endif
74529 -#ifdef LINUX_KERNEL
74530 -#endif
74531 -/**********************************************************************/
74532 -#ifdef TC
74533 -#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize);
74534 -#endif
74535 -#ifdef WIN2000
74536 -#define SiS_SetMemory(MemoryAddress,MemorySize,value) MemFill((PVOID) MemoryAddress,(ULONG) MemorySize,(UCHAR) value);
74537 +
74538 +#ifdef CONFIG_FB_SIS_315
74539 +#define SIS315H
74540  #endif
74541 -#ifdef WINCE_HEADER
74542 -#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize);
74543 +
74544 +#if 1
74545 +#define SISFBACCEL     /* Include 2D acceleration */
74546  #endif
74547 -#ifdef LINUX_XF86
74548 -#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize)
74549 +
74550  #endif
74551 -#ifdef LINUX_KERNEL
74552 -#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize)
74553 +
74554 +#ifdef LINUX_XF86 /* ----------------------------- */
74555 +#define SIS300
74556 +#define SIS315H
74557  #endif
74558 -/**********************************************************************/
74559  
74560  /**********************************************************************/
74561 -
74562 -#ifdef TC
74563 -#define SiS_MemoryCopy(Destination,Soruce,Length) memmove(Destination, Soruce, Length);
74564 -#endif
74565 -#ifdef WIN2000
74566 -#define SiS_MemoryCopy(Destination,Soruce,Length)  /*VideoPortMoveMemory((PUCHAR)Destination , Soruce,length);*/
74567 -#endif
74568 -#ifdef WINCE_HEADER
74569 -#define SiS_MemoryCopy(Destination,Soruce,Length) memmove(Destination, Soruce, Length);
74570 -#endif
74571  #ifdef LINUX_XF86
74572 +#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize)
74573  #define SiS_MemoryCopy(Destination,Soruce,Length) memcpy(Destination,Soruce,Length)
74574  #endif
74575 +
74576  #ifdef LINUX_KERNEL
74577 +#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize)
74578  #define SiS_MemoryCopy(Destination,Soruce,Length) memcpy(Destination,Soruce,Length)
74579  #endif
74580  
74581 @@ -104,19 +68,6 @@
74582  #endif /* InPortLong */
74583  
74584  /**********************************************************************/
74585 -/*  TC                                                                */
74586 -/**********************************************************************/
74587 -
74588 -#ifdef TC
74589 -#define OutPortByte(p,v) outp((unsigned short)(p),(unsigned char)(v))
74590 -#define OutPortWord(p,v) outp((unsigned short)(p),(unsigned short)(v))
74591 -#define OutPortLong(p,v) outp((unsigned short)(p),(unsigned long)(v))
74592 -#define InPortByte(p)    inp((unsigned short)(p))
74593 -#define InPortWord(p)    inp((unsigned short)(p))
74594 -#define InPortLong(p)    ((inp((unsigned short)(p+2))<<16) | inp((unsigned short)(p)))
74595 -#endif
74596 -
74597 -/**********************************************************************/
74598  /*  LINUX XF86                                                        */
74599  /**********************************************************************/
74600  
74601 @@ -142,29 +93,4 @@
74602  #define InPortLong(p)    inl((u16)(p))
74603  #endif
74604  
74605 -/**********************************************************************/
74606 -/*  WIN 2000                                                          */
74607 -/**********************************************************************/
74608 -
74609 -#ifdef WIN2000
74610 -#define OutPortByte(p,v) VideoPortWritePortUchar ((PUCHAR) (p), (UCHAR) (v))
74611 -#define OutPortWord(p,v) VideoPortWritePortUshort((PUSHORT) (p), (USHORT) (v))
74612 -#define OutPortLong(p,v) VideoPortWritePortUlong ((PULONG) (p), (ULONG) (v))
74613 -#define InPortByte(p)    VideoPortReadPortUchar  ((PUCHAR) (p))
74614 -#define InPortWord(p)    VideoPortReadPortUshort ((PUSHORT) (p))
74615 -#define InPortLong(p)    VideoPortReadPortUlong  ((PULONG) (p))
74616 -#endif
74617  
74618 -
74619 -/**********************************************************************/
74620 -/*  WIN CE                                                            */
74621 -/**********************************************************************/
74622 -
74623 -#ifdef WINCE_HEADER
74624 -#define OutPortByte(p,v) WRITE_PORT_UCHAR ((PUCHAR) (p), (UCHAR) (v))
74625 -#define OutPortWord(p,v) WRITE_PORT_USHORT((PUSHORT) (p), (USHORT) (v))
74626 -#define OutPortLong(p,v) WRITE_PORT_ULONG ((PULONG) (p), (ULONG) (v))
74627 -#define InPortByte(p)    READ_PORT_UCHAR  ((PUCHAR) (p))
74628 -#define InPortWord(p)    READ_PORT_USHORT ((PUSHORT) (p))
74629 -#define InPortLong(p)    READ_PORT_ULONG  ((PULONG) (p))
74630 -#endif
74631 --- linux-2.6.0-test6/drivers/video/sis/sis_accel.c     2003-06-14 12:18:52.000000000 -0700
74632 +++ 25/drivers/video/sis/sis_accel.c    2003-10-05 00:34:22.000000000 -0700
74633 @@ -1,5 +1,5 @@
74634  /*
74635 - * SiS 300/630/730/540/315/550/650/740 frame buffer driver
74636 + * SiS 300/630/730/540/315/550/650/740/330/660 frame buffer driver
74637   * for Linux kernels 2.4.x and 2.5.x
74638   *
74639   * 2D acceleration part
74640 @@ -211,7 +211,7 @@ SiS300SubsequentSolidFillRect(int x, int
74641         SiS300DoCMD
74642  }
74643  
74644 -/* 310/325 series ------------------------------------------------ */
74645 +/* 315 series ---------------------------------------------------- */
74646  
74647  static void
74648  SiS310SetupForScreenToScreenCopy(int xdir, int ydir, int rop,
74649 @@ -230,7 +230,7 @@ SiS310SetupForScreenToScreenCopy(int xdi
74650                 /* SiSSetupCMDFlag(BITBLT | SRCVIDEO) */
74651         }
74652         SiS310SetupCMDFlag(ivideo.SiS310_AccelDepth)
74653 -       /* TW: The 310/325 series is smart enough to know the direction */
74654 +       /* The 315 series is smart enough to know the direction */
74655  }
74656  
74657  static void
74658 @@ -328,11 +328,13 @@ void sisfb_syncaccel(void)
74659      }
74660  }
74661  
74662 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,34)  /* --- KERNEL 2.5.34 and later --- */
74663 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)  /* --------------- 2.5 --------------- */
74664  
74665  int fbcon_sis_sync(struct fb_info *info)
74666  {
74667 -   if(!sisfb_accel) return 0;
74668 +   if(!ivideo.accel)
74669 +       return 0;
74670 +
74671     CRITFLAGS
74672     if(sisvga_engine == SIS_300_VGA) {
74673        SiS300Sync();
74674 @@ -352,7 +354,7 @@ void fbcon_sis_fillrect(struct fb_info *
74675     if(!rect->width || !rect->height)
74676         return;
74677  
74678 -   if(!sisfb_accel) {
74679 +   if(!ivideo.accel) {
74680         cfb_fillrect(info, rect);
74681         return;
74682     }
74683 @@ -388,7 +390,7 @@ void fbcon_sis_copyarea(struct fb_info *
74684     CRITFLAGS
74685  
74686     TWDEBUG("Inside sis_copyarea");
74687 -   if(!sisfb_accel) {
74688 +   if(!ivideo.accel) {
74689         cfb_copyarea(info, area);
74690         return;
74691     }
74692 @@ -418,7 +420,7 @@ void fbcon_sis_copyarea(struct fb_info *
74693  
74694  #endif
74695  
74696 -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,33)  /* ------ KERNEL <2.5.34 ------ */
74697 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)  /* -------------- 2.4 --------------- */
74698  
74699  void fbcon_sis_bmove(struct display *p, int srcy, int srcx,
74700                             int dsty, int dstx, int height, int width)
74701 @@ -591,38 +593,38 @@ void fbcon_sis_revc(struct display *p, i
74702  
74703  #ifdef FBCON_HAS_CFB8
74704  struct display_switch fbcon_sis8 = {
74705 -       setup:                  fbcon_cfb8_setup,
74706 -       bmove:                  fbcon_sis_bmove,
74707 -       clear:                  fbcon_sis_clear8,
74708 -       putc:                   fbcon_cfb8_putc,
74709 -       putcs:                  fbcon_cfb8_putcs,
74710 -       revc:                   fbcon_cfb8_revc,
74711 -       clear_margins:          fbcon_cfb8_clear_margins,
74712 -       fontwidthmask:          FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
74713 +       .setup                  = fbcon_cfb8_setup,
74714 +       .bmove                  = fbcon_sis_bmove,
74715 +       .clear                  = fbcon_sis_clear8,
74716 +       .putc                   = fbcon_cfb8_putc,
74717 +       .putcs                  = fbcon_cfb8_putcs,
74718 +       .revc                   = fbcon_cfb8_revc,
74719 +       .clear_margins          = fbcon_cfb8_clear_margins,
74720 +       .fontwidthmask          = FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
74721  };
74722  #endif
74723  #ifdef FBCON_HAS_CFB16
74724  struct display_switch fbcon_sis16 = {
74725 -       setup:                  fbcon_cfb16_setup,
74726 -       bmove:                  fbcon_sis_bmove,
74727 -       clear:                  fbcon_sis_clear16,
74728 -       putc:                   fbcon_cfb16_putc,
74729 -       putcs:                  fbcon_cfb16_putcs,
74730 -       revc:                   fbcon_sis_revc,
74731 -       clear_margins:          fbcon_cfb16_clear_margins,
74732 -       fontwidthmask:          FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
74733 +       .setup                  = fbcon_cfb16_setup,
74734 +       .bmove                  = fbcon_sis_bmove,
74735 +       .clear                  = fbcon_sis_clear16,
74736 +       .putc                   = fbcon_cfb16_putc,
74737 +       .putcs                  = fbcon_cfb16_putcs,
74738 +       .revc                   = fbcon_sis_revc,
74739 +       .clear_margins          = fbcon_cfb16_clear_margins,
74740 +       .fontwidthmask          = FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
74741  };
74742  #endif
74743  #ifdef FBCON_HAS_CFB32
74744  struct display_switch fbcon_sis32 = {
74745 -       setup:                  fbcon_cfb32_setup,
74746 -       bmove:                  fbcon_sis_bmove,
74747 -       clear:                  fbcon_sis_clear32,
74748 -       putc:                   fbcon_cfb32_putc,
74749 -       putcs:                  fbcon_cfb32_putcs,
74750 -       revc:                   fbcon_sis_revc,
74751 -       clear_margins:          fbcon_cfb32_clear_margins,
74752 -       fontwidthmask:          FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
74753 +       .setup                  = fbcon_cfb32_setup,
74754 +       .bmove                  = fbcon_sis_bmove,
74755 +       .clear                  = fbcon_sis_clear32,
74756 +       .putc                   = fbcon_cfb32_putc,
74757 +       .putcs                  = fbcon_cfb32_putcs,
74758 +       .revc                   = fbcon_sis_revc,
74759 +       .clear_margins          = fbcon_cfb32_clear_margins,
74760 +       .fontwidthmask          = FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
74761  };
74762  #endif
74763  
74764 --- linux-2.6.0-test6/drivers/video/sis/sis_accel.h     2003-06-14 12:18:08.000000000 -0700
74765 +++ 25/drivers/video/sis/sis_accel.h    2003-10-05 00:34:22.000000000 -0700
74766 @@ -47,7 +47,7 @@
74767  #define TRAPAZOID_FILL          0x00000005  /* Fill trapezoid */
74768  #define TRANSPARENT_BITBLT      0x00000006  /* Transparent Blit */
74769  
74770 -/* Additional engine commands for 310/325 */
74771 +/* Additional engine commands for 315 */
74772  #define ALPHA_BLEND            0x00000007  /* Alpha blend ? */
74773  #define A3D_FUNCTION           0x00000008  /* 3D command ? */
74774  #define        CLEAR_Z_BUFFER          0x00000009  /* ? */
74775 @@ -90,11 +90,11 @@
74776  #define NO_RESET_COUNTER        0x00400000
74777  #define NO_LAST_PIXEL           0x00200000
74778  
74779 -/* Subfunctions for Color/Enhanced Color Expansion (310/325 only) */
74780 +/* Subfunctions for Color/Enhanced Color Expansion (315 only) */
74781  #define COLOR_TO_MONO          0x00100000
74782  #define AA_TEXT                        0x00200000
74783  
74784 -/* Some general registers for 310/325 series */
74785 +/* Some general registers for 315 series */
74786  #define SRC_ADDR               0x8200
74787  #define SRC_PITCH              0x8204
74788  #define AGP_BASE               0x8206 /* color-depth dependent value */
74789 @@ -326,7 +326,7 @@ int     CmdQueLen;
74790  
74791  
74792  
74793 -/* ----------- SiS 310/325 series --------------- */
74794 +/* -------------- SiS 315 series --------------- */
74795  
74796  /* Q_STATUS:
74797     bit 31 = 1: All engines idle and all queues empty
74798 @@ -342,16 +342,27 @@ int     CmdQueLen;
74799     bits 7:0:   2D counter 1
74800  
74801     Where is the command queue length (current amount of commands the queue
74802 -   can accept) on the 310/325 series? (The current implementation is taken
74803 -   from 300 series and certainly wrong...)
74804 +   can accept) on the 315 series?
74805  */
74806  
74807  /* TW: FIXME: CmdQueLen is... where....? */
74808 +/* We assume a length of 4 bytes per command; since 512K of
74809 + * of RAM are allocated, the number of commands is easily
74810 + * calculated (assuming that there is no 3D support yet)
74811 + * We calculate it very cautiously (128K only) and let the
74812 + * rest to the (never?)-to-come (?) 3D engine. (The 3D engine
74813 + * can use a similar technique, using the remaining 384K,
74814 + * hence a queue overflow is avoided)
74815 + * UPDATE: This technique causes a terrible system latency
74816 + * on integrated chipsets. Disable the queue handling for
74817 + * now.
74818 + */
74819  #define SiS310Idle \
74820    { \
74821    while( (MMIO_IN16(ivideo.mmio_vbase, Q_STATUS+2) & 0x8000) != 0x8000){}; \
74822    while( (MMIO_IN16(ivideo.mmio_vbase, Q_STATUS+2) & 0x8000) != 0x8000){}; \
74823 -  CmdQueLen=MMIO_IN16(ivideo.mmio_vbase, Q_STATUS); \
74824 +  CmdQueLen = 0; \
74825 +  /*CmdQueLen = ((128 * 1024) / 4) - 64; */ \
74826    }
74827  
74828  #define SiS310SetupSRCBase(base) \
74829 --- linux-2.6.0-test6/drivers/video/sis/sis_main.c      2003-06-14 12:18:25.000000000 -0700
74830 +++ 25/drivers/video/sis/sis_main.c     2003-10-05 00:34:22.000000000 -0700
74831 @@ -1,25 +1,20 @@
74832  /*
74833 - * SiS 300/630/730/540/315/550/650/740 frame buffer device
74834 + * SiS 300/630/730/540/315/550/650/740/330/660/760 frame buffer driver
74835   * for Linux kernels 2.4.x and 2.5.x
74836   *
74837 - * Partly based on the VBE 2.0 compliant graphic boards framebuffer driver,
74838 + * (C) 1999 Silicon Integrated Systems, Inc.
74839 + * (C) 2001-2003 Thomas Winischhofer, Vienna, Austria.
74840 + *
74841 + * Author:     Thomas Winischhofer <thomas@winischhofer.net>
74842 + *
74843 + * Author of code base:
74844 + *             SiS (www.sis.com.tw)
74845 + *
74846 + * See http://www.winischhofer.net/ for more information and updates
74847 + *
74848 + * Originally based on the VBE 2.0 compliant graphic boards framebuffer driver,
74849   * which is (c) 1998 Gerd Knorr <kraxel@goldbach.in-berlin.de>
74850   *
74851 - * Authors:    SiS (www.sis.com.tw)
74852 - *             (Various others)
74853 - *             Thomas Winischhofer <thomas@winischhofer.net>:
74854 - *                     - SiS Xabre (330) support
74855 - *                     - many fixes and enhancements for all chipset series,
74856 - *                     - extended bridge handling, TV output for Chrontel 7005
74857 - *                      - 650/LVDS support (for LCD panels up to 1600x1200)
74858 - *                      - 650/740/Chrontel 7019 support
74859 - *                      - 30xB/30xLV LCD, TV and VGA2 support
74860 - *                     - memory queue handling enhancements,
74861 - *                      - 2D acceleration and y-panning,
74862 - *                      - portation to 2.5 API
74863 - *                     - etc.
74864 - *                     (see http://www.winischhofer.net/
74865 - *                     for more information and updates)
74866   */
74867  
74868  #include <linux/config.h>
74869 @@ -43,6 +38,8 @@
74870  #include <linux/fs.h>
74871  #include <linux/agp_backend.h>
74872  #include <linux/types.h>
74873 +#include <linux/vmalloc.h>
74874 +#include <asm/uaccess.h>
74875  
74876  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
74877  #include <linux/spinlock.h>
74878 @@ -79,6 +76,12 @@
74879  #endif
74880  #endif
74881  
74882 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
74883 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,69)
74884 +#error "This version of sisfb requires at least 2.5.69"
74885 +#endif
74886 +#endif
74887 +
74888  /* -------------------- Macro definitions ---------------------------- */
74889  
74890  #undef SISFBDEBUG      /* TW: no debugging */
74891 @@ -134,9 +137,19 @@ sisfb_query_VGA_config_space(PSIS_HW_DEV
74892  
74893         if (!init) {
74894                 init = TRUE;
74895 -               pdev = pci_find_device(PCI_VENDOR_ID_SI, ivideo.chip_id, pdev);
74896 -               if (pdev)
74897 -                       valid_pdev = TRUE;
74898 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,74)
74899 +               pci_for_each_dev(pdev) {
74900 +#else
74901 +               while((pdev = pci_find_device(PCI_VENDOR_ID_SI, PCI_ANY_ID, pdev))) {
74902 +#endif
74903 +                       DPRINTK("sisfb: Current: 0x%x, target: 0x%x\n",
74904 +                                pdev->device, ivideo.chip_id);
74905 +                       if ((pdev->vendor == PCI_VENDOR_ID_SI)
74906 +                                  && (pdev->device == ivideo.chip_id)) {
74907 +                               valid_pdev = TRUE;
74908 +                               break;
74909 +                       }
74910 +               }
74911         }
74912  
74913         if (!valid_pdev) {
74914 @@ -163,6 +176,7 @@ BOOLEAN sisfb_query_north_bridge_space(P
74915         if (!init) {
74916                 init = TRUE;
74917                 switch (ivideo.chip) {
74918 +#ifdef CONFIG_FB_SIS_300
74919                 case SIS_540:
74920                         nbridge_id = PCI_DEVICE_ID_SI_540;
74921                         break;
74922 @@ -172,23 +186,42 @@ BOOLEAN sisfb_query_north_bridge_space(P
74923                 case SIS_730:
74924                         nbridge_id = PCI_DEVICE_ID_SI_730;
74925                         break;
74926 +#endif
74927 +#ifdef CONFIG_FB_SIS_315
74928                 case SIS_550:
74929                         nbridge_id = PCI_DEVICE_ID_SI_550;
74930                         break;
74931                 case SIS_650:
74932                         nbridge_id = PCI_DEVICE_ID_SI_650;
74933                         break;
74934 -               case SIS_740:                   
74935 +               case SIS_740:
74936                         nbridge_id = PCI_DEVICE_ID_SI_740;
74937                         break;
74938 +               case SIS_660:
74939 +                       nbridge_id = PCI_DEVICE_ID_SI_660;
74940 +                       break;
74941 +               case SIS_760:
74942 +                       nbridge_id = PCI_DEVICE_ID_SI_760;
74943 +                       break;
74944 +#endif
74945                 default:
74946                         nbridge_id = 0;
74947                         break;
74948                 }
74949  
74950 -               pdev = pci_find_device(PCI_VENDOR_ID_SI, nbridge_id, pdev);
74951 -               if (pdev)
74952 -                       valid_pdev = TRUE;
74953 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,74)
74954 +               pci_for_each_dev(pdev) {
74955 +#else
74956 +               while((pdev = pci_find_device(PCI_VENDOR_ID_SI, PCI_ANY_ID, pdev))) {
74957 +#endif
74958 +                       DPRINTK("Current: 0x%x, target: 0x%x\n",
74959 +                                       pdev->device, ivideo.chip_id);
74960 +                       if ((pdev->vendor == PCI_VENDOR_ID_SI)
74961 +                                       && (pdev->device == nbridge_id)) {
74962 +                               valid_pdev = TRUE;
74963 +                               break;
74964 +                       }
74965 +               }
74966         }
74967  
74968         if (!valid_pdev) {
74969 @@ -207,66 +240,291 @@ BOOLEAN sisfb_query_north_bridge_space(P
74970  
74971  /* ------------------ Internal helper routines ----------------- */
74972  
74973 -static void sisfb_search_mode(const char *name)
74974 +static BOOLEAN sisfb_verify_rate(struct sisfb_monitor *monitor, int mode_idx, int rate_idx, int rate)
74975  {
74976 -       int i = 0, j = 0;
74977 +       int htotal, vtotal;
74978 +       unsigned int dclock, hsync;
74979  
74980 -       if(name == NULL) {
74981 -          printk(KERN_ERR "sisfb: Internal error, using default mode.\n");
74982 -          sisfb_mode_idx = DEFAULT_MODE;
74983 -          return;
74984 +       if(!monitor->datavalid) return TRUE;
74985 +
74986 +       if(mode_idx < 0) return FALSE;
74987 +
74988 +       if(rate < (monitor->vmin - 1)) return FALSE;
74989 +       if(rate > (monitor->vmax + 1)) return FALSE;
74990 +
74991 +       if(sisfb_gettotalfrommode(&SiS_Pr, &sishw_ext, sisbios_mode[mode_idx].mode_no,
74992 +                                 &htotal, &vtotal, rate_idx)) {
74993 +               dclock = (htotal * vtotal * rate) / 1000;
74994 +               if(dclock > (monitor->dclockmax + 1000)) return FALSE;
74995 +               hsync = dclock / htotal;
74996 +               if(hsync < (monitor->hmin - 1)) return FALSE;
74997 +               if(hsync > (monitor->hmax + 1)) return FALSE;
74998 +        } else {
74999 +               return FALSE;
75000         }
75001 -               
75002 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)                
75003 -        if (!strcmp(name, sisbios_mode[MODE_INDEX_NONE].name)) {
75004 -          printk(KERN_ERR "sisfb: Mode 'none' not supported anymore. Using default.\n");
75005 -          sisfb_mode_idx = DEFAULT_MODE;
75006 -          return;
75007 +       return TRUE;
75008 +};
75009 +
75010 +static BOOLEAN sisfb_interpret_edid(struct sisfb_monitor *monitor, unsigned char *buffer)
75011 +{
75012 +       int i, j, xres, yres, refresh, index;
75013 +       u32 emodes;
75014 +
75015 +       if(buffer[0] != 0x00 || buffer[1] != 0xff ||
75016 +          buffer[2] != 0xff || buffer[3] != 0xff ||
75017 +          buffer[4] != 0xff || buffer[5] != 0xff ||
75018 +          buffer[6] != 0xff || buffer[7] != 0x00) {
75019 +          printk(KERN_DEBUG "sisfb: Bad EDID header\n");
75020 +          return FALSE;
75021         }
75022 -#endif         
75023  
75024 -       while(sisbios_mode[i].mode_no != 0) {
75025 -               if (!strcmp(name, sisbios_mode[i].name)) {
75026 -                       sisfb_mode_idx = i;
75027 -                       j = 1;
75028 -                       break;
75029 -               }
75030 -               i++;
75031 +       if(buffer[0x12] != 0x01) {
75032 +          printk(KERN_INFO "sisfb: EDID version %d not supported\n",
75033 +               buffer[0x12]);
75034 +          return FALSE;
75035 +       }
75036 +
75037 +       monitor->feature = buffer[0x18];
75038 +
75039 +       if(!buffer[0x14] & 0x80) {
75040 +          if(!(buffer[0x14] & 0x08)) {
75041 +             printk(KERN_INFO "sisfb: WARNING: Monitor does not support separate syncs\n");
75042 +          }
75043 +       }
75044 +
75045 +       if(buffer[0x13] >= 0x01) {
75046 +          /* EDID V1 rev 1 and 2: Search for monitor descriptor
75047 +           * to extract ranges
75048 +           */
75049 +           j = 0x36;
75050 +           for(i=0; i<4; i++) {
75051 +              if(buffer[j]     == 0x00 && buffer[j + 1] == 0x00 &&
75052 +                 buffer[j + 2] == 0x00 && buffer[j + 3] == 0xfd &&
75053 +                 buffer[j + 4] == 0x00) {
75054 +                 monitor->hmin = buffer[j + 7];
75055 +                 monitor->hmax = buffer[j + 8];
75056 +                 monitor->vmin = buffer[j + 5];
75057 +                 monitor->vmax = buffer[j + 6];
75058 +                 monitor->dclockmax = buffer[j + 9] * 10 * 1000;
75059 +                 monitor->datavalid = TRUE;
75060 +                 break;
75061 +              }
75062 +              j += 18;
75063 +           }
75064 +       }
75065 +
75066 +       if(!monitor->datavalid) {
75067 +          /* Otherwise: Get a range from the list of supported
75068 +           * Estabished Timings. This is not entirely accurate,
75069 +           * because fixed frequency monitors are not supported
75070 +           * that way.
75071 +           */
75072 +          monitor->hmin = 65535; monitor->hmax = 0;
75073 +          monitor->vmin = 65535; monitor->vmax = 0;
75074 +          monitor->dclockmax = 0;
75075 +          emodes = buffer[0x23] | (buffer[0x24] << 8) | (buffer[0x25] << 16);
75076 +          for(i = 0; i < 13; i++) {
75077 +             if(emodes & sisfb_ddcsmodes[i].mask) {
75078 +                if(monitor->hmin > sisfb_ddcsmodes[i].h) monitor->hmin = sisfb_ddcsmodes[i].h;
75079 +                if(monitor->hmax < sisfb_ddcsmodes[i].h) monitor->hmax = sisfb_ddcsmodes[i].h + 1;
75080 +                if(monitor->vmin > sisfb_ddcsmodes[i].v) monitor->vmin = sisfb_ddcsmodes[i].v;
75081 +                if(monitor->vmax < sisfb_ddcsmodes[i].v) monitor->vmax = sisfb_ddcsmodes[i].v;
75082 +                if(monitor->dclockmax < sisfb_ddcsmodes[i].d) monitor->dclockmax = sisfb_ddcsmodes[i].d;
75083 +             }
75084 +          }
75085 +          index = 0x26;
75086 +          for(i = 0; i < 8; i++) {
75087 +             xres = (buffer[index] + 31) * 8;
75088 +             switch(buffer[index + 1] & 0xc0) {
75089 +                case 0xc0: yres = (xres * 9) / 16; break;
75090 +                case 0x80: yres = (xres * 4) /  5; break;
75091 +                case 0x40: yres = (xres * 3) /  4; break;
75092 +                default:   yres = xres;            break;
75093 +             }
75094 +             refresh = (buffer[index + 1] & 0x3f) + 60;
75095 +             if((xres >= 640) && (yres >= 480)) {
75096 +                 for(j = 0; j < 8; j++) {
75097 +                   if((xres == sisfb_ddcfmodes[j].x) &&
75098 +                      (yres == sisfb_ddcfmodes[j].y) &&
75099 +                      (refresh == sisfb_ddcfmodes[j].v)) {
75100 +                     if(monitor->hmin > sisfb_ddcfmodes[j].h) monitor->hmin = sisfb_ddcfmodes[j].h;
75101 +                     if(monitor->hmax < sisfb_ddcfmodes[j].h) monitor->hmax = sisfb_ddcfmodes[j].h + 1;
75102 +                     if(monitor->vmin > sisfb_ddcsmodes[j].v) monitor->vmin = sisfb_ddcsmodes[j].v;
75103 +                     if(monitor->vmax < sisfb_ddcsmodes[j].v) monitor->vmax = sisfb_ddcsmodes[j].v;
75104 +                     if(monitor->dclockmax < sisfb_ddcsmodes[j].d) monitor->dclockmax = sisfb_ddcsmodes[i].d;
75105 +                   }
75106 +                }
75107 +             }
75108 +             index += 2;
75109 +           }
75110 +          if((monitor->hmin <= monitor->hmax) && (monitor->vmin <= monitor->vmax)) {
75111 +             monitor->datavalid = TRUE;
75112 +          }
75113 +       }
75114 +
75115 +       return(monitor->datavalid);
75116 +}
75117 +
75118 +static void sisfb_handle_ddc(struct sisfb_monitor *monitor, int crtno)
75119 +{
75120 +       USHORT        temp, i, realcrtno = crtno;
75121 +       unsigned char buffer[256];
75122 +
75123 +       monitor->datavalid = FALSE;
75124 +
75125 +       if(crtno) {
75126 +                  if(ivideo.vbflags & CRT2_LCD)      realcrtno = 1;
75127 +          else if(ivideo.vbflags & CRT2_VGA) realcrtno = 2;
75128 +          else return;
75129 +       }
75130 +
75131 +       if((sisfb_crt1off) && (!crtno)) return;
75132 +
75133 +       temp = SiS_HandleDDC(&SiS_Pr, ivideo.vbflags, sisvga_engine, realcrtno, 0, &buffer[0]);
75134 +       if((!temp) || (temp == 0xffff)) {
75135 +          printk(KERN_INFO "sisfb: CRT%d DDC probing failed\n", crtno + 1);
75136 +          return;
75137 +       } else {
75138 +          printk(KERN_INFO "sisfb: CRT%d DDC supported\n", crtno + 1);
75139 +          printk(KERN_INFO "sisfb: CRT%d DDC level: %s%s%s%s\n",
75140 +               crtno + 1,
75141 +               (temp & 0x1a) ? "" : "[none of the supported]",
75142 +               (temp & 0x02) ? "2 " : "",
75143 +               (temp & 0x08) ? "D&P" : "",
75144 +               (temp & 0x10) ? "FPDI-2" : "");
75145 +          if(temp & 0x02) {
75146 +             i = 3;  /* Number of retrys */
75147 +             do {
75148 +                temp = SiS_HandleDDC(&SiS_Pr, ivideo.vbflags, sisvga_engine,
75149 +                                    realcrtno, 1, &buffer[0]);
75150 +             } while((temp) && i--);
75151 +              if(!temp) {
75152 +                if(sisfb_interpret_edid(monitor, &buffer[0])) {
75153 +                   printk(KERN_INFO "sisfb: Monitor range H %d-%dKHz, V %d-%dHz, Max. dotclock %dMHz\n",
75154 +                       monitor->hmin, monitor->hmax, monitor->vmin, monitor->vmax,
75155 +                       monitor->dclockmax / 1000);
75156 +                } else {
75157 +                   printk(KERN_INFO "sisfb: CRT%d DDC EDID corrupt\n", crtno + 1);
75158 +                }
75159 +             } else {
75160 +                printk(KERN_INFO "sisfb: CRT%d DDC reading failed\n", crtno + 1);
75161 +             }
75162 +          } else {
75163 +             printk(KERN_INFO "sisfb: VESA D&P and FPDI-2 not supported yet\n");
75164 +          }
75165         }
75166 -       if(!j) printk(KERN_INFO "sisfb: Invalid mode '%s'\n", name);
75167  }
75168  
75169 -static void sisfb_search_vesamode(unsigned int vesamode)
75170 +static void sisfb_search_vesamode(unsigned int vesamode, BOOLEAN quiet)
75171  {
75172         int i = 0, j = 0;
75173  
75174         if(vesamode == 0) {
75175 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 
75176 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
75177                 sisfb_mode_idx = MODE_INDEX_NONE;
75178  #else
75179 -               printk(KERN_ERR "sisfb: Mode 'none' not supported anymore. Using default.\n");
75180 +               if(!quiet)
75181 +                  printk(KERN_ERR "sisfb: Mode 'none' not supported anymore. Using default.\n");
75182                 sisfb_mode_idx = DEFAULT_MODE;
75183 -#endif         
75184 +#endif
75185                 return;
75186         }
75187  
75188         vesamode &= 0x1dff;  /* Clean VESA mode number from other flags */
75189  
75190 +       while(sisbios_mode[i++].mode_no != 0) {
75191 +               if( (sisbios_mode[i-1].vesa_mode_no_1 == vesamode) ||
75192 +                   (sisbios_mode[i-1].vesa_mode_no_2 == vesamode) ) {
75193 +                   if(sisfb_fstn) {
75194 +                      if(sisbios_mode[i-1].mode_no == 0x50 ||
75195 +                         sisbios_mode[i-1].mode_no == 0x56 ||
75196 +                         sisbios_mode[i-1].mode_no == 0x53) continue;
75197 +                   } else {
75198 +                      if(sisbios_mode[i-1].mode_no == 0x5a ||
75199 +                         sisbios_mode[i-1].mode_no == 0x5b) continue;
75200 +                   }
75201 +                   sisfb_mode_idx = i - 1;
75202 +                   j = 1;
75203 +                   break;
75204 +               }
75205 +       }
75206 +       if((!j) && !quiet) printk(KERN_ERR "sisfb: Invalid VESA mode 0x%x'\n", vesamode);
75207 +}
75208 +
75209 +static void sisfb_search_mode(char *name, BOOLEAN quiet)
75210 +{
75211 +       int i = 0;
75212 +       unsigned int j = 0, xres = 0, yres = 0, depth = 0, rate = 0;
75213 +       char strbuf[16], strbuf1[20];
75214 +       char *nameptr = name;
75215 +
75216 +       if(name == NULL) {
75217 +          if(!quiet)
75218 +             printk(KERN_ERR "sisfb: Internal error, using default mode.\n");
75219 +          sisfb_mode_idx = DEFAULT_MODE;
75220 +          return;
75221 +       }
75222 +
75223 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
75224 +        if (!strnicmp(name, sisbios_mode[MODE_INDEX_NONE].name, strlen(name))) {
75225 +          if(!quiet)
75226 +             printk(KERN_ERR "sisfb: Mode 'none' not supported anymore. Using default.\n");
75227 +          sisfb_mode_idx = DEFAULT_MODE;
75228 +          return;
75229 +       }
75230 +#endif
75231 +       if(strlen(name) <= 19) {
75232 +          strcpy(strbuf1, name);
75233 +          for(i=0; i<strlen(strbuf1); i++) {
75234 +             if(strbuf1[i] < '0' || strbuf1[i] > '9') strbuf1[i] = ' ';
75235 +          }
75236 +
75237 +          /* This does some fuzzy mode naming detection */
75238 +          if(sscanf(strbuf1, "%u %u %u %u", &xres, &yres, &depth, &rate) == 4) {
75239 +             if((rate <= 32) || (depth > 32)) {
75240 +                j = rate; rate = depth; depth = j;
75241 +             }
75242 +             sprintf(strbuf, "%ux%ux%u", xres, yres, depth);
75243 +             nameptr = strbuf;
75244 +             ivideo.refresh_rate = sisfb_parm_rate = rate;
75245 +          } else if(sscanf(strbuf1, "%u %u %u", &xres, &yres, &depth) == 3) {
75246 +             sprintf(strbuf, "%ux%ux%u", xres, yres, depth);
75247 +             nameptr = strbuf;
75248 +          } else {
75249 +             xres = 0;
75250 +             if((sscanf(strbuf1, "%u %u", &xres, &yres) == 2) && (xres != 0)) {
75251 +                sprintf(strbuf, "%ux%ux8", xres, yres);
75252 +                nameptr = strbuf;
75253 +             } else {
75254 +                sisfb_search_vesamode(simple_strtoul(name, NULL, 0), quiet);
75255 +                return;
75256 +             }
75257 +          }
75258 +       }
75259 +
75260 +       i = 0; j = 0;
75261         while(sisbios_mode[i].mode_no != 0) {
75262 -               if( (sisbios_mode[i].vesa_mode_no_1 == vesamode) ||
75263 -                   (sisbios_mode[i].vesa_mode_no_2 == vesamode) ) {
75264 -                       sisfb_mode_idx = i;
75265 -                       j = 1;
75266 -                       break;
75267 +               if(!strnicmp(nameptr, sisbios_mode[i++].name, strlen(nameptr))) {
75268 +                  if(sisfb_fstn) {
75269 +                     if(sisbios_mode[i-1].mode_no == 0x50 ||
75270 +                        sisbios_mode[i-1].mode_no == 0x56 ||
75271 +                        sisbios_mode[i-1].mode_no == 0x53) continue;
75272 +                  } else {
75273 +                     if(sisbios_mode[i-1].mode_no == 0x5a ||
75274 +                        sisbios_mode[i-1].mode_no == 0x5b) continue;
75275 +                  }
75276 +                  sisfb_mode_idx = i - 1;
75277 +                  j = 1;
75278 +                  break;
75279                 }
75280 -               i++;
75281         }
75282 -       if(!j) printk(KERN_INFO "sisfb: Invalid VESA mode 0x%x'\n", vesamode);
75283 +       if((!j) && !quiet) printk(KERN_ERR "sisfb: Invalid mode '%s'\n", nameptr);
75284 +
75285  }
75286  
75287 -static int sisfb_validate_mode(int myindex)
75288 +static int sisfb_validate_mode(int myindex, unsigned long vbflags)
75289  {
75290 -   u16 xres, yres;
75291 +   u16 xres, yres, myres;
75292  
75293  #ifdef CONFIG_FB_SIS_300
75294     if(sisvga_engine == SIS_300_VGA) {
75295 @@ -283,8 +541,10 @@ static int sisfb_validate_mode(int myind
75296     }
75297  #endif
75298  
75299 -   switch (ivideo.disp_state & DISPTYPE_DISP2) {
75300 -     case DISPTYPE_LCD:
75301 +   myres = sisbios_mode[myindex].yres;
75302 +
75303 +   switch (vbflags & VB_DISPTYPE_DISP2) {
75304 +     case CRT2_LCD:
75305         switch (sishw_ext.ulCRT2LCDType) {
75306         case LCD_640x480:
75307                 xres =  640; yres =  480;  break;
75308 @@ -306,140 +566,209 @@ static int sisfb_validate_mode(int myind
75309                 xres = 1400; yres = 1050;  break;               
75310         case LCD_1600x1200:
75311                 xres = 1600; yres = 1200;  break;
75312 -       case LCD_320x480:                               /* TW: FSTN */
75313 +       case LCD_320x480:                               /* FSTN (old) */
75314                 xres =  320; yres =  480;  break;
75315 +       case LCD_640x480_2:                             /* FSTN (new) */
75316 +       case LCD_640x480_3:
75317 +               xres =  640; yres =  480;  break;
75318         default:
75319                 xres =    0; yres =    0;  break;
75320         }
75321 -       if(sisbios_mode[myindex].xres > xres) {
75322 -               return(-1);
75323 +
75324 +       if(SiS_Pr.SiS_CustomT == CUT_BARCO1366) {
75325 +               xres = 1360; yres = 1024;
75326         }
75327 -        if(sisbios_mode[myindex].yres > yres) {
75328 +
75329 +       if(SiS_Pr.SiS_CustomT == CUT_PANEL848) {
75330 +               xres = 848;  yres =  480;
75331 +       } else {
75332 +          if(sisbios_mode[myindex].xres > xres) {
75333 +               return(-1);
75334 +          }
75335 +           if(myres > yres) {
75336                 return(-1);
75337 +          }
75338         }
75339 -       if((sishw_ext.usExternalChip == 0x01) ||   /* LVDS */
75340 -           (sishw_ext.usExternalChip == 0x05) ||   /* LVDS+Chrontel */
75341 -          (sishw_ext.Is301BDH)) {                 /* 301B-DH */
75342 +
75343 +       if(vbflags & (VB_LVDS | VB_30xBDH)) {
75344            switch (sisbios_mode[myindex].xres) {
75345 +               case 320:
75346 +                       if((myres != 200) && (myres != 240))
75347 +                               return(-1);
75348 +                       if((myres == 240) || (myres == 480)) {
75349 +                               if(!sisfb_fstn) {
75350 +                                  if(sisbios_mode[myindex].mode_no == 0x5a ||
75351 +                                     sisbios_mode[myindex].mode_no == 0x5b)
75352 +                                       return(-1);
75353 +                               } else {
75354 +                                  if(sisbios_mode[myindex].mode_no == 0x50 ||
75355 +                                     sisbios_mode[myindex].mode_no == 0x56 ||
75356 +                                     sisbios_mode[myindex].mode_no == 0x53)
75357 +                                       return(-1);
75358 +                               }
75359 +                       }
75360 +                       if(SiS_Pr.SiS_CustomT == CUT_PANEL848) return(-1);
75361 +                       break;
75362 +               case 400:
75363 +                       if(myres != 300) return(-1);
75364 +                       if(SiS_Pr.SiS_CustomT == CUT_PANEL848) return(-1);
75365 +                       break;
75366                 case 512:
75367 -                       if(sisbios_mode[myindex].yres != 512) return -1;
75368 -                       if(sishw_ext.ulCRT2LCDType == LCD_1024x600) return -1;
75369 +                       if(myres != 384) return(-1);
75370 +                       if(sishw_ext.ulCRT2LCDType == LCD_1024x600) return(-1);
75371 +                       if(SiS_Pr.SiS_CustomT == CUT_PANEL848) return(-1);
75372                         break;
75373                 case 640:
75374 -                       if((sisbios_mode[myindex].yres != 400) &&
75375 -                          (sisbios_mode[myindex].yres != 480))
75376 +                       if((myres != 400) && (myres != 480))
75377                                 return -1;
75378 +                       if(SiS_Pr.SiS_CustomT == CUT_PANEL848) {
75379 +                          if(myres == 400)
75380 +                               return(-1);
75381 +                       }
75382                         break;
75383                 case 800:
75384 -                       if(sisbios_mode[myindex].yres != 600) return -1;
75385 +                       if(myres != 600) return(-1);
75386 +                       break;
75387 +               case 848:
75388 +                       if(SiS_Pr.SiS_CustomT != CUT_PANEL848) return(-1);
75389 +                       if(myres != 480) return(-1);
75390                         break;
75391                 case 1024:
75392 -                       if((sisbios_mode[myindex].yres != 600) &&
75393 -                          (sisbios_mode[myindex].yres != 768))
75394 -                               return -1;
75395 -                       if((sisbios_mode[myindex].yres == 600) &&
75396 +                       if((myres != 600) && (myres != 768))
75397 +                               return(-1);
75398 +                       if((myres == 600) &&
75399                            (sishw_ext.ulCRT2LCDType != LCD_1024x600))
75400 -                               return -1;
75401 +                               return(-1);
75402                         break;
75403                 case 1152:
75404 -                       if((sisbios_mode[myindex].yres) != 768) return -1;
75405 -                       if(sishw_ext.ulCRT2LCDType != LCD_1152x768) return -1;
75406 +                       if(myres != 768) return(-1);
75407 +                       if(sishw_ext.ulCRT2LCDType != LCD_1152x768) return(-1);
75408                         break;
75409                 case 1280:
75410 -                       if((sisbios_mode[myindex].yres != 768) &&
75411 -                          (sisbios_mode[myindex].yres != 1024))
75412 -                               return -1;
75413 -                       if((sisbios_mode[myindex].yres == 768) &&
75414 +                       if((myres != 768) && (myres != 1024))
75415 +                               return(-1);
75416 +                       if((myres == 768) &&
75417                            (sishw_ext.ulCRT2LCDType != LCD_1280x768))
75418 -                               return -1;                              
75419 +                               return(-1);
75420 +                       if(SiS_Pr.SiS_CustomT == CUT_PANEL848) return(-1);
75421 +                       break;
75422 +               case 1360:
75423 +                       if(SiS_Pr.SiS_CustomT != CUT_BARCO1366) return(-1);
75424 +                       if(myres != 1024) return(-1);
75425                         break;
75426                 case 1400:
75427 -                       if(sisbios_mode[myindex].yres != 1050) return -1;
75428 +                       if(myres != 1050) return(-1);
75429 +                       if(SiS_Pr.SiS_CustomT == CUT_PANEL848) return(-1);
75430                         break;
75431                 case 1600:
75432 -                       if(sisbios_mode[myindex].yres != 1200) return -1;
75433 +                       if(myres != 1200) return(-1);
75434 +                       if(SiS_Pr.SiS_CustomT == CUT_PANEL848) return(-1);
75435                         break;
75436                 default:
75437 -                       return -1;              
75438 +                       return(-1);
75439            }
75440         } else {
75441            switch (sisbios_mode[myindex].xres) {
75442 +               case 320:
75443 +                       if((myres != 200) && (myres != 240))
75444 +                               return -1;
75445 +                       break;
75446 +               case 400:
75447 +                       if(myres != 300) return(-1);
75448 +                       break;
75449                 case 512:
75450 -                       if(sisbios_mode[myindex].yres != 512) return -1;
75451 +                       if(myres != 384) return(-1);
75452                         break;
75453                 case 640:
75454 -                       if((sisbios_mode[myindex].yres != 400) &&
75455 -                          (sisbios_mode[myindex].yres != 480))
75456 -                               return -1;
75457 +                       if((myres != 400) && (myres != 480))
75458 +                               return(-1);
75459                         break;
75460                 case 800:
75461 -                       if(sisbios_mode[myindex].yres != 600) return -1;
75462 +                       if(myres != 600) return(-1);
75463                         break;
75464                 case 1024:
75465 -                       if(sisbios_mode[myindex].yres != 768) return -1;
75466 +                       if(myres != 768) return(-1);
75467                         break;
75468                 case 1280:
75469 -                       if((sisbios_mode[myindex].yres != 960) &&
75470 -                          (sisbios_mode[myindex].yres != 1024))
75471 -                               return -1;
75472 -                       if(sisbios_mode[myindex].yres == 960) {
75473 -                           if(sishw_ext.ulCRT2LCDType == LCD_1400x1050) 
75474 -                               return -1;
75475 +                       if((myres != 960) && (myres != 768) && (myres != 1024))
75476 +                               return(-1);
75477 +                       if((myres == 768) || (myres == 960)) {
75478 +                               if(sishw_ext.ulCRT2LCDType == LCD_1400x1050)
75479 +                                       return(-1);
75480 +                       }
75481 +                       if(myres == 768) {
75482 +                               if(sishw_ext.ulCRT2LCDType == LCD_1280x960)
75483 +                                       return(-1);
75484                         }
75485                         break;
75486                 case 1400:
75487 -                       if(sisbios_mode[myindex].yres != 1050) return -1;
75488 +                       if(myres != 1050) return(-1);
75489                         break;
75490                 case 1600:
75491 -                       if(sisbios_mode[myindex].yres != 1200) return -1;
75492 +                       if(myres != 1200) return(-1);
75493                         break;
75494                 default:
75495 -                       return -1;              
75496 +                       return(-1);
75497            }
75498         }
75499         break;
75500 -     case DISPTYPE_TV:
75501 +
75502 +     case CRT2_TV:
75503         switch (sisbios_mode[myindex].xres) {
75504 +       case 320:
75505 +               if(vbflags & VB_CHRONTEL) return(-1);
75506 +               if((myres != 200) && (myres != 240))
75507 +                       return(-1);
75508 +               break;
75509 +       case 400:
75510 +               if(vbflags & VB_CHRONTEL) return(-1);
75511 +               if(myres != 300) return(-1);
75512 +               break;
75513         case 512:
75514 +               if(vbflags & VB_CHRONTEL) return(-1);
75515 +               if((vbflags & VB_SISBRIDGE) && (vbflags & TV_NTSC))
75516 +                       return(-1);
75517 +               if(myres != 384) return(-1);
75518 +               break;
75519         case 640:
75520 -       case 800:
75521 +               if((myres != 400) && (myres != 480))
75522 +                       return(-1);
75523 +               if((vbflags & VB_CHRONTEL) && (myres == 400))
75524 +                       return(-1);
75525                 break;
75526         case 720:
75527 -               if (ivideo.TV_type == TVMODE_NTSC) {
75528 -                       if (sisbios_mode[myindex].yres != 480) {
75529 -                               return(-1);
75530 -                       }
75531 -               } else if (ivideo.TV_type == TVMODE_PAL) {
75532 -                       if (sisbios_mode[myindex].yres != 576) {
75533 -                               return(-1);
75534 -                       }
75535 -               }
75536 -               /* TW: LVDS/CHRONTEL does not support 720 */
75537 -               if (ivideo.hasVB == HASVB_LVDS_CHRONTEL ||
75538 -                                       ivideo.hasVB == HASVB_CHRONTEL) {
75539 -                               return(-1);
75540 -               }
75541 +               if(vbflags & VB_CHRONTEL) return(-1);
75542 +               if((vbflags & TV_NTSC) && (myres != 480))
75543 +                       return(-1);
75544 +               if((vbflags & TV_PAL) && (myres != 576))
75545 +                       return(-1);
75546 +               break;
75547 +       case 768:
75548 +               if(vbflags & VB_CHRONTEL) return(-1);
75549 +               if(!(vbflags & TV_PAL)) return(-1);
75550 +               if(myres != 576) return(-1);
75551 +               break;
75552 +       case 800:
75553 +               if(myres != 600) return(-1);
75554                 break;
75555         case 1024:
75556 -               if (ivideo.TV_type == TVMODE_NTSC) {
75557 -                       if(sisbios_mode[myindex].bpp == 32) {
75558 -                              return(-1);
75559 -                       }
75560 -               }
75561 -               /* TW: LVDS/CHRONTEL only supports < 800 (1024 on 650/Ch7019)*/
75562 -               if (ivideo.hasVB == HASVB_LVDS_CHRONTEL ||
75563 -                                       ivideo.hasVB == HASVB_CHRONTEL) {
75564 -                   if(ivideo.chip < SIS_315H) {
75565 +               if(vbflags & VB_301) return(-1);
75566 +               if(vbflags & VB_CHRONTEL) {
75567 +                       if(ivideo.chip < SIS_315H) {
75568                                 return(-1);
75569 -                   }
75570 +                       }
75571                 }
75572                 break;
75573         default:
75574                 return(-1);
75575         }
75576         break;
75577 -     case DISPTYPE_CRT2:       
75578 -        if(sisbios_mode[myindex].xres > 1280) return -1;
75579 +
75580 +     case CRT2_VGA:
75581 +        if(sisbios_mode[myindex].xres > 1600) return(-1);
75582 +       if(!(vbflags & (VB_301B|VB_302B))) {
75583 +          if(sisbios_mode[myindex].xres > 1400) return(-1);
75584 +       }
75585         break;  
75586       }
75587       return(myindex);
75588 @@ -453,15 +782,20 @@ static void sisfb_search_crt2type(const 
75589                 return;
75590  
75591         while(sis_crt2type[i].type_no != -1) {
75592 -               if (!strcmp(name, sis_crt2type[i].name)) {
75593 +               if (!strnicmp(name, sis_crt2type[i].name, strlen(sis_crt2type[i].name))) {
75594                         sisfb_crt2type = sis_crt2type[i].type_no;
75595                         sisfb_tvplug = sis_crt2type[i].tvplug_no;
75596 +                       sisfb_dstn = (sis_crt2type[i].flags & FL_550_DSTN) ? 1 : 0;
75597 +                       sisfb_fstn = (sis_crt2type[i].flags & FL_550_FSTN) ? 1 : 0;
75598                         break;
75599                 }
75600                 i++;
75601         }
75602         if(sisfb_crt2type < 0)
75603 -               printk(KERN_INFO "sisfb: Invalid CRT2 type: %s\n", name);
75604 +               printk(KERN_ERR "sisfb: Invalid CRT2 type: %s\n", name);
75605 +        if(ivideo.chip != SIS_550) {
75606 +          sisfb_dstn = sisfb_fstn = 0;
75607 +       }
75608  }
75609  
75610  static void sisfb_search_queuemode(const char *name)
75611 @@ -472,23 +806,23 @@ static void sisfb_search_queuemode(const
75612                 return;
75613  
75614         while (sis_queuemode[i].type_no != -1) {
75615 -               if (!strcmp(name, sis_queuemode[i].name)) {
75616 +               if (!strnicmp(name, sis_queuemode[i].name, strlen(sis_queuemode[i].name))) {
75617                         sisfb_queuemode = sis_queuemode[i].type_no;
75618                         break;
75619                 }
75620                 i++;
75621         }
75622         if (sisfb_queuemode < 0)
75623 -               printk(KERN_INFO "sisfb: Invalid queuemode type: %s\n", name);
75624 +               printk(KERN_ERR "sisfb: Invalid queuemode type: %s\n", name);
75625  }
75626  
75627 -static u8 sisfb_search_refresh_rate(unsigned int rate)
75628 +static u8 sisfb_search_refresh_rate(unsigned int rate, int mode_idx)
75629  {
75630         u16 xres, yres;
75631         int i = 0;
75632  
75633 -       xres = sisbios_mode[sisfb_mode_idx].xres;
75634 -       yres = sisbios_mode[sisfb_mode_idx].yres;
75635 +       xres = sisbios_mode[mode_idx].xres;
75636 +       yres = sisbios_mode[mode_idx].yres;
75637  
75638         sisfb_rate_idx = 0;
75639         while ((sisfb_vrate[i].idx != 0) && (sisfb_vrate[i].xres <= xres)) {
75640 @@ -536,23 +870,60 @@ static void sisfb_search_tvstd(const cha
75641                 return;
75642  
75643         while (sis_tvtype[i].type_no != -1) {
75644 -               if (!strcmp(name, sis_tvtype[i].name)) {
75645 -                       sisfb_tvmode = sis_tvtype[i].type_no;
75646 +               if (!strnicmp(name, sis_tvtype[i].name, strlen(sis_tvtype[i].name))) {
75647 +                       ivideo.vbflags |= sis_tvtype[i].type_no;
75648                         break;
75649                 }
75650                 i++;
75651         }
75652  }
75653  
75654 +static void sisfb_search_specialtiming(const char *name)
75655 +{
75656 +       int i = 0;
75657 +       BOOLEAN found = FALSE;
75658 +
75659 +       if(name == NULL)
75660 +               return;
75661 +
75662 +       if(!strnicmp(name, "none", 4)) {
75663 +               SiS_Pr.SiS_CustomT = CUT_FORCENONE;
75664 +               printk(KERN_DEBUG "sisfb: Special timing disabled\n");
75665 +       } else {
75666 +          while(mycustomttable[i].chipID != 0) {
75667 +             if(!strnicmp(name,mycustomttable[i].optionName, strlen(mycustomttable[i].optionName))) {
75668 +                SiS_Pr.SiS_CustomT = mycustomttable[i].SpecialID;
75669 +                found = TRUE;
75670 +                printk(KERN_INFO "sisfb: Special timing for %s %s forced\n",
75671 +                mycustomttable[i].vendorName, mycustomttable[i].cardName);
75672 +                break;
75673 +             }
75674 +             i++;
75675 +          }
75676 +          if(!found) {
75677 +             printk(KERN_WARNING "sisfb: Invalid SpecialTiming parameter, valid are:");
75678 +             printk(KERN_WARNING "\t\"none\" (to disable special timings)\n");
75679 +             i = 0;
75680 +             while(mycustomttable[i].chipID != 0) {
75681 +                printk(KERN_WARNING "\t\"%s\" (for %s %s)\n",
75682 +                    mycustomttable[i].optionName,
75683 +                    mycustomttable[i].vendorName,
75684 +                    mycustomttable[i].cardName);
75685 +                i++;
75686 +             }
75687 +           }
75688 +       }
75689 +}
75690 +
75691  static BOOLEAN sisfb_bridgeisslave(void)
75692  {
75693 -   unsigned char usScratchP1_00;
75694 +   unsigned char P1_00;
75695  
75696 -   if(ivideo.hasVB == HASVB_NONE) return FALSE;
75697 +   if(!(ivideo.vbflags & VB_VIDEOBRIDGE)) return FALSE;
75698  
75699 -   inSISIDXREG(SISPART1,0x00,usScratchP1_00);
75700 -   if( ((sisvga_engine == SIS_300_VGA) && (usScratchP1_00 & 0xa0) == 0x20) ||
75701 -       ((sisvga_engine == SIS_315_VGA) && (usScratchP1_00 & 0x50) == 0x10) ) {
75702 +   inSISIDXREG(SISPART1,0x00,P1_00);
75703 +   if( ((sisvga_engine == SIS_300_VGA) && (P1_00 & 0xa0) == 0x20) ||
75704 +       ((sisvga_engine == SIS_315_VGA) && (P1_00 & 0x50) == 0x10) ) {
75705            return TRUE;
75706     } else {
75707             return FALSE;
75708 @@ -597,7 +968,7 @@ static BOOLEAN sisfbcheckvretracecrt2(vo
75709  
75710  static BOOLEAN sisfb_CheckVBRetrace(void) 
75711  {
75712 -   if(ivideo.disp_state & DISPTYPE_DISP2) {
75713 +   if(ivideo.currentvbflags & VB_DISPTYPE_DISP2) {
75714        if(sisfb_bridgeisslave()) {
75715           return(sisfbcheckvretracecrt1());
75716        } else {
75717 @@ -607,60 +978,195 @@ static BOOLEAN sisfb_CheckVBRetrace(void
75718     return(sisfbcheckvretracecrt1());
75719  }
75720  
75721 +static int sisfb_myblank(int blank)
75722 +{
75723 +   u8 sr01, sr11, sr1f, cr63=0, p2_0, p1_13;
75724 +   BOOLEAN backlight = TRUE;
75725 +
75726 +   switch(blank) {
75727 +   case 0:     /* on */
75728 +      sr01  = 0x00;
75729 +      sr11  = 0x00;
75730 +      sr1f  = 0x00;
75731 +      cr63  = 0x00;
75732 +      p2_0  = 0x20;
75733 +      p1_13 = 0x00;
75734 +      backlight = TRUE;
75735 +      break;
75736 +   case 1:     /* blank */
75737 +      sr01  = 0x20;
75738 +      sr11  = 0x00;
75739 +      sr1f  = 0x00;
75740 +      cr63  = 0x00;
75741 +      p2_0  = 0x20;
75742 +      p1_13 = 0x00;
75743 +      backlight = TRUE;
75744 +      break;
75745 +   case 2:     /* no vsync */
75746 +      sr01  = 0x20;
75747 +      sr11  = 0x08;
75748 +      sr1f  = 0x80;
75749 +      cr63  = 0x40;
75750 +      p2_0  = 0x40;
75751 +      p1_13 = 0x80;
75752 +      backlight = FALSE;
75753 +      break;
75754 +   case 3:     /* no hsync */
75755 +      sr01  = 0x20;
75756 +      sr11  = 0x08;
75757 +      sr1f  = 0x40;
75758 +      cr63  = 0x40;
75759 +      p2_0  = 0x80;
75760 +      p1_13 = 0x40;
75761 +      backlight = FALSE;
75762 +      break;
75763 +   case 4:     /* off */
75764 +      sr01  = 0x20;
75765 +      sr11  = 0x08;
75766 +      sr1f  = 0xc0;
75767 +      cr63  = 0x40;
75768 +      p2_0  = 0xc0;
75769 +      p1_13 = 0xc0;
75770 +      backlight = FALSE;
75771 +      break;
75772 +   default:
75773 +      return 1;
75774 +   }
75775 +
75776 +   if(ivideo.currentvbflags & VB_DISPTYPE_CRT1) {
75777 +
75778 +      setSISIDXREG(SISSR, 0x01, ~0x20, sr01);
75779 +
75780 +      if( (!sisfb_thismonitor.datavalid) ||
75781 +          ((sisfb_thismonitor.datavalid) &&
75782 +           (sisfb_thismonitor.feature & 0xe0))) {
75783 +
75784 +        if(sisvga_engine == SIS_315_VGA) {
75785 +           setSISIDXREG(SISCR, 0x63, 0xbf, cr63);
75786 +        }
75787 +
75788 +        setSISIDXREG(SISSR, 0x1f, 0x3f, sr1f);
75789 +      }
75790 +
75791 +   }
75792 +
75793 +   if(ivideo.currentvbflags & CRT2_LCD) {
75794 +
75795 +      if(ivideo.vbflags & (VB_301LV|VB_302LV)) {
75796 +        if(backlight) {
75797 +           SiS_SiS30xBLOn(&SiS_Pr, &sishw_ext);
75798 +        } else {
75799 +           SiS_SiS30xBLOff(&SiS_Pr, &sishw_ext);
75800 +        }
75801 +      } else if(sisvga_engine == SIS_315_VGA) {
75802 +        if(ivideo.vbflags & VB_CHRONTEL) {
75803 +           if(backlight) {
75804 +              SiS_Chrontel701xBLOn(&SiS_Pr,&sishw_ext);
75805 +           } else {
75806 +              SiS_Chrontel701xBLOff(&SiS_Pr);
75807 +           }
75808 +        }
75809 +      }
75810 +
75811 +      if(((sisvga_engine == SIS_300_VGA) &&
75812 +          (ivideo.vbflags & (VB_301|VB_30xBDH|VB_LVDS))) ||
75813 +         ((sisvga_engine == SIS_315_VGA) &&
75814 +          ((ivideo.vbflags & (VB_LVDS | VB_CHRONTEL)) == VB_LVDS))) {
75815 +          setSISIDXREG(SISSR, 0x11, ~0x0c, sr11);
75816 +      }
75817 +
75818 +      if(sisvga_engine == SIS_300_VGA) {
75819 +         if((ivideo.vbflags & (VB_301B|VB_302B)) &&
75820 +            (!(ivideo.vbflags & VB_30xBDH))) {
75821 +           setSISIDXREG(SISPART1, 0x13, 0x3f, p1_13);
75822 +        }
75823 +      } else if(sisvga_engine == SIS_315_VGA) {
75824 +         if((ivideo.vbflags & (VB_301B|VB_302B)) &&
75825 +            (!(ivideo.vbflags & VB_30xBDH))) {
75826 +           setSISIDXREG(SISPART2, 0x00, 0x1f, p2_0);
75827 +        }
75828 +      }
75829 +
75830 +   } else if(ivideo.currentvbflags & CRT2_VGA) {
75831 +
75832 +      if(ivideo.vbflags & (VB_301B|VB_302B)) {
75833 +         setSISIDXREG(SISPART2, 0x00, 0x1f, p2_0);
75834 +      }
75835 +
75836 +   }
75837 +
75838 +   return(0);
75839 +}
75840 +
75841  /* ----------- FBDev related routines for all series ----------- */
75842  
75843 +static void sisfb_set_vparms(void)
75844 +{
75845 +   switch(ivideo.video_bpp) {
75846 +   case 8:
75847 +               ivideo.DstColor = 0x0000;
75848 +       ivideo.SiS310_AccelDepth = 0x00000000;
75849 +       ivideo.video_cmap_len = 256;
75850 +               break;
75851 +   case 16:
75852 +               ivideo.DstColor = 0x8000;
75853 +               ivideo.SiS310_AccelDepth = 0x00010000;
75854 +       ivideo.video_cmap_len = 16;
75855 +               break;
75856 +   case 32:
75857 +               ivideo.DstColor = 0xC000;
75858 +       ivideo.SiS310_AccelDepth = 0x00020000;
75859 +       ivideo.video_cmap_len = 16;
75860 +               break;
75861 +   default:
75862 +       ivideo.video_cmap_len = 16;
75863 +       printk(KERN_ERR "sisfb: Unsupported depth %d", ivideo.video_bpp);
75864 +       ivideo.accel = 0;
75865 +       break;
75866 +   }
75867 +}
75868 +
75869  static int sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
75870                       struct fb_info *info)
75871  {
75872 -       unsigned int htotal =
75873 -               var->left_margin + var->xres + var->right_margin +
75874 -               var->hsync_len;
75875 -       unsigned int vtotal = 0; 
75876 +       unsigned int htotal = 0, vtotal = 0;
75877         double drate = 0, hrate = 0;
75878         int found_mode = 0;
75879         int old_mode;
75880 -       unsigned char reg;
75881 +       u32 pixclock;
75882  
75883 -       TWDEBUG("Inside do_set_var");
75884 -       
75885 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 
75886 -       inSISIDXREG(SISCR,0x34,reg);
75887 -       if(reg & 0x80) {
75888 -          printk(KERN_INFO "sisfb: Cannot change display mode, X server is active\n");
75889 -          return -EBUSY;
75890 -       }
75891 -#endif 
75892 +       htotal = var->left_margin + var->xres + var->right_margin + var->hsync_len;
75893 +
75894 +       vtotal = var->upper_margin + var->lower_margin + var->vsync_len;
75895 +
75896 +       pixclock = var->pixclock;
75897  
75898         if((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) {
75899 -               vtotal = var->upper_margin + var->yres + var->lower_margin +
75900 -                        var->vsync_len;
75901 +               vtotal += var->yres;
75902                 vtotal <<= 1;
75903         } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
75904 -               vtotal = var->upper_margin + var->yres + var->lower_margin +
75905 -                        var->vsync_len;
75906 +               vtotal += var->yres;
75907                 vtotal <<= 2;
75908         } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
75909 -               vtotal = var->upper_margin + (var->yres/2) + var->lower_margin +
75910 -                        var->vsync_len; 
75911 -       } else  vtotal = var->upper_margin + var->yres + var->lower_margin +
75912 -                        var->vsync_len;
75913 +               vtotal += var->yres;
75914 +               vtotal <<= 1;
75915 +       } else  vtotal += var->yres;
75916  
75917         if(!(htotal) || !(vtotal)) {
75918                 DPRINTK("sisfb: Invalid 'var' information\n");
75919                 return -EINVAL;
75920         }
75921  
75922 -       if(var->pixclock && htotal && vtotal) {
75923 -          drate = 1E12 / var->pixclock;
75924 +       if(pixclock && htotal && vtotal) {
75925 +          drate = 1E12 / pixclock;
75926            hrate = drate / htotal;
75927            ivideo.refresh_rate = (unsigned int) (hrate / vtotal * 2 + 0.5);
75928         } else ivideo.refresh_rate = 60;
75929  
75930 -       /* TW: Calculation wrong for 1024x600 - force it to 60Hz */
75931 -       if((var->xres == 1024) && (var->yres == 600)) ivideo.refresh_rate = 60;
75932 -
75933 +#if 0
75934         printk(KERN_DEBUG "sisfb: Change mode to %dx%dx%d-%dHz\n",
75935                 var->xres,var->yres,var->bits_per_pixel,ivideo.refresh_rate);
75936 +#endif
75937  
75938         old_mode = sisfb_mode_idx;
75939         sisfb_mode_idx = 0;
75940 @@ -678,7 +1184,7 @@ static int sisfb_do_set_var(struct fb_va
75941         }
75942  
75943         if(found_mode)
75944 -               sisfb_mode_idx = sisfb_validate_mode(sisfb_mode_idx);
75945 +               sisfb_mode_idx = sisfb_validate_mode(sisfb_mode_idx, ivideo.currentvbflags);
75946         else
75947                 sisfb_mode_idx = -1;
75948  
75949 @@ -689,12 +1195,21 @@ static int sisfb_do_set_var(struct fb_va
75950                 return -EINVAL;
75951         }
75952  
75953 -       if(sisfb_search_refresh_rate(ivideo.refresh_rate) == 0) {
75954 +       if(sisfb_search_refresh_rate(ivideo.refresh_rate, sisfb_mode_idx) == 0) {
75955                 sisfb_rate_idx = sisbios_mode[sisfb_mode_idx].rate_idx;
75956                 ivideo.refresh_rate = 60;
75957         }
75958  
75959  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
75960 +       if(sisfb_thismonitor.datavalid) {
75961 +          if(!sisfb_verify_rate(&sisfb_thismonitor, sisfb_mode_idx,
75962 +                                sisfb_rate_idx, ivideo.refresh_rate)) {
75963 +             printk(KERN_INFO "sisfb: WARNING: Refresh rate exceeds monitor specs!\n");
75964 +          }
75965 +       }
75966 +#endif
75967 +
75968 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
75969         if(((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) && isactive) {
75970  #else
75971         if(isactive) {
75972 @@ -708,14 +1223,6 @@ static int sisfb_do_set_var(struct fb_va
75973  
75974                 outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD);
75975  
75976 -               sisfb_post_setmode();
75977 -
75978 -               DPRINTK("sisfb: Set new mode: %dx%dx%d-%d \n",
75979 -                       sisbios_mode[sisfb_mode_idx].xres,
75980 -                       sisbios_mode[sisfb_mode_idx].yres,
75981 -                       sisbios_mode[sisfb_mode_idx].bpp,
75982 -                       ivideo.refresh_rate);
75983 -
75984                 ivideo.video_bpp = sisbios_mode[sisfb_mode_idx].bpp;
75985                 ivideo.video_vwidth = ivideo.video_width = sisbios_mode[sisfb_mode_idx].xres;
75986                 ivideo.video_vheight = ivideo.video_height = sisbios_mode[sisfb_mode_idx].yres;
75987 @@ -725,53 +1232,38 @@ static int sisfb_do_set_var(struct fb_va
75988                 if(sisfb_accel) {
75989                    ivideo.accel = (var->accel_flags & FB_ACCELF_TEXT) ? -1 : 0;
75990                 }
75991 -               switch(ivideo.video_bpp) {
75992 -               case 8:
75993 -                       ivideo.DstColor = 0x0000;
75994 -                       ivideo.SiS310_AccelDepth = 0x00000000;
75995 -                       ivideo.video_cmap_len = 256;
75996 -                       break;
75997 -               case 16:
75998 -                       ivideo.DstColor = 0x8000;
75999 -                       ivideo.SiS310_AccelDepth = 0x00010000;
76000 -                       ivideo.video_cmap_len = 16;
76001 -                       break;
76002 -               case 32:
76003 -                       ivideo.DstColor = 0xC000;
76004 -                       ivideo.SiS310_AccelDepth = 0x00020000;
76005 -                       ivideo.video_cmap_len = 16;
76006 -                       break;
76007 -               default:
76008 -                       ivideo.video_cmap_len = 16;
76009 -                       printk(KERN_ERR "sisfb: Unsupported depth %d", ivideo.video_bpp);
76010 -                       ivideo.accel = 0;
76011 -                       break;
76012 -               }
76013 +
76014 +               sisfb_set_vparms();
76015 +
76016 +               ivideo.current_width = ivideo.video_width;
76017 +               ivideo.current_height = ivideo.video_height;
76018 +               ivideo.current_bpp = ivideo.video_bpp;
76019 +               ivideo.current_htotal = htotal;
76020 +               ivideo.current_vtotal = vtotal;
76021 +               ivideo.current_pixclock = var->pixclock;
76022 +               ivideo.current_refresh_rate = ivideo.refresh_rate;
76023 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
76024 +                sisfb_lastrates[sisfb_mode_no] = ivideo.refresh_rate;
76025 +#endif
76026 +
76027 +               sisfb_post_setmode();
76028  
76029         }
76030 -       TWDEBUG("End of do_set_var");
76031         return 0;
76032  }
76033  
76034 -#ifdef SISFB_PAN
76035  static int sisfb_pan_var(struct fb_var_screeninfo *var)
76036  {
76037         unsigned int base;
76038  
76039 -       TWDEBUG("Inside pan_var");
76040 -       
76041         if (var->xoffset > (var->xres_virtual - var->xres)) {
76042 -               printk(KERN_INFO "Pan: xo: %d xv %d xr %d\n",
76043 -                       var->xoffset, var->xres_virtual, var->xres);
76044                 return -EINVAL;
76045         }
76046         if(var->yoffset > (var->yres_virtual - var->yres)) {
76047 -               printk(KERN_INFO "Pan: yo: %d yv %d yr %d\n",
76048 -                       var->yoffset, var->yres_virtual, var->yres);
76049                 return -EINVAL;
76050         }
76051  
76052 -        base = var->yoffset * var->xres_virtual + var->xoffset;
76053 +       base = var->yoffset * var->xres_virtual + var->xoffset;
76054  
76055          /* calculate base bpp dep. */
76056          switch(var->bits_per_pixel) {
76057 @@ -794,7 +1286,7 @@ static int sisfb_pan_var(struct fb_var_s
76058         if(sisvga_engine == SIS_315_VGA) {
76059                 setSISIDXREG(SISSR, 0x37, 0xFE, (base >> 24) & 0x01);
76060         }
76061 -        if(ivideo.disp_state & DISPTYPE_DISP2) {
76062 +        if(ivideo.currentvbflags & VB_DISPTYPE_DISP2) {
76063                 orSISIDXREG(SISPART1, sisfb_CRT2_write_enable, 0x01);
76064                 outSISIDXREG(SISPART1, 0x06, (base & 0xFF));
76065                 outSISIDXREG(SISPART1, 0x05, ((base >> 8) & 0xFF));
76066 @@ -803,10 +1295,8 @@ static int sisfb_pan_var(struct fb_var_s
76067                         setSISIDXREG(SISPART1, 0x02, 0x7F, ((base >> 24) & 0x01) << 7);
76068                 }
76069          }
76070 -       TWDEBUG("End of pan_var");
76071         return 0;
76072  }
76073 -#endif
76074  
76075  static void sisfb_bpp_to_var(struct fb_var_screeninfo *var)
76076  {
76077 @@ -843,22 +1333,24 @@ static void sisfb_bpp_to_var(struct fb_v
76078  
76079  void sis_dispinfo(struct ap_data *rec)
76080  {
76081 -       rec->minfo.bpp    = ivideo.video_bpp;
76082 -       rec->minfo.xres   = ivideo.video_width;
76083 -       rec->minfo.yres   = ivideo.video_height;
76084 -       rec->minfo.v_xres = ivideo.video_vwidth;
76085 -       rec->minfo.v_yres = ivideo.video_vheight;
76086 -       rec->minfo.org_x  = ivideo.org_x;
76087 -       rec->minfo.org_y  = ivideo.org_y;
76088 -       rec->minfo.vrate  = ivideo.refresh_rate;
76089 -       rec->iobase       = ivideo.vga_base - 0x30;
76090 -       rec->mem_size     = ivideo.video_size;
76091 -       rec->disp_state   = ivideo.disp_state; 
76092 -       rec->version      = (VER_MAJOR << 24) | (VER_MINOR << 16) | VER_LEVEL; 
76093 -       rec->hasVB        = ivideo.hasVB; 
76094 -       rec->TV_type      = ivideo.TV_type; 
76095 -       rec->TV_plug      = ivideo.TV_plug; 
76096 -       rec->chip         = ivideo.chip;
76097 +       rec->minfo.bpp      = ivideo.video_bpp;
76098 +       rec->minfo.xres     = ivideo.video_width;
76099 +       rec->minfo.yres     = ivideo.video_height;
76100 +       rec->minfo.v_xres   = ivideo.video_vwidth;
76101 +       rec->minfo.v_yres   = ivideo.video_vheight;
76102 +       rec->minfo.org_x    = ivideo.org_x;
76103 +       rec->minfo.org_y    = ivideo.org_y;
76104 +       rec->minfo.vrate    = ivideo.refresh_rate;
76105 +       rec->iobase         = ivideo.vga_base - 0x30;
76106 +       rec->mem_size       = ivideo.video_size;
76107 +       rec->disp_state     = ivideo.disp_state;
76108 +       rec->version        = (VER_MAJOR << 24) | (VER_MINOR << 16) | VER_LEVEL;
76109 +       rec->hasVB          = ivideo.hasVB;
76110 +       rec->TV_type        = ivideo.TV_type;
76111 +       rec->TV_plug        = ivideo.TV_plug;
76112 +       rec->chip           = ivideo.chip;
76113 +       rec->vbflags        = ivideo.vbflags;
76114 +       rec->currentvbflags = ivideo.currentvbflags;
76115  }
76116  
76117  /* ------------ FBDev related routines for 2.4 series ----------- */
76118 @@ -873,7 +1365,6 @@ static void sisfb_crtc_to_var(struct fb_
76119         int A, B, C, D, E, F, temp;
76120         double hrate, drate;
76121  
76122 -       TWDEBUG("Inside crtc_to_var");
76123         inSISIDXREG(SISSR, IND_SIS_COLOR_MODE, sr_data);
76124  
76125         if (sr_data & SIS_INTERLACED_MODE)
76126 @@ -921,6 +1412,8 @@ static void sisfb_crtc_to_var(struct fb_
76127  
76128         inSISIDXREG(SISCR, 0x09, cr_data3);
76129  
76130 +       if(cr_data3 & 0x80) var->vmode = FB_VMODE_DOUBLE;
76131 +
76132         VBS = (cr_data & 0xff) | ((u16) (cr_data2 & 0x08) << 5) |
76133               ((u16) (cr_data3 & 0x20) << 4) | ((u16) (sr_data & 0x04) << 8);
76134  
76135 @@ -939,26 +1432,22 @@ static void sisfb_crtc_to_var(struct fb_
76136         D = B - F - C;
76137  
76138          var->yres = E;
76139 -#ifndef SISFB_PAN
76140 -       var->yres_virtual = E;
76141 -#endif
76142 -       /* TW: We have to report the physical dimension to the console! */
76143 +       var->upper_margin = D;
76144 +       var->lower_margin = F;
76145 +       var->vsync_len = C;
76146 +
76147         if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
76148                 var->yres <<= 1;
76149 -#ifndef SISFB_PAN
76150 -               var->yres_virtual <<= 1;
76151 -#endif
76152 +               var->upper_margin <<= 1;
76153 +               var->lower_margin <<= 1;
76154 +               var->vsync_len <<= 1;
76155         } else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
76156                 var->yres >>= 1;
76157 -#ifndef SISFB_PAN
76158 -               var->yres_virtual >>= 1;
76159 -#endif
76160 +               var->upper_margin >>= 1;
76161 +               var->lower_margin >>= 1;
76162 +               var->vsync_len >>= 1;
76163         }
76164  
76165 -       var->upper_margin = D;
76166 -       var->lower_margin = F;
76167 -       var->vsync_len = C;
76168 -
76169         inSISIDXREG(SISSR, 0x0b, sr_data);
76170  
76171         inSISIDXREG(SISCR, 0x00, cr_data);
76172 @@ -999,10 +1488,20 @@ static void sisfb_crtc_to_var(struct fb_
76173         D = B - F - C;
76174  
76175         var->xres = var->xres_virtual = E * 8;
76176 -       var->left_margin = D * 8;
76177 -       var->right_margin = F * 8;
76178 -       var->hsync_len = C * 8;
76179  
76180 +       if((var->xres == 320) &&
76181 +          (var->yres == 200 || var->yres == 240)) {
76182 +               /* Terrible hack, but the correct CRTC data for
76183 +                * these modes only produces a black screen...
76184 +                */
76185 +                       var->left_margin = (400 - 376);
76186 +                       var->right_margin = (328 - 320);
76187 +                       var->hsync_len = (376 - 328);
76188 +       } else {
76189 +               var->left_margin = D * 8;
76190 +               var->right_margin = F * 8;
76191 +               var->hsync_len = C * 8;
76192 +       }
76193         var->activate = FB_ACTIVATE_NOW;
76194  
76195         var->sync = 0;
76196 @@ -1022,21 +1521,21 @@ static void sisfb_crtc_to_var(struct fb_
76197         VT <<= 1;
76198         HT = (HT + 5) * 8;
76199  
76200 +       if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
76201 +               VT <<= 1;
76202 +       }
76203         hrate = (double) ivideo.refresh_rate * (double) VT / 2;
76204         drate = hrate * HT;
76205         var->pixclock = (u32) (1E12 / drate);
76206  
76207 -#ifdef SISFB_PAN
76208         if(sisfb_ypan) {
76209             var->yres_virtual = ivideo.heapstart / (var->xres * (var->bits_per_pixel >> 3));
76210             if(var->yres_virtual <= var->yres) {
76211                 var->yres_virtual = var->yres;
76212             }
76213         } else
76214 -#endif
76215 -          var->yres_virtual = var->yres;
76216 +           var->yres_virtual = var->yres;
76217  
76218 -        TWDEBUG("end of crtc_to_var");
76219  }
76220  
76221  static int sis_getcolreg(unsigned regno, unsigned *red, unsigned *green, unsigned *blue,
76222 @@ -1069,7 +1568,7 @@ static int sisfb_setcolreg(unsigned regn
76223                 outSISREG(SISDACD, (red >> 10));
76224                 outSISREG(SISDACD, (green >> 10));
76225                 outSISREG(SISDACD, (blue >> 10));
76226 -               if (ivideo.disp_state & DISPTYPE_DISP2) {
76227 +               if (ivideo.currentvbflags & VB_DISPTYPE_DISP2) {
76228                         outSISREG(SISDAC2A, regno);
76229                         outSISREG(SISDAC2D, (red >> 8));
76230                         outSISREG(SISDAC2D, (green >> 8));
76231 @@ -1118,7 +1617,7 @@ static void sisfb_set_disp(int con, stru
76232         display->ywrapstep = fix.ywrapstep;
76233         display->line_length = fix.line_length;
76234         display->next_line = fix.line_length;
76235 -       display->can_soft_blank = 0;
76236 +       display->can_soft_blank = 1;
76237         display->inverse = sisfb_inverse;
76238         display->var = *var;
76239  
76240 @@ -1162,17 +1661,12 @@ static void sisfb_set_disp(int con, stru
76241         display->dispsw = &sisfb_sw;
76242         restore_flags(flags);
76243  
76244 -#ifdef SISFB_PAN
76245 -        if((ivideo.accel) && (sisfb_ypan)) {
76246 -           /* display->scrollmode = SCROLL_YPAN; - not defined */
76247 +        if(sisfb_ypan) {
76248 +           /* display->scrollmode = 0;  */
76249         } else {
76250             display->scrollmode = SCROLL_YREDRAW;
76251             sisfb_sw.bmove = fbcon_redraw_bmove;
76252         }
76253 -#else
76254 -       display->scrollmode = SCROLL_YREDRAW;
76255 -       sisfb_sw.bmove = fbcon_redraw_bmove;
76256 -#endif
76257  }
76258  
76259  static void sisfb_do_install_cmap(int con, struct fb_info *info)
76260 @@ -1191,17 +1685,16 @@ static void sisfb_do_install_cmap(int co
76261  static int sisfb_get_var(struct fb_var_screeninfo *var, int con,
76262                          struct fb_info *info)
76263  {
76264 -       TWDEBUG("inside get_var");
76265         if(con == -1)
76266                 memcpy(var, &default_var, sizeof(struct fb_var_screeninfo));
76267         else
76268                 *var = fb_display[con].var;
76269  
76270 -       /* For FSTN, DSTN */
76271 -       if (var->xres == 320 && var->yres == 480)
76272 +       if(sisfb_fstn) {
76273 +          if (var->xres == 320 && var->yres == 480)
76274                 var->yres = 240;
76275 -               
76276 -       TWDEBUG("end of get_var");
76277 +        }
76278 +
76279         return 0;
76280  }
76281  
76282 @@ -1211,8 +1704,6 @@ static int sisfb_set_var(struct fb_var_s
76283         int err;
76284         unsigned int cols, rows;
76285  
76286 -       TWDEBUG("inside set_var");
76287 -
76288         fb_display[con].var.activate = FB_ACTIVATE_NOW;
76289          if(sisfb_do_set_var(var, con == currcon, info)) {
76290                 sisfb_crtc_to_var(var);
76291 @@ -1233,16 +1724,17 @@ static int sisfb_set_var(struct fb_var_s
76292  
76293         cols = sisbios_mode[sisfb_mode_idx].cols;
76294         rows = sisbios_mode[sisfb_mode_idx].rows;
76295 -       vc_resize_con(rows, cols, fb_display[con].conp->vc_num);
76296 +#if 0
76297 +       /* Why was this called here? */
76298 +       vc_resize_con(rows, cols, fb_display[con].conp->vc_num);
76299 +#endif
76300  
76301 -       TWDEBUG("end of set_var");
76302         return 0;
76303  }
76304  
76305  static int sisfb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
76306                           struct fb_info *info)
76307  {
76308 -       TWDEBUG("inside get_cmap");
76309          if (con == currcon)
76310                 return fb_get_cmap(cmap, kspc, sis_getcolreg, info);
76311  
76312 @@ -1251,7 +1743,6 @@ static int sisfb_get_cmap(struct fb_cmap
76313         else
76314                 fb_copy_cmap(fb_default_cmap(ivideo.video_cmap_len), cmap, kspc ? 0 : 2);
76315  
76316 -       TWDEBUG("end of get_cmap");
76317         return 0;
76318  }
76319  
76320 @@ -1260,7 +1751,6 @@ static int sisfb_set_cmap(struct fb_cmap
76321  {
76322         int err;
76323  
76324 -       TWDEBUG("inside set_cmap");
76325         if (!fb_display[con].cmap.len) {
76326                 err = fb_alloc_cmap(&fb_display[con].cmap, ivideo.video_cmap_len, 0);
76327                 if (err)
76328 @@ -1272,17 +1762,15 @@ static int sisfb_set_cmap(struct fb_cmap
76329  
76330         else
76331                 fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1);
76332 -       TWDEBUG("end of set_cmap");
76333 +
76334         return 0;
76335  }
76336  
76337 -#ifdef SISFB_PAN
76338  static int sisfb_pan_display(struct fb_var_screeninfo *var, int con,
76339                              struct fb_info* info)
76340  {
76341         int err;
76342 -       
76343 -       TWDEBUG("inside pan_display");
76344 +
76345         if (var->vmode & FB_VMODE_YWRAP) {
76346                 if (var->yoffset < 0 || var->yoffset >= fb_display[con].var.yres_virtual || var->xoffset)
76347                         return -EINVAL;
76348 @@ -1303,10 +1791,8 @@ static int sisfb_pan_display(struct fb_v
76349         else
76350                 fb_display[con].var.vmode &= ~FB_VMODE_YWRAP;
76351  
76352 -       TWDEBUG("end of pan_display");
76353         return 0;
76354  }
76355 -#endif
76356  
76357  static int sisfb_mmap(struct fb_info *info, struct file *file,
76358                       struct vm_area_struct *vma)
76359 @@ -1316,7 +1802,6 @@ static int sisfb_mmap(struct fb_info *in
76360         unsigned long off;
76361         u32 len, mmio_off;
76362  
76363 -       TWDEBUG("inside mmap");
76364         if(vma->vm_pgoff > (~0UL >> PAGE_SHIFT))  return -EINVAL;
76365  
76366         off = vma->vm_pgoff << PAGE_SHIFT;
76367 @@ -1351,11 +1836,11 @@ static int sisfb_mmap(struct fb_info *in
76368         if (boot_cpu_data.x86 > 3)
76369                 pgprot_val(vma->vm_page_prot) |= _PAGE_PCD;
76370  #endif
76371 +        /* RedHat requires vma as the first paramater to the following call */
76372         if (io_remap_page_range(vma->vm_start, off, vma->vm_end - vma->vm_start,
76373                                 vma->vm_page_prot))
76374                 return -EAGAIN;
76375  
76376 -        TWDEBUG("end of mmap");
76377         return 0;
76378  }
76379  
76380 @@ -1368,7 +1853,6 @@ static void sis_get_glyph(struct fb_info
76381         u8 *gbuf = gly->gmask;
76382         int size;
76383  
76384 -       TWDEBUG("Inside get_glyph");
76385         gly->fontheight = fontheight(p);
76386         gly->fontwidth = fontwidth(p);
76387         widthb = (fontwidth(p) + 7) / 8;
76388 @@ -1382,16 +1866,11 @@ static void sis_get_glyph(struct fb_info
76389         size = fontheight(p) * widthb;
76390         memcpy(gbuf, cdat, size);
76391         gly->ngmask = size;
76392 -       TWDEBUG("End of get_glyph");
76393  }
76394  
76395  static int sisfb_update_var(int con, struct fb_info *info)
76396  {
76397 -#ifdef SISFB_PAN
76398          return(sisfb_pan_var(&fb_display[con].var));
76399 -#else
76400 -       return 0;
76401 -#endif 
76402  }
76403  
76404  static int sisfb_switch(int con, struct fb_info *info)
76405 @@ -1428,127 +1907,7 @@ static int sisfb_switch(int con, struct 
76406  
76407  static void sisfb_blank(int blank, struct fb_info *info)
76408  {
76409 -       u8 reg;
76410 -
76411 -       inSISIDXREG(SISCR, 0x17, reg);
76412 -
76413 -       if(blank > 0)
76414 -               reg &= 0x7f;
76415 -       else
76416 -               reg |= 0x80;
76417 -
76418 -        outSISIDXREG(SISCR, 0x17, reg);                
76419 -       outSISIDXREG(SISSR, 0x00, 0x01);    /* Synchronous Reset */
76420 -       outSISIDXREG(SISSR, 0x00, 0x03);    /* End Reset */
76421 -       printk(KERN_DEBUG "sisfb_blank() called (%d)\n", blank);
76422 -}
76423 -
76424 -
76425 -static int sisfb_ioctl(struct inode *inode, struct file *file,
76426 -                      unsigned int cmd, unsigned long arg, int con,
76427 -                      struct fb_info *info)
76428 -{
76429 -       TWDEBUG("inside ioctl");
76430 -       switch (cmd) {
76431 -          case FBIO_ALLOC:
76432 -               if (!capable(CAP_SYS_RAWIO))
76433 -                       return -EPERM;
76434 -               sis_malloc((struct sis_memreq *) arg);
76435 -               break;
76436 -          case FBIO_FREE:
76437 -               if (!capable(CAP_SYS_RAWIO))
76438 -                       return -EPERM;
76439 -               sis_free(*(unsigned long *) arg);
76440 -               break;
76441 -          case FBIOGET_GLYPH:
76442 -                sis_get_glyph(info,(SIS_GLYINFO *) arg);
76443 -               break;  
76444 -          case FBIOGET_HWCINFO:
76445 -               {
76446 -                       unsigned long *hwc_offset = (unsigned long *) arg;
76447 -
76448 -                       if (sisfb_caps & HW_CURSOR_CAP)
76449 -                               *hwc_offset = sisfb_hwcursor_vbase -
76450 -                                   (unsigned long) ivideo.video_vbase;
76451 -                       else
76452 -                               *hwc_offset = 0;
76453 -
76454 -                       break;
76455 -               }
76456 -          case FBIOPUT_MODEINFO:
76457 -               {
76458 -                       struct mode_info *x = (struct mode_info *)arg;
76459 -
76460 -                       ivideo.video_bpp        = x->bpp;
76461 -                       ivideo.video_width      = x->xres;
76462 -                       ivideo.video_height     = x->yres;
76463 -                       ivideo.video_vwidth     = x->v_xres;
76464 -                       ivideo.video_vheight    = x->v_yres;
76465 -                       ivideo.org_x            = x->org_x;
76466 -                       ivideo.org_y            = x->org_y;
76467 -                       ivideo.refresh_rate     = x->vrate;
76468 -                       ivideo.video_linelength = ivideo.video_vwidth * (ivideo.video_bpp >> 3);
76469 -                       switch(ivideo.video_bpp) {
76470 -                       case 8:
76471 -                               ivideo.DstColor = 0x0000;
76472 -                               ivideo.SiS310_AccelDepth = 0x00000000;
76473 -                               ivideo.video_cmap_len = 256;
76474 -                               break;
76475 -                       case 16:
76476 -                               ivideo.DstColor = 0x8000;
76477 -                               ivideo.SiS310_AccelDepth = 0x00010000;
76478 -                               ivideo.video_cmap_len = 16;
76479 -                               break;
76480 -                       case 32:
76481 -                               ivideo.DstColor = 0xC000;
76482 -                               ivideo.SiS310_AccelDepth = 0x00020000;
76483 -                               ivideo.video_cmap_len = 16;
76484 -                               break;
76485 -                       default:
76486 -                               ivideo.video_cmap_len = 16;
76487 -                               printk(KERN_ERR "sisfb: Unsupported depth %d", ivideo.video_bpp);
76488 -                               ivideo.accel = 0;
76489 -                               break;
76490 -                       }
76491 -
76492 -                       break;
76493 -               }
76494 -          case FBIOGET_DISPINFO:
76495 -               sis_dispinfo((struct ap_data *)arg);
76496 -               break;
76497 -          case SISFB_GET_INFO:  /* TW: New for communication with X driver */
76498 -               {
76499 -                       sisfb_info *x = (sisfb_info *)arg;
76500 -
76501 -                       x->sisfb_id = SISFB_ID;
76502 -                       x->sisfb_version = VER_MAJOR;
76503 -                       x->sisfb_revision = VER_MINOR;
76504 -                       x->sisfb_patchlevel = VER_LEVEL;
76505 -                       x->chip_id = ivideo.chip_id;
76506 -                       x->memory = ivideo.video_size / 1024;
76507 -                       x->heapstart = ivideo.heapstart / 1024;
76508 -                       x->fbvidmode = sisfb_mode_no;
76509 -                       x->sisfb_caps = sisfb_caps;
76510 -                       x->sisfb_tqlen = 512; /* yet unused */
76511 -                       x->sisfb_pcibus = ivideo.pcibus;
76512 -                       x->sisfb_pcislot = ivideo.pcislot;
76513 -                       x->sisfb_pcifunc = ivideo.pcifunc;
76514 -                       x->sisfb_lcdpdc = sisfb_detectedpdc;
76515 -                       x->sisfb_lcda = sisfb_detectedlcda;
76516 -                       break;
76517 -               }
76518 -          case SISFB_GET_VBRSTATUS:
76519 -               {
76520 -                       unsigned long *vbrstatus = (unsigned long *) arg;
76521 -                       if(sisfb_CheckVBRetrace()) *vbrstatus = 1;
76522 -                       else                       *vbrstatus = 0;
76523 -               }
76524 -          default:
76525 -               return -EINVAL;
76526 -       }
76527 -       TWDEBUG("end of ioctl");
76528 -       return 0;
76529 -
76530 +       sisfb_myblank(blank);
76531  }
76532  #endif
76533  
76534 @@ -1575,11 +1934,9 @@ static int sisfb_get_cmap_len(const stru
76535                 rc = 256;       
76536                 break;
76537         case 16:
76538 -               rc = 16;        
76539 -               break;          
76540         case 32:
76541                 rc = 16;
76542 -               break;  
76543 +               break;
76544         }
76545         return rc;
76546  }
76547 @@ -1596,7 +1953,7 @@ static int sisfb_setcolreg(unsigned regn
76548                 outSISREG(SISDACD, (red >> 10));
76549                 outSISREG(SISDACD, (green >> 10));
76550                 outSISREG(SISDACD, (blue >> 10));
76551 -               if (ivideo.disp_state & DISPTYPE_DISP2) {
76552 +               if (ivideo.currentvbflags & VB_DISPTYPE_DISP2) {
76553                         outSISREG(SISDAC2A, regno);
76554                         outSISREG(SISDAC2D, (red >> 8));
76555                         outSISREG(SISDAC2D, (green >> 8));
76556 @@ -1622,63 +1979,52 @@ static int sisfb_set_par(struct fb_info 
76557  {
76558         int err;
76559  
76560 -       TWDEBUG("inside set_par");
76561          if((err = sisfb_do_set_var(&info->var, 1, info)))
76562                 return err;
76563  
76564         sisfb_get_fix(&info->fix, info->currcon, info);
76565  
76566 -       TWDEBUG("end of set_par");
76567         return 0;
76568  }
76569  
76570  static int sisfb_check_var(struct fb_var_screeninfo *var,
76571                             struct fb_info *info)
76572  {
76573 -       unsigned int htotal =
76574 -               var->left_margin + var->xres + var->right_margin +
76575 -               var->hsync_len;
76576 -       unsigned int vtotal = 0;
76577 +       unsigned int htotal = 0, vtotal = 0, myrateindex = 0;
76578         double drate = 0, hrate = 0;
76579         int found_mode = 0;
76580         int refresh_rate, search_idx;
76581 +       BOOLEAN recalc_clock = FALSE;
76582 +       u32 pixclock;
76583 +
76584 +       htotal = var->left_margin + var->xres + var->right_margin + var->hsync_len;
76585 +
76586 +       vtotal = var->upper_margin + var->lower_margin + var->vsync_len;
76587  
76588 -       TWDEBUG("Inside check_var");
76589 +       pixclock = var->pixclock;
76590  
76591         if((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) {
76592 -               vtotal = var->upper_margin + var->yres + var->lower_margin +
76593 -                        var->vsync_len;   
76594 +               vtotal += var->yres;
76595                 vtotal <<= 1;
76596         } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
76597 -               vtotal = var->upper_margin + var->yres + var->lower_margin +
76598 -                        var->vsync_len;   
76599 +               vtotal += var->yres;
76600                 vtotal <<= 2;
76601         } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
76602 -               vtotal = var->upper_margin + (var->yres/2) + var->lower_margin +
76603 -                        var->vsync_len;   
76604 -       } else  vtotal = var->upper_margin + var->yres + var->lower_margin +
76605 -                        var->vsync_len;
76606 +               vtotal += var->yres;
76607 +               vtotal <<= 1;
76608 +       } else  vtotal += var->yres;
76609  
76610         if(!(htotal) || !(vtotal)) {
76611                 SISFAIL("sisfb: no valid timing data");
76612         }
76613  
76614 -       if((var->pixclock) && (htotal)) {
76615 -          drate = 1E12 / var->pixclock;
76616 -          hrate = drate / htotal;
76617 -          refresh_rate = (unsigned int) (hrate / vtotal * 2 + 0.5);
76618 -       } else refresh_rate = 60;
76619 -
76620 -       /* TW: Calculation wrong for 1024x600 - force it to 60Hz */
76621 -       if((var->xres == 1024) && (var->yres == 600)) refresh_rate = 60;
76622 -
76623         search_idx = 0;
76624         while( (sisbios_mode[search_idx].mode_no != 0) &&
76625                (sisbios_mode[search_idx].xres <= var->xres) ) {
76626                 if( (sisbios_mode[search_idx].xres == var->xres) &&
76627                     (sisbios_mode[search_idx].yres == var->yres) &&
76628                     (sisbios_mode[search_idx].bpp == var->bits_per_pixel)) {
76629 -                       if(sisfb_validate_mode(search_idx) > 0) {
76630 +                       if(sisfb_validate_mode(search_idx, ivideo.currentvbflags) > 0) {
76631                            found_mode = 1;
76632                            break;
76633                         }
76634 @@ -1687,38 +2033,95 @@ static int sisfb_check_var(struct fb_var
76635         }
76636  
76637         if(!found_mode) {
76638 -       
76639 -               printk(KERN_ERR "sisfb: %dx%dx%d is no valid mode\n", 
76640 -                       var->xres, var->yres, var->bits_per_pixel);
76641 -                       
76642 +
76643                  search_idx = 0;
76644                 while(sisbios_mode[search_idx].mode_no != 0) {
76645 -                      
76646                    if( (var->xres <= sisbios_mode[search_idx].xres) &&
76647 -                      (var->yres <= sisbios_mode[search_idx].yres) && 
76648 +                      (var->yres <= sisbios_mode[search_idx].yres) &&
76649                        (var->bits_per_pixel == sisbios_mode[search_idx].bpp) ) {
76650 -                         if(sisfb_validate_mode(search_idx) > 0) {
76651 +                         if(sisfb_validate_mode(search_idx, ivideo.currentvbflags) > 0) {
76652                              found_mode = 1;
76653                              break;
76654                           }
76655                    }
76656                    search_idx++;
76657 -               }                       
76658 +               }
76659                 if(found_mode) {
76660 +                       printk(KERN_DEBUG "sisfb: Adapted from %dx%dx%d to %dx%dx%d\n",
76661 +                               var->xres, var->yres, var->bits_per_pixel,
76662 +                               sisbios_mode[search_idx].xres,
76663 +                               sisbios_mode[search_idx].yres,
76664 +                               var->bits_per_pixel);
76665                         var->xres = sisbios_mode[search_idx].xres;
76666                         var->yres = sisbios_mode[search_idx].yres;
76667 -                       printk(KERN_DEBUG "sisfb: Adapted to mode %dx%dx%d\n",
76668 -                               var->xres, var->yres, var->bits_per_pixel);
76669 -                  
76670 +
76671 +
76672                 } else {
76673 -                       printk(KERN_ERR "sisfb: Failed to find similar mode to %dx%dx%d\n", 
76674 +                       printk(KERN_ERR "sisfb: Failed to find supported mode near %dx%dx%d\n",
76675                                 var->xres, var->yres, var->bits_per_pixel);
76676                         return -EINVAL;
76677                 }
76678         }
76679  
76680 -       /* TW: TODO: Check the refresh rate */          
76681 -       
76682 +       if( ((ivideo.vbflags & VB_LVDS) ||                      /* Slave modes on LVDS and 301B-DH */
76683 +            ((ivideo.vbflags & VB_30xBDH) && (ivideo.currentvbflags & CRT2_LCD))) &&
76684 +           (var->bits_per_pixel == 8) ) {
76685 +               refresh_rate = 60;
76686 +               recalc_clock = TRUE;
76687 +       } else if( (ivideo.current_htotal == htotal) &&         /* x=x & y=y & c=c -> assume depth change */
76688 +                  (ivideo.current_vtotal == vtotal) &&
76689 +                  (ivideo.current_pixclock == pixclock) ) {
76690 +               drate = 1E12 / pixclock;
76691 +               hrate = drate / htotal;
76692 +               refresh_rate = (unsigned int) (hrate / vtotal * 2 + 0.5);
76693 +       } else if( ( (ivideo.current_htotal != htotal) ||       /* x!=x | y!=y & c=c -> invalid pixclock */
76694 +                    (ivideo.current_vtotal != vtotal) ) &&
76695 +                  (ivideo.current_pixclock == var->pixclock) ) {
76696 +               if(sisfb_lastrates[sisbios_mode[search_idx].mode_no]) {
76697 +                       refresh_rate = sisfb_lastrates[sisbios_mode[search_idx].mode_no];
76698 +               } else if(sisfb_parm_rate != -1) {
76699 +                       refresh_rate = sisfb_parm_rate;
76700 +               } else {
76701 +                       refresh_rate = 60;
76702 +               }
76703 +               recalc_clock = TRUE;
76704 +       } else if((pixclock) && (htotal) && (vtotal)) {
76705 +               drate = 1E12 / pixclock;
76706 +               hrate = drate / htotal;
76707 +               refresh_rate = (unsigned int) (hrate / vtotal * 2 + 0.5);
76708 +       } else if(ivideo.current_refresh_rate) {
76709 +               refresh_rate = ivideo.current_refresh_rate;
76710 +               recalc_clock = TRUE;
76711 +       } else {
76712 +               refresh_rate = 60;
76713 +               recalc_clock = TRUE;
76714 +       }
76715 +
76716 +       myrateindex = sisfb_search_refresh_rate(refresh_rate, search_idx);
76717 +
76718 +       /* Eventually recalculate timing and clock */
76719 +       if(recalc_clock) {
76720 +          if(!myrateindex) myrateindex = sisbios_mode[search_idx].rate_idx;
76721 +          var->pixclock = (u32) (1E12 / sisfb_mode_rate_to_dclock(&SiS_Pr, &sishw_ext,
76722 +                                               sisbios_mode[search_idx].mode_no, myrateindex));
76723 +          sisfb_mode_rate_to_ddata(&SiS_Pr, &sishw_ext,
76724 +                                       sisbios_mode[search_idx].mode_no, myrateindex,
76725 +                                       &var->left_margin, &var->right_margin,
76726 +                                       &var->upper_margin, &var->lower_margin,
76727 +                                       &var->hsync_len, &var->vsync_len,
76728 +                                       &var->sync, &var->vmode);
76729 +          if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
76730 +               var->pixclock <<= 1;
76731 +          }
76732 +       }
76733 +
76734 +       if(sisfb_thismonitor.datavalid) {
76735 +          if(!sisfb_verify_rate(&sisfb_thismonitor, search_idx,
76736 +                                myrateindex, refresh_rate)) {
76737 +             printk(KERN_INFO "sisfb: WARNING: Refresh rate exceeds monitor specs!\n");
76738 +          }
76739 +       }
76740 +
76741         /* Adapt RGB settings */
76742         sisfb_bpp_to_var(var);  
76743         
76744 @@ -1732,17 +2135,19 @@ static int sisfb_check_var(struct fb_var
76745         if(var->xres != var->xres_virtual)
76746                 var->xres_virtual = var->xres;
76747  
76748 -       if(!sisfb_ypan) {
76749 -               if(var->yres != var->yres_virtual)
76750 -                       var->yres_virtual = var->yres;
76751 -       } else {
76752 +       if(sisfb_ypan) {
76753            /* TW: Now patch yres_virtual if we use panning */
76754            /* *** May I do this? *** */
76755            var->yres_virtual = ivideo.heapstart / (var->xres * (var->bits_per_pixel >> 3));
76756 -           if(var->yres_virtual <= var->yres) {
76757 +          if(var->yres_virtual <= var->yres) {
76758                 /* TW: Paranoia check */
76759                 var->yres_virtual = var->yres;
76760 -           }
76761 +          }
76762 +       } else {
76763 +          if(var->yres != var->yres_virtual)
76764 +               var->yres_virtual = var->yres;
76765 +          var->xoffset = 0;
76766 +          var->yoffset = 0;
76767         }
76768         
76769         /* Truncate offsets to maximum if too high */
76770 @@ -1757,28 +2162,25 @@ static int sisfb_check_var(struct fb_var
76771             var->green.msb_right =
76772             var->blue.msb_right =
76773             var->transp.offset = var->transp.length = var->transp.msb_right = 0;                
76774 -               
76775 -       TWDEBUG("end of check_var");
76776 +
76777         return 0;
76778  }
76779  
76780 -#ifdef SISFB_PAN
76781  static int sisfb_pan_display(struct fb_var_screeninfo *var,
76782                              struct fb_info* info)
76783  {
76784         int err;
76785 -       
76786 -       TWDEBUG("inside pan_display");
76787 -       
76788 +
76789         if (var->xoffset > (var->xres_virtual - var->xres))
76790                 return -EINVAL;
76791         if (var->yoffset > (var->yres_virtual - var->yres))
76792                 return -EINVAL;
76793  
76794         if (var->vmode & FB_VMODE_YWRAP) {
76795 -               if (var->yoffset < 0
76796 -                   || var->yoffset >= info->var.yres_virtual
76797 -                   || var->xoffset) return -EINVAL;
76798 +               if (var->yoffset < 0 ||
76799 +                   var->yoffset >= info->var.yres_virtual ||
76800 +                   var->xoffset)
76801 +                       return -EINVAL;
76802         } else {
76803                 if (var->xoffset + info->var.xres > info->var.xres_virtual ||
76804                     var->yoffset + info->var.yres > info->var.yres_virtual)
76805 @@ -1794,10 +2196,8 @@ static int sisfb_pan_display(struct fb_v
76806         else
76807                 info->var.vmode &= ~FB_VMODE_YWRAP;
76808  
76809 -       TWDEBUG("end of pan_display");
76810         return 0;
76811  }
76812 -#endif
76813  
76814  static int sisfb_mmap(struct fb_info *info, struct file *file,
76815                       struct vm_area_struct *vma)
76816 @@ -1806,7 +2206,6 @@ static int sisfb_mmap(struct fb_info *in
76817         unsigned long off;
76818         u32 len, mmio_off;
76819  
76820 -       TWDEBUG("inside mmap");
76821         if(vma->vm_pgoff > (~0UL >> PAGE_SHIFT))  return -EINVAL;
76822  
76823         off = vma->vm_pgoff << PAGE_SHIFT;
76824 @@ -1844,139 +2243,143 @@ static int sisfb_mmap(struct fb_info *in
76825                                 vma->vm_page_prot))
76826                 return -EAGAIN;
76827  
76828 -        TWDEBUG("end of mmap");
76829         return 0;
76830  }
76831  
76832  static int sisfb_blank(int blank, struct fb_info *info)
76833  {
76834 -       u8 reg;
76835 +       return(sisfb_myblank(blank));
76836 +}
76837  
76838 -       inSISIDXREG(SISCR, 0x17, reg);
76839 +#endif
76840  
76841 -       if(blank > 0)
76842 -               reg &= 0x7f;
76843 -       else
76844 -               reg |= 0x80;
76845 +/* ----------- FBDev related routines for all series ---------- */
76846  
76847 -        outSISIDXREG(SISCR, 0x17, reg);                
76848 -       outSISIDXREG(SISSR, 0x00, 0x01);    /* Synchronous Reset */
76849 -       outSISIDXREG(SISSR, 0x00, 0x03);    /* End Reset */
76850 -        return(0);
76851 -}
76852  
76853 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
76854 +static int sisfb_ioctl(struct inode *inode, struct file *file,
76855 +                      unsigned int cmd, unsigned long arg,
76856 +                      struct fb_info *info)
76857 +#else
76858  static int sisfb_ioctl(struct inode *inode, struct file *file,
76859 -                      unsigned int cmd, unsigned long arg, 
76860 +                      unsigned int cmd, unsigned long arg, int con,
76861                        struct fb_info *info)
76862 +#endif
76863  {
76864 -       TWDEBUG("inside ioctl");
76865 +       struct sis_memreq sismemreq;
76866 +       struct ap_data sisapdata;
76867 +       unsigned long sismembase = 0;
76868 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
76869 +       SIS_GLYINFO sisglyinfo;
76870 +#endif
76871 +
76872         switch (cmd) {
76873            case FBIO_ALLOC:
76874 -               if (!capable(CAP_SYS_RAWIO))
76875 +               if(!capable(CAP_SYS_RAWIO))
76876                         return -EPERM;
76877 -               sis_malloc((struct sis_memreq *) arg);
76878 +               if(copy_from_user(&sismemreq, (void *)arg, sizeof(sismemreq)))
76879 +                       return -EFAULT;
76880 +               sis_malloc(&sismemreq);
76881 +               if(copy_to_user((void *)arg, &sismemreq, sizeof(sismemreq))) {
76882 +                       sis_free(sismemreq.offset);
76883 +                       return -EFAULT;
76884 +               }
76885                 break;
76886            case FBIO_FREE:
76887 -               if (!capable(CAP_SYS_RAWIO))
76888 +               if(!capable(CAP_SYS_RAWIO))
76889                         return -EPERM;
76890 -               sis_free(*(unsigned long *) arg);
76891 +               if(get_user(sismembase, (unsigned long *) arg))
76892 +                       return -EFAULT;
76893 +               sis_free(sismembase);
76894                 break;
76895 -          case FBIOGET_HWCINFO:
76896 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
76897 +          case FBIOGET_GLYPH:
76898 +               if(copy_from_user(&sisglyinfo, (void *)arg, sizeof(sisglyinfo)))
76899 +                       return -EFAULT;
76900 +                sis_get_glyph(info, &sisglyinfo);
76901 +               break;
76902 +          case FBIOPUT_MODEINFO:
76903                 {
76904 -                       unsigned long *hwc_offset = (unsigned long *) arg;
76905 +                       struct mode_info x;
76906  
76907 -                       if (sisfb_caps & HW_CURSOR_CAP)
76908 -                               *hwc_offset = sisfb_hwcursor_vbase -
76909 -                                   (unsigned long) ivideo.video_vbase;
76910 -                       else
76911 -                               *hwc_offset = 0;
76912 +                       if(copy_from_user(&x, (void *)arg, sizeof(x)))
76913 +                               return -EFAULT;
76914  
76915 +                       ivideo.video_bpp        = x.bpp;
76916 +                       ivideo.video_width      = x.xres;
76917 +                       ivideo.video_height     = x.yres;
76918 +                       ivideo.video_vwidth     = x.v_xres;
76919 +                       ivideo.video_vheight    = x.v_yres;
76920 +                       ivideo.org_x            = x.org_x;
76921 +                       ivideo.org_y            = x.org_y;
76922 +                       ivideo.refresh_rate     = x.vrate;
76923 +                       ivideo.video_linelength = ivideo.video_vwidth * (ivideo.video_bpp >> 3);
76924 +                       sisfb_set_vparms();
76925                         break;
76926                 }
76927 -          case FBIOPUT_MODEINFO:
76928 +#endif
76929 +          case FBIOGET_HWCINFO:
76930                 {
76931 -                       struct mode_info *x = (struct mode_info *)arg;
76932 +                       unsigned long myhwcoffset = 0;
76933  
76934 -                       ivideo.video_bpp        = x->bpp;
76935 -                       ivideo.video_width      = x->xres;
76936 -                       ivideo.video_height     = x->yres;
76937 -                       ivideo.video_vwidth     = x->v_xres;
76938 -                       ivideo.video_vheight    = x->v_yres;
76939 -                       ivideo.org_x            = x->org_x;
76940 -                       ivideo.org_y            = x->org_y;
76941 -                       ivideo.refresh_rate     = x->vrate;
76942 -                       ivideo.video_linelength = ivideo.video_vwidth * (ivideo.video_bpp >> 3);
76943 -                       switch(ivideo.video_bpp) {
76944 -                       case 8:
76945 -                               ivideo.DstColor = 0x0000;
76946 -                               ivideo.SiS310_AccelDepth = 0x00000000;
76947 -                               ivideo.video_cmap_len = 256;
76948 -                               break;
76949 -                       case 16:
76950 -                               ivideo.DstColor = 0x8000;
76951 -                               ivideo.SiS310_AccelDepth = 0x00010000;
76952 -                               ivideo.video_cmap_len = 16;
76953 -                               break;
76954 -                       case 32:
76955 -                               ivideo.DstColor = 0xC000;
76956 -                               ivideo.SiS310_AccelDepth = 0x00020000;
76957 -                               ivideo.video_cmap_len = 16;
76958 -                               break;
76959 -                       default:
76960 -                               ivideo.video_cmap_len = 16;
76961 -                               printk(KERN_ERR "sisfb: Unsupported accel depth %d", ivideo.video_bpp);
76962 -                               ivideo.accel = 0;
76963 -                               break;
76964 -                       }
76965 +                       if(sisfb_caps & HW_CURSOR_CAP)
76966 +                               myhwcoffset = sisfb_hwcursor_vbase -
76967 +                                   (unsigned long) ivideo.video_vbase;
76968 +
76969 +                       return put_user(myhwcoffset, (unsigned long *)arg);
76970  
76971                         break;
76972                 }
76973            case FBIOGET_DISPINFO:
76974 -               sis_dispinfo((struct ap_data *)arg);
76975 +               sis_dispinfo(&sisapdata);
76976 +               if(copy_to_user((void *)arg, &sisapdata, sizeof(sisapdata)))
76977 +                       return -EFAULT;
76978                 break;
76979 -          case SISFB_GET_INFO:  /* TW: New for communication with X driver */
76980 +          case SISFB_GET_INFO:  /* For communication with X driver */
76981                 {
76982 -                       sisfb_info *x = (sisfb_info *)arg;
76983 +                       sisfb_info x;
76984  
76985 -                       x->sisfb_id = SISFB_ID;
76986 -                       x->sisfb_version = VER_MAJOR;
76987 -                       x->sisfb_revision = VER_MINOR;
76988 -                       x->sisfb_patchlevel = VER_LEVEL;
76989 -                       x->chip_id = ivideo.chip_id;
76990 -                       x->memory = ivideo.video_size / 1024;
76991 -                       x->heapstart = ivideo.heapstart / 1024;
76992 -                       x->fbvidmode = sisfb_mode_no;
76993 -                       x->sisfb_caps = sisfb_caps;
76994 -                       x->sisfb_tqlen = 512; /* yet unused */
76995 -                       x->sisfb_pcibus = ivideo.pcibus;
76996 -                       x->sisfb_pcislot = ivideo.pcislot;
76997 -                       x->sisfb_pcifunc = ivideo.pcifunc;
76998 -                       x->sisfb_lcdpdc = sisfb_detectedpdc;
76999 -                       x->sisfb_lcda = sisfb_detectedlcda;
77000 +                       x.sisfb_id = SISFB_ID;
77001 +                       x.sisfb_version = VER_MAJOR;
77002 +                       x.sisfb_revision = VER_MINOR;
77003 +                       x.sisfb_patchlevel = VER_LEVEL;
77004 +                       x.chip_id = ivideo.chip_id;
77005 +                       x.memory = ivideo.video_size / 1024;
77006 +                       x.heapstart = ivideo.heapstart / 1024;
77007 +                       x.fbvidmode = sisfb_mode_no;
77008 +                       x.sisfb_caps = sisfb_caps;
77009 +                       x.sisfb_tqlen = 512; /* yet unused */
77010 +                       x.sisfb_pcibus = ivideo.pcibus;
77011 +                       x.sisfb_pcislot = ivideo.pcislot;
77012 +                       x.sisfb_pcifunc = ivideo.pcifunc;
77013 +                       x.sisfb_lcdpdc = sisfb_detectedpdc;
77014 +                       x.sisfb_lcda = sisfb_detectedlcda;
77015 +                       x.sisfb_vbflags = ivideo.vbflags;
77016 +                       x.sisfb_currentvbflags = ivideo.currentvbflags;
77017 +                       x.sisfb_scalelcd = SiS_Pr.UsePanelScaler;
77018 +                       x.sisfb_specialtiming = SiS_Pr.SiS_CustomT;
77019 +                       if(copy_to_user((void *)arg, &x, sizeof(x)))
77020 +                               return -EFAULT;
77021                         break;
77022                 }
77023            case SISFB_GET_VBRSTATUS:
77024                 {
77025 -                       unsigned long *vbrstatus = (unsigned long *) arg;
77026 -                       if(sisfb_CheckVBRetrace()) *vbrstatus = 1;
77027 -                       else                       *vbrstatus = 0;
77028 +                       if(sisfb_CheckVBRetrace())
77029 +                               return put_user(1UL, (unsigned long *) arg);
77030 +                       else
77031 +                               return put_user(0UL, (unsigned long *) arg);
77032 +                       break;
77033                 }
77034            default:
77035                 return -EINVAL;
77036         }
77037 -       TWDEBUG("end of ioctl");
77038         return 0;
77039 -
77040  }
77041  
77042 -#endif
77043 -
77044 -/* ----------- FBDev related routines for all series ---------- */
77045  
77046  static int sisfb_get_fix(struct fb_fix_screeninfo *fix, int con,
77047                          struct fb_info *info)
77048  {
77049 -       TWDEBUG("inside get_fix");
77050         memset(fix, 0, sizeof(struct fb_fix_screeninfo));
77051  
77052  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 
77053 @@ -1987,45 +2390,47 @@ static int sisfb_get_fix(struct fb_fix_s
77054  
77055         fix->smem_start = ivideo.video_base;
77056  
77057 -        /* TW */
77058          if((!sisfb_mem) || (sisfb_mem > (ivideo.video_size/1024))) {
77059 -           if (ivideo.video_size > 0x1000000) {
77060 -               fix->smem_len = 0xc00000;
77061 -           } else if (ivideo.video_size > 0x800000)
77062 -               fix->smem_len = 0x800000;
77063 -           else
77064 -               fix->smem_len = 0x400000;
77065 +           if(sisvga_engine == SIS_300_VGA) {
77066 +              if(ivideo.video_size > 0x1000000) {
77067 +                       fix->smem_len = 0xc00000;
77068 +              } else if(ivideo.video_size > 0x800000)
77069 +                       fix->smem_len = 0x800000;
77070 +              else
77071 +                       fix->smem_len = 0x400000;
77072 +            } else {
77073 +               fix->smem_len = ivideo.video_size - 0x100000;
77074 +           }
77075          } else
77076                 fix->smem_len = sisfb_mem * 1024;
77077  
77078 -       fix->type        = video_type;
77079 +       fix->type        = FB_TYPE_PACKED_PIXELS;
77080         fix->type_aux    = 0;
77081         if(ivideo.video_bpp == 8)
77082                 fix->visual = FB_VISUAL_PSEUDOCOLOR;
77083         else
77084                 fix->visual = FB_VISUAL_TRUECOLOR;
77085         fix->xpanstep    = 0;
77086 -#ifdef SISFB_PAN
77087 +
77088          if(sisfb_ypan)          fix->ypanstep = 1;
77089 -#endif
77090 +
77091         fix->ywrapstep   = 0;
77092         fix->line_length = ivideo.video_linelength;
77093         fix->mmio_start  = ivideo.mmio_base;
77094         fix->mmio_len    = sisfb_mmio_size;
77095         if(sisvga_engine == SIS_300_VGA) 
77096            fix->accel    = FB_ACCEL_SIS_GLAMOUR;
77097 -       else if(ivideo.chip == SIS_330)
77098 +       else if((ivideo.chip == SIS_330) || (ivideo.chip == SIS_660) || (ivideo.chip == SIS_760))
77099            fix->accel    = FB_ACCEL_SIS_XABRE;
77100 -       else 
77101 +       else
77102            fix->accel    = FB_ACCEL_SIS_GLAMOUR_2;
77103 -       
77104 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)         
77105 +
77106 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
77107         fix->reserved[0] = ivideo.video_size & 0xFFFF;
77108         fix->reserved[1] = (ivideo.video_size >> 16) & 0xFFFF;
77109         fix->reserved[2] = sisfb_caps;
77110 -#endif 
77111 +#endif
77112  
77113 -       TWDEBUG("end of get_fix");
77114         return 0;
77115  }
77116  
77117 @@ -2033,17 +2438,15 @@ static int sisfb_get_fix(struct fb_fix_s
77118  
77119  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
77120  static struct fb_ops sisfb_ops = {
77121 -       owner:          THIS_MODULE,
77122 -       fb_get_fix:     sisfb_get_fix,
77123 -       fb_get_var:     sisfb_get_var,
77124 -       fb_set_var:     sisfb_set_var,
77125 -       fb_get_cmap:    sisfb_get_cmap,
77126 -       fb_set_cmap:    sisfb_set_cmap,
77127 -#ifdef SISFB_PAN
77128 -        fb_pan_display:        sisfb_pan_display,
77129 -#endif
77130 -       fb_ioctl:       sisfb_ioctl,
77131 -       fb_mmap:        sisfb_mmap,
77132 +       .owner          = THIS_MODULE,
77133 +       .fb_get_fix     = sisfb_get_fix,
77134 +       .fb_get_var     = sisfb_get_var,
77135 +       .fb_set_var     = sisfb_set_var,
77136 +       .fb_get_cmap    = sisfb_get_cmap,
77137 +       .fb_set_cmap    = sisfb_set_cmap,
77138 +        .fb_pan_display = sisfb_pan_display,
77139 +       .fb_ioctl       = sisfb_ioctl,
77140 +       .fb_mmap        = sisfb_mmap,
77141  };
77142  #endif
77143  
77144 @@ -2056,9 +2459,7 @@ static struct fb_ops sisfb_ops = {
77145         .fb_check_var = sisfb_check_var,
77146         .fb_set_par   = sisfb_set_par,
77147         .fb_setcolreg = sisfb_setcolreg,
77148 -#ifdef SISFB_PAN
77149          .fb_pan_display = sisfb_pan_display,
77150 -#endif 
77151          .fb_blank     = sisfb_blank,
77152         .fb_fillrect  = fbcon_sis_fillrect,
77153         .fb_copyarea  = fbcon_sis_copyarea,
77154 @@ -2105,35 +2506,42 @@ static int sisfb_get_dram_size_300(void)
77155  
77156         } else {                /* 540, 630, 730 */
77157  
77158 -               pdev = pci_find_device(PCI_VENDOR_ID_SI, nbridge_id, pdev);
77159 -               if (pdev) {
77160 -                       pci_read_config_byte(pdev, IND_BRI_DRAM_STATUS, &pci_data);
77161 -                       pci_data = (pci_data & BRI_DRAM_SIZE_MASK) >> 4;
77162 -                       ivideo.video_size = (unsigned int)(1 << (pci_data+21));
77163 -                       pdev_valid = 1;
77164 -
77165 -                       reg = SIS_DATA_BUS_64 << 6;
77166 -                       switch (pci_data) {
77167 -                          case BRI_DRAM_SIZE_2MB:
77168 -                               reg |= SIS_DRAM_SIZE_2MB;
77169 -                               break;
77170 -                          case BRI_DRAM_SIZE_4MB:
77171 -                               reg |= SIS_DRAM_SIZE_4MB;
77172 -                               break;
77173 -                          case BRI_DRAM_SIZE_8MB:
77174 -                               reg |= SIS_DRAM_SIZE_8MB;
77175 -                               break;
77176 -                          case BRI_DRAM_SIZE_16MB:
77177 -                               reg |= SIS_DRAM_SIZE_16MB;
77178 -                               break;
77179 -                          case BRI_DRAM_SIZE_32MB:
77180 -                               reg |= SIS_DRAM_SIZE_32MB;
77181 -                               break;
77182 -                          case BRI_DRAM_SIZE_64MB:
77183 -                               reg |= SIS_DRAM_SIZE_64MB;
77184 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,74)
77185 +               pci_for_each_dev(pdev) {
77186 +#else
77187 +               while((pdev = pci_find_device(PCI_VENDOR_ID_SI, PCI_ANY_ID, pdev))) {
77188 +#endif
77189 +                       if ((pdev->vendor == PCI_VENDOR_ID_SI)
77190 +                                      && (pdev->device == nbridge_id)) {
77191 +                               pci_read_config_byte(pdev, IND_BRI_DRAM_STATUS, &pci_data);
77192 +                               pci_data = (pci_data & BRI_DRAM_SIZE_MASK) >> 4;
77193 +                               ivideo.video_size = (unsigned int)(1 << (pci_data+21));
77194 +                               pdev_valid = 1;
77195 +
77196 +                               reg = SIS_DATA_BUS_64 << 6;
77197 +                               switch (pci_data) {
77198 +                                  case BRI_DRAM_SIZE_2MB:
77199 +                                       reg |= SIS_DRAM_SIZE_2MB;
77200 +                                       break;
77201 +                                  case BRI_DRAM_SIZE_4MB:
77202 +                                       reg |= SIS_DRAM_SIZE_4MB;
77203 +                                       break;
77204 +                                  case BRI_DRAM_SIZE_8MB:
77205 +                                       reg |= SIS_DRAM_SIZE_8MB;
77206 +                                       break;
77207 +                                  case BRI_DRAM_SIZE_16MB:
77208 +                                       reg |= SIS_DRAM_SIZE_16MB;
77209 +                                       break;
77210 +                                  case BRI_DRAM_SIZE_32MB:
77211 +                                       reg |= SIS_DRAM_SIZE_32MB;
77212 +                                       break;
77213 +                                  case BRI_DRAM_SIZE_64MB:
77214 +                                       reg |= SIS_DRAM_SIZE_64MB;
77215 +                                       break;
77216 +                               }
77217 +                               outSISIDXREG(SISSR, IND_SIS_DRAM_SIZE, reg);
77218                                 break;
77219                         }
77220 -                       outSISIDXREG(SISSR, IND_SIS_DRAM_SIZE, reg);
77221                 }
77222         
77223                 if (!pdev_valid)  return -1;
77224 @@ -2141,171 +2549,10 @@ static int sisfb_get_dram_size_300(void)
77225         return 0;
77226  }
77227  
77228 -static void sisfb_detect_VB_connect_300()
77229 -{
77230 -       u8 sr16, sr17, cr32, temp;
77231 -
77232 -       ivideo.TV_plug = ivideo.TV_type = 0;
77233 -
77234 -        switch(ivideo.hasVB) {
77235 -         case HASVB_LVDS_CHRONTEL:
77236 -         case HASVB_CHRONTEL:
77237 -            SiS_SenseCh();
77238 -            break;
77239 -         case HASVB_301:
77240 -         case HASVB_302:
77241 -            SiS_Sense30x();
77242 -            break;
77243 -       }
77244 -
77245 -       inSISIDXREG(SISSR, IND_SIS_SCRATCH_REG_17, sr17);
77246 -        inSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR32, cr32);
77247 -
77248 -       if ((sr17 & 0x0F) && (ivideo.chip != SIS_300)) {
77249 -
77250 -               if ((sr17 & 0x01) && !sisfb_crt1off)
77251 -                       sisfb_crt1off = 0;
77252 -               else {
77253 -                       if (sr17 & 0x0E)
77254 -                               sisfb_crt1off = 1;
77255 -                       else
77256 -                               sisfb_crt1off = 0;
77257 -               }
77258 -
77259 -               if (sisfb_crt2type != -1)
77260 -                       /* TW: override detected CRT2 type */
77261 -                       ivideo.disp_state = sisfb_crt2type;
77262 -                else if (sr17 & 0x04)
77263 -                       ivideo.disp_state = DISPTYPE_TV;                        
77264 -               else if (sr17 & 0x02)
77265 -                       ivideo.disp_state = DISPTYPE_LCD;                       
77266 -               else if (sr17 & 0x08 )
77267 -                       ivideo.disp_state = DISPTYPE_CRT2;
77268 -               else
77269 -                       ivideo.disp_state = 0;
77270 -
77271 -               if(sisfb_tvplug != -1)
77272 -                       /* PR/TW: override detected TV type */
77273 -                       ivideo.TV_plug = sisfb_tvplug;
77274 -               else if (sr17 & 0x20)
77275 -                       ivideo.TV_plug = TVPLUG_SVIDEO;
77276 -               else if (sr17 & 0x10)
77277 -                       ivideo.TV_plug = TVPLUG_COMPOSITE;
77278 -
77279 -               inSISIDXREG(SISSR, IND_SIS_SCRATCH_REG_16, sr16);
77280 -               if (sr16 & 0x20)
77281 -                       ivideo.TV_type = TVMODE_PAL;
77282 -               else
77283 -                       ivideo.TV_type = TVMODE_NTSC;
77284 -
77285 -       } else {
77286 -
77287 -               if ((cr32 & SIS_CRT1) && !sisfb_crt1off)
77288 -                       sisfb_crt1off = 0;
77289 -               else {
77290 -                       if (cr32 & 0x5F)
77291 -                               sisfb_crt1off = 1;
77292 -                       else
77293 -                               sisfb_crt1off = 0;
77294 -               }
77295 -
77296 -               if (sisfb_crt2type != -1)
77297 -                       /* TW: override detected CRT2 type */
77298 -                       ivideo.disp_state = sisfb_crt2type;
77299 -               else if (cr32 & SIS_VB_TV)
77300 -                       ivideo.disp_state = DISPTYPE_TV;
77301 -               else if (cr32 & SIS_VB_LCD)
77302 -                       ivideo.disp_state = DISPTYPE_LCD;
77303 -               else if (cr32 & SIS_VB_CRT2)
77304 -                       ivideo.disp_state = DISPTYPE_CRT2;
77305 -               else
77306 -                       ivideo.disp_state = 0;
77307 -
77308 -               /* TW: Detect TV plug & type */
77309 -               if(sisfb_tvplug != -1)
77310 -                       /* PR/TW: override with option */
77311 -                       ivideo.TV_plug = sisfb_tvplug;
77312 -               else if (cr32 & SIS_VB_HIVISION) {
77313 -                       ivideo.TV_type = TVMODE_HIVISION;
77314 -                       ivideo.TV_plug = TVPLUG_SVIDEO;
77315 -               }
77316 -               else if (cr32 & SIS_VB_SVIDEO)
77317 -                       ivideo.TV_plug = TVPLUG_SVIDEO;
77318 -               else if (cr32 & SIS_VB_COMPOSITE)
77319 -                       ivideo.TV_plug = TVPLUG_COMPOSITE;
77320 -               else if (cr32 & SIS_VB_SCART)
77321 -                       ivideo.TV_plug = TVPLUG_SCART;
77322 -
77323 -               if (ivideo.TV_type == 0) {
77324 -                       inSISIDXREG(SISSR, IND_SIS_POWER_ON_TRAP, temp);
77325 -                       if (temp & 0x01)
77326 -                               ivideo.TV_type = TVMODE_PAL;
77327 -                       else
77328 -                               ivideo.TV_type = TVMODE_NTSC;
77329 -               }
77330 -
77331 -       }
77332 -
77333 -       /* TW: Copy forceCRT1 option to CRT1off if option is given */
77334 -       if (sisfb_forcecrt1 != -1) {
77335 -               if(sisfb_forcecrt1) sisfb_crt1off = 0;
77336 -               else                sisfb_crt1off = 1;
77337 -       }
77338 -}
77339 -
77340 -static void sisfb_get_VB_type_300(void)
77341 -{
77342 -       u8 reg;
77343 -
77344 -       if(ivideo.chip != SIS_300) {
77345 -               if(!sisfb_has_VB_300()) {
77346 -                       inSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR37, reg);
77347 -                       switch ((reg & SIS_EXTERNAL_CHIP_MASK) >> 1) {
77348 -                          case SIS_EXTERNAL_CHIP_LVDS:
77349 -                               ivideo.hasVB = HASVB_LVDS;
77350 -                               break;
77351 -                          case SIS_EXTERNAL_CHIP_TRUMPION:
77352 -                               ivideo.hasVB = HASVB_TRUMPION;
77353 -                               break;
77354 -                          case SIS_EXTERNAL_CHIP_LVDS_CHRONTEL:
77355 -                               ivideo.hasVB = HASVB_LVDS_CHRONTEL;
77356 -                               break;
77357 -                          case SIS_EXTERNAL_CHIP_CHRONTEL:
77358 -                               ivideo.hasVB = HASVB_CHRONTEL;
77359 -                               break;
77360 -                          default:
77361 -                               break;
77362 -                       }
77363 -               }
77364 -       } else {
77365 -               sisfb_has_VB_300();
77366 -       }
77367 -}
77368 -
77369 -static int sisfb_has_VB_300(void)
77370 -{
77371 -       u8 vb_chipid;
77372 -
77373 -       inSISIDXREG(SISPART4, 0x00, vb_chipid);
77374 -       switch (vb_chipid) {
77375 -          case 0x01:
77376 -               ivideo.hasVB = HASVB_301;
77377 -               break;
77378 -          case 0x02:
77379 -               ivideo.hasVB = HASVB_302;
77380 -               break;
77381 -          default:
77382 -               ivideo.hasVB = HASVB_NONE;
77383 -               return FALSE;
77384 -       }
77385 -       return TRUE;
77386 -
77387 -}
77388 -
77389  #endif  /* CONFIG_FB_SIS_300 */
77390  
77391  
77392 -#ifdef CONFIG_FB_SIS_315    /* for SiS 315/550/650/740/330 */
77393 +#ifdef CONFIG_FB_SIS_315    /* for SiS 315/550/650/740/330/660/760 */
77394  
77395  static int sisfb_get_dram_size_315(void)
77396  {
77397 @@ -2314,21 +2561,33 @@ static int sisfb_get_dram_size_315(void)
77398         u8  pci_data;
77399         u8  reg = 0;
77400  
77401 -       if (ivideo.chip == SIS_550 || ivideo.chip == SIS_650 || ivideo.chip == SIS_740) {
77402 +       if (ivideo.chip == SIS_550 ||
77403 +           ivideo.chip == SIS_650 ||
77404 +           ivideo.chip == SIS_740 ||
77405 +           ivideo.chip == SIS_660 ||
77406 +           ivideo.chip == SIS_760) {
77407  
77408  #ifdef LINUXBIOS
77409  
77410 -               while ((pdev = pci_find_device(PCI_VENDOR_ID_SI, PCI_ANY_ID, pdev)) != NULL) {
77411 -                       if ((pdev->device == PCI_DEVICE_ID_SI_550) ||
77412 -                            (pdev->device == PCI_DEVICE_ID_SI_650) ||
77413 -                            (pdev->device == PCI_DEVICE_ID_SI_740)) {
77414 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,74)
77415 +               pci_for_each_dev(pdev) {
77416 +#else
77417 +               while((pdev = pci_find_device(PCI_VENDOR_ID_SI, PCI_ANY_ID, pdev))) {
77418 +#endif
77419 +
77420 +                       if ( (pdev->vendor == PCI_VENDOR_ID_SI)
77421 +                               && ( (pdev->device == PCI_DEVICE_ID_SI_550) ||
77422 +                                    (pdev->device == PCI_DEVICE_ID_SI_650) ||
77423 +                                    (pdev->device == PCI_DEVICE_ID_SI_740) ||
77424 +                                    (pdev->device == PCI_DEVICE_ID_SI_660) ||
77425 +                                    (pdev->device == PCI_DEVICE_ID_SI_760))) {
77426                                 pci_read_config_byte(pdev, IND_BRI_DRAM_STATUS,
77427                                                      &pci_data);
77428                                 pci_data = (pci_data & BRI_DRAM_SIZE_MASK) >> 4;
77429                                 ivideo.video_size = (unsigned int)(1 << (pci_data + 21));
77430                                 pdev_valid = 1;
77431  
77432 -                               /* TW: Initialize SR14 "by hand" */
77433 +                               /* Initialize SR14 "by hand" */
77434                                 inSISIDXREG(SISSR, IND_SIS_DRAM_SIZE, reg);
77435                                 reg &= 0xC0;
77436                                 switch (pci_data) {
77437 @@ -2390,7 +2649,15 @@ static int sisfb_get_dram_size_315(void)
77438                                "now reading from PCI config\n");
77439                         pdev_valid = 0;
77440  
77441 -                       while ((pdev = pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_550, pdev)) != NULL) {
77442 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,74)
77443 +                       pci_for_each_dev(pdev) {
77444 +#else
77445 +                       while((pdev = pci_find_device(PCI_VENDOR_ID_SI, PCI_ANY_ID, pdev))) {
77446 +#endif
77447 +
77448 +                          if ( (pdev->vendor == PCI_VENDOR_ID_SI)
77449 +                                && (pdev->device == PCI_DEVICE_ID_SI_550) ) {
77450 +
77451                                 pci_read_config_byte(pdev, IND_BRI_DRAM_STATUS,
77452                                                      &pci_data);
77453                                 pci_data = (pci_data & BRI_DRAM_SIZE_MASK) >> 4;
77454 @@ -2415,6 +2682,7 @@ static int sisfb_get_dram_size_315(void)
77455                                         return -1;
77456                                 }
77457                                 outSISIDXREG(SISSR, IND_SIS_DRAM_SIZE, reg);
77458 +                          }
77459                         }
77460                         if (!pdev_valid) {
77461                                 printk(KERN_INFO "sisfb: Total confusion - No SiS PCI VGA device found?!\n");
77462 @@ -2425,7 +2693,7 @@ static int sisfb_get_dram_size_315(void)
77463  #endif
77464                 return 0;
77465  
77466 -       } else {        /* 315 */
77467 +       } else {        /* 315, 330 */
77468  
77469                 inSISIDXREG(SISSR, IND_SIS_DRAM_SIZE, reg);
77470                 switch ((reg & SIS315_DRAM_SIZE_MASK) >> 4) {
77471 @@ -2458,7 +2726,7 @@ static int sisfb_get_dram_size_315(void)
77472                 reg >>= 2;
77473                 
77474                 if(ivideo.chip == SIS_330) {
77475 -               
77476 +
77477                    if(reg) ivideo.video_size <<= 1;
77478                 
77479                 } else {
77480 @@ -2470,7 +2738,7 @@ static int sisfb_get_dram_size_315(void)
77481                       case SIS315_DUAL_CHANNEL_1_RANK:
77482                            ivideo.video_size <<= 1;
77483                            break;
77484 -                     case SIS315_ASYM_DDR:             /* TW: DDR asymentric */
77485 +                     case SIS315_ASYM_DDR:             /* TW: DDR asymetric */
77486                            ivideo.video_size += (ivideo.video_size/2);
77487                            break;
77488                    }
77489 @@ -2483,127 +2751,241 @@ static int sisfb_get_dram_size_315(void)
77490         
77491  }
77492  
77493 -static void sisfb_detect_VB_connect_315(void)
77494 +#endif   /* CONFIG_FB_SIS_315 */
77495 +
77496 +
77497 +/* -------------- video bridge detection --------------- */
77498 +
77499 +static void sisfb_detect_VB_connect()
77500  {
77501 -       u8 cr32, temp=0;
77502 +       u8 sr16, sr17, cr32, temp;
77503 +
77504 +       if(sisvga_engine == SIS_300_VGA) {
77505  
77506 -       ivideo.TV_plug = ivideo.TV_type = 0;
77507 +               inSISIDXREG(SISSR, IND_SIS_SCRATCH_REG_17, sr17);
77508 +
77509 +               if ((sr17 & 0x0F) && (ivideo.chip != SIS_300)) {
77510 +
77511 +                       /* Old BIOSes store the detected CRT2 type in SR17
77512 +                        * instead of CR32. However, since our detection
77513 +                        * routines store their results to CR32, we now copy
77514 +                        * the remaining bits (for LCD and VGA) to CR32 for
77515 +                        * unified usage.
77516 +                        * SR17[0] CRT1    [1] LCD     [2] TV    [3] VGA2
77517 +                        *     [4] AVIDEO  [5] SVIDEO
77518 +                        */
77519 +
77520 +#if 0
77521 +                       if (sr17 & 0x01) orSISIDXREG(SISCR, 0x32, SIS_CRT1);
77522 +                       else             andSISIDXREG(SISCR, 0x32, ~SIS_CRT1);
77523 +
77524 +                       if (sr17 & 0x02) orSISIDXREG(SISCR, 0x32, SIS_VB_LCD);
77525 +                       else             andSISIDXREG(SISCR, 0x32, ~SIS_VB_LCD);
77526 +
77527 +                       /* no HiVision and no DVI connector here */
77528 +                       andSISIDXREG(SISCR, 0x32, ~0xc0);
77529 +#endif
77530 +
77531 +                       /* PAL/NTSC is stored on SR16 on such machines */
77532 +                       if (!(ivideo.vbflags & (TV_PAL | TV_NTSC))) {
77533 +                               inSISIDXREG(SISSR, IND_SIS_SCRATCH_REG_16, sr16);
77534 +                               if (sr16 & 0x20)
77535 +                                       ivideo.vbflags |= TV_PAL;
77536 +                               else
77537 +                                       ivideo.vbflags |= TV_NTSC;
77538 +                       }
77539 +
77540 +               }
77541  
77542 -        switch(ivideo.hasVB) {
77543 -         case HASVB_LVDS_CHRONTEL:
77544 -         case HASVB_CHRONTEL:
77545 -            SiS_SenseCh();
77546 -            break;
77547 -         case HASVB_301:
77548 -         case HASVB_302:
77549 -            SiS_Sense30x();
77550 -            break;
77551         }
77552  
77553         inSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR32, cr32);
77554  
77555 -       if ((cr32 & SIS_CRT1) && !sisfb_crt1off)
77556 +       if (cr32 & SIS_CRT1)
77557                 sisfb_crt1off = 0;
77558         else {
77559 -               if (cr32 & 0x5F)   
77560 +               if (cr32 & 0x5F)
77561                         sisfb_crt1off = 1;
77562                 else
77563                         sisfb_crt1off = 0;
77564         }
77565  
77566 -       if (sisfb_crt2type != -1)
77567 -               /* TW: Override with option */
77568 -               ivideo.disp_state = sisfb_crt2type;
77569 -       else if (cr32 & SIS_VB_TV)
77570 -               ivideo.disp_state = DISPTYPE_TV;                
77571 -       else if (cr32 & SIS_VB_LCD)
77572 -               ivideo.disp_state = DISPTYPE_LCD;               
77573 -       else if (cr32 & SIS_VB_CRT2)
77574 -               ivideo.disp_state = DISPTYPE_CRT2;
77575 -       else
77576 -               ivideo.disp_state = 0;
77577 +       ivideo.vbflags &= ~(CRT2_TV | CRT2_LCD | CRT2_VGA);
77578  
77579 +       if (cr32 & SIS_VB_TV)
77580 +               ivideo.vbflags |= CRT2_TV;
77581 +       if (cr32 & SIS_VB_LCD)
77582 +               ivideo.vbflags |= CRT2_LCD;
77583 +       if (cr32 & SIS_VB_CRT2)
77584 +               ivideo.vbflags |= CRT2_VGA;
77585 +
77586 +       /* TW: Detect/set TV plug & type */
77587         if(sisfb_tvplug != -1)
77588 -               /* PR/TW: Override with option */
77589 -               ivideo.TV_plug = sisfb_tvplug;
77590 -       else if (cr32 & SIS_VB_HIVISION) {
77591 -               ivideo.TV_type = TVMODE_HIVISION;
77592 -               ivideo.TV_plug = TVPLUG_SVIDEO;
77593 -       }
77594 +               ivideo.vbflags |= sisfb_tvplug;
77595 +       if (cr32 & SIS_VB_HIVISION)
77596 +               ivideo.vbflags |= (TV_HIVISION | TV_SVIDEO);
77597         else if (cr32 & SIS_VB_SVIDEO)
77598 -               ivideo.TV_plug = TVPLUG_SVIDEO;
77599 +               ivideo.vbflags |= TV_SVIDEO;
77600         else if (cr32 & SIS_VB_COMPOSITE)
77601 -               ivideo.TV_plug = TVPLUG_COMPOSITE;
77602 +               ivideo.vbflags |= TV_AVIDEO;
77603         else if (cr32 & SIS_VB_SCART)
77604 -               ivideo.TV_plug = TVPLUG_SCART;
77605 +               ivideo.vbflags |= TV_SCART;
77606  
77607 -       if(ivideo.TV_type == 0) {
77608 -           /* TW: PAL/NTSC changed for 650 */
77609 -           if((ivideo.chip <= SIS_315PRO) || (ivideo.chip >= SIS_330)) {
77610 -
77611 -                inSISIDXREG(SISCR, 0x38, temp);
77612 -               if(temp & 0x10)
77613 -                       ivideo.TV_type = TVMODE_PAL;
77614 -               else
77615 -                       ivideo.TV_type = TVMODE_NTSC;
77616 +       if (!(ivideo.vbflags & (TV_PAL | TV_NTSC))) {
77617 +               if(sisvga_engine == SIS_300_VGA) {
77618 +                       inSISIDXREG(SISSR, IND_SIS_POWER_ON_TRAP, temp);
77619 +                       if (temp & 0x01)
77620 +                               ivideo.vbflags |= TV_PAL;
77621 +                       else
77622 +                               ivideo.vbflags |= TV_NTSC;
77623 +               } else if((ivideo.chip <= SIS_315PRO) || (ivideo.chip == SIS_330)) {
77624  
77625 -           } else {
77626 +                       inSISIDXREG(SISCR, 0x38, temp);
77627 +                       if(temp & 0x10)
77628 +                               ivideo.vbflags |= TV_PAL;
77629 +                       else
77630 +                               ivideo.vbflags |= TV_NTSC;
77631  
77632 -               inSISIDXREG(SISCR, 0x79, temp);
77633 -               if(temp & 0x20)
77634 -                       ivideo.TV_type = TVMODE_PAL;
77635 -               else
77636 -                       ivideo.TV_type = TVMODE_NTSC;
77637 -           }
77638 +               } else {
77639 +
77640 +                       inSISIDXREG(SISCR, 0x79, temp);
77641 +                       if(temp & 0x20)
77642 +                               ivideo.vbflags |= TV_PAL;
77643 +                       else
77644 +                               ivideo.vbflags |= TV_NTSC;
77645 +               }
77646         }
77647  
77648         /* TW: Copy forceCRT1 option to CRT1off if option is given */
77649         if (sisfb_forcecrt1 != -1) {
77650 -               if (sisfb_forcecrt1) sisfb_crt1off = 0;
77651 -               else                 sisfb_crt1off = 1;
77652 +               if(sisfb_forcecrt1) sisfb_crt1off = 0;
77653 +               else                sisfb_crt1off = 1;
77654         }
77655 -}
77656 -
77657 -static void sisfb_get_VB_type_315(void)
77658 -{
77659 -       u8 reg;
77660  
77661 -       if (!sisfb_has_VB_315()) {
77662 -               inSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR37, reg);
77663 -               switch ((reg & SIS_EXTERNAL_CHIP_MASK) >> 1) {
77664 -                  case SIS310_EXTERNAL_CHIP_LVDS:
77665 -                       ivideo.hasVB = HASVB_LVDS;
77666 -                       break;
77667 -                  case SIS310_EXTERNAL_CHIP_LVDS_CHRONTEL:
77668 -                       ivideo.hasVB = HASVB_LVDS_CHRONTEL;
77669 -                       break;
77670 -                  default:
77671 -                       break;
77672 -               }
77673 -       }
77674  }
77675  
77676 -
77677 -static int sisfb_has_VB_315(void)
77678 +static void sisfb_get_VB_type(void)
77679  {
77680         u8 vb_chipid;
77681 +       u8 reg;
77682 +       char stdstr[]    = "sisfb: Detected";
77683 +       char bridgestr[] = "video bridge";
77684 +       char lvdsstr[]   = "LVDS transmitter";
77685 +       char chrstr[]    = "Chrontel TV encoder";
77686 +
77687 +       ivideo.hasVB = HASVB_NONE;
77688 +       sishw_ext.ujVBChipID = VB_CHIP_UNKNOWN;
77689 +       sishw_ext.Is301BDH = FALSE;
77690 +       sishw_ext.usExternalChip = 0;
77691  
77692         inSISIDXREG(SISPART4, 0x00, vb_chipid);
77693         switch (vb_chipid) {
77694            case 0x01:
77695                 ivideo.hasVB = HASVB_301;
77696 +               inSISIDXREG(SISPART4, 0x01, reg);
77697 +               if(reg < 0xb0) {
77698 +                       ivideo.vbflags |= VB_301;
77699 +                       sishw_ext.ujVBChipID = VB_CHIP_301;
77700 +                       printk(KERN_INFO "%s SiS301 %s\n", stdstr, bridgestr);
77701 +               } else if(reg < 0xd0) {
77702 +                       ivideo.vbflags |= VB_301B;
77703 +                       sishw_ext.ujVBChipID = VB_CHIP_301B;
77704 +                       printk(KERN_INFO "%s SiS301B %s\n", stdstr, bridgestr);
77705 +               } else if(reg < 0xe0) {
77706 +                       ivideo.vbflags |= VB_301LV;
77707 +                       sishw_ext.ujVBChipID = VB_CHIP_301LV;
77708 +                       printk(KERN_INFO "%s SiS301LV %s\n", stdstr, bridgestr);
77709 +               } else if(reg <= 0xe1) {
77710 +                       ivideo.vbflags |= VB_302LV;
77711 +                       sishw_ext.ujVBChipID = VB_CHIP_302LV;
77712 +                       printk(KERN_INFO "%s SiS302LV %s\n", stdstr, bridgestr);
77713 +               }
77714                 break;
77715            case 0x02:
77716                 ivideo.hasVB = HASVB_302;
77717 +               inSISIDXREG(SISPART4, 0x01, reg);
77718 +               if(reg < 0xd0) {
77719 +                       ivideo.vbflags |= VB_302B;
77720 +                       sishw_ext.ujVBChipID = VB_CHIP_302B;
77721 +                       printk(KERN_INFO "%s SiS302B %s\n", stdstr, bridgestr);
77722 +               } else if(reg < 0xe0) {
77723 +                       ivideo.vbflags |= VB_301LV;
77724 +                       sishw_ext.ujVBChipID = VB_CHIP_301LV;
77725 +                       printk(KERN_INFO "%s SiS301LV %s\n", stdstr, bridgestr);
77726 +               } else if(reg <= 0xe1) {
77727 +                       ivideo.vbflags |= VB_302LV;
77728 +                       sishw_ext.ujVBChipID = VB_CHIP_302LV;
77729 +                       printk(KERN_INFO "%s SiS302LV %s\n", stdstr, bridgestr);
77730 +               }
77731                 break;
77732 -          default:
77733 -               ivideo.hasVB = HASVB_NONE;
77734 -               return FALSE;
77735         }
77736 -       return TRUE;
77737 -}
77738  
77739 -#endif   /* CONFIG_FB_SIS_315 */
77740 +       if(ivideo.vbflags & (VB_301B | VB_302B)) {
77741 +               inSISIDXREG(SISPART4,0x23,reg);
77742 +               if(!(reg & 0x02)) {
77743 +                       sishw_ext.Is301BDH = TRUE;
77744 +                       ivideo.vbflags |= VB_30xBDH;
77745 +                       printk(KERN_INFO "This %s does not support LCD output\n", bridgestr);
77746 +               }
77747 +       }
77748 +
77749 +       if((!(ivideo.vbflags & VB_VIDEOBRIDGE)) && (ivideo.chip != SIS_300)) {
77750 +               inSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR37, reg);
77751 +               reg &= SIS_EXTERNAL_CHIP_MASK;
77752 +               reg >>= 1;
77753 +               if(sisvga_engine == SIS_300_VGA) {
77754 +                       switch (reg) {
77755 +                          case SIS_EXTERNAL_CHIP_LVDS:
77756 +                               ivideo.hasVB = HASVB_LVDS;
77757 +                               ivideo.vbflags |= VB_LVDS;
77758 +                               sishw_ext.usExternalChip = 0x01;
77759 +                               printk(KERN_INFO "%s %s\n", stdstr, lvdsstr);
77760 +                               break;
77761 +                          case SIS_EXTERNAL_CHIP_TRUMPION:
77762 +                               ivideo.hasVB = HASVB_TRUMPION;
77763 +                               ivideo.vbflags |= VB_TRUMPION;
77764 +                               sishw_ext.usExternalChip = 0x02;
77765 +                               printk(KERN_INFO "%s Trumpion LCD scaler\n", stdstr);
77766 +                               break;
77767 +                          case SIS_EXTERNAL_CHIP_CHRONTEL:
77768 +                               ivideo.hasVB = HASVB_CHRONTEL;
77769 +                               ivideo.vbflags |= VB_CHRONTEL;
77770 +                               sishw_ext.usExternalChip = 0x04;
77771 +                               printk(KERN_INFO "%s %s\n", stdstr, chrstr);
77772 +                               break;
77773 +                          case SIS_EXTERNAL_CHIP_LVDS_CHRONTEL:
77774 +                               ivideo.hasVB = HASVB_LVDS_CHRONTEL;
77775 +                               ivideo.vbflags |= (VB_LVDS | VB_CHRONTEL);
77776 +                               sishw_ext.usExternalChip = 0x05;
77777 +                               printk(KERN_INFO "%s %s and %s\n", stdstr, lvdsstr, chrstr);
77778 +                               break;
77779 +                       }
77780 +               } else {
77781 +                       switch (reg) {
77782 +                          case SIS310_EXTERNAL_CHIP_LVDS:
77783 +                               ivideo.hasVB = HASVB_LVDS;
77784 +                               ivideo.vbflags |= VB_LVDS;
77785 +                               sishw_ext.usExternalChip = 0x01;
77786 +                               printk(KERN_INFO "%s %s\n", stdstr, lvdsstr);
77787 +                               break;
77788 +                          case SIS310_EXTERNAL_CHIP_LVDS_CHRONTEL:
77789 +                               ivideo.hasVB = HASVB_LVDS_CHRONTEL;
77790 +                               ivideo.vbflags |= (VB_LVDS | VB_CHRONTEL);
77791 +                               sishw_ext.usExternalChip = 0x05;
77792 +                               printk(KERN_INFO "%s %s and %s\n", stdstr, lvdsstr, chrstr);
77793 +                               break;
77794 +                       }
77795 +               }
77796 +
77797 +       }
77798 +
77799 +       if(ivideo.vbflags & VB_SISBRIDGE) {
77800 +               SiS_Sense30x();
77801 +       } else if(ivideo.vbflags & VB_CHRONTEL) {
77802 +               SiS_SenseCh();
77803 +       }
77804 +
77805 +}
77806  
77807  /* ------------------ Sensing routines ------------------ */
77808  
77809 @@ -2621,34 +3003,39 @@ SISDoSense(int tempbl, int tempbh, int t
77810      inSISIDXREG(SISPART4,0x03,temp);
77811      temp ^= 0x0e;
77812      temp &= tempch;
77813 -    return(temp);
77814 +    return((temp == tempch));
77815  }
77816  
77817  void
77818  SiS_Sense30x(void)
77819  {
77820 -  u8 backupP4_0d;
77821 +  u8 backupP4_0d,backupP2_00;
77822    u8 testsvhs_tempbl, testsvhs_tempbh;
77823    u8 testsvhs_tempcl, testsvhs_tempch;
77824    u8 testcvbs_tempbl, testcvbs_tempbh;
77825    u8 testcvbs_tempcl, testcvbs_tempch;
77826    u8 testvga2_tempbl, testvga2_tempbh;
77827    u8 testvga2_tempcl, testvga2_tempch;
77828 -  int myflag, result;
77829 +  int myflag, result, haveresult, i, j;
77830 +  char stdstr[] = "sisfb: Detected";
77831 +  char tvstr[]  = "TV connected to";
77832  
77833    inSISIDXREG(SISPART4,0x0d,backupP4_0d);
77834    outSISIDXREG(SISPART4,0x0d,(backupP4_0d | 0x04));
77835  
77836 +  inSISIDXREG(SISPART2,0x00,backupP2_00);
77837 +  outSISIDXREG(SISPART2,0x00,(backupP2_00 | 0x1c));
77838 +
77839    if(sisvga_engine == SIS_300_VGA) {
77840  
77841 -       testvga2_tempbh = 0x00; testvga2_tempbl = 0xd1;
77842 -        testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xb9;
77843 -       testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xb3;
77844 -       if((sishw_ext.ujVBChipID != VB_CHIP_301) &&
77845 -          (sishw_ext.ujVBChipID != VB_CHIP_302) ) {
77846 -          testvga2_tempbh = 0x01; testvga2_tempbl = 0x90;
77847 -          testsvhs_tempbh = 0x01; testsvhs_tempbl = 0x6b;
77848 -          testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x74;
77849 +       if(ivideo.vbflags & (VB_301B|VB_302B|VB_301LV|VB_302LV)) {
77850 +               testvga2_tempbh = 0x01; testvga2_tempbl = 0x90;
77851 +               testsvhs_tempbh = 0x01; testsvhs_tempbl = 0x6b;
77852 +               testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x74;
77853 +       } else {
77854 +               testvga2_tempbh = 0x00; testvga2_tempbl = 0xd1;
77855 +               testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xb9;
77856 +               testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xb3;
77857         }
77858         inSISIDXREG(SISPART4,0x01,myflag);
77859         if(myflag & 0x04) {
77860 @@ -2657,35 +3044,36 @@ SiS_Sense30x(void)
77861            testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xee;
77862         }
77863         testvga2_tempch = 0x0e; testvga2_tempcl = 0x08;
77864 -       testsvhs_tempch = 0x06; testsvhs_tempcl = 0x04;
77865 +       testsvhs_tempch = 0x04; testsvhs_tempcl = 0x04;
77866         testcvbs_tempch = 0x08; testcvbs_tempcl = 0x04;
77867 +       if(ivideo.vbflags & (VB_301LV|VB_302LV)) {
77868 +               testvga2_tempbh = 0x00; testvga2_tempbl = 0x00;
77869 +               testvga2_tempch = 0x00; testvga2_tempcl = 0x00;
77870 +        }
77871         if(ivideo.chip == SIS_300) {
77872            inSISIDXREG(SISSR,0x3b,myflag);
77873            if(!(myflag & 0x01)) {
77874 -             testvga2_tempbh = 0x00; testvga2_tempbl = 0x00;
77875 -             testvga2_tempch = 0x00; testvga2_tempcl = 0x00;
77876 +               testvga2_tempbh = 0x00; testvga2_tempbl = 0x00;
77877 +               testvga2_tempch = 0x00; testvga2_tempcl = 0x00;
77878            }
77879         }
77880  
77881    } else {
77882  
77883 -       testvga2_tempbh = 0x00; testvga2_tempbl = 0xd1;
77884 -        testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xb9;
77885 -       testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xb3;
77886 -       if((sishw_ext.ujVBChipID != VB_CHIP_301) &&
77887 -          (sishw_ext.ujVBChipID != VB_CHIP_302)) {
77888 -             testvga2_tempbh = 0x01; testvga2_tempbl = 0x90;
77889 -             testsvhs_tempbh = 0x01; testsvhs_tempbl = 0x6b;
77890 -             testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x74;
77891 -             if(sishw_ext.ujVBChipID == VB_CHIP_301LV ||
77892 -                sishw_ext.ujVBChipID == VB_CHIP_302LV) {
77893 -                testvga2_tempbh = 0x00; testvga2_tempbl = 0x00;
77894 -                testsvhs_tempbh = 0x02; testsvhs_tempbl = 0x00;
77895 -                testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x00;
77896 -             }
77897 +       if(ivideo.vbflags & (VB_301B|VB_302B)) {
77898 +               testvga2_tempbh = 0x01; testvga2_tempbl = 0x90;
77899 +               testsvhs_tempbh = 0x01; testsvhs_tempbl = 0x6b;
77900 +               testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x74;
77901 +       } else if(ivideo.vbflags & (VB_301LV|VB_302LV)) {
77902 +               testvga2_tempbh = 0x00; testvga2_tempbl = 0x00;
77903 +               testsvhs_tempbh = 0x02; testsvhs_tempbl = 0x00;
77904 +               testcvbs_tempbh = 0x01; testcvbs_tempbl = 0x00;
77905 +       } else {
77906 +               testvga2_tempbh = 0x00; testvga2_tempbl = 0xd1;
77907 +               testsvhs_tempbh = 0x00; testsvhs_tempbl = 0xb9;
77908 +               testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xb3;
77909         }
77910 -       if(sishw_ext.ujVBChipID != VB_CHIP_301LV &&
77911 -          sishw_ext.ujVBChipID != VB_CHIP_302LV) {
77912 +       if(ivideo.vbflags & (VB_301|VB_301B|VB_302B)) {
77913            inSISIDXREG(SISPART4,0x01,myflag);
77914            if(myflag & 0x04) {
77915               testvga2_tempbh = 0x00; testvga2_tempbl = 0xfd;
77916 @@ -2693,49 +3081,78 @@ SiS_Sense30x(void)
77917               testcvbs_tempbh = 0x00; testcvbs_tempbl = 0xee;
77918            }
77919         }
77920 -       if((sishw_ext.ujVBChipID == VB_CHIP_301LV) ||
77921 -          (sishw_ext.ujVBChipID == VB_CHIP_302LV) ) {
77922 +       if(ivideo.vbflags & (VB_301LV|VB_302LV)) {
77923            testvga2_tempbh = 0x00; testvga2_tempbl = 0x00;
77924            testvga2_tempch = 0x00; testvga2_tempcl = 0x00;
77925            testsvhs_tempch = 0x04; testsvhs_tempcl = 0x08;
77926            testcvbs_tempch = 0x08; testcvbs_tempcl = 0x08;
77927         } else {
77928            testvga2_tempch = 0x0e; testvga2_tempcl = 0x08;
77929 -          testsvhs_tempch = 0x06; testsvhs_tempcl = 0x04;
77930 +          testsvhs_tempch = 0x04; testsvhs_tempcl = 0x04;
77931            testcvbs_tempch = 0x08; testcvbs_tempcl = 0x04;
77932         }
77933      } 
77934  
77935      if(testvga2_tempch || testvga2_tempcl || testvga2_tempbh || testvga2_tempbl) {
77936 -        result = SISDoSense(testvga2_tempbl, testvga2_tempbh,
77937 -                            testvga2_tempcl, testvga2_tempch);
77938 -       if(result) {
77939 -               printk(KERN_INFO "sisfb: Detected secondary VGA connection\n");
77940 -               orSISIDXREG(SISCR, 0x32, 0x10);
77941 -       }
77942 +       haveresult = 0;
77943 +       for(j = 0; j < 10; j++) {
77944 +          result = 0;
77945 +          for(i = 0; i < 3; i++) {
77946 +             if(SISDoSense(testvga2_tempbl, testvga2_tempbh,
77947 +                           testvga2_tempcl, testvga2_tempch))
77948 +               result++;
77949 +          }
77950 +         if((result == 0) || (result >= 2)) break;
77951 +       }
77952 +       if(result) {
77953 +          printk(KERN_INFO "%s secondary VGA connection\n", stdstr);
77954 +         orSISIDXREG(SISCR, 0x32, 0x10);
77955 +       } else {
77956 +         andSISIDXREG(SISCR, 0x32, ~0x10);
77957 +       }
77958 +    }
77959 +
77960 +    haveresult = 0;
77961 +    for(j = 0; j < 10; j++) {
77962 +       result = 0;
77963 +       for(i = 0; i < 3; i++) {
77964 +          if(SISDoSense(testsvhs_tempbl, testsvhs_tempbh,
77965 +                        testsvhs_tempcl, testsvhs_tempch))
77966 +               result++;
77967 +       }
77968 +       if((result == 0) || (result >= 2)) break;
77969      }
77970 -    
77971 -    result = SISDoSense(testsvhs_tempbl, testsvhs_tempbh,
77972 -                        testsvhs_tempcl, testsvhs_tempch);
77973      if(result) {
77974 -        printk(KERN_INFO "sisfb: Detected TV connected to SVHS output\n");
77975 -        /* TW: So we can be sure that there IS a SVHS output */
77976 -       ivideo.TV_plug = TVPLUG_SVIDEO;
77977 +        printk(KERN_INFO "%s %s SVIDEO output\n", stdstr, tvstr);
77978 +       ivideo.vbflags |= TV_SVIDEO;
77979         orSISIDXREG(SISCR, 0x32, 0x02);
77980 +       andSISIDXREG(SISCR, 0x32, ~0x05);
77981      }
77982  
77983      if(!result) {
77984 -        result = SISDoSense(testcvbs_tempbl, testcvbs_tempbh,
77985 -                           testcvbs_tempcl, testcvbs_tempch);
77986 +
77987 +       haveresult = 0;
77988 +               for(j = 0; j < 10; j++) {
77989 +           result = 0;
77990 +           for(i = 0; i < 3; i++) {
77991 +              if(SISDoSense(testcvbs_tempbl, testcvbs_tempbh,
77992 +                           testcvbs_tempcl, testcvbs_tempch))
77993 +               result++;
77994 +           }
77995 +           if((result == 0) || (result >= 2)) break;
77996 +        }
77997         if(result) {
77998 -           printk(KERN_INFO "sisfb: Detected TV connected to CVBS output\n");
77999 -           /* TW: So we can be sure that there IS a CVBS output */
78000 -           ivideo.TV_plug = TVPLUG_COMPOSITE;
78001 +           printk(KERN_INFO "%s %s COMPOSITE output\n", stdstr, tvstr);
78002 +           ivideo.vbflags |= TV_AVIDEO;
78003             orSISIDXREG(SISCR, 0x32, 0x01);
78004 +           andSISIDXREG(SISCR, 0x32, ~0x06);
78005 +       } else {
78006 +           andSISIDXREG(SISCR, 0x32, ~0x07);
78007         }
78008      }
78009      SISDoSense(0, 0, 0, 0);
78010  
78011 +    outSISIDXREG(SISPART2,0x00,backupP2_00);
78012      outSISIDXREG(SISPART4,0x0d,backupP4_0d);
78013  }
78014  
78015 @@ -2744,51 +3161,84 @@ void
78016  SiS_SenseCh(void)
78017  {
78018  
78019 -   u8 temp1;
78020 -#ifdef CONFIG_FB_SIS_315
78021 -   u8 temp2;
78022 +   u8 temp1, temp2;
78023 +#ifdef CONFIG_FB_SIS_300
78024 +   unsigned char test[3];
78025 +   int i;
78026  #endif
78027 +   char stdstr[] = "sisfb: Chrontel: Detected TV connected to";
78028  
78029     if(ivideo.chip < SIS_315H) {
78030  
78031  #ifdef CONFIG_FB_SIS_300
78032 -       SiS_Pr.SiS_IF_DEF_CH70xx = 1;           /* TW: Chrontel 7005 */
78033 +       SiS_Pr.SiS_IF_DEF_CH70xx = 1;           /* Chrontel 700x */
78034 +       SiS_SetChrontelGPIO(&SiS_Pr, 0x9c);     /* Set general purpose IO for Chrontel communication */
78035 +       SiS_DDC2Delay(&SiS_Pr, 1000);
78036         temp1 = SiS_GetCH700x(&SiS_Pr, 0x25);
78037 -       if ((temp1 >= 50) && (temp1 <= 100)) {
78038 -          /* TW: Read power status */
78039 +       /* TW: See Chrontel TB31 for explanation */
78040 +       temp2 = SiS_GetCH700x(&SiS_Pr, 0x0e);
78041 +       if(((temp2 & 0x07) == 0x01) || (temp2 & 0x04)) {
78042 +         SiS_SetCH700x(&SiS_Pr, 0x0b0e);
78043 +         SiS_DDC2Delay(&SiS_Pr, 300);
78044 +       }
78045 +       temp2 = SiS_GetCH700x(&SiS_Pr, 0x25);
78046 +       if(temp2 != temp1) temp1 = temp2;
78047 +
78048 +       if((temp1 >= 0x22) && (temp1 <= 0x50)) {
78049 +          /* Read power status */
78050            temp1 = SiS_GetCH700x(&SiS_Pr, 0x0e);
78051            if((temp1 & 0x03) != 0x03) {
78052 -               /* TW: Power all outputs */
78053 -               SiS_SetCH70xxANDOR(&SiS_Pr, 0x030E,0xF8);
78054 +               /* Power all outputs */
78055 +               SiS_SetCH700x(&SiS_Pr, 0x0B0E);
78056 +               SiS_DDC2Delay(&SiS_Pr, 300);
78057            }
78058 -          /* TW: Sense connected TV devices */
78059 -          SiS_SetCH700x(&SiS_Pr, 0x0110);
78060 -          SiS_SetCH700x(&SiS_Pr, 0x0010);
78061 -          temp1 = SiS_GetCH700x(&SiS_Pr, 0x10);
78062 -          if(!(temp1 & 0x08)) {
78063 -               printk(KERN_INFO
78064 -                  "sisfb: Chrontel: Detected TV connected to SVHS output\n");
78065 -               /* TW: So we can be sure that there IS a SVHS output */
78066 -               ivideo.TV_plug = TVPLUG_SVIDEO;
78067 +          /* Sense connected TV devices */
78068 +          for(i = 0; i < 3; i++) {
78069 +              SiS_SetCH700x(&SiS_Pr, 0x0110);
78070 +              SiS_DDC2Delay(&SiS_Pr, 0x96);
78071 +              SiS_SetCH700x(&SiS_Pr, 0x0010);
78072 +              SiS_DDC2Delay(&SiS_Pr, 0x96);
78073 +              temp1 = SiS_GetCH700x(&SiS_Pr, 0x10);
78074 +              if(!(temp1 & 0x08))       test[i] = 0x02;
78075 +              else if(!(temp1 & 0x02))  test[i] = 0x01;
78076 +              else                      test[i] = 0;
78077 +              SiS_DDC2Delay(&SiS_Pr, 0x96);
78078 +          }
78079 +
78080 +          if(test[0] == test[1])      temp1 = test[0];
78081 +          else if(test[0] == test[2]) temp1 = test[0];
78082 +          else if(test[1] == test[2]) temp1 = test[1];
78083 +          else {
78084 +               printk(KERN_INFO
78085 +                       "sisfb: TV detection unreliable - test results varied\n");
78086 +               temp1 = test[2];
78087 +          }
78088 +          if(temp1 == 0x02) {
78089 +               printk(KERN_INFO "%s SVIDEO output\n", stdstr);
78090 +               ivideo.vbflags |= TV_SVIDEO;
78091                 orSISIDXREG(SISCR, 0x32, 0x02);
78092 -          } else if (!(temp1 & 0x02)) {
78093 -               printk(KERN_INFO
78094 -                  "sisfb: Chrontel: Detected TV connected to CVBS output\n");
78095 -               /* TW: So we can be sure that there IS a CVBS output */
78096 -               ivideo.TV_plug = TVPLUG_COMPOSITE;
78097 +               andSISIDXREG(SISCR, 0x32, ~0x05);
78098 +          } else if (temp1 == 0x01) {
78099 +               printk(KERN_INFO "%s CVBS output\n", stdstr);
78100 +               ivideo.vbflags |= TV_AVIDEO;
78101                 orSISIDXREG(SISCR, 0x32, 0x01);
78102 +               andSISIDXREG(SISCR, 0x32, ~0x06);
78103            } else {
78104                 SiS_SetCH70xxANDOR(&SiS_Pr, 0x010E,0xF8);
78105 +               andSISIDXREG(SISCR, 0x32, ~0x07);
78106            }
78107         } else if(temp1 == 0) {
78108           SiS_SetCH70xxANDOR(&SiS_Pr, 0x010E,0xF8);
78109 +         andSISIDXREG(SISCR, 0x32, ~0x07);
78110         }
78111 +       /* Set general purpose IO for Chrontel communication */
78112 +       SiS_SetChrontelGPIO(&SiS_Pr, 0x00);
78113  #endif
78114  
78115     } else {
78116  
78117  #ifdef CONFIG_FB_SIS_315
78118 -       SiS_Pr.SiS_IF_DEF_CH70xx = 2;           /* TW: Chrontel 7019 */
78119 +       SiS_Pr.SiS_IF_DEF_CH70xx = 2;           /* Chrontel 7019 */
78120          temp1 = SiS_GetCH701x(&SiS_Pr, 0x49);
78121         SiS_SetCH701x(&SiS_Pr, 0x2049);
78122         SiS_DDC2Delay(&SiS_Pr, 0x96);
78123 @@ -2808,22 +3258,24 @@ SiS_SenseCh(void)
78124         if( (temp1 & 0x01) && (temp1 & 0x02) ) temp1 = 0x04;
78125         switch(temp1) {
78126         case 0x01:
78127 -            printk(KERN_INFO
78128 -               "sisfb: Chrontel: Detected TV connected to CVBS output\n");
78129 -            ivideo.TV_plug = TVPLUG_COMPOSITE;
78130 +            printk(KERN_INFO "%s CVBS output\n", stdstr);
78131 +            ivideo.vbflags |= TV_AVIDEO;
78132              orSISIDXREG(SISCR, 0x32, 0x01);
78133 +            andSISIDXREG(SISCR, 0x32, ~0x06);
78134               break;
78135         case 0x02:
78136 -            printk(KERN_INFO
78137 -               "sisfb: Chrontel: Detected TV connected to SVHS output\n");
78138 -            ivideo.TV_plug = TVPLUG_SVIDEO;
78139 +            printk(KERN_INFO "%s SVIDEO output\n", stdstr);
78140 +            ivideo.vbflags |= TV_SVIDEO;
78141              orSISIDXREG(SISCR, 0x32, 0x02);
78142 +            andSISIDXREG(SISCR, 0x32, ~0x05);
78143               break;
78144         case 0x04:
78145 -            /* TW: This should not happen */
78146 -            printk(KERN_INFO
78147 -               "sisfb: Chrontel: Detected TV connected to SCART output\n");
78148 +            printk(KERN_INFO "%s SCART output\n", stdstr);
78149 +            orSISIDXREG(SISCR, 0x32, 0x04);
78150 +            andSISIDXREG(SISCR, 0x32, ~0x03);
78151               break;
78152 +       default:
78153 +            andSISIDXREG(SISCR, 0x32, ~0x07);
78154         }
78155  #endif
78156  
78157 @@ -2845,8 +3297,8 @@ static int sisfb_heap_init(void)
78158         unsigned long *write_port = 0;
78159         SIS_CMDTYPE    cmd_type;
78160  #ifndef AGPOFF
78161 -       struct agp_kern_info  *agp_info;
78162 -       struct agp_memory     *agp;
78163 +       agp_kern_info  *agp_info;
78164 +       agp_memory     *agp;
78165         u32            agp_phys;
78166  #endif
78167  #endif
78168 @@ -2860,14 +3312,21 @@ static int sisfb_heap_init(void)
78169   *     in XF86Config-4.
78170   *     The heap start can also be specified by parameter "mem" when starting the sisfb
78171   *     driver. sisfb mem=1024 lets heap starts at 1MB, etc.
78172 + *
78173 + *     On the 315 and Xabre series, the default is a 1MB heap since DRI is not
78174 + *     supported there.
78175   */
78176       if ((!sisfb_mem) || (sisfb_mem > (ivideo.video_size/1024))) {
78177 -        if (ivideo.video_size > 0x1000000) {
78178 +        if(sisvga_engine == SIS_300_VGA) {
78179 +           if (ivideo.video_size > 0x1000000) {
78180                 ivideo.heapstart = 0xc00000;
78181 -       } else if (ivideo.video_size > 0x800000) {
78182 +          } else if (ivideo.video_size > 0x800000) {
78183                 ivideo.heapstart = 0x800000;
78184 -       } else {
78185 +          } else {
78186                 ivideo.heapstart = 0x400000;
78187 +          }
78188 +       } else {
78189 +          ivideo.heapstart = ivideo.video_size - 0x100000;
78190         }
78191       } else {
78192             ivideo.heapstart = sisfb_mem * 1024;
78193 @@ -2883,7 +3342,7 @@ static int sisfb_heap_init(void)
78194  #ifdef CONFIG_FB_SIS_315
78195       if (sisvga_engine == SIS_315_VGA) {
78196          /* TW: Now initialize the 310 series' command queue mode.
78197 -        * On 310/325, there are three queue modes available which
78198 +        * On 315, there are three queue modes available which
78199          * are chosen by setting bits 7:5 in SR26:
78200          * 1. MMIO queue mode (bit 5, 0x20). The hardware will keep
78201          *    track of the queue, the FIFO, command parsing and so
78202 @@ -2923,8 +3382,8 @@ static int sisfb_heap_init(void)
78203  
78204  #ifndef AGPOFF
78205         if (sisfb_queuemode == AGP_CMD_QUEUE) {
78206 -               agp_info = vmalloc(sizeof(*agp_info));
78207 -               memset((void*)agp_info, 0x00, sizeof(*agp_info));
78208 +               agp_info = vmalloc(sizeof(agp_kern_info));
78209 +               memset((void*)agp_info, 0x00, sizeof(agp_kern_info));
78210                 agp_copy_info(agp_info);
78211  
78212                 agp_backend_acquire();
78213 @@ -3025,10 +3484,6 @@ static int sisfb_heap_init(void)
78214                 break;
78215  
78216            default:  /* MMIO */
78217 -               /* TW: This previously only wrote SIS_MMIO_CMD_ENABLE
78218 -                * to IND_SIS_CMDQUEUE_SET. I doubt that this is
78219 -                * enough. Reserve memory in any way.
78220 -                */
78221                 sisfb_heap_end -= COMMAND_QUEUE_AREA_SIZE;
78222                 sisfb_heap_size -= COMMAND_QUEUE_AREA_SIZE;
78223  
78224 @@ -3037,7 +3492,7 @@ static int sisfb_heap_init(void)
78225  
78226                 *write_port = *read_port;
78227  
78228 -               /* TW: Set Auto_Correction bit */
78229 +               /* Set Auto_Correction bit */
78230                 temp |= (SIS_MMIO_CMD_ENABLE | SIS_CMD_AUTO_CORR);
78231                 outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_SET, temp);
78232  
78233 @@ -3333,7 +3788,6 @@ void sis_malloc(struct sis_memreq *req)
78234                 req->offset = poh->offset;
78235                 req->size = poh->size;
78236         }
78237 -
78238  }
78239  
78240  void sis_free(unsigned long base)
78241 @@ -3352,35 +3806,70 @@ void sis_free(unsigned long base)
78242  
78243  static void sisfb_pre_setmode(void)
78244  {
78245 -       u8 cr30 = 0, cr31 = 0;
78246 +       u8 cr30 = 0, cr31 = 0, cr33 = 0;
78247 +
78248 +       ivideo.currentvbflags &= (VB_VIDEOBRIDGE | VB_DISPTYPE_DISP2);
78249  
78250         inSISIDXREG(SISCR, 0x31, cr31);
78251         cr31 &= ~0x60;
78252 +       cr31 |= 0x04;
78253  
78254 -       switch (ivideo.disp_state & DISPTYPE_DISP2) {
78255 -          case DISPTYPE_CRT2:
78256 -               cr30 = (SIS_VB_OUTPUT_CRT2 | SIS_SIMULTANEOUS_VIEW_ENABLE);
78257 -               cr31 |= SIS_DRIVER_MODE;
78258 -               break;
78259 -          case DISPTYPE_LCD:
78260 -               cr30  = (SIS_VB_OUTPUT_LCD | SIS_SIMULTANEOUS_VIEW_ENABLE);
78261 -               cr31 |= SIS_DRIVER_MODE;
78262 -               break;
78263 -          case DISPTYPE_TV:
78264 -               if (ivideo.TV_type == TVMODE_HIVISION)
78265 +       cr33 = sisfb_rate_idx & 0x0F;
78266 +
78267 +       SiS_SetEnableDstn(&SiS_Pr, FALSE);
78268 +       SiS_SetEnableFstn(&SiS_Pr, FALSE);
78269 +
78270 +       switch (ivideo.currentvbflags & VB_DISPTYPE_DISP2) {
78271 +          case CRT2_TV:
78272 +               ivideo.disp_state = DISPTYPE_TV;
78273 +               if (ivideo.vbflags & TV_HIVISION) {
78274                         cr30 = (SIS_VB_OUTPUT_HIVISION | SIS_SIMULTANEOUS_VIEW_ENABLE);
78275 -               else if (ivideo.TV_plug == TVPLUG_SVIDEO)
78276 +                       ivideo.currentvbflags |= (TV_HIVISION | TV_SVIDEO);
78277 +                       ivideo.TV_type = TVMODE_HIVISION;
78278 +                       ivideo.TV_plug = TVPLUG_SVIDEO;
78279 +               } else if (ivideo.vbflags & TV_SVIDEO) {
78280                         cr30 = (SIS_VB_OUTPUT_SVIDEO | SIS_SIMULTANEOUS_VIEW_ENABLE);
78281 -               else if (ivideo.TV_plug == TVPLUG_COMPOSITE)
78282 +                       ivideo.currentvbflags |= TV_SVIDEO;
78283 +                       ivideo.TV_plug = TVPLUG_SVIDEO;
78284 +               } else if (ivideo.vbflags & TV_AVIDEO) {
78285                         cr30 = (SIS_VB_OUTPUT_COMPOSITE | SIS_SIMULTANEOUS_VIEW_ENABLE);
78286 -               else if (ivideo.TV_plug == TVPLUG_SCART)
78287 +                       ivideo.currentvbflags |= TV_AVIDEO;
78288 +                       ivideo.TV_plug = TVPLUG_COMPOSITE;
78289 +               } else if (ivideo.vbflags & TV_SCART) {
78290                         cr30 = (SIS_VB_OUTPUT_SCART | SIS_SIMULTANEOUS_VIEW_ENABLE);
78291 +                       ivideo.currentvbflags |= TV_SCART;
78292 +                       ivideo.TV_plug = TVPLUG_SCART;
78293 +               }
78294                 cr31 |= SIS_DRIVER_MODE;
78295  
78296 -               if (sisfb_tvmode == 1 || ivideo.TV_type == TVMODE_PAL)
78297 -                       cr31 |= 0x01;
78298 -                else
78299 -                        cr31 &= ~0x01;
78300 +               if(!(ivideo.vbflags & TV_HIVISION)) {
78301 +                       if (ivideo.vbflags & TV_PAL) {
78302 +                               cr31 |= 0x01;
78303 +                               ivideo.currentvbflags |= TV_PAL;
78304 +                               ivideo.TV_type = TVMODE_PAL;
78305 +                       } else {
78306 +                               cr31 &= ~0x01;
78307 +                               ivideo.currentvbflags |= TV_NTSC;
78308 +                               ivideo.TV_type = TVMODE_NTSC;
78309 +                       }
78310 +               }
78311 +               break;
78312 +          case CRT2_LCD:
78313 +               ivideo.disp_state = DISPTYPE_LCD;
78314 +               cr30  = (SIS_VB_OUTPUT_LCD | SIS_SIMULTANEOUS_VIEW_ENABLE);
78315 +               cr31 |= SIS_DRIVER_MODE;
78316 +               SiS_SetEnableDstn(&SiS_Pr, sisfb_dstn);
78317 +               SiS_SetEnableFstn(&SiS_Pr, sisfb_fstn);
78318 +               break;
78319 +          case CRT2_VGA:
78320 +               ivideo.disp_state = DISPTYPE_CRT2;
78321 +               cr30 = (SIS_VB_OUTPUT_CRT2 | SIS_SIMULTANEOUS_VIEW_ENABLE);
78322 +               cr31 |= SIS_DRIVER_MODE;
78323 +               if(sisfb_nocrt2rate) {
78324 +                       cr33 |= (sisbios_mode[sisfb_mode_idx].rate_idx << 4);
78325 +               } else {
78326 +                       cr33 |= ((sisfb_rate_idx & 0x0F) << 4);
78327 +               }
78328                 break;
78329            default:     /* disable CRT2 */
78330                 cr30 = 0x00;
78331 @@ -3389,8 +3878,14 @@ static void sisfb_pre_setmode(void)
78332  
78333         outSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR30, cr30);
78334         outSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR31, cr31);
78335 +       outSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR33, cr33);
78336  
78337 -        outSISIDXREG(SISCR, IND_SIS_SCRATCH_REG_CR33, (sisfb_rate_idx & 0x0F));
78338 +#ifdef CONFIG_FB_SIS_315
78339 +        if(sisvga_engine == SIS_315_VGA) {
78340 +          /* Clear LCDA and PAL-N/M bits */
78341 +          andSISIDXREG(SISCR,0x38,~0xc3);
78342 +       }
78343 +#endif
78344  
78345         if(ivideo.accel) sisfb_syncaccel();
78346  
78347 @@ -3400,67 +3895,89 @@ static void sisfb_pre_setmode(void)
78348  static void sisfb_post_setmode(void)
78349  {
78350         u8 reg;
78351 +       BOOLEAN crt1isoff = FALSE;
78352 +#ifdef CONFIG_FB_SIS_315
78353 +       u8 reg1;
78354 +#endif
78355 +#ifdef CONFIG_FB_SIS_300
78356         BOOLEAN doit = TRUE;
78357 -#if 0  /* TW: Wrong: Is not in MMIO space, but in RAM */
78358 -       /* Backup mode number to MMIO space */
78359 -       if(ivideo.mmio_vbase) {
78360 -         *(volatile u8 *)(((u8*)ivideo.mmio_vbase) + 0x449) = (unsigned char)sisfb_mode_no;
78361 -       }
78362 -#endif 
78363 -
78364 -       if (ivideo.video_bpp == 8) {
78365 -               /* TW: We can't switch off CRT1 on LVDS/Chrontel in 8bpp Modes */
78366 -               if ((ivideo.hasVB == HASVB_LVDS) || (ivideo.hasVB == HASVB_LVDS_CHRONTEL)) {
78367 -                       doit = FALSE;
78368 -               }
78369 -               /* TW: We can't switch off CRT1 on 301B-DH in 8bpp Modes if using LCD */
78370 -               if ( (sishw_ext.Is301BDH) && (ivideo.disp_state & DISPTYPE_LCD) ) {
78371 -                       doit = FALSE;
78372 -               }
78373 -       }
78374 -
78375 +#endif
78376         /* TW: We can't switch off CRT1 if bridge is in slave mode */
78377 -       if(ivideo.hasVB != HASVB_NONE) {
78378 -               inSISIDXREG(SISPART1, 0x00, reg);
78379 +       if(ivideo.vbflags & VB_VIDEOBRIDGE) {
78380 +#ifdef CONFIG_FB_SIS_300
78381                 if(sisvga_engine == SIS_300_VGA) {
78382 +                       inSISIDXREG(SISPART1, 0x00, reg);
78383                         if((reg & 0xa0) == 0x20) {
78384                                 doit = FALSE;
78385                         }
78386                 }
78387 -               if(sisvga_engine == SIS_315_VGA) {
78388 -                       if((reg & 0x50) == 0x10) {
78389 -                               doit = FALSE;
78390 -                       }
78391 -               }
78392 +#endif
78393         } else sisfb_crt1off = 0;
78394  
78395 -       inSISIDXREG(SISCR, 0x17, reg);
78396 -       if((sisfb_crt1off) && (doit))
78397 -               reg &= ~0x80;
78398 -       else          
78399 -               reg |= 0x80;
78400 -       outSISIDXREG(SISCR, 0x17, reg);
78401 +       if(sisvga_engine == SIS_300_VGA) {
78402  
78403 -        andSISIDXREG(SISSR, IND_SIS_RAMDAC_CONTROL, ~0x04);
78404 +#ifdef CONFIG_FB_SIS_300
78405 +          if((sisfb_crt1off) && (doit)) {
78406 +               crt1isoff = TRUE;
78407 +               reg = 0x00;
78408 +          } else {
78409 +               crt1isoff = FALSE;
78410 +               reg = 0x80;
78411 +          }
78412 +          setSISIDXREG(SISCR, 0x17, 0x7f, reg);
78413 +#endif
78414 +
78415 +       } else {
78416 +
78417 +#ifdef CONFIG_FB_SIS_315
78418 +          if(sisfb_crt1off) {
78419 +               crt1isoff = TRUE;
78420 +               reg  = 0x40;
78421 +               reg1 = 0xc0;
78422 +          } else {
78423 +               crt1isoff = FALSE;
78424 +               reg  = 0x00;
78425 +               reg1 = 0x00;
78426  
78427 -       if((ivideo.disp_state & DISPTYPE_TV) && (ivideo.hasVB == HASVB_301)) {
78428 +          }
78429 +          setSISIDXREG(SISCR, 0x63, ~0x40, reg);
78430 +          setSISIDXREG(SISSR, 0x1f, ~0xc0, reg1);
78431 +#endif
78432 +
78433 +       }
78434 +
78435 +       if(crt1isoff) {
78436 +          ivideo.currentvbflags &= ~VB_DISPTYPE_CRT1;
78437 +          ivideo.currentvbflags |= VB_SINGLE_MODE;
78438 +          ivideo.disp_state |= DISPMODE_SINGLE;
78439 +       } else {
78440 +          ivideo.currentvbflags |= VB_DISPTYPE_CRT1;
78441 +          ivideo.disp_state |= DISPTYPE_CRT1;
78442 +          if(ivideo.currentvbflags & VB_DISPTYPE_CRT2) {
78443 +               ivideo.currentvbflags |= VB_MIRROR_MODE;
78444 +               ivideo.disp_state |= DISPMODE_MIRROR;
78445 +          } else {
78446 +               ivideo.currentvbflags |= VB_SINGLE_MODE;
78447 +               ivideo.disp_state |= DISPMODE_SINGLE;
78448 +          }
78449 +       }
78450  
78451 -          inSISIDXREG(SISPART4, 0x01, reg);
78452 +        andSISIDXREG(SISSR, IND_SIS_RAMDAC_CONTROL, ~0x04);
78453  
78454 -          if(reg < 0xB0) {             /* Set filter for SiS301 */
78455 +       if((ivideo.currentvbflags & CRT2_TV) && (ivideo.vbflags & VB_301)) {  /* Set filter for SiS301 */
78456  
78457                 switch (ivideo.video_width) {
78458                    case 320:
78459 -                       filter_tb = (ivideo.TV_type == TVMODE_NTSC) ? 4 : 12;
78460 +                       filter_tb = (ivideo.vbflags & TV_NTSC) ? 4 : 12;
78461                         break;
78462                    case 640:
78463 -                       filter_tb = (ivideo.TV_type == TVMODE_NTSC) ? 5 : 13;
78464 +                       filter_tb = (ivideo.vbflags & TV_NTSC) ? 5 : 13;
78465                         break;
78466                    case 720:
78467 -                       filter_tb = (ivideo.TV_type == TVMODE_NTSC) ? 6 : 14;
78468 +                       filter_tb = (ivideo.vbflags & TV_NTSC) ? 6 : 14;
78469                         break;
78470                    case 800:
78471 -                       filter_tb = (ivideo.TV_type == TVMODE_NTSC) ? 7 : 15;
78472 +                       filter_tb = (ivideo.vbflags & TV_NTSC) ? 7 : 15;
78473                         break;
78474                    default:
78475                         filter = -1;
78476 @@ -3469,15 +3986,15 @@ static void sisfb_post_setmode(void)
78477  
78478                 orSISIDXREG(SISPART1, sisfb_CRT2_write_enable, 0x01);
78479  
78480 -               if(ivideo.TV_type == TVMODE_NTSC) {
78481 +               if(ivideo.vbflags & TV_NTSC) {
78482  
78483                         andSISIDXREG(SISPART2, 0x3a, 0x1f);
78484  
78485 -                       if (ivideo.TV_plug == TVPLUG_SVIDEO) {
78486 +                       if (ivideo.vbflags & TV_SVIDEO) {
78487  
78488                                 andSISIDXREG(SISPART2, 0x30, 0xdf);
78489  
78490 -                       } else if (ivideo.TV_plug == TVPLUG_COMPOSITE) {
78491 +                       } else if (ivideo.vbflags & TV_AVIDEO) {
78492  
78493                                 orSISIDXREG(SISPART2, 0x30, 0x20);
78494  
78495 @@ -3503,15 +4020,15 @@ static void sisfb_post_setmode(void)
78496                                 }
78497                         }
78498  
78499 -               } else if(ivideo.TV_type == TVMODE_PAL) {
78500 +               } else if(ivideo.vbflags & TV_PAL) {
78501  
78502                         andSISIDXREG(SISPART2, 0x3A, 0x1F);
78503  
78504 -                       if (ivideo.TV_plug == TVPLUG_SVIDEO) {
78505 +                       if (ivideo.vbflags & TV_SVIDEO) {
78506  
78507                                 andSISIDXREG(SISPART2, 0x30, 0xDF);
78508  
78509 -                       } else if (ivideo.TV_plug == TVPLUG_COMPOSITE) {
78510 +                       } else if (ivideo.vbflags & TV_AVIDEO) {
78511  
78512                                 orSISIDXREG(SISPART2, 0x30, 0x20);
78513  
78514 @@ -3539,7 +4056,7 @@ static void sisfb_post_setmode(void)
78515                 }
78516  
78517                 if ((filter >= 0) && (filter <=7)) {
78518 -                       DPRINTK("FilterTable[%d]-%d: %02x %02x %02x %02x\n", filter_tb, filter, 
78519 +                       DPRINTK("FilterTable[%d]-%d: %02x %02x %02x %02x\n", filter_tb, filter,
78520                                 sis_TV_filter[filter_tb].filter[filter][0],
78521                                 sis_TV_filter[filter_tb].filter[filter][1],
78522                                 sis_TV_filter[filter_tb].filter[filter][2],
78523 @@ -3550,8 +4067,6 @@ static void sisfb_post_setmode(void)
78524                         outSISIDXREG(SISPART2, 0x37, (sis_TV_filter[filter_tb].filter[filter][2]));
78525                         outSISIDXREG(SISPART2, 0x38, (sis_TV_filter[filter_tb].filter[filter][3]));
78526                 }
78527 -
78528 -            }
78529           
78530         }
78531  
78532 @@ -3567,8 +4082,10 @@ int sisfb_setup(char *options)
78533  #endif 
78534  
78535         ivideo.refresh_rate = 0;
78536 +       SiS_Pr.SiS_CustomT = CUT_NONE;
78537 +       SiS_Pr.UsePanelScaler = -1;
78538  
78539 -        printk(KERN_INFO "sisfb: Options %s\n", options);
78540 +        printk(KERN_DEBUG "sisfb: Options %s\n", options);
78541  
78542         if (!options || !*options)
78543                 return 0;
78544 @@ -3577,72 +4094,75 @@ int sisfb_setup(char *options)
78545  
78546                 if (!*this_opt) continue;
78547  
78548 -               if (!strncmp(this_opt, "mode:", 5)) {
78549 -                       sisfb_search_mode(this_opt + 5);
78550 -               } else if (!strncmp(this_opt, "vesa:", 5)) {
78551 -                       sisfb_search_vesamode(simple_strtoul(this_opt + 5, NULL, 0));
78552 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)                 
78553 -               } else if (!strcmp(this_opt, "inverse")) {
78554 +               if (!strnicmp(this_opt, "mode:", 5)) {
78555 +                       sisfb_search_mode(this_opt + 5, FALSE);
78556 +               } else if (!strnicmp(this_opt, "vesa:", 5)) {
78557 +                       sisfb_search_vesamode(simple_strtoul(this_opt + 5, NULL, 0), FALSE);
78558 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
78559 +               } else if (!strnicmp(this_opt, "inverse", 7)) {
78560                         sisfb_inverse = 1;
78561                         /* fb_invert_cmaps(); */
78562 -               } else if (!strncmp(this_opt, "font:", 5)) {
78563 +               } else if (!strnicmp(this_opt, "font:", 5)) {
78564                         strcpy(sis_fb_info.fontname, this_opt + 5);
78565 -#endif                 
78566 -               } else if (!strncmp(this_opt, "mode:", 5)) {
78567 -                       sisfb_search_mode(this_opt + 5);
78568 -               } else if (!strncmp(this_opt, "vesa:", 5)) {
78569 -                       sisfb_search_vesamode(simple_strtoul(this_opt + 5, NULL, 0));
78570 -               } else if (!strncmp(this_opt, "vrate:", 6)) {
78571 +#endif
78572 +               } else if (!strnicmp(this_opt, "vrate:", 6)) {
78573                         ivideo.refresh_rate = simple_strtoul(this_opt + 6, NULL, 0);
78574 -               } else if (!strncmp(this_opt, "rate:", 5)) {
78575 +                       sisfb_parm_rate = ivideo.refresh_rate;
78576 +               } else if (!strnicmp(this_opt, "rate:", 5)) {
78577                         ivideo.refresh_rate = simple_strtoul(this_opt + 5, NULL, 0);
78578 -               } else if (!strncmp(this_opt, "off", 3)) {
78579 +                       sisfb_parm_rate = ivideo.refresh_rate;
78580 +               } else if (!strnicmp(this_opt, "off", 3)) {
78581                         sisfb_off = 1;
78582 -               } else if (!strncmp(this_opt, "crt1off", 7)) {
78583 +               } else if (!strnicmp(this_opt, "crt1off", 7)) {
78584                         sisfb_crt1off = 1;
78585 -               } else if (!strncmp(this_opt, "filter:", 7)) {
78586 +               } else if (!strnicmp(this_opt, "filter:", 7)) {
78587                         filter = (int)simple_strtoul(this_opt + 7, NULL, 0);
78588 -               } else if (!strncmp(this_opt, "forcecrt2type:", 14)) {
78589 +               } else if (!strnicmp(this_opt, "forcecrt2type:", 14)) {
78590                         sisfb_search_crt2type(this_opt + 14);
78591 -               } else if (!strncmp(this_opt, "forcecrt1:", 10)) {
78592 +               } else if (!strnicmp(this_opt, "forcecrt1:", 10)) {
78593                         sisfb_forcecrt1 = (int)simple_strtoul(this_opt + 10, NULL, 0);
78594 -                } else if (!strncmp(this_opt, "tvmode:",7)) {
78595 +                } else if (!strnicmp(this_opt, "tvmode:",7)) {
78596                         sisfb_search_tvstd(this_opt + 7);
78597 -                } else if (!strncmp(this_opt, "tvstandard:",11)) {
78598 +                } else if (!strnicmp(this_opt, "tvstandard:",11)) {
78599                         sisfb_search_tvstd(this_opt + 7);
78600 -                } else if (!strncmp(this_opt, "mem:",4)) {
78601 +                } else if (!strnicmp(this_opt, "mem:",4)) {
78602                         sisfb_mem = simple_strtoul(this_opt + 4, NULL, 0);
78603 -                } else if (!strncmp(this_opt, "dstn", 4)) {
78604 -                       enable_dstn = 1;
78605 -                       /* TW: DSTN overrules forcecrt2type */
78606 -                       sisfb_crt2type = DISPTYPE_LCD;
78607 -               } else if (!strncmp(this_opt, "queuemode:", 10)) {
78608 +               } else if (!strnicmp(this_opt, "queuemode:", 10)) {
78609                         sisfb_search_queuemode(this_opt + 10);
78610 -               } else if (!strncmp(this_opt, "pdc:", 4)) {
78611 +               } else if (!strnicmp(this_opt, "pdc:", 4)) {
78612                         sisfb_pdc = simple_strtoul(this_opt + 4, NULL, 0);
78613                         if(sisfb_pdc & ~0x3c) {
78614                            printk(KERN_INFO "sisfb: Illegal pdc parameter\n");
78615                            sisfb_pdc = 0;
78616                         }
78617 -               } else if (!strncmp(this_opt, "noaccel", 7)) {
78618 +               } else if (!strnicmp(this_opt, "noaccel", 7)) {
78619                         sisfb_accel = 0;
78620 -               } else if (!strncmp(this_opt, "noypan", 6)) {
78621 +               } else if (!strnicmp(this_opt, "noypan", 6)) {
78622                         sisfb_ypan = 0;
78623 -               } else if (!strncmp(this_opt, "userom:", 7)) {
78624 +               } else if (!strnicmp(this_opt, "userom:", 7)) {
78625                         sisfb_userom = (int)simple_strtoul(this_opt + 7, NULL, 0);
78626 -               } else if (!strncmp(this_opt, "useoem:", 7)) {
78627 +               } else if (!strnicmp(this_opt, "useoem:", 7)) {
78628                         sisfb_useoem = (int)simple_strtoul(this_opt + 7, NULL, 0);
78629 +               } else if (!strnicmp(this_opt, "nocrt2rate", 10)) {
78630 +                       sisfb_nocrt2rate = 1;
78631 +               } else if (!strnicmp(this_opt, "scalelcd:", 9)) {
78632 +                       unsigned long temp = 2;
78633 +                       temp = simple_strtoul(this_opt + 9, NULL, 0);
78634 +                       if((temp == 0) || (temp == 1)) {
78635 +                          SiS_Pr.UsePanelScaler = temp ^ 1;
78636 +                       }
78637 +               } else if (!strnicmp(this_opt, "specialtiming:", 14)) {
78638 +                       sisfb_search_specialtiming(this_opt + 14);
78639 +               } else if(this_opt[0] >= '0' && this_opt[0] <= '9') {
78640 +                       sisfb_search_mode(this_opt, TRUE);
78641                 } else {
78642                         printk(KERN_INFO "sisfb: Invalid option %s\n", this_opt);
78643                 }
78644  
78645                 /* TW: Acceleration only with MMIO mode */
78646                 if((sisfb_queuemode != -1) && (sisfb_queuemode != MMIO_CMD)) {
78647 -                       sisfb_ypan = 0;
78648                         sisfb_accel = 0;
78649                 }
78650 -               /* TW: Panning only with acceleration */
78651 -               if(sisfb_accel == 0) sisfb_ypan = 0;
78652  
78653         }
78654         return 0;
78655 @@ -3661,14 +4181,14 @@ static char *sis_find_rom(void)
78656          char *sis_sig_300[4] = {
78657            "300", "540", "630", "730"
78658          };
78659 -        char *sis_sig_310[7] = {
78660 -          "315", "315", "315", "5315", "6325", "6325", "Xabre"
78661 +        char *sis_sig_310[9] = {
78662 +          "315", "315", "315", "5315", "6325", "6325", "Xabre", "6330", "6330"
78663          };
78664         ushort sis_nums_300[4] = {
78665           SIS_300, SIS_540, SIS_630, SIS_730
78666         };
78667 -       unsigned short sis_nums_310[7] = {
78668 -         SIS_315PRO, SIS_315H, SIS_315, SIS_550, SIS_650, SIS_740, SIS_330
78669 +       unsigned short sis_nums_310[9] = {
78670 +         SIS_315PRO, SIS_315H, SIS_315, SIS_550, SIS_650, SIS_740, SIS_330, SIS_660, SIS_760
78671         };
78672  
78673          for(segstart=0x000c0000; segstart<0x000f0000; segstart+=0x00001000) {
78674 @@ -3705,7 +4225,7 @@ static char *sis_find_rom(void)
78675                      }
78676                  }
78677                 if(stage != 4) {
78678 -                   for(i = 0;(i < 7) && (stage != 4); i++) {
78679 +                   for(i = 0;(i < 9) && (stage != 4); i++) {
78680                        if(strncmp(sis_sig_310[i], rom, strlen(sis_sig_310[i])) == 0) {
78681                           if(sis_nums_310[i] == ivideo.chip) {
78682                               stage = 4;
78683 @@ -3735,7 +4255,7 @@ int __init sisfb_init(void)
78684         int pdev_valid = 0;
78685         u32 reg32;
78686         u16 reg16;
78687 -       u8  reg, reg1;
78688 +       u8  reg;
78689  
78690         /* outb(0x77, 0x80); */  /* What is this? */
78691  
78692 @@ -3751,18 +4271,24 @@ int __init sisfb_init(void)
78693         if (sisfb_off)
78694                 return -ENXIO;
78695  
78696 -       if (enable_dstn)
78697 -               SiS_SetEnableDstn(&SiS_Pr);
78698 -               
78699         sisfb_registered = 0;
78700 +       sisfb_thismonitor.datavalid = FALSE;
78701  
78702         memset(&sis_fb_info, 0, sizeof(sis_fb_info));
78703 +
78704 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
78705 +        memset(&sisfb_lastrates[0], 0, 128);
78706 +#endif
78707         
78708  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 
78709         memset(&sis_disp, 0, sizeof(sis_disp));
78710  #endif 
78711  
78712 -       while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) {
78713 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,74)
78714 +       pci_for_each_dev(pdev) {
78715 +#else
78716 +       while((pdev = pci_find_device(PCI_VENDOR_ID_SI, PCI_ANY_ID, pdev))) {
78717 +#endif
78718                 for (b = sisdev_list; b->vendor; b++) {
78719                         if ((b->vendor == pdev->vendor)
78720                             && (b->device == pdev->device)) {
78721 @@ -3804,18 +4330,17 @@ int __init sisfb_init(void)
78722                 break;
78723            case PCI_DEVICE_ID_SI_630_VGA:
78724                 {
78725 +                       ivideo.chip = SIS_630;
78726                         sisfb_set_reg4(0xCF8, 0x80000000);
78727                         reg32 = sisfb_get_reg3(0xCFC);
78728                         if(reg32 == 0x07301039) {
78729                                 ivideo.chip = SIS_730;
78730 -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)                                
78731 +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)
78732                                 strcpy(sis_fb_info.modename, "SIS 730");
78733  #else
78734                                 strcpy(myid, "SIS 730");
78735 -#endif                         
78736 -                       } else
78737 -                               ivideo.chip = SIS_630;
78738 -
78739 +#endif
78740 +                       }
78741                         sisvga_engine = SIS_300_VGA;
78742                         sisfb_hwcursor_size = HW_CURSOR_AREA_SIZE_300 * 2;
78743                         sisfb_CRT2_write_enable = IND_SIS_CRT2_WRITE_ENABLE_300;
78744 @@ -3860,11 +4385,11 @@ int __init sisfb_init(void)
78745                         reg32 = sisfb_get_reg3(0xCFC);
78746                         if(reg32 == 0x07401039) {
78747                                 ivideo.chip = SIS_740;
78748 -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)                                
78749 +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)
78750                                 strcpy(sis_fb_info.modename, "SIS 740");
78751  #else
78752 -                               strcpy(myid, "SIS 740");                                
78753 -#endif                         
78754 +                               strcpy(myid, "SIS 740");
78755 +#endif
78756                         }
78757                         sisvga_engine = SIS_315_VGA;
78758                         sisfb_hwcursor_size = HW_CURSOR_AREA_SIZE_315 * 2;
78759 @@ -3877,6 +4402,24 @@ int __init sisfb_init(void)
78760                 sisfb_hwcursor_size = HW_CURSOR_AREA_SIZE_315 * 2;
78761                 sisfb_CRT2_write_enable = IND_SIS_CRT2_WRITE_ENABLE_315;
78762                 break;
78763 +          case PCI_DEVICE_ID_SI_660_VGA:
78764 +               {
78765 +                       ivideo.chip = SIS_660;
78766 +                       sisfb_set_reg4(0xCF8, 0x80000000);
78767 +                       reg32 = sisfb_get_reg3(0xCFC);
78768 +                       if(reg32 == 0x07601039) {
78769 +                               ivideo.chip = SIS_760;
78770 +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)
78771 +                               strcpy(sis_fb_info.modename, "SIS 760");
78772 +#else
78773 +                               strcpy(myid, "SIS 760");
78774 +#endif
78775 +                       }
78776 +                       sisvga_engine = SIS_315_VGA;
78777 +                       sisfb_hwcursor_size = HW_CURSOR_AREA_SIZE_315 * 2;
78778 +                       sisfb_CRT2_write_enable = IND_SIS_CRT2_WRITE_ENABLE_315;
78779 +                       break;
78780 +               }
78781  #endif
78782             default:
78783                 return -ENODEV;
78784 @@ -3903,29 +4446,31 @@ int __init sisfb_init(void)
78785          SiS_Pr.SiS_CHOverScan = -1;
78786          SiS_Pr.SiS_ChSW = FALSE;
78787         SiS_Pr.SiS_UseLCDA = FALSE;
78788 -       SiS_Pr.UsePanelScaler = -1;
78789         SiSRegInit(&SiS_Pr, (USHORT)sishw_ext.ulIOAddress);
78790  
78791  #ifdef CONFIG_FB_SIS_300
78792 -       /* TW: Find PCI systems for Chrontel/ISA bridge manipulation */
78793 +       /* TW: Find PCI systems for Chrontel/GPIO communication setup */
78794         if(ivideo.chip == SIS_630) {
78795 -         int i=0;
78796 -          do {
78797 -           if(mychswtable[i].subsysVendor == ivideo.subsysvendor &&
78798 -              mychswtable[i].subsysCard   == ivideo.subsysdevice) {
78799 -               SiS_Pr.SiS_ChSW = TRUE;
78800 -            }
78801 -            i++;
78802 -          } while(mychswtable[i].subsysVendor != 0);
78803 +          int i=0;
78804 +           do {
78805 +             if(mychswtable[i].subsysVendor == ivideo.subsysvendor &&
78806 +                mychswtable[i].subsysCard   == ivideo.subsysdevice) {
78807 +                SiS_Pr.SiS_ChSW = TRUE;
78808 +                printk(KERN_DEBUG "sisfb: Identified [%s %s] requiring Chrontel/GPIO setup\n",
78809 +                       mychswtable[i].vendorName, mychswtable[i].cardName);
78810 +                break;
78811 +              }
78812 +              i++;
78813 +           } while(mychswtable[i].subsysVendor != 0);
78814         }
78815  #endif
78816  
78817          outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD);
78818  
78819  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)         
78820 -#ifdef MODULE  
78821 +#ifdef MODULE
78822         inSISIDXREG(SISCR,0x34,reg);
78823 -       if(reg & 0x80) {
78824 +       if((reg & 0x80) && (reg != 0xff)) {
78825            if((sisbios_mode[sisfb_mode_idx].mode_no) != 0xFF) {
78826               printk(KERN_INFO "sisfb: Cannot initialize display mode, X server is active\n");
78827               return -EBUSY;
78828 @@ -3938,7 +4483,7 @@ int __init sisfb_init(void)
78829  
78830  #ifdef CONFIG_FB_SIS_300
78831         if (sisvga_engine == SIS_300_VGA) {
78832 -               outSISIDXREG(SISSR, 0x28, 0x37);
78833 +               outSISIDXREG(SISSR, 0x28, 0x37);        /* Reset memory clock */
78834  
78835                  outSISIDXREG(SISSR, 0x29, 0x61);
78836  
78837 @@ -3946,7 +4491,9 @@ int __init sisfb_init(void)
78838         }
78839  #endif
78840  #ifdef CONFIG_FB_SIS_315
78841 -       if (ivideo.chip == SIS_550 || ivideo.chip == SIS_650 || ivideo.chip == SIS_740) {
78842 +       if (ivideo.chip == SIS_550 || ivideo.chip == SIS_650 ||
78843 +           ivideo.chip == SIS_740 || ivideo.chip == SIS_660 ||
78844 +           ivideo.chip == SIS_760) {
78845                 outSISIDXREG(SISSR, 0x28, 0x5a);
78846  
78847                  outSISIDXREG(SISSR, 0x29, 0x64);
78848 @@ -3967,6 +4514,8 @@ int __init sisfb_init(void)
78849                    case SIS_550:
78850                    case SIS_650:
78851                    case SIS_740:
78852 +                  case SIS_660:
78853 +                  case SIS_760:
78854                         sishw_ext.bIntegratedMMEnabled = TRUE;
78855                         break;
78856                    default:
78857 @@ -4006,13 +4555,56 @@ int __init sisfb_init(void)
78858         sishw_ext.pQueryNorthBridgeSpace = &sisfb_query_north_bridge_space;
78859         strcpy(sishw_ext.szVBIOSVer, "0.84");
78860  
78861 -       /* TW: Mode numbers for 1280x960 are different for 300 and 310/325 series */
78862 +        /* Find systems for special custom timing */
78863 +       if((sishw_ext.UseROM) && (SiS_Pr.SiS_CustomT == CUT_NONE)) {
78864 +          int i=0,j;
78865 +          unsigned char *biosver = sishw_ext.pjVirtualRomBase + 0x06;
78866 +           unsigned char *biosdate = sishw_ext.pjVirtualRomBase + 0x2c;
78867 +          BOOLEAN footprint;
78868 +          unsigned long chksum = 0;
78869 +
78870 +           for(i=0; i<32768; i++) chksum += sishw_ext.pjVirtualRomBase[i];
78871 +
78872 +          i=0;
78873 +           do {
78874 +             if( (mycustomttable[i].chipID == ivideo.chip) &&
78875 +                 ((!strlen(mycustomttable[i].biosversion)) ||
78876 +                  (!strncmp(mycustomttable[i].biosversion, biosver, strlen(mycustomttable[i].biosversion)))) &&
78877 +                 ((!strlen(mycustomttable[i].biosdate)) ||
78878 +                  (!strncmp(mycustomttable[i].biosdate, biosdate, strlen(mycustomttable[i].biosdate)))) &&
78879 +                 ((!mycustomttable[i].bioschksum) ||
78880 +                  (mycustomttable[i].bioschksum == chksum))    &&
78881 +                 (mycustomttable[i].pcisubsysvendor == ivideo.subsysvendor) &&
78882 +                 (mycustomttable[i].pcisubsyscard == ivideo.subsysdevice) ) {
78883 +                footprint = TRUE;
78884 +                for(j=0; j<5; j++) {
78885 +                  if(mycustomttable[i].biosFootprintAddr[j]) {
78886 +                     if(sishw_ext.pjVirtualRomBase[mycustomttable[i].biosFootprintAddr[j]] !=
78887 +                               mycustomttable[i].biosFootprintData[j])
78888 +                        footprint = FALSE;
78889 +                  }
78890 +                }
78891 +                if(footprint) {
78892 +                   SiS_Pr.SiS_CustomT = mycustomttable[i].SpecialID;
78893 +                   printk(KERN_DEBUG "sisfb: Identified [%s %s], special timing applies\n",
78894 +                       mycustomttable[i].vendorName,
78895 +                       mycustomttable[i].cardName);
78896 +                   break;
78897 +                 }
78898 +             }
78899 +              i++;
78900 +           } while(mycustomttable[i].chipID);
78901 +       }
78902 +
78903 +#ifdef CONFIG_FB_SIS_300
78904 +       /* Mode numbers for 1280x768 are different for 300 and 315 series */
78905         if(sisvga_engine == SIS_300_VGA) {
78906 -               sisbios_mode[MODEINDEX_1280x960].mode_no = 0x6e;
78907 -               sisbios_mode[MODEINDEX_1280x960+1].mode_no = 0x6f;
78908 -               sisbios_mode[MODEINDEX_1280x960+2].mode_no = 0x7b;
78909 -               sisbios_mode[MODEINDEX_1280x960+3].mode_no = 0x7b;
78910 +               sisbios_mode[MODEINDEX_1280x768].mode_no = 0x55;
78911 +               sisbios_mode[MODEINDEX_1280x768+1].mode_no = 0x5a;
78912 +               sisbios_mode[MODEINDEX_1280x768+2].mode_no = 0x5b;
78913 +               sisbios_mode[MODEINDEX_1280x768+3].mode_no = 0x5b;
78914         }
78915 +#endif
78916  
78917         sishw_ext.pSR = vmalloc(sizeof(SIS_DSReg) * SR_BUFFER_SIZE);
78918         if (sishw_ext.pSR == NULL) {
78919 @@ -4168,120 +4760,53 @@ int __init sisfb_init(void)
78920  
78921         ivideo.mtrr = (unsigned int) 0;
78922  
78923 -       if((sisfb_mode_idx < 0) || ((sisbios_mode[sisfb_mode_idx].mode_no) != 0xFF)) { 
78924 -
78925 -#ifdef CONFIG_FB_SIS_300
78926 -               if (sisvga_engine == SIS_300_VGA) {
78927 -                       sisfb_get_VB_type_300();
78928 -               }
78929 -#endif
78930 +       ivideo.vbflags = 0;
78931  
78932 -#ifdef CONFIG_FB_SIS_315
78933 -               if (sisvga_engine == SIS_315_VGA) {
78934 -                       sisfb_get_VB_type_315();
78935 -               }
78936 -#endif
78937 +       if((sisfb_mode_idx < 0) || ((sisbios_mode[sisfb_mode_idx].mode_no) != 0xFF)) {
78938  
78939                 sishw_ext.ujVBChipID = VB_CHIP_UNKNOWN;
78940                 sishw_ext.Is301BDH = FALSE;
78941                 sishw_ext.usExternalChip = 0;
78942  
78943 -               switch (ivideo.hasVB) {
78944 +               sisfb_get_VB_type();
78945  
78946 -               case HASVB_301:
78947 -                       inSISIDXREG(SISPART4, 0x01, reg);
78948 -                       if (reg >= 0xE0) {
78949 -                               sishw_ext.ujVBChipID = VB_CHIP_302LV;
78950 -                               printk(KERN_INFO "sisfb: SiS302LV bridge detected (revision 0x%02x)\n",reg);
78951 -                       } else if (reg >= 0xD0) {
78952 -                               sishw_ext.ujVBChipID = VB_CHIP_301LV;
78953 -                               printk(KERN_INFO "sisfb: SiS301LV bridge detected (revision 0x%02x)\n",reg);
78954 -                       } else if (reg >= 0xB0) {
78955 -                               sishw_ext.ujVBChipID = VB_CHIP_301B;
78956 -                               inSISIDXREG(SISPART4,0x23,reg1);
78957 -                               if(!(reg1 & 0x02)) sishw_ext.Is301BDH = TRUE;
78958 -                               printk(KERN_INFO "sisfb: SiS301B%s bridge detected (revision 0x%02x)\n",
78959 -                                       (sishw_ext.Is301BDH ? "-DH" : ""), reg);
78960 -                       } else {
78961 -                               sishw_ext.ujVBChipID = VB_CHIP_301;
78962 -                               printk(KERN_INFO "sisfb: SiS301 bridge detected\n");
78963 -                       }
78964 -                       break;
78965 -               case HASVB_302:
78966 -                       inSISIDXREG(SISPART4, 0x01, reg);
78967 -                       if (reg >= 0xE0) {
78968 -                               sishw_ext.ujVBChipID = VB_CHIP_302LV;
78969 -                               printk(KERN_INFO "sisfb: SiS302LV bridge detected (revision 0x%02x)\n",reg);
78970 -                       } else if (reg >= 0xD0) {
78971 -                               sishw_ext.ujVBChipID = VB_CHIP_301LV;
78972 -                               printk(KERN_INFO "sisfb: SiS302LV bridge detected (revision 0x%02x)\n",reg);
78973 -                       } else if (reg >= 0xB0) {
78974 -                               inSISIDXREG(SISPART4,0x23,reg1);
78975 -                               if(!(reg1 & 0x02)) sishw_ext.Is301BDH = TRUE;
78976 -                               sishw_ext.ujVBChipID = VB_CHIP_302B;
78977 -                               printk(KERN_INFO "sisfb: SiS302B%s bridge detected (revision 0x%02x)\n",
78978 -                                       (sishw_ext.Is301BDH ? "-DH" : ""), reg);
78979 -                       } else {
78980 -                               sishw_ext.ujVBChipID = VB_CHIP_302;
78981 -                               printk(KERN_INFO "sisfb: SiS302 bridge detected\n");
78982 -                       }
78983 -                       break;
78984 -               case HASVB_LVDS:
78985 -                       sishw_ext.usExternalChip = 0x1;
78986 -                       printk(KERN_INFO "sisfb: LVDS transmitter detected\n");
78987 -                       break;
78988 -               case HASVB_TRUMPION:
78989 -                       sishw_ext.usExternalChip = 0x2;
78990 -                       printk(KERN_INFO "sisfb: Trumpion Zurac LVDS scaler detected\n");
78991 -                       break;
78992 -               case HASVB_CHRONTEL:
78993 -                       sishw_ext.usExternalChip = 0x4;
78994 -                       printk(KERN_INFO "sisfb: Chrontel TV encoder detected\n");
78995 -                       break;
78996 -               case HASVB_LVDS_CHRONTEL:
78997 -                       sishw_ext.usExternalChip = 0x5;
78998 -                       printk(KERN_INFO "sisfb: LVDS transmitter and Chrontel TV encoder detected\n");
78999 -                       break;
79000 -               default:
79001 -                       printk(KERN_INFO "sisfb: No or unknown bridge type detected\n");
79002 -                       break;
79003 +               if(ivideo.vbflags & VB_VIDEOBRIDGE) {
79004 +                       sisfb_detect_VB_connect();
79005                 }
79006  
79007 -               if (ivideo.hasVB != HASVB_NONE) {
79008 -#ifdef CONFIG_FB_SIS_300
79009 -                     if (sisvga_engine == SIS_300_VGA) {
79010 -                               sisfb_detect_VB_connect_300();
79011 -                      }
79012 -#endif
79013 -#ifdef CONFIG_FB_SIS_315
79014 -                     if (sisvga_engine == SIS_315_VGA) {
79015 -                               sisfb_detect_VB_connect_315();
79016 -                      }
79017 -#endif
79018 -               }
79019 +               ivideo.currentvbflags = ivideo.vbflags & VB_VIDEOBRIDGE;
79020  
79021 -               if (ivideo.disp_state & DISPTYPE_DISP2) {
79022 -                       if (sisfb_crt1off)
79023 -                               ivideo.disp_state |= DISPMODE_SINGLE;
79024 -                       else
79025 -                               ivideo.disp_state |= (DISPMODE_MIRROR | DISPTYPE_CRT1);
79026 -               } else {
79027 -                       ivideo.disp_state = DISPMODE_SINGLE | DISPTYPE_CRT1;
79028 +               if(ivideo.vbflags & VB_VIDEOBRIDGE) {
79029 +                  if(sisfb_crt2type != -1) {
79030 +                     if((sisfb_crt2type == CRT2_LCD) && (ivideo.vbflags & CRT2_LCD)) {
79031 +                        ivideo.currentvbflags |= CRT2_LCD;
79032 +                     } else if(sisfb_crt2type != CRT2_LCD) {
79033 +                        ivideo.currentvbflags |= sisfb_crt2type;
79034 +                     }
79035 +                  } else {
79036 +                     /* Chrontel 700x TV detection often unreliable, therefore use a
79037 +                      * different default order on such machines
79038 +                      */
79039 +                     if((sisvga_engine == SIS_300_VGA) && (ivideo.vbflags & VB_CHRONTEL)) {
79040 +                        if(ivideo.vbflags & CRT2_LCD)      ivideo.currentvbflags |= CRT2_LCD;
79041 +                        else if(ivideo.vbflags & CRT2_TV)  ivideo.currentvbflags |= CRT2_TV;
79042 +                        else if(ivideo.vbflags & CRT2_VGA) ivideo.currentvbflags |= CRT2_VGA;
79043 +                     } else {
79044 +                        if(ivideo.vbflags & CRT2_TV)       ivideo.currentvbflags |= CRT2_TV;
79045 +                        else if(ivideo.vbflags & CRT2_LCD) ivideo.currentvbflags |= CRT2_LCD;
79046 +                        else if(ivideo.vbflags & CRT2_VGA) ivideo.currentvbflags |= CRT2_VGA;
79047 +                     }
79048 +                  }
79049                 }
79050  
79051 -               if (ivideo.disp_state & DISPTYPE_LCD) {
79052 -                   if (!enable_dstn) {
79053 -                       inSISIDXREG(SISCR, IND_SIS_LCD_PANEL, reg);
79054 -                       reg &= 0x0f;
79055 -                       if (sisvga_engine == SIS_300_VGA) {
79056 -                           sishw_ext.ulCRT2LCDType = sis300paneltype[reg];
79057 -                       } else {
79058 -                           sishw_ext.ulCRT2LCDType = sis310paneltype[reg];
79059 -                       }
79060 -                   } else {
79061 -                       /* TW: FSTN/DSTN */
79062 -                       sishw_ext.ulCRT2LCDType = LCD_320x480;
79063 -                   }
79064 +               if(ivideo.vbflags & CRT2_LCD) {
79065 +                  inSISIDXREG(SISCR, IND_SIS_LCD_PANEL, reg);
79066 +                  reg &= 0x0f;
79067 +                  if(sisvga_engine == SIS_300_VGA) {
79068 +                     sishw_ext.ulCRT2LCDType = sis300paneltype[reg];
79069 +                  } else {
79070 +                     sishw_ext.ulCRT2LCDType = sis310paneltype[reg];
79071 +                  }
79072                 }
79073                 
79074                 sisfb_detectedpdc = 0;
79075 @@ -4289,9 +4814,7 @@ int __init sisfb_init(void)
79076  #ifdef CONFIG_FB_SIS_300
79077                  /* TW: Save the current PanelDelayCompensation if the LCD is currently used */
79078                 if(sisvga_engine == SIS_300_VGA) {
79079 -                 if((sishw_ext.usExternalChip == 0x01) ||   /* LVDS */
79080 -                    (sishw_ext.usExternalChip == 0x05) ||   /* LVDS+Chrontel */
79081 -                    (sishw_ext.Is301BDH)) {                 /* 301B-DH */
79082 +                 if(ivideo.vbflags & (VB_LVDS | VB_30xBDH)) {
79083                        int tmp;
79084                        inSISIDXREG(SISCR,0x30,tmp);
79085                        if(tmp & 0x20) {
79086 @@ -4320,54 +4843,57 @@ int __init sisfb_init(void)
79087  #ifdef CONFIG_FB_SIS_315
79088                  /* TW: Try to find about LCDA */
79089                 if(sisvga_engine == SIS_315_VGA) {
79090 -                 if((sishw_ext.ujVBChipID == VB_CHIP_302B) ||
79091 -                    (sishw_ext.ujVBChipID == VB_CHIP_301LV) ||
79092 -                    (sishw_ext.ujVBChipID == VB_CHIP_302LV)) {
79093 -                      int tmp;
79094 -                      inSISIDXREG(SISCR,0x34,tmp);
79095 -                      if(tmp <= 0x13) {        
79096 -                         /* Currently on LCDA? (Some BIOSes leave CR38) */
79097 -                         inSISIDXREG(SISCR,0x38,tmp);
79098 -                         if((tmp & 0x03) == 0x03) {
79099 -                            SiS_Pr.SiS_UseLCDA = TRUE;
79100 -                         } else {
79101 -                            /* Currently on LCDA? (Some newer BIOSes set D0 in CR35) */
79102 -                            inSISIDXREG(SISCR,0x35,tmp);
79103 -                            if(tmp & 0x01) {
79104 -                               SiS_Pr.SiS_UseLCDA = TRUE;
79105 -                            } else {
79106 -                               /* Currently on LCD? If so, we can find out 
79107 -                                  by peeking the mode register 
79108 -                                */
79109 -                               inSISIDXREG(SISCR,0x30,tmp);
79110 -                               if(tmp & 0x20) {
79111 -                                  inSISIDXREG(SISPART1,0x13,tmp);
79112 -                                  if(tmp & 0x04) {
79113 -                                     SiS_Pr.SiS_UseLCDA = TRUE;
79114 -                                  }
79115 -                               }
79116 -                            }
79117 -                         }
79118 -                      } 
79119 -                      if(SiS_Pr.SiS_UseLCDA) {
79120 -                         sisfb_detectedlcda = 0x03;
79121 -                         printk(KERN_INFO
79122 -                                "sisfb: Bridge uses LCDA for low resolution and text modes\n");
79123 -                      }
79124 +                  if(ivideo.vbflags & (VB_302B | VB_301LV | VB_302LV)) {
79125 +                     int tmp;
79126 +                     inSISIDXREG(SISCR,0x34,tmp);
79127 +                     if((tmp <= 0x13) || (tmp == 0xff)) {
79128 +                        /* Currently on LCDA? (Some BIOSes leave CR38) */
79129 +                        inSISIDXREG(SISCR,0x38,tmp);
79130 +                        if((tmp & 0x03) == 0x03)  SiS_Pr.SiS_UseLCDA = TRUE;
79131 +                        else {
79132 +                           /* Currently on LCDA? (Some newer BIOSes set D0 in CR35) */
79133 +                           inSISIDXREG(SISCR,0x35,tmp);
79134 +                           if(tmp & 0x01) SiS_Pr.SiS_UseLCDA = TRUE;
79135 +                           else {
79136 +                              /* Currently on LCD? If so, we can find out
79137 +                               * by peeking the mode register
79138 +                               */
79139 +                              inSISIDXREG(SISCR,0x30,tmp);
79140 +                              if(tmp & 0x20) {
79141 +                                 inSISIDXREG(SISPART1,0x13,tmp);
79142 +                                 if(tmp & 0x04) SiS_Pr.SiS_UseLCDA = TRUE;
79143 +                              }
79144 +                           }
79145 +                        }
79146 +                     }
79147 +                     if(SiS_Pr.SiS_UseLCDA) {
79148 +                        sisfb_detectedlcda = 0x03;
79149 +                        printk(KERN_DEBUG
79150 +                               "sisfb: Bridge uses LCDA for low resolution and text modes\n");
79151 +                     }
79152                   }
79153                 }
79154  #endif
79155  #endif
79156  
79157 +               if (!sisfb_crt1off) {
79158 +                       sisfb_handle_ddc(&sisfb_thismonitor, 0);
79159 +               } else {
79160 +                       if ((ivideo.vbflags & (VB_301|VB_301B|VB_302B)) &&
79161 +                           (ivideo.vbflags & (CRT2_VGA | CRT2_LCD))) {
79162 +                               sisfb_handle_ddc(&sisfb_thismonitor, 1);
79163 +                       }
79164 +               }
79165 +
79166                 if (sisfb_mode_idx >= 0)
79167 -                       sisfb_mode_idx = sisfb_validate_mode(sisfb_mode_idx);
79168 +                       sisfb_mode_idx = sisfb_validate_mode(sisfb_mode_idx, ivideo.currentvbflags);
79169  
79170                 if (sisfb_mode_idx < 0) {
79171 -                       switch (ivideo.disp_state & DISPTYPE_DISP2) {
79172 -                          case DISPTYPE_LCD:
79173 +                       switch (ivideo.currentvbflags & VB_DISPTYPE_DISP2) {
79174 +                          case CRT2_LCD:
79175                                 sisfb_mode_idx = DEFAULT_LCDMODE;
79176                                 break;
79177 -                          case DISPTYPE_TV:
79178 +                          case CRT2_TV:
79179                                 sisfb_mode_idx = DEFAULT_TVMODE;
79180                                 break;
79181                            default:
79182 @@ -4379,39 +4905,27 @@ int __init sisfb_init(void)
79183                 sisfb_mode_no = sisbios_mode[sisfb_mode_idx].mode_no;
79184  
79185                 if (ivideo.refresh_rate != 0)
79186 -                       sisfb_search_refresh_rate(ivideo.refresh_rate);
79187 +                       sisfb_search_refresh_rate(ivideo.refresh_rate, sisfb_mode_idx);
79188  
79189                 if (sisfb_rate_idx == 0) {
79190                         sisfb_rate_idx = sisbios_mode[sisfb_mode_idx].rate_idx;
79191                         ivideo.refresh_rate = 60;
79192                 }
79193  
79194 +               if (sisfb_thismonitor.datavalid) {
79195 +                       if(!sisfb_verify_rate(&sisfb_thismonitor, sisfb_mode_idx,
79196 +                                             sisfb_rate_idx, ivideo.refresh_rate)) {
79197 +                               printk(KERN_INFO "sisfb: WARNING: Refresh rate exceeds monitor specs!\n");
79198 +                       }
79199 +               }
79200 +
79201                 ivideo.video_bpp = sisbios_mode[sisfb_mode_idx].bpp;
79202                 ivideo.video_vwidth = ivideo.video_width = sisbios_mode[sisfb_mode_idx].xres;
79203                 ivideo.video_vheight = ivideo.video_height = sisbios_mode[sisfb_mode_idx].yres;
79204                 ivideo.org_x = ivideo.org_y = 0;
79205                 ivideo.video_linelength = ivideo.video_width * (ivideo.video_bpp >> 3);
79206 -               switch(ivideo.video_bpp) {
79207 -               case 8:
79208 -                       ivideo.DstColor = 0x0000;
79209 -                       ivideo.SiS310_AccelDepth = 0x00000000;
79210 -                       ivideo.video_cmap_len = 256;
79211 -                       break;
79212 -               case 16:
79213 -                       ivideo.DstColor = 0x8000;
79214 -                       ivideo.SiS310_AccelDepth = 0x00010000;
79215 -                       ivideo.video_cmap_len = 16;
79216 -                       break;
79217 -               case 32:
79218 -                       ivideo.DstColor = 0xC000;
79219 -                       ivideo.SiS310_AccelDepth = 0x00020000;
79220 -                       ivideo.video_cmap_len = 16;
79221 -                       break;
79222 -               default:
79223 -                       ivideo.video_cmap_len = 16;
79224 -                       printk(KERN_INFO "sisfb: Unsupported depth %d", ivideo.video_bpp);
79225 -                       break;
79226 -               }
79227 +
79228 +               sisfb_set_vparms();
79229                 
79230  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 
79231  
79232 @@ -4424,27 +4938,49 @@ int __init sisfb_init(void)
79233                 sisfb_pre_setmode();
79234  
79235                 if (SiSSetMode(&SiS_Pr, &sishw_ext, sisfb_mode_no) == 0) {
79236 -                       printk(KERN_ERR "sisfb: Setting mode[0x%x] failed, using default mode\n", 
79237 +                       printk(KERN_ERR "sisfb: Fatal error: Setting mode[0x%x] failed\n",
79238                                 sisfb_mode_no);
79239 -                       return -1;
79240 +                       vfree(sishw_ext.pSR);
79241 +                       vfree(sishw_ext.pCR);
79242 +                       release_mem_region(ivideo.video_base, ivideo.video_size);
79243 +                       release_mem_region(ivideo.mmio_base, sisfb_mmio_size);
79244 +                       return -EINVAL;
79245                 }
79246  
79247                 outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD);
79248  
79249                 sisfb_post_setmode();
79250  
79251 +               ivideo.accel = 0;
79252 +               if(sisfb_accel) {
79253 +                  ivideo.accel = -1;
79254 +                  default_var.accel_flags |= FB_ACCELF_TEXT;
79255 +                  sisfb_initaccel();
79256 +               }
79257 +
79258                 sisfb_crtc_to_var(&default_var);
79259                 
79260 +               sis_fb_info.node = -1;
79261 +               sis_fb_info.flags = FBINFO_FLAG_DEFAULT;
79262 +               sis_fb_info.blank = &sisfb_blank;
79263 +               sis_fb_info.fbops = &sisfb_ops;
79264 +               sis_fb_info.switch_con = &sisfb_switch;
79265 +               sis_fb_info.updatevar = &sisfb_update_var;
79266 +               sis_fb_info.changevar = NULL;
79267 +               sis_fb_info.disp = &sis_disp;
79268 +
79269 +               sisfb_set_disp(-1, &default_var, &sis_fb_info);
79270 +
79271  #else          /* --------- For 2.5: Setup a somewhat sane default var ------------ */
79272  
79273                 printk(KERN_INFO "sisfb: Default mode is %dx%dx%d (%dHz)\n",
79274                         ivideo.video_width, ivideo.video_height, ivideo.video_bpp,
79275                         ivideo.refresh_rate);
79276 -                       
79277 +
79278                 default_var.xres = default_var.xres_virtual = ivideo.video_width;
79279                 default_var.yres = default_var.yres_virtual = ivideo.video_height;
79280                 default_var.bits_per_pixel = ivideo.video_bpp;
79281 -               
79282 +
79283                 sisfb_bpp_to_var(&default_var);
79284                 
79285                 default_var.pixclock = (u32) (1E12 /
79286 @@ -4457,28 +4993,10 @@ int __init sisfb_init(void)
79287                          &default_var.upper_margin, &default_var.lower_margin,
79288                          &default_var.hsync_len, &default_var.vsync_len,
79289                          &default_var.sync, &default_var.vmode)) {
79290 -                        
79291 -                  if((default_var.vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
79292 -                     default_var.yres <<= 1;
79293 -                     default_var.yres_virtual <<= 1;
79294 -                  } else if((default_var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
79295 -                     default_var.pixclock >>= 1;
79296 -                     default_var.yres >>= 1;
79297 -                     default_var.yres_virtual >>= 1;
79298 -                  }
79299 -                  
79300 +                       if((default_var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
79301 +                               default_var.pixclock <<= 1;
79302 +                       }
79303                 }
79304 -#ifdef SISFB_PAN
79305 -               if(sisfb_ypan) {
79306 -                       default_var.yres_virtual = 
79307 -                               ivideo.heapstart / (default_var.xres * (default_var.bits_per_pixel >> 3));
79308 -                       if(default_var.yres_virtual <= default_var.yres) {
79309 -                               default_var.yres_virtual = default_var.yres;
79310 -                       }
79311 -               } 
79312 -#endif
79313 -               
79314 -#endif
79315  
79316                 ivideo.accel = 0;
79317                 if(sisfb_accel) {
79318 @@ -4487,20 +5005,14 @@ int __init sisfb_init(void)
79319                    sisfb_initaccel();
79320                 }
79321  
79322 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)         /* ---- 2.4 series init ---- */
79323 -               sis_fb_info.node = -1;
79324 -               sis_fb_info.flags = FBINFO_FLAG_DEFAULT;
79325 -               sis_fb_info.blank = &sisfb_blank;
79326 -               sis_fb_info.fbops = &sisfb_ops;
79327 -               sis_fb_info.switch_con = &sisfb_switch;
79328 -               sis_fb_info.updatevar = &sisfb_update_var;
79329 -               sis_fb_info.changevar = NULL;
79330 -               sis_fb_info.disp = &sis_disp;
79331 -                       
79332 -               sisfb_set_disp(-1, &default_var, &sis_fb_info);
79333 -#endif
79334 +               if(sisfb_ypan) {
79335 +                       default_var.yres_virtual =
79336 +                               ivideo.heapstart / (default_var.xres * (default_var.bits_per_pixel >> 3));
79337 +                       if(default_var.yres_virtual <= default_var.yres) {
79338 +                               default_var.yres_virtual = default_var.yres;
79339 +                       }
79340 +               }
79341  
79342 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)                /* ---- 2.5 series init ---- */
79343                 sis_fb_info.flags = FBINFO_FLAG_DEFAULT;
79344                 sis_fb_info.var = default_var;
79345                 sis_fb_info.fix = sisfb_fix;
79346 @@ -4513,6 +5025,8 @@ int __init sisfb_init(void)
79347                 fb_alloc_cmap(&sis_fb_info.cmap, 256 , 0);
79348  #endif
79349  
79350 +               printk(KERN_INFO "sisfb: Initial vbflags 0x%lx\n", ivideo.vbflags);
79351 +
79352  #ifdef CONFIG_MTRR
79353                 ivideo.mtrr = mtrr_add((unsigned int) ivideo.video_base,
79354                                 (unsigned int) ivideo.video_size,
79355 @@ -4520,20 +5034,28 @@ int __init sisfb_init(void)
79356                 if(ivideo.mtrr) {
79357                         printk(KERN_INFO "sisfb: Added MTRRs\n");
79358                 }
79359 +
79360  #endif
79361  
79362  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
79363                 vc_resize_con(1, 1, 0);
79364  #endif
79365  
79366 -               TWDEBUG("Before calling register_framebuffer");
79367 -               
79368 -               if(register_framebuffer(&sis_fb_info) < 0)
79369 +               if(register_framebuffer(&sis_fb_info) < 0) {
79370 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
79371 +                       vfree(sishw_ext.pSR);
79372 +                       vfree(sishw_ext.pCR);
79373 +                       release_mem_region(ivideo.video_base, ivideo.video_size);
79374 +                       release_mem_region(ivideo.mmio_base, sisfb_mmio_size);
79375 +#endif
79376 +                       printk(KERN_ERR "sisfb: Fatal error: Failed to register framebuffer\n");
79377                         return -EINVAL;
79378 -                       
79379 +               }
79380 +
79381                 sisfb_registered = 1;                   
79382  
79383                 printk(KERN_INFO "sisfb: Installed SISFB_GET_INFO ioctl (%x)\n", SISFB_GET_INFO);
79384 +               printk(KERN_INFO "sisfb: Installed SISFB_GET_VBRSTATUS ioctl (%x)\n", SISFB_GET_VBRSTATUS);
79385                 
79386                 printk(KERN_INFO "sisfb: 2D acceleration is %s, scrolling mode %s\n",
79387                      sisfb_accel ? "enabled" : "disabled",
79388 @@ -4547,9 +5069,11 @@ int __init sisfb_init(void)
79389  
79390  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
79391                 printk(KERN_INFO "fb%d: %s frame buffer device, Version %d.%d.%02d\n",
79392 -                       sis_fb_info.node, myid, VER_MAJOR, VER_MINOR, VER_LEVEL);                            
79393 +                       sis_fb_info.node, myid, VER_MAJOR, VER_MINOR, VER_LEVEL);
79394  #endif
79395  
79396 +               printk(KERN_INFO "sisfb: (C) 2001-2003 Thomas Winischhofer. All rights reserved.\n");
79397 +
79398         }       /* TW: if mode = "none" */
79399         return 0;
79400  }
79401 @@ -4562,7 +5086,6 @@ static int          vesa = -1;
79402  static unsigned int rate = 0;
79403  static unsigned int crt1off = 1;
79404  static unsigned int mem = 0;
79405 -static unsigned int dstn = 0;
79406  static char         *forcecrt2type = NULL;
79407  static int          forcecrt1 = -1;
79408  static char         *queuemode = NULL;
79409 @@ -4575,25 +5098,33 @@ static int          inverse = 0;
79410  static int          userom = 1;
79411  static int          useoem = -1;
79412  static char         *tvstandard = NULL;
79413 +static int         nocrt2rate = 0;
79414 +static int          scalelcd = -1;
79415 +static char        *specialtiming = NULL;
79416  
79417 -MODULE_DESCRIPTION("SiS 300/540/630/730/315/550/650/740/330 framebuffer driver");
79418 +MODULE_DESCRIPTION("SiS 300/540/630/730/315/550/650/740/330/660/760 framebuffer driver");
79419  MODULE_LICENSE("GPL");
79420 -MODULE_AUTHOR("SiS; Thomas Winischhofer <thomas@winischhofer.net>; Various others");
79421 +MODULE_AUTHOR("Thomas Winischhofer <thomas@winischhofer.net>; SiS; Various others");
79422  
79423  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
79424  MODULE_PARM(mode, "s");
79425  MODULE_PARM_DESC(mode,
79426         "\nSelects the desired display mode in the format [X]x[Y]x[Depth], eg.\n"
79427 -         "800x600x16 (default: none if sisfb is a module; this leaves the\n"
79428 -        "console untouched and the driver will only do the video memory\n"
79429 -        "management for eg. DRM/DRI; 800x600x8 if sisfb is in the kernel)");
79430 +         "1024x768x16. Other formats supported include XxY-Depth and\n"
79431 +        "XxY-Depth@Rate. If the parameter is only one (decimal or hexadecimal)\n"
79432 +        "number, it will be interpreted as a VESA mode number. (default: none if\n"
79433 +        "sisfb is a module; this leaves the console untouched and the driver will\n"
79434 +        "only do the video memory management for eg. DRM/DRI; 800x600x8 if sisfb\n"
79435 +        "is in the kernel)");
79436  #endif
79437  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)         
79438  MODULE_PARM(mode, "s");
79439  MODULE_PARM_DESC(mode,
79440 -       "\nSelects the desired default display mode in the format [X]x[Y]x[Depth],\n"
79441 -         "eg. 1024x768x16 (default: 800x600x8)");
79442 -#endif  
79443 +       "\nSelects the desired default display mode in the format XxYxDepth,\n"
79444 +         "eg. 1024x768x16. Other formats supported include XxY-Depth and\n"
79445 +        "XxY-Depth@Rate. If the parameter is only one (decimal or hexadecimal)\n"
79446 +        "number, it will be interpreted as a VESA mode number. (default: 800x600x8)");
79447 +#endif
79448  
79449  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
79450  MODULE_PARM(vesa, "i");
79451 @@ -4603,17 +5134,18 @@ MODULE_PARM_DESC(vesa,
79452          "and the driver will only do the video memory management for eg. DRM/DRI;\n"
79453          "0x0103 if sisfb is in the kernel)");
79454  #endif
79455 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)         
79456 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
79457  MODULE_PARM(vesa, "i");
79458  MODULE_PARM_DESC(vesa,
79459         "\nSelects the desired default display mode by VESA defined mode number, eg.\n"
79460           "0x117 (default: 0x0103)");
79461 -#endif  
79462 +#endif
79463  
79464  MODULE_PARM(rate, "i");
79465  MODULE_PARM_DESC(rate,
79466         "\nSelects the desired vertical refresh rate for CRT1 (external VGA) in Hz.\n"
79467 -       "(default: 60)");
79468 +         "If the mode is specified in the format XxY-Depth@Rate, this parameter\n"
79469 +         "will be ignored (default: 60)");
79470  
79471  MODULE_PARM(crt1off,   "i");
79472  MODULE_PARM_DESC(crt1off,
79473 @@ -4624,14 +5156,9 @@ MODULE_PARM_DESC(filter,
79474         "\nSelects TV flicker filter type (only for systems with a SiS301 video bridge).\n"
79475           "(Possible values 0-7, default: [no filter])");
79476  
79477 -MODULE_PARM(dstn,   "i");
79478 -MODULE_PARM_DESC(dstn,
79479 -       "\nSelects DSTN/FSTN display mode for SiS550. This sets CRT2 type to LCD and\n"
79480 -         "overrides forcecrt2type setting. (1=ON, 0=OFF) (default: 0)");
79481 -
79482  MODULE_PARM(queuemode,   "s");
79483  MODULE_PARM_DESC(queuemode,
79484 -       "\nSelects the queue mode on 315/550/650/740/330. Possible choices are AGP, VRAM or\n"
79485 +       "\nSelects the queue mode on 315/550/650/740/330/660. Possible choices are AGP, VRAM,\n"
79486           "MMIO. AGP is only available if the kernel has AGP support. The queue mode is\n"
79487           "important to programs using the 2D/3D accelerator of the SiS chip. The modes\n"
79488           "require a totally different way of programming the engines. If any mode than\n"
79489 @@ -4642,11 +5169,12 @@ MODULE_PARM_DESC(queuemode,
79490  MODULE_PARM(mem,    "i");
79491  MODULE_PARM_DESC(mem,
79492         "\nDetermines the beginning of the video memory heap in KB. This heap is used\n"
79493 -         "for video RAM management for eg. DRM/DRI. The default depends on the amount\n"
79494 -         "of video RAM available. If 8MB of video RAM or less is available, the heap\n"
79495 -         "starts at 4096KB, if between 8 and 16MB are available at 8192KB, otherwise\n"
79496 -         "at 12288KB. The value is to be specified without 'KB' and should match\n"
79497 -         "the MaxXFBMem setting for XFree 4.x (x>=2).");
79498 +         "for video RAM management for eg. DRM/DRI. On 300 series, the default depends\n"
79499 +         "on the amount of video RAM available. If 8MB of video RAM or less is available,\n"
79500 +         "the heap starts at 4096KB, if between 8 and 16MB are available at 8192KB,\n"
79501 +         "otherwise at 12288KB. On 315 and Xabre series, the heap is 1MB by default. The\n"
79502 +         "value is to be specified without 'KB' and should match the MaxXFBMem setting for\n"
79503 +         "XFree 4.x (x>=2).");
79504  
79505  MODULE_PARM(forcecrt2type, "s");
79506  MODULE_PARM_DESC(forcecrt2type,
79507 @@ -4673,56 +5201,76 @@ MODULE_PARM_DESC(pdc,
79508  MODULE_PARM(noaccel, "i");
79509  MODULE_PARM_DESC(noaccel,
79510          "\nIf set to anything other than 0, 2D acceleration and y-panning will be\n"
79511 -       "disabled. (default: 0)");
79512 +         "disabled. (default: 0)");
79513  
79514  MODULE_PARM(noypan, "i");
79515  MODULE_PARM_DESC(noypan,
79516          "\nIf set to anything other than 0, y-panning will be disabled and scrolling\n"
79517 -       "will be performed by redrawing the screen. This required 2D acceleration, so\n"
79518 -       "if the option noaccel is set, y-panning will be disabled. (default: 0)");
79519 +         "will be performed by redrawing the screen. (default: 0)");
79520  
79521  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 
79522  MODULE_PARM(inverse, "i");
79523  MODULE_PARM_DESC(inverse,
79524          "\nSetting this to anything but 0 should invert the display colors, but this\n"
79525 -       "does not seem to work. (default: 0)");
79526 +         "does not seem to work. (default: 0)");
79527  #endif 
79528  
79529  MODULE_PARM(userom, "i");
79530  MODULE_PARM_DESC(userom,
79531          "\nSetting this to 0 keeps sisfb from using the video BIOS data which is needed\n"
79532 -       "for some LCD and TV setup. (default: 1)");
79533 +         "for some LCD and TV setup. (default: 1)");
79534  
79535  MODULE_PARM(useoem, "i");
79536  MODULE_PARM_DESC(useoem,
79537          "\nSetting this to 0 keeps sisfb from using its internel OEM data for some LCD\n"
79538 -       "panels and TV connector types. (default: auto)");
79539 +         "panels and TV connector types. (default: [auto])");
79540  
79541  MODULE_PARM(tvstandard, "s");
79542  MODULE_PARM_DESC(tvstandard,
79543         "\nThis allows overriding the BIOS default for the TV standard. Valid choices are\n"
79544 -       "pal and ntsc. (default: auto)");
79545 +         "pal and ntsc. (default: [auto])");
79546 +
79547 +MODULE_PARM(nocrt2rate, "i");
79548 +MODULE_PARM_DESC(nocrt2rate,
79549 +       "\nSetting this to 1 will force the driver to use the default refresh rate for\n"
79550 +         "CRT2 if CRT2 type is VGA. (default: 0, use same rate as CRT1)");
79551 +
79552 +MODULE_PARM(scalelcd, "i");
79553 +MODULE_PARM_DESC(scalelcd,
79554 +       "\nSetting this to 1 will force the driver to scale the LCD image to the panel's\n"
79555 +         "native resolution. Setting it to 0 will disable scaling; if the panel can scale\n"
79556 +         "by itself, it will probably do this, otherwise you will see a black bar around\n"
79557 +         "the screen image. Default: [autodetect if panel can scale]");
79558 +
79559 +MODULE_PARM(specialtiming, "s");
79560  
79561  int init_module(void)
79562  {
79563         int err;
79564 -       
79565 +
79566 +       SiS_Pr.UsePanelScaler = -1;
79567 +       SiS_Pr.SiS_CustomT = CUT_NONE;
79568 +
79569 +       ivideo.refresh_rate = sisfb_parm_rate = rate;
79570 +
79571 +       if((scalelcd == 0) || (scalelcd == 1)) {
79572 +          SiS_Pr.UsePanelScaler = scalelcd ^ 1;
79573 +       }
79574 +
79575         if(mode)
79576 -               sisfb_search_mode(mode);
79577 +               sisfb_search_mode(mode, FALSE);
79578         else if(vesa != -1)
79579 -               sisfb_search_vesamode(vesa);
79580 -       else  
79581 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 
79582 +               sisfb_search_vesamode(vesa, FALSE);
79583 +       else
79584 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
79585                 /* For 2.4, set mode=none if no mode is given  */
79586                 sisfb_mode_idx = MODE_INDEX_NONE;
79587  #endif
79588  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
79589 -               /* For 2.5, we don't need this "mode=none" stuff anymore */     
79590 +               /* For 2.5, we don't need this "mode=none" stuff anymore */
79591                 sisfb_mode_idx = DEFAULT_MODE;
79592  #endif
79593  
79594 -       ivideo.refresh_rate = rate;
79595 -
79596         if(forcecrt2type)
79597                 sisfb_search_crt2type(forcecrt2type);
79598  
79599 @@ -4745,9 +5293,6 @@ int init_module(void)
79600  
79601         if(noypan == 1)       sisfb_ypan = 0;
79602         else if(noypan == 0)  sisfb_ypan = 1;
79603 -
79604 -       /* TW: Panning only with acceleration */
79605 -       if(sisfb_accel == 0)  sisfb_ypan = 0;
79606         
79607  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
79608         if(inverse)           sisfb_inverse = 1;
79609 @@ -4759,17 +5304,11 @@ int init_module(void)
79610  
79611         sisfb_useoem = useoem;
79612  
79613 -       enable_dstn = dstn;
79614 -
79615 -       /* TW: DSTN overrules forcecrt2type */
79616 -       if (enable_dstn)      sisfb_crt2type = DISPTYPE_LCD;
79617 -
79618         if (queuemode)        sisfb_search_queuemode(queuemode);
79619         
79620         /* TW: If other queuemode than MMIO, disable 2D accel and ypan */
79621         if((sisfb_queuemode != -1) && (sisfb_queuemode != MMIO_CMD)) {
79622                 sisfb_accel = 0;
79623 -               sisfb_ypan = 0;
79624         }
79625  
79626          if(pdc) {
79627 @@ -4778,6 +5317,11 @@ int init_module(void)
79628            }
79629         }
79630  
79631 +       sisfb_nocrt2rate = nocrt2rate;
79632 +
79633 +       if(specialtiming)
79634 +               sisfb_search_specialtiming(specialtiming);
79635 +
79636         if((err = sisfb_init()) < 0) return err;
79637  
79638         return 0;
79639 @@ -4788,7 +5332,7 @@ void cleanup_module(void)
79640         /* TW: Release mem regions */
79641         release_mem_region(ivideo.video_base, ivideo.video_size);
79642         release_mem_region(ivideo.mmio_base, sisfb_mmio_size);
79643 -       
79644 +
79645  #ifdef CONFIG_MTRR
79646         /* TW: Release MTRR region */
79647         if(ivideo.mtrr) {
79648 @@ -4802,11 +5346,17 @@ void cleanup_module(void)
79649         if(sisfb_registered) {
79650                 unregister_framebuffer(&sis_fb_info);
79651         }
79652 -       
79653 +
79654         if(sishw_ext.pSR) vfree(sishw_ext.pSR);
79655         if(sishw_ext.pCR) vfree(sishw_ext.pCR);
79656         
79657 -       /* TODO: Restore the initial mode */
79658 +       /* TODO: Restore the initial mode
79659 +        * This sounds easy but is as good as impossible
79660 +        * on many machines with SiS chip and video bridge
79661 +        * since text modes are always set up differently
79662 +        * from machine to machine. Depends on the type
79663 +        * of integration between chipset and bridge.
79664 +        */
79665         
79666         printk(KERN_INFO "sisfb: Module unloaded\n");
79667  }
79668 --- linux-2.6.0-test6/drivers/video/sis/sis_main.h      2003-06-14 12:18:04.000000000 -0700
79669 +++ 25/drivers/video/sis/sis_main.h     2003-10-05 00:34:22.000000000 -0700
79670 @@ -1,8 +1,6 @@
79671  #ifndef _SISFB_MAIN
79672  #define _SISFB_MAIN
79673  
79674 -/* Comments and changes marked with "TW" by Thomas Winischhofer <thomas@winischhofer.net> */
79675 -
79676  #include "vstruct.h"
79677  
79678  /* ------------------- Constant Definitions ------------------------- */
79679 @@ -14,11 +12,11 @@
79680  
79681  #define VER_MAJOR                 1
79682  #define VER_MINOR                 6
79683 -#define VER_LEVEL                 1
79684 +#define VER_LEVEL                 13
79685  
79686  #include "sis.h"
79687  
79688 -/* TW: To be included in pci_ids.h */
79689 +/* To be included in pci_ids.h */
79690  #ifndef PCI_DEVICE_ID_SI_650_VGA
79691  #define PCI_DEVICE_ID_SI_650_VGA  0x6325
79692  #endif
79693 @@ -31,13 +29,22 @@
79694  #ifndef PCI_DEVICE_ID_SI_330
79695  #define PCI_DEVICE_ID_SI_330      0x0330
79696  #endif
79697 +#ifndef PCI_DEVICE_ID_SI_660
79698 +#define PCI_DEVICE_ID_SI_660      0x0660
79699 +#endif
79700 +#ifndef PCI_DEVICE_ID_SI_660_VGA
79701 +#define PCI_DEVICE_ID_SI_660_VGA  0x6330
79702 +#endif
79703 +#ifndef PCI_DEVICE_ID_SI_760
79704 +#define PCI_DEVICE_ID_SI_760      0x0760
79705 +#endif
79706  
79707  /* To be included in fb.h */
79708  #ifndef FB_ACCEL_SIS_GLAMOUR_2
79709  #define FB_ACCEL_SIS_GLAMOUR_2  40     /* SiS 315, 650, 740            */
79710  #endif
79711  #ifndef FB_ACCEL_SIS_XABRE
79712 -#define FB_ACCEL_SIS_XABRE      41     /* SiS 330 ("Xabre")            */
79713 +#define FB_ACCEL_SIS_XABRE      41     /* SiS 330, 660, 760 ("Xabre")  */
79714  #endif
79715  
79716  #define MAX_ROM_SCAN              0x10000
79717 @@ -53,13 +60,12 @@
79718  #define TURBO_QUEUE_AREA_SIZE     0x80000 /* 512K */
79719  #endif
79720  
79721 -/* For 315 series */
79722 +/* For 315/Xabre series */
79723  #ifdef CONFIG_FB_SIS_315
79724  #define COMMAND_QUEUE_AREA_SIZE   0x80000 /* 512K */
79725  #define COMMAND_QUEUE_THRESHOLD   0x1F
79726  #endif
79727  
79728 -/* TW */
79729  #define HW_CURSOR_AREA_SIZE_315   0x4000  /* 16K */
79730  #define HW_CURSOR_AREA_SIZE_300   0x1000  /* 4K */
79731  
79732 @@ -283,48 +289,46 @@
79733  /* Fbcon variables */
79734  static struct fb_info sis_fb_info;
79735  
79736 -static int    video_type = FB_TYPE_PACKED_PIXELS;
79737 -
79738  static struct fb_var_screeninfo default_var = {
79739 -       .xres           = 0,
79740 -       .yres           = 0,
79741 -       .xres_virtual   = 0,
79742 -       .yres_virtual   = 0,
79743 -       .xoffset        = 0,
79744 -       .yoffset        = 0,
79745 -       .bits_per_pixel = 0,
79746 -       .grayscale      = 0,
79747 -       .red            = {0, 8, 0},
79748 -       .green          = {0, 8, 0},
79749 -       .blue           = {0, 8, 0},
79750 -       .transp         = {0, 0, 0},
79751 -       .nonstd         = 0,
79752 -       .activate       = FB_ACTIVATE_NOW,
79753 -       .height         = -1,
79754 -       .width          = -1,
79755 -       .accel_flags    = 0,
79756 -       .pixclock       = 0,
79757 -       .left_margin    = 0,
79758 -       .right_margin   = 0,
79759 -       .upper_margin   = 0,
79760 -       .lower_margin   = 0,
79761 -       .hsync_len      = 0,
79762 -       .vsync_len      = 0,
79763 -       .sync           = 0,
79764 -       .vmode          = FB_VMODE_NONINTERLACED,
79765 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 
79766 -       .reserved       = {0, 0, 0, 0, 0, 0}
79767 -#endif 
79768 +       .xres            = 0,
79769 +       .yres            = 0,
79770 +       .xres_virtual    = 0,
79771 +       .yres_virtual    = 0,
79772 +       .xoffset         = 0,
79773 +       .yoffset         = 0,
79774 +       .bits_per_pixel  = 0,
79775 +       .grayscale       = 0,
79776 +       .red             = {0, 8, 0},
79777 +       .green           = {0, 8, 0},
79778 +       .blue            = {0, 8, 0},
79779 +       .transp          = {0, 0, 0},
79780 +       .nonstd          = 0,
79781 +       .activate        = FB_ACTIVATE_NOW,
79782 +       .height          = -1,
79783 +       .width           = -1,
79784 +       .accel_flags     = 0,
79785 +       .pixclock        = 0,
79786 +       .left_margin     = 0,
79787 +       .right_margin    = 0,
79788 +       .upper_margin    = 0,
79789 +       .lower_margin    = 0,
79790 +       .hsync_len       = 0,
79791 +       .vsync_len       = 0,
79792 +       .sync            = 0,
79793 +       .vmode           = FB_VMODE_NONINTERLACED,
79794 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
79795 +       .reserved        = {0, 0, 0, 0, 0, 0}
79796 +#endif
79797  };
79798  
79799  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
79800  static struct fb_fix_screeninfo sisfb_fix = {
79801         .id             = "SiS",
79802         .type           = FB_TYPE_PACKED_PIXELS,
79803 -       .xpanstep       = 1,
79804 +       .xpanstep       = 0,
79805         .ypanstep       = 1,
79806  };
79807 -static char myid[20];
79808 +static char myid[40];
79809  static u32 pseudo_palette[17];
79810  #endif
79811  
79812 @@ -347,26 +351,24 @@ static union {
79813  } sis_fbcon_cmap;
79814  
79815  static int sisfb_inverse = 0;
79816 +static int currcon = 0;
79817  #endif
79818  
79819 -/* display status */
79820 +/* global flags */
79821  static int sisfb_off = 0;
79822  static int sisfb_crt1off = 0;
79823  static int sisfb_forcecrt1 = -1;
79824  static int sisvga_enabled = 0;
79825  static int sisfb_userom = 1;
79826  static int sisfb_useoem = -1;
79827 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
79828 -static int currcon = 0;
79829 -#endif
79830 -
79831 -/* global flags */
79832 -static int sisfb_registered;
79833 -static int sisfb_tvmode = 0;
79834 +static int sisfb_parm_rate = -1;
79835 +static int sisfb_registered = 0;
79836  static int sisfb_mem = 0;
79837  static int sisfb_pdc = 0;
79838 -static int enable_dstn = 0;
79839  static int sisfb_ypan = -1;
79840 +static int sisfb_nocrt2rate = 0;
79841 +static int sisfb_dstn = 0;
79842 +static int sisfb_fstn = 0;
79843  
79844  VGA_ENGINE sisvga_engine = UNKNOWN_VGA;
79845  int       sisfb_accel = -1;
79846 @@ -375,22 +377,22 @@ int          sisfb_accel = -1;
79847  static int sisfb_hwcursor_size = 0;
79848  static int sisfb_CRT2_write_enable = 0;
79849  
79850 -int sisfb_crt2type  = -1;      /* TW: CRT2 type (for overriding autodetection) */
79851 -int sisfb_tvplug    = -1;      /* PR: Tv plug type (for overriding autodetection) */
79852 +int sisfb_crt2type  = -1;      /* CRT2 type (for overriding autodetection) */
79853 +int sisfb_tvplug    = -1;      /* Tv plug type (for overriding autodetection) */
79854  
79855 -int sisfb_queuemode = -1;      /* TW: Use MMIO queue mode by default (310/325 series only) */
79856 +int sisfb_queuemode = -1;      /* Use MMIO queue mode by default (315 series only) */
79857  
79858  unsigned char sisfb_detectedpdc = 0;
79859  
79860  unsigned char sisfb_detectedlcda = 0xff;
79861  
79862 -/* data for sis components */
79863 +/* data for sis hardware ("par") */
79864  struct video_info ivideo;
79865  
79866 -/* TW: For ioctl SISFB_GET_INFO */
79867 +/* For ioctl SISFB_GET_INFO */
79868  sisfb_info sisfbinfo;
79869  
79870 -/* TW: Hardware extension; contains data on hardware */
79871 +/* Hardware extension; contains data on hardware */
79872  HW_DEVICE_EXTENSION sishw_ext = {
79873         NULL, NULL, FALSE, NULL, NULL,
79874         0, 0, 0, 0, 0, 0, 0, 0, 0,
79875 @@ -399,10 +401,10 @@ HW_DEVICE_EXTENSION sishw_ext = {
79876         0
79877  };
79878  
79879 -/* TW: SiS private structure */
79880 +/* SiS private structure */
79881  SiS_Private  SiS_Pr;
79882  
79883 -/* card parameters */
79884 +/* Card parameters */
79885  static unsigned long sisfb_mmio_size = 0;
79886  static u8            sisfb_caps = 0;
79887  
79888 @@ -412,7 +414,7 @@ typedef enum _SIS_CMDTYPE {
79889         VM_CMD_QUEUE,
79890  } SIS_CMDTYPE;
79891  
79892 -/* Supported SiS Chips list */
79893 +/* List of supported chips */
79894  static struct board {
79895         u16 vendor, device;
79896         const char *name;
79897 @@ -424,16 +426,17 @@ static struct board {
79898         {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_315,     "SIS 315"},
79899         {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_315PRO,  "SIS 315PRO"},
79900         {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_550_VGA, "SIS 550 VGA"},
79901 -       {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_650_VGA, "SIS 650/M650/651/740 VGA"},
79902 +       {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_650_VGA, "SIS 650/M650/651/M652/740 VGA"},
79903         {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_330,     "SIS 330"},
79904 +       {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_660_VGA, "SIS 660/M660/760/M760 VGA"},
79905         {0, 0, NULL}
79906  };
79907  
79908  #define MD_SIS300 1
79909  #define MD_SIS315 2
79910  
79911 -/* mode table */
79912 -/* NOT const - will be patched for 1280x960 mode number chaos reasons */
79913 +/* Mode table */
79914 +/* NOT const - will be patched for 1280x768 mode number chaos reasons */
79915  struct _sisbios_mode {
79916         char name[15];
79917         u8 mode_no;
79918 @@ -447,14 +450,33 @@ struct _sisbios_mode {
79919         u16 rows;
79920         u8  chipset;
79921  } sisbios_mode[] = {
79922 -#define MODE_INDEX_NONE           0  /* TW: index for mode=none */
79923 -       {"none",         0xFF, 0x0000, 0x0000,    0,    0,  0, 0,   0,  0, MD_SIS300|MD_SIS315},  /* TW: for mode "none" */
79924 -       {"320x240x16",   0x56, 0x0000, 0x0000,  320,  240, 16, 1,  40, 15,           MD_SIS315},
79925 -       {"320x480x8",    0x5A, 0x0000, 0x0000,  320,  480,  8, 1,  40, 30,           MD_SIS315},  /* TW: FSTN */
79926 -       {"320x480x16",   0x5B, 0x0000, 0x0000,  320,  480, 16, 1,  40, 30,           MD_SIS315},  /* TW: FSTN */
79927 -       {"640x480x8",    0x2E, 0x0101, 0x0101,  640,  480,  8, 1,  80, 30, MD_SIS300|MD_SIS315},
79928 +#define MODE_INDEX_NONE           0  /* index for mode=none */
79929 +       {"none",         0xff, 0x0000, 0x0000,    0,    0,  0, 0,   0,  0, MD_SIS300|MD_SIS315},
79930 +       {"320x200x8",    0x59, 0x0138, 0x0000,  320,  200,  8, 1,  40, 12, MD_SIS300|MD_SIS315},
79931 +       {"320x200x16",   0x41, 0x010e, 0x0000,  320,  200, 16, 1,  40, 12, MD_SIS300|MD_SIS315},
79932 +       {"320x200x24",   0x4f, 0x0000, 0x0000,  320,  200, 32, 1,  40, 12, MD_SIS300|MD_SIS315},  /* TW: That's for people who mix up color- and fb depth */
79933 +       {"320x200x32",   0x4f, 0x0000, 0x0000,  320,  200, 32, 1,  40, 12, MD_SIS300|MD_SIS315},
79934 +       {"320x240x8",    0x50, 0x0132, 0x0000,  320,  240,  8, 1,  40, 15, MD_SIS300|MD_SIS315},
79935 +       {"320x240x16",   0x56, 0x0135, 0x0000,  320,  240, 16, 1,  40, 15, MD_SIS300|MD_SIS315},
79936 +       {"320x240x24",   0x53, 0x0000, 0x0000,  320,  240, 32, 1,  40, 15, MD_SIS300|MD_SIS315},
79937 +       {"320x240x32",   0x53, 0x0000, 0x0000,  320,  240, 32, 1,  40, 15, MD_SIS300|MD_SIS315},
79938 +       {"320x240x8",    0x5a, 0x0132, 0x0000,  320,  480,  8, 1,  40, 30,           MD_SIS315},  /* TW: FSTN */
79939 +       {"320x240x16",   0x5b, 0x0135, 0x0000,  320,  480, 16, 1,  40, 30,           MD_SIS315},  /* TW: FSTN */
79940 +       {"400x300x8",    0x51, 0x0133, 0x0000,  400,  300,  8, 1,  50, 18, MD_SIS300|MD_SIS315},
79941 +       {"400x300x16",   0x57, 0x0136, 0x0000,  400,  300, 16, 1,  50, 18, MD_SIS300|MD_SIS315},
79942 +       {"400x300x24",   0x54, 0x0000, 0x0000,  400,  300, 32, 1,  50, 18, MD_SIS300|MD_SIS315},
79943 +       {"400x300x32",   0x54, 0x0000, 0x0000,  400,  300, 32, 1,  50, 18, MD_SIS300|MD_SIS315},
79944 +       {"512x384x8",    0x52, 0x0000, 0x0000,  512,  384,  8, 1,  64, 24, MD_SIS300|MD_SIS315},
79945 +       {"512x384x16",   0x58, 0x0000, 0x0000,  512,  384, 16, 1,  64, 24, MD_SIS300|MD_SIS315},
79946 +       {"512x384x24",   0x5c, 0x0000, 0x0000,  512,  384, 32, 1,  64, 24, MD_SIS300|MD_SIS315},
79947 +       {"512x384x32",   0x5c, 0x0000, 0x0000,  512,  384, 32, 1,  64, 24, MD_SIS300|MD_SIS315},
79948 +       {"640x400x8",    0x2f, 0x0000, 0x0000,  640,  400,  8, 1,  80, 25, MD_SIS300|MD_SIS315},
79949 +       {"640x400x16",   0x5d, 0x0000, 0x0000,  640,  400, 16, 1,  80, 25, MD_SIS300|MD_SIS315},
79950 +       {"640x400x24",   0x5e, 0x0000, 0x0000,  640,  400, 32, 1,  80, 25, MD_SIS300|MD_SIS315},
79951 +       {"640x400x32",   0x5e, 0x0000, 0x0000,  640,  400, 32, 1,  80, 25, MD_SIS300|MD_SIS315},
79952 +       {"640x480x8",    0x2e, 0x0101, 0x0101,  640,  480,  8, 1,  80, 30, MD_SIS300|MD_SIS315},
79953         {"640x480x16",   0x44, 0x0111, 0x0111,  640,  480, 16, 1,  80, 30, MD_SIS300|MD_SIS315},
79954 -       {"640x480x24",   0x62, 0x013a, 0x0112,  640,  480, 32, 1,  80, 30, MD_SIS300|MD_SIS315},  /* TW: That's for people who mix up color- and fb depth */
79955 +       {"640x480x24",   0x62, 0x013a, 0x0112,  640,  480, 32, 1,  80, 30, MD_SIS300|MD_SIS315},
79956         {"640x480x32",   0x62, 0x013a, 0x0112,  640,  480, 32, 1,  80, 30, MD_SIS300|MD_SIS315},
79957         {"720x480x8",    0x31, 0x0000, 0x0000,  720,  480,  8, 1,  90, 30, MD_SIS300|MD_SIS315},
79958         {"720x480x16",   0x33, 0x0000, 0x0000,  720,  480, 16, 1,  90, 30, MD_SIS300|MD_SIS315},
79959 @@ -464,63 +486,87 @@ struct _sisbios_mode {
79960         {"720x576x16",   0x34, 0x0000, 0x0000,  720,  576, 16, 1,  90, 36, MD_SIS300|MD_SIS315},
79961         {"720x576x24",   0x36, 0x0000, 0x0000,  720,  576, 32, 1,  90, 36, MD_SIS300|MD_SIS315},
79962         {"720x576x32",   0x36, 0x0000, 0x0000,  720,  576, 32, 1,  90, 36, MD_SIS300|MD_SIS315},
79963 +       {"768x576x8",    0x5f, 0x0000, 0x0000,  768,  576,  8, 1,  96, 36, MD_SIS300|MD_SIS315},
79964 +       {"768x576x16",   0x60, 0x0000, 0x0000,  768,  576, 16, 1,  96, 36, MD_SIS300|MD_SIS315},
79965 +       {"768x576x24",   0x61, 0x0000, 0x0000,  768,  576, 32, 1,  96, 36, MD_SIS300|MD_SIS315},
79966 +       {"768x576x32",   0x61, 0x0000, 0x0000,  768,  576, 32, 1,  96, 36, MD_SIS300|MD_SIS315},
79967         {"800x480x8",    0x70, 0x0000, 0x0000,  800,  480,  8, 1, 100, 30, MD_SIS300|MD_SIS315},
79968         {"800x480x16",   0x7a, 0x0000, 0x0000,  800,  480, 16, 1, 100, 30, MD_SIS300|MD_SIS315},
79969         {"800x480x24",   0x76, 0x0000, 0x0000,  800,  480, 32, 1, 100, 30, MD_SIS300|MD_SIS315},
79970         {"800x480x32",   0x76, 0x0000, 0x0000,  800,  480, 32, 1, 100, 30, MD_SIS300|MD_SIS315},
79971 -#define DEFAULT_MODE              20 /* TW: index for 800x600x8 */
79972 -#define DEFAULT_LCDMODE           20 /* TW: index for 800x600x8 */
79973 -#define DEFAULT_TVMODE            20 /* TW: index for 800x600x8 */
79974 +#define DEFAULT_MODE              43 /* index for 800x600x8 */
79975 +#define DEFAULT_LCDMODE           43 /* index for 800x600x8 */
79976 +#define DEFAULT_TVMODE            43 /* index for 800x600x8 */
79977         {"800x600x8",    0x30, 0x0103, 0x0103,  800,  600,  8, 2, 100, 37, MD_SIS300|MD_SIS315},
79978         {"800x600x16",   0x47, 0x0114, 0x0114,  800,  600, 16, 2, 100, 37, MD_SIS300|MD_SIS315},
79979         {"800x600x24",   0x63, 0x013b, 0x0115,  800,  600, 32, 2, 100, 37, MD_SIS300|MD_SIS315},
79980         {"800x600x32",   0x63, 0x013b, 0x0115,  800,  600, 32, 2, 100, 37, MD_SIS300|MD_SIS315},
79981 +       {"848x480x8",    0x39, 0x0000, 0x0000,  848,  480,  8, 2, 106, 30, MD_SIS300|MD_SIS315},
79982 +       {"848x480x16",   0x3b, 0x0000, 0x0000,  848,  480, 16, 2, 106, 30, MD_SIS300|MD_SIS315},
79983 +       {"848x480x24",   0x3e, 0x0000, 0x0000,  848,  480, 32, 2, 106, 30, MD_SIS300|MD_SIS315},
79984 +       {"848x480x32",   0x3e, 0x0000, 0x0000,  848,  480, 32, 2, 106, 30, MD_SIS300|MD_SIS315},
79985 +       {"856x480x8",    0x3f, 0x0000, 0x0000,  856,  480,  8, 2, 107, 30, MD_SIS300|MD_SIS315},
79986 +       {"856x480x16",   0x42, 0x0000, 0x0000,  856,  480, 16, 2, 107, 30, MD_SIS300|MD_SIS315},
79987 +       {"856x480x24",   0x45, 0x0000, 0x0000,  856,  480, 32, 2, 107, 30, MD_SIS300|MD_SIS315},
79988 +       {"856x480x32",   0x45, 0x0000, 0x0000,  856,  480, 32, 2, 107, 30, MD_SIS300|MD_SIS315},
79989         {"1024x576x8",   0x71, 0x0000, 0x0000, 1024,  576,  8, 1, 128, 36, MD_SIS300|MD_SIS315},
79990         {"1024x576x16",  0x74, 0x0000, 0x0000, 1024,  576, 16, 1, 128, 36, MD_SIS300|MD_SIS315},
79991         {"1024x576x24",  0x77, 0x0000, 0x0000, 1024,  576, 32, 1, 128, 36, MD_SIS300|MD_SIS315},
79992         {"1024x576x32",  0x77, 0x0000, 0x0000, 1024,  576, 32, 1, 128, 36, MD_SIS300|MD_SIS315},
79993 -       {"1024x600x8",   0x20, 0x0000, 0x0000, 1024,  600,  8, 1, 128, 37, MD_SIS300          },  /* TW: 300 series only */
79994 +       {"1024x600x8",   0x20, 0x0000, 0x0000, 1024,  600,  8, 1, 128, 37, MD_SIS300          },
79995         {"1024x600x16",  0x21, 0x0000, 0x0000, 1024,  600, 16, 1, 128, 37, MD_SIS300          },
79996         {"1024x600x24",  0x22, 0x0000, 0x0000, 1024,  600, 32, 1, 128, 37, MD_SIS300          },
79997         {"1024x600x32",  0x22, 0x0000, 0x0000, 1024,  600, 32, 1, 128, 37, MD_SIS300          },
79998         {"1024x768x8",   0x38, 0x0105, 0x0105, 1024,  768,  8, 2, 128, 48, MD_SIS300|MD_SIS315},
79999 -       {"1024x768x16",  0x4A, 0x0117, 0x0117, 1024,  768, 16, 2, 128, 48, MD_SIS300|MD_SIS315},
80000 +       {"1024x768x16",  0x4a, 0x0117, 0x0117, 1024,  768, 16, 2, 128, 48, MD_SIS300|MD_SIS315},
80001         {"1024x768x24",  0x64, 0x013c, 0x0118, 1024,  768, 32, 2, 128, 48, MD_SIS300|MD_SIS315},
80002         {"1024x768x32",  0x64, 0x013c, 0x0118, 1024,  768, 32, 2, 128, 48, MD_SIS300|MD_SIS315},
80003 -       {"1152x768x8",   0x23, 0x0000, 0x0000, 1152,  768,  8, 1, 144, 48, MD_SIS300          },  /* TW: 300 series only */
80004 +       {"1152x768x8",   0x23, 0x0000, 0x0000, 1152,  768,  8, 1, 144, 48, MD_SIS300          },
80005         {"1152x768x16",  0x24, 0x0000, 0x0000, 1152,  768, 16, 1, 144, 48, MD_SIS300          },
80006         {"1152x768x24",  0x25, 0x0000, 0x0000, 1152,  768, 32, 1, 144, 48, MD_SIS300          },
80007         {"1152x768x32",  0x25, 0x0000, 0x0000, 1152,  768, 32, 1, 144, 48, MD_SIS300          },
80008 +       {"1152x864x8",   0x29, 0x0000, 0x0000, 1152,  864,  8, 1, 144, 54, MD_SIS300|MD_SIS315},
80009 +       {"1152x864x16",  0x2a, 0x0000, 0x0000, 1152,  864, 16, 1, 144, 54, MD_SIS300|MD_SIS315},
80010 +       {"1152x864x24",  0x2b, 0x0000, 0x0000, 1152,  864, 32, 1, 144, 54, MD_SIS300|MD_SIS315},
80011 +       {"1152x864x32",  0x2b, 0x0000, 0x0000, 1152,  864, 32, 1, 144, 54, MD_SIS300|MD_SIS315},
80012         {"1280x720x8",   0x79, 0x0000, 0x0000, 1280,  720,  8, 1, 160, 45, MD_SIS300|MD_SIS315},
80013         {"1280x720x16",  0x75, 0x0000, 0x0000, 1280,  720, 16, 1, 160, 45, MD_SIS300|MD_SIS315},
80014         {"1280x720x24",  0x78, 0x0000, 0x0000, 1280,  720, 32, 1, 160, 45, MD_SIS300|MD_SIS315},
80015         {"1280x720x32",  0x78, 0x0000, 0x0000, 1280,  720, 32, 1, 160, 45, MD_SIS300|MD_SIS315},
80016 -       {"1280x768x8",   0x23, 0x0000, 0x0000, 1280,  768,  8, 1, 160, 48,           MD_SIS315},  /* TW: 310/325 series only */
80017 -       {"1280x768x16",  0x24, 0x0000, 0x0000, 1280,  768, 16, 1, 160, 48,           MD_SIS315},
80018 -       {"1280x768x24",  0x25, 0x0000, 0x0000, 1280,  768, 32, 1, 160, 48,           MD_SIS315},
80019 -       {"1280x768x32",  0x25, 0x0000, 0x0000, 1280,  768, 32, 1, 160, 48,           MD_SIS315},
80020 -#define MODEINDEX_1280x960 48
80021 -       {"1280x960x8",   0x7C, 0x0000, 0x0000, 1280,  960,  8, 1, 160, 60, MD_SIS300|MD_SIS315},  /* TW: Modenumbers being patched */
80022 -       {"1280x960x16",  0x7D, 0x0000, 0x0000, 1280,  960, 16, 1, 160, 60, MD_SIS300|MD_SIS315},
80023 -       {"1280x960x24",  0x7E, 0x0000, 0x0000, 1280,  960, 32, 1, 160, 60, MD_SIS300|MD_SIS315},
80024 -       {"1280x960x32",  0x7E, 0x0000, 0x0000, 1280,  960, 32, 1, 160, 60, MD_SIS300|MD_SIS315},
80025 -       {"1280x1024x8",  0x3A, 0x0107, 0x0107, 1280, 1024,  8, 2, 160, 64, MD_SIS300|MD_SIS315},
80026 -       {"1280x1024x16", 0x4D, 0x011a, 0x011a, 1280, 1024, 16, 2, 160, 64, MD_SIS300|MD_SIS315},
80027 +#define MODEINDEX_1280x768 79
80028 +       {"1280x768x8",   0x23, 0x0000, 0x0000, 1280,  768,  8, 1, 160, 48, MD_SIS300|MD_SIS315},
80029 +       {"1280x768x16",  0x24, 0x0000, 0x0000, 1280,  768, 16, 1, 160, 48, MD_SIS300|MD_SIS315},
80030 +       {"1280x768x24",  0x25, 0x0000, 0x0000, 1280,  768, 32, 1, 160, 48, MD_SIS300|MD_SIS315},
80031 +       {"1280x768x32",  0x25, 0x0000, 0x0000, 1280,  768, 32, 1, 160, 48, MD_SIS300|MD_SIS315},
80032 +       {"1280x960x8",   0x7c, 0x0000, 0x0000, 1280,  960,  8, 1, 160, 60, MD_SIS300|MD_SIS315},
80033 +       {"1280x960x16",  0x7d, 0x0000, 0x0000, 1280,  960, 16, 1, 160, 60, MD_SIS300|MD_SIS315},
80034 +       {"1280x960x24",  0x7e, 0x0000, 0x0000, 1280,  960, 32, 1, 160, 60, MD_SIS300|MD_SIS315},
80035 +       {"1280x960x32",  0x7e, 0x0000, 0x0000, 1280,  960, 32, 1, 160, 60, MD_SIS300|MD_SIS315},
80036 +       {"1280x1024x8",  0x3a, 0x0107, 0x0107, 1280, 1024,  8, 2, 160, 64, MD_SIS300|MD_SIS315},
80037 +       {"1280x1024x16", 0x4d, 0x011a, 0x011a, 1280, 1024, 16, 2, 160, 64, MD_SIS300|MD_SIS315},
80038         {"1280x1024x24", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 2, 160, 64, MD_SIS300|MD_SIS315},
80039         {"1280x1024x32", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 2, 160, 64, MD_SIS300|MD_SIS315},
80040 -       {"1400x1050x8",  0x26, 0x0000, 0x0000, 1400, 1050,  8, 1, 175, 65,           MD_SIS315},  /* TW: 310/325 series only */
80041 +       {"1360x768x8",   0x48, 0x0000, 0x0000, 1360,  768,  8, 1, 170, 48, MD_SIS300|MD_SIS315},
80042 +       {"1360x768x16",  0x4b, 0x0000, 0x0000, 1360,  768, 16, 1, 170, 48, MD_SIS300|MD_SIS315},
80043 +       {"1360x768x24",  0x4e, 0x0000, 0x0000, 1360,  768, 32, 1, 170, 48, MD_SIS300|MD_SIS315},
80044 +       {"1360x768x32",  0x4e, 0x0000, 0x0000, 1360,  768, 32, 1, 170, 48, MD_SIS300|MD_SIS315},
80045 +       {"1360x1024x8",  0x67, 0x0000, 0x0000, 1360, 1024,  8, 1, 170, 64, MD_SIS300          },
80046 +       {"1360x1024x16", 0x6f, 0x0000, 0x0000, 1360, 1024, 16, 1, 170, 64, MD_SIS300          },
80047 +       {"1360x1024x24", 0x72, 0x0000, 0x0000, 1360, 1024, 32, 1, 170, 64, MD_SIS300          },
80048 +       {"1360x1024x32", 0x72, 0x0000, 0x0000, 1360, 1024, 32, 1, 170, 64, MD_SIS300          },
80049 +       {"1400x1050x8",  0x26, 0x0000, 0x0000, 1400, 1050,  8, 1, 175, 65,           MD_SIS315},
80050         {"1400x1050x16", 0x27, 0x0000, 0x0000, 1400, 1050, 16, 1, 175, 65,           MD_SIS315},
80051         {"1400x1050x24", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65,           MD_SIS315},
80052         {"1400x1050x32", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65,           MD_SIS315},
80053 -       {"1600x1200x8",  0x3C, 0x0130, 0x011c, 1600, 1200,  8, 1, 200, 75, MD_SIS300|MD_SIS315},
80054 -       {"1600x1200x16", 0x3D, 0x0131, 0x011e, 1600, 1200, 16, 1, 200, 75, MD_SIS300|MD_SIS315},
80055 +       {"1600x1200x8",  0x3c, 0x0130, 0x011c, 1600, 1200,  8, 1, 200, 75, MD_SIS300|MD_SIS315},
80056 +       {"1600x1200x16", 0x3d, 0x0131, 0x011e, 1600, 1200, 16, 1, 200, 75, MD_SIS300|MD_SIS315},
80057         {"1600x1200x24", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75, MD_SIS300|MD_SIS315},
80058         {"1600x1200x32", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75, MD_SIS300|MD_SIS315},
80059         {"1920x1440x8",  0x68, 0x013f, 0x0000, 1920, 1440,  8, 1, 240, 75, MD_SIS300|MD_SIS315},
80060         {"1920x1440x16", 0x69, 0x0140, 0x0000, 1920, 1440, 16, 1, 240, 75, MD_SIS300|MD_SIS315},
80061 -       {"1920x1440x24", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_SIS300|MD_SIS315},
80062 -       {"1920x1440x32", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_SIS300|MD_SIS315},
80063 -       {"2048x1536x8",  0x6c, 0x0000, 0x0000, 2048, 1536,  8, 1, 256, 96,           MD_SIS315},  /* TW: 310/325 series only */
80064 +       {"1920x1440x24", 0x6b, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_SIS300|MD_SIS315},
80065 +       {"1920x1440x32", 0x6b, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_SIS300|MD_SIS315},
80066 +       {"2048x1536x8",  0x6c, 0x0000, 0x0000, 2048, 1536,  8, 1, 256, 96,           MD_SIS315},
80067         {"2048x1536x16", 0x6d, 0x0000, 0x0000, 2048, 1536, 16, 1, 256, 96,           MD_SIS315},
80068         {"2048x1536x24", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96,           MD_SIS315},
80069         {"2048x1536x32", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96,           MD_SIS315},
80070 @@ -538,37 +584,36 @@ u8  sisfb_rate_idx = 0;
80071  
80072  /* TW: CR36 evaluation */
80073  const USHORT sis300paneltype[] =
80074 -    { LCD_UNKNOWN,   LCD_800x600,  LCD_1024x768,  LCD_1280x1024,
80075 -      LCD_1280x960,  LCD_640x480,  LCD_1024x600,  LCD_1152x768,
80076 -      LCD_320x480,   LCD_1024x768, LCD_1024x768,  LCD_1024x768,
80077 -      LCD_1024x768,  LCD_1024x768, LCD_1024x768,  LCD_1024x768 };
80078 +    { LCD_UNKNOWN,   LCD_800x600,   LCD_1024x768,  LCD_1280x1024,
80079 +      LCD_1280x960,  LCD_640x480,   LCD_1024x600,  LCD_1152x768,
80080 +      LCD_1024x768,  LCD_1024x768,  LCD_1024x768,  LCD_1024x768,
80081 +      LCD_1024x768,  LCD_1024x768,  LCD_320x480,   LCD_1024x768 };
80082  
80083  const USHORT sis310paneltype[] =
80084 -    { LCD_UNKNOWN,   LCD_800x600,  LCD_1024x768,  LCD_1280x1024,
80085 -      LCD_640x480,   LCD_1024x600, LCD_1152x864,  LCD_1280x960,
80086 -      LCD_1152x768,  LCD_1400x1050,LCD_1280x768,  LCD_1600x1200,
80087 -      LCD_320x480,   LCD_1024x768, LCD_1024x768,  LCD_1024x768 };
80088 +    { LCD_UNKNOWN,   LCD_800x600,   LCD_1024x768,  LCD_1280x1024,
80089 +      LCD_640x480,   LCD_1024x600,  LCD_1152x864,  LCD_1280x960,
80090 +      LCD_1152x768,  LCD_1400x1050, LCD_1280x768,  LCD_1600x1200,
80091 +      LCD_640x480_2, LCD_640x480_3, LCD_320x480,   LCD_1024x768 };
80092 +
80093 +#define FL_550_DSTN 0x01
80094 +#define FL_550_FSTN 0x02
80095  
80096  static const struct _sis_crt2type {
80097         char name[10];
80098         int type_no;
80099         int tvplug_no;
80100 +       unsigned short flags;
80101  } sis_crt2type[] = {
80102 -       {"NONE",        0,              -1},
80103 -       {"LCD",         DISPTYPE_LCD,   -1},
80104 -       {"TV",          DISPTYPE_TV,    -1},
80105 -       {"VGA",         DISPTYPE_CRT2,  -1},
80106 -       {"SVIDEO",      DISPTYPE_TV,    TVPLUG_SVIDEO},
80107 -       {"COMPOSITE",   DISPTYPE_TV,    TVPLUG_COMPOSITE},
80108 -       {"SCART",       DISPTYPE_TV,    TVPLUG_SCART},
80109 -       {"none",        0,              -1},
80110 -       {"lcd",         DISPTYPE_LCD,   -1},
80111 -       {"tv",          DISPTYPE_TV,    -1},
80112 -       {"vga",         DISPTYPE_CRT2,  -1},
80113 -       {"svideo",      DISPTYPE_TV,    TVPLUG_SVIDEO},
80114 -       {"composite",   DISPTYPE_TV,    TVPLUG_COMPOSITE},
80115 -       {"scart",       DISPTYPE_TV,    TVPLUG_SCART},
80116 -       {"\0",          -1,             -1}
80117 +       {"NONE",        0,              -1,        0},
80118 +       {"LCD",         CRT2_LCD,       -1,        0},
80119 +       {"TV",          CRT2_TV,        -1,        0},
80120 +       {"VGA",         CRT2_VGA,       -1,        0},
80121 +       {"SVIDEO",      CRT2_TV,        TV_SVIDEO, 0},
80122 +       {"COMPOSITE",   CRT2_TV,        TV_AVIDEO, 0},
80123 +       {"SCART",       CRT2_TV,        TV_SCART,  0},
80124 +       {"DSTN",        CRT2_LCD,       -1,        FL_550_DSTN},
80125 +       {"FSTN",        CRT2_LCD,       -1,        FL_550_FSTN},
80126 +       {"\0",          -1,             -1,        0}
80127  };
80128  
80129  /* Queue mode selection for 310 series */
80130 @@ -579,9 +624,6 @@ static const struct _sis_queuemode {
80131         {"AGP",         AGP_CMD_QUEUE},
80132         {"VRAM",        VM_CMD_QUEUE},
80133         {"MMIO",        MMIO_CMD},
80134 -       {"agp",         AGP_CMD_QUEUE},
80135 -       {"vram",        VM_CMD_QUEUE},
80136 -       {"mmio",        MMIO_CMD},
80137         {"\0",          -1}
80138  };
80139  
80140 @@ -590,10 +632,8 @@ static const struct _sis_tvtype {
80141         char name[6];
80142         int type_no;
80143  } sis_tvtype[] = {
80144 -       {"PAL",         1},
80145 -       {"NTSC",        2},
80146 -       {"pal",         1},
80147 -       {"ntsc",        2},
80148 +       {"PAL",         TV_PAL},
80149 +       {"NTSC",        TV_NTSC},
80150         {"\0",          -1}
80151  };
80152  
80153 @@ -602,33 +642,102 @@ static const struct _sis_vrate {
80154         u16 xres;
80155         u16 yres;
80156         u16 refresh;
80157 +       BOOLEAN SiS730valid32bpp;
80158  } sisfb_vrate[] = {
80159 -       {1,  640,  480, 60}, {2,  640,  480,  72}, {3, 640,   480,  75}, {4,  640, 480,  85},
80160 -       {5,  640,  480,100}, {6,  640,  480, 120}, {7, 640,   480, 160}, {8,  640, 480, 200},
80161 -       {1,  720,  480, 60},
80162 -       {1,  720,  576, 58},
80163 -       {1,  800,  480, 60}, {2,  800,  480,  75}, {3, 800,   480,  85},
80164 -       {1,  800,  600, 56}, {2,  800,  600,  60}, {3, 800,   600,  72}, {4,  800, 600,  75},
80165 -       {5,  800,  600, 85}, {6,  800,  600, 100}, {7, 800,   600, 120}, {8,  800, 600, 160},
80166 -       {1, 1024,  768, 43}, {2, 1024,  768,  60}, {3, 1024,  768,  70}, {4, 1024, 768,  75},
80167 -       {5, 1024,  768, 85}, {6, 1024,  768, 100}, {7, 1024,  768, 120},
80168 -       {1, 1024,  576, 60}, {2, 1024,  576,  75}, {3, 1024,  576,  85},
80169 -       {1, 1024,  600, 60},
80170 -       {1, 1152,  768, 60},
80171 -       {1, 1280,  720, 60}, {2, 1280,  720,  75}, {3, 1280,  720,  85},
80172 -       {1, 1280,  768, 60},
80173 -       {1, 1280, 1024, 43}, {2, 1280, 1024,  60}, {3, 1280, 1024,  75}, {4, 1280, 1024,  85},
80174 -       {1, 1280,  960, 70},
80175 -       {1, 1400, 1050, 60},
80176 -       {1, 1600, 1200, 60}, {2, 1600, 1200,  65}, {3, 1600, 1200,  70}, {4, 1600, 1200,  75},
80177 -       {5, 1600, 1200, 85}, {6, 1600, 1200, 100}, {7, 1600, 1200, 120},
80178 -       {1, 1920, 1440, 60}, {2, 1920, 1440,  65}, {3, 1920, 1440,  70}, {4, 1920, 1440,  75},
80179 -       {5, 1920, 1440, 85}, {6, 1920, 1440, 100},
80180 -       {1, 2048, 1536, 60}, {2, 2048, 1536,  65}, {3, 2048, 1536,  70}, {4, 2048, 1536,  75},
80181 -       {5, 2048, 1536, 85},
80182 -       {0, 0, 0, 0}
80183 +       {1,  320,  200,  70,  TRUE},
80184 +       {1,  320,  240,  60,  TRUE},
80185 +       {1,  320,  480,  60,  TRUE},
80186 +       {1,  400,  300,  60,  TRUE},
80187 +       {1,  512,  384,  60,  TRUE},
80188 +       {1,  640,  400,  72,  TRUE},
80189 +       {1,  640,  480,  60,  TRUE}, {2,  640,  480,  72,  TRUE}, {3,  640,  480,  75,  TRUE},
80190 +       {4,  640,  480,  85,  TRUE}, {5,  640,  480, 100,  TRUE}, {6,  640,  480, 120,  TRUE},
80191 +       {7,  640,  480, 160,  TRUE}, {8,  640,  480, 200,  TRUE},
80192 +       {1,  720,  480,  60,  TRUE},
80193 +       {1,  720,  576,  58,  TRUE},
80194 +       {1,  800,  480,  60,  TRUE}, {2,  800,  480,  75,  TRUE}, {3,  800,  480,  85,  TRUE},
80195 +       {1,  800,  600,  56,  TRUE}, {2,  800,  600,  60,  TRUE}, {3,  800,  600,  72,  TRUE},
80196 +       {4,  800,  600,  75,  TRUE}, {5,  800,  600,  85,  TRUE}, {6,  800,  600, 105,  TRUE},
80197 +       {7,  800,  600, 120,  TRUE}, {8,  800,  600, 160,  TRUE},
80198 +       {1,  848,  480,  39,  TRUE}, {2,  848,  480,  60,  TRUE},
80199 +       {1,  856,  480,  39,  TRUE}, {2,  856,  480,  60,  TRUE},
80200 +       {1, 1024,  576,  60,  TRUE}, {2, 1024,  576,  75,  TRUE}, {3, 1024,  576,  85,  TRUE},
80201 +       {1, 1024,  600,  60,  TRUE},
80202 +       {1, 1024,  768,  43,  TRUE}, {2, 1024,  768,  60,  TRUE}, {3, 1024,  768,  70, FALSE},
80203 +       {4, 1024,  768,  75, FALSE}, {5, 1024,  768,  85,  TRUE}, {6, 1024,  768, 100,  TRUE},
80204 +       {7, 1024,  768, 120,  TRUE},
80205 +       {1, 1152,  768,  60,  TRUE},
80206 +       {1, 1152,  864,  75,  TRUE}, {2, 1152,  864,  84,  TRUE},
80207 +       {1, 1280,  720,  60,  TRUE}, {2, 1280,  720,  75,  TRUE}, {3, 1280,  720,  85,  TRUE},
80208 +       {1, 1280,  768,  60,  TRUE},
80209 +       {1, 1280,  960,  60,  TRUE}, {2, 1280,  960,  85,  TRUE},
80210 +       {1, 1280, 1024,  43,  TRUE}, {2, 1280, 1024,  60,  TRUE}, {3, 1280, 1024,  75,  TRUE},
80211 +       {4, 1280, 1024,  85,  TRUE},
80212 +       {1, 1360,  768,  60,  TRUE},
80213 +       {1, 1360, 1024,  59,  TRUE},
80214 +       {1, 1400, 1050,  60,  TRUE}, {2, 1400, 1050,  75,  TRUE},
80215 +       {1, 1600, 1200,  60,  TRUE}, {2, 1600, 1200,  65,  TRUE}, {3, 1600, 1200,  70,  TRUE},
80216 +       {4, 1600, 1200,  75,  TRUE}, {5, 1600, 1200,  85,  TRUE}, {6, 1600, 1200, 100,  TRUE},
80217 +       {7, 1600, 1200, 120,  TRUE},
80218 +       {1, 1920, 1440,  60,  TRUE}, {2, 1920, 1440,  65,  TRUE}, {3, 1920, 1440,  70,  TRUE},
80219 +       {4, 1920, 1440,  75,  TRUE}, {5, 1920, 1440,  85,  TRUE}, {6, 1920, 1440, 100,  TRUE},
80220 +       {1, 2048, 1536,  60,  TRUE}, {2, 2048, 1536,  65,  TRUE}, {3, 2048, 1536,  70,  TRUE},
80221 +       {4, 2048, 1536,  75,  TRUE}, {5, 2048, 1536,  85,  TRUE},
80222 +       {0,    0,    0,   0, FALSE}
80223  };
80224  
80225 +static struct sisfb_monitor {
80226 +       u16 hmin;
80227 +       u16 hmax;
80228 +       u16 vmin;
80229 +       u16 vmax;
80230 +       u32 dclockmax;
80231 +       u8  feature;
80232 +       BOOLEAN datavalid;
80233 +} sisfb_thismonitor;
80234 +
80235 +static const struct _sisfbddcsmodes {
80236 +       u32 mask;
80237 +       u16 h;
80238 +       u16 v;
80239 +       u32 d;
80240 +} sisfb_ddcsmodes[] = {
80241 +       { 0x10000, 67, 75, 108000},
80242 +       { 0x08000, 48, 72,  50000},
80243 +       { 0x04000, 46, 75,  49500},
80244 +       { 0x01000, 35, 43,  44900},
80245 +       { 0x00800, 48, 60,  65000},
80246 +       { 0x00400, 56, 70,  75000},
80247 +       { 0x00200, 60, 75,  78800},
80248 +       { 0x00100, 80, 75, 135000},
80249 +       { 0x00020, 31, 60,  25200},
80250 +       { 0x00008, 38, 72,  31500},
80251 +       { 0x00004, 37, 75,  31500},
80252 +       { 0x00002, 35, 56,  36000},
80253 +       { 0x00001, 38, 60,  40000}
80254 +};
80255 +
80256 +static const struct _sisfbddcfmodes {
80257 +       u16 x;
80258 +       u16 y;
80259 +       u16 v;
80260 +       u16 h;
80261 +       u32 d;
80262 +} sisfb_ddcfmodes[] = {
80263 +       { 1280, 1024, 85, 92, 157500},
80264 +       { 1600, 1200, 60, 75, 162000},
80265 +       { 1600, 1200, 65, 82, 175500},
80266 +       { 1600, 1200, 70, 88, 189000},
80267 +       { 1600, 1200, 75, 94, 202500},
80268 +       { 1600, 1200, 85, 107,229500},
80269 +       { 1920, 1440, 60, 90, 234000},
80270 +       { 1920, 1440, 75, 113,297000}
80271 +};
80272 +
80273 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
80274 +static u8 sisfb_lastrates[128];
80275 +#endif
80276 +
80277  static const struct _chswtable {
80278      int subsysVendor;
80279      int subsysCard;
80280 @@ -636,9 +745,61 @@ static const struct _chswtable {
80281      char *cardName;
80282  } mychswtable[] = {
80283          { 0x1631, 0x1002, "Mitachi", "0x1002" },
80284 +       { 0x1071, 0x7521, "Mitac"  , "7521P"  },
80285         { 0,      0,      ""       , ""       }
80286  };
80287  
80288 +static const struct _customttable {
80289 +    unsigned short chipID;
80290 +    char *biosversion;
80291 +    char *biosdate;
80292 +    unsigned long bioschksum;
80293 +    unsigned short biosFootprintAddr[5];
80294 +    unsigned char biosFootprintData[5];
80295 +    unsigned short pcisubsysvendor;
80296 +    unsigned short pcisubsyscard;
80297 +    char *vendorName;
80298 +    char *cardName;
80299 +    unsigned long SpecialID;
80300 +    char *optionName;
80301 +} mycustomttable[] = {
80302 +        { SIS_630, "2.00.07", "09/27/2002-13:38:25",
80303 +         0x3240A8,
80304 +         { 0x220, 0x227, 0x228, 0x229, 0x22a },
80305 +         {  0x01,  0xe3,  0x9a,  0x6a,  0x00 },
80306 +         0x1039, 0x6300,
80307 +         "Barco", "iQ R200L/300/400", CUT_BARCO1366, "BARCO1366"
80308 +       },
80309 +       { SIS_630, "2.00.07", "09/27/2002-13:38:25",
80310 +         0x323FBD,
80311 +         { 0x220, 0x227, 0x228, 0x229, 0x22a },
80312 +         {  0x00,  0x5a,  0x64,  0x41,  0x00 },
80313 +         0x1039, 0x6300,
80314 +         "Barco", "iQ G200L/300/400/500", CUT_BARCO1024, "BARCO1024"
80315 +       },
80316 +       { SIS_650, "", "",
80317 +         0,
80318 +         { 0, 0, 0, 0, 0 },
80319 +         { 0, 0, 0, 0, 0 },
80320 +         0x0e11, 0x083c,
80321 +         "Compaq", "Presario 3045US", CUT_COMPAQ12802, "COMPAQ1280"
80322 +       },
80323 +       { 4321, "", "",                 /* This is hopefully NEVER autodetected */
80324 +         0,
80325 +         { 0, 0, 0, 0, 0 },
80326 +         { 0, 0, 0, 0, 0 },
80327 +         0, 0,
80328 +         "Generic", "LVDS/Parallel 848x480", CUT_PANEL848, "PANEL848x480"
80329 +       },
80330 +       { 0, "", "",
80331 +         0,
80332 +         { 0, 0, 0, 0 },
80333 +         { 0, 0, 0, 0 },
80334 +         0, 0,
80335 +         "", "", CUT_NONE, ""
80336 +       }
80337 +};
80338 +
80339  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
80340  /* Offscreen layout */
80341  typedef struct _SIS_GLYINFO {
80342 @@ -677,7 +838,6 @@ static unsigned long sisfb_heap_end;
80343  static unsigned long sisfb_heap_size;
80344  static SIS_HEAP      sisfb_heap;
80345  
80346 -// Eden Chen
80347  static const struct _sis_TV_filter {
80348         u8 filter[9][4];
80349  } sis_TV_filter[] = {
80350 @@ -829,9 +989,8 @@ static const struct _sis_TV_filter {
80351  
80352  static int           filter = -1;
80353  static unsigned char filter_tb;
80354 -//~Eden Chen
80355  
80356 -/* ---------------------- Routine prototypes ------------------------- */
80357 +/* ---------------------- Prototypes ------------------------- */
80358  
80359  /* Interface used by the world */
80360  #ifndef MODULE
80361 @@ -894,10 +1053,6 @@ extern void     fbcon_sis_fillrect(struc
80362                                     const struct fb_fillrect *rect);
80363  extern void     fbcon_sis_copyarea(struct fb_info *info, 
80364                                     const struct fb_copyarea *area);
80365 -#if 0                             
80366 -extern void     cfb_imageblit(struct fb_info *info, 
80367 -                              const struct fb_image *image);
80368 -#endif                       
80369  extern int      fbcon_sis_sync(struct fb_info *info);
80370  static int      sisfb_ioctl(struct inode *inode, 
80371                             struct file *file,
80372 @@ -912,7 +1067,7 @@ extern int      sisfb_mode_rate_to_ddata
80373                          unsigned int *left_margin, unsigned int *right_margin, 
80374                          unsigned int *upper_margin, unsigned int *lower_margin,
80375                          unsigned int *hsync_len, unsigned int *vsync_len,
80376 -                        unsigned int *sync, unsigned int *vmode);                                                                    
80377 +                        unsigned int *sync, unsigned int *vmode);
80378  #endif
80379                         
80380  static int      sisfb_get_fix(struct fb_fix_screeninfo *fix, int con,
80381 @@ -923,9 +1078,9 @@ extern int      sisfb_initaccel(void);
80382  extern void     sisfb_syncaccel(void);
80383  
80384  /* Internal general routines */
80385 -static void     sisfb_search_mode(const char *name);
80386 -static int      sisfb_validate_mode(int modeindex);
80387 -static u8       sisfb_search_refresh_rate(unsigned int rate);
80388 +static void     sisfb_search_mode(char *name, BOOLEAN quiet);
80389 +static int      sisfb_validate_mode(int modeindex, unsigned long vbflags);
80390 +static u8       sisfb_search_refresh_rate(unsigned int rate, int index);
80391  static int      sisfb_setcolreg(unsigned regno, unsigned red, unsigned green,
80392                         unsigned blue, unsigned transp,
80393                         struct fb_info *fb_info);
80394 @@ -939,6 +1094,12 @@ static BOOLEAN  sisfb_CheckVBRetrace(voi
80395  static BOOLEAN  sisfbcheckvretracecrt2(void);
80396  static BOOLEAN  sisfbcheckvretracecrt1(void);
80397  static BOOLEAN  sisfb_bridgeisslave(void);
80398 +static void     sisfb_detect_VB_connect(void);
80399 +static void     sisfb_get_VB_type(void);
80400 +
80401 +static void     sisfb_handle_ddc(struct sisfb_monitor *monitor, int crtno);
80402 +static BOOLEAN  sisfb_interpret_edid(struct sisfb_monitor *monitor, unsigned char *buffer);
80403 +
80404  
80405  /* SiS-specific Export functions */
80406  void            sis_dispinfo(struct ap_data *rec);
80407 @@ -952,15 +1113,9 @@ u32             sisfb_get_reg3(u16 port)
80408  /* Chipset-dependent internal routines */
80409  #ifdef CONFIG_FB_SIS_300
80410  static int      sisfb_get_dram_size_300(void);
80411 -static void     sisfb_detect_VB_connect_300(void);
80412 -static void     sisfb_get_VB_type_300(void);
80413 -static int      sisfb_has_VB_300(void);
80414  #endif
80415  #ifdef CONFIG_FB_SIS_315
80416  static int      sisfb_get_dram_size_315(void);
80417 -static void     sisfb_detect_VB_connect_315(void);
80418 -static void     sisfb_get_VB_type_315(void);
80419 -static int      sisfb_has_VB_315(void);
80420  #endif
80421  
80422  /* Internal heap routines */
80423 @@ -978,23 +1133,33 @@ BOOLEAN         sisfb_query_VGA_config_s
80424  BOOLEAN         sisfb_query_north_bridge_space(PSIS_HW_DEVICE_INFO psishw_ext,
80425                         unsigned long offset, unsigned long set, unsigned long *value);
80426  
80427 -
80428  /* Routines from init.c/init301.c */
80429  extern void    SiSRegInit(SiS_Private *SiS_Pr, USHORT BaseAddr);
80430  extern BOOLEAN  SiSInit(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension);
80431  extern BOOLEAN  SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo);
80432 -extern void     SiS_SetEnableDstn(SiS_Private *SiS_Pr);
80433 +extern void     SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable);
80434 +extern void     SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable);
80435  extern void     SiS_LongWait(SiS_Private *SiS_Pr);
80436  
80437 -/* TW: Chrontel TV functions */
80438 +extern BOOLEAN  sisfb_gettotalfrommode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
80439 +                      unsigned char modeno, int *htotal, int *vtotal, unsigned char rateindex);
80440 +
80441 +/* Chrontel TV functions */
80442  extern USHORT  SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempbx);
80443  extern void    SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempbx);
80444  extern USHORT  SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempbx);
80445  extern void    SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx);
80446  extern void     SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh);
80447  extern void     SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime);
80448 +extern void     SiS_SetChrontelGPIO(SiS_Private *SiS_Pr, USHORT myvbinfo);
80449 +extern USHORT   SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine,
80450 +                             USHORT adaptnum, USHORT DDCdatatype, unsigned char *buffer);
80451 +extern void SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension);
80452 +extern void SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr);
80453 +extern void SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension);
80454 +extern void SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension);
80455  
80456 -/* TW: Sensing routines */
80457 +/* Sensing routines */
80458  void            SiS_Sense30x(void);
80459  int             SISDoSense(int tempbl, int tempbh, int tempcl, int tempch);
80460  void            SiS_SenseCh(void);                     
80461 --- linux-2.6.0-test6/drivers/video/sis/vgatypes.h      2003-06-14 12:17:55.000000000 -0700
80462 +++ 25/drivers/video/sis/vgatypes.h     2003-10-05 00:34:22.000000000 -0700
80463 @@ -1,3 +1,36 @@
80464 +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/vgatypes.h,v 1.0 2001/06/15 21:23:00 dawes Exp $ */
80465 +/*
80466 + * General type definitions for universal mode switching modules
80467 + *
80468 + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
80469 + *
80470 + * If distributed as part of the linux kernel, the contents of this file
80471 + * is entirely covered by the GPL.
80472 + *
80473 + * Otherwise, the following terms apply:
80474 + *
80475 + * Permission to use, copy, modify, distribute, and sell this software and its
80476 + * documentation for any purpose is hereby granted without fee, provided that
80477 + * the above copyright notice appear in all copies and that both that
80478 + * copyright notice and this permission notice appear in supporting
80479 + * documentation, and that the name of the copyright holder not be used in
80480 + * advertising or publicity pertaining to distribution of the software without
80481 + * specific, written prior permission.  The copyright holder makes no representations
80482 + * about the suitability of this software for any purpose.  It is provided
80483 + * "as is" without express or implied warranty.
80484 + *
80485 + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
80486 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
80487 + * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
80488 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
80489 + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
80490 + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
80491 + * PERFORMANCE OF THIS SOFTWARE.
80492 + *
80493 + * Authors:    Thomas Winischhofer <thomas@winischhofer.net>
80494 + *             Silicon Integrated Systems
80495 + *
80496 + */
80497  #ifndef _VGATYPES_
80498  #define _VGATYPES_
80499  
80500 @@ -5,7 +38,7 @@
80501  #include "xf86Pci.h"
80502  #endif
80503  
80504 -#ifdef LINUX_KERNEL  /* TW: We don't want the X driver to depend on kernel source */
80505 +#ifdef LINUX_KERNEL  /* We don't want the X driver to depend on kernel source */
80506  #include <linux/ioctl.h>
80507  #endif
80508  
80509 @@ -72,18 +105,15 @@ typedef void VOID;
80510  typedef UCHAR BOOLEAN;
80511  #endif
80512  
80513 -#ifndef WINCE_HEADER
80514  #ifndef bool
80515  typedef UCHAR bool;
80516  #endif
80517 -#endif /*WINCE_HEADER*/
80518  
80519  #ifndef VBIOS_VER_MAX_LENGTH
80520  #define VBIOS_VER_MAX_LENGTH         4
80521  #endif
80522  
80523  #ifndef LINUX_KERNEL   /* For kernel, this is defined in sisfb.h */
80524 -#ifndef WIN2000
80525  #ifndef SIS_CHIP_TYPE
80526  typedef enum _SIS_CHIP_TYPE {
80527      SIS_VGALegacy = 0,
80528 @@ -101,19 +131,19 @@ typedef enum _SIS_CHIP_TYPE {
80529      SIS_550,
80530      SIS_650,
80531      SIS_740,
80532 -    SIS_330, 
80533 +    SIS_330,
80534 +    SIS_660,
80535 +    SIS_760,
80536      MAX_SIS_CHIP
80537  } SIS_CHIP_TYPE;
80538  #endif
80539  #endif
80540 -#endif
80541  
80542 -#ifndef WIN2000
80543  #ifndef SIS_VB_CHIP_TYPE
80544  typedef enum _SIS_VB_CHIP_TYPE {
80545      VB_CHIP_Legacy = 0,
80546      VB_CHIP_301,
80547 -    VB_CHIP_301B,      
80548 +    VB_CHIP_301B,
80549      VB_CHIP_301LV,
80550      VB_CHIP_302,
80551      VB_CHIP_302B,
80552 @@ -122,9 +152,7 @@ typedef enum _SIS_VB_CHIP_TYPE {
80553      MAX_VB_CHIP
80554  } SIS_VB_CHIP_TYPE;
80555  #endif
80556 -#endif
80557  
80558 -#ifndef WIN2000
80559  #ifndef SIS_LCD_TYPE
80560  typedef enum _SIS_LCD_TYPE {
80561      LCD_INVALID = 0,
80562 @@ -136,18 +164,20 @@ typedef enum _SIS_LCD_TYPE {
80563      LCD_1600x1200,
80564      LCD_1920x1440,
80565      LCD_2048x1536,
80566 -    LCD_320x480,       /* TW: FSTN */
80567 +    LCD_320x480,       /* FSTN, DSTN */
80568      LCD_1400x1050,
80569      LCD_1152x864,
80570      LCD_1152x768,
80571      LCD_1280x768,
80572      LCD_1024x600,
80573 +    LCD_640x480_2,     /* FSTN, DSTN */
80574 +    LCD_640x480_3,     /* FSTN, DSTN */
80575 +    LCD_848x480,
80576 +    LCD_CUSTOM,
80577      LCD_UNKNOWN
80578  } SIS_LCD_TYPE;
80579  #endif
80580 -#endif
80581  
80582 -#ifndef WIN2000 /* mark by Paul, Move definition to sisv.h*/
80583  #ifndef PSIS_DSReg
80584  typedef struct _SIS_DSReg
80585  {
80586 @@ -162,7 +192,6 @@ typedef struct _SIS_HW_DEVICE_INFO  SIS_
80587  
80588  typedef BOOLEAN (*PSIS_QUERYSPACE)   (PSIS_HW_DEVICE_INFO, ULONG, ULONG, ULONG *);
80589  
80590 -
80591  struct _SIS_HW_DEVICE_INFO
80592  {
80593      PVOID  pDevice;              /* The pointer to the physical device data structure
80594 @@ -173,7 +202,7 @@ struct _SIS_HW_DEVICE_INFO
80595                                   /* Note:ROM image file is the file of VBIOS ROM */
80596  
80597      BOOLEAN UseROM;             /* TW: Use the ROM image if provided */
80598
80599 +
80600      UCHAR  *pjCustomizedROMImage;/* base virtual address of ROM image file. */
80601                                   /* wincE:ROM image file is the file for OEM */
80602                                   /*       customized table */
80603 @@ -195,7 +224,7 @@ struct _SIS_HW_DEVICE_INFO
80604                                   /* defined in the data structure type */
80605                                   /* "SIS_VB_CHIP_TYPE" */
80606  
80607 -    USHORT usExternalChip;       /* NO VB or other video bridge(not  */
80608 +    USHORT usExternalChip;       /* NO VB or other video bridge (other than  */
80609                                   /* SiS video bridge) */
80610                                   /* if ujVBChipID = VB_CHIP_UNKNOWN, */
80611                                   /* then bit0=1 : LVDS,bit1=1 : trumpion, */
80612 @@ -207,7 +236,7 @@ struct _SIS_HW_DEVICE_INFO
80613                                   /*             011:Trumpion LVDS Scaling Chip */
80614                                   /*             100:LVDS(LCD-out)+Chrontel 7005 */
80615                                   /*             101:Single Chrontel 7005 */
80616 -                                /* TW: This has changed on 310/325 series! */
80617 +                                /* TW: This has changed on 315 series! */
80618  
80619      ULONG  ulCRT2LCDType;        /* defined in the data structure type */
80620                                   /* "SIS_LCD_TYPE" */
80621 @@ -244,7 +273,6 @@ struct _SIS_HW_DEVICE_INFO
80622  #endif
80623  };
80624  #endif
80625 -#endif 
80626  
80627  
80628  /* TW: Addtional IOCTL for communication sisfb <> X driver        */
80629 @@ -284,12 +312,16 @@ struct _SISFB_INFO {
80630         
80631         unsigned char sisfb_lcda;
80632  
80633 -       char reserved[235];             /* for future use */
80634 +       unsigned long sisfb_vbflags;
80635 +       unsigned long sisfb_currentvbflags;
80636 +
80637 +       int sisfb_scalelcd;
80638 +       unsigned long sisfb_specialtiming;
80639 +
80640 +       char reserved[219];             /* for future use */
80641  };
80642  #endif
80643  
80644 -#ifndef WIN2000
80645 -#ifndef WINCE_HEADER
80646  #ifndef BUS_DATA_TYPE
80647  typedef enum _BUS_DATA_TYPE {
80648      ConfigurationSpaceUndefined = -1,
80649 @@ -307,7 +339,6 @@ typedef enum _BUS_DATA_TYPE {
80650      MaximumBusDataType
80651  } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
80652  #endif
80653 -#endif /* WINCE_HEADER */
80654  
80655  #ifndef PCI_TYPE0_ADDRESSES
80656  #define PCI_TYPE0_ADDRESSES             6
80657 @@ -317,7 +348,6 @@ typedef enum _BUS_DATA_TYPE {
80658  #define PCI_TYPE1_ADDRESSES             2
80659  #endif
80660  
80661 -#ifndef WINCE_HEADER
80662  #ifndef PCI_COMMON_CONFIG
80663  typedef struct _PCI_COMMON_CONFIG {
80664      USHORT  VendorID;                   /* (ro)                 */
80665 @@ -355,7 +385,6 @@ typedef struct _PCI_COMMON_CONFIG {
80666  
80667  } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
80668  #endif
80669 -#endif /* WINCE_HEADER */
80670  
80671  #ifndef FIELD_OFFSET
80672  #define FIELD_OFFSET(type, field)    ((LONG)&(((type *)0)->field))
80673 @@ -364,6 +393,6 @@ typedef struct _PCI_COMMON_CONFIG {
80674  #ifndef PCI_COMMON_HDR_LENGTH
80675  #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET (PCI_COMMON_CONFIG, DeviceSpecific))
80676  #endif
80677 -#endif
80678  
80679  #endif
80680 +
80681 --- linux-2.6.0-test6/drivers/video/sis/vstruct.h       2003-06-14 12:18:25.000000000 -0700
80682 +++ 25/drivers/video/sis/vstruct.h      2003-10-05 00:34:22.000000000 -0700
80683 @@ -1,3 +1,37 @@
80684 +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/vstruct.h,v 1.0 2001/06/15 21:23:00 dawes Exp $ */
80685 +/*
80686 + * General structure definitions for universal mode switching modules
80687 + *
80688 + * Copyright 2002, 2003 by Thomas Winischhofer, Vienna, Austria
80689 + *
80690 + * If distributed as part of the linux kernel, the contents of this file
80691 + * is entirely covered by the GPL.
80692 + *
80693 + * Otherwise, the following terms apply:
80694 + *
80695 + * Permission to use, copy, modify, distribute, and sell this software and its
80696 + * documentation for any purpose is hereby granted without fee, provided that
80697 + * the above copyright notice appear in all copies and that both that
80698 + * copyright notice and this permission notice appear in supporting
80699 + * documentation, and that the name of the copyright holder not be used in
80700 + * advertising or publicity pertaining to distribution of the software without
80701 + * specific, written prior permission.  The copyright holder makes no representations
80702 + * about the suitability of this software for any purpose.  It is provided
80703 + * "as is" without express or implied warranty.
80704 + *
80705 + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
80706 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
80707 + * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
80708 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
80709 + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
80710 + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
80711 + * PERFORMANCE OF THIS SOFTWARE.
80712 + *
80713 + * Authors:    Thomas Winischhofer <thomas@winischhofer.net>
80714 + *              Silicon Integrated Systems
80715 + *
80716 + */
80717 +
80718  #ifdef _INIT_
80719  #define EXTERN
80720  #else
80721 @@ -58,7 +92,6 @@ typedef struct _SiS_LVDSCRT1DataStruct
80722         UCHAR  CR[15];
80723  } SiS_LVDSCRT1DataStruct;
80724  
80725 -/*add for LCDA*/
80726  typedef struct _SiS_LCDACRT1DataStruct
80727  {
80728         UCHAR  CR[17];
80729 @@ -111,9 +144,7 @@ typedef struct _SiS_ExtStruct
80730         UCHAR  Ext_ModeID;
80731         USHORT Ext_ModeFlag;
80732         USHORT Ext_ModeInfo;
80733 -       USHORT Ext_Point;
80734         USHORT Ext_VESAID;
80735 -       UCHAR  Ext_VESAMEMSize;
80736         UCHAR  Ext_RESINFO;
80737         UCHAR  VB_ExtTVFlickerIndex;
80738         UCHAR  VB_ExtTVEdgeIndex;
80739 @@ -130,7 +161,6 @@ typedef struct _SiS_Ext2Struct
80740         UCHAR  ModeID;
80741         USHORT XRes;
80742         USHORT YRes;
80743 -       USHORT ROM_OFFSET;
80744  } SiS_Ext2Struct;
80745  
80746  typedef struct _SiS_Part2PortTblStruct
80747 @@ -183,6 +213,15 @@ typedef struct _SiS_ModeResInfoStruct
80748  
80749  typedef UCHAR DRAM4Type[4];
80750  
80751 +/* Defines for SiS_Customt */
80752 +#define CUT_NONE        0
80753 +#define CUT_FORCENONE   1
80754 +#define CUT_BARCO1366   2
80755 +#define CUT_BARCO1024   3
80756 +#define CUT_COMPAQ1280  4
80757 +#define CUT_COMPAQ12802 5
80758 +#define CUT_PANEL848    6
80759 +
80760  typedef struct _SiS_Private
80761  {
80762  #ifdef LINUX_KERNEL
80763 @@ -198,25 +237,34 @@ typedef struct _SiS_Private
80764         USHORT SiS_P3c7;
80765         USHORT SiS_P3c8;
80766         USHORT SiS_P3c9;
80767 +       USHORT SiS_P3cb;
80768 +       USHORT SiS_P3cd;
80769         USHORT SiS_P3da;
80770         USHORT SiS_Part1Port;
80771         USHORT SiS_Part2Port;
80772         USHORT SiS_Part3Port;
80773         USHORT SiS_Part4Port;
80774         USHORT SiS_Part5Port;
80775 +       USHORT SiS_VidCapt;
80776 +       USHORT SiS_VidPlay;
80777         USHORT SiS_IF_DEF_LVDS;
80778         USHORT SiS_IF_DEF_TRUMPION;
80779         USHORT SiS_IF_DEF_DSTN;
80780         USHORT SiS_IF_DEF_FSTN;
80781         USHORT SiS_IF_DEF_CH70xx;
80782         USHORT SiS_IF_DEF_HiVision;
80783 +       USHORT SiS_SysFlags;
80784         UCHAR  SiS_VGAINFO;
80785 +#ifndef LINUX_KERNEL
80786 +        USHORT SiS_CP1, SiS_CP2, SiS_CP3, SiS_CP4;
80787 +#endif
80788         BOOLEAN SiS_UseROM;
80789         int    SiS_CHOverScan;
80790         BOOLEAN SiS_CHSOverScan;
80791         BOOLEAN SiS_ChSW;
80792         BOOLEAN SiS_UseLCDA;
80793         int    SiS_UseOEM;
80794 +       ULONG  SiS_CustomT;
80795         USHORT SiS_Backup70xx;
80796         USHORT SiS_CRT1Mode;
80797         USHORT SiS_flag_clearbuffer;
80798 @@ -270,15 +318,18 @@ typedef struct _SiS_Private
80799         USHORT SiS_Panel1280x768;
80800         USHORT SiS_Panel1024x600;
80801         USHORT SiS_Panel640x480;
80802 +       USHORT SiS_Panel640x480_2;
80803 +       USHORT SiS_Panel640x480_3;
80804         USHORT SiS_Panel1152x864;
80805 +       USHORT SiS_PanelCustom;
80806 +       USHORT SiS_PanelBarco1366;
80807         USHORT SiS_PanelMax;
80808         USHORT SiS_PanelMinLVDS;
80809         USHORT SiS_PanelMin301;
80810         USHORT SiS_ChrontelInit;
80811         
80812 -       /* Pointers: */
80813         const SiS_StStruct          *SiS_SModeIDTable;
80814 -       const SiS_StandTableStruct  *SiS_StandTable;
80815 +       SiS_StandTableStruct        *SiS_StandTable;
80816         const SiS_ExtStruct         *SiS_EModeIDTable;
80817         const SiS_Ext2Struct        *SiS_RefIndex;
80818         const SiS_VBModeStruct      *SiS_VBModeIDTable;
80819 @@ -316,7 +367,7 @@ typedef struct _SiS_Private
80820         const USHORT *pSiS_RGBSenseData;
80821         const USHORT *pSiS_VideoSenseData;
80822         const USHORT *pSiS_YCSenseData;
80823 -       const USHORT *pSiS_RGBSenseData2; /*301b*/
80824 +       const USHORT *pSiS_RGBSenseData2;
80825         const USHORT *pSiS_VideoSenseData2;
80826         const USHORT *pSiS_YCSenseData2;
80827  #endif
80828 @@ -340,15 +391,18 @@ typedef struct _SiS_Private
80829         const SiS_LCDDataStruct  *SiS_LCD1280x960Data;
80830         const SiS_LCDDataStruct  *SiS_NoScaleData1400x1050;
80831         const SiS_LCDDataStruct  *SiS_NoScaleData1600x1200;
80832 +       const SiS_LCDDataStruct  *SiS_NoScaleData1280x768;
80833         const SiS_LCDDataStruct  *SiS_StLCD1400x1050Data;
80834         const SiS_LCDDataStruct  *SiS_StLCD1600x1200Data;
80835 +       const SiS_LCDDataStruct  *SiS_StLCD1280x768Data;
80836         const SiS_LCDDataStruct  *SiS_ExtLCD1400x1050Data;
80837         const SiS_LCDDataStruct  *SiS_ExtLCD1600x1200Data;
80838 +       const SiS_LCDDataStruct  *SiS_ExtLCD1280x768Data;
80839 +       const SiS_LCDDataStruct  *SiS_NoScaleData;
80840         const SiS_TVDataStruct   *SiS_StPALData;
80841         const SiS_TVDataStruct   *SiS_ExtPALData;
80842         const SiS_TVDataStruct   *SiS_StNTSCData;
80843         const SiS_TVDataStruct   *SiS_ExtNTSCData;
80844 -/*     const SiS_TVDataStruct   *SiS_St1HiTVData;  */
80845         const SiS_TVDataStruct   *SiS_St2HiTVData;
80846         const SiS_TVDataStruct   *SiS_ExtHiTVData;
80847         const UCHAR *SiS_NTSCTiming;
80848 @@ -381,12 +435,19 @@ typedef struct _SiS_Private
80849         const SiS_LVDSDataStruct  *SiS_LVDS1152x768Data_1;
80850         const SiS_LVDSDataStruct  *SiS_LVDS1152x768Data_2;
80851         const SiS_LVDSDataStruct  *SiS_LVDS640x480Data_1;
80852 +       const SiS_LVDSDataStruct  *SiS_LVDS640x480Data_2;
80853         const SiS_LVDSDataStruct  *SiS_LVDS320x480Data_1;
80854         const SiS_LVDSDataStruct  *SiS_LCDA1400x1050Data_1;
80855         const SiS_LVDSDataStruct  *SiS_LCDA1400x1050Data_2;
80856         const SiS_LVDSDataStruct  *SiS_LCDA1600x1200Data_1;
80857         const SiS_LVDSDataStruct  *SiS_LCDA1600x1200Data_2;
80858         const SiS_LVDSDataStruct  *SiS_LVDSXXXxXXXData_1;
80859 +       const SiS_LVDSDataStruct  *SiS_LVDSBARCO1366Data_1;
80860 +       const SiS_LVDSDataStruct  *SiS_LVDSBARCO1366Data_2;
80861 +       const SiS_LVDSDataStruct  *SiS_LVDSBARCO1024Data_1;
80862 +       const SiS_LVDSDataStruct  *SiS_LVDSBARCO1024Data_2;
80863 +       const SiS_LVDSDataStruct  *SiS_LVDS848x480Data_1;
80864 +       const SiS_LVDSDataStruct  *SiS_LVDS848x480Data_2;
80865         const SiS_LVDSDataStruct  *SiS_CHTVUNTSCData;
80866         const SiS_LVDSDataStruct  *SiS_CHTVONTSCData;
80867         const SiS_LVDSDataStruct  *SiS_CHTVUPALData;
80868 @@ -478,6 +539,12 @@ typedef struct _SiS_Private
80869         const SiS_LVDSCRT1DataStruct  *SiS_LVDSCRT11600x1200_2_H;
80870         const SiS_LVDSCRT1DataStruct  *SiS_LVDSCRT1XXXxXXX_1;
80871         const SiS_LVDSCRT1DataStruct  *SiS_LVDSCRT1XXXxXXX_1_H;
80872 +       const SiS_LVDSCRT1DataStruct  *SiS_LVDSCRT1640x480_1;
80873 +       const SiS_LVDSCRT1DataStruct  *SiS_LVDSCRT1640x480_1_H;
80874 +       const SiS_LVDSCRT1DataStruct  *SiS_LVDSCRT1640x480_2;
80875 +       const SiS_LVDSCRT1DataStruct  *SiS_LVDSCRT1640x480_2_H;
80876 +       const SiS_LVDSCRT1DataStruct  *SiS_LVDSCRT1640x480_3;
80877 +       const SiS_LVDSCRT1DataStruct  *SiS_LVDSCRT1640x480_3_H;
80878         const SiS_LVDSCRT1DataStruct  *SiS_CHTVCRT1UNTSC;
80879         const SiS_LVDSCRT1DataStruct  *SiS_CHTVCRT1ONTSC;
80880         const SiS_LVDSCRT1DataStruct  *SiS_CHTVCRT1UPAL;
80881 @@ -507,7 +574,6 @@ typedef struct _SiS_Private
80882         const SiS_LCDACRT1DataStruct  *SiS_LCDACRT11400x1050_2_H;
80883         const SiS_LCDACRT1DataStruct  *SiS_LCDACRT11600x1200_2_H;
80884  
80885 -       /* TW: New for 650/301LV */
80886         const SiS_Part2PortTblStruct *SiS_CRT2Part2_1024x768_1;
80887         const SiS_Part2PortTblStruct *SiS_CRT2Part2_1280x1024_1;
80888         const SiS_Part2PortTblStruct *SiS_CRT2Part2_1400x1050_1;
80889 @@ -539,6 +605,9 @@ typedef struct _SiS_Private
80890         const UCHAR *SiS_CHTVVCLKUPALN;
80891         const UCHAR *SiS_CHTVVCLKOPALN;
80892         const UCHAR *SiS_CHTVVCLKSOPAL;
80893 +
80894 +       USHORT  PanelXRes;
80895 +       USHORT  PanelYRes;
80896         
80897         BOOLEAN UseCustomMode;
80898         BOOLEAN CRT1UsesCustomMode;
80899 @@ -560,8 +629,11 @@ typedef struct _SiS_Private
80900         UCHAR   CSR2B;
80901         UCHAR   CSR2C;
80902         USHORT  CSRClock;
80903 +       USHORT  CSRClock_CRT1;
80904         USHORT  CModeFlag;
80905 +       USHORT  CModeFlag_CRT1;
80906         USHORT  CInfoFlag;
80907 +
80908         BOOLEAN SiS_CHPALM;
80909         BOOLEAN SiS_CHPALN;
80910         
80911 @@ -578,7 +650,21 @@ typedef struct _SiS_Private
80912         UCHAR Backup_1c;
80913         UCHAR Backup_1d;
80914         
80915 -       int    UsePanelScaler;
80916 +       int     UsePanelScaler;
80917 +
80918 +       USHORT  CP_Vendor, CP_Product;
80919 +       BOOLEAN CP_HaveCustomData;
80920 +       int     CP_PreferredX, CP_PreferredY;
80921 +       int     CP_MaxX, CP_MaxY, CP_MaxClock;
80922 +       int     CP_HDisplay[7], CP_VDisplay[7]; /* For Custom LCD panel dimensions */
80923 +       int     CP_HTotal[7], CP_VTotal[7];
80924 +       int     CP_HSyncStart[7], CP_VSyncStart[7];
80925 +       int     CP_HSyncEnd[7], CP_VSyncEnd[7];
80926 +       int     CP_HBlankStart[7], CP_VBlankStart[7];
80927 +       int     CP_HBlankEnd[7], CP_VBlankEnd[7];
80928 +       int     CP_Clock[7];
80929 +       BOOLEAN CP_DataValid[7];
80930 +       BOOLEAN CP_HSync_P[7], CP_VSync_P[7], CP_SyncValid[7];
80931  } SiS_Private;
80932  
80933  #endif
80934 --- linux-2.6.0-test6/drivers/video/skeletonfb.c        2003-06-14 12:17:59.000000000 -0700
80935 +++ 25/drivers/video/skeletonfb.c       2003-10-05 00:34:22.000000000 -0700
80936 @@ -1,7 +1,7 @@
80937  /*
80938   * linux/drivers/video/skeletonfb.c -- Skeleton for a frame buffer device
80939   *
80940 - *  Modified to new api Jan 2001 by James Simmons (jsimmons@transvirtual.com)
80941 + *  Modified to new api Jan 2001 by James Simmons (jsimmons@infradead.org)
80942   *
80943   *  Created 28 Dec 1997 by Geert Uytterhoeven
80944   *
80945 @@ -469,15 +469,71 @@ void xxxfb_imageblit(struct fb_info *p, 
80946  int xxxfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
80947  {
80948  /*
80949 - *      @set:  Which fields we are altering in struct fb_cursor 
80950 + *      @set:   Which fields we are altering in struct fb_cursor
80951   *     @enable: Disable or enable the cursor 
80952 - *      @rop:  The bit operation we want to do. 
80953 - *      @mask:  This is the cursor mask bitmap. 
80954 - *      @dest:  A image of the area we are going to display the cursor.
80955 - *             Used internally by the driver.   
80956 - *      @hot:  The hot spot. 
80957 - *     @image: The actual data for the cursor image.
80958 - */
80959 + *      @rop:   The bit operation we want to do.
80960 + *      @hot:   The hot spot.
80961 + *     @image:  The actual data for the cursor image.
80962 + *      @mask:   This is the cursor mask bitmap.
80963 + */
80964 +
80965 +   /* Disable hardware cursor. We don't want to display the cursor
80966 +      while changing it. Note we use the enable and rop fields in
80967 +      struct fb_cursor that is apart of struct fb_info. Not the
80968 +      cursor data passed in from userland. */
80969 +
80970 +   if (cursor->set & FB_CUR_SETHOT) {
80971 +       info->cursor.hot = cursor->hot;
80972 +       /* Set the hardware cursor's hot spot  */
80973 +   }
80974 +
80975 +   if (cursor->set & FB_CUR_SETPOS) {
80976 +       info->cursor.image.dx = cursor->image.dx;
80977 +       info->cursor.image.dy = cursor->image.dy;
80978 +       /* Set the hardware cursor's position */
80979 +   }
80980 +
80981 +   if (cursor->set & FB_CUR_SETSIZE) {
80982 +       info->cursor.image.height = cursor->image.height;
80983 +       info->cursor.image.width = cursor->image.width;
80984 +       /* Set the hardware cursor's size */
80985 +   }
80986 +
80987 +   if (cursor->set & FB_CUR_SETCMAP) {
80988 +       if (cursor->image.depth == 1) {
80989 +               info->cursor.image.fg_color = cursor->image.fg_color;
80990 +               info->cursor.image.bg_color = cursor->image.bg_color;
80991 +       } else {
80992 +               if (cursor->image.cmap.len)
80993 +                       fb_copy_cmap(&cursor->image.cmap, &info->cursor.image.cmap, 0);
80994 +       }
80995 +       info->curosr.image.depth = cursor->image.depth;
80996 +
80997 +       /* Set the hardware cursor's color map */
80998 +   }
80999 +
81000 +   /*
81001 +    * Set the cursor shape. The two pieces needed to create
81002 +    * the final image is mask and image.data. The mask is
81003 +    * combined with image.data according to the rop field.
81004 +    */
81005 +   if (cursor->set & FB_CUR_SETSHAPE) {
81006 +       switch (info->cursor.rop) {
81007 +       case ROP_XOR:
81008 +               /* ... */
81009 +               break;
81010 +       case ROP_COPY:
81011 +       default:
81012 +               /* ... */
81013 +               break;
81014 +       }
81015 +       /* ... */
81016 +   }
81017 +
81018 +   if (info->cursor.enable) {
81019 +       /* Now we turn the hardware cursor on */
81020 +   }
81021 +   return 0;
81022  }
81023  
81024  /**
81025 --- linux-2.6.0-test6/drivers/video/softcursor.c        2003-06-14 12:18:22.000000000 -0700
81026 +++ 25/drivers/video/softcursor.c       2003-10-05 00:34:28.000000000 -0700
81027 @@ -21,8 +21,13 @@ int soft_cursor(struct fb_info *info, st
81028  {
81029         unsigned int scan_align = info->pixmap.scan_align - 1;
81030         unsigned int buf_align = info->pixmap.buf_align - 1;
81031 -       unsigned int i, size, dsize, s_pitch, d_pitch;
81032 -       u8 *dst, src[64];
81033 +       u8 *dst = (u8 *) info->cursor.image.data;
81034 +       unsigned int i, size, pitch;
81035 +
81036 +       pitch = ((info->cursor.image.width + 7) >> 3) + scan_align;
81037 +       pitch &= ~scan_align;
81038 +       size = pitch * info->cursor.image.height + buf_align;
81039 +       size &= ~buf_align;
81040  
81041         if (cursor->set & FB_CUR_SETSIZE) {
81042                 info->cursor.image.height = cursor->image.height;
81043 @@ -48,34 +53,33 @@ int soft_cursor(struct fb_info *info, st
81044                 info->cursor.image.depth = cursor->image.depth;
81045         }       
81046  
81047 -       s_pitch = (info->cursor.image.width + 7) >> 3;
81048 -       dsize = s_pitch * info->cursor.image.height;
81049 -       d_pitch = (s_pitch + scan_align) & ~scan_align;
81050 -       size = d_pitch * info->cursor.image.height + buf_align;
81051 -       size &= ~buf_align;
81052 -       dst = info->pixmap.addr + fb_get_buffer_offset(info, size);
81053 -
81054 -       if (info->cursor.enable) {
81055 +       if (cursor->set & FB_CUR_SETSHAPE) {
81056                 switch (info->cursor.rop) {
81057                 case ROP_XOR:
81058 -                       for (i = 0; i < dsize; i++)
81059 -                               src[i] = cursor->image.data[i] ^ info->cursor.mask[i]; 
81060 +                       for (i = 0; i < size; i++)
81061 +                               dst[i] ^= info->cursor.mask[i];
81062                         break;
81063                 case ROP_COPY:
81064                 default:
81065 -                       for (i = 0; i < dsize; i++)
81066 -                               src[i] = cursor->image.data[i] & info->cursor.mask[i];
81067 +                       for (i = 0; i < size; i++)
81068 +                               dst[i] &= info->cursor.mask[i];
81069                         break;
81070                 }
81071 -       } else 
81072 -               memcpy(src, cursor->image.data, dsize);
81073 -       
81074 -       move_buf_aligned(info, dst, src, d_pitch, s_pitch, info->cursor.image.height);
81075 -       info->cursor.image.data = dst;
81076 +       }
81077         
81078 -       info->fbops->fb_imageblit(info, &info->cursor.image);
81079 -       atomic_dec(&info->pixmap.count);
81080 -       smp_mb__after_atomic_dec();
81081 +       if (!info->cursor.enable) {
81082 +               for (i = 0; i < size; i++)
81083 +                       dst[i] ^= info->cursor.mask[i];
81084 +       }
81085 +
81086 +       if (info->cursor.image.data)
81087 +               info->fbops->fb_imageblit(info, &info->cursor.image);
81088 +
81089 +       if (!info->cursor.enable) {
81090 +               for (i = 0; i < size; i++)
81091 +                       dst[i] ^= info->cursor.mask[i];
81092 +       }
81093 +
81094         return 0;
81095  }
81096  
81097 --- linux-2.6.0-test6/drivers/video/sstfb.c     2003-08-08 22:55:13.000000000 -0700
81098 +++ 25/drivers/video/sstfb.c    2003-10-05 00:33:24.000000000 -0700
81099 @@ -94,7 +94,6 @@
81100  #include <linux/pci.h>
81101  #include <linux/delay.h>
81102  #include <linux/init.h>
81103 -#include <linux/version.h>
81104  #include <linux/slab.h>
81105  #include <asm/io.h>
81106  #include <asm/ioctl.h>
81107 --- linux-2.6.0-test6/drivers/video/stifb.c     2003-09-08 13:58:58.000000000 -0700
81108 +++ 25/drivers/video/stifb.c    2003-10-05 00:33:24.000000000 -0700
81109 @@ -1238,7 +1238,7 @@ stifb_init_fb(struct sti_struct *sti, in
81110  
81111  
81112         /* get framebuffer physical and virtual base addr & len (64bit ready) */
81113 -       fix->smem_start = fb->sti->regions_phys[1] | 0xffffffff00000000;
81114 +       fix->smem_start = F_EXTEND(fb->sti->regions_phys[1]);
81115         fix->smem_len = fb->sti->regions[1].region_desc.length * 4096;
81116  
81117         fix->line_length = (fb->sti->glob_cfg->total_x * bpp) / 8;
81118 --- linux-2.6.0-test6/drivers/video/valkyriefb.c        2003-07-27 12:14:40.000000000 -0700
81119 +++ 25/drivers/video/valkyriefb.c       2003-10-05 00:34:22.000000000 -0700
81120 @@ -51,7 +51,6 @@
81121  #include <linux/delay.h>
81122  #include <linux/interrupt.h>
81123  #include <linux/fb.h>
81124 -#include <linux/selection.h>
81125  #include <linux/init.h>
81126  #include <linux/pci.h>
81127  #include <linux/nvram.h>
81128 --- linux-2.6.0-test6/fs/adfs/super.c   2003-09-08 13:58:58.000000000 -0700
81129 +++ 25/fs/adfs/super.c  2003-10-05 00:33:24.000000000 -0700
81130 @@ -18,6 +18,7 @@
81131  #include <linux/init.h>
81132  #include <linux/buffer_head.h>
81133  #include <linux/vfs.h>
81134 +#include <linux/parser.h>
81135  
81136  #include <asm/bitops.h>
81137  #include <asm/uaccess.h>
81138 @@ -133,50 +134,56 @@ static void adfs_put_super(struct super_
81139         sb->s_fs_info = NULL;
81140  }
81141  
81142 +enum {Opt_uid, Opt_gid, Opt_ownmask, Opt_othmask, Opt_err};
81143 +
81144 +static match_table_t tokens = {
81145 +       {Opt_uid, "uid=%u"},
81146 +       {Opt_gid, "gid=%u"},
81147 +       {Opt_ownmask, "ownmask=%o"},
81148 +       {Opt_othmask, "othmask=%o"},
81149 +       {Opt_err, NULL}
81150 +};
81151 +
81152  static int parse_options(struct super_block *sb, char *options)
81153  {
81154 -       char *value, *opt;
81155 +       char *p;
81156         struct adfs_sb_info *asb = ADFS_SB(sb);
81157 +       int option;
81158  
81159         if (!options)
81160                 return 0;
81161  
81162 -       while ((opt = strsep(&options, ",")) != NULL) {
81163 -               if (!*opt)
81164 +       while ((p = strsep(&options, ",")) != NULL) {
81165 +               substring_t args[MAX_OPT_ARGS];
81166 +               int token;
81167 +               if (!*p)
81168                         continue;
81169 -               value = strchr(opt, '=');
81170 -               if (value)
81171 -                       *value++ = '\0';
81172  
81173 -               if (!strcmp(opt, "uid")) {      /* owner of all files */
81174 -                       if (!value || !*value)
81175 -                               return -EINVAL;
81176 -                       asb->s_uid = simple_strtoul(value, &value, 0);
81177 -                       if (*value)
81178 -                               return -EINVAL;
81179 -               } else
81180 -               if (!strcmp(opt, "gid")) {      /* group owner of all files */
81181 -                       if (!value || !*value)
81182 -                               return -EINVAL;
81183 -                       asb->s_gid = simple_strtoul(value, &value, 0);
81184 -                       if (*value)
81185 -                               return -EINVAL;
81186 -               } else
81187 -               if (!strcmp(opt, "ownmask")) {  /* owner permission mask */
81188 -                       if (!value || !*value)
81189 +               token = match_token(p, tokens, args);
81190 +               switch (token) {
81191 +               case Opt_uid:
81192 +                       if (match_int(args, &option))
81193                                 return -EINVAL;
81194 -                       asb->s_owner_mask = simple_strtoul(value, &value, 8);
81195 -                       if (*value)
81196 +                       asb->s_uid = option;
81197 +                       break;
81198 +               case Opt_gid:
81199 +                       if (match_int(args, &option))
81200                                 return -EINVAL;
81201 -               } else
81202 -               if (!strcmp(opt, "othmask")) {  /* others permission mask */
81203 -                       if (!value || !*value)
81204 +                       asb->s_gid = option;
81205 +                       break;
81206 +               case Opt_ownmask:
81207 +                       if (match_octal(args, &option))
81208                                 return -EINVAL;
81209 -                       asb->s_other_mask = simple_strtoul(value, &value, 8);
81210 -                       if (*value)
81211 +                       asb->s_owner_mask = option;
81212 +                       break;
81213 +               case Opt_othmask:
81214 +                       if (match_octal(args, &option))
81215                                 return -EINVAL;
81216 -               } else {                        /* eh? say again. */
81217 -                       printk("ADFS-fs: unrecognised mount option %s\n", opt);
81218 +                       asb->s_other_mask = option;
81219 +                       break;
81220 +               default:
81221 +                       printk("ADFS-fs: unrecognised mount option \"%s\" "
81222 +                                       "or missing value\n", p);
81223                         return -EINVAL;
81224                 }
81225         }
81226 --- linux-2.6.0-test6/fs/affs/file.c    2003-09-08 13:58:58.000000000 -0700
81227 +++ 25/fs/affs/file.c   2003-10-05 00:33:24.000000000 -0700
81228 @@ -39,7 +39,7 @@ static int affs_grow_extcache(struct ino
81229  static struct buffer_head *affs_alloc_extblock(struct inode *inode, struct buffer_head *bh, u32 ext);
81230  static inline struct buffer_head *affs_get_extblock(struct inode *inode, u32 ext);
81231  static struct buffer_head *affs_get_extblock_slow(struct inode *inode, u32 ext);
81232 -static ssize_t affs_file_write(struct file *filp, const char *buf, size_t count, loff_t *ppos);
81233 +static ssize_t affs_file_write(struct file *filp, const char __user *buf, size_t count, loff_t *ppos);
81234  static int affs_file_open(struct inode *inode, struct file *filp);
81235  static int affs_file_release(struct inode *inode, struct file *filp);
81236  
81237 @@ -491,7 +491,8 @@ affs_getemptyblk_ino(struct inode *inode
81238  }
81239  
81240  static ssize_t
81241 -affs_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
81242 +affs_file_write(struct file *file, const char __user *buf,
81243 +               size_t count, loff_t *ppos)
81244  {
81245         ssize_t retval;
81246  
81247 --- linux-2.6.0-test6/fs/affs/super.c   2003-06-22 12:04:44.000000000 -0700
81248 +++ 25/fs/affs/super.c  2003-10-05 00:33:24.000000000 -0700
81249 @@ -28,6 +28,7 @@
81250  #include <linux/smp_lock.h>
81251  #include <linux/buffer_head.h>
81252  #include <linux/vfs.h>
81253 +#include <linux/parser.h>
81254  #include <asm/system.h>
81255  #include <asm/uaccess.h>
81256  
81257 @@ -142,12 +143,37 @@ static struct super_operations affs_sops
81258         .remount_fs     = affs_remount,
81259  };
81260  
81261 +enum {
81262 +       Opt_bs, Opt_mode, Opt_mufs, Opt_prefix, Opt_protect,
81263 +       Opt_reserved, Opt_root, Opt_setgid, Opt_setuid,
81264 +       Opt_verbose, Opt_volume, Opt_ignore, Opt_err,
81265 +};
81266 +
81267 +static match_table_t tokens = {
81268 +       {Opt_bs, "bs=%d"},
81269 +       {Opt_mode, "mode=%o"},
81270 +       {Opt_mufs, "mufs"},
81271 +       {Opt_prefix, "prefix=%s"},
81272 +       {Opt_protect, "protect"},
81273 +       {Opt_reserved, "reserved=%d"},
81274 +       {Opt_root, "root=%d"},
81275 +       {Opt_setgid, "setgid=%d"},
81276 +       {Opt_setuid, "setuid=%d"},
81277 +       {Opt_verbose, "verbose"},
81278 +       {Opt_volume, "volume=%s"},
81279 +       {Opt_ignore, "grpquota"},
81280 +       {Opt_ignore, "noquota"},
81281 +       {Opt_ignore, "quota"},
81282 +       {Opt_ignore, "usrquota"},
81283 +       {Opt_err, NULL},
81284 +};
81285 +
81286  static int
81287  parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s32 *root,
81288                 int *blocksize, char **prefix, char *volume, unsigned long *mount_opts)
81289  {
81290 -       char    *this_char, *value, *optn;
81291 -       int      f;
81292 +       char *p;
81293 +       substring_t args[MAX_OPT_ARGS];
81294  
81295         /* Fill in defaults */
81296  
81297 @@ -161,109 +187,85 @@ parse_options(char *options, uid_t *uid,
81298         *mount_opts = 0;
81299         if (!options)
81300                 return 1;
81301 -       while ((this_char = strsep(&options, ",")) != NULL) {
81302 -               if (!*this_char)
81303 +
81304 +       while ((p = strsep(&options, ",")) != NULL) {
81305 +               int token, n, option;
81306 +               if (!*p)
81307                         continue;
81308 -               f = 0;
81309 -               if ((value = strchr(this_char,'=')) != NULL)
81310 -                       *value++ = 0;
81311 -               if ((optn = "protect") && !strcmp(this_char, optn)) {
81312 -                       if (value)
81313 -                               goto out_inv_arg;
81314 -                       *mount_opts |= SF_IMMUTABLE;
81315 -               } else if ((optn = "verbose") && !strcmp(this_char, optn)) {
81316 -                       if (value)
81317 -                               goto out_inv_arg;
81318 -                       *mount_opts |= SF_VERBOSE;
81319 -               } else if ((optn = "mufs") && !strcmp(this_char, optn)) {
81320 -                       if (value)
81321 -                               goto out_inv_arg;
81322 -                       *mount_opts |= SF_MUFS;
81323 -               } else if ((f = !strcmp(this_char,"setuid")) || !strcmp(this_char,"setgid")) {
81324 -                       if (value) {
81325 -                               if (!*value) {
81326 -                                       printk("AFFS: Argument for set[ug]id option missing\n");
81327 -                                       return 0;
81328 -                               } else {
81329 -                                       (f ? *uid : *gid) = simple_strtoul(value,&value,0);
81330 -                                       if (*value) {
81331 -                                               printk("AFFS: Bad set[ug]id argument\n");
81332 -                                               return 0;
81333 -                                       }
81334 -                                       *mount_opts |= f ? SF_SETUID : SF_SETGID;
81335 -                               }
81336 +
81337 +               token = match_token(p, tokens, args);
81338 +               switch (token) {
81339 +               case Opt_bs:
81340 +                       if (match_int(&args[0], &n))
81341 +                               return -EINVAL;
81342 +                       if (n != 512 && n != 1024 && n != 2048
81343 +                           && n != 4096) {
81344 +                               printk ("AFFS: Invalid blocksize (512, 1024, 2048, 4096 allowed)\n");
81345 +                               return 0;
81346                         }
81347 -               } else if (!strcmp(this_char,"prefix")) {
81348 -                       optn = "prefix";
81349 -                       if (!value || !*value)
81350 -                               goto out_no_arg;
81351 +                       *blocksize = n;
81352 +                       break;
81353 +               case Opt_mode:
81354 +                       if (match_octal(&args[0], &option))
81355 +                               return 1;
81356 +                       *mode = option & 0777;
81357 +                       *mount_opts |= SF_SETMODE;
81358 +                       break;
81359 +               case Opt_mufs:
81360 +                       *mount_opts |= SF_MUFS;
81361 +                       break;
81362 +               case Opt_prefix:
81363                         if (*prefix) {          /* Free any previous prefix */
81364                                 kfree(*prefix);
81365                                 *prefix = NULL;
81366                         }
81367 -                       *prefix = kmalloc(strlen(value) + 1,GFP_KERNEL);
81368 +                       *prefix = match_strdup(&args[0]);
81369                         if (!*prefix)
81370                                 return 0;
81371 -                       strcpy(*prefix,value);
81372                         *mount_opts |= SF_PREFIX;
81373 -               } else if (!strcmp(this_char,"volume")) {
81374 -                       optn = "volume";
81375 -                       if (!value || !*value)
81376 -                               goto out_no_arg;
81377 -                       strlcpy(volume,value,31);
81378 -               } else if (!strcmp(this_char,"mode")) {
81379 -                       optn = "mode";
81380 -                       if (!value || !*value)
81381 -                               goto out_no_arg;
81382 -                       *mode = simple_strtoul(value,&value,8) & 0777;
81383 -                       if (*value)
81384 -                               return 0;
81385 -                       *mount_opts |= SF_SETMODE;
81386 -               } else if (!strcmp(this_char,"reserved")) {
81387 -                       optn = "reserved";
81388 -                       if (!value || !*value)
81389 -                               goto out_no_arg;
81390 -                       *reserved = simple_strtoul(value,&value,0);
81391 -                       if (*value)
81392 -                               return 0;
81393 -               } else if (!strcmp(this_char,"root")) {
81394 -                       optn = "root";
81395 -                       if (!value || !*value)
81396 -                               goto out_no_arg;
81397 -                       *root = simple_strtoul(value,&value,0);
81398 -                       if (*value)
81399 -                               return 0;
81400 -               } else if (!strcmp(this_char,"bs")) {
81401 -                       optn = "bs";
81402 -                       if (!value || !*value)
81403 -                               goto out_no_arg;
81404 -                       *blocksize = simple_strtoul(value,&value,0);
81405 -                       if (*value)
81406 -                               return 0;
81407 -                       if (*blocksize != 512 && *blocksize != 1024 && *blocksize != 2048
81408 -                           && *blocksize != 4096) {
81409 -                               printk ("AFFS: Invalid blocksize (512, 1024, 2048, 4096 allowed)\n");
81410 -                               return 0;
81411 -                       }
81412 -               } else if (!strcmp (this_char, "grpquota")
81413 -                        || !strcmp (this_char, "noquota")
81414 -                        || !strcmp (this_char, "quota")
81415 -                        || !strcmp (this_char, "usrquota"))
81416 -                        /* Silently ignore the quota options */
81417 -                       ;
81418 -               else {
81419 -                       printk("AFFS: Unrecognized mount option %s\n", this_char);
81420 +                       break;
81421 +               case Opt_protect:
81422 +                       *mount_opts |= SF_IMMUTABLE;
81423 +                       break;
81424 +               case Opt_reserved:
81425 +                       if (match_int(&args[0], reserved))
81426 +                               return 1;
81427 +                       break;
81428 +               case Opt_root:
81429 +                       if (match_int(&args[0], root))
81430 +                               return 1;
81431 +                       break;
81432 +               case Opt_setgid:
81433 +                       if (match_int(&args[0], &option))
81434 +                               return 1;
81435 +                       *gid = option;
81436 +                       *mount_opts |= SF_SETGID;
81437 +                       break;
81438 +               case Opt_setuid:
81439 +                       if (match_int(&args[0], &option))
81440 +                               return -EINVAL;
81441 +                       *uid = option;
81442 +                       *mount_opts |= SF_SETUID;
81443 +                       break;
81444 +               case Opt_verbose:
81445 +                       *mount_opts |= SF_VERBOSE;
81446 +                       break;
81447 +               case Opt_volume: {
81448 +                       char *vol = match_strdup(&args[0]);
81449 +                       strlcpy(volume, vol, 32);
81450 +                       kfree(vol);
81451 +                       break;
81452 +               }
81453 +               case Opt_ignore:
81454 +                       /* Silently ignore the quota options */
81455 +                       break;
81456 +               default:
81457 +                       printk("AFFS: Unrecognized mount option \"%s\" "
81458 +                                       "or missing value\n", p);
81459                         return 0;
81460                 }
81461         }
81462         return 1;
81463 -
81464 -out_no_arg:
81465 -       printk("AFFS: The %s option requires an argument\n", optn);
81466 -       return 0;
81467 -out_inv_arg:
81468 -       printk("AFFS: Option %s does not take an argument\n", optn);
81469 -       return 0;
81470  }
81471  
81472  /* This function definitely needs to be split up. Some fine day I'll
81473 --- linux-2.6.0-test6/fs/aio.c  2003-09-27 18:57:46.000000000 -0700
81474 +++ 25/fs/aio.c 2003-10-05 00:37:05.000000000 -0700
81475 @@ -27,6 +27,8 @@
81476  #include <linux/aio.h>
81477  #include <linux/highmem.h>
81478  #include <linux/workqueue.h>
81479 +#include <linux/writeback.h>
81480 +#include <linux/pagemap.h>
81481  
81482  #include <asm/kmap_types.h>
81483  #include <asm/uaccess.h>
81484 @@ -38,6 +40,9 @@
81485  #define dprintk(x...)  do { ; } while (0)
81486  #endif
81487  
81488 +long aio_run = 0; /* for testing only */
81489 +long aio_wakeups = 0; /* for testing only */
81490 +
81491  /*------ sysctl variables----*/
81492  atomic_t aio_nr = ATOMIC_INIT(0);      /* current system wide number of aio requests */
81493  unsigned aio_max_nr = 0x10000; /* system wide maximum number of aio requests */
81494 @@ -47,6 +52,7 @@ static kmem_cache_t   *kiocb_cachep;
81495  static kmem_cache_t    *kioctx_cachep;
81496  
81497  static struct workqueue_struct *aio_wq;
81498 +static struct workqueue_struct *aio_fput_wq;
81499  
81500  /* Used for rare fput completion. */
81501  static void aio_fput_routine(void *);
81502 @@ -74,6 +80,7 @@ static int __init aio_setup(void)
81503                 panic("unable to create kioctx cache");
81504  
81505         aio_wq = create_workqueue("aio");
81506 +       aio_fput_wq = create_workqueue("aio_fput");
81507  
81508         pr_debug("aio_setup: sizeof(struct page) = %d\n", (int)sizeof(struct page));
81509  
81510 @@ -281,6 +288,7 @@ static void aio_cancel_all(struct kioctx
81511                 struct kiocb *iocb = list_kiocb(pos);
81512                 list_del_init(&iocb->ki_list);
81513                 cancel = iocb->ki_cancel;
81514 +               kiocbSetCancelled(iocb);
81515                 if (cancel) {
81516                         iocb->ki_users++;
81517                         spin_unlock_irq(&ctx->ctx_lock);
81518 @@ -341,6 +349,11 @@ void exit_aio(struct mm_struct *mm)
81519                 aio_cancel_all(ctx);
81520  
81521                 wait_for_all_aios(ctx);
81522 +               /*
81523 +                * this is an overkill, but ensures we don't leave
81524 +                * the ctx on the aio_wq
81525 +                */
81526 +               flush_workqueue(aio_wq);
81527  
81528                 if (1 != atomic_read(&ctx->users))
81529                         printk(KERN_DEBUG
81530 @@ -395,6 +408,7 @@ static struct kiocb *__aio_get_req(struc
81531         req->ki_cancel = NULL;
81532         req->ki_retry = NULL;
81533         req->ki_user_obj = NULL;
81534 +       INIT_LIST_HEAD(&req->ki_run_list);
81535  
81536         /* Check if the completion queue has enough free space to
81537          * accept an event from this io.
81538 @@ -494,7 +508,7 @@ static int __aio_put_req(struct kioctx *
81539                 spin_lock(&fput_lock);
81540                 list_add(&req->ki_list, &fput_head);
81541                 spin_unlock(&fput_lock);
81542 -               queue_work(aio_wq, &fput_work);
81543 +               queue_work(aio_fput_wq, &fput_work);
81544         } else
81545                 really_put_req(ctx, req);
81546         return 1;
81547 @@ -536,65 +550,307 @@ struct kioctx *lookup_ioctx(unsigned lon
81548         return ioctx;
81549  }
81550  
81551 +/*
81552 + * use_mm
81553 + *     Makes the calling kernel thread take on the specified
81554 + *     mm context.
81555 + *     Called by the retry thread execute retries within the
81556 + *     iocb issuer's mm context, so that copy_from/to_user
81557 + *     operations work seamlessly for aio.
81558 + *     (Note: this routine is intended to be called only
81559 + *     from a kernel thread context)
81560 + */
81561  static void use_mm(struct mm_struct *mm)
81562  {
81563 -       struct mm_struct *active_mm = current->active_mm;
81564 +       struct mm_struct *active_mm;
81565 +       struct task_struct *tsk = current;
81566 +
81567 +       task_lock(tsk);
81568 +       active_mm = tsk->active_mm;
81569         atomic_inc(&mm->mm_count);
81570 -       current->mm = mm;
81571 -       if (mm != active_mm) {
81572 -               current->active_mm = mm;
81573 -               activate_mm(active_mm, mm);
81574 -       }
81575 +       tsk->mm = mm;
81576 +       tsk->active_mm = mm;
81577 +       activate_mm(active_mm, mm);
81578 +       task_unlock(tsk);
81579 +
81580         mmdrop(active_mm);
81581  }
81582  
81583 -static void unuse_mm(struct mm_struct *mm)
81584 +/*
81585 + * unuse_mm
81586 + *     Reverses the effect of use_mm, i.e. releases the
81587 + *     specified mm context which was earlier taken on
81588 + *     by the calling kernel thread
81589 + *     (Note: this routine is intended to be called only
81590 + *     from a kernel thread context)
81591 + *
81592 + * Comments: Called with ctx->ctx_lock held. This nests
81593 + * task_lock instead ctx_lock.
81594 + */
81595 +void unuse_mm(struct mm_struct *mm)
81596  {
81597 -       current->mm = NULL;
81598 +       struct task_struct *tsk = current;
81599 +
81600 +       task_lock(tsk);
81601 +       tsk->mm = NULL;
81602         /* active_mm is still 'mm' */
81603 -       enter_lazy_tlb(mm, current);
81604 +       enter_lazy_tlb(mm, tsk);
81605 +       task_unlock(tsk);
81606  }
81607  
81608 -/* Run on kevent's context.  FIXME: needs to be per-cpu and warn if an
81609 - * operation blocks.
81610 +/*
81611 + * Queue up a kiocb to be retried. Assumes that the kiocb
81612 + * has already been marked as kicked, and places it on
81613 + * the retry run list for the corresponding ioctx, if it
81614 + * isn't already queued. Returns 1 if it actually queued
81615 + * the kiocb (to tell the caller to activate the work
81616 + * queue to process it), or 0, if it found that it was
81617 + * already queued.
81618 + *
81619 + * Should be called with the spin lock iocb->ki_ctx->ctx_lock
81620 + * held
81621   */
81622 -static void aio_kick_handler(void *data)
81623 +static inline int __queue_kicked_iocb(struct kiocb *iocb)
81624  {
81625 -       struct kioctx *ctx = data;
81626 +       struct kioctx   *ctx = iocb->ki_ctx;
81627  
81628 -       use_mm(ctx->mm);
81629 +       if (list_empty(&iocb->ki_run_list)) {
81630 +               list_add_tail(&iocb->ki_run_list,
81631 +                       &ctx->run_list);
81632 +               iocb->ki_queued++;
81633 +               return 1;
81634 +       }
81635 +       return 0;
81636 +}
81637  
81638 -       spin_lock_irq(&ctx->ctx_lock);
81639 -       while (!list_empty(&ctx->run_list)) {
81640 -               struct kiocb *iocb;
81641 -               long ret;
81642 +/* aio_run_iocb
81643 + *      This is the core aio execution routine. It is
81644 + *      invoked both for initial i/o submission and
81645 + *      subsequent retries via the aio_kick_handler.
81646 + *       Expects to be invoked with iocb->ki_ctx->lock
81647 + *       already held. The lock is released and reaquired
81648 + *       as needed during processing.
81649 + *
81650 + * Calls the iocb retry method (already setup for the
81651 + * iocb on initial submission) for operation specific
81652 + * handling, but takes care of most of common retry
81653 + * execution details for a given iocb. The retry method
81654 + * needs to be non-blocking as far as possible, to avoid
81655 + * holding up other iocbs waiting to be serviced by the
81656 + * retry kernel thread.
81657 + *
81658 + * The trickier parts in this code have to do with
81659 + * ensuring that only one retry instance is in progress
81660 + * for a given iocb at any time. Providing that guarantee
81661 + * simplifies the coding of individual aio operations as
81662 + * it avoids various potential races.
81663 + */
81664 +static ssize_t aio_run_iocb(struct kiocb *iocb)
81665 +{
81666 +       struct kioctx   *ctx = iocb->ki_ctx;
81667 +       ssize_t (*retry)(struct kiocb *);
81668 +       ssize_t ret;
81669  
81670 -               iocb = list_entry(ctx->run_list.next, struct kiocb,
81671 -                                 ki_run_list);
81672 -               list_del(&iocb->ki_run_list);
81673 -               iocb->ki_users ++;
81674 -               spin_unlock_irq(&ctx->ctx_lock);
81675 +       if (iocb->ki_retried++ > 1024*1024) {
81676 +               printk("Maximal retry count.  Bytes done %Zd\n",
81677 +                       iocb->ki_nbytes - iocb->ki_left);
81678 +               return -EAGAIN;
81679 +       }
81680 +
81681 +       if (!(iocb->ki_retried & 0xff)) {
81682 +               pr_debug("%ld retry: %d of %d (kick %ld, Q %ld run %ld, wake %ld)\n",
81683 +                       iocb->ki_retried,
81684 +                       iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes,
81685 +                       iocb->ki_kicked, iocb->ki_queued, aio_run, aio_wakeups);
81686 +       }
81687 +
81688 +       if (!(retry = iocb->ki_retry)) {
81689 +               printk("aio_run_iocb: iocb->ki_retry = NULL\n");
81690 +               return 0;
81691 +       }
81692 +
81693 +       /*
81694 +        * We don't want the next retry iteration for this
81695 +        * operation to start until this one has returned and
81696 +        * updated the iocb state. However, wait_queue functions
81697 +        * can trigger a kick_iocb from interrupt context in the
81698 +        * meantime, indicating that data is available for the next
81699 +        * iteration. We want to remember that and enable the
81700 +        * next retry iteration _after_ we are through with
81701 +        * this one.
81702 +        *
81703 +        * So, in order to be able to register a "kick", but
81704 +        * prevent it from being queued now, we clear the kick
81705 +        * flag, but make the kick code *think* that the iocb is
81706 +        * still on the run list until we are actually done.
81707 +        * When we are done with this iteration, we check if
81708 +        * the iocb was kicked in the meantime and if so, queue
81709 +        * it up afresh.
81710 +        */
81711 +
81712 +       kiocbClearKicked(iocb);
81713 +
81714 +       /*
81715 +        * This is so that aio_complete knows it doesn't need to
81716 +        * pull the iocb off the run list (We can't just call
81717 +        * INIT_LIST_HEAD because we don't want a kick_iocb to
81718 +        * queue this on the run list yet)
81719 +        */
81720 +       iocb->ki_run_list.next = iocb->ki_run_list.prev = NULL;
81721 +       iocb->ki_retry = NULL;
81722 +       spin_unlock_irq(&ctx->ctx_lock);
81723 +
81724 +       /* Quit retrying if the i/o has been cancelled */
81725 +       if (kiocbIsCancelled(iocb)) {
81726 +               ret = -EINTR;
81727 +               aio_complete(iocb, ret, 0);
81728 +               /* must not access the iocb after this */
81729 +               goto out;
81730 +       }
81731 +
81732 +       /*
81733 +        * Now we are all set to call the retry method in async
81734 +        * context. By setting this thread's io_wait context
81735 +        * to point to the wait queue entry inside the currently
81736 +        * running iocb for the duration of the retry, we ensure
81737 +        * that async notification wakeups are queued by the
81738 +        * operation instead of blocking waits, and when notified,
81739 +        * cause the iocb to be kicked for continuation (through
81740 +        * the aio_wake_function callback).
81741 +        */
81742 +       BUG_ON(current->io_wait != NULL);
81743 +       current->io_wait = &iocb->ki_wait;
81744 +       ret = retry(iocb);
81745 +       current->io_wait = NULL;
81746  
81747 -               kiocbClearKicked(iocb);
81748 -               ret = iocb->ki_retry(iocb);
81749 +       if (-EIOCBRETRY != ret) {
81750                 if (-EIOCBQUEUED != ret) {
81751 +                       BUG_ON(!list_empty(&iocb->ki_wait.task_list));
81752                         aio_complete(iocb, ret, 0);
81753 -                       iocb = NULL;
81754 +                       /* must not access the iocb after this */
81755                 }
81756 +       } else {
81757 +               /*
81758 +                * Issue an additional retry to avoid waiting forever if
81759 +                * no waits were queued (e.g. in case of a short read).
81760 +                */
81761 +               if (list_empty(&iocb->ki_wait.task_list))
81762 +                       kiocbSetKicked(iocb);
81763 +       }
81764 +out:
81765 +       spin_lock_irq(&ctx->ctx_lock);
81766  
81767 -               spin_lock_irq(&ctx->ctx_lock);
81768 -               if (NULL != iocb)
81769 -                       __aio_put_req(ctx, iocb);
81770 +       if (-EIOCBRETRY == ret) {
81771 +               /*
81772 +                * OK, now that we are done with this iteration
81773 +                * and know that there is more left to go,
81774 +                * this is where we let go so that a subsequent
81775 +                * "kick" can start the next iteration
81776 +                */
81777 +               iocb->ki_retry = retry;
81778 +               /* will make __queue_kicked_iocb succeed from here on */
81779 +               INIT_LIST_HEAD(&iocb->ki_run_list);
81780 +               /* we must queue the next iteration ourselves, if it
81781 +                * has already been kicked */
81782 +               if (kiocbIsKicked(iocb)) {
81783 +                       __queue_kicked_iocb(iocb);
81784 +               }
81785         }
81786 +       return ret;
81787 +}
81788 +
81789 +/*
81790 + * __aio_run_iocbs:
81791 + *     Process all pending retries queued on the ioctx
81792 + *     run list.
81793 + * Assumes it is operating within the aio issuer's mm
81794 + * context. Expects to be called with ctx->ctx_lock held
81795 + */
81796 +static void __aio_run_iocbs(struct kioctx *ctx)
81797 +{
81798 +       struct kiocb *iocb;
81799 +       int count = 0;
81800 +
81801 +       while (!list_empty(&ctx->run_list)) {
81802 +               iocb = list_entry(ctx->run_list.next, struct kiocb,
81803 +                       ki_run_list);
81804 +               list_del(&iocb->ki_run_list);
81805 +               /*
81806 +                * Hold an extra reference while retrying i/o.
81807 +                */
81808 +               iocb->ki_users++;       /* grab extra reference */
81809 +               aio_run_iocb(iocb);
81810 +               if (__aio_put_req(ctx, iocb))  /* drop extra ref */
81811 +                       put_ioctx(ctx);
81812 +               count++;
81813 +       }
81814 +       aio_run++;
81815 +}
81816 +
81817 +/*
81818 + * aio_run_iocbs:
81819 + *     Process all pending retries queued on the ioctx
81820 + *     run list.
81821 + * Assumes it is operating within the aio issuer's mm
81822 + * context.
81823 + */
81824 +static inline void aio_run_iocbs(struct kioctx *ctx)
81825 +{
81826 +       spin_lock_irq(&ctx->ctx_lock);
81827 +       __aio_run_iocbs(ctx);
81828         spin_unlock_irq(&ctx->ctx_lock);
81829 +}
81830 +
81831 +/*
81832 + * aio_kick_handler:
81833 + *     Work queue handler triggered to process pending
81834 + *     retries on an ioctx. Takes on the aio issuer's
81835 + *     mm context before running the iocbs.
81836 + * Run on aiod's context.
81837 + */
81838 +static void aio_kick_handler(void *data)
81839 +{
81840 +       struct kioctx *ctx = data;
81841  
81842 +       use_mm(ctx->mm);
81843 +       spin_lock_irq(&ctx->ctx_lock);
81844 +       __aio_run_iocbs(ctx);
81845         unuse_mm(ctx->mm);
81846 +       spin_unlock_irq(&ctx->ctx_lock);
81847  }
81848  
81849 -void kick_iocb(struct kiocb *iocb)
81850 +
81851 +/*
81852 + * Called by kick_iocb to queue the kiocb for retry
81853 + * and if required activate the aio work queue to process
81854 + * it
81855 + */
81856 +void queue_kicked_iocb(struct kiocb *iocb)
81857  {
81858         struct kioctx   *ctx = iocb->ki_ctx;
81859 +       unsigned long flags;
81860 +       int run = 0;
81861  
81862 +       WARN_ON((!list_empty(&iocb->ki_wait.task_list)));
81863 +
81864 +       spin_lock_irqsave(&ctx->ctx_lock, flags);
81865 +       run = __queue_kicked_iocb(iocb);
81866 +       spin_unlock_irqrestore(&ctx->ctx_lock, flags);
81867 +       if (run) {
81868 +               queue_work(aio_wq, &ctx->wq);
81869 +               aio_wakeups++;
81870 +       }
81871 +}
81872 +
81873 +/*
81874 + * kick_iocb:
81875 + *     Called typically from a wait queue callback context
81876 + *     (aio_wake_function) to trigger a retry of the iocb.
81877 + *     The retry is usually executed by aio workqueue
81878 + *     threads (See aio_kick_handler).
81879 + */
81880 +void kick_iocb(struct kiocb *iocb)
81881 +{
81882         /* sync iocbs are easy: they can only ever be executing from a 
81883          * single context. */
81884         if (is_sync_kiocb(iocb)) {
81885 @@ -603,12 +859,10 @@ void kick_iocb(struct kiocb *iocb)
81886                 return;
81887         }
81888  
81889 +       iocb->ki_kicked++;
81890 +       /* If its already kicked we shouldn't queue it again */
81891         if (!kiocbTryKick(iocb)) {
81892 -               unsigned long flags;
81893 -               spin_lock_irqsave(&ctx->ctx_lock, flags);
81894 -               list_add_tail(&iocb->ki_run_list, &ctx->run_list);
81895 -               spin_unlock_irqrestore(&ctx->ctx_lock, flags);
81896 -               schedule_work(&ctx->wq);
81897 +               queue_kicked_iocb(iocb);
81898         }
81899  }
81900  
81901 @@ -661,6 +915,9 @@ int aio_complete(struct kiocb *iocb, lon
81902          */
81903         spin_lock_irqsave(&ctx->ctx_lock, flags);
81904  
81905 +       if (iocb->ki_run_list.prev && !list_empty(&iocb->ki_run_list))
81906 +               list_del_init(&iocb->ki_run_list);
81907 +
81908         ring = kmap_atomic(info->ring_pages[0], KM_IRQ1);
81909  
81910         tail = info->tail;
81911 @@ -689,6 +946,11 @@ int aio_complete(struct kiocb *iocb, lon
81912  
81913         pr_debug("added to ring %p at [%lu]\n", iocb, tail);
81914  
81915 +       pr_debug("%ld retries: %d of %d (kicked %ld, Q %ld run %ld wake %ld)\n",
81916 +               iocb->ki_retried,
81917 +               iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes,
81918 +               iocb->ki_kicked, iocb->ki_queued, aio_run, aio_wakeups);
81919 +
81920         /* everything turned out well, dispose of the aiocb. */
81921         ret = __aio_put_req(ctx, iocb);
81922  
81923 @@ -803,6 +1065,7 @@ static int read_events(struct kioctx *ct
81924         int                     i = 0;
81925         struct io_event         ent;
81926         struct timeout          to;
81927 +       int                     event_loop = 0; /* testing only */
81928  
81929         /* needed to zero any padding within an entry (there shouldn't be 
81930          * any, but C is fun!
81931 @@ -852,7 +1115,6 @@ static int read_events(struct kioctx *ct
81932                 add_wait_queue_exclusive(&ctx->wait, &wait);
81933                 do {
81934                         set_task_state(tsk, TASK_INTERRUPTIBLE);
81935 -
81936                         ret = aio_read_evt(ctx, &ent);
81937                         if (ret)
81938                                 break;
81939 @@ -862,6 +1124,7 @@ static int read_events(struct kioctx *ct
81940                         if (to.timed_out)       /* Only check after read evt */
81941                                 break;
81942                         schedule();
81943 +                       event_loop++;
81944                         if (signal_pending(tsk)) {
81945                                 ret = -EINTR;
81946                                 break;
81947 @@ -889,6 +1152,9 @@ static int read_events(struct kioctx *ct
81948         if (timeout)
81949                 clear_timeout(&to);
81950  out:
81951 +       pr_debug("event loop executed %d times\n", event_loop);
81952 +       pr_debug("aio_run %ld\n", aio_run);
81953 +       pr_debug("aio_wakeups %ld\n", aio_wakeups);
81954         return i ? i : ret;
81955  }
81956  
81957 @@ -918,6 +1184,11 @@ static void io_destroy(struct kioctx *io
81958  
81959         aio_cancel_all(ioctx);
81960         wait_for_all_aios(ioctx);
81961 +       /*
81962 +        * this is an overkill, but ensures we don't leave
81963 +        * the ctx on the aio_wq
81964 +        */
81965 +       flush_workqueue(aio_wq);
81966         put_ioctx(ioctx);       /* once for the lookup */
81967  }
81968  
81969 @@ -980,13 +1251,192 @@ asmlinkage long sys_io_destroy(aio_conte
81970         return -EINVAL;
81971  }
81972  
81973 +/*
81974 + * Retry method for aio_read (also used for first time submit)
81975 + * Responsible for updating iocb state as retries progress
81976 + */
81977 +static ssize_t aio_pread(struct kiocb *iocb)
81978 +{
81979 +       struct file *file = iocb->ki_filp;
81980 +       ssize_t ret = 0;
81981 +
81982 +       ret = file->f_op->aio_read(iocb, iocb->ki_buf,
81983 +               iocb->ki_left, iocb->ki_pos);
81984 +
81985 +       /*
81986 +        * Can't just depend on iocb->ki_left to determine
81987 +        * whether we are done. This may have been a short read.
81988 +        */
81989 +       if (ret > 0) {
81990 +               iocb->ki_buf += ret;
81991 +               iocb->ki_left -= ret;
81992 +
81993 +               ret = -EIOCBRETRY;
81994 +       }
81995 +
81996 +       /* This means we must have transferred all that we could */
81997 +       /* No need to retry anymore */
81998 +       if ((ret == 0) || (iocb->ki_left == 0))
81999 +               ret = iocb->ki_nbytes - iocb->ki_left;
82000 +
82001 +       return ret;
82002 +}
82003 +
82004 +/*
82005 + * Retry method for aio_write (also used for first time submit)
82006 + * Responsible for updating iocb state as retries progress
82007 + */
82008 +static ssize_t aio_pwrite(struct kiocb *iocb)
82009 +{
82010 +       struct file *file = iocb->ki_filp;
82011 +       struct address_space *mapping = file->f_mapping;
82012 +       struct inode *inode = mapping->host;
82013 +       ssize_t ret = 0;
82014 +
82015 +       ret = file->f_op->aio_write(iocb, iocb->ki_buf,
82016 +                               iocb->ki_left, iocb->ki_pos);
82017 +
82018 +       /*
82019 +        * Even if iocb->ki_left = 0, we may need to wait
82020 +        * for a balance_dirty_pages to complete
82021 +        */
82022 +       if (ret > 0) {
82023 +               iocb->ki_buf += iocb->ki_buf ? ret : 0;
82024 +               iocb->ki_left -= ret;
82025 +
82026 +               ret = -EIOCBRETRY;
82027 +       }
82028 +
82029 +       /* This means we must have transferred all that we could */
82030 +       /* No need to retry anymore unless we need to osync data */
82031 +       if (ret == 0) {
82032 +               ret = iocb->ki_nbytes - iocb->ki_left;
82033 +               if (!iocb->ki_buf)
82034 +                       return ret;
82035 +
82036 +               /* Set things up for potential O_SYNC */
82037 +               if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
82038 +                       iocb->ki_buf = NULL;
82039 +                       iocb->ki_pos -= ret; /* back up fpos */
82040 +                       iocb->ki_left = ret; /* sync what we have written out */
82041 +                       iocb->ki_nbytes = ret;
82042 +                       ret = -EIOCBRETRY;
82043 +               }
82044 +       }
82045 +
82046 +       return ret;
82047 +}
82048 +
82049 +static ssize_t aio_fdsync(struct kiocb *iocb)
82050 +{
82051 +       struct file *file = iocb->ki_filp;
82052 +       ssize_t ret = -EINVAL;
82053 +
82054 +       if (file->f_op->aio_fsync)
82055 +               ret = file->f_op->aio_fsync(iocb, 1);
82056 +       return ret;
82057 +}
82058 +
82059 +static ssize_t aio_fsync(struct kiocb *iocb)
82060 +{
82061 +       struct file *file = iocb->ki_filp;
82062 +       ssize_t ret = -EINVAL;
82063 +
82064 +       if (file->f_op->aio_fsync)
82065 +               ret = file->f_op->aio_fsync(iocb, 0);
82066 +       return ret;
82067 +}
82068 +
82069 +/*
82070 + * aio_setup_iocb:
82071 + *     Performs the initial checks and aio retry method
82072 + *     setup for the kiocb at the time of io submission.
82073 + */
82074 +ssize_t aio_setup_iocb(struct kiocb *kiocb)
82075 +{
82076 +       struct file *file = kiocb->ki_filp;
82077 +       ssize_t ret = 0;
82078 +
82079 +       switch (kiocb->ki_opcode) {
82080 +       case IOCB_CMD_PREAD:
82081 +               ret = -EBADF;
82082 +               if (unlikely(!(file->f_mode & FMODE_READ)))
82083 +                       break;
82084 +               ret = -EFAULT;
82085 +               if (unlikely(!access_ok(VERIFY_WRITE, kiocb->ki_buf,
82086 +                       kiocb->ki_left)))
82087 +                       break;
82088 +               ret = -EINVAL;
82089 +               if (file->f_op->aio_read)
82090 +                       kiocb->ki_retry = aio_pread;
82091 +               break;
82092 +       case IOCB_CMD_PWRITE:
82093 +               ret = -EBADF;
82094 +               if (unlikely(!(file->f_mode & FMODE_WRITE)))
82095 +                       break;
82096 +               ret = -EFAULT;
82097 +               if (unlikely(!access_ok(VERIFY_READ, kiocb->ki_buf,
82098 +                       kiocb->ki_left)))
82099 +                       break;
82100 +               ret = -EINVAL;
82101 +               if (file->f_op->aio_write)
82102 +                       kiocb->ki_retry = aio_pwrite;
82103 +               break;
82104 +       case IOCB_CMD_FDSYNC:
82105 +               ret = -EINVAL;
82106 +               if (file->f_op->aio_fsync)
82107 +                       kiocb->ki_retry = aio_fdsync;
82108 +               break;
82109 +       case IOCB_CMD_FSYNC:
82110 +               ret = -EINVAL;
82111 +               if (file->f_op->aio_fsync)
82112 +                       kiocb->ki_retry = aio_fsync;
82113 +               break;
82114 +       default:
82115 +               dprintk("EINVAL: io_submit: no operation provided\n");
82116 +               ret = -EINVAL;
82117 +       }
82118 +
82119 +       if (!kiocb->ki_retry)
82120 +               return ret;
82121 +
82122 +       return 0;
82123 +}
82124 +
82125 +/*
82126 + * aio_wake_function:
82127 + *     wait queue callback function for aio notification,
82128 + *     Simply triggers a retry of the operation via kick_iocb.
82129 + *
82130 + *     This callback is specified in the wait queue entry in
82131 + *     a kiocb (current->io_wait points to this wait queue
82132 + *     entry when an aio operation executes; it is used
82133 + *     instead of a synchronous wait when an i/o blocking
82134 + *     condition is encountered during aio).
82135 + *
82136 + * Note:
82137 + * This routine is executed with the wait queue lock held.
82138 + * Since kick_iocb acquires iocb->ctx->ctx_lock, it nests
82139 + * the ioctx lock inside the wait queue lock. This is safe
82140 + * because this callback isn't used for wait queues which
82141 + * are nested inside ioctx lock (i.e. ctx->wait)
82142 + */
82143 +int aio_wake_function(wait_queue_t *wait, unsigned mode, int sync)
82144 +{
82145 +       struct kiocb *iocb = container_of(wait, struct kiocb, ki_wait);
82146 +
82147 +       list_del_init(&wait->task_list);
82148 +       kick_iocb(iocb);
82149 +       return 1;
82150 +}
82151 +
82152  int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
82153                          struct iocb *iocb)
82154  {
82155         struct kiocb *req;
82156         struct file *file;
82157         ssize_t ret;
82158 -       char *buf;
82159 +       int need_putctx;
82160  
82161         /* enforce forwards compatibility on users */
82162         if (unlikely(iocb->aio_reserved1 || iocb->aio_reserved2 ||
82163 @@ -1027,51 +1477,41 @@ int io_submit_one(struct kioctx *ctx, st
82164         req->ki_user_data = iocb->aio_data;
82165         req->ki_pos = iocb->aio_offset;
82166  
82167 -       buf = (char *)(unsigned long)iocb->aio_buf;
82168 +       req->ki_buf = (char *)(unsigned long)iocb->aio_buf;
82169 +       req->ki_left = req->ki_nbytes = iocb->aio_nbytes;
82170 +       req->ki_opcode = iocb->aio_lio_opcode;
82171 +       init_waitqueue_func_entry(&req->ki_wait, aio_wake_function);
82172 +       INIT_LIST_HEAD(&req->ki_wait.task_list);
82173 +       req->ki_run_list.next = req->ki_run_list.prev = NULL;
82174 +       req->ki_retry = NULL;
82175 +       req->ki_retried = 0;
82176 +       req->ki_kicked = 0;
82177 +       req->ki_queued = 0;
82178 +       aio_run = 0;
82179 +       aio_wakeups = 0;
82180  
82181 -       switch (iocb->aio_lio_opcode) {
82182 -       case IOCB_CMD_PREAD:
82183 -               ret = -EBADF;
82184 -               if (unlikely(!(file->f_mode & FMODE_READ)))
82185 -                       goto out_put_req;
82186 -               ret = -EFAULT;
82187 -               if (unlikely(!access_ok(VERIFY_WRITE, buf, iocb->aio_nbytes)))
82188 -                       goto out_put_req;
82189 -               ret = -EINVAL;
82190 -               if (file->f_op->aio_read)
82191 -                       ret = file->f_op->aio_read(req, buf,
82192 -                                       iocb->aio_nbytes, req->ki_pos);
82193 -               break;
82194 -       case IOCB_CMD_PWRITE:
82195 -               ret = -EBADF;
82196 -               if (unlikely(!(file->f_mode & FMODE_WRITE)))
82197 -                       goto out_put_req;
82198 -               ret = -EFAULT;
82199 -               if (unlikely(!access_ok(VERIFY_READ, buf, iocb->aio_nbytes)))
82200 -                       goto out_put_req;
82201 -               ret = -EINVAL;
82202 -               if (file->f_op->aio_write)
82203 -                       ret = file->f_op->aio_write(req, buf,
82204 -                                       iocb->aio_nbytes, req->ki_pos);
82205 -               break;
82206 -       case IOCB_CMD_FDSYNC:
82207 -               ret = -EINVAL;
82208 -               if (file->f_op->aio_fsync)
82209 -                       ret = file->f_op->aio_fsync(req, 1);
82210 -               break;
82211 -       case IOCB_CMD_FSYNC:
82212 -               ret = -EINVAL;
82213 -               if (file->f_op->aio_fsync)
82214 -                       ret = file->f_op->aio_fsync(req, 0);
82215 -               break;
82216 -       default:
82217 -               dprintk("EINVAL: io_submit: no operation provided\n");
82218 -               ret = -EINVAL;
82219 -       }
82220 +       ret = aio_setup_iocb(req);
82221 +
82222 +       if (ret)
82223 +               goto out_put_req;
82224 +
82225 +       spin_lock_irq(&ctx->ctx_lock);
82226 +       /*
82227 +        * Hold an extra reference while submitting the i/o.
82228 +        * This prevents races between the aio code path referencing the
82229 +        * req (after submitting it) and aio_complete() freeing the req.
82230 +        */
82231 +       req->ki_users++;                        /* grab extra reference */
82232 +       ret = aio_run_iocb(req);
82233 +       need_putctx = __aio_put_req(ctx, req);  /* drop the extra reference */
82234 +       spin_unlock_irq(&ctx->ctx_lock);
82235 +
82236 +       if (-EIOCBRETRY == ret)
82237 +               queue_work(aio_wq, &ctx->wq);
82238 +
82239 +       if (need_putctx)
82240 +               put_ioctx(ctx);
82241  
82242 -       if (likely(-EIOCBQUEUED == ret))
82243 -               return 0;
82244 -       aio_complete(req, ret, 0);
82245         return 0;
82246  
82247  out_put_req:
82248 --- linux-2.6.0-test6/fs/autofs4/inode.c        2003-09-27 18:57:46.000000000 -0700
82249 +++ 25/fs/autofs4/inode.c       2003-10-05 00:33:24.000000000 -0700
82250 @@ -14,6 +14,7 @@
82251  #include <linux/slab.h>
82252  #include <linux/file.h>
82253  #include <linux/pagemap.h>
82254 +#include <linux/parser.h>
82255  #include <asm/bitops.h>
82256  #include "autofs_i.h"
82257  #include <linux/module.h>
82258 @@ -94,11 +95,25 @@ static struct super_operations autofs4_s
82259         .statfs         = simple_statfs,
82260  };
82261  
82262 +enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto};
82263 +
82264 +static match_table_t tokens = {
82265 +       {Opt_fd, "fd=%d"},
82266 +       {Opt_uid, "uid=%d"},
82267 +       {Opt_gid, "gid=%d"},
82268 +       {Opt_pgrp, "pgrp=%d"},
82269 +       {Opt_minproto, "minproto=%d"},
82270 +       {Opt_maxproto, "maxproto=%d"},
82271 +       {Opt_err, NULL}
82272 +};
82273 +
82274  static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid,
82275                          pid_t *pgrp, int *minproto, int *maxproto)
82276  {
82277 -       char *this_char, *value;
82278 -       
82279 +       char *p;
82280 +       substring_t args[MAX_OPT_ARGS];
82281 +       int option;
82282 +
82283         *uid = current->uid;
82284         *gid = current->gid;
82285         *pgrp = process_group(current);
82286 @@ -108,55 +123,48 @@ static int parse_options(char *options, 
82287  
82288         *pipefd = -1;
82289  
82290 -       if ( !options ) return 1;
82291 -       while ((this_char = strsep(&options,",")) != NULL) {
82292 -               if (!*this_char)
82293 +       if (!options)
82294 +               return 1;
82295 +
82296 +       while ((p = strsep(&options, ",")) != NULL) {
82297 +               int token;
82298 +               if (!*p)
82299                         continue;
82300 -               if ((value = strchr(this_char,'=')) != NULL)
82301 -                       *value++ = 0;
82302 -               if (!strcmp(this_char,"fd")) {
82303 -                       if (!value || !*value)
82304 -                               return 1;
82305 -                       *pipefd = simple_strtoul(value,&value,0);
82306 -                       if (*value)
82307 -                               return 1;
82308 -               }
82309 -               else if (!strcmp(this_char,"uid")) {
82310 -                       if (!value || !*value)
82311 -                               return 1;
82312 -                       *uid = simple_strtoul(value,&value,0);
82313 -                       if (*value)
82314 -                               return 1;
82315 -               }
82316 -               else if (!strcmp(this_char,"gid")) {
82317 -                       if (!value || !*value)
82318 -                               return 1;
82319 -                       *gid = simple_strtoul(value,&value,0);
82320 -                       if (*value)
82321 -                               return 1;
82322 -               }
82323 -               else if (!strcmp(this_char,"pgrp")) {
82324 -                       if (!value || !*value)
82325 -                               return 1;
82326 -                       *pgrp = simple_strtoul(value,&value,0);
82327 -                       if (*value)
82328 -                               return 1;
82329 -               }
82330 -               else if (!strcmp(this_char,"minproto")) {
82331 -                       if (!value || !*value)
82332 -                               return 1;
82333 -                       *minproto = simple_strtoul(value,&value,0);
82334 -                       if (*value)
82335 -                               return 1;
82336 -               }
82337 -               else if (!strcmp(this_char,"maxproto")) {
82338 -                       if (!value || !*value)
82339 -                               return 1;
82340 -                       *maxproto = simple_strtoul(value,&value,0);
82341 -                       if (*value)
82342 -                               return 1;
82343 +
82344 +               token = match_token(p, tokens, args);
82345 +               switch (token) {
82346 +               case Opt_fd:
82347 +                       if (match_int(args, pipefd))
82348 +                               return 1;
82349 +                       break;
82350 +               case Opt_uid:
82351 +                       if (match_int(args, &option))
82352 +                               return 1;
82353 +                       *uid = option;
82354 +                       break;
82355 +               case Opt_gid:
82356 +                       if (match_int(args, &option))
82357 +                               return 1;
82358 +                       *gid = option;
82359 +                       break;
82360 +               case Opt_pgrp:
82361 +                       if (match_int(args, &option))
82362 +                               return 1;
82363 +                       *pgrp = option;
82364 +                       break;
82365 +               case Opt_minproto:
82366 +                       if (match_int(args, &option))
82367 +                               return 1;
82368 +                       *minproto = option;
82369 +                       break;
82370 +               case Opt_maxproto:
82371 +                       if (match_int(args, &option))
82372 +                               return 1;
82373 +                       *maxproto = option;
82374 +                       break;
82375 +               default:
82376 +                       return 1;
82377                 }
82378 -               else break;
82379         }
82380         return (*pipefd < 0);
82381  }
82382 --- linux-2.6.0-test6/fs/autofs/inode.c 2003-09-27 18:57:46.000000000 -0700
82383 +++ 25/fs/autofs/inode.c        2003-10-05 00:33:24.000000000 -0700
82384 @@ -14,6 +14,7 @@
82385  #include <linux/mm.h>
82386  #include <linux/slab.h>
82387  #include <linux/file.h>
82388 +#include <linux/parser.h>
82389  #include <asm/bitops.h>
82390  #include "autofs_i.h"
82391  #include <linux/module.h>
82392 @@ -45,10 +46,24 @@ static struct super_operations autofs_so
82393         .statfs         = simple_statfs,
82394  };
82395  
82396 +enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto};
82397 +
82398 +static match_table_t autofs_tokens = {
82399 +       {Opt_fd, "fd=%d"},
82400 +       {Opt_uid, "uid=%d"},
82401 +       {Opt_gid, "gid=%d"},
82402 +       {Opt_pgrp, "pgrp=%d"},
82403 +       {Opt_minproto, "minproto=%d"},
82404 +       {Opt_maxproto, "maxproto=%d"},
82405 +       {Opt_err, NULL}
82406 +};
82407 +
82408  static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid, pid_t *pgrp, int *minproto, int *maxproto)
82409  {
82410 -       char *this_char, *value;
82411 -       
82412 +       char *p;
82413 +       substring_t args[MAX_OPT_ARGS];
82414 +       int option;
82415 +
82416         *uid = current->uid;
82417         *gid = current->gid;
82418         *pgrp = process_group(current);
82419 @@ -57,55 +72,49 @@ static int parse_options(char *options, 
82420  
82421         *pipefd = -1;
82422  
82423 -       if ( !options ) return 1;
82424 -       while ((this_char = strsep(&options,",")) != NULL) {
82425 -               if (!*this_char)
82426 +       if (!options)
82427 +               return 1;
82428 +
82429 +       while ((p = strsep(&options, ",")) != NULL) {
82430 +               int token;
82431 +               if (!*p)
82432                         continue;
82433 -               if ((value = strchr(this_char,'=')) != NULL)
82434 -                       *value++ = 0;
82435 -               if (!strcmp(this_char,"fd")) {
82436 -                       if (!value || !*value)
82437 -                               return 1;
82438 -                       *pipefd = simple_strtoul(value,&value,0);
82439 -                       if (*value)
82440 -                               return 1;
82441 -               }
82442 -               else if (!strcmp(this_char,"uid")) {
82443 -                       if (!value || !*value)
82444 -                               return 1;
82445 -                       *uid = simple_strtoul(value,&value,0);
82446 -                       if (*value)
82447 -                               return 1;
82448 -               }
82449 -               else if (!strcmp(this_char,"gid")) {
82450 -                       if (!value || !*value)
82451 -                               return 1;
82452 -                       *gid = simple_strtoul(value,&value,0);
82453 -                       if (*value)
82454 -                               return 1;
82455 -               }
82456 -               else if (!strcmp(this_char,"pgrp")) {
82457 -                       if (!value || !*value)
82458 -                               return 1;
82459 -                       *pgrp = simple_strtoul(value,&value,0);
82460 -                       if (*value)
82461 -                               return 1;
82462 -               }
82463 -               else if (!strcmp(this_char,"minproto")) {
82464 -                       if (!value || !*value)
82465 -                               return 1;
82466 -                       *minproto = simple_strtoul(value,&value,0);
82467 -                       if (*value)
82468 -                               return 1;
82469 -               }
82470 -               else if (!strcmp(this_char,"maxproto")) {
82471 -                       if (!value || !*value)
82472 -                               return 1;
82473 -                       *maxproto = simple_strtoul(value,&value,0);
82474 -                       if (*value)
82475 -                               return 1;
82476 +
82477 +               token = match_token(p, autofs_tokens, args);
82478 +               switch (token) {
82479 +               case Opt_fd:
82480 +                       if (match_int(&args[0], &option))
82481 +                               return 1;
82482 +                       *pipefd = option;
82483 +                       break;
82484 +               case Opt_uid:
82485 +                       if (match_int(&args[0], &option))
82486 +                               return 1;
82487 +                       *uid = option;
82488 +                       break;
82489 +               case Opt_gid:
82490 +                       if (match_int(&args[0], &option))
82491 +                               return 1;
82492 +                       *gid = option;
82493 +                       break;
82494 +               case Opt_pgrp:
82495 +                       if (match_int(&args[0], &option))
82496 +                               return 1;
82497 +                       *pgrp = option;
82498 +                       break;
82499 +               case Opt_minproto:
82500 +                       if (match_int(&args[0], &option))
82501 +                               return 1;
82502 +                       *minproto = option;
82503 +                       break;
82504 +               case Opt_maxproto:
82505 +                       if (match_int(&args[0], &option))
82506 +                               return 1;
82507 +                       *maxproto = option;
82508 +                       break;
82509 +               default:
82510 +                       return 1;
82511                 }
82512 -               else break;
82513         }
82514         return (*pipefd < 0);
82515  }
82516 --- linux-2.6.0-test6/fs/befs/linuxvfs.c        2003-07-10 18:50:31.000000000 -0700
82517 +++ 25/fs/befs/linuxvfs.c       2003-10-05 00:33:24.000000000 -0700
82518 @@ -13,6 +13,7 @@
82519  #include <linux/nls.h>
82520  #include <linux/buffer_head.h>
82521  #include <linux/vfs.h>
82522 +#include <linux/parser.h>
82523  
82524  #include "befs.h"
82525  #include "btree.h"
82526 @@ -39,7 +40,7 @@ static struct inode *befs_alloc_inode(st
82527  static void befs_destroy_inode(struct inode *inode);
82528  static int befs_init_inodecache(void);
82529  static void befs_destroy_inodecache(void);
82530 -static int befs_readlink(struct dentry *, char *, int);
82531 +static int befs_readlink(struct dentry *, char __user *, int);
82532  static int befs_follow_link(struct dentry *, struct nameidata *nd);
82533  static int befs_utf2nls(struct super_block *sb, const char *in, int in_len,
82534                         char **out, int *out_len);
82535 @@ -494,7 +495,7 @@ befs_follow_link(struct dentry *dentry, 
82536  }
82537  
82538  static int
82539 -befs_readlink(struct dentry *dentry, char *buffer, int buflen)
82540 +befs_readlink(struct dentry *dentry, char __user *buffer, int buflen)
82541  {
82542         struct super_block *sb = dentry->d_sb;
82543         befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
82544 @@ -667,12 +668,27 @@ befs_nls2utf(struct super_block *sb, con
82545         return -EILSEQ;
82546  }
82547  
82548 +/**
82549 + * Use the
82550 + *
82551 + */
82552 +enum {
82553 +       Opt_uid, Opt_gid, Opt_charset, Opt_debug,
82554 +};
82555 +
82556 +static match_table_t befs_tokens = {
82557 +       {Opt_uid, "uid=%d"},
82558 +       {Opt_gid, "gid=%d"},
82559 +       {Opt_charset, "iocharset=%s"},
82560 +       {Opt_debug, "debug"}
82561 +};
82562 +
82563  static int
82564  parse_options(char *options, befs_mount_options * opts)
82565  {
82566 -       char *this_char;
82567 -       char *value;
82568 -       int ret = 1;
82569 +       char *p;
82570 +       substring_t args[MAX_OPT_ARGS];
82571 +       int option;
82572  
82573         /* Initialize options */
82574         opts->uid = 0;
82575 @@ -683,64 +699,56 @@ parse_options(char *options, befs_mount_
82576         opts->debug = 0;
82577  
82578         if (!options)
82579 -               return ret;
82580 -
82581 -       while ((this_char = strsep(&options, ",")) != NULL) {
82582 -
82583 -               if ((value = strchr(this_char, '=')) != NULL)
82584 -                       *value++ = 0;
82585 +               return 1;
82586  
82587 -               if (!strcmp(this_char, "uid")) {
82588 -                       if (!value || !*value) {
82589 -                               ret = 0;
82590 -                       } else {
82591 -                               opts->uid = simple_strtoul(value, &value, 0);
82592 -                               opts->use_uid = 1;
82593 -                               if (*value) {
82594 -                                       printk(KERN_ERR "BEFS: Invalid uid "
82595 -                                              "option: %s\n", value);
82596 -                                       ret = 0;
82597 -                               }
82598 +       while ((p = strsep(&options, ",")) != NULL) {
82599 +               int token;
82600 +               if (!*p)
82601 +                       continue;
82602 +
82603 +               token = match_token(p, befs_tokens, args);
82604 +               switch (token) {
82605 +               case Opt_uid:
82606 +                       if (match_int(&args[0], &option))
82607 +                               return 0;
82608 +                       if (option < 0) {
82609 +                               printk(KERN_ERR "BeFS: Invalid uid %d, "
82610 +                                               "using default\n", option);
82611 +                               break;
82612                         }
82613 -               } else if (!strcmp(this_char, "gid")) {
82614 -                       if (!value || !*value)
82615 -                               ret = 0;
82616 -                       else {
82617 -                               opts->gid = simple_strtoul(value, &value, 0);
82618 -                               opts->use_gid = 1;
82619 -                               if (*value) {
82620 -                                       printk(KERN_ERR
82621 -                                              "BEFS: Invalid gid option: "
82622 -                                              "%s\n", value);
82623 -                                       ret = 0;
82624 -                               }
82625 +                       opts->uid = option;
82626 +                       opts->use_uid = 1;
82627 +                       break;
82628 +               case Opt_gid:
82629 +                       if (match_int(&args[0], &option))
82630 +                               return 0;
82631 +                       if (option < 0) {
82632 +                               printk(KERN_ERR "BeFS: Invalid gid %d, "
82633 +                                               "using default\n", option);
82634 +                               break;
82635                         }
82636 -               } else if (!strcmp(this_char, "iocharset") && value) {
82637 -                       char *p = value;
82638 -                       int len;
82639 -
82640 -                       while (*value && *value != ',')
82641 -                               value++;
82642 -                       len = value - p;
82643 -                       if (len) {
82644 -                               char *buffer = kmalloc(len + 1, GFP_NOFS);
82645 -                               if (buffer) {
82646 -                                       opts->iocharset = buffer;
82647 -                                       memcpy(buffer, p, len);
82648 -                                       buffer[len] = 0;
82649 -
82650 -                               } else {
82651 -                                       printk(KERN_ERR "BEFS: "
82652 -                                              "cannot allocate memory\n");
82653 -                                       ret = 0;
82654 -                               }
82655 +                       opts->gid = option;
82656 +                       opts->use_gid = 1;
82657 +                       break;
82658 +               case Opt_charset:
82659 +                       kfree(opts->iocharset);
82660 +                       opts->iocharset = match_strdup(&args[0]);
82661 +                       if (!opts->iocharset) {
82662 +                               printk(KERN_ERR "BeFS: allocation failure for "
82663 +                                               "iocharset string\n");
82664 +                               return 0;
82665                         }
82666 -               } else if (!strcmp(this_char, "debug")) {
82667 +                       break;
82668 +               case Opt_debug:
82669                         opts->debug = 1;
82670 +                       break;
82671 +               default:
82672 +                       printk(KERN_ERR "BeFS: Unrecognized mount option \"%s\" "
82673 +                                       "or missing value\n", p);
82674 +                       return 0;
82675                 }
82676         }
82677 -
82678 -       return ret;
82679 +       return 1;
82680  }
82681  
82682  /* This function has the responsibiltiy of getting the
82683 @@ -939,9 +947,19 @@ init_befs_fs(void)
82684  
82685         err = befs_init_inodecache();
82686         if (err)
82687 -               return err;
82688 +               goto unaquire_none;
82689 +
82690 +       err = register_filesystem(&befs_fs_type);
82691 +       if (err)
82692 +               goto unaquire_inodecache;
82693 +
82694 +       return 0;
82695 +
82696 +unaquire_inodecache:
82697 +       befs_destroy_inodecache();
82698  
82699 -       return register_filesystem(&befs_fs_type);
82700 +unaquire_none:
82701 +       return err;
82702  }
82703  
82704  static void __exit
82705 --- linux-2.6.0-test6/fs/binfmt_elf.c   2003-09-27 18:57:46.000000000 -0700
82706 +++ 25/fs/binfmt_elf.c  2003-10-05 00:36:15.000000000 -0700
82707 @@ -134,7 +134,7 @@ create_elf_tables(struct linux_binprm *b
82708         elf_addr_t *sp, *u_platform;
82709         const char *k_platform = ELF_PLATFORM;
82710         int items;
82711 -       elf_addr_t elf_info[40];
82712 +       elf_addr_t *elf_info;
82713         int ei_index = 0;
82714         struct task_struct *tsk = current;
82715  
82716 @@ -169,6 +169,7 @@ create_elf_tables(struct linux_binprm *b
82717         }
82718  
82719         /* Create the ELF interpreter info */
82720 +       elf_info = (elf_addr_t *) current->mm->saved_auxv;
82721  #define NEW_AUX_ENT(id, val) \
82722         do { elf_info[ei_index++] = id; elf_info[ei_index++] = val; } while (0)
82723  
82724 @@ -196,8 +197,13 @@ create_elf_tables(struct linux_binprm *b
82725         if (k_platform) {
82726                 NEW_AUX_ENT(AT_PLATFORM, (elf_addr_t)(long)u_platform);
82727         }
82728 -       NEW_AUX_ENT(AT_NULL, 0);
82729  #undef NEW_AUX_ENT
82730 +       /* AT_NULL is zero; clear the rest too */
82731 +       memset(&elf_info[ei_index], 0,
82732 +              sizeof current->mm->saved_auxv - ei_index * sizeof elf_info[0]);
82733 +
82734 +       /* And advance past the AT_NULL entry.  */
82735 +       ei_index += 2;
82736  
82737         sp = STACK_ADD(p, ei_index);
82738  
82739 @@ -1078,7 +1084,7 @@ static void fill_prstatus(struct elf_prs
82740         prstatus->pr_pid = p->pid;
82741         prstatus->pr_ppid = p->parent->pid;
82742         prstatus->pr_pgrp = process_group(p);
82743 -       prstatus->pr_sid = p->session;
82744 +       prstatus->pr_sid = process_session(p);
82745         jiffies_to_timeval(p->utime, &prstatus->pr_utime);
82746         jiffies_to_timeval(p->stime, &prstatus->pr_stime);
82747         jiffies_to_timeval(p->cutime, &prstatus->pr_cutime);
82748 @@ -1106,7 +1112,7 @@ static void fill_psinfo(struct elf_prpsi
82749         psinfo->pr_pid = p->pid;
82750         psinfo->pr_ppid = p->parent->pid;
82751         psinfo->pr_pgrp = process_group(p);
82752 -       psinfo->pr_sid = p->session;
82753 +       psinfo->pr_sid = process_session(p);
82754  
82755         i = p->state ? ffz(~p->state) + 1 : 0;
82756         psinfo->pr_state = i;
82757 @@ -1186,7 +1192,7 @@ static int elf_dump_thread_status(long s
82758   */
82759  static int elf_core_dump(long signr, struct pt_regs * regs, struct file * file)
82760  {
82761 -#define        NUM_NOTES       5
82762 +#define        NUM_NOTES       6
82763         int has_dumped = 0;
82764         mm_segment_t fs;
82765         int segs;
82766 @@ -1196,7 +1202,7 @@ static int elf_core_dump(long signr, str
82767         struct elfhdr *elf = NULL;
82768         off_t offset = 0, dataoff;
82769         unsigned long limit = current->rlim[RLIMIT_CORE].rlim_cur;
82770 -       int numnote = NUM_NOTES;
82771 +       int numnote;
82772         struct memelfnote *notes = NULL;
82773         struct elf_prstatus *prstatus = NULL;   /* NT_PRSTATUS */
82774         struct elf_prpsinfo *psinfo = NULL;     /* NT_PRPSINFO */
82775 @@ -1208,6 +1214,7 @@ static int elf_core_dump(long signr, str
82776         elf_fpxregset_t *xfpu = NULL;
82777  #endif
82778         int thread_status_size = 0;
82779 +       elf_addr_t *auxv;
82780  
82781         /*
82782          * We no longer stop all VM operations.
82783 @@ -1287,18 +1294,25 @@ static int elf_core_dump(long signr, str
82784         
82785         fill_note(notes +2, "CORE", NT_TASKSTRUCT, sizeof(*current), current);
82786    
82787 +       numnote = 3;
82788 +
82789 +       auxv = (elf_addr_t *) current->mm->saved_auxv;
82790 +
82791 +       i = 0;
82792 +       do
82793 +               i += 2;
82794 +       while (auxv[i - 2] != AT_NULL);
82795 +       fill_note(&notes[numnote++], "CORE", NT_AUXV,
82796 +                 i * sizeof (elf_addr_t), auxv);
82797 +
82798         /* Try to dump the FPU. */
82799         if ((prstatus->pr_fpvalid = elf_core_copy_task_fpregs(current, regs, fpu)))
82800 -               fill_note(notes +3, "CORE", NT_PRFPREG, sizeof(*fpu), fpu);
82801 -       else
82802 -               --numnote;
82803 +               fill_note(notes + numnote++,
82804 +                         "CORE", NT_PRFPREG, sizeof(*fpu), fpu);
82805  #ifdef ELF_CORE_COPY_XFPREGS
82806         if (elf_core_copy_task_xfpregs(current, xfpu))
82807 -               fill_note(notes +4, "LINUX", NT_PRXFPREG, sizeof(*xfpu), xfpu);
82808 -       else
82809 -               --numnote;
82810 -#else
82811 -       numnote--;
82812 +               fill_note(notes + numnote++,
82813 +                         "LINUX", NT_PRXFPREG, sizeof(*xfpu), xfpu);
82814  #endif 
82815    
82816         fs = get_fs();
82817 --- linux-2.6.0-test6/fs/block_dev.c    2003-09-08 13:58:58.000000000 -0700
82818 +++ 25/fs/block_dev.c   2003-10-05 00:34:12.000000000 -0700
82819 @@ -25,6 +25,22 @@
82820  #include <linux/namei.h>
82821  #include <asm/uaccess.h>
82822  
82823 +struct bdev_inode {
82824 +       struct block_device bdev;
82825 +       struct inode vfs_inode;
82826 +};
82827 +
82828 +static inline struct bdev_inode *BDEV_I(struct inode *inode)
82829 +{
82830 +       return container_of(inode, struct bdev_inode, vfs_inode);
82831 +}
82832 +
82833 +inline struct block_device *I_BDEV(struct inode *inode)
82834 +{
82835 +       return &BDEV_I(inode)->bdev;
82836 +}
82837 +
82838 +EXPORT_SYMBOL(I_BDEV);
82839  
82840  static sector_t max_block(struct block_device *bdev)
82841  {
82842 @@ -70,6 +86,8 @@ int set_blocksize(struct block_device *b
82843         return 0;
82844  }
82845  
82846 +EXPORT_SYMBOL(set_blocksize);
82847 +
82848  int sb_set_blocksize(struct super_block *sb, int size)
82849  {
82850         int bits;
82851 @@ -82,6 +100,8 @@ int sb_set_blocksize(struct super_block 
82852         return sb->s_blocksize;
82853  }
82854  
82855 +EXPORT_SYMBOL(sb_set_blocksize);
82856 +
82857  int sb_min_blocksize(struct super_block *sb, int size)
82858  {
82859         int minsize = bdev_hardsect_size(sb->s_bdev);
82860 @@ -90,14 +110,16 @@ int sb_min_blocksize(struct super_block 
82861         return sb_set_blocksize(sb, size);
82862  }
82863  
82864 +EXPORT_SYMBOL(sb_min_blocksize);
82865 +
82866  static int
82867  blkdev_get_block(struct inode *inode, sector_t iblock,
82868                 struct buffer_head *bh, int create)
82869  {
82870 -       if (iblock >= max_block(inode->i_bdev))
82871 +       if (iblock >= max_block(I_BDEV(inode)))
82872                 return -EIO;
82873  
82874 -       bh->b_bdev = inode->i_bdev;
82875 +       bh->b_bdev = I_BDEV(inode);
82876         bh->b_blocknr = iblock;
82877         set_buffer_mapped(bh);
82878         return 0;
82879 @@ -107,10 +129,10 @@ static int
82880  blkdev_get_blocks(struct inode *inode, sector_t iblock,
82881                 unsigned long max_blocks, struct buffer_head *bh, int create)
82882  {
82883 -       if ((iblock + max_blocks) > max_block(inode->i_bdev))
82884 +       if ((iblock + max_blocks) > max_block(I_BDEV(inode)))
82885                 return -EIO;
82886  
82887 -       bh->b_bdev = inode->i_bdev;
82888 +       bh->b_bdev = I_BDEV(inode);
82889         bh->b_blocknr = iblock;
82890         bh->b_size = max_blocks << inode->i_blkbits;
82891         set_buffer_mapped(bh);
82892 @@ -122,9 +144,9 @@ blkdev_direct_IO(int rw, struct kiocb *i
82893                         loff_t offset, unsigned long nr_segs)
82894  {
82895         struct file *file = iocb->ki_filp;
82896 -       struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
82897 +       struct inode *inode = file->f_mapping->host;
82898  
82899 -       return blockdev_direct_IO(rw, iocb, inode, inode->i_bdev, iov, offset,
82900 +       return blockdev_direct_IO(rw, iocb, inode, I_BDEV(inode), iov, offset,
82901                                 nr_segs, blkdev_get_blocks, NULL);
82902  }
82903  
82904 @@ -155,11 +177,10 @@ static int blkdev_commit_write(struct fi
82905   */
82906  static loff_t block_llseek(struct file *file, loff_t offset, int origin)
82907  {
82908 -       struct inode *bd_inode;
82909 +       struct inode *bd_inode = file->f_mapping->host;
82910         loff_t size;
82911         loff_t retval;
82912  
82913 -       bd_inode = file->f_dentry->d_inode->i_bdev->bd_inode;
82914         down(&bd_inode->i_sem);
82915         size = i_size_read(bd_inode);
82916  
82917 @@ -182,15 +203,13 @@ static loff_t block_llseek(struct file *
82918  }
82919         
82920  /*
82921 - *     Filp may be NULL when we are called by an msync of a vma
82922 - *     since the vma has no handle.
82923 + *     Filp is never NULL; the only case when ->fsync() is called with
82924 + *     NULL first argument is nfsd_sync_dir() and that's not a directory.
82925   */
82926   
82927  static int block_fsync(struct file *filp, struct dentry *dentry, int datasync)
82928  {
82929 -       struct inode * inode = dentry->d_inode;
82930 -
82931 -       return sync_blockdev(inode->i_bdev);
82932 +       return sync_blockdev(I_BDEV(filp->f_mapping->host));
82933  }
82934  
82935  /*
82936 @@ -200,16 +219,6 @@ static int block_fsync(struct file *filp
82937  static spinlock_t bdev_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
82938  static kmem_cache_t * bdev_cachep;
82939  
82940 -struct bdev_inode {
82941 -       struct block_device bdev;
82942 -       struct inode vfs_inode;
82943 -};
82944 -
82945 -static inline struct bdev_inode *BDEV_I(struct inode *inode)
82946 -{
82947 -       return container_of(inode, struct bdev_inode, vfs_inode);
82948 -}
82949 -
82950  static struct inode *bdev_alloc_inode(struct super_block *sb)
82951  {
82952         struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, SLAB_KERNEL);
82953 @@ -243,7 +252,6 @@ static inline void __bd_forget(struct in
82954  {
82955         list_del_init(&inode->i_devices);
82956         inode->i_bdev = NULL;
82957 -       inode->i_mapping = &inode->i_data;
82958  }
82959  
82960  static void bdev_clear_inode(struct inode *inode)
82961 @@ -358,6 +366,8 @@ struct block_device *bdget(dev_t dev)
82962         return bdev;
82963  }
82964  
82965 +EXPORT_SYMBOL(bdget);
82966 +
82967  long nr_blockdev_pages(void)
82968  {
82969         struct list_head *p;
82970 @@ -376,27 +386,29 @@ void bdput(struct block_device *bdev)
82971  {
82972         iput(bdev->bd_inode);
82973  }
82974 +
82975 +EXPORT_SYMBOL(bdput);
82976   
82977 -int bd_acquire(struct inode *inode)
82978 +static struct block_device *bd_acquire(struct inode *inode)
82979  {
82980         struct block_device *bdev;
82981         spin_lock(&bdev_lock);
82982 -       if (inode->i_bdev && igrab(inode->i_bdev->bd_inode)) {
82983 +       bdev = inode->i_bdev;
82984 +       if (bdev && igrab(bdev->bd_inode)) {
82985                 spin_unlock(&bdev_lock);
82986 -               return 0;
82987 +               return bdev;
82988         }
82989         spin_unlock(&bdev_lock);
82990         bdev = bdget(inode->i_rdev);
82991 -       if (!bdev)
82992 -               return -ENOMEM;
82993 -       spin_lock(&bdev_lock);
82994 -       if (inode->i_bdev)
82995 -               __bd_forget(inode);
82996 -       inode->i_bdev = bdev;
82997 -       inode->i_mapping = bdev->bd_inode->i_mapping;
82998 -       list_add(&inode->i_devices, &bdev->bd_inodes);
82999 -       spin_unlock(&bdev_lock);
83000 -       return 0;
83001 +       if (bdev) {
83002 +               spin_lock(&bdev_lock);
83003 +               if (inode->i_bdev)
83004 +                       __bd_forget(inode);
83005 +               inode->i_bdev = bdev;
83006 +               list_add(&inode->i_devices, &bdev->bd_inodes);
83007 +               spin_unlock(&bdev_lock);
83008 +       }
83009 +       return bdev;
83010  }
83011  
83012  /* Call when you free inode */
83013 @@ -444,6 +456,8 @@ int bd_claim(struct block_device *bdev, 
83014         return res;
83015  }
83016  
83017 +EXPORT_SYMBOL(bd_claim);
83018 +
83019  void bd_release(struct block_device *bdev)
83020  {
83021         spin_lock(&bdev_lock);
83022 @@ -454,6 +468,8 @@ void bd_release(struct block_device *bde
83023         spin_unlock(&bdev_lock);
83024  }
83025  
83026 +EXPORT_SYMBOL(bd_release);
83027 +
83028  /*
83029   * Tries to open block device by device number.  Use it ONLY if you
83030   * really do not have anything better - i.e. when you are behind a
83031 @@ -471,6 +487,8 @@ struct block_device *open_by_devnum(dev_
83032         return err ? ERR_PTR(err) : bdev;
83033  }
83034  
83035 +EXPORT_SYMBOL(open_by_devnum);
83036 +
83037  /*
83038   * This routine checks whether a removable media has been changed,
83039   * and invalidates all buffer-cache-entries in that case. This
83040 @@ -500,6 +518,8 @@ int check_disk_change(struct block_devic
83041         return 1;
83042  }
83043  
83044 +EXPORT_SYMBOL(check_disk_change);
83045 +
83046  static void bd_set_size(struct block_device *bdev, loff_t size)
83047  {
83048         unsigned bsize = bdev_hardsect_size(bdev);
83049 @@ -513,13 +533,14 @@ static void bd_set_size(struct block_dev
83050         bdev->bd_inode->i_blkbits = blksize_bits(bsize);
83051  }
83052  
83053 -static int do_open(struct block_device *bdev, struct inode *inode, struct file *file)
83054 +static int do_open(struct block_device *bdev, struct file *file)
83055  {
83056         struct module *owner = NULL;
83057         struct gendisk *disk;
83058         int ret = -ENXIO;
83059         int part;
83060  
83061 +       file->f_mapping = bdev->bd_inode->i_mapping;
83062         lock_kernel();
83063         disk = get_gendisk(bdev->bd_dev, &part);
83064         if (!disk) {
83065 @@ -536,7 +557,7 @@ static int do_open(struct block_device *
83066                 if (!part) {
83067                         struct backing_dev_info *bdi;
83068                         if (disk->fops->open) {
83069 -                               ret = disk->fops->open(inode, file);
83070 +                               ret = disk->fops->open(bdev, file);
83071                                 if (ret)
83072                                         goto out_first;
83073                         }
83074 @@ -581,7 +602,7 @@ static int do_open(struct block_device *
83075                 module_put(owner);
83076                 if (bdev->bd_contains == bdev) {
83077                         if (bdev->bd_disk->fops->open) {
83078 -                               ret = bdev->bd_disk->fops->open(inode, file);
83079 +                               ret = bdev->bd_disk->fops->open(bdev, file);
83080                                 if (ret)
83081                                         goto out;
83082                         }
83083 @@ -629,9 +650,11 @@ int blkdev_get(struct block_device *bdev
83084         fake_file.f_dentry = &fake_dentry;
83085         fake_dentry.d_inode = bdev->bd_inode;
83086  
83087 -       return do_open(bdev, bdev->bd_inode, &fake_file);
83088 +       return do_open(bdev, &fake_file);
83089  }
83090  
83091 +EXPORT_SYMBOL(blkdev_get);
83092 +
83093  int blkdev_open(struct inode * inode, struct file * filp)
83094  {
83095         struct block_device *bdev;
83096 @@ -645,10 +668,9 @@ int blkdev_open(struct inode * inode, st
83097          */
83098         filp->f_flags |= O_LARGEFILE;
83099  
83100 -       bd_acquire(inode);
83101 -       bdev = inode->i_bdev;
83102 +       bdev = bd_acquire(inode);
83103  
83104 -       res = do_open(bdev, inode, filp);
83105 +       res = do_open(bdev, filp);
83106         if (res)
83107                 return res;
83108  
83109 @@ -662,10 +684,11 @@ int blkdev_open(struct inode * inode, st
83110         return res;
83111  }
83112  
83113 +EXPORT_SYMBOL(blkdev_open);
83114 +
83115  int blkdev_put(struct block_device *bdev, int kind)
83116  {
83117         int ret = 0;
83118 -       struct inode *bd_inode = bdev->bd_inode;
83119         struct gendisk *disk = bdev->bd_disk;
83120  
83121         down(&bdev->bd_sem);
83122 @@ -674,14 +697,14 @@ int blkdev_put(struct block_device *bdev
83123                 switch (kind) {
83124                 case BDEV_FILE:
83125                 case BDEV_FS:
83126 -                       sync_blockdev(bd_inode->i_bdev);
83127 +                       sync_blockdev(bdev);
83128                         break;
83129                 }
83130                 kill_bdev(bdev);
83131         }
83132         if (bdev->bd_contains == bdev) {
83133                 if (disk->fops->release)
83134 -                       ret = disk->fops->release(bd_inode, NULL);
83135 +                       ret = disk->fops->release(disk);
83136         } else {
83137                 down(&bdev->bd_contains->bd_sem);
83138                 bdev->bd_contains->bd_part_count--;
83139 @@ -710,11 +733,14 @@ int blkdev_put(struct block_device *bdev
83140         return ret;
83141  }
83142  
83143 -int blkdev_close(struct inode * inode, struct file * filp)
83144 +EXPORT_SYMBOL(blkdev_put);
83145 +
83146 +static int blkdev_close(struct inode * inode, struct file * filp)
83147  {
83148 -       if (inode->i_bdev->bd_holder == filp)
83149 -               bd_release(inode->i_bdev);
83150 -       return blkdev_put(inode->i_bdev, BDEV_FILE);
83151 +       struct block_device *bdev = I_BDEV(filp->f_mapping->host);
83152 +       if (bdev->bd_holder == filp)
83153 +               bd_release(bdev);
83154 +       return blkdev_put(bdev, BDEV_FILE);
83155  }
83156  
83157  static ssize_t blkdev_file_write(struct file *file, const char __user *buf,
83158 @@ -733,6 +759,11 @@ static ssize_t blkdev_file_aio_write(str
83159         return generic_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos);
83160  }
83161  
83162 +static int block_ioctl(struct inode *inode, struct file *file, unsigned cmd,
83163 +                       unsigned long arg)
83164 +{
83165 +       return blkdev_ioctl(I_BDEV(file->f_mapping->host), file, cmd, arg);
83166 +}
83167  
83168  struct address_space_operations def_blk_aops = {
83169         .readpage       = blkdev_readpage,
83170 @@ -754,22 +785,26 @@ struct file_operations def_blk_fops = {
83171         .aio_write      = blkdev_file_aio_write, 
83172         .mmap           = generic_file_mmap,
83173         .fsync          = block_fsync,
83174 -       .ioctl          = blkdev_ioctl,
83175 +       .ioctl          = block_ioctl,
83176         .readv          = generic_file_readv,
83177         .writev         = generic_file_writev,
83178         .sendfile       = generic_file_sendfile,
83179  };
83180  
83181 +EXPORT_SYMBOL(def_blk_fops);
83182 +
83183  int ioctl_by_bdev(struct block_device *bdev, unsigned cmd, unsigned long arg)
83184  {
83185         int res;
83186         mm_segment_t old_fs = get_fs();
83187         set_fs(KERNEL_DS);
83188 -       res = blkdev_ioctl(bdev->bd_inode, NULL, cmd, arg);
83189 +       res = blkdev_ioctl(bdev, NULL, cmd, arg);
83190         set_fs(old_fs);
83191         return res;
83192  }
83193  
83194 +EXPORT_SYMBOL(ioctl_by_bdev);
83195 +
83196  /**
83197   * lookup_bdev  - lookup a struct block_device by name
83198   *
83199 @@ -800,11 +835,10 @@ struct block_device *lookup_bdev(const c
83200         error = -EACCES;
83201         if (nd.mnt->mnt_flags & MNT_NODEV)
83202                 goto fail;
83203 -       error = bd_acquire(inode);
83204 -       if (error)
83205 +       error = -ENOMEM;
83206 +       bdev = bd_acquire(inode);
83207 +       if (!bdev)
83208                 goto fail;
83209 -       bdev = inode->i_bdev;
83210 -
83211  out:
83212         path_release(&nd);
83213         return bdev;
83214 @@ -854,6 +888,8 @@ blkdev_put:
83215         return ERR_PTR(error);
83216  }
83217  
83218 +EXPORT_SYMBOL(open_bdev_excl);
83219 +
83220  /**
83221   * close_bdev_excl  -  release a blockdevice openen by open_bdev_excl()
83222   *
83223 @@ -867,3 +903,5 @@ void close_bdev_excl(struct block_device
83224         bd_release(bdev);
83225         blkdev_put(bdev, kind);
83226  }
83227 +
83228 +EXPORT_SYMBOL(close_bdev_excl);
83229 --- linux-2.6.0-test6/fs/buffer.c       2003-08-22 19:23:42.000000000 -0700
83230 +++ 25/fs/buffer.c      2003-10-05 00:36:59.000000000 -0700
83231 @@ -116,27 +116,50 @@ void unlock_buffer(struct buffer_head *b
83232  }
83233  
83234  /*
83235 - * Block until a buffer comes unlocked.  This doesn't stop it
83236 + * Wait until a buffer comes unlocked.  This doesn't stop it
83237   * from becoming locked again - you have to lock it yourself
83238   * if you want to preserve its state.
83239 + * If the wait queue parameter specifies an async i/o callback,
83240 + * then instead of blocking, we just queue up the callback
83241 + * on the wait queue for async notification when the buffer gets
83242 + * unlocked.
83243 + * A NULL wait queue parameter defaults to synchronous behaviour
83244   */
83245 -void __wait_on_buffer(struct buffer_head * bh)
83246 +int __wait_on_buffer_wq(struct buffer_head * bh, wait_queue_t *wait)
83247  {
83248         wait_queue_head_t *wqh = bh_waitq_head(bh);
83249 -       DEFINE_WAIT(wait);
83250 +       DEFINE_WAIT(local_wait);
83251 +
83252 +       if (!wait)
83253 +               wait = &local_wait;
83254  
83255         if (atomic_read(&bh->b_count) == 0 &&
83256                         (!bh->b_page || !PageLocked(bh->b_page)))
83257                 buffer_error();
83258  
83259         do {
83260 -               prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE);
83261 +               prepare_to_wait(wqh, wait, TASK_UNINTERRUPTIBLE);
83262                 if (buffer_locked(bh)) {
83263                         blk_run_queues();
83264 +                       if (!is_sync_wait(wait)) {
83265 +                               /*
83266 +                                * if we've queued an async wait queue
83267 +                                * callback do not block; just tell the
83268 +                                * caller to return and retry later when
83269 +                                * the callback is notified
83270 +                                */
83271 +                               return -EIOCBRETRY;
83272 +                       }
83273                         io_schedule();
83274                 }
83275         } while (buffer_locked(bh));
83276 -       finish_wait(wqh, &wait);
83277 +       finish_wait(wqh, wait);
83278 +       return 0;
83279 +}
83280 +
83281 +void __wait_on_buffer(struct buffer_head * bh)
83282 +{
83283 +       __wait_on_buffer_wq(bh, NULL);
83284  }
83285  
83286  static void
83287 @@ -314,8 +337,7 @@ int file_fsync(struct file *filp, struct
83288  asmlinkage long sys_fsync(unsigned int fd)
83289  {
83290         struct file * file;
83291 -       struct dentry * dentry;
83292 -       struct inode * inode;
83293 +       struct address_space *mapping;
83294         int ret, err;
83295  
83296         ret = -EBADF;
83297 @@ -323,8 +345,7 @@ asmlinkage long sys_fsync(unsigned int f
83298         if (!file)
83299                 goto out;
83300  
83301 -       dentry = file->f_dentry;
83302 -       inode = dentry->d_inode;
83303 +       mapping = file->f_mapping;
83304  
83305         ret = -EINVAL;
83306         if (!file->f_op || !file->f_op->fsync) {
83307 @@ -333,17 +354,17 @@ asmlinkage long sys_fsync(unsigned int f
83308         }
83309  
83310         /* We need to protect against concurrent writers.. */
83311 -       down(&inode->i_sem);
83312 +       down(&mapping->host->i_sem);
83313         current->flags |= PF_SYNCWRITE;
83314 -       ret = filemap_fdatawrite(inode->i_mapping);
83315 -       err = file->f_op->fsync(file, dentry, 0);
83316 +       ret = filemap_fdatawrite(mapping);
83317 +       err = file->f_op->fsync(file, file->f_dentry, 0);
83318         if (!ret)
83319                 ret = err;
83320 -       err = filemap_fdatawait(inode->i_mapping);
83321 +       err = filemap_fdatawait(mapping);
83322         if (!ret)
83323                 ret = err;
83324         current->flags &= ~PF_SYNCWRITE;
83325 -       up(&inode->i_sem);
83326 +       up(&mapping->host->i_sem);
83327  
83328  out_putf:
83329         fput(file);
83330 @@ -354,8 +375,7 @@ out:
83331  asmlinkage long sys_fdatasync(unsigned int fd)
83332  {
83333         struct file * file;
83334 -       struct dentry * dentry;
83335 -       struct inode * inode;
83336 +       struct address_space *mapping;
83337         int ret, err;
83338  
83339         ret = -EBADF;
83340 @@ -363,24 +383,23 @@ asmlinkage long sys_fdatasync(unsigned i
83341         if (!file)
83342                 goto out;
83343  
83344 -       dentry = file->f_dentry;
83345 -       inode = dentry->d_inode;
83346 -
83347         ret = -EINVAL;
83348         if (!file->f_op || !file->f_op->fsync)
83349                 goto out_putf;
83350  
83351 -       down(&inode->i_sem);
83352 +       mapping = file->f_mapping;
83353 +
83354 +       down(&mapping->host->i_sem);
83355         current->flags |= PF_SYNCWRITE;
83356 -       ret = filemap_fdatawrite(inode->i_mapping);
83357 -       err = file->f_op->fsync(file, dentry, 1);
83358 +       ret = filemap_fdatawrite(mapping);
83359 +       err = file->f_op->fsync(file, file->f_dentry, 1);
83360         if (!ret)
83361                 ret = err;
83362 -       err = filemap_fdatawait(inode->i_mapping);
83363 +       err = filemap_fdatawait(mapping);
83364         if (!ret)
83365                 ret = err;
83366         current->flags &= ~PF_SYNCWRITE;
83367 -       up(&inode->i_sem);
83368 +       up(&mapping->host->i_sem);
83369  
83370  out_putf:
83371         fput(file);
83372 @@ -1296,9 +1315,12 @@ void __bforget(struct buffer_head *bh)
83373         __brelse(bh);
83374  }
83375  
83376 -static struct buffer_head *__bread_slow(struct buffer_head *bh)
83377 +static struct buffer_head *__bread_slow_wq(struct buffer_head *bh,
83378 +               wait_queue_t *wait)
83379  {
83380 -       lock_buffer(bh);
83381 +       if (-EIOCBRETRY == lock_buffer_wq(bh, wait))
83382 +               return ERR_PTR(-EIOCBRETRY);
83383 +
83384         if (buffer_uptodate(bh)) {
83385                 unlock_buffer(bh);
83386                 return bh;
83387 @@ -1308,7 +1330,8 @@ static struct buffer_head *__bread_slow(
83388                 get_bh(bh);
83389                 bh->b_end_io = end_buffer_read_sync;
83390                 submit_bh(READ, bh);
83391 -               wait_on_buffer(bh);
83392 +               if (-EIOCBRETRY == wait_on_buffer_wq(bh, wait))
83393 +                       return ERR_PTR(-EIOCBRETRY);
83394                 if (buffer_uptodate(bh))
83395                         return bh;
83396         }
83397 @@ -1316,6 +1339,11 @@ static struct buffer_head *__bread_slow(
83398         return NULL;
83399  }
83400  
83401 +static inline struct buffer_head *__bread_slow(struct buffer_head *bh)
83402 +{
83403 +       return __bread_slow_wq(bh, NULL);
83404 +}
83405 +
83406  /*
83407   * Per-cpu buffer LRU implementation.  To reduce the cost of __find_get_block().
83408   * The bhs[] array is sorted - newest buffer is at bhs[0].  Buffers have their
83409 @@ -1503,6 +1531,18 @@ __bread(struct block_device *bdev, secto
83410  }
83411  EXPORT_SYMBOL(__bread);
83412  
83413 +struct buffer_head *
83414 +__bread_wq(struct block_device *bdev, sector_t block, int size,
83415 +       wait_queue_t *wait)
83416 +{
83417 +       struct buffer_head *bh = __getblk(bdev, block, size);
83418 +
83419 +       if (!buffer_uptodate(bh))
83420 +               bh = __bread_slow_wq(bh, wait);
83421 +       return bh;
83422 +}
83423 +EXPORT_SYMBOL(__bread_wq);
83424 +
83425  /*
83426   * invalidate_bh_lrus() is called rarely - at unmount.  Because it is only for
83427   * unmount it only needs to ensure that all buffers from the target device are
83428 @@ -1980,8 +2020,9 @@ static int __block_prepare_write(struct 
83429         /*
83430          * If we issued read requests - let them complete.
83431          */
83432 -       while(wait_bh > wait) {
83433 -               wait_on_buffer(*--wait_bh);
83434 +       while (wait_bh > wait) {
83435 +               if ((err = wait_on_buffer_wq(*--wait_bh, current->io_wait)))
83436 +                       return err;
83437                 if (!buffer_uptodate(*wait_bh))
83438                         return -EIO;
83439         }
83440 @@ -3035,3 +3076,32 @@ void __init buffer_init(void)
83441                                 (void *)(long)smp_processor_id());
83442         register_cpu_notifier(&buffer_nb);
83443  }
83444 +
83445 +EXPORT_SYMBOL(__bforget);
83446 +EXPORT_SYMBOL(__brelse);
83447 +EXPORT_SYMBOL(__wait_on_buffer);
83448 +EXPORT_SYMBOL(__wait_on_buffer_wq);
83449 +EXPORT_SYMBOL(block_commit_write);
83450 +EXPORT_SYMBOL(block_prepare_write);
83451 +EXPORT_SYMBOL(block_read_full_page);
83452 +EXPORT_SYMBOL(block_sync_page);
83453 +EXPORT_SYMBOL(block_truncate_page);
83454 +EXPORT_SYMBOL(block_write_full_page);
83455 +EXPORT_SYMBOL(buffer_insert_list);
83456 +EXPORT_SYMBOL(cont_prepare_write);
83457 +EXPORT_SYMBOL(end_buffer_async_write);
83458 +EXPORT_SYMBOL(end_buffer_read_sync);
83459 +EXPORT_SYMBOL(end_buffer_write_sync);
83460 +EXPORT_SYMBOL(file_fsync);
83461 +EXPORT_SYMBOL(fsync_bdev);
83462 +EXPORT_SYMBOL(fsync_buffers_list);
83463 +EXPORT_SYMBOL(generic_block_bmap);
83464 +EXPORT_SYMBOL(generic_commit_write);
83465 +EXPORT_SYMBOL(generic_cont_expand);
83466 +EXPORT_SYMBOL(init_buffer);
83467 +EXPORT_SYMBOL(invalidate_bdev);
83468 +EXPORT_SYMBOL(ll_rw_block);
83469 +EXPORT_SYMBOL(mark_buffer_dirty);
83470 +EXPORT_SYMBOL(submit_bh);
83471 +EXPORT_SYMBOL(sync_dirty_buffer);
83472 +EXPORT_SYMBOL(unlock_buffer);
83473 --- linux-2.6.0-test6/fs/coda/file.c    2003-09-27 18:57:46.000000000 -0700
83474 +++ 25/fs/coda/file.c   2003-10-05 00:34:03.000000000 -0700
83475 @@ -89,6 +89,7 @@ coda_file_mmap(struct file *coda_file, s
83476  
83477         coda_inode = coda_file->f_dentry->d_inode;
83478         host_inode = host_file->f_dentry->d_inode;
83479 +       coda_file->f_mapping = host_file->f_mapping;
83480         if (coda_inode->i_mapping == &coda_inode->i_data)
83481                 coda_inode->i_mapping = host_inode->i_mapping;
83482  
83483 --- linux-2.6.0-test6/fs/compat_ioctl.c 2003-09-27 18:57:46.000000000 -0700
83484 +++ 25/fs/compat_ioctl.c        2003-10-05 00:34:44.000000000 -0700
83485 @@ -106,6 +106,7 @@
83486  #include <linux/nbd.h>
83487  #include <linux/random.h>
83488  #include <linux/filter.h>
83489 +#include <linux/msdos_fs.h>
83490  
83491  #undef INCLUDES
83492  #endif
83493 @@ -576,54 +577,45 @@ static int ethtool_ioctl(unsigned int fd
83494  
83495  static int bond_ioctl(unsigned long fd, unsigned int cmd, unsigned long arg)
83496  {
83497 -       struct ifreq ifr;
83498 +       struct ifreq kifr;
83499 +       struct ifreq *uifr;
83500 +       struct ifreq32 *ifr32 = (struct ifreq32 *) arg;
83501         mm_segment_t old_fs;
83502 -       int err, len;
83503 +       int err;
83504         u32 data;
83505 -       
83506 -       if (copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
83507 -               return -EFAULT;
83508 -       ifr.ifr_data = (__kernel_caddr_t)get_zeroed_page(GFP_KERNEL);
83509 -       if (!ifr.ifr_data)
83510 -               return -EAGAIN;
83511 +       void *datap;
83512  
83513         switch (cmd) {
83514         case SIOCBONDENSLAVE:
83515         case SIOCBONDRELEASE:
83516         case SIOCBONDSETHWADDR:
83517         case SIOCBONDCHANGEACTIVE:
83518 -               len = IFNAMSIZ * sizeof(char);
83519 -               break;
83520 +               if (copy_from_user(&kifr, ifr32, sizeof(struct ifreq32)))
83521 +                       return -EFAULT;
83522 +
83523 +               old_fs = get_fs();
83524 +               set_fs (KERNEL_DS);
83525 +               err = sys_ioctl (fd, cmd, (unsigned long)&kifr);
83526 +               set_fs (old_fs);
83527 +
83528 +               return err;
83529         case SIOCBONDSLAVEINFOQUERY:
83530 -               len = sizeof(struct ifslave);
83531 -               break;
83532         case SIOCBONDINFOQUERY:
83533 -               len = sizeof(struct ifbond);
83534 -               break;
83535 -       default:
83536 -               err = -EINVAL;
83537 -               goto out;
83538 -       };
83539 +               uifr = compat_alloc_user_space(sizeof(*uifr));
83540 +               if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
83541 +                       return -EFAULT;
83542  
83543 -       __get_user(data, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_data));
83544 -       if (copy_from_user(ifr.ifr_data, compat_ptr(data), len)) {
83545 -               err = -EFAULT;
83546 -               goto out;
83547 -       }
83548 +               if (get_user(data, &ifr32->ifr_ifru.ifru_data))
83549 +                       return -EFAULT;
83550  
83551 -       old_fs = get_fs();
83552 -       set_fs (KERNEL_DS);
83553 -       err = sys_ioctl (fd, cmd, (unsigned long)&ifr);
83554 -       set_fs (old_fs);
83555 -       if (!err) {
83556 -               len = copy_to_user(compat_ptr(data), ifr.ifr_data, len);
83557 -               if (len)
83558 -                       err = -EFAULT;
83559 -       }
83560 +               datap = compat_ptr(data);
83561 +               if (put_user(datap, &uifr->ifr_ifru.ifru_data))
83562 +                       return -EFAULT;
83563  
83564 -out:
83565 -       free_page((unsigned long)ifr.ifr_data);
83566 -       return err;
83567 +               return sys_ioctl (fd, cmd, (unsigned long)uifr);
83568 +       default:
83569 +               return -EINVAL;
83570 +       };
83571  }
83572  
83573  int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
83574 @@ -1035,6 +1027,7 @@ static int sg_build_iovec(sg_io_hdr_t *s
83575                         return -EFAULT;
83576         }
83577  
83578 +       sgio->dxferp = iov;
83579         return 0;
83580  }
83581  
83582 @@ -1581,7 +1574,7 @@ static int vt_check(struct file *file)
83583          * To have permissions to do most of the vt ioctls, we either have
83584          * to be the owner of the tty, or super-user.
83585          */
83586 -       if (current->tty == tty || capable(CAP_SYS_ADMIN))
83587 +       if (process_tty(current) == tty || capable(CAP_SYS_ADMIN))
83588                 return 1;
83589         return 0;                                                    
83590  }
83591 @@ -2310,6 +2303,572 @@ static int mtd_rw_oob(unsigned int fd, u
83592         return err;
83593  }      
83594  
83595 +#define        VFAT_IOCTL_READDIR_BOTH32       _IOR('r', 1, struct compat_dirent[2])
83596 +#define        VFAT_IOCTL_READDIR_SHORT32      _IOR('r', 2, struct compat_dirent[2])
83597 +
83598 +static long
83599 +put_dirent32 (struct dirent *d, struct compat_dirent *d32)
83600 +{
83601 +        int ret;
83602 +
83603 +        if ((ret = verify_area(VERIFY_WRITE, d32,
83604 +                               sizeof(struct compat_dirent))))
83605 +                return ret;
83606 +
83607 +        __put_user(d->d_ino, &d32->d_ino);
83608 +        __put_user(d->d_off, &d32->d_off);
83609 +        __put_user(d->d_reclen, &d32->d_reclen);
83610 +        __copy_to_user(d32->d_name, d->d_name, d->d_reclen);
83611 +        return ret;
83612 +}
83613 +
83614 +static int vfat_ioctl32(unsigned fd, unsigned cmd,  void *ptr)
83615 +{
83616 +       int ret;
83617 +       mm_segment_t oldfs = get_fs();
83618 +       struct dirent d[2];
83619 +
83620 +       switch(cmd)
83621 +       {
83622 +               case VFAT_IOCTL_READDIR_BOTH32:
83623 +                       cmd = VFAT_IOCTL_READDIR_BOTH;
83624 +                       break;
83625 +               case VFAT_IOCTL_READDIR_SHORT32:
83626 +                       cmd = VFAT_IOCTL_READDIR_SHORT;
83627 +                       break;
83628 +       }
83629 +
83630 +       set_fs(KERNEL_DS);
83631 +       ret = sys_ioctl(fd,cmd,(unsigned long)&d);
83632 +       set_fs(oldfs);
83633 +       if (ret >= 0) {
83634 +               ret |= put_dirent32(&d[0], (struct compat_dirent *)ptr);
83635 +               ret |= put_dirent32(&d[1], ((struct compat_dirent *)ptr) + 1);
83636 +       }
83637 +       return ret;
83638 +}
83639 +
83640 +#define REISERFS_IOC_UNPACK32               _IOW(0xCD,1,int)
83641 +
83642 +static int reiserfs_ioctl32(unsigned fd, unsigned cmd, unsigned long ptr)
83643 +{
83644 +        if (cmd == REISERFS_IOC_UNPACK32)
83645 +                cmd = REISERFS_IOC_UNPACK;
83646 +
83647 +        return sys_ioctl(fd,cmd,ptr);
83648 +}
83649 +
83650 +struct raw32_config_request
83651 +{
83652 +        compat_int_t    raw_minor;
83653 +        __u64   block_major;
83654 +        __u64   block_minor;
83655 +} __attribute__((packed));
83656 +
83657 +static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request *user_req)
83658 +{
83659 +        __u32   lo_maj, hi_maj, lo_min, hi_min;
83660 +        int ret;
83661 +
83662 +        if ((ret = verify_area(VERIFY_READ, user_req,
83663 +                               sizeof(struct raw32_config_request))))
83664 +                return ret;
83665 +
83666 +        __get_user(req->raw_minor, &user_req->raw_minor);
83667 +        __get_user(lo_maj, (__u32*)&user_req->block_major);
83668 +        __get_user(hi_maj, ((__u32*)(&user_req->block_major) + 1));
83669 +        __get_user(lo_min, (__u32*)&user_req->block_minor);
83670 +        __get_user(hi_min, ((__u32*)(&user_req->block_minor) + 1));
83671 +
83672 +        req->block_major = lo_maj | (((__u64)hi_maj) << 32);
83673 +        req->block_minor = lo_min | (((__u64)lo_min) << 32);
83674 +
83675 +        return ret;
83676 +}
83677 +
83678 +static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request *user_req)
83679 +{
83680 +       int ret;
83681 +
83682 +        if ((ret = verify_area(VERIFY_WRITE, user_req,
83683 +                               sizeof(struct raw32_config_request))))
83684 +                return ret;
83685 +
83686 +        __put_user(req->raw_minor, &user_req->raw_minor);
83687 +        __put_user((__u32)(req->block_major), (__u32*)&user_req->block_major);
83688 +        __put_user((__u32)(req->block_major >> 32), ((__u32*)(&user_req->block_major) + 1));
83689 +        __put_user((__u32)(req->block_minor), (__u32*)&user_req->block_minor);
83690 +        __put_user((__u32)(req->block_minor >> 32), ((__u32*)(&user_req->block_minor) + 1));
83691 +
83692 +        return ret;
83693 +}
83694 +
83695 +static int raw_ioctl(unsigned fd, unsigned cmd,  void *ptr)
83696 +{
83697 +        int ret;
83698 +
83699 +        switch (cmd) {
83700 +        case RAW_SETBIND:
83701 +        case RAW_GETBIND: {
83702 +                struct raw_config_request req;
83703 +                struct raw32_config_request *user_req = ptr;
83704 +                mm_segment_t oldfs = get_fs();
83705 +
83706 +                if ((ret = get_raw32_request(&req, user_req)))
83707 +                        return ret;
83708 +
83709 +                set_fs(KERNEL_DS);
83710 +                ret = sys_ioctl(fd,cmd,(unsigned long)&req);
83711 +                set_fs(oldfs);
83712 +
83713 +                if ((!ret) && (cmd == RAW_GETBIND)) {
83714 +                        ret = set_raw32_request(&req, user_req);
83715 +                }
83716 +                break;
83717 +        }
83718 +        default:
83719 +                ret = sys_ioctl(fd,cmd,(unsigned long)ptr);
83720 +                break;
83721 +        }
83722 +        return ret;
83723 +}
83724 +
83725 +struct serial_struct32 {
83726 +        compat_int_t    type;
83727 +        compat_int_t    line;
83728 +        compat_uint_t   port;
83729 +        compat_int_t    irq;
83730 +        compat_int_t    flags;
83731 +        compat_int_t    xmit_fifo_size;
83732 +        compat_int_t    custom_divisor;
83733 +        compat_int_t    baud_base;
83734 +        unsigned short  close_delay;
83735 +        char    io_type;
83736 +        char    reserved_char[1];
83737 +        compat_int_t    hub6;
83738 +        unsigned short  closing_wait; /* time to wait before closing */
83739 +        unsigned short  closing_wait2; /* no longer used... */
83740 +        compat_uint_t   iomem_base;
83741 +        unsigned short  iomem_reg_shift;
83742 +        unsigned int    port_high;
83743 +        compat_int_t    reserved[1];
83744 +};
83745 +
83746 +static int serial_struct_ioctl(unsigned fd, unsigned cmd,  void *ptr)
83747 +{
83748 +        typedef struct serial_struct SS;
83749 +        typedef struct serial_struct32 SS32;
83750 +        struct serial_struct32 *ss32 = ptr;
83751 +        int err;
83752 +        struct serial_struct ss;
83753 +        mm_segment_t oldseg = get_fs();
83754 +        __u32 udata;
83755 +
83756 +        if (cmd == TIOCSSERIAL) {
83757 +                if (verify_area(VERIFY_READ, ss32, sizeof(SS32)))
83758 +                        return -EFAULT;
83759 +                __copy_from_user(&ss, ss32, offsetof(SS32, iomem_base));
83760 +                __get_user(udata, &ss32->iomem_base);
83761 +                ss.iomem_base = compat_ptr(udata);
83762 +                __get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift);
83763 +                __get_user(ss.port_high, &ss32->port_high);
83764 +                ss.iomap_base = 0UL;
83765 +        }
83766 +        set_fs(KERNEL_DS);
83767 +                err = sys_ioctl(fd,cmd,(unsigned long)(&ss));
83768 +        set_fs(oldseg);
83769 +        if (cmd == TIOCGSERIAL && err >= 0) {
83770 +                if (verify_area(VERIFY_WRITE, ss32, sizeof(SS32)))
83771 +                        return -EFAULT;
83772 +                __copy_to_user(ss32,&ss,offsetof(SS32,iomem_base));
83773 +                __put_user((unsigned long)ss.iomem_base  >> 32 ?
83774 +                            0xffffffff : (unsigned)(unsigned long)ss.iomem_base,
83775 +                            &ss32->iomem_base);
83776 +                __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift);
83777 +                __put_user(ss.port_high, &ss32->port_high);
83778 +
83779 +        }
83780 +        return err;
83781 +}
83782 +
83783 +struct usbdevfs_ctrltransfer32 {
83784 +        u8 bRequestType;
83785 +        u8 bRequest;
83786 +        u16 wValue;
83787 +        u16 wIndex;
83788 +        u16 wLength;
83789 +        u32 timeout;  /* in milliseconds */
83790 +        compat_caddr_t data;
83791 +};
83792 +
83793 +#define USBDEVFS_CONTROL32           _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
83794 +
83795 +static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg)
83796 +{
83797 +        struct usbdevfs_ctrltransfer kctrl;
83798 +        struct usbdevfs_ctrltransfer32 *uctrl;
83799 +        mm_segment_t old_fs;
83800 +        __u32 udata;
83801 +        void *uptr, *kptr;
83802 +        int err;
83803 +
83804 +        uctrl = (struct usbdevfs_ctrltransfer32 *) arg;
83805 +
83806 +        if (copy_from_user(&kctrl, uctrl,
83807 +                           (sizeof(struct usbdevfs_ctrltransfer32) -
83808 +                            sizeof(compat_caddr_t))))
83809 +                return -EFAULT;
83810 +
83811 +        if (get_user(udata, &uctrl->data))
83812 +                return -EFAULT;
83813 +        uptr = compat_ptr(udata);
83814 +        /* In usbdevice_fs, it limits the control buffer to a page,
83815 +         * for simplicity so do we.
83816 +         */
83817 +        if (!uptr || kctrl.wLength > PAGE_SIZE)
83818 +                return -EINVAL;
83819 +
83820 +        kptr = (void *)__get_free_page(GFP_KERNEL);
83821 +
83822 +        if ((kctrl.bRequestType & USB_DIR_IN) == 0) {
83823 +                err = -EFAULT;
83824 +                if (copy_from_user(kptr, uptr, kctrl.wLength))
83825 +                        goto out;
83826 +        }
83827 +
83828 +        kctrl.data = kptr;
83829 +
83830 +        old_fs = get_fs();
83831 +        set_fs(KERNEL_DS);
83832 +        err = sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)&kctrl);
83833 +        set_fs(old_fs);
83834 +
83835 +        if (err >= 0 &&
83836 +            ((kctrl.bRequestType & USB_DIR_IN) != 0)) {
83837 +                if (copy_to_user(uptr, kptr, kctrl.wLength))
83838 +                        err = -EFAULT;
83839 +        }
83840 +
83841 +out:
83842 +        free_page((unsigned long) kptr);
83843 +        return err;
83844 +}
83845 +
83846 +
83847 +struct usbdevfs_bulktransfer32 {
83848 +        compat_uint_t ep;
83849 +        compat_uint_t len;
83850 +        compat_uint_t timeout; /* in milliseconds */
83851 +        compat_caddr_t data;
83852 +};
83853 +
83854 +#define USBDEVFS_BULK32              _IOWR('U', 2, struct usbdevfs_bulktransfer32)
83855 +
83856 +static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg)
83857 +{
83858 +        struct usbdevfs_bulktransfer kbulk;
83859 +        struct usbdevfs_bulktransfer32 *ubulk;
83860 +        mm_segment_t old_fs;
83861 +        __u32 udata;
83862 +        void *uptr, *kptr;
83863 +        int err;
83864 +
83865 +       ubulk = (struct usbdevfs_bulktransfer32 *) arg;
83866 +
83867 +        if (get_user(kbulk.ep, &ubulk->ep) ||
83868 +            get_user(kbulk.len, &ubulk->len) ||
83869 +            get_user(kbulk.timeout, &ubulk->timeout) ||
83870 +            get_user(udata, &ubulk->data))
83871 +                return -EFAULT;
83872 +
83873 +        uptr = compat_ptr(udata);
83874 +
83875 +        /* In usbdevice_fs, it limits the control buffer to a page,
83876 +         * for simplicity so do we.
83877 +         */
83878 +        if (!uptr || kbulk.len > PAGE_SIZE)
83879 +                return -EINVAL;
83880 +
83881 +        kptr = (void *) __get_free_page(GFP_KERNEL);
83882 +
83883 +        if ((kbulk.ep & 0x80) == 0) {
83884 +                err = -EFAULT;
83885 +               if (copy_from_user(kptr, uptr, kbulk.len))
83886 +                        goto out;
83887 +        }
83888 +
83889 +        kbulk.data = kptr;
83890 +
83891 +       old_fs = get_fs();
83892 +        set_fs(KERNEL_DS);
83893 +        err = sys_ioctl(fd, USBDEVFS_BULK, (unsigned long) &kbulk);
83894 +        set_fs(old_fs);
83895 +
83896 +        if (err >= 0 &&
83897 +            ((kbulk.ep & 0x80) != 0)) {
83898 +                if (copy_to_user(uptr, kptr, kbulk.len))
83899 +                        err = -EFAULT;
83900 +        }
83901 +
83902 +out:
83903 +        free_page((unsigned long) kptr);
83904 +        return err;
83905 +}
83906 +
83907 +/* This needs more work before we can enable it.  Unfortunately
83908 + * because of the fancy asynchronous way URB status/error is written
83909 + * back to userspace, we'll need to fiddle with USB devio internals
83910 + * and/or reimplement entirely the frontend of it ourselves. -DaveM
83911 + *
83912 + * The issue is:
83913 + *
83914 + *     When an URB is submitted via usbdevicefs it is put onto an
83915 + *     asynchronous queue.  When the URB completes, it may be reaped
83916 + *     via another ioctl.  During this reaping the status is written
83917 + *     back to userspace along with the length of the transfer.
83918 + *
83919 + *     We must translate into 64-bit kernel types so we pass in a kernel
83920 + *     space copy of the usbdevfs_urb structure.  This would mean that we
83921 + *     must do something to deal with the async entry reaping.  First we
83922 + *     have to deal somehow with this transitory memory we've allocated.
83923 + *     This is problematic since there are many call sites from which the
83924 + *     async entries can be destroyed (and thus when we'd need to free up
83925 + *     this kernel memory).  One of which is the close() op of usbdevicefs.
83926 + *     To handle that we'd need to make our own file_operations struct which
83927 + *     overrides usbdevicefs's release op with our own which runs usbdevicefs's
83928 + *     real release op then frees up the kernel memory.
83929 + *
83930 + *     But how to keep track of these kernel buffers?  We'd need to either
83931 + *     keep track of them in some table _or_ know about usbdevicefs internals
83932 + *     (ie. the exact layout of its file private, which is actually defined
83933 + *     in linux/usbdevice_fs.h, the layout of the async queues are private to
83934 + *     devio.c)
83935 + *
83936 + * There is one possible other solution I considered, also involving knowledge
83937 + * of usbdevicefs internals:
83938 + *
83939 + *     After an URB is submitted, we "fix up" the address back to the user
83940 + *     space one.  This would work if the status/length fields written back
83941 + *     by the async URB completion lines up perfectly in the 32-bit type with
83942 + *     the 64-bit kernel type.  Unfortunately, it does not because the iso
83943 + *     frame descriptors, at the end of the struct, can be written back.
83944 + *
83945 + * I think we'll just need to simply duplicate the devio URB engine here.
83946 + */
83947 +#if 0
83948 +struct usbdevfs_urb32 {
83949 +       unsigned char type;
83950 +       unsigned char endpoint;
83951 +       compat_int_t status;
83952 +       compat_uint_t flags;
83953 +       compat_caddr_t buffer;
83954 +       compat_int_t buffer_length;
83955 +       compat_int_t actual_length;
83956 +       compat_int_t start_frame;
83957 +       compat_int_t number_of_packets;
83958 +       compat_int_t error_count;
83959 +       compat_uint_t signr;
83960 +       compat_caddr_t usercontext; /* unused */
83961 +       struct usbdevfs_iso_packet_desc iso_frame_desc[0];
83962 +};
83963 +
83964 +#define USBDEVFS_SUBMITURB32       _IOR('U', 10, struct usbdevfs_urb32)
83965 +
83966 +static int get_urb32(struct usbdevfs_urb *kurb,
83967 +                    struct usbdevfs_urb32 *uurb)
83968 +{
83969 +       if (get_user(kurb->type, &uurb->type) ||
83970 +           __get_user(kurb->endpoint, &uurb->endpoint) ||
83971 +           __get_user(kurb->status, &uurb->status) ||
83972 +           __get_user(kurb->flags, &uurb->flags) ||
83973 +           __get_user(kurb->buffer_length, &uurb->buffer_length) ||
83974 +           __get_user(kurb->actual_length, &uurb->actual_length) ||
83975 +           __get_user(kurb->start_frame, &uurb->start_frame) ||
83976 +           __get_user(kurb->number_of_packets, &uurb->number_of_packets) ||
83977 +           __get_user(kurb->error_count, &uurb->error_count) ||
83978 +           __get_user(kurb->signr, &uurb->signr))
83979 +               return -EFAULT;
83980 +
83981 +       kurb->usercontext = 0; /* unused currently */
83982 +
83983 +       return 0;
83984 +}
83985 +
83986 +/* Just put back the values which usbdevfs actually changes. */
83987 +static int put_urb32(struct usbdevfs_urb *kurb,
83988 +                    struct usbdevfs_urb32 *uurb)
83989 +{
83990 +       if (put_user(kurb->status, &uurb->status) ||
83991 +           __put_user(kurb->actual_length, &uurb->actual_length) ||
83992 +           __put_user(kurb->error_count, &uurb->error_count))
83993 +               return -EFAULT;
83994 +
83995 +       if (kurb->number_of_packets != 0) {
83996 +               int i;
83997 +
83998 +               for (i = 0; i < kurb->number_of_packets; i++) {
83999 +                       if (__put_user(kurb->iso_frame_desc[i].actual_length,
84000 +                                      &uurb->iso_frame_desc[i].actual_length) ||
84001 +                           __put_user(kurb->iso_frame_desc[i].status,
84002 +                                      &uurb->iso_frame_desc[i].status))
84003 +                               return -EFAULT;
84004 +               }
84005 +       }
84006 +
84007 +       return 0;
84008 +}
84009 +
84010 +static int get_urb32_isoframes(struct usbdevfs_urb *kurb,
84011 +                              struct usbdevfs_urb32 *uurb)
84012 +{
84013 +       unsigned int totlen;
84014 +       int i;
84015 +
84016 +       if (kurb->type != USBDEVFS_URB_TYPE_ISO) {
84017 +               kurb->number_of_packets = 0;
84018 +               return 0;
84019 +       }
84020 +
84021 +       if (kurb->number_of_packets < 1 ||
84022 +           kurb->number_of_packets > 128)
84023 +               return -EINVAL;
84024 +
84025 +       if (copy_from_user(&kurb->iso_frame_desc[0],
84026 +                          &uurb->iso_frame_desc[0],
84027 +                          sizeof(struct usbdevfs_iso_packet_desc) *
84028 +                          kurb->number_of_packets))
84029 +               return -EFAULT;
84030 +
84031 +       totlen = 0;
84032 +       for (i = 0; i < kurb->number_of_packets; i++) {
84033 +               unsigned int this_len;
84034 +
84035 +               this_len = kurb->iso_frame_desc[i].length;
84036 +               if (this_len > 1023)
84037 +                       return -EINVAL;
84038 +
84039 +               totlen += this_len;
84040 +       }
84041 +
84042 +       if (totlen > 32768)
84043 +               return -EINVAL;
84044 +
84045 +       kurb->buffer_length = totlen;
84046 +
84047 +       return 0;
84048 +}
84049 +
84050 +static int do_usbdevfs_urb(unsigned int fd, unsigned int cmd, unsigned long arg)
84051 +{
84052 +       struct usbdevfs_urb *kurb;
84053 +       struct usbdevfs_urb32 *uurb;
84054 +       mm_segment_t old_fs;
84055 +       __u32 udata;
84056 +       void *uptr, *kptr;
84057 +       unsigned int buflen;
84058 +       int err;
84059 +
84060 +       uurb = (struct usbdevfs_urb32 *) arg;
84061 +
84062 +       err = -ENOMEM;
84063 +       kurb = kmalloc(sizeof(struct usbdevfs_urb) +
84064 +                      (sizeof(struct usbdevfs_iso_packet_desc) * 128),
84065 +                      GFP_KERNEL);
84066 +       if (!kurb)
84067 +               goto out;
84068 +
84069 +       err = -EFAULT;
84070 +       if (get_urb32(kurb, uurb))
84071 +               goto out;
84072 +
84073 +       err = get_urb32_isoframes(kurb, uurb);
84074 +       if (err)
84075 +               goto out;
84076 +
84077 +       err = -EFAULT;
84078 +       if (__get_user(udata, &uurb->buffer))
84079 +               goto out;
84080 +       uptr = compat_ptr(udata);
84081 +
84082 +       buflen = kurb->buffer_length;
84083 +       err = verify_area(VERIFY_WRITE, uptr, buflen);
84084 +       if (err)
84085 +               goto out;
84086 +
84087 +
84088 +       old_fs = get_fs();
84089 +       set_fs(KERNEL_DS);
84090 +       err = sys_ioctl(fd, USBDEVFS_SUBMITURB, (unsigned long) kurb);
84091 +       set_fs(old_fs);
84092 +
84093 +       if (err >= 0) {
84094 +               /* RED-PEN Shit, this doesn't work for async URBs :-( XXX */
84095 +               if (put_urb32(kurb, uurb)) {
84096 +                       err = -EFAULT;
84097 +               }
84098 +       }
84099 +
84100 +out:
84101 +       kfree(kurb);
84102 +       return err;
84103 +}
84104 +#endif
84105 +
84106 +#define USBDEVFS_REAPURB32         _IOW('U', 12, u32)
84107 +#define USBDEVFS_REAPURBNDELAY32   _IOW('U', 13, u32)
84108 +
84109 +static int do_usbdevfs_reapurb(unsigned int fd, unsigned int cmd, unsigned long arg)
84110 +{
84111 +        mm_segment_t old_fs;
84112 +        void *kptr;
84113 +        int err;
84114 +
84115 +        old_fs = get_fs();
84116 +        set_fs(KERNEL_DS);
84117 +        err = sys_ioctl(fd,
84118 +                        (cmd == USBDEVFS_REAPURB32 ?
84119 +                         USBDEVFS_REAPURB :
84120 +                         USBDEVFS_REAPURBNDELAY),
84121 +                        (unsigned long) &kptr);
84122 +        set_fs(old_fs);
84123 +
84124 +        if (err >= 0 &&
84125 +            put_user((u32)(u64)kptr, (u32 *)arg))
84126 +                err = -EFAULT;
84127 +
84128 +        return err;
84129 +}
84130 +
84131 +struct usbdevfs_disconnectsignal32 {
84132 +        compat_int_t signr;
84133 +        compat_caddr_t context;
84134 +};
84135 +
84136 +#define USBDEVFS_DISCSIGNAL32      _IOR('U', 14, struct usbdevfs_disconnectsignal32)
84137 +
84138 +static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg)
84139 +{
84140 +        struct usbdevfs_disconnectsignal kdis;
84141 +        struct usbdevfs_disconnectsignal32 *udis;
84142 +        mm_segment_t old_fs;
84143 +        u32 uctx;
84144 +        int err;
84145 +
84146 +        udis = (struct usbdevfs_disconnectsignal32 *) arg;
84147 +
84148 +        if (get_user(kdis.signr, &udis->signr) ||
84149 +            __get_user(uctx, &udis->context))
84150 +                return -EFAULT;
84151 +
84152 +        kdis.context = (void *) (long)uctx;
84153 +
84154 +        old_fs = get_fs();
84155 +        set_fs(KERNEL_DS);
84156 +        err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis);
84157 +        set_fs(old_fs);
84158 +
84159 +        return err;
84160 +}
84161  #undef CODE
84162  #endif
84163  
84164 @@ -2451,6 +3010,22 @@ HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_io
84165  HANDLE_IOCTL(BLKBSZGET_32, do_blkbszget)
84166  HANDLE_IOCTL(BLKBSZSET_32, do_blkbszset)
84167  HANDLE_IOCTL(BLKGETSIZE64_32, do_blkgetsize64)
84168 -
84169 +/* vfat */
84170 +HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32)
84171 +HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32, vfat_ioctl32)
84172 +HANDLE_IOCTL(REISERFS_IOC_UNPACK32, reiserfs_ioctl32)
84173 +/* Raw devices */
84174 +HANDLE_IOCTL(RAW_SETBIND, raw_ioctl)
84175 +HANDLE_IOCTL(RAW_GETBIND, raw_ioctl)
84176 +/* Serial */
84177 +HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl)
84178 +HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl)
84179 +/* Usbdevfs */
84180 +HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
84181 +HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
84182 +/*HANDLE_IOCTL(USBDEVFS_SUBMITURB32, do_usbdevfs_urb)*/
84183 +HANDLE_IOCTL(USBDEVFS_REAPURB32, do_usbdevfs_reapurb)
84184 +HANDLE_IOCTL(USBDEVFS_REAPURBNDELAY32, do_usbdevfs_reapurb)
84185 +HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
84186  #undef DECLARES
84187  #endif
84188 --- linux-2.6.0-test6/fs/dcache.c       2003-09-27 18:57:46.000000000 -0700
84189 +++ 25/fs/dcache.c      2003-10-05 00:33:24.000000000 -0700
84190 @@ -1639,3 +1639,27 @@ void __init vfs_caches_init(unsigned lon
84191         bdev_cache_init();
84192         chrdev_init();
84193  }
84194 +
84195 +EXPORT_SYMBOL(d_alloc);
84196 +EXPORT_SYMBOL(d_alloc_anon);
84197 +EXPORT_SYMBOL(d_alloc_root);
84198 +EXPORT_SYMBOL(d_delete);
84199 +EXPORT_SYMBOL(d_find_alias);
84200 +EXPORT_SYMBOL(d_instantiate);
84201 +EXPORT_SYMBOL(d_invalidate);
84202 +EXPORT_SYMBOL(d_lookup);
84203 +EXPORT_SYMBOL(d_move);
84204 +EXPORT_SYMBOL(d_path);
84205 +EXPORT_SYMBOL(d_prune_aliases);
84206 +EXPORT_SYMBOL(d_rehash);
84207 +EXPORT_SYMBOL(d_splice_alias);
84208 +EXPORT_SYMBOL(d_validate);
84209 +EXPORT_SYMBOL(dget_locked);
84210 +EXPORT_SYMBOL(dput);
84211 +EXPORT_SYMBOL(find_inode_number);
84212 +EXPORT_SYMBOL(have_submounts);
84213 +EXPORT_SYMBOL(is_subdir);
84214 +EXPORT_SYMBOL(names_cachep);
84215 +EXPORT_SYMBOL(shrink_dcache_anon);
84216 +EXPORT_SYMBOL(shrink_dcache_parent);
84217 +EXPORT_SYMBOL(shrink_dcache_sb);
84218 --- linux-2.6.0-test6/fs/devfs/base.c   2003-09-27 18:57:46.000000000 -0700
84219 +++ 25/fs/devfs/base.c  2003-10-05 00:36:10.000000000 -0700
84220 @@ -973,8 +973,9 @@ static struct devfs_entry *_devfs_search
84221  
84222  /**
84223   *     _devfs_alloc_entry - Allocate a devfs entry.
84224 - *     @name:  The name of the entry.
84225 - *     @namelen:  The number of characters in @name.
84226 + *     @name:     the name of the entry
84227 + *     @namelen:  the number of characters in @name
84228 + *      @mode:     the mode for the entry
84229   *
84230   *  Allocate a devfs entry and returns a pointer to the entry on success, else
84231   *   %NULL.
84232 @@ -1954,15 +1955,9 @@ static int devfs_notify_change (struct d
84233      return 0;
84234  }   /*  End Function devfs_notify_change  */
84235  
84236 -static void devfs_clear_inode (struct inode *inode)
84237 -{
84238 -    if ( S_ISBLK (inode->i_mode) ) bdput (inode->i_bdev);
84239 -}   /*  End Function devfs_clear_inode  */
84240 -
84241  static struct super_operations devfs_sops =
84242  { 
84243      .drop_inode    = generic_delete_inode,
84244 -    .clear_inode   = devfs_clear_inode,
84245      .statfs        = simple_statfs,
84246  };
84247  
84248 @@ -2014,11 +2009,7 @@ static struct inode *_devfs_get_vfs_inod
84249         inode->i_rdev = de->u.cdev.dev;
84250      }
84251      else if ( S_ISBLK (de->mode) )
84252 -    {
84253 -       inode->i_rdev = de->u.bdev.dev;
84254 -       if (bd_acquire (inode) != 0)
84255 -               PRINTK ("(%d): no block device from bdget()\n",(int)inode->i_ino);
84256 -    }
84257 +       init_special_inode(inode, de->mode, de->u.bdev.dev);
84258      else if ( S_ISFIFO (de->mode) )
84259         inode->i_fop = &def_fifo_fops;
84260      else if ( S_ISDIR (de->mode) )
84261 @@ -2117,11 +2108,7 @@ static int devfs_open (struct inode *ino
84262      if (de == NULL) return -ENODEV;
84263      if ( S_ISDIR (de->mode) ) return 0;
84264      file->private_data = de->info;
84265 -    if ( S_ISBLK (inode->i_mode) )
84266 -    {
84267 -       file->f_op = &def_blk_fops;
84268 -       err = def_blk_fops.open (inode, file); /* Module refcount unchanged */
84269 -    } else if (S_ISCHR(inode->i_mode)) {
84270 +    if (S_ISCHR(inode->i_mode)) {
84271         ops = devfs_get_ops (de);  /*  Now have module refcount  */
84272         file->f_op = ops;
84273         if (file->f_op)
84274 --- linux-2.6.0-test6/fs/direct-io.c    2003-08-08 22:55:13.000000000 -0700
84275 +++ 25/fs/direct-io.c   2003-10-05 00:36:53.000000000 -0700
84276 @@ -51,6 +51,10 @@
84277   *
84278   * If blkfactor is zero then the user's request was aligned to the filesystem's
84279   * blocksize.
84280 + *
84281 + * needs_locking is set for regular files on direct-IO-naive filesystems.  It
84282 + * determines whether we need to do the fancy locking which prevents direct-IO
84283 + * from being able to read uninitialised disk blocks.
84284   */
84285  
84286  struct dio {
84287 @@ -58,6 +62,7 @@ struct dio {
84288         struct bio *bio;                /* bio under assembly */
84289         struct inode *inode;
84290         int rw;
84291 +       int needs_locking;              /* doesn't change */
84292         unsigned blkbits;               /* doesn't change */
84293         unsigned blkfactor;             /* When we're using an alignment which
84294                                            is finer than the filesystem's soft
84295 @@ -205,6 +210,8 @@ static void dio_complete(struct dio *dio
84296  {
84297         if (dio->end_io)
84298                 dio->end_io(dio->inode, offset, bytes, dio->map_bh.b_private);
84299 +       if (dio->needs_locking)
84300 +               up_read(&dio->inode->i_alloc_sem);
84301  }
84302  
84303  /*
84304 @@ -448,6 +455,7 @@ static int get_more_blocks(struct dio *d
84305         unsigned long fs_count; /* Number of filesystem-sized blocks */
84306         unsigned long dio_count;/* Number of dio_block-sized blocks */
84307         unsigned long blkmask;
84308 +       int beyond_eof = 0;
84309  
84310         /*
84311          * If there was a memory error and we've overwritten all the
84312 @@ -465,8 +473,19 @@ static int get_more_blocks(struct dio *d
84313                 if (dio_count & blkmask)        
84314                         fs_count++;
84315  
84316 +               if (dio->needs_locking) {
84317 +                       if (dio->block_in_file >= (i_size_read(dio->inode) >>
84318 +                                                       dio->blkbits))
84319 +                               beyond_eof = 1;
84320 +               }
84321 +               /*
84322 +                * For writes inside i_size we forbid block creations: only
84323 +                * overwrites are permitted.  We fall back to buffered writes
84324 +                * at a higher level for inside-i_size block-instantiating
84325 +                * writes.
84326 +                */
84327                 ret = (*dio->get_blocks)(dio->inode, fs_startblk, fs_count,
84328 -                               map_bh, dio->rw == WRITE);
84329 +                               map_bh, (dio->rw == WRITE) && beyond_eof);
84330         }
84331         return ret;
84332  }
84333 @@ -773,6 +792,10 @@ do_holes:
84334                         if (!buffer_mapped(map_bh)) {
84335                                 char *kaddr;
84336  
84337 +                               /* AKPM: eargh, -ENOTBLK is a hack */
84338 +                               if (dio->rw == WRITE)
84339 +                                       return -ENOTBLK;
84340 +
84341                                 if (dio->block_in_file >=
84342                                         i_size_read(dio->inode)>>blkbits) {
84343                                         /* We hit eof */
84344 @@ -838,21 +861,21 @@ out:
84345         return ret;
84346  }
84347  
84348 +/*
84349 + * Releases both i_sem and i_alloc_sem
84350 + */
84351  static int
84352  direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode, 
84353         const struct iovec *iov, loff_t offset, unsigned long nr_segs, 
84354 -       unsigned blkbits, get_blocks_t get_blocks, dio_iodone_t end_io)
84355 +       unsigned blkbits, get_blocks_t get_blocks, dio_iodone_t end_io,
84356 +       struct dio *dio)
84357  {
84358         unsigned long user_addr; 
84359         int seg;
84360         int ret = 0;
84361         int ret2;
84362 -       struct dio *dio;
84363         size_t bytes;
84364  
84365 -       dio = kmalloc(sizeof(*dio), GFP_KERNEL);
84366 -       if (!dio)
84367 -               return -ENOMEM;
84368         dio->is_async = !is_sync_kiocb(iocb);
84369  
84370         dio->bio = NULL;
84371 @@ -863,7 +886,6 @@ direct_io_worker(int rw, struct kiocb *i
84372         dio->start_zero_done = 0;
84373         dio->block_in_file = offset >> blkbits;
84374         dio->blocks_available = 0;
84375 -
84376         dio->cur_page = NULL;
84377  
84378         dio->boundary = 0;
84379 @@ -946,6 +968,13 @@ direct_io_worker(int rw, struct kiocb *i
84380                 dio_bio_submit(dio);
84381  
84382         /*
84383 +        * All new block allocations have been performed.  We can let i_sem
84384 +        * go now.
84385 +        */
84386 +       if (dio->needs_locking)
84387 +               up(&dio->inode->i_sem);
84388 +
84389 +       /*
84390          * OK, all BIOs are submitted, so we can decrement bio_count to truly
84391          * reflect the number of to-be-processed BIOs.
84392          */
84393 @@ -980,11 +1009,17 @@ direct_io_worker(int rw, struct kiocb *i
84394  
84395  /*
84396   * This is a library function for use by filesystem drivers.
84397 + *
84398 + * For writes to S_ISREG files, we are called under i_sem and return with i_sem
84399 + * held, even though it is internally dropped.
84400 + *
84401 + * For writes to S_ISBLK files, i_sem is not held on entry; it is never taken.
84402   */
84403  int
84404 -blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, 
84405 +__blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
84406         struct block_device *bdev, const struct iovec *iov, loff_t offset, 
84407 -       unsigned long nr_segs, get_blocks_t get_blocks, dio_iodone_t end_io)
84408 +       unsigned long nr_segs, get_blocks_t get_blocks, dio_iodone_t end_io,
84409 +       int needs_special_locking)
84410  {
84411         int seg;
84412         size_t size;
84413 @@ -993,6 +1028,8 @@ blockdev_direct_IO(int rw, struct kiocb 
84414         unsigned bdev_blkbits = 0;
84415         unsigned blocksize_mask = (1 << blkbits) - 1;
84416         ssize_t retval = -EINVAL;
84417 +       struct dio *dio;
84418 +       int needs_locking;
84419  
84420         if (bdev)
84421                 bdev_blkbits = blksize_bits(bdev_hardsect_size(bdev));
84422 @@ -1018,8 +1055,37 @@ blockdev_direct_IO(int rw, struct kiocb 
84423                 }
84424         }
84425  
84426 -       retval = direct_io_worker(rw, iocb, inode, iov, offset, 
84427 -                               nr_segs, blkbits, get_blocks, end_io);
84428 +       dio = kmalloc(sizeof(*dio), GFP_KERNEL);
84429 +       retval = -ENOMEM;
84430 +       if (!dio)
84431 +               goto out;
84432 +
84433 +       /*
84434 +        * For regular files,
84435 +        *      readers need to grab i_sem and i_alloc_sem
84436 +        *      writers need to grab i_alloc_sem only (i_sem is already held)
84437 +        */
84438 +       needs_locking = 0;
84439 +       if (S_ISREG(inode->i_mode) && needs_special_locking) {
84440 +               needs_locking = 1;
84441 +               if (rw == READ) {
84442 +                       down(&inode->i_sem);
84443 +                       retval = filemap_write_and_wait(inode->i_mapping);
84444 +                       if (retval) {
84445 +                               up(&inode->i_sem);
84446 +                               kfree(dio);
84447 +                               goto out;
84448 +                       }
84449 +               }
84450 +               down_read(&inode->i_alloc_sem);
84451 +       }
84452 +       dio->needs_locking = needs_locking;
84453 +
84454 +       retval = direct_io_worker(rw, iocb, inode, iov, offset,
84455 +                               nr_segs, blkbits, get_blocks, end_io, dio);
84456 +       if (needs_locking && rw == WRITE)
84457 +               down(&inode->i_sem);
84458  out:
84459         return retval;
84460  }
84461 +EXPORT_SYMBOL(__blockdev_direct_IO);
84462 --- linux-2.6.0-test6/fs/dquot.c        2003-07-10 18:50:31.000000000 -0700
84463 +++ 25/fs/dquot.c       2003-10-05 00:36:15.000000000 -0700
84464 @@ -668,12 +668,12 @@ static void print_warning(struct dquot *
84465  
84466         if (!need_print_warning(dquot) || (flag && test_and_set_bit(flag, &dquot->dq_flags)))
84467                 return;
84468 -       tty_write_message(current->tty, dquot->dq_sb->s_id);
84469 +       tty_write_message(process_tty(current), dquot->dq_sb->s_id);
84470         if (warntype == ISOFTWARN || warntype == BSOFTWARN)
84471 -               tty_write_message(current->tty, ": warning, ");
84472 +               tty_write_message(process_tty(current), ": warning, ");
84473         else
84474 -               tty_write_message(current->tty, ": write failed, ");
84475 -       tty_write_message(current->tty, quotatypes[dquot->dq_type]);
84476 +               tty_write_message(process_tty(current), ": write failed, ");
84477 +       tty_write_message(process_tty(current), quotatypes[dquot->dq_type]);
84478         switch (warntype) {
84479                 case IHARDWARN:
84480                         msg = " file limit reached.\n";
84481 @@ -694,7 +694,7 @@ static void print_warning(struct dquot *
84482                         msg = " block quota exceeded.\n";
84483                         break;
84484         }
84485 -       tty_write_message(current->tty, msg);
84486 +       tty_write_message(process_tty(current), msg);
84487  }
84488  
84489  static inline void flush_warnings(struct dquot **dquots, char *warntype)
84490 --- linux-2.6.0-test6/fs/efs/super.c    2003-06-22 12:04:44.000000000 -0700
84491 +++ 25/fs/efs/super.c   2003-10-05 00:33:24.000000000 -0700
84492 @@ -218,7 +218,11 @@ int efs_fill_super(struct super_block *s
84493         memset(sb, 0, sizeof(struct efs_sb_info));
84494   
84495         s->s_magic              = EFS_SUPER_MAGIC;
84496 -       sb_set_blocksize(s, EFS_BLOCKSIZE);
84497 +       if (!sb_set_blocksize(s, EFS_BLOCKSIZE)) {
84498 +               printk(KERN_ERR "EFS: device does not support %d byte blocks\n",
84499 +                       EFS_BLOCKSIZE);
84500 +               goto out_no_fs_ul;
84501 +       }
84502    
84503         /* read the vh (volume header) block */
84504         bh = sb_bread(s, 0);
84505 --- linux-2.6.0-test6/fs/eventpoll.c    2003-09-27 18:57:46.000000000 -0700
84506 +++ 25/fs/eventpoll.c   2003-10-05 00:34:03.000000000 -0700
84507 @@ -740,6 +740,7 @@ static int ep_getfd(int *efd, struct ino
84508         d_add(dentry, inode);
84509         file->f_vfsmnt = mntget(eventpoll_mnt);
84510         file->f_dentry = dget(dentry);
84511 +       file->f_mapping = inode->i_mapping;
84512  
84513         file->f_pos = 0;
84514         file->f_flags = O_RDONLY;
84515 --- linux-2.6.0-test6/fs/exec.c 2003-09-27 18:57:46.000000000 -0700
84516 +++ 25/fs/exec.c        2003-10-05 00:36:15.000000000 -0700
84517 @@ -83,6 +83,8 @@ int register_binfmt(struct linux_binfmt 
84518         return 0;       
84519  }
84520  
84521 +EXPORT_SYMBOL(register_binfmt);
84522 +
84523  int unregister_binfmt(struct linux_binfmt * fmt)
84524  {
84525         struct linux_binfmt ** tmp = &formats;
84526 @@ -100,6 +102,8 @@ int unregister_binfmt(struct linux_binfm
84527         return -EINVAL;
84528  }
84529  
84530 +EXPORT_SYMBOL(unregister_binfmt);
84531 +
84532  static inline void put_binfmt(struct linux_binfmt * fmt)
84533  {
84534         module_put(fmt->module);
84535 @@ -281,6 +285,8 @@ int copy_strings_kernel(int argc,char **
84536         return r;
84537  }
84538  
84539 +EXPORT_SYMBOL(copy_strings_kernel);
84540 +
84541  #ifdef CONFIG_MMU
84542  /*
84543   * This routine is used to map in a page into an address space: needed by
84544 @@ -443,6 +449,8 @@ int setup_arg_pages(struct linux_binprm 
84545         return 0;
84546  }
84547  
84548 +EXPORT_SYMBOL(setup_arg_pages);
84549 +
84550  #define free_arg_pages(bprm) do { } while (0)
84551  
84552  #else
84553 @@ -493,6 +501,8 @@ out:
84554         goto out;
84555  }
84556  
84557 +EXPORT_SYMBOL(open_exec);
84558 +
84559  int kernel_read(struct file *file, unsigned long offset,
84560         char *addr, unsigned long count)
84561  {
84562 @@ -508,6 +518,8 @@ int kernel_read(struct file *file, unsig
84563         return result;
84564  }
84565  
84566 +EXPORT_SYMBOL(kernel_read);
84567 +
84568  static int exec_mmap(struct mm_struct *mm)
84569  {
84570         struct task_struct *tsk;
84571 @@ -584,6 +596,11 @@ static inline int de_thread(struct task_
84572                 newsig->group_stop_count = 0;
84573                 newsig->curr_target = NULL;
84574                 init_sigpending(&newsig->shared_pending);
84575 +
84576 +               newsig->pgrp = oldsig->pgrp;
84577 +               newsig->session = oldsig->session;
84578 +               newsig->leader = oldsig->leader;
84579 +               newsig->tty_old_pgrp = oldsig->tty_old_pgrp;
84580         }
84581  
84582         if (thread_group_empty(current))
84583 @@ -822,6 +839,8 @@ out:
84584         return retval;
84585  }
84586  
84587 +EXPORT_SYMBOL(flush_old_exec);
84588 +
84589  /*
84590   * We mustn't allow tracing of suid binaries, unless
84591   * the tracer has the capability to trace anything..
84592 @@ -878,6 +897,8 @@ int prepare_binprm(struct linux_binprm *
84593         return kernel_read(bprm->file,0,bprm->buf,BINPRM_BUF_SIZE);
84594  }
84595  
84596 +EXPORT_SYMBOL(prepare_binprm);
84597 +
84598  /*
84599   * This function is used to produce the new IDs and capabilities
84600   * from the old ones and the file's capabilities.
84601 @@ -918,6 +939,8 @@ void compute_creds(struct linux_binprm *
84602         security_bprm_compute_creds(bprm);
84603  }
84604  
84605 +EXPORT_SYMBOL(compute_creds);
84606 +
84607  void remove_arg_zero(struct linux_binprm *bprm)
84608  {
84609         if (bprm->argc) {
84610 @@ -942,6 +965,8 @@ inside:
84611         }
84612  }
84613  
84614 +EXPORT_SYMBOL(remove_arg_zero);
84615 +
84616  /*
84617   * cycle the list of binary formats handler, until one recognizes the image
84618   */
84619 @@ -1037,6 +1062,8 @@ int search_binary_handler(struct linux_b
84620         return retval;
84621  }
84622  
84623 +EXPORT_SYMBOL(search_binary_handler);
84624 +
84625  /*
84626   * sys_execve() executes a new program.
84627   */
84628 @@ -1133,6 +1160,8 @@ out_file:
84629         return retval;
84630  }
84631  
84632 +EXPORT_SYMBOL(do_execve);
84633 +
84634  int set_binfmt(struct linux_binfmt *new)
84635  {
84636         struct linux_binfmt *old = current->binfmt;
84637 @@ -1147,6 +1176,8 @@ int set_binfmt(struct linux_binfmt *new)
84638         return 0;
84639  }
84640  
84641 +EXPORT_SYMBOL(set_binfmt);
84642 +
84643  #define CORENAME_MAX_SIZE 64
84644  
84645  /* format_corename will inspect the pattern parameter, and output a
84646 --- linux-2.6.0-test6/fs/ext2/inode.c   2003-09-27 18:57:46.000000000 -0700
84647 +++ 25/fs/ext2/inode.c  2003-10-05 00:36:59.000000000 -0700
84648 @@ -257,11 +257,12 @@ static int ext2_block_to_path(struct ino
84649   *     or when it reads all @depth-1 indirect blocks successfully and finds
84650   *     the whole chain, all way to the data (returns %NULL, *err == 0).
84651   */
84652 -static Indirect *ext2_get_branch(struct inode *inode,
84653 +static Indirect *ext2_get_branch_wq(struct inode *inode,
84654                                  int depth,
84655                                  int *offsets,
84656                                  Indirect chain[4],
84657 -                                int *err)
84658 +                                int *err,
84659 +                                wait_queue_t *wait)
84660  {
84661         struct super_block *sb = inode->i_sb;
84662         Indirect *p = chain;
84663 @@ -273,8 +274,8 @@ static Indirect *ext2_get_branch(struct 
84664         if (!p->key)
84665                 goto no_block;
84666         while (--depth) {
84667 -               bh = sb_bread(sb, le32_to_cpu(p->key));
84668 -               if (!bh)
84669 +               bh = sb_bread_wq(sb, le32_to_cpu(p->key), wait);
84670 +               if (!bh || IS_ERR(bh))
84671                         goto failure;
84672                 read_lock(&EXT2_I(inode)->i_meta_lock);
84673                 if (!verify_chain(chain, p))
84674 @@ -292,11 +293,21 @@ changed:
84675         *err = -EAGAIN;
84676         goto no_block;
84677  failure:
84678 -       *err = -EIO;
84679 +       *err = IS_ERR(bh) ? PTR_ERR(bh) : -EIO;
84680  no_block:
84681         return p;
84682  }
84683  
84684 +static Indirect *ext2_get_branch(struct inode *inode,
84685 +                                int depth,
84686 +                                int *offsets,
84687 +                                Indirect chain[4],
84688 +                                int *err)
84689 +{
84690 +       return ext2_get_branch_wq(inode, depth, offsets, chain,
84691 +               err, NULL);
84692 +}
84693 +
84694  /**
84695   *     ext2_find_near - find a place for allocation with sufficient locality
84696   *     @inode: owner
84697 @@ -536,7 +547,8 @@ changed:
84698   * reachable from inode.
84699   */
84700  
84701 -static int ext2_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create)
84702 +static int ext2_get_block_wq(struct inode *inode, sector_t iblock,
84703 +       struct buffer_head *bh_result, int create, wait_queue_t *wait)
84704  {
84705         int err = -EIO;
84706         int offsets[4];
84707 @@ -551,7 +563,8 @@ static int ext2_get_block(struct inode *
84708                 goto out;
84709  
84710  reread:
84711 -       partial = ext2_get_branch(inode, depth, offsets, chain, &err);
84712 +       partial = ext2_get_branch_wq(inode, depth, offsets, chain, &err,
84713 +               wait);
84714  
84715         /* Simplest case - block found, no allocation needed */
84716         if (!partial) {
84717 @@ -565,7 +578,7 @@ got_it:
84718         }
84719  
84720         /* Next simple case - plain lookup or failed read of indirect block */
84721 -       if (!create || err == -EIO) {
84722 +       if (!create || err == -EIO || err == -EIOCBRETRY) {
84723  cleanup:
84724                 while (partial > chain) {
84725                         brelse(partial->bh);
84726 @@ -606,6 +619,19 @@ changed:
84727         goto reread;
84728  }
84729  
84730 +static int ext2_get_block_async(struct inode *inode, sector_t iblock,
84731 +       struct buffer_head *bh_result, int create)
84732 +{
84733 +       return ext2_get_block_wq(inode, iblock, bh_result, create,
84734 +               current->io_wait);
84735 +}
84736 +
84737 +static int ext2_get_block(struct inode *inode, sector_t iblock,
84738 +       struct buffer_head *bh_result, int create)
84739 +{
84740 +       return ext2_get_block_wq(inode, iblock, bh_result, create, NULL);
84741 +}
84742 +
84743  static int ext2_writepage(struct page *page, struct writeback_control *wbc)
84744  {
84745         return block_write_full_page(page, ext2_get_block, wbc);
84746 @@ -627,7 +653,7 @@ static int
84747  ext2_prepare_write(struct file *file, struct page *page,
84748                         unsigned from, unsigned to)
84749  {
84750 -       return block_prepare_write(page,from,to,ext2_get_block);
84751 +       return block_prepare_write(page,from,to,ext2_get_block_async);
84752  }
84753  
84754  static int
84755 @@ -659,7 +685,7 @@ ext2_direct_IO(int rw, struct kiocb *ioc
84756                         loff_t offset, unsigned long nr_segs)
84757  {
84758         struct file *file = iocb->ki_filp;
84759 -       struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
84760 +       struct inode *inode = file->f_mapping->host;
84761  
84762         return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
84763                                 offset, nr_segs, ext2_get_blocks, NULL);
84764 @@ -1228,6 +1254,7 @@ static int ext2_update_inode(struct inod
84765                         raw_inode->i_block[0] = 0;
84766                         raw_inode->i_block[1] =
84767                                 cpu_to_le32(new_encode_dev(inode->i_rdev));
84768 +                       raw_inode->i_block[2] = 0;
84769                 }
84770         } else for (n = 0; n < EXT2_N_BLOCKS; n++)
84771                 raw_inode->i_block[n] = ei->i_data[n];
84772 --- linux-2.6.0-test6/fs/ext2/super.c   2003-07-10 18:50:31.000000000 -0700
84773 +++ 25/fs/ext2/super.c  2003-10-05 00:33:24.000000000 -0700
84774 @@ -22,6 +22,7 @@
84775  #include <linux/slab.h>
84776  #include <linux/init.h>
84777  #include <linux/blkdev.h>
84778 +#include <linux/parser.h>
84779  #include <linux/random.h>
84780  #include <linux/buffer_head.h>
84781  #include <linux/smp_lock.h>
84782 @@ -265,149 +266,157 @@ static unsigned long get_sb_block(void *
84783         return sb_block;
84784  }
84785  
84786 -static int want_value(char *value, char *option)
84787 -{
84788 -       if (!value || !*value) {
84789 -               printk(KERN_NOTICE "EXT2-fs: the %s option needs an argument\n",
84790 -                      option);
84791 -               return -1;
84792 -       }
84793 -       return 0;
84794 -}
84795 -
84796 -static int want_null_value(char *value, char *option)
84797 -{
84798 -       if (*value) {
84799 -               printk(KERN_NOTICE "EXT2-fs: Invalid %s argument: %s\n",
84800 -                      option, value);
84801 -               return -1;
84802 -       }
84803 -       return 0;
84804 -}
84805 +enum {
84806 +       Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
84807 +       Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro,
84808 +       Opt_nouid32, Opt_check, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov, Opt_nobh,
84809 +       Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl,
84810 +       Opt_ignore, Opt_err,
84811 +};
84812  
84813 -static int want_numeric(char *value, char *option, unsigned long *number)
84814 -{
84815 -       if (want_value(value, option))
84816 -               return -1;
84817 -       *number = simple_strtoul(value, &value, 0);
84818 -       if (want_null_value(value, option))
84819 -               return -1;
84820 -       return 0;
84821 -}
84822 +static match_table_t tokens = {
84823 +       {Opt_bsd_df, "bsddf"},
84824 +       {Opt_minix_df, "minixdf"},
84825 +       {Opt_grpid, "grpid"},
84826 +       {Opt_grpid, "bsdgroups"},
84827 +       {Opt_nogrpid, "nogrpid"},
84828 +       {Opt_nogrpid, "sysvgroups"},
84829 +       {Opt_resgid, "resgid=%d"},
84830 +       {Opt_resuid, "resuid=%d"},
84831 +       {Opt_sb, "sb=%d"},
84832 +       {Opt_err_cont, "errors=continue"},
84833 +       {Opt_err_panic, "errors=panic"},
84834 +       {Opt_err_ro, "errors=remount-ro"},
84835 +       {Opt_nouid32, "nouid32"},
84836 +       {Opt_nocheck, "check=none"},
84837 +       {Opt_nocheck, "nocheck"},
84838 +       {Opt_check, "check"},
84839 +       {Opt_debug, "debug"},
84840 +       {Opt_oldalloc, "oldalloc"},
84841 +       {Opt_orlov, "orlov"},
84842 +       {Opt_nobh, "nobh"},
84843 +       {Opt_user_xattr, "user_xattr"},
84844 +       {Opt_nouser_xattr, "nouser_xattr"},
84845 +       {Opt_acl, "acl"},
84846 +       {Opt_noacl, "noacl"},
84847 +       {Opt_ignore, "grpquota"},
84848 +       {Opt_ignore, "noquota"},
84849 +       {Opt_ignore, "quota"},
84850 +       {Opt_ignore, "usrquota"},
84851 +       {Opt_err, NULL}
84852 +};
84853  
84854 -/*
84855 - * This function has been shamelessly adapted from the msdos fs
84856 - */
84857  static int parse_options (char * options,
84858                           struct ext2_sb_info *sbi)
84859  {
84860 -       char * this_char;
84861 -       char * value;
84862 +       char * p;
84863 +       substring_t args[MAX_OPT_ARGS];
84864 +       unsigned long kind = EXT2_MOUNT_ERRORS_CONT;
84865 +       int option;
84866  
84867         if (!options)
84868                 return 1;
84869 -       while ((this_char = strsep (&options, ",")) != NULL) {
84870 -               if (!*this_char)
84871 +
84872 +       while ((p = strsep (&options, ",")) != NULL) {
84873 +               int token;
84874 +               if (!*p)
84875                         continue;
84876 -               if ((value = strchr (this_char, '=')) != NULL)
84877 -                       *value++ = 0;
84878 +
84879 +               token = match_token(p, tokens, args);
84880 +               switch (token) {
84881 +               case Opt_bsd_df:
84882 +                       clear_opt (sbi->s_mount_opt, MINIX_DF);
84883 +                       break;
84884 +               case Opt_minix_df:
84885 +                       set_opt (sbi->s_mount_opt, MINIX_DF);
84886 +                       break;
84887 +               case Opt_grpid:
84888 +                       set_opt (sbi->s_mount_opt, GRPID);
84889 +                       break;
84890 +               case Opt_nogrpid:
84891 +                       clear_opt (sbi->s_mount_opt, GRPID);
84892 +                       break;
84893 +               case Opt_resuid:
84894 +                       if (match_int(&args[0], &option))
84895 +                               return 0;
84896 +                       sbi->s_resuid = option;
84897 +                       break;
84898 +               case Opt_resgid:
84899 +                       if (match_int(&args[0], &option))
84900 +                               return 0;
84901 +                       sbi->s_resgid = option;
84902 +                       break;
84903 +               case Opt_sb:
84904 +                       /* handled by get_sb_block() instead of here */
84905 +                       /* *sb_block = match_int(&args[0]); */
84906 +                       break;
84907 +               case Opt_err_panic:
84908 +                       kind = EXT2_MOUNT_ERRORS_PANIC;
84909 +                       break;
84910 +               case Opt_err_ro:
84911 +                       kind = EXT2_MOUNT_ERRORS_RO;
84912 +                       break;
84913 +               case Opt_err_cont:
84914 +                       kind = EXT2_MOUNT_ERRORS_CONT;
84915 +                       break;
84916 +               case Opt_nouid32:
84917 +                       set_opt (sbi->s_mount_opt, NO_UID32);
84918 +                       break;
84919 +               case Opt_check:
84920 +#ifdef CONFIG_EXT2_CHECK
84921 +                       set_opt (sbi->s_mount_opt, CHECK);
84922 +#else
84923 +                       printk("EXT2 Check option not supported\n");
84924 +#endif
84925 +                       break;
84926 +               case Opt_nocheck:
84927 +                       clear_opt (sbi->s_mount_opt, CHECK);
84928 +                       break;
84929 +               case Opt_debug:
84930 +                       set_opt (sbi->s_mount_opt, DEBUG);
84931 +                       break;
84932 +               case Opt_oldalloc:
84933 +                       set_opt (sbi->s_mount_opt, OLDALLOC);
84934 +                       break;
84935 +               case Opt_orlov:
84936 +                       clear_opt (sbi->s_mount_opt, OLDALLOC);
84937 +                       break;
84938 +               case Opt_nobh:
84939 +                       set_opt (sbi->s_mount_opt, NOBH);
84940 +                       break;
84941  #ifdef CONFIG_EXT2_FS_XATTR
84942 -               if (!strcmp (this_char, "user_xattr"))
84943 +               case Opt_user_xattr:
84944                         set_opt (sbi->s_mount_opt, XATTR_USER);
84945 -               else if (!strcmp (this_char, "nouser_xattr"))
84946 +                       break;
84947 +               case Opt_nouser_xattr:
84948                         clear_opt (sbi->s_mount_opt, XATTR_USER);
84949 -               else
84950 +                       break;
84951 +#else
84952 +               case Opt_user_xattr:
84953 +               case Opt_nouser_xattr:
84954 +                       printk("EXT2 (no)user_xattr options not supported\n");
84955 +                       break;
84956  #endif
84957  #ifdef CONFIG_EXT2_FS_POSIX_ACL
84958 -               if (!strcmp(this_char, "acl"))
84959 +               case Opt_acl:
84960                         set_opt(sbi->s_mount_opt, POSIX_ACL);
84961 -               else if (!strcmp(this_char, "noacl"))
84962 +                       break;
84963 +               case Opt_noacl:
84964                         clear_opt(sbi->s_mount_opt, POSIX_ACL);
84965 -               else
84966 -#endif
84967 -               if (!strcmp (this_char, "bsddf"))
84968 -                       clear_opt (sbi->s_mount_opt, MINIX_DF);
84969 -               else if (!strcmp (this_char, "nouid32")) {
84970 -                       set_opt (sbi->s_mount_opt, NO_UID32);
84971 -               }
84972 -               else if (!strcmp (this_char, "check")) {
84973 -                       if (!value || !*value || !strcmp (value, "none"))
84974 -                               clear_opt (sbi->s_mount_opt, CHECK);
84975 -                       else
84976 -#ifdef CONFIG_EXT2_CHECK
84977 -                               set_opt (sbi->s_mount_opt, CHECK);
84978 +                       break;
84979  #else
84980 -                               printk("EXT2 Check option not supported\n");
84981 +               case Opt_acl:
84982 +               case Opt_noacl:
84983 +                       printk("EXT2 (no)acl options not supported\n");
84984 +                       break;
84985  #endif
84986 -               }
84987 -               else if (!strcmp (this_char, "debug"))
84988 -                       set_opt (sbi->s_mount_opt, DEBUG);
84989 -               else if (!strcmp (this_char, "errors")) {
84990 -                       if (!value || !*value) {
84991 -                               printk ("EXT2-fs: the errors option requires "
84992 -                                       "an argument\n");
84993 -                               return 0;
84994 -                       }
84995 -                       if (!strcmp (value, "continue")) {
84996 -                               clear_opt (sbi->s_mount_opt, ERRORS_RO);
84997 -                               clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
84998 -                               set_opt (sbi->s_mount_opt, ERRORS_CONT);
84999 -                       }
85000 -                       else if (!strcmp (value, "remount-ro")) {
85001 -                               clear_opt (sbi->s_mount_opt, ERRORS_CONT);
85002 -                               clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
85003 -                               set_opt (sbi->s_mount_opt, ERRORS_RO);
85004 -                       }
85005 -                       else if (!strcmp (value, "panic")) {
85006 -                               clear_opt (sbi->s_mount_opt, ERRORS_CONT);
85007 -                               clear_opt (sbi->s_mount_opt, ERRORS_RO);
85008 -                               set_opt (sbi->s_mount_opt, ERRORS_PANIC);
85009 -                       }
85010 -                       else {
85011 -                               printk ("EXT2-fs: Invalid errors option: %s\n",
85012 -                                       value);
85013 -                               return 0;
85014 -                       }
85015 -               }
85016 -               else if (!strcmp (this_char, "grpid") ||
85017 -                        !strcmp (this_char, "bsdgroups"))
85018 -                       set_opt (sbi->s_mount_opt, GRPID);
85019 -               else if (!strcmp (this_char, "minixdf"))
85020 -                       set_opt (sbi->s_mount_opt, MINIX_DF);
85021 -               else if (!strcmp (this_char, "nocheck"))
85022 -                       clear_opt (sbi->s_mount_opt, CHECK);
85023 -               else if (!strcmp (this_char, "nogrpid") ||
85024 -                        !strcmp (this_char, "sysvgroups"))
85025 -                       clear_opt (sbi->s_mount_opt, GRPID);
85026 -               else if (!strcmp (this_char, "resgid")) {
85027 -                       unsigned long v;
85028 -                       if (want_numeric(value, "resgid", &v))
85029 -                               return 0;
85030 -                       sbi->s_resgid = v;
85031 -               }
85032 -               else if (!strcmp (this_char, "resuid")) {
85033 -                       unsigned long v;
85034 -                       if (want_numeric(value, "resuid", &v))
85035 -                               return 0;
85036 -                       sbi->s_resuid = v;
85037 -               }
85038 -               else if (!strcmp (this_char, "oldalloc"))
85039 -                       set_opt (sbi->s_mount_opt, OLDALLOC);
85040 -               else if (!strcmp (this_char, "orlov"))
85041 -                       clear_opt (sbi->s_mount_opt, OLDALLOC);
85042 -               else if (!strcmp (this_char, "nobh"))
85043 -                       set_opt(sbi->s_mount_opt, NOBH);
85044 -               /* Silently ignore the quota options */
85045 -               else if (!strcmp (this_char, "grpquota")
85046 -                        || !strcmp (this_char, "noquota")
85047 -                        || !strcmp (this_char, "quota")
85048 -                        || !strcmp (this_char, "usrquota"))
85049 -                       /* Don't do anything ;-) */ ;
85050 -               else {
85051 -                       printk ("EXT2-fs: Unrecognized mount option %s\n", this_char);
85052 +               case Opt_ignore:
85053 +                       break;
85054 +               default:
85055                         return 0;
85056                 }
85057         }
85058 +       sbi->s_mount_opt |= kind;
85059         return 1;
85060  }
85061  
85062 --- linux-2.6.0-test6/fs/ext3/file.c    2003-08-08 22:55:13.000000000 -0700
85063 +++ 25/fs/ext3/file.c   2003-10-05 00:33:24.000000000 -0700
85064 @@ -47,7 +47,7 @@ static int ext3_release_file (struct ino
85065   * the caller didn't specify O_LARGEFILE.  On 64bit systems we force
85066   * on this flag in sys_open.
85067   */
85068 -static int ext3_open_file (struct inode * inode, struct file * filp)
85069 +static int ext3_open_file (struct inode *inode, struct file *filp)
85070  {
85071         if (!(filp->f_flags & O_LARGEFILE) &&
85072             inode->i_size > 0x7FFFFFFFLL)
85073 @@ -56,7 +56,7 @@ static int ext3_open_file (struct inode 
85074  }
85075  
85076  static ssize_t
85077 -ext3_file_write(struct kiocb *iocb, const char *buf, size_t count, loff_t pos)
85078 +ext3_file_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t pos)
85079  {
85080         struct file *file = iocb->ki_filp;
85081         struct inode *inode = file->f_dentry->d_inode;
85082 @@ -117,8 +117,8 @@ struct file_operations ext3_file_operati
85083         .llseek         = generic_file_llseek,
85084         .read           = do_sync_read,
85085         .write          = do_sync_write,
85086 -       .aio_read               = generic_file_aio_read,
85087 -       .aio_write              = ext3_file_write,
85088 +       .aio_read       = generic_file_aio_read,
85089 +       .aio_write      = ext3_file_write,
85090         .readv          = generic_file_readv,
85091         .writev         = generic_file_writev,
85092         .ioctl          = ext3_ioctl,
85093 --- linux-2.6.0-test6/fs/ext3/inode.c   2003-09-27 18:57:46.000000000 -0700
85094 +++ 25/fs/ext3/inode.c  2003-10-05 00:36:12.000000000 -0700
85095 @@ -812,15 +812,17 @@ out:
85096         if (err == -EAGAIN)
85097                 goto changed;
85098  
85099 -       if (ext3_find_goal(inode, iblock, chain, partial, &goal) < 0)
85100 +       down(&ei->truncate_sem);
85101 +       if (ext3_find_goal(inode, iblock, chain, partial, &goal) < 0) {
85102 +               up(&ei->truncate_sem);
85103                 goto changed;
85104 +       }
85105  
85106         left = (chain + depth) - partial;
85107  
85108         /*
85109          * Block out ext3_truncate while we alter the tree
85110          */
85111 -       down_read(&ei->truncate_sem);
85112         err = ext3_alloc_branch(handle, inode, left, goal,
85113                                         offsets+(partial-chain), partial);
85114  
85115 @@ -832,7 +834,7 @@ out:
85116         if (!err)
85117                 err = ext3_splice_branch(handle, inode, iblock, chain,
85118                                          partial, left);
85119 -       up_read(&ei->truncate_sem);
85120 +       up(&ei->truncate_sem);
85121         if (err == -EAGAIN)
85122                 goto changed;
85123         if (err)
85124 @@ -1537,7 +1539,7 @@ static int ext3_direct_IO(int rw, struct
85125                         unsigned long nr_segs)
85126  {
85127         struct file *file = iocb->ki_filp;
85128 -       struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
85129 +       struct inode *inode = file->f_mapping->host;
85130         struct ext3_inode_info *ei = EXT3_I(inode);
85131         handle_t *handle = NULL;
85132         int ret;
85133 @@ -2205,7 +2207,7 @@ void ext3_truncate(struct inode * inode)
85134          * From here we block out all ext3_get_block() callers who want to
85135          * modify the block allocation tree.
85136          */
85137 -       down_write(&ei->truncate_sem);
85138 +       down(&ei->truncate_sem);
85139  
85140         if (n == 1) {           /* direct blocks */
85141                 ext3_free_data(handle, inode, NULL, i_data+offsets[0],
85142 @@ -2269,7 +2271,7 @@ do_indirects:
85143                 case EXT3_TIND_BLOCK:
85144                         ;
85145         }
85146 -       up_write(&ei->truncate_sem);
85147 +       up(&ei->truncate_sem);
85148         inode->i_mtime = inode->i_ctime = CURRENT_TIME;
85149         ext3_mark_inode_dirty(handle, inode);
85150  
85151 @@ -2679,6 +2681,7 @@ static int ext3_do_update_inode(handle_t
85152                         raw_inode->i_block[0] = 0;
85153                         raw_inode->i_block[1] =
85154                                 cpu_to_le32(new_encode_dev(inode->i_rdev));
85155 +                       raw_inode->i_block[2] = 0;
85156                 }
85157         } else for (block = 0; block < EXT3_N_BLOCKS; block++)
85158                 raw_inode->i_block[block] = ei->i_data[block];
85159 --- linux-2.6.0-test6/fs/ext3/super.c   2003-09-27 18:57:46.000000000 -0700
85160 +++ 25/fs/ext3/super.c  2003-10-05 00:36:12.000000000 -0700
85161 @@ -27,6 +27,7 @@
85162  #include <linux/slab.h>
85163  #include <linux/init.h>
85164  #include <linux/blkdev.h>
85165 +#include <linux/parser.h>
85166  #include <linux/smp_lock.h>
85167  #include <linux/buffer_head.h>
85168  #include <linux/vfs.h>
85169 @@ -459,7 +460,7 @@ static void init_once(void * foo, kmem_c
85170  #ifdef CONFIG_EXT3_FS_XATTR
85171                 init_rwsem(&ei->xattr_sem);
85172  #endif
85173 -               init_rwsem(&ei->truncate_sem);
85174 +               init_MUTEX(&ei->truncate_sem);
85175                 inode_init_once(&ei->vfs_inode);
85176         }
85177  }
85178 @@ -526,36 +527,54 @@ static struct export_operations ext3_exp
85179         .get_parent = ext3_get_parent,
85180  };
85181  
85182 +enum {
85183 +       Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
85184 +       Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro,
85185 +       Opt_nouid32, Opt_check, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov,
85186 +       Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, Opt_noload,
85187 +       Opt_commit, Opt_journal_update, Opt_journal_inum,
85188 +       Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
85189 +       Opt_ignore, Opt_err,
85190 +};
85191  
85192 -static int want_value(char *value, char *option)
85193 -{
85194 -       if (!value || !*value) {
85195 -               printk(KERN_NOTICE "EXT3-fs: the %s option needs an argument\n",
85196 -                      option);
85197 -               return -1;
85198 -       }
85199 -       return 0;
85200 -}
85201 -
85202 -static int want_null_value(char *value, char *option)
85203 -{
85204 -       if (*value) {
85205 -               printk(KERN_NOTICE "EXT3-fs: Invalid %s argument: %s\n",
85206 -                      option, value);
85207 -               return -1;
85208 -       }
85209 -       return 0;
85210 -}
85211 -
85212 -static int want_numeric(char *value, char *option, unsigned long *number)
85213 -{
85214 -       if (want_value(value, option))
85215 -               return -1;
85216 -       *number = simple_strtoul(value, &value, 0);
85217 -       if (want_null_value(value, option))
85218 -               return -1;
85219 -       return 0;
85220 -}
85221 +static match_table_t tokens = {
85222 +       {Opt_bsd_df, "bsddf"},
85223 +       {Opt_minix_df, "minixdf"},
85224 +       {Opt_grpid, "grpid"},
85225 +       {Opt_grpid, "bsdgroups"},
85226 +       {Opt_nogrpid, "nogrpid"},
85227 +       {Opt_nogrpid, "sysvgroups"},
85228 +       {Opt_resgid, "resgid=%d"},
85229 +       {Opt_resuid, "resuid=%d"},
85230 +       {Opt_sb, "sb=%d"},
85231 +       {Opt_err_cont, "errors=continue"},
85232 +       {Opt_err_panic, "errors=panic"},
85233 +       {Opt_err_ro, "errors=remount-ro"},
85234 +       {Opt_nouid32, "nouid32"},
85235 +       {Opt_nocheck, "nocheck"},
85236 +       {Opt_nocheck, "check=none"},
85237 +       {Opt_check, "check"},
85238 +       {Opt_debug, "debug"},
85239 +       {Opt_oldalloc, "oldalloc"},
85240 +       {Opt_orlov, "orlov"},
85241 +       {Opt_user_xattr, "user_xattr"},
85242 +       {Opt_nouser_xattr, "nouser_xattr"},
85243 +       {Opt_acl, "acl"},
85244 +       {Opt_noacl, "noacl"},
85245 +       {Opt_noload, "noload"},
85246 +       {Opt_commit, "commit=%u"},
85247 +       {Opt_journal_update, "journal=update"},
85248 +       {Opt_journal_inum, "journal=%u"},
85249 +       {Opt_abort, "abort"},
85250 +       {Opt_data_journal, "data=journal"},
85251 +       {Opt_data_ordered, "data=ordered"},
85252 +       {Opt_data_writeback, "data=writeback"},
85253 +       {Opt_ignore, "grpquota"},
85254 +       {Opt_ignore, "noquota"},
85255 +       {Opt_ignore, "quota"},
85256 +       {Opt_ignore, "usrquota"},
85257 +       {Opt_err, NULL}
85258 +};
85259  
85260  static unsigned long get_sb_block(void **data)
85261  {
85262 @@ -577,175 +596,180 @@ static unsigned long get_sb_block(void *
85263         return sb_block;
85264  }
85265  
85266 -/*
85267 - * This function has been shamelessly adapted from the msdos fs
85268 - */
85269  static int parse_options (char * options, struct ext3_sb_info *sbi,
85270                           unsigned long * inum, int is_remount)
85271  {
85272 -       char * this_char;
85273 -       char * value;
85274 +       char * p;
85275 +       substring_t args[MAX_OPT_ARGS];
85276 +       int data_opt = 0;
85277 +       int option;
85278  
85279         if (!options)
85280                 return 1;
85281 -       while ((this_char = strsep (&options, ",")) != NULL) {
85282 -               if (!*this_char)
85283 +
85284 +       while ((p = strsep (&options, ",")) != NULL) {
85285 +               int token;
85286 +               if (!*p)
85287                         continue;
85288 -               if ((value = strchr (this_char, '=')) != NULL)
85289 -                       *value++ = 0;
85290 -#ifdef CONFIG_EXT3_FS_XATTR
85291 -               if (!strcmp (this_char, "user_xattr"))
85292 -                       set_opt (sbi->s_mount_opt, XATTR_USER);
85293 -               else if (!strcmp (this_char, "nouser_xattr"))
85294 -                       clear_opt (sbi->s_mount_opt, XATTR_USER);
85295 -               else
85296 -#endif
85297 -#ifdef CONFIG_EXT3_FS_POSIX_ACL
85298 -               if (!strcmp(this_char, "acl"))
85299 -                       set_opt (sbi->s_mount_opt, POSIX_ACL);
85300 -               else if (!strcmp(this_char, "noacl"))
85301 -                       clear_opt (sbi->s_mount_opt, POSIX_ACL);
85302 -               else
85303 -#endif
85304 -               if (!strcmp (this_char, "bsddf"))
85305 +
85306 +               token = match_token(p, tokens, args);
85307 +               switch (token) {
85308 +               case Opt_bsd_df:
85309                         clear_opt (sbi->s_mount_opt, MINIX_DF);
85310 -               else if (!strcmp (this_char, "nouid32")) {
85311 +                       break;
85312 +               case Opt_minix_df:
85313 +                       set_opt (sbi->s_mount_opt, MINIX_DF);
85314 +                       break;
85315 +               case Opt_grpid:
85316 +                       set_opt (sbi->s_mount_opt, GRPID);
85317 +                       break;
85318 +               case Opt_nogrpid:
85319 +                       clear_opt (sbi->s_mount_opt, GRPID);
85320 +                       break;
85321 +               case Opt_resuid:
85322 +                       if (match_int(&args[0], &option))
85323 +                               return 0;
85324 +                       sbi->s_resuid = option;
85325 +                       break;
85326 +               case Opt_resgid:
85327 +                       if (match_int(&args[0], &option))
85328 +                               return 0;
85329 +                       sbi->s_resgid = option;
85330 +                       break;
85331 +               case Opt_sb:
85332 +                       /* handled by get_sb_block() instead of here */
85333 +                       /* *sb_block = match_int(&args[0]); */
85334 +                       break;
85335 +               case Opt_err_panic:
85336 +                       clear_opt (sbi->s_mount_opt, ERRORS_CONT);
85337 +                       clear_opt (sbi->s_mount_opt, ERRORS_RO);
85338 +                       set_opt (sbi->s_mount_opt, ERRORS_PANIC);
85339 +                       break;
85340 +               case Opt_err_ro:
85341 +                       clear_opt (sbi->s_mount_opt, ERRORS_CONT);
85342 +                       clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
85343 +                       set_opt (sbi->s_mount_opt, ERRORS_RO);
85344 +                       break;
85345 +               case Opt_err_cont:
85346 +                       clear_opt (sbi->s_mount_opt, ERRORS_RO);
85347 +                       clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
85348 +                       set_opt (sbi->s_mount_opt, ERRORS_CONT);
85349 +                       break;
85350 +               case Opt_nouid32:
85351                         set_opt (sbi->s_mount_opt, NO_UID32);
85352 -               }
85353 -               else if (!strcmp (this_char, "abort"))
85354 -                       set_opt (sbi->s_mount_opt, ABORT);
85355 -               else if (!strcmp (this_char, "check")) {
85356 -                       if (!value || !*value || !strcmp (value, "none"))
85357 -                               clear_opt (sbi->s_mount_opt, CHECK);
85358 -                       else
85359 +                       break;
85360 +               case Opt_check:
85361  #ifdef CONFIG_EXT3_CHECK
85362 -                               set_opt (sbi->s_mount_opt, CHECK);
85363 +                       set_opt (sbi->s_mount_opt, CHECK);
85364  #else
85365 -                               printk(KERN_ERR 
85366 -                                      "EXT3 Check option not supported\n");
85367 +                       printk(KERN_ERR
85368 +                              "EXT3 Check option not supported\n");
85369  #endif
85370 -               }
85371 -               else if (!strcmp (this_char, "debug"))
85372 -                       set_opt (sbi->s_mount_opt, DEBUG);
85373 -               else if (!strcmp (this_char, "errors")) {
85374 -                       if (want_value(value, "errors"))
85375 -                               return 0;
85376 -                       if (!strcmp (value, "continue")) {
85377 -                               clear_opt (sbi->s_mount_opt, ERRORS_RO);
85378 -                               clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
85379 -                               set_opt (sbi->s_mount_opt, ERRORS_CONT);
85380 -                       }
85381 -                       else if (!strcmp (value, "remount-ro")) {
85382 -                               clear_opt (sbi->s_mount_opt, ERRORS_CONT);
85383 -                               clear_opt (sbi->s_mount_opt, ERRORS_PANIC);
85384 -                               set_opt (sbi->s_mount_opt, ERRORS_RO);
85385 -                       }
85386 -                       else if (!strcmp (value, "panic")) {
85387 -                               clear_opt (sbi->s_mount_opt, ERRORS_CONT);
85388 -                               clear_opt (sbi->s_mount_opt, ERRORS_RO);
85389 -                               set_opt (sbi->s_mount_opt, ERRORS_PANIC);
85390 -                       }
85391 -                       else {
85392 -                               printk (KERN_ERR
85393 -                                       "EXT3-fs: Invalid errors option: %s\n",
85394 -                                       value);
85395 -                               return 0;
85396 -                       }
85397 -               }
85398 -               else if (!strcmp (this_char, "grpid") ||
85399 -                        !strcmp (this_char, "bsdgroups"))
85400 -                       set_opt (sbi->s_mount_opt, GRPID);
85401 -               else if (!strcmp (this_char, "minixdf"))
85402 -                       set_opt (sbi->s_mount_opt, MINIX_DF);
85403 -               else if (!strcmp (this_char, "nocheck"))
85404 +                       break;
85405 +               case Opt_nocheck:
85406                         clear_opt (sbi->s_mount_opt, CHECK);
85407 -               else if (!strcmp (this_char, "nogrpid") ||
85408 -                        !strcmp (this_char, "sysvgroups"))
85409 -                       clear_opt (sbi->s_mount_opt, GRPID);
85410 -               else if (!strcmp (this_char, "resgid")) {
85411 -                       unsigned long v;
85412 -                       if (want_numeric(value, "resgid", &v))
85413 -                               return 0;
85414 -                       sbi->s_resgid = v;
85415 -               }
85416 -               else if (!strcmp (this_char, "resuid")) {
85417 -                       unsigned long v;
85418 -                       if (want_numeric(value, "resuid", &v))
85419 -                               return 0;
85420 -                       sbi->s_resuid = v;
85421 -               }
85422 -               else if (!strcmp (this_char, "oldalloc"))
85423 +                       break;
85424 +               case Opt_debug:
85425 +                       set_opt (sbi->s_mount_opt, DEBUG);
85426 +                       break;
85427 +               case Opt_oldalloc:
85428                         set_opt (sbi->s_mount_opt, OLDALLOC);
85429 -               else if (!strcmp (this_char, "orlov"))
85430 +                       break;
85431 +               case Opt_orlov:
85432                         clear_opt (sbi->s_mount_opt, OLDALLOC);
85433 -               /* Silently ignore the quota options */
85434 -               else if (!strcmp (this_char, "grpquota")
85435 -                        || !strcmp (this_char, "noquota")
85436 -                        || !strcmp (this_char, "quota")
85437 -                        || !strcmp (this_char, "usrquota"))
85438 -                       /* Don't do anything ;-) */ ;
85439 -               else if (!strcmp (this_char, "journal")) {
85440 +                       break;
85441 +#ifdef CONFIG_EXT3_FS_XATTR
85442 +               case Opt_user_xattr:
85443 +                       set_opt (sbi->s_mount_opt, XATTR_USER);
85444 +                       break;
85445 +               case Opt_nouser_xattr:
85446 +                       clear_opt (sbi->s_mount_opt, XATTR_USER);
85447 +                       break;
85448 +#else
85449 +               case Opt_user_xattr:
85450 +               case Opt_nouser_xattr:
85451 +                       printk("EXT3 (no)user_xattr options not supported\n");
85452 +                       break;
85453 +#endif
85454 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
85455 +               case Opt_acl:
85456 +                       set_opt(sbi->s_mount_opt, POSIX_ACL);
85457 +                       break;
85458 +               case Opt_noacl:
85459 +                       clear_opt(sbi->s_mount_opt, POSIX_ACL);
85460 +                       break;
85461 +#else
85462 +               case Opt_acl:
85463 +               case Opt_noacl:
85464 +                       printk("EXT3 (no)acl options not supported\n");
85465 +                       break;
85466 +#endif
85467 +               case Opt_journal_update:
85468                         /* @@@ FIXME */
85469                         /* Eventually we will want to be able to create
85470 -                           a journal file here.  For now, only allow the
85471 -                           user to specify an existing inode to be the
85472 -                           journal file. */
85473 +                          a journal file here.  For now, only allow the
85474 +                          user to specify an existing inode to be the
85475 +                          journal file. */
85476                         if (is_remount) {
85477                                 printk(KERN_ERR "EXT3-fs: cannot specify "
85478                                        "journal on remount\n");
85479                                 return 0;
85480                         }
85481 -
85482 -                       if (want_value(value, "journal"))
85483 +                       set_opt (sbi->s_mount_opt, UPDATE_JOURNAL);
85484 +                       break;
85485 +               case Opt_journal_inum:
85486 +                       if (is_remount) {
85487 +                               printk(KERN_ERR "EXT3-fs: cannot specify "
85488 +                                      "journal on remount\n");
85489                                 return 0;
85490 -                       if (!strcmp (value, "update"))
85491 -                               set_opt (sbi->s_mount_opt, UPDATE_JOURNAL);
85492 -                       else if (want_numeric(value, "journal", inum))
85493 +                       }
85494 +                       if (match_int(&args[0], &option))
85495                                 return 0;
85496 -               }
85497 -               else if (!strcmp (this_char, "noload"))
85498 +                       *inum = option;
85499 +                       break;
85500 +               case Opt_noload:
85501                         set_opt (sbi->s_mount_opt, NOLOAD);
85502 -               else if (!strcmp (this_char, "data")) {
85503 -                       int data_opt = 0;
85504 -
85505 -                       if (want_value(value, "data"))
85506 -                               return 0;
85507 -                       if (!strcmp (value, "journal"))
85508 -                               data_opt = EXT3_MOUNT_JOURNAL_DATA;
85509 -                       else if (!strcmp (value, "ordered"))
85510 -                               data_opt = EXT3_MOUNT_ORDERED_DATA;
85511 -                       else if (!strcmp (value, "writeback"))
85512 -                               data_opt = EXT3_MOUNT_WRITEBACK_DATA;
85513 -                       else {
85514 -                               printk (KERN_ERR 
85515 -                                       "EXT3-fs: Invalid data option: %s\n",
85516 -                                       value);
85517 +                       break;
85518 +               case Opt_commit:
85519 +                       if (match_int(&args[0], &option))
85520                                 return 0;
85521 -                       }
85522 +                       sbi->s_commit_interval = HZ * option;
85523 +                       break;
85524 +               case Opt_data_journal:
85525 +                       data_opt = EXT3_MOUNT_JOURNAL_DATA;
85526 +                       goto datacheck;
85527 +               case Opt_data_ordered:
85528 +                       data_opt = EXT3_MOUNT_ORDERED_DATA;
85529 +                       goto datacheck;
85530 +               case Opt_data_writeback:
85531 +                       data_opt = EXT3_MOUNT_WRITEBACK_DATA;
85532 +               datacheck:
85533                         if (is_remount) {
85534 -                               if ((sbi->s_mount_opt & EXT3_MOUNT_DATA_FLAGS) !=
85535 -                                                       data_opt) {
85536 +                               if ((sbi->s_mount_opt & EXT3_MOUNT_DATA_FLAGS)
85537 +                                               != data_opt) {
85538                                         printk(KERN_ERR
85539 -                                              "EXT3-fs: cannot change data "
85540 -                                              "mode on remount\n");
85541 +                                               "EXT3-fs: cannot change data "
85542 +                                               "mode on remount\n");
85543                                         return 0;
85544                                 }
85545                         } else {
85546                                 sbi->s_mount_opt &= ~EXT3_MOUNT_DATA_FLAGS;
85547                                 sbi->s_mount_opt |= data_opt;
85548                         }
85549 -               } else if (!strcmp (this_char, "commit")) {
85550 -                       unsigned long v;
85551 -                       if (want_numeric(value, "commit", &v))
85552 -                               return 0;
85553 -                       sbi->s_commit_interval = (HZ * v);
85554 -               } else {
85555 -                       printk (KERN_ERR 
85556 -                               "EXT3-fs: Unrecognized mount option %s\n",
85557 -                               this_char);
85558 +                       break;
85559 +               case Opt_abort:
85560 +                       set_opt(sbi->s_mount_opt, ABORT);
85561 +                       break;
85562 +               case Opt_ignore:
85563 +                       break;
85564 +               default:
85565 +                       printk (KERN_ERR
85566 +                               "EXT3-fs: Unrecognized mount option \"%s\" "
85567 +                               "or missing value\n", p);
85568                         return 0;
85569                 }
85570         }
85571 +
85572         return 1;
85573  }
85574  
85575 --- linux-2.6.0-test6/fs/ext3/symlink.c 2003-06-14 12:18:22.000000000 -0700
85576 +++ 25/fs/ext3/symlink.c        2003-10-05 00:33:24.000000000 -0700
85577 @@ -22,7 +22,8 @@
85578  #include <linux/ext3_fs.h>
85579  #include "xattr.h"
85580  
85581 -static int ext3_readlink(struct dentry *dentry, char *buffer, int buflen)
85582 +static int
85583 +ext3_readlink(struct dentry *dentry, char __user *buffer, int buflen)
85584  {
85585         struct ext3_inode_info *ei = EXT3_I(dentry->d_inode);
85586         return vfs_readlink(dentry, buffer, buflen, (char*)ei->i_data);
85587 --- linux-2.6.0-test6/fs/fat/dir.c      2003-08-08 22:55:13.000000000 -0700
85588 +++ 25/fs/fat/dir.c     2003-10-05 00:33:24.000000000 -0700
85589 @@ -663,7 +663,7 @@ int fat_dir_ioctl(struct inode * inode, 
85590                 return -EINVAL;
85591         }
85592  
85593 -       d1 = (struct dirent *)arg;
85594 +       d1 = (struct dirent __user *)arg;
85595         if (!access_ok(VERIFY_WRITE, d1, sizeof(struct dirent[2])))
85596                 return -EFAULT;
85597         /*
85598 --- linux-2.6.0-test6/fs/fat/inode.c    2003-08-08 22:55:13.000000000 -0700
85599 +++ 25/fs/fat/inode.c   2003-10-05 00:33:24.000000000 -0700
85600 @@ -20,6 +20,7 @@
85601  #include <linux/buffer_head.h>
85602  #include <linux/mount.h>
85603  #include <linux/vfs.h>
85604 +#include <linux/parser.h>
85605  #include <asm/unaligned.h>
85606  
85607  /*
85608 @@ -183,20 +184,6 @@ void fat_put_super(struct super_block *s
85609         kfree(sbi);
85610  }
85611  
85612 -static int simple_getbool(char *s, int *setval)
85613 -{
85614 -       if (s) {
85615 -               if (!strcmp(s,"1") || !strcmp(s,"yes") || !strcmp(s,"true"))
85616 -                       *setval = 1;
85617 -               else if (!strcmp(s,"0") || !strcmp(s,"no") || !strcmp(s,"false"))
85618 -                       *setval = 0;
85619 -               else
85620 -                       return 0;
85621 -       } else
85622 -               *setval = 1;
85623 -       return 1;
85624 -}
85625 -
85626  static int fat_show_options(struct seq_file *m, struct vfsmount *mnt)
85627  {
85628         struct msdos_sb_info *sbi = MSDOS_SB(mnt->mnt_sb);
85629 @@ -259,11 +246,95 @@ static int fat_show_options(struct seq_f
85630         return 0;
85631  }
85632  
85633 +static void print_obsolete_option(char *optname)
85634 +{
85635 +       printk(KERN_INFO "FAT: %s option is obsolete, "
85636 +                       "not supported now\n", optname);
85637 +}
85638 +
85639 +enum {
85640 +       Opt_blocksize, Opt_charset, Opt_check_n, Opt_check_r, Opt_check_s,
85641 +       Opt_fat, Opt_codepage, Opt_conv_a, Opt_conv_b, Opt_conv_t,
85642 +       Opt_debug, Opt_dots, Opt_err, Opt_gid, Opt_immutable,
85643 +       Opt_nocase, Opt_nodots, Opt_quiet, Opt_showexec, Opt_uid,
85644 +       Opt_shortname_lower, Opt_shortname_win95, Opt_shortname_winnt, Opt_shortname_mixed,
85645 +       Opt_umask, Opt_dmask, Opt_fmask, Opt_posix, Opt_cvf_format, Opt_cvf_options,
85646 +       Opt_utf8_off, Opt_utf8_no, Opt_utf8_false,
85647 +       Opt_utf8_on, Opt_utf8_yes, Opt_utf8_true, Opt_utf8_opt,
85648 +       Opt_uni_xl_off, Opt_uni_xl_no, Opt_uni_xl_false,
85649 +       Opt_uni_xl_on, Opt_uni_xl_yes, Opt_uni_xl_true, Opt_uni_xl_opt,
85650 +       Opt_nonumtail_off, Opt_nonumtail_no, Opt_nonumtail_false,
85651 +       Opt_nonumtail_on, Opt_nonumtail_yes, Opt_nonumtail_true, Opt_nonumtail_opt,
85652 +};
85653 +
85654 +static match_table_t FAT_tokens = {
85655 +       {Opt_check_r, "check=relaxed"},
85656 +       {Opt_check_s, "check=strict"},
85657 +       {Opt_check_n, "check=normal"},
85658 +       {Opt_check_r, "check=r"},
85659 +       {Opt_check_s, "check=s"},
85660 +       {Opt_check_n, "check=n"},
85661 +       {Opt_conv_b, "conv=binary"},
85662 +       {Opt_conv_t, "conv=text"},
85663 +       {Opt_conv_a, "conv=auto"},
85664 +       {Opt_conv_b, "conv=b"},
85665 +       {Opt_conv_t, "conv=t"},
85666 +       {Opt_conv_a, "conv=a"},
85667 +       {Opt_nodots, "nodots"},
85668 +       {Opt_nodots, "dotsOK=no"},
85669 +       {Opt_dots, "dotsOK=yes"},
85670 +       {Opt_dots, "dots"},
85671 +       {Opt_uid, "uid=%d"},
85672 +       {Opt_gid, "gid=%d"},
85673 +       {Opt_umask, "umask=%o"},
85674 +       {Opt_dmask, "dmask=%o"},
85675 +       {Opt_fmask, "fmask=%o"},
85676 +       {Opt_fat, "fat=%d"},
85677 +       {Opt_codepage, "codepage=%d"},
85678 +       {Opt_charset, "iocharset=%s"},
85679 +       {Opt_blocksize, "blocksize=%d"},
85680 +       {Opt_nocase, "nocase"},
85681 +       {Opt_cvf_format, "cvf_format=%20s"},
85682 +       {Opt_cvf_options, "cvf_options=%100s"},
85683 +       {Opt_shortname_lower, "shortname=lower"},
85684 +       {Opt_shortname_win95, "shortname=win95"},
85685 +       {Opt_shortname_winnt, "shortname=winnt"},
85686 +       {Opt_shortname_mixed, "shortname=mixed"},
85687 +       {Opt_utf8_off, "utf8=0"},       /* 0 or no or false */
85688 +       {Opt_utf8_no, "utf8=no"},
85689 +       {Opt_utf8_false, "utf8=false"},
85690 +       {Opt_utf8_on, "utf8=1"},        /* empty or 1 or yes or true */
85691 +       {Opt_utf8_yes, "utf8=yes"},
85692 +       {Opt_utf8_true, "utf8=true"},
85693 +       {Opt_utf8_opt, "utf8"},
85694 +       {Opt_uni_xl_off, "uni_xlate=0"},        /* 0 or no or false */
85695 +       {Opt_uni_xl_no, "uni_xlate=no"},
85696 +       {Opt_uni_xl_false, "uni_xlate=false"},
85697 +       {Opt_uni_xl_on, "uni_xlate=1"},         /* empty or 1 or yes or true */
85698 +       {Opt_uni_xl_yes, "uni_xlate=yes"},
85699 +       {Opt_uni_xl_true, "uni_xlate=true"},
85700 +       {Opt_uni_xl_opt, "uni_xlate"},
85701 +       {Opt_nonumtail_off, "nonumtail=0"},     /* 0 or no or false */
85702 +       {Opt_nonumtail_no, "nonumtail=no"},
85703 +       {Opt_nonumtail_false, "nonumtail=false"},
85704 +       {Opt_nonumtail_on, "nonumtail=1"},      /* empty or 1 or yes or true */
85705 +       {Opt_nonumtail_yes, "nonumtail=yes"},
85706 +       {Opt_nonumtail_true, "nonumtail=true"},
85707 +       {Opt_nonumtail_opt, "nonumtail"},
85708 +       {Opt_quiet, "quiet"},
85709 +       {Opt_showexec, "showexec"},
85710 +       {Opt_debug, "debug"},
85711 +       {Opt_immutable, "sys_immutable"},
85712 +       {Opt_posix, "posix"},
85713 +       {Opt_err, NULL}
85714 +};
85715 +
85716  static int parse_options(char *options, int is_vfat, int *debug,
85717                          struct fat_mount_options *opts)
85718  {
85719 -       char *this_char, *value, *p;
85720 -       int ret = 1, val, len;
85721 +       char *p;
85722 +       substring_t args[MAX_OPT_ARGS];
85723 +       int option;
85724  
85725         opts->isvfat = is_vfat;
85726  
85727 @@ -284,183 +355,198 @@ static int parse_options(char *options, 
85728         *debug = 0;
85729  
85730         if (!options)
85731 -               goto out;
85732 -       while ((this_char = strsep(&options,",")) != NULL) {
85733 -               if (!*this_char)
85734 +               return 1;
85735 +
85736 +       while ((p = strsep(&options, ",")) != NULL) {
85737 +               int token;
85738 +               if (!*p)
85739                         continue;
85740 -               if ((value = strchr(this_char,'=')) != NULL)
85741 -                       *value++ = 0;
85742  
85743 -               if (!strcmp(this_char,"check") && value) {
85744 -                       if (value[0] && !value[1] && strchr("rns",*value))
85745 -                               opts->name_check = *value;
85746 -                       else if (!strcmp(value,"relaxed"))
85747 -                               opts->name_check = 'r';
85748 -                       else if (!strcmp(value,"normal"))
85749 -                               opts->name_check = 'n';
85750 -                       else if (!strcmp(value,"strict"))
85751 -                               opts->name_check = 's';
85752 -                       else ret = 0;
85753 -               }
85754 -               else if (!strcmp(this_char,"conv") && value) {
85755 -                       printk(KERN_INFO "FAT: conv option is obsolete, "
85756 -                              "not supported now\n");
85757 -               }
85758 -               else if (!strcmp(this_char,"nocase")) {
85759 +               token = match_token(p, FAT_tokens, args);
85760 +               switch (token) {
85761 +               case Opt_check_s:
85762 +                       opts->name_check = 's';
85763 +                       break;
85764 +               case Opt_check_r:
85765 +                               opts->name_check = 'r';
85766 +                       break;
85767 +               case Opt_check_n:
85768 +                               opts->name_check = 'n';
85769 +                       break;
85770 +               case Opt_dots:          /* msdos specific */
85771 +                       if (!is_vfat)
85772 +                               opts->dotsOK = 1;
85773 +                       break;
85774 +               case Opt_nodots:        /* msdos specific */
85775 +                       if (!is_vfat)
85776 +                               opts->dotsOK = 0;
85777 +                       break;
85778 +               case Opt_nocase:
85779                         if (!is_vfat)
85780                                 opts->nocase = 1;
85781                         else {
85782 -                               /* for backward compatible */
85783 +                               /* for backward compatibility */
85784                                 opts->shortname = VFAT_SFN_DISPLAY_WIN95
85785                                         | VFAT_SFN_CREATE_WIN95;
85786                         }
85787 -               }
85788 -               else if (!strcmp(this_char,"showexec")) {
85789 +                       break;
85790 +               case Opt_quiet:
85791 +                       opts->quiet = 1;
85792 +                       break;
85793 +               case Opt_showexec:
85794                         opts->showexec = 1;
85795 -               }
85796 -               else if (!strcmp(this_char,"uid")) {
85797 -                       if (!value || !*value) ret = 0;
85798 -                       else {
85799 -                               opts->fs_uid = simple_strtoul(value,&value,0);
85800 -                               if (*value) ret = 0;
85801 -                       }
85802 -               }
85803 -               else if (!strcmp(this_char,"gid")) {
85804 -                       if (!value || !*value) ret= 0;
85805 -                       else {
85806 -                               opts->fs_gid = simple_strtoul(value,&value,0);
85807 -                               if (*value) ret = 0;
85808 -                       }
85809 -               }
85810 -               else if (!strcmp(this_char,"umask")) {
85811 -                       if (!value || !*value) ret = 0;
85812 -                       else {
85813 -                               opts->fs_fmask = opts->fs_dmask =
85814 -                                       simple_strtoul(value,&value,8);
85815 -                               if (*value) ret = 0;
85816 -                       }
85817 -               }
85818 -               else if (!strcmp(this_char,"fmask")) {
85819 -                       if (!value || !*value) ret = 0;
85820 -                       else {
85821 -                               opts->fs_fmask = simple_strtoul(value,&value,8);
85822 -                               if (*value) ret = 0;
85823 -                       }
85824 -               }
85825 -               else if (!strcmp(this_char,"dmask")) {
85826 -                       if (!value || !*value) ret = 0;
85827 -                       else {
85828 -                               opts->fs_dmask = simple_strtoul(value,&value,8);
85829 -                               if (*value) ret = 0;
85830 -                       }
85831 -               }
85832 -               else if (!strcmp(this_char,"debug")) {
85833 -                       if (value) ret = 0;
85834 -                       else *debug = 1;
85835 -               }
85836 -               else if (!strcmp(this_char,"fat")) {
85837 -                       printk(KERN_INFO "FAT: fat option is obsolete, "
85838 -                              "not supported now\n");
85839 -               }
85840 -               else if (!strcmp(this_char,"quiet")) {
85841 -                       if (value) ret = 0;
85842 -                       else opts->quiet = 1;
85843 -               }
85844 -               else if (!strcmp(this_char,"blocksize")) {
85845 -                       printk(KERN_INFO "FAT: blocksize option is obsolete, "
85846 -                              "not supported now\n");
85847 -               }
85848 -               else if (!strcmp(this_char,"sys_immutable")) {
85849 -                       if (value) ret = 0;
85850 -                       else opts->sys_immutable = 1;
85851 -               }
85852 -               else if (!strcmp(this_char,"codepage") && value) {
85853 -                       opts->codepage = simple_strtoul(value,&value,0);
85854 -                       if (*value) ret = 0;
85855 -               }
85856 -
85857 -               /* msdos specific */
85858 -               else if (!is_vfat && !strcmp(this_char,"dots")) {
85859 -                       opts->dotsOK = 1;
85860 -               }
85861 -               else if (!is_vfat && !strcmp(this_char,"nodots")) {
85862 -                       opts->dotsOK = 0;
85863 -               }
85864 -               else if (!is_vfat && !strcmp(this_char,"dotsOK") && value) {
85865 -                       if (!strcmp(value,"yes")) opts->dotsOK = 1;
85866 -                       else if (!strcmp(value,"no")) opts->dotsOK = 0;
85867 -                       else ret = 0;
85868 -               }
85869 +                       break;
85870 +               case Opt_debug:
85871 +                       *debug = 1;
85872 +                       break;
85873 +               case Opt_immutable:
85874 +                       opts->sys_immutable = 1;
85875 +                       break;
85876 +               case Opt_uid:
85877 +                       if (match_int(&args[0], &option))
85878 +                               return 0;
85879 +                       opts->fs_uid = option;
85880 +                       break;
85881 +               case Opt_gid:
85882 +                       if (match_int(&args[0], &option))
85883 +                               return 0;
85884 +                       opts->fs_gid = option;
85885 +                       break;
85886 +               case Opt_umask:
85887 +                       if (match_octal(&args[0], &option))
85888 +                               return 0;
85889 +                       opts->fs_fmask = opts->fs_dmask = option;
85890 +                       break;
85891 +               case Opt_dmask:
85892 +                       if (match_octal(&args[0], &option))
85893 +                               return 0;
85894 +                       opts->fs_dmask = option;
85895 +                       break;
85896 +               case Opt_fmask:
85897 +                       if (match_octal(&args[0], &option))
85898 +                               return 0;
85899 +                       opts->fs_fmask = option;
85900 +                       break;
85901 +               case Opt_codepage:
85902 +                       if (match_int(&args[0], &option))
85903 +                               return 0;
85904 +                       opts->codepage = option;
85905 +                       printk("MSDOS FS: Using codepage %d\n",
85906 +                                       opts->codepage);
85907 +                       break;
85908  
85909                 /* vfat specific */
85910 -               else if (is_vfat && !strcmp(this_char,"iocharset") && value) {
85911 -                       p = value;
85912 -                       while (*value && *value != ',')
85913 -                               value++;
85914 -                       len = value - p;
85915 -                       if (len) {
85916 -                               char *buffer;
85917 -
85918 -                               if (opts->iocharset != NULL) {
85919 -                                       kfree(opts->iocharset);
85920 -                                       opts->iocharset = NULL;
85921 -                               }
85922 -                               buffer = kmalloc(len + 1, GFP_KERNEL);
85923 -                               if (buffer != NULL) {
85924 -                                       opts->iocharset = buffer;
85925 -                                       memcpy(buffer, p, len);
85926 -                                       buffer[len] = 0;
85927 -                               } else
85928 -                                       ret = 0;
85929 +               case Opt_charset:
85930 +                       if (is_vfat) {
85931 +                               kfree(opts->iocharset);
85932 +                               opts->iocharset = match_strdup(&args[0]);
85933 +                               if (!opts->iocharset)
85934 +                                       return 0;
85935 +                               printk("MSDOS FS: IO charset %s\n",
85936 +                                       opts->iocharset);
85937                         }
85938 -               }
85939 -               else if (is_vfat && !strcmp(this_char,"utf8")) {
85940 -                       ret = simple_getbool(value, &val);
85941 -                       if (ret) opts->utf8 = val;
85942 -               }
85943 -               else if (is_vfat && !strcmp(this_char,"uni_xlate")) {
85944 -                       ret = simple_getbool(value, &val);
85945 -                       if (ret) opts->unicode_xlate = val;
85946 -               }
85947 -               else if (is_vfat && !strcmp(this_char,"posix")) {
85948 -                       printk(KERN_INFO "FAT: posix option is obsolete, "
85949 -                              "not supported now\n");
85950 -               }
85951 -               else if (is_vfat && !strcmp(this_char,"nonumtail")) {
85952 -                       ret = simple_getbool(value, &val);
85953 -                       if (ret) {
85954 -                               opts->numtail = !val;
85955 -                       }
85956 -               }
85957 -               else if (is_vfat && !strcmp(this_char, "shortname")) {
85958 -                       if (!strcmp(value, "lower"))
85959 +                       break;
85960 +               case Opt_shortname_lower:
85961 +                       if (is_vfat) {
85962                                 opts->shortname = VFAT_SFN_DISPLAY_LOWER
85963                                                 | VFAT_SFN_CREATE_WIN95;
85964 -                       else if (!strcmp(value, "win95"))
85965 +                       }
85966 +                       break;
85967 +               case Opt_shortname_win95:
85968 +                       if (is_vfat) {
85969                                 opts->shortname = VFAT_SFN_DISPLAY_WIN95
85970                                                 | VFAT_SFN_CREATE_WIN95;
85971 -                       else if (!strcmp(value, "winnt"))
85972 +                       }
85973 +                       break;
85974 +               case Opt_shortname_winnt:
85975 +                       if (is_vfat) {
85976                                 opts->shortname = VFAT_SFN_DISPLAY_WINNT
85977                                                 | VFAT_SFN_CREATE_WINNT;
85978 -                       else if (!strcmp(value, "mixed"))
85979 +                       }
85980 +                       break;
85981 +               case Opt_shortname_mixed:
85982 +                       if (is_vfat) {
85983                                 opts->shortname = VFAT_SFN_DISPLAY_WINNT
85984                                                 | VFAT_SFN_CREATE_WIN95;
85985 -                       else
85986 -                               ret = 0;
85987 -               } else {
85988 -                       printk(KERN_ERR "FAT: Unrecognized mount option %s\n",
85989 -                              this_char);
85990 -                       ret = 0;
85991 -               }
85992 +                       }
85993 +                       break;
85994 +               case Opt_utf8_off:      /* 0 or no or false */
85995 +               case Opt_utf8_no:
85996 +               case Opt_utf8_false:
85997 +                       if (is_vfat) {
85998 +                               opts->utf8 = 0;
85999 +                       }
86000 +                       break;
86001 +               case Opt_utf8_on:       /* empty or 1 or yes or true */
86002 +               case Opt_utf8_opt:
86003 +               case Opt_utf8_yes:
86004 +               case Opt_utf8_true:
86005 +                       if (is_vfat) {
86006 +                               opts->utf8 = 1;
86007 +                       }
86008 +                       break;
86009 +               case Opt_uni_xl_off:    /* 0 or no or false */
86010 +               case Opt_uni_xl_no:
86011 +               case Opt_uni_xl_false:
86012 +                       if (is_vfat) {
86013 +                               opts->unicode_xlate = 0;
86014 +                       }
86015 +                       break;
86016 +               case Opt_uni_xl_on:     /* empty or 1 or yes or true */
86017 +               case Opt_uni_xl_yes:
86018 +               case Opt_uni_xl_true:
86019 +               case Opt_uni_xl_opt:
86020 +                       if (is_vfat) {
86021 +                               opts->unicode_xlate = 1;
86022 +                       }
86023 +                       break;
86024 +               case Opt_nonumtail_off:         /* 0 or no or false */
86025 +               case Opt_nonumtail_no:
86026 +               case Opt_nonumtail_false:
86027 +                       if (is_vfat) {
86028 +                                       opts->numtail = 1;      /* negated option */
86029 +                       }
86030 +                       break;
86031 +               case Opt_nonumtail_on:          /* empty or 1 or yes or true */
86032 +               case Opt_nonumtail_yes:
86033 +               case Opt_nonumtail_true:
86034 +               case Opt_nonumtail_opt:
86035 +                       if (is_vfat) {
86036 +                                       opts->numtail = 0;      /* negated option */
86037 +                       }
86038 +                       break;
86039  
86040 -               if (ret == 0)
86041 +               /* obsolete mount options */
86042 +               case Opt_conv_b:
86043 +               case Opt_conv_t:
86044 +               case Opt_conv_a:
86045 +                       print_obsolete_option("conv");
86046 +                       break;
86047 +               case Opt_blocksize:
86048 +                       print_obsolete_option("blocksize");
86049 +                       break;
86050 +               case Opt_posix:
86051 +                       print_obsolete_option("posix");
86052 +                       break;
86053 +               case Opt_fat:
86054 +                       print_obsolete_option("fat");
86055 +                       break;
86056 +               case Opt_cvf_format:
86057 +               case Opt_cvf_options:
86058 +                       print_obsolete_option("cvf");
86059                         break;
86060 +               /* unknown option */
86061 +               default:
86062 +                       printk(KERN_ERR "FAT: Unrecognized mount option \"%s\" "
86063 +                                       "or missing value\n", p);
86064 +                       return 0;
86065 +               }
86066         }
86067 -out:
86068 +
86069         if (opts->unicode_xlate)
86070                 opts->utf8 = 0;
86071         
86072 -       return ret;
86073 +       return 1;
86074  }
86075  
86076  static int fat_calc_dir_size(struct inode *inode)
86077 --- linux-2.6.0-test6/fs/fcntl.c        2003-09-08 13:58:58.000000000 -0700
86078 +++ 25/fs/fcntl.c       2003-10-05 00:34:08.000000000 -0700
86079 @@ -229,8 +229,8 @@ static int setfl(int fd, struct file * f
86080                    arg |= O_NONBLOCK;
86081  
86082         if (arg & O_DIRECT) {
86083 -               if (!inode->i_mapping || !inode->i_mapping->a_ops ||
86084 -                       !inode->i_mapping->a_ops->direct_IO)
86085 +               if (!filp->f_mapping || !filp->f_mapping->a_ops ||
86086 +                       !filp->f_mapping->a_ops->direct_IO)
86087                                 return -EINVAL;
86088         }
86089  
86090 @@ -619,3 +619,6 @@ module_init(fasync_init)
86091  
86092  EXPORT_SYMBOL(f_setown);
86093  EXPORT_SYMBOL(f_delown);
86094 +#ifdef CONFIG_NET
86095 +EXPORT_SYMBOL(__kill_fasync);
86096 +#endif
86097 --- linux-2.6.0-test6/fs/file_table.c   2003-08-08 22:55:13.000000000 -0700
86098 +++ 25/fs/file_table.c  2003-10-05 00:34:03.000000000 -0700
86099 @@ -114,6 +114,7 @@ int open_private_file(struct file *filp,
86100         filp->f_mode   = (flags+1) & O_ACCMODE;
86101         atomic_set(&filp->f_count, 1);
86102         filp->f_dentry = dentry;
86103 +       filp->f_mapping = dentry->d_inode->i_mapping;
86104         filp->f_uid    = current->fsuid;
86105         filp->f_gid    = current->fsgid;
86106         filp->f_op     = dentry->d_inode->i_fop;
86107 @@ -285,3 +286,5 @@ void __init files_init(unsigned long mem
86108                 files_stat.max_files = NR_FILE;
86109  } 
86110  
86111 +/* Needed by unix.o */
86112 +EXPORT_SYMBOL(files_stat);
86113 --- linux-2.6.0-test6/fs/freevxfs/vxfs_immed.c  2003-06-14 12:18:25.000000000 -0700
86114 +++ 25/fs/freevxfs/vxfs_immed.c 2003-10-05 00:33:24.000000000 -0700
86115 @@ -39,7 +39,7 @@
86116  #include "vxfs_inode.h"
86117  
86118  
86119 -static int     vxfs_immed_readlink(struct dentry *, char *, int);
86120 +static int     vxfs_immed_readlink(struct dentry *, char __user *, int);
86121  static int     vxfs_immed_follow_link(struct dentry *, struct nameidata *);
86122  
86123  static int     vxfs_immed_readpage(struct file *, struct page *);
86124 @@ -77,7 +77,7 @@ struct address_space_operations vxfs_imm
86125   *   Number of bytes successfully copied to userspace.
86126   */
86127  static int
86128 -vxfs_immed_readlink(struct dentry *dp, char *bp, int buflen)
86129 +vxfs_immed_readlink(struct dentry *dp, char __user *bp, int buflen)
86130  {
86131         struct vxfs_inode_info          *vip = VXFS_INO(dp->d_inode);
86132  
86133 --- linux-2.6.0-test6/fs/fs-writeback.c 2003-07-10 18:50:31.000000000 -0700
86134 +++ 25/fs/fs-writeback.c        2003-10-05 00:34:09.000000000 -0700
86135 @@ -510,7 +510,7 @@ void write_inode_now(struct inode *inode
86136   *    OSYNC_INODE:    the inode itself
86137   */
86138  
86139 -int generic_osync_inode(struct inode *inode, int what)
86140 +int generic_osync_inode(struct inode *inode, struct address_space *mapping, int what)
86141  {
86142         int err = 0;
86143         int need_write_inode_now = 0;
86144 @@ -518,14 +518,14 @@ int generic_osync_inode(struct inode *in
86145  
86146         current->flags |= PF_SYNCWRITE;
86147         if (what & OSYNC_DATA)
86148 -               err = filemap_fdatawrite(inode->i_mapping);
86149 +               err = filemap_fdatawrite(mapping);
86150         if (what & (OSYNC_METADATA|OSYNC_DATA)) {
86151 -               err2 = sync_mapping_buffers(inode->i_mapping);
86152 +               err2 = sync_mapping_buffers(mapping);
86153                 if (!err)
86154                         err = err2;
86155         }
86156         if (what & OSYNC_DATA) {
86157 -               err2 = filemap_fdatawait(inode->i_mapping);
86158 +               err2 = filemap_fdatawait(mapping);
86159                 if (!err)
86160                         err = err2;
86161         }
86162 --- linux-2.6.0-test6/fs/hfs/file.c     2003-06-14 12:18:06.000000000 -0700
86163 +++ 25/fs/hfs/file.c    2003-10-05 00:33:24.000000000 -0700
86164 @@ -25,10 +25,10 @@
86165  
86166  /*================ Forward declarations ================*/
86167  
86168 -static hfs_rwret_t hfs_file_read(struct file *, char *, hfs_rwarg_t,
86169 +static hfs_rwret_t hfs_file_read(struct file *, char __user *, hfs_rwarg_t,
86170                                  loff_t *);
86171 -static hfs_rwret_t hfs_file_write(struct file *, const char *, hfs_rwarg_t,
86172 -                                 loff_t *);
86173 +static hfs_rwret_t hfs_file_write(struct file *, const char __user *,
86174 +                                 hfs_rwarg_t, loff_t *);
86175  static void hfs_file_truncate(struct inode *);
86176  
86177  /*================ Global variables ================*/
86178 @@ -139,7 +139,7 @@ int hfs_get_block(struct inode *inode, s
86179   * user-space at the address 'buf'.  Returns the number of bytes
86180   * successfully transferred.  This function checks the arguments, does
86181   * some setup and then calls hfs_do_read() to do the actual transfer.  */
86182 -static hfs_rwret_t hfs_file_read(struct file * filp, char * buf, 
86183 +static hfs_rwret_t hfs_file_read(struct file *filp, char __user *buf, 
86184                                  hfs_rwarg_t count, loff_t *ppos)
86185  {
86186          struct inode *inode = filp->f_dentry->d_inode;
86187 @@ -181,7 +181,7 @@ static hfs_rwret_t hfs_file_read(struct 
86188   * 'file->f_pos' from user-space at the address 'buf'.  The return
86189   * value is the number of bytes actually transferred.
86190   */
86191 -static hfs_rwret_t hfs_file_write(struct file * filp, const char * buf,
86192 +static hfs_rwret_t hfs_file_write(struct file *filp, const char __user *buf,
86193                                   hfs_rwarg_t count, loff_t *ppos)
86194  {
86195          struct inode    *inode = filp->f_dentry->d_inode;
86196 @@ -242,7 +242,7 @@ static void hfs_file_truncate(struct ino
86197   *
86198   * Like copy_to_user() while translating CR->NL.
86199   */
86200 -static inline void xlate_to_user(char *buf, const char *data, int count)
86201 +static inline void xlate_to_user(char __user *buf, const char *data, int count)
86202  {
86203         char ch;
86204  
86205 @@ -257,7 +257,8 @@ static inline void xlate_to_user(char *b
86206   *
86207   * Like copy_from_user() while translating NL->CR;
86208   */
86209 -static inline int xlate_from_user(char *data, const char *buf, int count)
86210 +static inline
86211 +int xlate_from_user(char *data, const char __user *buf, int count)
86212  {
86213         int i;
86214  
86215 @@ -290,8 +291,8 @@ static inline int xlate_from_user(char *
86216   * This is based on Linus's minix_file_read().
86217   * It has been changed to take into account that HFS files have no holes.
86218   */
86219 -hfs_s32 hfs_do_read(struct inode *inode, struct hfs_fork * fork, hfs_u32 pos,
86220 -                   char * buf, hfs_u32 count)
86221 +hfs_s32 hfs_do_read(struct inode *inode, struct hfs_fork *fork, hfs_u32 pos,
86222 +                   char __user *buf, hfs_u32 count)
86223  {
86224         hfs_s32 size, chars, offset, block, blocks, read = 0;
86225         int bhrequest, uptodate;
86226 @@ -436,8 +437,8 @@ hfs_s32 hfs_do_read(struct inode *inode,
86227   * 
86228   * This is just a minor edit of Linus's minix_file_write().
86229   */
86230 -hfs_s32 hfs_do_write(struct inode *inode, struct hfs_fork * fork, hfs_u32 pos,
86231 -                    const char * buf, hfs_u32 count)
86232 +hfs_s32 hfs_do_write(struct inode *inode, struct hfs_fork *fork, hfs_u32 pos,
86233 +                    const char __user *buf, hfs_u32 count)
86234  {
86235         hfs_s32 written, c;
86236         struct buffer_head * bh;
86237 --- linux-2.6.0-test6/fs/hfs/file_cap.c 2003-06-14 12:18:22.000000000 -0700
86238 +++ 25/fs/hfs/file_cap.c        2003-10-05 00:33:24.000000000 -0700
86239 @@ -29,9 +29,9 @@
86240  /*================ Forward declarations ================*/
86241  static loff_t      cap_info_llseek(struct file *, loff_t,
86242                                     int);
86243 -static hfs_rwret_t cap_info_read(struct file *, char *,
86244 +static hfs_rwret_t cap_info_read(struct file *, char __user *,
86245                                  hfs_rwarg_t, loff_t *);
86246 -static hfs_rwret_t cap_info_write(struct file *, const char *,
86247 +static hfs_rwret_t cap_info_write(struct file *, const char __user *,
86248                                   hfs_rwarg_t, loff_t *);
86249  /*================ Function-like macros ================*/
86250  
86251 @@ -121,7 +121,7 @@ static loff_t cap_info_llseek(struct fil
86252   * 'file->f_pos' to user-space at the address 'buf'.  The return value
86253   * is the number of bytes actually transferred.
86254   */
86255 -static hfs_rwret_t cap_info_read(struct file *filp, char *buf,
86256 +static hfs_rwret_t cap_info_read(struct file *filp, char __user *buf,
86257                                  hfs_rwarg_t count, loff_t *ppos)
86258  {
86259         struct inode *inode = filp->f_dentry->d_inode;
86260 @@ -189,7 +189,7 @@ static hfs_rwret_t cap_info_read(struct 
86261   * '*ppos' from user-space at the address 'buf'.
86262   * The return value is the number of bytes actually transferred.
86263   */
86264 -static hfs_rwret_t cap_info_write(struct file *filp, const char *buf, 
86265 +static hfs_rwret_t cap_info_write(struct file *filp, const char __user *buf, 
86266                                   hfs_rwarg_t count, loff_t *ppos)
86267  {
86268          struct inode *inode = filp->f_dentry->d_inode;
86269 --- linux-2.6.0-test6/fs/hfs/file_hdr.c 2003-06-14 12:18:25.000000000 -0700
86270 +++ 25/fs/hfs/file_hdr.c        2003-10-05 00:33:24.000000000 -0700
86271 @@ -41,8 +41,9 @@
86272  
86273  /*================ Forward declarations ================*/
86274  static loff_t      hdr_llseek(struct file *, loff_t, int);
86275 -static hfs_rwret_t hdr_read(struct file *, char *, hfs_rwarg_t, loff_t *);
86276 -static hfs_rwret_t hdr_write(struct file *, const char *,
86277 +static hfs_rwret_t hdr_read(struct file *, char __user *,
86278 +                           hfs_rwarg_t, loff_t *);
86279 +static hfs_rwret_t hdr_write(struct file *, const char __user *,
86280                              hfs_rwarg_t, loff_t *);
86281  /*================ Global variables ================*/
86282  
86283 @@ -382,7 +383,7 @@ loff_t hdr_llseek(struct file *file, lof
86284   * successfully transferred.
86285   */
86286  /* XXX: what about the entry count changing on us? */
86287 -static hfs_rwret_t hdr_read(struct file * filp, char * buf, 
86288 +static hfs_rwret_t hdr_read(struct file *filp, char __user *buf, 
86289                             hfs_rwarg_t count, loff_t *ppos)
86290  {
86291         struct inode *inode = filp->f_dentry->d_inode;
86292 @@ -633,7 +634,7 @@ done:
86293   * '*ppos' from user-space at the address 'buf'.
86294   * The return value is the number of bytes actually transferred.
86295   */
86296 -static hfs_rwret_t hdr_write(struct file *filp, const char *buf,
86297 +static hfs_rwret_t hdr_write(struct file *filp, const char __user *buf,
86298                              hfs_rwarg_t count, loff_t *ppos)
86299  {
86300         struct inode *inode = filp->f_dentry->d_inode;
86301 --- linux-2.6.0-test6/fs/hfs/super.c    2003-06-22 12:04:44.000000000 -0700
86302 +++ 25/fs/hfs/super.c   2003-10-05 00:33:24.000000000 -0700
86303 @@ -31,6 +31,7 @@
86304  #include <linux/blkdev.h>
86305  #include <linux/module.h>
86306  #include <linux/init.h>
86307 +#include <linux/parser.h>
86308  #include <linux/smp_lock.h>
86309  #include <linux/vfs.h>
86310  
86311 @@ -211,6 +212,60 @@ static int hfs_statfs(struct super_block
86312         return 0;
86313  }
86314  
86315 +enum {
86316 +       Opt_version, Opt_uid, Opt_gid, Opt_umask, Opt_part,
86317 +       Opt_type, Opt_creator, Opt_quiet, Opt_afpd,
86318 +       Opt_names_netatalk, Opt_names_trivial, Opt_names_alpha, Opt_names_latin,
86319 +       Opt_names_7bit, Opt_names_8bit, Opt_names_cap,
86320 +       Opt_fork_netatalk, Opt_fork_single, Opt_fork_double, Opt_fork_cap,
86321 +       Opt_case_lower, Opt_case_asis,
86322 +       Opt_conv_binary, Opt_conv_text, Opt_conv_auto,
86323 +};
86324 +
86325 +static match_table_t tokens = {
86326 +       {Opt_version, "version=%u"},
86327 +       {Opt_uid, "uid=%u"},
86328 +       {Opt_gid, "gid=%u"},
86329 +       {Opt_umask, "umask=%o"},
86330 +       {Opt_part, "part=%u"},
86331 +       {Opt_type, "type=%s"},
86332 +       {Opt_creator, "creator=%s"},
86333 +       {Opt_quiet, "quiet"},
86334 +       {Opt_afpd, "afpd"},
86335 +       {Opt_names_netatalk, "names=netatalk"},
86336 +       {Opt_names_trivial, "names=trivial"},
86337 +       {Opt_names_alpha, "names=alpha"},
86338 +       {Opt_names_latin, "names=latin"},
86339 +       {Opt_names_7bit, "names=7bit"},
86340 +       {Opt_names_8bit, "names=8bit"},
86341 +       {Opt_names_cap, "names=cap"},
86342 +       {Opt_names_netatalk, "names=n"},
86343 +       {Opt_names_trivial, "names=t"},
86344 +       {Opt_names_alpha, "names=a"},
86345 +       {Opt_names_latin, "names=l"},
86346 +       {Opt_names_7bit, "names=7"},
86347 +       {Opt_names_8bit, "names=8"},
86348 +       {Opt_names_cap, "names=c"},
86349 +       {Opt_fork_netatalk, "fork=netatalk"},
86350 +       {Opt_fork_single, "fork=single"},
86351 +       {Opt_fork_double, "fork=double"},
86352 +       {Opt_fork_cap, "fork=cap"},
86353 +       {Opt_fork_netatalk, "fork=n"},
86354 +       {Opt_fork_single, "fork=s"},
86355 +       {Opt_fork_double, "fork=d"},
86356 +       {Opt_fork_cap, "fork=c"},
86357 +       {Opt_case_lower, "case=lower"},
86358 +       {Opt_case_asis, "case=asis"},
86359 +       {Opt_case_lower, "case=l"},
86360 +       {Opt_case_asis, "case=a"},
86361 +       {Opt_conv_binary, "conv=binary"},
86362 +       {Opt_conv_text, "conv=text"},
86363 +       {Opt_conv_auto, "conv=auto"},
86364 +       {Opt_conv_binary, "conv=b"},
86365 +       {Opt_conv_text, "conv=t"},
86366 +       {Opt_conv_auto, "conv=a"},
86367 +};
86368 +
86369  /*
86370   * parse_options()
86371   * 
86372 @@ -219,8 +274,10 @@ static int hfs_statfs(struct super_block
86373   */
86374  static int parse_options(char *options, struct hfs_sb_info *hsb, int *part)
86375  {
86376 -       char *this_char, *value;
86377 +       char *p;
86378         char names, fork;
86379 +       substring_t args[MAX_OPT_ARGS];
86380 +       int option;
86381  
86382         /* initialize the sb with defaults */
86383         memset(hsb, 0, sizeof(*hsb));
86384 @@ -243,117 +300,109 @@ static int parse_options(char *options, 
86385         if (!options) {
86386                 goto done;
86387         }
86388 -       while ((this_char = strsep(&options,",")) != NULL) {
86389 -               if (!*this_char)
86390 +       while ((p = strsep(&options,",")) != NULL) {
86391 +               int token;
86392 +               if (!*p)
86393                         continue;
86394 -               if ((value = strchr(this_char,'=')) != NULL) {
86395 -                       *value++ = 0;
86396 -               }
86397 -       /* Numeric-valued options */
86398 -               if (!strcmp(this_char, "version")) {
86399 -                       if (!value || !*value) {
86400 -                               return 0;
86401 -                       }
86402 -                       hsb->s_version = simple_strtoul(value,&value,0);
86403 -                       if (*value) {
86404 -                               return 0;
86405 -                       }
86406 -               } else if (!strcmp(this_char,"uid")) {
86407 -                       if (!value || !*value) {
86408 -                               return 0;
86409 -                       }
86410 -                       hsb->s_uid = simple_strtoul(value,&value,0);
86411 -                       if (*value) {
86412 -                               return 0;
86413 -                       }
86414 -               } else if (!strcmp(this_char,"gid")) {
86415 -                       if (!value || !*value) {
86416 -                               return 0;
86417 -                       }
86418 -                       hsb->s_gid = simple_strtoul(value,&value,0);
86419 -                       if (*value) {
86420 -                               return 0;
86421 -                       }
86422 -               } else if (!strcmp(this_char,"umask")) {
86423 -                       if (!value || !*value) {
86424 -                               return 0;
86425 -                       }
86426 -                       hsb->s_umask = simple_strtoul(value,&value,8);
86427 -                       if (*value) {
86428 -                               return 0;
86429 -                       }
86430 -               } else if (!strcmp(this_char,"part")) {
86431 -                       if (!value || !*value) {
86432 -                               return 0;
86433 -                       }
86434 -                       *part = simple_strtoul(value,&value,0);
86435 -                       if (*value) {
86436 -                               return 0;
86437 -                       }
86438 -       /* String-valued options */
86439 -               } else if (!strcmp(this_char,"type") && value) {
86440 -                       if (strlen(value) != 4) {
86441 -                               return 0;
86442 -                       }
86443 -                       hsb->s_type = hfs_get_nl(value);
86444 -               } else if (!strcmp(this_char,"creator") && value) {
86445 -                       if (strlen(value) != 4) {
86446 -                               return 0;
86447 -                       }
86448 -                       hsb->s_creator = hfs_get_nl(value);
86449 -       /* Boolean-valued options */
86450 -               } else if (!strcmp(this_char,"quiet")) {
86451 -                       if (value) {
86452 -                               return 0;
86453 -                       }
86454 +
86455 +               token = match_token(p, tokens, args);
86456 +               switch (token) {
86457 +               /* Numeric-valued options */
86458 +               case Opt_version:
86459 +                       if (match_int(&args[0], &option))
86460 +                               return 0;
86461 +                       hsb->s_version = option;
86462 +                       break;
86463 +               case Opt_uid:
86464 +                       if (match_int(&args[0], &option))
86465 +                               return 0;
86466 +                       hsb->s_uid = option;
86467 +                       break;
86468 +               case Opt_gid:
86469 +                       if (match_int(&args[0], &option))
86470 +                               return 0;
86471 +                       hsb->s_gid = option;
86472 +                       break;
86473 +               case Opt_umask:
86474 +                       if (match_octal(&args[0], &option))
86475 +                               return 0;
86476 +                       hsb->s_umask = option;
86477 +                       break;
86478 +               case Opt_part:
86479 +                       if (match_int(&args[0], &option))
86480 +                               return 0;
86481 +                       *part = option;
86482 +                       break;
86483 +               /* String-valued options */
86484 +               case Opt_type:
86485 +                       if (strlen(args[0].from) != 4) {
86486 +                               return 0;
86487 +                       }
86488 +                       hsb->s_type = hfs_get_nl(args[0].from);
86489 +                       break;
86490 +               case Opt_creator:
86491 +                       if (strlen(args[0].from) != 4) {
86492 +                               return 0;
86493 +                       }
86494 +                       hsb->s_creator = hfs_get_nl(args[0].from);
86495 +                       break;
86496 +               /* Boolean-valued options */
86497 +               case Opt_quiet:
86498                         hsb->s_quiet = 1;
86499 -               } else if (!strcmp(this_char,"afpd")) {
86500 -                       if (value) {
86501 -                               return 0;
86502 -                       }
86503 +                       break;
86504 +               case Opt_afpd:
86505                         hsb->s_afpd = 1;
86506 -       /* Multiple choice options */
86507 -               } else if (!strcmp(this_char,"names") && value) {
86508 -                       if ((*value && !value[1] && strchr("ntal78c",*value)) ||
86509 -                           !strcmp(value,"netatalk") ||
86510 -                           !strcmp(value,"trivial") ||
86511 -                           !strcmp(value,"alpha") ||
86512 -                           !strcmp(value,"latin") ||
86513 -                           !strcmp(value,"7bit") ||
86514 -                           !strcmp(value,"8bit") ||
86515 -                           !strcmp(value,"cap")) {
86516 -                               names = *value;
86517 -                       } else {
86518 -                               return 0;
86519 -                       }
86520 -               } else if (!strcmp(this_char,"fork") && value) {
86521 -                       if ((*value && !value[1] && strchr("nsdc",*value)) ||
86522 -                           !strcmp(value,"netatalk") ||
86523 -                           !strcmp(value,"single") ||
86524 -                           !strcmp(value,"double") ||
86525 -                           !strcmp(value,"cap")) {
86526 -                               fork = *value;
86527 -                       } else {
86528 -                               return 0;
86529 -                       }
86530 -               } else if (!strcmp(this_char,"case") && value) {
86531 -                       if ((*value && !value[1] && strchr("la",*value)) ||
86532 -                           !strcmp(value,"lower") ||
86533 -                           !strcmp(value,"asis")) {
86534 -                               hsb->s_lowercase = (*value == 'l');
86535 -                       } else {
86536 -                               return 0;
86537 -                       }
86538 -               } else if (!strcmp(this_char,"conv") && value) {
86539 -                       if ((*value && !value[1] && strchr("bta",*value)) ||
86540 -                           !strcmp(value,"binary") ||
86541 -                           !strcmp(value,"text") ||
86542 -                           !strcmp(value,"auto")) {
86543 -                               hsb->s_conv = *value;
86544 -                       } else {
86545 -                               return 0;
86546 -                       }
86547 -               } else {
86548 +                       break;
86549 +               /* Multiple choice options */
86550 +               case Opt_names_netatalk:
86551 +                       names = 'n';
86552 +                       break;
86553 +               case Opt_names_trivial:
86554 +                       names = 't';
86555 +                       break;
86556 +               case Opt_names_alpha:
86557 +                       names = 'a';
86558 +                       break;
86559 +               case Opt_names_latin:
86560 +                       names = 'l';
86561 +                       break;
86562 +               case Opt_names_7bit:
86563 +                       names = '7';
86564 +                       break;
86565 +               case Opt_names_8bit:
86566 +                       names = '8';
86567 +                       break;
86568 +               case Opt_names_cap:
86569 +                       names = 'c';
86570 +                       break;
86571 +               case Opt_fork_netatalk:
86572 +                       fork = 'n';
86573 +                       break;
86574 +               case Opt_fork_single:
86575 +                       fork = 's';
86576 +                       break;
86577 +               case Opt_fork_double:
86578 +                       fork = 'd';
86579 +                       break;
86580 +               case Opt_fork_cap:
86581 +                       fork = 'c';
86582 +                       break;
86583 +               case Opt_case_lower:
86584 +                       hsb->s_lowercase = 1;
86585 +                       break;
86586 +               case Opt_case_asis:
86587 +                       hsb->s_lowercase = 0;
86588 +                       break;
86589 +               case Opt_conv_binary:
86590 +                       hsb->s_conv = 'b';
86591 +                       break;
86592 +               case Opt_conv_text:
86593 +                       hsb->s_conv = 't';
86594 +                       break;
86595 +               case Opt_conv_auto:
86596 +                       hsb->s_conv = 'a';
86597 +                       break;
86598 +               default:
86599                         return 0;
86600                 }
86601         }
86602 --- linux-2.6.0-test6/fs/hpfs/file.c    2003-06-14 12:18:35.000000000 -0700
86603 +++ 25/fs/hpfs/file.c   2003-10-05 00:33:24.000000000 -0700
86604 @@ -124,7 +124,8 @@ struct address_space_operations hpfs_aop
86605         .bmap = _hpfs_bmap
86606  };
86607  
86608 -ssize_t hpfs_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
86609 +ssize_t hpfs_file_write(struct file *file, const char __user *buf,
86610 +                       size_t count, loff_t *ppos)
86611  {
86612         ssize_t retval;
86613  
86614 --- linux-2.6.0-test6/fs/hpfs/hpfs_fn.h 2003-07-10 18:50:31.000000000 -0700
86615 +++ 25/fs/hpfs/hpfs_fn.h        2003-10-05 00:33:24.000000000 -0700
86616 @@ -249,7 +249,7 @@ int hpfs_file_fsync(struct file *, struc
86617  secno hpfs_bmap(struct inode *, unsigned);
86618  void hpfs_truncate(struct inode *);
86619  int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create);
86620 -ssize_t hpfs_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos);
86621 +ssize_t hpfs_file_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos);
86622  
86623  /* inode.c */
86624  
86625 --- linux-2.6.0-test6/fs/hpfs/super.c   2003-06-22 12:04:44.000000000 -0700
86626 +++ 25/fs/hpfs/super.c  2003-10-05 00:33:24.000000000 -0700
86627 @@ -10,6 +10,7 @@
86628  #include <linux/string.h>
86629  #include "hpfs_fn.h"
86630  #include <linux/module.h>
86631 +#include <linux/parser.h>
86632  #include <linux/init.h>
86633  #include <linux/vfs.h>
86634  
86635 @@ -219,15 +220,52 @@ static struct super_operations hpfs_sops
86636  
86637  /*
86638   * A tiny parser for option strings, stolen from dosfs.
86639 - *
86640   * Stolen again from read-only hpfs.
86641 + * And updated for table-driven option parsing.
86642   */
86643  
86644 +enum {
86645 +       Opt_help, Opt_uid, Opt_gid, Opt_umask, Opt_case_lower, Opt_case_asis,
86646 +       Opt_conv_binary, Opt_conv_text, Opt_conv_auto,
86647 +       Opt_check_none, Opt_check_normal, Opt_check_strict,
86648 +       Opt_err_cont, Opt_err_ro, Opt_err_panic,
86649 +       Opt_eas_no, Opt_eas_ro, Opt_eas_rw,
86650 +       Opt_chkdsk_no, Opt_chkdsk_errors, Opt_chkdsk_always,
86651 +       Opt_timeshift, Opt_err,
86652 +};
86653 +
86654 +static match_table_t tokens = {
86655 +       {Opt_help, "help"},
86656 +       {Opt_uid, "uid=%u"},
86657 +       {Opt_gid, "gid=%u"},
86658 +       {Opt_umask, "umask=%o"},
86659 +       {Opt_case_lower, "case=lower"},
86660 +       {Opt_case_asis, "case=asis"},
86661 +       {Opt_conv_binary, "conv=binary"},
86662 +       {Opt_conv_text, "conv=text"},
86663 +       {Opt_conv_auto, "conv=auto"},
86664 +       {Opt_check_none, "check=none"},
86665 +       {Opt_check_normal, "check=normal"},
86666 +       {Opt_check_strict, "check=strict"},
86667 +       {Opt_err_cont, "errors=continue"},
86668 +       {Opt_err_ro, "errors=remount-ro"},
86669 +       {Opt_err_panic, "errors=panic"},
86670 +       {Opt_eas_no, "eas=no"},
86671 +       {Opt_eas_ro, "eas=ro"},
86672 +       {Opt_eas_rw, "eas=rw"},
86673 +       {Opt_chkdsk_no, "chkdsk=no"},
86674 +       {Opt_chkdsk_errors, "chkdsk=errors"},
86675 +       {Opt_chkdsk_always, "chkdsk=always"},
86676 +       {Opt_timeshift, "timeshift=%d"},
86677 +       {Opt_err, NULL},
86678 +};
86679 +
86680  int parse_opts(char *opts, uid_t *uid, gid_t *gid, umode_t *umask,
86681                int *lowercase, int *conv, int *eas, int *chk, int *errs,
86682                int *chkdsk, int *timeshift)
86683  {
86684 -       char *p, *rhs;
86685 +       char *p;
86686 +       int option;
86687  
86688         if (!opts)
86689                 return 1;
86690 @@ -235,34 +273,85 @@ int parse_opts(char *opts, uid_t *uid, g
86691         /*printk("Parsing opts: '%s'\n",opts);*/
86692  
86693         while ((p = strsep(&opts, ",")) != NULL) {
86694 +               substring_t args[MAX_OPT_ARGS];
86695 +               int token;
86696                 if (!*p)
86697                         continue;
86698 -               if ((rhs = strchr(p, '=')) != 0)
86699 -                       *rhs++ = '\0';
86700 -               if (!strcmp(p, "help")) return 2;
86701 -               if (!strcmp(p, "uid")) {
86702 -                       if (!rhs || !*rhs)
86703 -                               return 0;
86704 -                       *uid = simple_strtoul(rhs, &rhs, 0);
86705 -                       if (*rhs)
86706 -                               return 0;
86707 -               }
86708 -               else if (!strcmp(p, "gid")) {
86709 -                       if (!rhs || !*rhs)
86710 -                               return 0;
86711 -                       *gid = simple_strtoul(rhs, &rhs, 0);
86712 -                       if (*rhs)
86713 -                               return 0;
86714 -               }
86715 -               else if (!strcmp(p, "umask")) {
86716 -                       if (!rhs || !*rhs)
86717 -                               return 0;
86718 -                       *umask = simple_strtoul(rhs, &rhs, 8);
86719 -                       if (*rhs)
86720 -                               return 0;
86721 -               }
86722 -               else if (!strcmp(p, "timeshift")) {
86723 +
86724 +               token = match_token(p, tokens, args);
86725 +               switch (token) {
86726 +               case Opt_help:
86727 +                       return 2;
86728 +               case Opt_uid:
86729 +                       if (match_int(args, &option))
86730 +                               return 0;
86731 +                       *uid = option;
86732 +                       break;
86733 +               case Opt_gid:
86734 +                       if (match_int(args, &option))
86735 +                               return 0;
86736 +                       *gid = option;
86737 +                       break;
86738 +               case Opt_umask:
86739 +                       if (match_octal(args, &option))
86740 +                               return 0;
86741 +                       *umask = option;
86742 +                       break;
86743 +               case Opt_case_lower:
86744 +                       *lowercase = 1;
86745 +                       break;
86746 +               case Opt_case_asis:
86747 +                       *lowercase = 0;
86748 +                       break;
86749 +               case Opt_conv_binary:
86750 +                       *conv = CONV_BINARY;
86751 +                       break;
86752 +               case Opt_conv_text:
86753 +                       *conv = CONV_TEXT;
86754 +                       break;
86755 +               case Opt_conv_auto:
86756 +                       *conv = CONV_AUTO;
86757 +                       break;
86758 +               case Opt_check_none:
86759 +                       *chk = 0;
86760 +                       break;
86761 +               case Opt_check_normal:
86762 +                       *chk = 1;
86763 +                       break;
86764 +               case Opt_check_strict:
86765 +                       *chk = 2;
86766 +                       break;
86767 +               case Opt_err_cont:
86768 +                       *errs = 0;
86769 +                       break;
86770 +               case Opt_err_ro:
86771 +                       *errs = 1;
86772 +                       break;
86773 +               case Opt_err_panic:
86774 +                       *errs = 2;
86775 +                       break;
86776 +               case Opt_eas_no:
86777 +                       *eas = 0;
86778 +                       break;
86779 +               case Opt_eas_ro:
86780 +                       *eas = 1;
86781 +                       break;
86782 +               case Opt_eas_rw:
86783 +                       *eas = 2;
86784 +                       break;
86785 +               case Opt_chkdsk_no:
86786 +                       *chkdsk = 0;
86787 +                       break;
86788 +               case Opt_chkdsk_errors:
86789 +                       *chkdsk = 1;
86790 +                       break;
86791 +               case Opt_chkdsk_always:
86792 +                       *chkdsk = 2;
86793 +                       break;
86794 +               case Opt_timeshift:
86795 +               {
86796                         int m = 1;
86797 +                       char *rhs = args[0].from;
86798                         if (!rhs || !*rhs)
86799                                 return 0;
86800                         if (*rhs == '-') m = -1;
86801 @@ -270,79 +359,11 @@ int parse_opts(char *opts, uid_t *uid, g
86802                         *timeshift = simple_strtoul(rhs, &rhs, 0) * m;
86803                         if (*rhs)
86804                                 return 0;
86805 +                       break;
86806                 }
86807 -               else if (!strcmp(p, "case")) {
86808 -                       if (!rhs || !*rhs)
86809 -                               return 0;
86810 -                       if (!strcmp(rhs, "lower"))
86811 -                               *lowercase = 1;
86812 -                       else if (!strcmp(rhs, "asis"))
86813 -                               *lowercase = 0;
86814 -                       else
86815 -                               return 0;
86816 -               }
86817 -               else if (!strcmp(p, "conv")) {
86818 -                       if (!rhs || !*rhs)
86819 -                               return 0;
86820 -                       if (!strcmp(rhs, "binary"))
86821 -                               *conv = CONV_BINARY;
86822 -                       else if (!strcmp(rhs, "text"))
86823 -                               *conv = CONV_TEXT;
86824 -                       else if (!strcmp(rhs, "auto"))
86825 -                               *conv = CONV_AUTO;
86826 -                       else
86827 -                               return 0;
86828 -               }
86829 -               else if (!strcmp(p, "check")) {
86830 -                       if (!rhs || !*rhs)
86831 -                               return 0;
86832 -                       if (!strcmp(rhs, "none"))
86833 -                               *chk = 0;
86834 -                       else if (!strcmp(rhs, "normal"))
86835 -                               *chk = 1;
86836 -                       else if (!strcmp(rhs, "strict"))
86837 -                               *chk = 2;
86838 -                       else
86839 -                               return 0;
86840 -               }
86841 -               else if (!strcmp(p, "errors")) {
86842 -                       if (!rhs || !*rhs)
86843 -                               return 0;
86844 -                       if (!strcmp(rhs, "continue"))
86845 -                               *errs = 0;
86846 -                       else if (!strcmp(rhs, "remount-ro"))
86847 -                               *errs = 1;
86848 -                       else if (!strcmp(rhs, "panic"))
86849 -                               *errs = 2;
86850 -                       else
86851 -                               return 0;
86852 -               }
86853 -               else if (!strcmp(p, "eas")) {
86854 -                       if (!rhs || !*rhs)
86855 -                               return 0;
86856 -                       if (!strcmp(rhs, "no"))
86857 -                               *eas = 0;
86858 -                       else if (!strcmp(rhs, "ro"))
86859 -                               *eas = 1;
86860 -                       else if (!strcmp(rhs, "rw"))
86861 -                               *eas = 2;
86862 -                       else
86863 -                               return 0;
86864 -               }
86865 -               else if (!strcmp(p, "chkdsk")) {
86866 -                       if (!rhs || !*rhs)
86867 -                               return 0;
86868 -                       if (!strcmp(rhs, "no"))
86869 -                               *chkdsk = 0;
86870 -                       else if (!strcmp(rhs, "errors"))
86871 -                               *chkdsk = 1;
86872 -                       else if (!strcmp(rhs, "always"))
86873 -                               *chkdsk = 2;
86874 -                       else
86875 -                               return 0;
86876 -               }
86877 -               else
86878 +               default:
86879                         return 0;
86880 +               }
86881         }
86882         return 1;
86883  }
86884 --- linux-2.6.0-test6/fs/hugetlbfs/inode.c      2003-09-27 18:57:46.000000000 -0700
86885 +++ 25/fs/hugetlbfs/inode.c     2003-10-05 00:37:03.000000000 -0700
86886 @@ -165,7 +165,7 @@ void truncate_hugepages(struct address_s
86887         pagevec_init(&pvec, 0);
86888         next = start;
86889         while (1) {
86890 -               if (!pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)) {
86891 +               if (!pagevec_lookup(&pvec, mapping, &next, PAGEVEC_SIZE)) {
86892                         if (next == start)
86893                                 break;
86894                         next = start;
86895 @@ -176,9 +176,6 @@ void truncate_hugepages(struct address_s
86896                         struct page *page = pvec.pages[i];
86897  
86898                         lock_page(page);
86899 -                       if (page->index > next)
86900 -                               next = page->index;
86901 -                       ++next;
86902                         truncate_huge_page(page);
86903                         unlock_page(page);
86904                         hugetlb_put_quota(mapping);
86905 @@ -648,11 +645,6 @@ hugetlbfs_fill_super(struct super_block 
86906         struct hugetlbfs_config config;
86907         struct hugetlbfs_sb_info *sbinfo;
86908  
86909 -       sbinfo = kmalloc(sizeof(struct hugetlbfs_sb_info), GFP_KERNEL);
86910 -       if (!sbinfo)
86911 -               return -ENOMEM;
86912 -       sb->s_fs_info = sbinfo;
86913 -
86914         config.nr_blocks = -1; /* No limit on size by default */
86915         config.nr_inodes = -1; /* No limit on number of inodes by default */
86916         config.uid = current->fsuid;
86917 @@ -663,6 +655,10 @@ hugetlbfs_fill_super(struct super_block 
86918         if (ret)
86919                 return ret;
86920  
86921 +       sbinfo = kmalloc(sizeof(struct hugetlbfs_sb_info), GFP_KERNEL);
86922 +       if (!sbinfo)
86923 +               return -ENOMEM;
86924 +       sb->s_fs_info = sbinfo;
86925         spin_lock_init(&sbinfo->stat_lock);
86926         sbinfo->max_blocks = config.nr_blocks;
86927         sbinfo->free_blocks = config.nr_blocks;
86928 @@ -675,15 +671,18 @@ hugetlbfs_fill_super(struct super_block 
86929         inode = hugetlbfs_get_inode(sb, config.uid, config.gid,
86930                                         S_IFDIR | config.mode, 0);
86931         if (!inode)
86932 -               return -ENOMEM;
86933 +               goto out_free;
86934  
86935         root = d_alloc_root(inode);
86936         if (!root) {
86937                 iput(inode);
86938 -               return -ENOMEM;
86939 +               goto out_free;
86940         }
86941         sb->s_root = root;
86942         return 0;
86943 +out_free:
86944 +       kfree(sbinfo);
86945 +       return -ENOMEM;
86946  }
86947  
86948  int hugetlb_get_quota(struct address_space *mapping)
86949 @@ -772,6 +771,7 @@ struct file *hugetlb_zero_setup(size_t s
86950         inode->i_nlink = 0;
86951         file->f_vfsmnt = mntget(hugetlbfs_vfsmount);
86952         file->f_dentry = dentry;
86953 +       file->f_mapping = inode->i_mapping;
86954         file->f_op = &hugetlbfs_file_operations;
86955         file->f_mode = FMODE_WRITE | FMODE_READ;
86956         return file;
86957 --- linux-2.6.0-test6/fs/inode.c        2003-09-08 13:58:58.000000000 -0700
86958 +++ 25/fs/inode.c       2003-10-05 00:36:52.000000000 -0700
86959 @@ -183,6 +183,7 @@ void inode_init_once(struct inode *inode
86960         INIT_LIST_HEAD(&inode->i_dentry);
86961         INIT_LIST_HEAD(&inode->i_devices);
86962         sema_init(&inode->i_sem, 1);
86963 +       init_rwsem(&inode->i_alloc_sem);
86964         INIT_RADIX_TREE(&inode->i_data.page_tree, GFP_ATOMIC);
86965         spin_lock_init(&inode->i_data.page_lock);
86966         init_MUTEX(&inode->i_data.i_shared_sem);
86967 @@ -195,6 +196,8 @@ void inode_init_once(struct inode *inode
86968         i_size_ordered_init(inode);
86969  }
86970  
86971 +EXPORT_SYMBOL(inode_init_once);
86972 +
86973  static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
86974  {
86975         struct inode * inode = (struct inode *) foo;
86976 @@ -229,7 +232,6 @@ void __iget(struct inode * inode)
86977   * that the inode is no longer useful. We just
86978   * terminate it with extreme prejudice.
86979   */
86980
86981  void clear_inode(struct inode *inode)
86982  {
86983         invalidate_inode_buffers(inode);
86984 @@ -251,7 +253,12 @@ void clear_inode(struct inode *inode)
86985         inode->i_state = I_CLEAR;
86986  }
86987  
86988 +EXPORT_SYMBOL(clear_inode);
86989 +
86990  /*
86991 + * dispose_list - dispose of the contents of a local list
86992 + * @head: the head of the list to free
86993 + *
86994   * Dispose-list gets a local list with local inodes in it, so it doesn't
86995   * need to worry about list corruption and SMP locks.
86996   */
86997 @@ -327,7 +334,6 @@ static int invalidate_list(struct list_h
86998   *     fails because there are busy inodes then a non zero value is returned.
86999   *     If the discard is successful all the inodes have been discarded.
87000   */
87001
87002  int invalidate_inodes(struct super_block * sb)
87003  {
87004         int busy;
87005 @@ -346,6 +352,8 @@ int invalidate_inodes(struct super_block
87006  
87007         return busy;
87008  }
87009 +
87010 +EXPORT_SYMBOL(invalidate_inodes);
87011   
87012  int __invalidate_device(struct block_device *bdev, int do_sync)
87013  {
87014 @@ -372,6 +380,8 @@ int __invalidate_device(struct block_dev
87015         return res;
87016  }
87017  
87018 +EXPORT_SYMBOL(__invalidate_device);
87019 +
87020  static int can_unuse(struct inode *inode)
87021  {
87022         if (inode->i_state)
87023 @@ -532,7 +542,6 @@ repeat:
87024   *
87025   *     Allocates a new inode for given superblock.
87026   */
87027
87028  struct inode *new_inode(struct super_block *sb)
87029  {
87030         static unsigned long last_ino;
87031 @@ -552,6 +561,8 @@ struct inode *new_inode(struct super_blo
87032         return inode;
87033  }
87034  
87035 +EXPORT_SYMBOL(new_inode);
87036 +
87037  void unlock_new_inode(struct inode *inode)
87038  {
87039         /*
87040 @@ -565,6 +576,7 @@ void unlock_new_inode(struct inode *inod
87041         inode->i_state &= ~(I_LOCK|I_NEW);
87042         wake_up_inode(inode);
87043  }
87044 +
87045  EXPORT_SYMBOL(unlock_new_inode);
87046  
87047  /*
87048 @@ -685,7 +697,6 @@ static inline unsigned long hash(struct 
87049   *     With a large number of inodes live on the file system this function
87050   *     currently becomes quite slow.
87051   */
87052
87053  ino_t iunique(struct super_block *sb, ino_t max_reserved)
87054  {
87055         static ino_t counter;
87056 @@ -709,6 +720,8 @@ retry:
87057         
87058  }
87059  
87060 +EXPORT_SYMBOL(iunique);
87061 +
87062  struct inode *igrab(struct inode *inode)
87063  {
87064         spin_lock(&inode_lock);
87065 @@ -725,14 +738,16 @@ struct inode *igrab(struct inode *inode)
87066         return inode;
87067  }
87068  
87069 +EXPORT_SYMBOL(igrab);
87070 +
87071  /**
87072   * ifind - internal function, you want ilookup5() or iget5().
87073   * @sb:                super block of file system to search
87074 - * @hashval:   hash value (usually inode number) to search for
87075 + * @head:       the head of the list to search
87076   * @test:      callback used for comparisons between inodes
87077   * @data:      opaque data pointer to pass to @test
87078   *
87079 - * ifind() searches for the inode specified by @hashval and @data in the inode
87080 + * ifind() searches for the inode specified by @data in the inode
87081   * cache. This is a generalized version of ifind_fast() for file systems where
87082   * the inode number is not sufficient for unique identification of an inode.
87083   *
87084 @@ -764,6 +779,7 @@ static inline struct inode *ifind(struct
87085  /**
87086   * ifind_fast - internal function, you want ilookup() or iget().
87087   * @sb:                super block of file system to search
87088 + * @head:       head of the list to search
87089   * @ino:       inode number to search for
87090   *
87091   * ifind_fast() searches for the inode @ino in the inode cache. This is for
87092 @@ -818,6 +834,7 @@ struct inode *ilookup5(struct super_bloc
87093  
87094         return ifind(sb, head, test, data);
87095  }
87096 +
87097  EXPORT_SYMBOL(ilookup5);
87098  
87099  /**
87100 @@ -840,6 +857,7 @@ struct inode *ilookup(struct super_block
87101  
87102         return ifind_fast(sb, head, ino);
87103  }
87104 +
87105  EXPORT_SYMBOL(ilookup);
87106  
87107  /**
87108 @@ -880,6 +898,7 @@ struct inode *iget5_locked(struct super_
87109          */
87110         return get_new_inode(sb, head, test, set, data);
87111  }
87112 +
87113  EXPORT_SYMBOL(iget5_locked);
87114  
87115  /**
87116 @@ -913,6 +932,7 @@ struct inode *iget_locked(struct super_b
87117          */
87118         return get_new_inode_fast(sb, head, ino);
87119  }
87120 +
87121  EXPORT_SYMBOL(iget_locked);
87122  
87123  /**
87124 @@ -923,7 +943,6 @@ EXPORT_SYMBOL(iget_locked);
87125   *
87126   *     Add an inode to the inode hash for this superblock.
87127   */
87128
87129  void __insert_inode_hash(struct inode *inode, unsigned long hashval)
87130  {
87131         struct hlist_head *head = inode_hashtable + hash(inode->i_sb, hashval);
87132 @@ -932,13 +951,14 @@ void __insert_inode_hash(struct inode *i
87133         spin_unlock(&inode_lock);
87134  }
87135  
87136 +EXPORT_SYMBOL(__insert_inode_hash);
87137 +
87138  /**
87139   *     remove_inode_hash - remove an inode from the hash
87140   *     @inode: inode to unhash
87141   *
87142   *     Remove an inode from the superblock.
87143   */
87144
87145  void remove_inode_hash(struct inode *inode)
87146  {
87147         spin_lock(&inode_lock);
87148 @@ -946,6 +966,8 @@ void remove_inode_hash(struct inode *ino
87149         spin_unlock(&inode_lock);
87150  }
87151  
87152 +EXPORT_SYMBOL(remove_inode_hash);
87153 +
87154  /*
87155   * Tell the filesystem that this inode is no longer of any interest and should
87156   * be completely destroyed.
87157 @@ -988,6 +1010,7 @@ void generic_delete_inode(struct inode *
87158                 BUG();
87159         destroy_inode(inode);
87160  }
87161 +
87162  EXPORT_SYMBOL(generic_delete_inode);
87163  
87164  static void generic_forget_inode(struct inode *inode)
87165 @@ -1059,7 +1082,6 @@ static inline void iput_final(struct ino
87166   *     Puts an inode, dropping its usage count. If the inode use count hits
87167   *     zero the inode is also then freed and may be destroyed.
87168   */
87169
87170  void iput(struct inode *inode)
87171  {
87172         if (inode) {
87173 @@ -1076,6 +1098,8 @@ void iput(struct inode *inode)
87174         }
87175  }
87176  
87177 +EXPORT_SYMBOL(iput);
87178 +
87179  /**
87180   *     bmap    - find a block number in a file
87181   *     @inode: inode of file
87182 @@ -1087,7 +1111,6 @@ void iput(struct inode *inode)
87183   *     disk block relative to the disk start that holds that block of the 
87184   *     file.
87185   */
87186
87187  sector_t bmap(struct inode * inode, sector_t block)
87188  {
87189         sector_t res = 0;
87190 @@ -1096,6 +1119,8 @@ sector_t bmap(struct inode * inode, sect
87191         return res;
87192  }
87193  
87194 +EXPORT_SYMBOL(bmap);
87195 +
87196  /*
87197   * Return true if the filesystem which backs this inode considers the two
87198   * passed timespecs to be sufficiently different to warrant flushing the
87199 @@ -1117,7 +1142,6 @@ static int inode_times_differ(struct ino
87200   *     This function automatically handles read only file systems and media,
87201   *     as well as the "noatime" flag and inode specific "noatime" markers.
87202   */
87203
87204  void update_atime(struct inode *inode)
87205  {
87206         struct timespec now;
87207 @@ -1139,6 +1163,8 @@ void update_atime(struct inode *inode)
87208         }
87209  }
87210  
87211 +EXPORT_SYMBOL(update_atime);
87212 +
87213  /**
87214   *     inode_update_time       -       update mtime and ctime time
87215   *     @inode: inode accessed
87216 @@ -1170,6 +1196,7 @@ void inode_update_time(struct inode *ino
87217         if (sync_it)
87218                 mark_inode_dirty_sync(inode);
87219  }
87220 +
87221  EXPORT_SYMBOL(inode_update_time);
87222  
87223  int inode_needs_sync(struct inode *inode)
87224 @@ -1180,6 +1207,7 @@ int inode_needs_sync(struct inode *inode
87225                 return 1;
87226         return 0;
87227  }
87228 +
87229  EXPORT_SYMBOL(inode_needs_sync);
87230  
87231  /*
87232 @@ -1375,3 +1403,5 @@ void init_special_inode(struct inode *in
87233                 printk(KERN_DEBUG "init_special_inode: bogus i_mode (%o)\n",
87234                        mode);
87235  }
87236 +
87237 +EXPORT_SYMBOL(init_special_inode);
87238 --- linux-2.6.0-test6/fs/intermezzo/file.c      2003-09-27 18:57:46.000000000 -0700
87239 +++ 25/fs/intermezzo/file.c     2003-10-05 00:34:01.000000000 -0700
87240 @@ -337,7 +337,7 @@ static void presto_apply_write_policy(st
87241                                  unlock_kernel();
87242                                  return; 
87243                          }
87244 -                        error = presto_journal_close(&rec, fset, file,
87245 +                        error = presto_journal_close(&rec, fset, fdata,
87246                                                       file->f_dentry,
87247                                                       &fdata->fd_version,
87248                                                       &new_file_ver);
87249 --- linux-2.6.0-test6/fs/intermezzo/intermezzo_fs.h     2003-07-10 18:50:31.000000000 -0700
87250 +++ 25/fs/intermezzo/intermezzo_fs.h    2003-10-05 00:34:01.000000000 -0700
87251 @@ -603,7 +603,7 @@ int presto_journal_rename(struct rec_inf
87252  int presto_journal_open(struct rec_info *, struct presto_file_set *,
87253                          struct dentry *, struct presto_version *old_ver);
87254  int presto_journal_close(struct rec_info *rec, struct presto_file_set *,
87255 -                         struct file *, struct dentry *,
87256 +                         struct presto_file_data *, struct dentry *,
87257                           struct presto_version *old_file_ver,
87258                           struct presto_version *new_file_ver);
87259  int presto_write_lml_close(struct rec_info *rec,
87260 --- linux-2.6.0-test6/fs/intermezzo/journal.c   2003-09-27 18:57:46.000000000 -0700
87261 +++ 25/fs/intermezzo/journal.c  2003-10-05 00:34:01.000000000 -0700
87262 @@ -2104,12 +2104,11 @@ int presto_journal_unlink(struct rec_inf
87263  
87264  int
87265  presto_journal_close(struct rec_info *rec, struct presto_file_set *fset,
87266 -                     struct file *file, struct dentry *dentry,
87267 +                     struct presto_file_data *fd, struct dentry *dentry,
87268                       struct presto_version *old_file_ver,
87269                       struct presto_version *new_file_ver)
87270  {
87271          int opcode = KML_OPCODE_CLOSE;
87272 -        struct presto_file_data *fd;
87273          char *buffer, *path, *logrecord, record[316];
87274          struct dentry *root;
87275          int error, size, i;
87276 @@ -2138,7 +2137,6 @@ presto_journal_close(struct rec_info *re
87277  
87278          root = fset->fset_dentry;
87279  
87280 -        fd = (struct presto_file_data *)file->private_data;
87281          if (fd) {
87282                  open_ngroups = fd->fd_ngroups;
87283                  for (i = 0; i < fd->fd_ngroups; i++)
87284 --- linux-2.6.0-test6/fs/intermezzo/presto.c    2003-09-27 18:57:46.000000000 -0700
87285 +++ 25/fs/intermezzo/presto.c   2003-10-05 00:34:01.000000000 -0700
87286 @@ -260,11 +260,8 @@ int lento_cancel_lml(char *path, 
87287  
87288  
87289          if (info->flags & LENTO_FL_WRITE_KML) {
87290 -                struct file file;
87291 -                file.private_data = NULL;
87292 -                file.f_dentry = dentry; 
87293                  presto_getversion(&new_ver, dentry->d_inode);
87294 -                error = presto_journal_close(&rec, fset, &file, dentry, 
87295 +                error = presto_journal_close(&rec, fset, NULL, dentry, 
87296                                               &new_ver);
87297                  if ( error ) {
87298                          EXIT; 
87299 --- linux-2.6.0-test6/fs/intermezzo/vfs.c       2003-09-08 13:58:58.000000000 -0700
87300 +++ 25/fs/intermezzo/vfs.c      2003-10-05 00:34:03.000000000 -0700
87301 @@ -322,7 +322,7 @@ int presto_do_close(struct presto_file_s
87302          }
87303  
87304          if (fdata->fd_info.flags & LENTO_FL_KML) 
87305 -                rc = presto_journal_close(&rec, fset, file, file->f_dentry,
87306 +                rc = presto_journal_close(&rec, fset, fdata, file->f_dentry,
87307                                            &fdata->fd_version, 
87308                                            &fdata->fd_info.remote_version);
87309          if (rc) { 
87310 @@ -432,14 +432,11 @@ int presto_do_setattr(struct presto_file
87311  
87312          if ( presto_do_kml(info, dentry) ) {
87313                  if ((iattr->ia_valid & ATTR_SIZE) && (old_size != inode->i_size)) {
87314 -                        struct file file;
87315                          /* Journal a close whenever we see a potential truncate
87316                          * At the receiving end, lento should explicitly remove
87317                          * ATTR_SIZE from the list of valid attributes */
87318                          presto_getversion(&new_ver, inode);
87319 -                        file.private_data = NULL;
87320 -                        file.f_dentry = dentry;
87321 -                        error = presto_journal_close(&rec, fset, &file, dentry,
87322 +                        error = presto_journal_close(&rec, fset, NULL, dentry,
87323                                                       &old_ver, &new_ver);
87324                  }
87325  
87326 @@ -2087,7 +2084,9 @@ static struct file *presto_filp_dopen(st
87327                  }
87328          }
87329  
87330 +       /* XXX: where the fuck is ->f_vfsmnt? */
87331          f->f_dentry = dentry;
87332 +        f->f_mapping = dentry->d_inode->i_mapping;
87333          f->f_pos = 0;
87334          //f->f_reada = 0;
87335          f->f_op = NULL;
87336 --- linux-2.6.0-test6/fs/ioctl.c        2003-07-13 21:44:35.000000000 -0700
87337 +++ 25/fs/ioctl.c       2003-10-05 00:34:08.000000000 -0700
87338 @@ -22,7 +22,7 @@ static int file_ioctl(struct file *filp,
87339         switch (cmd) {
87340                 case FIBMAP:
87341                 {
87342 -                       struct address_space *mapping = inode->i_mapping;
87343 +                       struct address_space *mapping = filp->f_mapping;
87344                         int res;
87345                         /* do we support this mess? */
87346                         if (!mapping->a_ops->bmap)
87347 --- linux-2.6.0-test6/fs/isofs/inode.c  2003-09-08 13:58:58.000000000 -0700
87348 +++ 25/fs/isofs/inode.c 2003-10-05 00:33:24.000000000 -0700
87349 @@ -29,6 +29,7 @@
87350  #include <linux/blkdev.h>
87351  #include <linux/buffer_head.h>
87352  #include <linux/vfs.h>
87353 +#include <linux/parser.h>
87354  #include <asm/system.h>
87355  #include <asm/uaccess.h>
87356  
87357 @@ -328,9 +329,52 @@ isofs_dentry_cmpi_ms(struct dentry *dent
87358  }
87359  #endif
87360  
87361 +enum {
87362 +       Opt_block, Opt_check_r, Opt_check_s, Opt_cruft, Opt_gid, Opt_ignore,
87363 +       Opt_iocharset, Opt_map_a, Opt_map_n, Opt_map_o, Opt_mode, Opt_nojoliet,
87364 +       Opt_norock, Opt_sb, Opt_session, Opt_uid, Opt_unhide, Opt_utf8, Opt_err,
87365 +       Opt_nocompress,
87366 +};
87367 +
87368 +static match_table_t tokens = {
87369 +       {Opt_norock, "norock"},
87370 +       {Opt_nojoliet, "nojoliet"},
87371 +       {Opt_unhide, "unhide"},
87372 +       {Opt_cruft, "cruft"},
87373 +       {Opt_utf8, "utf8"},
87374 +       {Opt_iocharset, "iocharset=%s"},
87375 +       {Opt_map_a, "map=acorn"},
87376 +       {Opt_map_a, "map=a"},
87377 +       {Opt_map_n, "map=normal"},
87378 +       {Opt_map_n, "map=n"},
87379 +       {Opt_map_o, "map=off"},
87380 +       {Opt_map_o, "map=o"},
87381 +       {Opt_session, "session=%u"},
87382 +       {Opt_sb, "sbsector=%u"},
87383 +       {Opt_check_r, "check=relaxed"},
87384 +       {Opt_check_r, "check=r"},
87385 +       {Opt_check_s, "check=strict"},
87386 +       {Opt_check_s, "check=s"},
87387 +       {Opt_uid, "uid=%u"},
87388 +       {Opt_gid, "gid=%u"},
87389 +       {Opt_mode, "mode=%u"},
87390 +       {Opt_block, "block=%u"},
87391 +       {Opt_ignore, "conv=binary"},
87392 +       {Opt_ignore, "conv=b"},
87393 +       {Opt_ignore, "conv=text"},
87394 +       {Opt_ignore, "conv=t"},
87395 +       {Opt_ignore, "conv=mtext"},
87396 +       {Opt_ignore, "conv=m"},
87397 +       {Opt_ignore, "conv=auto"},
87398 +       {Opt_ignore, "conv=a"},
87399 +       {Opt_nocompress, "nocompress"},
87400 +       {Opt_err, NULL}
87401 +};
87402 +
87403  static int parse_options(char *options, struct iso9660_options * popt)
87404  {
87405 -       char *this_char,*value;
87406 +       char *p;
87407 +       int option;
87408  
87409         popt->map = 'n';
87410         popt->rock = 'y';
87411 @@ -350,112 +394,101 @@ static int parse_options(char *options, 
87412         popt->utf8 = 0;
87413         popt->session=-1;
87414         popt->sbsector=-1;
87415 -       if (!options) return 1;
87416 -       while ((this_char = strsep(&options,",")) != NULL) {
87417 -               if (!*this_char)
87418 +       if (!options)
87419 +               return 1;
87420 +
87421 +       while ((p = strsep(&options, ",")) != NULL) {
87422 +               int token;
87423 +               substring_t args[MAX_OPT_ARGS];
87424 +               unsigned n;
87425 +
87426 +               if (!*p)
87427                         continue;
87428 -               if (strncmp(this_char,"norock",6) == 0) {
87429 -                 popt->rock = 'n';
87430 -                 continue;
87431 -               }
87432 -               if (strncmp(this_char,"nojoliet",8) == 0) {
87433 -                 popt->joliet = 'n';
87434 -                 continue;
87435 -               }
87436 -               if (strncmp(this_char,"unhide",6) == 0) {
87437 -                 popt->unhide = 'y';
87438 -                 continue;
87439 -               }
87440 -               if (strncmp(this_char,"cruft",5) == 0) {
87441 -                 popt->cruft = 'y';
87442 -                 continue;
87443 -               }
87444 -               if (strncmp(this_char,"utf8",4) == 0) {
87445 -                 popt->utf8 = 1;
87446 -                 continue;
87447 -               }
87448 -               if (strncmp(this_char,"nocompress",10) == 0) {
87449 -                 popt->nocompress = 1;
87450 -                 continue;
87451 -               }
87452 -               if ((value = strchr(this_char,'=')) != NULL)
87453 -                       *value++ = 0;
87454  
87455 +               token = match_token(p, tokens, args);
87456 +               switch (token) {
87457 +               case Opt_norock:
87458 +                       popt->rock = 'n';
87459 +                       break;
87460 +               case Opt_nojoliet:
87461 +                       popt->joliet = 'n';
87462 +                       break;
87463 +               case Opt_unhide:
87464 +                       popt->unhide = 'y';
87465 +                       break;
87466 +               case Opt_cruft:
87467 +                       popt->cruft = 'y';
87468 +                       break;
87469 +               case Opt_utf8:
87470 +                       popt->utf8 = 1;
87471 +                       break;
87472  #ifdef CONFIG_JOLIET
87473 -               if (!strcmp(this_char,"iocharset") && value) {
87474 -                       popt->iocharset = value;
87475 -                       while (*value && *value != ',')
87476 -                               value++;
87477 -                       if (value == popt->iocharset)
87478 -                               return 0;
87479 -                       *value = 0;
87480 -               } else
87481 +               case Opt_iocharset:
87482 +                       popt->iocharset = match_strdup(&args[0]);
87483 +                       break;
87484  #endif
87485 -               if (!strcmp(this_char,"map") && value) {
87486 -                       if (value[0] && !value[1] && strchr("ano",*value))
87487 -                               popt->map = *value;
87488 -                       else if (!strcmp(value,"off")) popt->map = 'o';
87489 -                       else if (!strcmp(value,"normal")) popt->map = 'n';
87490 -                       else if (!strcmp(value,"acorn")) popt->map = 'a';
87491 -                       else return 0;
87492 -               }
87493 -               if (!strcmp(this_char,"session") && value) {
87494 -                       char * vpnt = value;
87495 -                       unsigned int ivalue = simple_strtoul(vpnt, &vpnt, 0);
87496 -                       if(ivalue < 0 || ivalue >99) return 0;
87497 -                       popt->session=ivalue+1;
87498 -               }
87499 -               if (!strcmp(this_char,"sbsector") && value) {
87500 -                       char * vpnt = value;
87501 -                       unsigned int ivalue = simple_strtoul(vpnt, &vpnt, 0);
87502 -                       if(ivalue < 0 || ivalue >660*512) return 0;
87503 -                       popt->sbsector=ivalue;
87504 -               }
87505 -               else if (!strcmp(this_char,"check") && value) {
87506 -                       if (value[0] && !value[1] && strchr("rs",*value))
87507 -                               popt->check = *value;
87508 -                       else if (!strcmp(value,"relaxed")) popt->check = 'r';
87509 -                       else if (!strcmp(value,"strict")) popt->check = 's';
87510 -                       else return 0;
87511 -               }
87512 -               else if (!strcmp(this_char,"conv") && value) {
87513 -                       /* no conversion is done anymore;
87514 -                          we still accept the same mount options,
87515 -                          but ignore them */
87516 -                       if (value[0] && !value[1] && strchr("btma",*value)) ;
87517 -                       else if (!strcmp(value,"binary")) ;
87518 -                       else if (!strcmp(value,"text")) ;
87519 -                       else if (!strcmp(value,"mtext")) ;
87520 -                       else if (!strcmp(value,"auto")) ;
87521 -                       else return 0;
87522 -               }
87523 -               else if (value &&
87524 -                        (!strcmp(this_char,"block") ||
87525 -                         !strcmp(this_char,"mode") ||
87526 -                         !strcmp(this_char,"uid") ||
87527 -                         !strcmp(this_char,"gid"))) {
87528 -                 char * vpnt = value;
87529 -                 unsigned int ivalue = simple_strtoul(vpnt, &vpnt, 0);
87530 -                 if (*vpnt) return 0;
87531 -                 switch(*this_char) {
87532 -                 case 'b':
87533 -                   if (   ivalue != 512
87534 -                       && ivalue != 1024
87535 -                       && ivalue != 2048) return 0;
87536 -                   popt->blocksize = ivalue;
87537 -                   break;
87538 -                 case 'u':
87539 -                   popt->uid = ivalue;
87540 -                   break;
87541 -                 case 'g':
87542 -                   popt->gid = ivalue;
87543 -                   break;
87544 -                 case 'm':
87545 -                   popt->mode = ivalue;
87546 -                   break;
87547 -                 }
87548 +               case Opt_map_a:
87549 +                       popt->map = 'a';
87550 +                       break;
87551 +               case Opt_map_o:
87552 +                       popt->map = 'o';
87553 +                       break;
87554 +               case Opt_map_n:
87555 +                       popt->map = 'n';
87556 +                       break;
87557 +               case Opt_session:
87558 +                       if (match_int(&args[0], &option))
87559 +                               return 0;
87560 +                       n = option;
87561 +                       if (n > 99)
87562 +                               return 0;
87563 +                       popt->session = n + 1;
87564 +                       break;
87565 +               case Opt_sb:
87566 +                       if (match_int(&args[0], &option))
87567 +                               return 0;
87568 +                       n = option;
87569 +                       if (n > 660 * 512)
87570 +                               return 0;
87571 +                       popt->sbsector = n;
87572 +                       break;
87573 +               case Opt_check_r:
87574 +                       popt->check = 'r';
87575 +                       break;
87576 +               case Opt_check_s:
87577 +                       popt->check = 's';
87578 +                       break;
87579 +               case Opt_ignore:
87580 +                       break;
87581 +               case Opt_uid:
87582 +                       if (match_int(&args[0], &option))
87583 +                               return 0;
87584 +                       popt->uid = option;
87585 +                       break;
87586 +               case Opt_gid:
87587 +                       if (match_int(&args[0], &option))
87588 +                               return 0;
87589 +                       popt->gid = option;
87590 +                       break;
87591 +               case Opt_mode:
87592 +                       if (match_int(&args[0], &option))
87593 +                               return 0;
87594 +                       popt->mode = option;
87595 +                       break;
87596 +               case Opt_block:
87597 +                       if (match_int(&args[0], &option))
87598 +                               return 0;
87599 +                       n = option;
87600 +                       if (n != 512 && n != 1024 && n != 2048)
87601 +                               return 0;
87602 +                       popt->blocksize = n;
87603 +                       break;
87604 +               case Opt_nocompress:
87605 +                       popt->nocompress = 1;
87606 +                       break;
87607 +               default:
87608 +                       return 0;
87609                 }
87610 -               else return 1;
87611         }
87612         return 1;
87613  }
87614 @@ -842,6 +875,9 @@ root_found:
87615         if (opt.check == 'r') table++;
87616         s->s_root->d_op = &isofs_dentry_ops[table];
87617  
87618 +       if (opt.iocharset)
87619 +               kfree(opt.iocharset);
87620 +
87621         return 0;
87622  
87623         /*
87624 @@ -879,6 +915,8 @@ out_unknown_format:
87625  out_freebh:
87626         brelse(bh);
87627  out_freesbi:
87628 +       if (opt.iocharset)
87629 +               kfree(opt.iocharset);
87630         kfree(sbi);
87631         s->s_fs_info = NULL;
87632         return -EINVAL;
87633 --- linux-2.6.0-test6/fs/jbd/journal.c  2003-09-27 18:57:46.000000000 -0700
87634 +++ 25/fs/jbd/journal.c 2003-10-05 00:33:24.000000000 -0700
87635 @@ -1800,7 +1800,7 @@ int read_jbd_debug(char *page, char **st
87636         return ret;
87637  }
87638  
87639 -int write_jbd_debug(struct file *file, const char *buffer,
87640 +int write_jbd_debug(struct file *file, const char __user *buffer,
87641                            unsigned long count, void *data)
87642  {
87643         char buf[32];
87644 --- linux-2.6.0-test6/fs/jffs/intrep.c  2003-09-27 18:57:46.000000000 -0700
87645 +++ 25/fs/jffs/intrep.c 2003-10-05 00:34:48.000000000 -0700
87646 @@ -3337,18 +3337,16 @@ jffs_garbage_collect_thread(void *ptr)
87647         int result = 0;
87648         D1(int i = 1);
87649  
87650 +       daemonize("jffs_gcd");
87651 +
87652         c->gc_task = current;
87653  
87654         lock_kernel();
87655 -       exit_mm(c->gc_task);
87656 -
87657 -       set_special_pids(1, 1);
87658         init_completion(&c->gc_thread_comp); /* barrier */ 
87659         spin_lock_irq(&current->sighand->siglock);
87660         siginitsetinv (&current->blocked, sigmask(SIGHUP) | sigmask(SIGKILL) | sigmask(SIGSTOP) | sigmask(SIGCONT));
87661         recalc_sigpending();
87662         spin_unlock_irq(&current->sighand->siglock);
87663 -       strcpy(current->comm, "jffs_gcd");
87664  
87665         D1(printk (KERN_NOTICE "jffs_garbage_collect_thread(): Starting infinite loop.\n"));
87666  
87667 --- linux-2.6.0-test6/fs/jfs/inode.c    2003-09-08 13:58:58.000000000 -0700
87668 +++ 25/fs/jfs/inode.c   2003-10-05 00:34:07.000000000 -0700
87669 @@ -302,7 +302,7 @@ static int jfs_direct_IO(int rw, struct 
87670                         loff_t offset, unsigned long nr_segs)
87671  {
87672         struct file *file = iocb->ki_filp;
87673 -       struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
87674 +       struct inode *inode = file->f_mapping->host;
87675  
87676         return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
87677                                 offset, nr_segs, jfs_get_blocks, NULL);
87678 --- linux-2.6.0-test6/fs/jfs/jfs_debug.c        2003-06-14 12:18:29.000000000 -0700
87679 +++ 25/fs/jfs/jfs_debug.c       2003-10-05 00:33:24.000000000 -0700
87680 @@ -81,7 +81,7 @@ static int loglevel_read(char *page, cha
87681         return len;
87682  }
87683  
87684 -static int loglevel_write(struct file *file, const char *buffer,
87685 +static int loglevel_write(struct file *file, const char __user *buffer,
87686                         unsigned long count, void *data)
87687  {
87688         char c;
87689 --- linux-2.6.0-test6/fs/jfs/jfs_imap.c 2003-09-27 18:57:46.000000000 -0700
87690 +++ 25/fs/jfs/jfs_imap.c        2003-10-05 00:33:24.000000000 -0700
87691 @@ -838,7 +838,7 @@ int diWrite(tid_t tid, struct inode *ip)
87692          */
87693         if (S_ISDIR(ip->i_mode)
87694             && (ip->i_ipmnt->i_mntflag & JFS_DASD_ENABLED))
87695 -               bcopy(&ip->i_DASD, &dp->di_DASD, sizeof(struct dasd));
87696 +               memcpy(&dp->di_DASD, &ip->i_DASD, sizeof(struct dasd));
87697  #endif                         /*  _JFS_FASTDASD */
87698  
87699         /* release the buffer holding the updated on-disk inode. 
87700 --- linux-2.6.0-test6/fs/jfs/super.c    2003-09-27 18:57:46.000000000 -0700
87701 +++ 25/fs/jfs/super.c   2003-10-05 00:33:24.000000000 -0700
87702 @@ -20,6 +20,7 @@
87703  #include <linux/fs.h>
87704  #include <linux/config.h>
87705  #include <linux/module.h>
87706 +#include <linux/parser.h>
87707  #include <linux/completion.h>
87708  #include <linux/vfs.h>
87709  #include <asm/uaccess.h>
87710 @@ -164,59 +165,82 @@ static void jfs_put_super(struct super_b
87711         kfree(sbi);
87712  }
87713  
87714 +enum {
87715 +       Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
87716 +       Opt_ignore, Opt_err,
87717 +};
87718 +
87719 +static match_table_t tokens = {
87720 +       {Opt_integrity, "integrity"},
87721 +       {Opt_nointegrity, "nointegrity"},
87722 +       {Opt_iocharset, "iocharset=%s"},
87723 +       {Opt_resize, "resize=%u"},
87724 +       {Opt_ignore, "noquota"},
87725 +       {Opt_ignore, "quota"},
87726 +       {Opt_ignore, "usrquota"},
87727 +       {Opt_ignore, "grpquota"},
87728 +       {Opt_err, NULL}
87729 +};
87730 +
87731  static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
87732                          int *flag)
87733  {
87734         void *nls_map = NULL;
87735 -       char *this_char;
87736 -       char *value;
87737 +       char *p;
87738         struct jfs_sb_info *sbi = JFS_SBI(sb);
87739  
87740         *newLVSize = 0;
87741  
87742         if (!options)
87743                 return 1;
87744 -       while ((this_char = strsep(&options, ",")) != NULL) {
87745 -               if (!*this_char)
87746 +
87747 +       while ((p = strsep(&options, ",")) != NULL) {
87748 +               substring_t args[MAX_OPT_ARGS];
87749 +               int token;
87750 +               if (!*p)
87751                         continue;
87752 -               if ((value = strchr(this_char, '=')) != NULL)
87753 -                       *value++ = 0;
87754 -               if (!strcmp(this_char, "integrity")) {
87755 +
87756 +               token = match_token(p, tokens, args);
87757 +               switch (token) {
87758 +               case Opt_integrity:
87759                         *flag &= ~JFS_NOINTEGRITY;
87760 -               } else  if (!strcmp(this_char, "nointegrity")) {
87761 +                       break;
87762 +               case Opt_nointegrity:
87763                         *flag |= JFS_NOINTEGRITY;
87764 -               } else if (!strcmp(this_char, "iocharset")) {
87765 -                       if (!value || !*value)
87766 -                               goto needs_arg;
87767 +                       break;
87768 +               case Opt_ignore:
87769 +                       /* Silently ignore the quota options */
87770 +                       /* Don't do anything ;-) */
87771 +                       break;
87772 +               case Opt_iocharset:
87773                         if (nls_map)    /* specified iocharset twice! */
87774                                 unload_nls(nls_map);
87775 -                       nls_map = load_nls(value);
87776 +                       nls_map = load_nls(args[0].from);
87777                         if (!nls_map) {
87778                                 printk(KERN_ERR "JFS: charset not found\n");
87779                                 goto cleanup;
87780                         }
87781 -               } else if (!strcmp(this_char, "resize")) {
87782 -                       if (!value || !*value) {
87783 +                       break;
87784 +               case Opt_resize:
87785 +               {
87786 +                       char *resize = args[0].from;
87787 +                       if (!resize || !*resize) {
87788                                 *newLVSize = sb->s_bdev->bd_inode->i_size >>
87789                                         sb->s_blocksize_bits;
87790                                 if (*newLVSize == 0)
87791                                         printk(KERN_ERR
87792 -                                        "JFS: Cannot determine volume size\n");
87793 +                                       "JFS: Cannot determine volume size\n");
87794                         } else
87795 -                               *newLVSize = simple_strtoull(value, &value, 0);
87796 -
87797 -                       /* Silently ignore the quota options */
87798 -               } else if (!strcmp(this_char, "grpquota")
87799 -                          || !strcmp(this_char, "noquota")
87800 -                          || !strcmp(this_char, "quota")
87801 -                          || !strcmp(this_char, "usrquota"))
87802 -                       /* Don't do anything ;-) */ ;
87803 -               else {
87804 -                       printk("jfs: Unrecognized mount option %s\n",
87805 -                              this_char);
87806 +                               *newLVSize = simple_strtoull(resize, &resize, 0);
87807 +                       break;
87808 +               }
87809 +               default:
87810 +                       printk("jfs: Unrecognized mount option \"%s\" "
87811 +                                       " or missing value\n", p);
87812                         goto cleanup;
87813                 }
87814         }
87815 +
87816         if (nls_map) {
87817                 /* Discard old (if remount) */
87818                 if (sbi->nls_tab)
87819 @@ -224,8 +248,7 @@ static int parse_options(char *options, 
87820                 sbi->nls_tab = nls_map;
87821         }
87822         return 1;
87823 -needs_arg:
87824 -       printk(KERN_ERR "JFS: %s needs an argument\n", this_char);
87825 +
87826  cleanup:
87827         if (nls_map)
87828                 unload_nls(nls_map);
87829 --- linux-2.6.0-test6/fs/jfs/symlink.c  2003-06-14 12:18:51.000000000 -0700
87830 +++ 25/fs/jfs/symlink.c 2003-10-05 00:33:24.000000000 -0700
87831 @@ -26,7 +26,7 @@ static int jfs_follow_link(struct dentry
87832         return vfs_follow_link(nd, s);
87833  }
87834  
87835 -static int jfs_readlink(struct dentry *dentry, char *buffer, int buflen)
87836 +static int jfs_readlink(struct dentry *dentry, char __user *buffer, int buflen)
87837  {
87838         char *s = JFS_IP(dentry->d_inode)->i_inline;
87839         return vfs_readlink(dentry, buffer, buflen, s);
87840 --- linux-2.6.0-test6/fs/Kconfig        2003-09-27 18:57:46.000000000 -0700
87841 +++ 25/fs/Kconfig       2003-10-05 00:36:47.000000000 -0700
87842 @@ -874,6 +874,7 @@ config TMPFS
87843  
87844  config HUGETLBFS
87845         bool "HugeTLB file system support"
87846 +       depends X86 || IA64 || PPC64 || SPARC64 || X86_64 || BROKEN
87847  
87848  config HUGETLB_PAGE
87849         def_bool HUGETLBFS
87850 @@ -1254,6 +1255,8 @@ menu "Network File Systems"
87851  config NFS_FS
87852         tristate "NFS file system support"
87853         depends on INET
87854 +       select LOCKD
87855 +       select SUNRPC
87856         help
87857           If you are connected to some other (usually local) Unix computer
87858           (using SLIP, PLIP, PPP or Ethernet) and want to mount files residing
87859 @@ -1306,9 +1309,36 @@ config NFS_V4
87860  
87861           If unsure, say N.
87862  
87863 +config NFS_DIRECTIO
87864 +       bool
87865 +       depends on NFS_FS
87866 +       default y
87867 +       help
87868 +         This option enables applications to perform uncached I/O on files
87869 +         in NFS file systems using the O_DIRECT open() flag.  When O_DIRECT
87870 +         is set for a file, its data is not cached in the system's page
87871 +         cache.  Data is moved to and from user-level application buffers
87872 +         directly.  Unlike local disk-based file systems, NFS O_DIRECT has
87873 +         no alignment restrictions.
87874 +
87875 +         Unless your program is designed to use O_DIRECT properly, you are
87876 +         much better off allowing the NFS client to manage data caching for
87877 +         you.  Misusing O_DIRECT can cause poor server performance or network
87878 +         storms.  This kernel build option defaults OFF to avoid exposing
87879 +         system administrators unwittingly to a potentially hazardous
87880 +         feature.
87881 +
87882 +         For more details on NFS O_DIRECT, see fs/nfs/direct.c.
87883 +
87884 +         If unsure, say N.  This reduces the size of the NFS client, and
87885 +         causes open() to return EINVAL if a file residing in NFS is
87886 +         opened with the O_DIRECT flag.
87887 +
87888  config NFSD
87889         tristate "NFS server support"
87890         depends on INET
87891 +       select LOCKD
87892 +       select SUNRPC
87893         help
87894           If you want your Linux box to act as an NFS *server*, so that other
87895           computers on your local network which support NFS can access certain
87896 @@ -1371,8 +1401,6 @@ config ROOT_NFS
87897  
87898  config LOCKD
87899         tristate
87900 -       default m if NFS_FS!=y && NFSD!=y && (NFS_FS=m || NFSD=m)
87901 -       default y if NFS_FS=y || NFSD=y
87902  
87903  config LOCKD_V4
87904         bool
87905 @@ -1385,8 +1413,6 @@ config EXPORTFS
87906  
87907  config SUNRPC
87908         tristate
87909 -       default m if NFS_FS!=y && NFSD!=y && (NFS_FS=m || NFSD=m)
87910 -       default y if NFS_FS=y || NFSD=y
87911  
87912  config SUNRPC_GSS
87913         tristate "Provide RPCSEC_GSS authentication (EXPERIMENTAL)"
87914 @@ -1565,6 +1591,7 @@ config AFS_FS
87915  # for fs/nls/Config.in
87916         tristate "Andrew File System support (AFS) (Experimental)"
87917         depends on INET && EXPERIMENTAL
87918 +       select RXRPC
87919         help
87920           If you say Y here, you will get an experimental Andrew File System
87921           driver. It currently only supports unsecured read-only AFS access.
87922 @@ -1575,8 +1602,6 @@ config AFS_FS
87923  
87924  config RXRPC
87925         tristate
87926 -       default m if AFS_FS=m
87927 -       default y if AFS_FS=y
87928  
87929  endmenu
87930  
87931 --- linux-2.6.0-test6/fs/libfs.c        2003-09-27 18:57:46.000000000 -0700
87932 +++ 25/fs/libfs.c       2003-10-05 00:33:24.000000000 -0700
87933 @@ -429,3 +429,26 @@ void simple_release_fs(struct vfsmount *
87934         spin_unlock(&pin_fs_lock);
87935         mntput(mnt);
87936  }
87937 +
87938 +EXPORT_SYMBOL(dcache_dir_close);
87939 +EXPORT_SYMBOL(dcache_dir_lseek);
87940 +EXPORT_SYMBOL(dcache_dir_open);
87941 +EXPORT_SYMBOL(dcache_readdir);
87942 +EXPORT_SYMBOL(generic_read_dir);
87943 +EXPORT_SYMBOL(simple_commit_write);
87944 +EXPORT_SYMBOL(simple_dir_inode_operations);
87945 +EXPORT_SYMBOL(simple_dir_operations);
87946 +EXPORT_SYMBOL(simple_empty);
87947 +EXPORT_SYMBOL(simple_fill_super);
87948 +EXPORT_SYMBOL(simple_getattr);
87949 +EXPORT_SYMBOL(simple_link);
87950 +EXPORT_SYMBOL(simple_lookup);
87951 +EXPORT_SYMBOL(simple_pin_fs);
87952 +EXPORT_SYMBOL(simple_prepare_write);
87953 +EXPORT_SYMBOL(simple_readpage);
87954 +EXPORT_SYMBOL(simple_release_fs);
87955 +EXPORT_SYMBOL(simple_rename);
87956 +EXPORT_SYMBOL(simple_rmdir);
87957 +EXPORT_SYMBOL(simple_statfs);
87958 +EXPORT_SYMBOL(simple_sync_file);
87959 +EXPORT_SYMBOL(simple_unlink);
87960 --- linux-2.6.0-test6/fs/locks.c        2003-09-27 18:57:46.000000000 -0700
87961 +++ 25/fs/locks.c       2003-10-05 00:36:10.000000000 -0700
87962 @@ -928,10 +928,10 @@ int locks_mandatory_locked(struct inode 
87963   * locks_mandatory_area - Check for a conflicting lock
87964   * @read_write: %FLOCK_VERIFY_WRITE for exclusive access, %FLOCK_VERIFY_READ
87965   *             for shared
87966 - * @inode: the file to check
87967 - * @file: how the file was opened (if it was)
87968 - * @offset: start of area to check
87969 - * @count: length of area to check
87970 + * @inode:      the file to check
87971 + * @filp:       how the file was opened (if it was)
87972 + * @offset:     start of area to check
87973 + * @count:      length of area to check
87974   *
87975   * Searches the inode's list of locks to find any POSIX locks which conflict.
87976   * This function is called from locks_verify_area() and
87977 @@ -1119,6 +1119,7 @@ out:
87978  /**
87979   *     lease_get_mtime
87980   *     @inode: the inode
87981 + *      @time:  pointer to a timespec which will contain the last modified time
87982   *
87983   * This is to force NFS clients to flush their caches for files with
87984   * exclusive leases.  The justification is that if someone has an
87985 @@ -1434,7 +1435,7 @@ int fcntl_setlk(struct file *filp, unsig
87986          */
87987         if (IS_MANDLOCK(inode) &&
87988             (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) {
87989 -               struct address_space *mapping = inode->i_mapping;
87990 +               struct address_space *mapping = filp->f_mapping;
87991  
87992                 if (!list_empty(&mapping->i_mmap_shared)) {
87993                         error = -EAGAIN;
87994 @@ -1572,7 +1573,7 @@ int fcntl_setlk64(struct file *filp, uns
87995          */
87996         if (IS_MANDLOCK(inode) &&
87997             (inode->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) {
87998 -               struct address_space *mapping = inode->i_mapping;
87999 +               struct address_space *mapping = filp->f_mapping;
88000  
88001                 if (!list_empty(&mapping->i_mmap_shared)) {
88002                         error = -EAGAIN;
88003 @@ -1726,6 +1727,7 @@ posix_block_lock(struct file_lock *block
88004  
88005  /**
88006   *     posix_unblock_lock - stop waiting for a file lock
88007 + *      @filp:   how the file was opened
88008   *     @waiter: the lock which was waiting
88009   *
88010   *     lockd needs to block waiting for locks.
88011 --- linux-2.6.0-test6/fs/namei.c        2003-09-27 18:57:46.000000000 -0700
88012 +++ 25/fs/namei.c       2003-10-05 00:33:24.000000000 -0700
88013 @@ -15,6 +15,7 @@
88014   */
88015  
88016  #include <linux/init.h>
88017 +#include <linux/module.h>
88018  #include <linux/slab.h>
88019  #include <linux/fs.h>
88020  #include <linux/namei.h>
88021 @@ -218,7 +219,7 @@ int permission(struct inode * inode,int 
88022         if (retval)
88023                 return retval;
88024  
88025 -       return security_inode_permission(inode, mask);
88026 +       return security_inode_permission(inode, mask, nd);
88027  }
88028  
88029  /*
88030 @@ -302,7 +303,8 @@ static struct dentry * cached_lookup(str
88031   * short-cut DAC fails, then call permission() to do more
88032   * complete permission check.
88033   */
88034 -static inline int exec_permission_lite(struct inode *inode)
88035 +static inline int exec_permission_lite(struct inode *inode,
88036 +                                      struct nameidata *nd)
88037  {
88038         umode_t mode = inode->i_mode;
88039  
88040 @@ -325,7 +327,7 @@ static inline int exec_permission_lite(s
88041  
88042         return -EACCES;
88043  ok:
88044 -       return security_inode_permission(inode, MAY_EXEC);
88045 +       return security_inode_permission(inode, MAY_EXEC, nd);
88046  }
88047  
88048  /*
88049 @@ -584,7 +586,7 @@ int link_path_walk(const char * name, st
88050                 struct qstr this;
88051                 unsigned int c;
88052  
88053 -               err = exec_permission_lite(inode);
88054 +               err = exec_permission_lite(inode, nd);
88055                 if (err == -EAGAIN) { 
88056                         err = permission(inode, MAY_EXEC, nd);
88057                 }
88058 @@ -2275,3 +2277,33 @@ struct inode_operations page_symlink_ino
88059         .readlink       = page_readlink,
88060         .follow_link    = page_follow_link,
88061  };
88062 +
88063 +EXPORT_SYMBOL(__user_walk);
88064 +EXPORT_SYMBOL(follow_down);
88065 +EXPORT_SYMBOL(follow_up);
88066 +EXPORT_SYMBOL(get_write_access); /* binfmt_aout */
88067 +EXPORT_SYMBOL(getname);
88068 +EXPORT_SYMBOL(lock_rename);
88069 +EXPORT_SYMBOL(lookup_create);
88070 +EXPORT_SYMBOL(lookup_hash);
88071 +EXPORT_SYMBOL(lookup_one_len);
88072 +EXPORT_SYMBOL(page_follow_link);
88073 +EXPORT_SYMBOL(page_readlink);
88074 +EXPORT_SYMBOL(page_symlink);
88075 +EXPORT_SYMBOL(page_symlink_inode_operations);
88076 +EXPORT_SYMBOL(path_lookup);
88077 +EXPORT_SYMBOL(path_release);
88078 +EXPORT_SYMBOL(path_walk);
88079 +EXPORT_SYMBOL(permission);
88080 +EXPORT_SYMBOL(unlock_rename);
88081 +EXPORT_SYMBOL(vfs_create);
88082 +EXPORT_SYMBOL(vfs_follow_link);
88083 +EXPORT_SYMBOL(vfs_link);
88084 +EXPORT_SYMBOL(vfs_mkdir);
88085 +EXPORT_SYMBOL(vfs_mknod);
88086 +EXPORT_SYMBOL(vfs_permission);
88087 +EXPORT_SYMBOL(vfs_readlink);
88088 +EXPORT_SYMBOL(vfs_rename);
88089 +EXPORT_SYMBOL(vfs_rmdir);
88090 +EXPORT_SYMBOL(vfs_symlink);
88091 +EXPORT_SYMBOL(vfs_unlink);
88092 --- linux-2.6.0-test6/fs/nfs/direct.c   2003-06-26 22:07:25.000000000 -0700
88093 +++ 25/fs/nfs/direct.c  2003-10-05 00:36:46.000000000 -0700
88094 @@ -1,7 +1,7 @@
88095  /*
88096   * linux/fs/nfs/direct.c
88097   *
88098 - * Copyright (C) 2001 by Chuck Lever <cel@netapp.com>
88099 + * Copyright (C) 2003 by Chuck Lever <cel@netapp.com>
88100   *
88101   * High-performance uncached I/O for the Linux NFS client
88102   *
88103 @@ -26,19 +26,23 @@
88104   * also supports uncaching whole NFS partitions with "-o forcedirectio,"
88105   * an undocumented mount option.
88106   *
88107 - * Designed by Jeff Kimmel, Chuck Lever, and Trond Myklebust.
88108 + * Designed by Jeff Kimmel, Chuck Lever, and Trond Myklebust, with
88109 + * help from Andrew Morton.
88110   *
88111   * 18 Dec 2001 Initial implementation for 2.4  --cel
88112   * 08 Jul 2002 Version for 2.4.19, with bug fixes --trondmy
88113 - * 24 Sep 2002 Rewrite to use asynchronous RPCs, port to 2.5  --cel
88114 + * 08 Jun 2003 Port to 2.5 APIs  --cel
88115   *
88116   */
88117  
88118  #include <linux/config.h>
88119 +#include <linux/errno.h>
88120  #include <linux/sched.h>
88121  #include <linux/kernel.h>
88122 +#include <linux/smp_lock.h>
88123  #include <linux/file.h>
88124 -#include <linux/errno.h>
88125 +#include <linux/pagemap.h>
88126 +
88127  #include <linux/nfs_fs.h>
88128  #include <linux/nfs_page.h>
88129  #include <linux/sunrpc/clnt.h>
88130 @@ -46,35 +50,41 @@
88131  #include <asm/system.h>
88132  #include <asm/uaccess.h>
88133  
88134 -#define NFSDBG_FACILITY                (NFSDBG_PAGECACHE | NFSDBG_VFS)
88135 +#define NFSDBG_FACILITY                NFSDBG_VFS
88136  #define VERF_SIZE              (2 * sizeof(__u32))
88137 +#define MAX_DIRECTIO_SIZE      (4096UL << PAGE_SHIFT)
88138  
88139  
88140  /**
88141 - * nfs_get_user_pages - find and set up page representing user buffer
88142 - * addr: user-space address of target buffer
88143 - * size: total size in bytes of target buffer
88144 - * @pages: returned array of page struct pointers underlying target buffer
88145 - * write: whether or not buffer is target of a write operation
88146 + * nfs_get_user_pages - find and set up pages underlying user's buffer
88147 + * rw: direction (read or write)
88148 + * user_addr: starting address of this segment of user's buffer
88149 + * count: size of this segment
88150 + * @pages: returned array of page struct pointers underlying user's buffer
88151   */
88152  static inline int
88153 -nfs_get_user_pages(unsigned long addr, size_t size,
88154 -               struct page ***pages, int rw)
88155 +nfs_get_user_pages(int rw, unsigned long user_addr, size_t size,
88156 +               struct page ***pages)
88157  {
88158         int result = -ENOMEM;
88159 -       unsigned page_count = (unsigned) size >> PAGE_SHIFT;
88160 -       unsigned array_size = (page_count * sizeof(struct page *)) + 2U;
88161 +       unsigned long page_count;
88162 +       size_t array_size;
88163 +
88164 +       /* set an arbitrary limit to prevent arithmetic overflow */
88165 +       if (size > MAX_DIRECTIO_SIZE)
88166 +               return -EFBIG;
88167  
88168 -       *pages = (struct page **) kmalloc(array_size, GFP_KERNEL);
88169 +       page_count = (user_addr + size + PAGE_SIZE - 1) >> PAGE_SHIFT;
88170 +       page_count -= user_addr >> PAGE_SHIFT;
88171 +
88172 +       array_size = (page_count * sizeof(struct page *));
88173 +       *pages = kmalloc(array_size, GFP_KERNEL);
88174         if (*pages) {
88175                 down_read(&current->mm->mmap_sem);
88176 -               result = get_user_pages(current, current->mm, addr,
88177 -                                       page_count, (rw == WRITE), 0,
88178 +               result = get_user_pages(current, current->mm, user_addr,
88179 +                                       page_count, (rw == READ), 0,
88180                                         *pages, NULL);
88181                 up_read(&current->mm->mmap_sem);
88182 -               if (result < 0)
88183 -                       printk(KERN_ERR "%s: get_user_pages result %d\n",
88184 -                                       __FUNCTION__, result);
88185         }
88186         return result;
88187  }
88188 @@ -84,176 +94,349 @@ nfs_get_user_pages(unsigned long addr, s
88189   * @pages: array of page struct pointers underlying target buffer
88190   */
88191  static inline void
88192 -nfs_free_user_pages(struct page **pages, unsigned count)
88193 +nfs_free_user_pages(struct page **pages)
88194  {
88195 -       unsigned page = 0;
88196 +       kfree(pages);
88197 +}
88198  
88199 -       while (count--)
88200 -               page_cache_release(pages[page++]);
88201 +/**
88202 + * nfs_direct_read_seg - Read in one iov segment.  Generate separate
88203 + *                        read RPCs for each "rsize" bytes.
88204 + * @inode: target inode
88205 + * @cred: user's credential
88206 + * user_addr: starting address of this segment of user's buffer
88207 + * count: size of this segment
88208 + * file_offset: offset in file to begin the operation
88209 + * @pages: array of addresses of page structs defining user's buffer
88210 + * nr_pages: size of pages array
88211 + */
88212 +static int
88213 +nfs_direct_read_seg(struct inode *inode, struct rpc_cred *cred,
88214 +               unsigned long user_addr, size_t count, loff_t file_offset,
88215 +               struct page **pages, int nr_pages)
88216 +{
88217 +       const unsigned int rsize = NFS_SERVER(inode)->rsize;
88218 +       int tot_bytes = 0;
88219 +       int curpage = 0;
88220 +       struct nfs_read_data    rdata = {
88221 +               .flags          = 0,
88222 +               .cred           = cred,
88223 +               .inode          = inode,
88224 +               .args           = {
88225 +                       .fh             = NFS_FH(inode),
88226 +               },
88227 +               .res            = {
88228 +                       .fattr          = &rdata.fattr,
88229 +               },
88230 +       };
88231 +
88232 +        do {
88233 +               int request, result;
88234 +
88235 +                request = count;
88236 +                if (count > rsize)
88237 +                        request = rsize;
88238 +               rdata.args.count = request,
88239 +               rdata.args.pgbase = user_addr & ~PAGE_MASK;
88240 +               rdata.args.offset = file_offset;
88241 +               rdata.args.pages = &pages[curpage];
88242 +
88243 +               dprintk("NFS: direct read: c=%u o=%Ld ua=%lu, pb=%u, cp=%u\n",
88244 +                       rdata.args.count, (long long) rdata.args.offset,
88245 +                       user_addr, rdata.args.pgbase, curpage);
88246 +
88247 +               lock_kernel();
88248 +               result = NFS_PROTO(inode)->read(&rdata);
88249 +               unlock_kernel();
88250 +
88251 +               if (result < 0) {
88252 +                       if (result == -EISDIR)
88253 +                               result = -EINVAL;
88254 +                       return result;
88255 +               }
88256  
88257 -       kfree(pages);
88258 +                tot_bytes += result;
88259 +                count -= result;
88260 +                file_offset += result;
88261 +               user_addr += result;
88262 +
88263 +               if (rdata.res.eof)
88264 +                       break;
88265 +
88266 +               curpage += (rdata.args.pgbase + result) >> PAGE_SHIFT;
88267 +       } while (count);
88268 +
88269 +       /* XXX: should we zero the rest of the user's buffer if we
88270 +        *      hit eof? */
88271 +
88272 +       return tot_bytes;
88273  }
88274  
88275  /**
88276 - * nfs_iov2pagelist - convert an array of iovecs to a list of page requests
88277 - * @inode: inode of target file
88278 - * @cred: credentials of user who requested I/O
88279 + * nfs_direct_read - For each iov segment, map the user's buffer
88280 + *                   then generate read RPCs.
88281 + * @inode: target inode
88282 + * @cred: user's credential
88283   * @iov: array of vectors that define I/O buffer
88284 - * offset: where in file to begin the read
88285 + * file_offset: offset in file to begin the operation
88286   * nr_segs: size of iovec array
88287 - * @requests: append new page requests to this list head
88288 + *
88289 + * generic_file_direct_IO has already pushed out any non-direct
88290 + * writes so that this read will see them when we read from the
88291 + * server.
88292   */
88293  static int
88294 -nfs_iov2pagelist(int rw, const struct inode *inode,
88295 -               const struct rpc_cred *cred,
88296 -               const struct iovec *iov, loff_t offset,
88297 -               unsigned long nr_segs, struct list_head *requests)
88298 +nfs_direct_read(struct inode *inode, struct rpc_cred *cred,
88299 +               const struct iovec *iov, loff_t file_offset,
88300 +               unsigned long nr_segs)
88301  {
88302 -       unsigned seg;
88303         int tot_bytes = 0;
88304 -       struct page **pages;
88305 +       unsigned long seg = 0;
88306  
88307 -       /* for each iovec in the array... */
88308 -       for (seg = 0; seg < nr_segs; seg++) {
88309 -               const unsigned long user_addr =
88310 -                                       (unsigned long) iov[seg].iov_base;
88311 -               size_t bytes = iov[seg].iov_len;
88312 -               unsigned int pg_offset = (user_addr & ~PAGE_MASK);
88313 -               int page_count, page = 0;
88314 -
88315 -               page_count = nfs_get_user_pages(user_addr, bytes, &pages, rw);
88316 -               if (page_count < 0) {
88317 -                       nfs_release_list(requests);
88318 -                       return page_count;
88319 +       while ((seg < nr_segs) && (tot_bytes >= 0)) {
88320 +               int result, page_count;
88321 +               struct page **pages;
88322 +               const struct iovec *vec = &iov[seg++];
88323 +               unsigned long user_addr = (unsigned long) vec->iov_base;
88324 +               size_t size = vec->iov_len;
88325 +
88326 +                page_count = nfs_get_user_pages(READ, user_addr, size, &pages);
88327 +                if (page_count < 0) {
88328 +                        nfs_free_user_pages(pages);
88329 +                        return page_count;
88330 +                }
88331 +
88332 +               result = nfs_direct_read_seg(inode, cred, user_addr, size,
88333 +                               file_offset, pages, page_count);
88334 +               if (result < 0)
88335 +                       tot_bytes = result;
88336 +               else {
88337 +                       tot_bytes += result;
88338 +                       file_offset += result;
88339                 }
88340  
88341 -               /* ...build as many page requests as required */
88342 -               while (bytes > 0) {
88343 -                       struct nfs_page *new;
88344 -                       const unsigned int pg_bytes = (bytes > PAGE_SIZE) ?
88345 -                                                       PAGE_SIZE : bytes;
88346 -
88347 -                       new = nfs_create_request((struct rpc_cred *) cred,
88348 -                                                (struct inode *) inode,
88349 -                                                pages[page],
88350 -                                                pg_offset, pg_bytes);
88351 -                       if (IS_ERR(new)) {
88352 -                               nfs_free_user_pages(pages, page_count);
88353 -                               nfs_release_list(requests);
88354 -                               return PTR_ERR(new);
88355 -                       }
88356 -                       new->wb_index = offset;
88357 -                       nfs_list_add_request(new, requests);
88358 -
88359 -                       /* after the first page */
88360 -                       pg_offset = 0;
88361 -                       offset += PAGE_SIZE;
88362 -                       tot_bytes += pg_bytes;
88363 -                       bytes -= pg_bytes;
88364 -                       page++;
88365 +               nfs_free_user_pages(pages);
88366 +       }
88367 +
88368 +       return tot_bytes;
88369 +}
88370 +
88371 +/**
88372 + * nfs_direct_write_seg - Write out one iov segment.  Generate separate
88373 + *                        write RPCs for each "wsize" bytes, then commit.
88374 + * @inode: target inode
88375 + * @cred: user's credential
88376 + * user_addr: starting address of this segment of user's buffer
88377 + * count: size of this segment
88378 + * file_offset: offset in file to begin the operation
88379 + * @pages: array of addresses of page structs defining user's buffer
88380 + * nr_pages: size of pages array
88381 + */
88382 +static int
88383 +nfs_direct_write_seg(struct inode *inode, struct rpc_cred *cred,
88384 +               unsigned long user_addr, size_t count, loff_t file_offset,
88385 +               struct page **pages, int nr_pages)
88386 +{
88387 +       const unsigned int wsize = NFS_SERVER(inode)->wsize;
88388 +       loff_t save_offset = file_offset;
88389 +       size_t save_count = count;
88390 +       int need_commit = 0;
88391 +       int tot_bytes = 0;
88392 +       int curpage = 0;
88393 +       struct nfs_writeverf first_verf;
88394 +       struct nfs_write_data   wdata = {
88395 +               .cred           = cred,
88396 +               .inode          = inode,
88397 +               .args           = {
88398 +                       .fh             = NFS_FH(inode),
88399 +               },
88400 +               .res            = {
88401 +                       .fattr          = &wdata.fattr,
88402 +                       .verf           = &wdata.verf,
88403 +               },
88404 +       };
88405 +
88406 +       wdata.args.stable = NFS_UNSTABLE;
88407 +       if (IS_SYNC(inode) || NFS_PROTO(inode)->version == 2 || count <= wsize)
88408 +               wdata.args.stable = NFS_FILE_SYNC;
88409 +
88410 +retry:
88411 +        do {
88412 +               int request, result;
88413 +
88414 +                request = count;
88415 +                if (count > wsize)
88416 +                        request = wsize;
88417 +               wdata.args.count = request,
88418 +               wdata.args.pgbase = user_addr & ~PAGE_MASK;
88419 +               wdata.args.offset = file_offset;
88420 +               wdata.args.pages = &pages[curpage];
88421 +
88422 +               dprintk("NFS: direct write: c=%u o=%Ld ua=%lu, pb=%u, cp=%u\n",
88423 +                       wdata.args.count, (long long) wdata.args.offset,
88424 +                       user_addr, wdata.args.pgbase, curpage);
88425 +
88426 +               lock_kernel();
88427 +               result = NFS_PROTO(inode)->write(&wdata);
88428 +               unlock_kernel();
88429 +
88430 +               if (result < 0)
88431 +                       return result;
88432 +
88433 +               if (!tot_bytes)
88434 +                       memcpy(&first_verf.verifier, &wdata.verf.verifier,
88435 +                                                               VERF_SIZE);
88436 +               if (wdata.verf.committed != NFS_FILE_SYNC) {
88437 +                       need_commit = 1;
88438 +                       if (memcmp(&first_verf.verifier,
88439 +                                       &wdata.verf.verifier, VERF_SIZE))
88440 +                               goto sync_retry;
88441                 }
88442  
88443 -               /* don't release pages here -- I/O completion will do that */
88444 -               nfs_free_user_pages(pages, 0);
88445 +                tot_bytes += result;
88446 +                count -= result;
88447 +                file_offset += result;
88448 +               user_addr += result;
88449 +
88450 +               curpage += (wdata.args.pgbase + result) >> PAGE_SHIFT;
88451 +       } while (count);
88452 +
88453 +       /*
88454 +        * Commit data written so far, even in the event of an error
88455 +        */
88456 +       if (need_commit) {
88457 +               int result;
88458 +
88459 +               wdata.args.count = tot_bytes;
88460 +               wdata.args.offset = save_offset;
88461 +
88462 +               lock_kernel();
88463 +               result = NFS_PROTO(inode)->commit(&wdata);
88464 +               unlock_kernel();
88465 +
88466 +               if (result < 0)
88467 +                       goto sync_retry;
88468 +               if (memcmp(&first_verf.verifier, &wdata.verf.verifier,
88469 +                                                               VERF_SIZE))
88470 +                       goto sync_retry;
88471         }
88472  
88473         return tot_bytes;
88474 +
88475 +sync_retry:
88476 +       wdata.args.stable = NFS_FILE_SYNC;
88477 +       file_offset = save_offset;
88478 +       count = save_count;
88479 +       goto retry;
88480  }
88481  
88482  /**
88483 - * do_nfs_direct_IO - Read or write data without caching
88484 - * @inode: inode of target file
88485 - * @cred: credentials of user who requested I/O
88486 + * nfs_direct_write - For each iov segment, map the user's buffer
88487 + *                    then generate write and commit RPCs.
88488 + * @inode: target inode
88489 + * @cred: user's credential
88490   * @iov: array of vectors that define I/O buffer
88491 - * offset: where in file to begin the read
88492 + * file_offset: offset in file to begin the operation
88493   * nr_segs: size of iovec array
88494   *
88495 - * Break the passed-in iovec into a series of page-sized or smaller
88496 - * requests, where each page is mapped for direct user-land I/O.
88497 - *
88498 - * For each of these pages, create an NFS page request and
88499 - * append it to an automatic list of page requests.
88500 - *
88501 - * When all page requests have been queued, start the I/O on the
88502 - * whole list.  The underlying routines coalesce the pages on the
88503 - * list into a bunch of asynchronous "r/wsize" network requests.
88504 - *
88505 - * I/O completion automatically unmaps and releases the pages.
88506 + * Upon return, generic_file_direct_IO invalidates any cached pages
88507 + * that non-direct readers might access, so they will pick up these
88508 + * writes immediately.
88509   */
88510  static int
88511 -do_nfs_direct_IO(int rw, const struct inode *inode,
88512 -               const struct rpc_cred *cred, const struct iovec *iov,
88513 -               loff_t offset, unsigned long nr_segs)
88514 +nfs_direct_write(struct inode *inode, struct rpc_cred *cred,
88515 +               const struct iovec *iov, loff_t file_offset,
88516 +               unsigned long nr_segs)
88517  {
88518 -       LIST_HEAD(requests);
88519 -       int result, tot_bytes;
88520 +       int tot_bytes = 0;
88521 +       unsigned long seg = 0;
88522  
88523 -       result = nfs_iov2pagelist(rw, inode, cred, iov, offset, nr_segs,
88524 -                                                               &requests);
88525 -       if (result < 0)
88526 -               return result;
88527 -       tot_bytes = result;
88528 +       while ((seg < nr_segs) && (tot_bytes >= 0)) {
88529 +               int result, page_count;
88530 +               struct page **pages;
88531 +               const struct iovec *vec = &iov[seg++];
88532 +               unsigned long user_addr = (unsigned long) vec->iov_base;
88533 +               size_t size = vec->iov_len;
88534 +
88535 +                page_count = nfs_get_user_pages(WRITE, user_addr, size, &pages);
88536 +                if (page_count < 0) {
88537 +                        nfs_free_user_pages(pages);
88538 +                        return page_count;
88539 +                }
88540  
88541 -       switch (rw) {
88542 -       case READ:
88543 -               if (IS_SYNC(inode) || (NFS_SERVER(inode)->rsize < PAGE_SIZE)) {
88544 -                       result = nfs_direct_read_sync(inode, cred, iov, offset, nr_segs);
88545 -                       break;
88546 +               result = nfs_direct_write_seg(inode, cred, user_addr, size,
88547 +                               file_offset, pages, page_count);
88548 +               if (result < 0)
88549 +                       tot_bytes = result;
88550 +               else {
88551 +                       tot_bytes += result;
88552 +                       file_offset += result;
88553                 }
88554 -               result = nfs_pagein_list(&requests, NFS_SERVER(inode)->rpages);
88555 -               nfs_wait_for_reads(&requests);
88556 -               break;
88557 -       case WRITE:
88558 -               if (IS_SYNC(inode) || (NFS_SERVER(inode)->wsize < PAGE_SIZE))
88559 -                       result = nfs_direct_write_sync(inode, cred, iov, offset, nr_segs);
88560 -               else
88561 -                       result = nfs_flush_list(&requests,
88562 -                                       NFS_SERVER(inode)->wpages, FLUSH_WAIT);
88563  
88564 -               /* invalidate cache so non-direct readers pick up changes */
88565 -               invalidate_inode_pages((struct inode *) inode);
88566 -               break;
88567 -       default:
88568 -               result = -EINVAL;
88569 -               break;
88570 +               nfs_free_user_pages(pages);
88571         }
88572  
88573 -       if (result < 0)
88574 -               return result;
88575         return tot_bytes;
88576  }
88577  
88578  /**
88579   * nfs_direct_IO - NFS address space operation for direct I/O
88580   * rw: direction (read or write)
88581 - * @file: file struct of target file
88582 + * @iocb: target I/O control block
88583   * @iov: array of vectors that define I/O buffer
88584 - * offset: offset in file to begin the operation
88585 + * file_offset: offset in file to begin the operation
88586   * nr_segs: size of iovec array
88587   *
88588 + * Usually a file system implements direct I/O by calling out to
88589 + * blockdev_direct_IO.  The NFS client doesn't have a backing block
88590 + * device, so we do everything by hand instead.
88591 + *
88592   * The inode's i_sem is no longer held by the VFS layer before it calls
88593   * this function to do a write.
88594   */
88595  int
88596  nfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
88597 -               loff_t offset, unsigned long nr_segs)
88598 +               loff_t file_offset, unsigned long nr_segs)
88599  {
88600 -       /* None of this works yet, so prevent it from compiling. */
88601 -#if 0
88602 -       int result;
88603 +       int result = -EINVAL;
88604 +       struct file *file = iocb->ki_filp;
88605         struct dentry *dentry = file->f_dentry;
88606 -       const struct inode *inode = dentry->d_inode->i_mapping->host;
88607 -       const struct rpc_cred *cred = nfs_file_cred(file);
88608 -#endif
88609 -
88610 -       dfprintk(VFS, "NFS: direct_IO(%s) (%s/%s) off/no(%Lu/%lu)\n",
88611 -                               ((rw == READ) ? "READ" : "WRITE"),
88612 -                               dentry->d_parent->d_name.name,
88613 -                               dentry->d_name.name, offset, nr_segs);
88614 +       struct inode *inode = dentry->d_inode;
88615 +       struct rpc_cred *cred;
88616 +
88617 +       /*
88618 +        * No support for async yet
88619 +        */
88620 +       if (!is_sync_kiocb(iocb))
88621 +               goto out;
88622 +
88623 +       cred = get_rpccred(nfs_file_cred(file));
88624 +       if (!cred)
88625 +               cred = get_rpccred(NFS_I(inode)->mm_cred);
88626 +
88627 +       switch (rw) {
88628 +       case READ:
88629 +               dprintk("NFS: direct_IO(read) (%s) off/no(%Lu/%lu)\n",
88630 +                               dentry->d_name.name, file_offset, nr_segs);
88631 +
88632 +               result = nfs_direct_read(inode, cred, iov,
88633 +                                               file_offset, nr_segs);
88634 +               break;
88635 +       case WRITE:
88636 +               dprintk("NFS: direct_IO(write) (%s) off/no(%Lu/%lu)\n",
88637 +                               dentry->d_name.name, file_offset, nr_segs);
88638  
88639 -       result = do_nfs_direct_IO(rw, inode, cred, iov, offset, nr_segs);
88640 +               result = nfs_direct_write(inode, cred, iov,
88641 +                                               file_offset, nr_segs);
88642 +               break;
88643 +       default:
88644 +               break;
88645 +       }
88646  
88647 -       dfprintk(VFS, "NFS: direct_IO result = %d\n", result);
88648 +       if (cred)
88649 +               put_rpccred(cred);
88650  
88651 +out:
88652 +       dprintk("NFS: direct_IO result=%d\n", result);
88653         return result;
88654  }
88655 --- linux-2.6.0-test6/fs/nfsd/nfsctl.c  2003-07-02 14:53:16.000000000 -0700
88656 +++ 25/fs/nfsd/nfsctl.c 2003-10-05 00:33:24.000000000 -0700
88657 @@ -429,6 +429,7 @@ static struct file_system_type nfsd_fs_t
88658  
88659  static int __init init_nfsd(void)
88660  {
88661 +       int retval;
88662         printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n");
88663  
88664         nfsd_stat_init();       /* Statistics */
88665 @@ -441,8 +442,16 @@ static int __init init_nfsd(void)
88666                 if (entry)
88667                         entry->proc_fops =  &exports_operations;
88668         }
88669 -       register_filesystem(&nfsd_fs_type);
88670 -       return 0;
88671 +       retval = register_filesystem(&nfsd_fs_type);
88672 +       if (retval) {
88673 +               nfsd_export_shutdown();
88674 +               nfsd_cache_shutdown();
88675 +               remove_proc_entry("fs/nfs/exports", NULL);
88676 +               remove_proc_entry("fs/nfs", NULL);
88677 +               nfsd_stat_shutdown();
88678 +               nfsd_lockd_shutdown();
88679 +       }
88680 +       return retval;
88681  }
88682  
88683  static void __exit exit_nfsd(void)
88684 --- linux-2.6.0-test6/fs/nfs/file.c     2003-07-10 18:50:32.000000000 -0700
88685 +++ 25/fs/nfs/file.c    2003-10-05 00:34:08.000000000 -0700
88686 @@ -262,7 +262,7 @@ out_swapfile:
88687  int
88688  nfs_lock(struct file *filp, int cmd, struct file_lock *fl)
88689  {
88690 -       struct inode * inode = filp->f_dentry->d_inode;
88691 +       struct inode * inode = filp->f_mapping->host;
88692         int     status = 0;
88693         int     status2;
88694  
88695 @@ -305,13 +305,13 @@ nfs_lock(struct file *filp, int cmd, str
88696          * Flush all pending writes before doing anything
88697          * with locks..
88698          */
88699 -       status = filemap_fdatawrite(inode->i_mapping);
88700 +       status = filemap_fdatawrite(filp->f_mapping);
88701         down(&inode->i_sem);
88702         status2 = nfs_wb_all(inode);
88703         if (!status)
88704                 status = status2;
88705         up(&inode->i_sem);
88706 -       status2 = filemap_fdatawait(inode->i_mapping);
88707 +       status2 = filemap_fdatawait(filp->f_mapping);
88708         if (!status)
88709                 status = status2;
88710         if (status < 0)
88711 @@ -331,11 +331,11 @@ nfs_lock(struct file *filp, int cmd, str
88712          */
88713   out_ok:
88714         if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
88715 -               filemap_fdatawrite(inode->i_mapping);
88716 +               filemap_fdatawrite(filp->f_mapping);
88717                 down(&inode->i_sem);
88718                 nfs_wb_all(inode);      /* we may have slept */
88719                 up(&inode->i_sem);
88720 -               filemap_fdatawait(inode->i_mapping);
88721 +               filemap_fdatawait(filp->f_mapping);
88722                 nfs_zap_caches(inode);
88723         }
88724         return status;
88725 --- linux-2.6.0-test6/fs/nfs/nfs3proc.c 2003-09-27 18:57:46.000000000 -0700
88726 +++ 25/fs/nfs/nfs3proc.c        2003-10-05 00:36:45.000000000 -0700
88727 @@ -225,81 +225,74 @@ nfs3_proc_readlink(struct inode *inode, 
88728  }
88729  
88730  static int
88731 -nfs3_proc_read(struct inode *inode, struct rpc_cred *cred,
88732 -              struct nfs_fattr *fattr, int flags,
88733 -              unsigned int base, unsigned int count, struct page *page,
88734 -              int *eofp)
88735 -{
88736 -       u64                     offset = page_offset(page) + base;
88737 -       struct nfs_readargs     arg = {
88738 -               .fh             = NFS_FH(inode),
88739 -               .offset         = offset,
88740 -               .count          = count,
88741 -               .pgbase         = base,
88742 -               .pages          = &page
88743 -       };
88744 -       struct nfs_readres      res = {
88745 -               .fattr          = fattr,
88746 -               .count          = count,
88747 -       };
88748 +nfs3_proc_read(struct nfs_read_data *rdata)
88749 +{
88750 +       int                     flags = rdata->flags;
88751 +       struct inode *          inode = rdata->inode;
88752 +       struct nfs_fattr *      fattr = rdata->res.fattr;
88753         struct rpc_message      msg = {
88754                 .rpc_proc       = &nfs3_procedures[NFS3PROC_READ],
88755 -               .rpc_argp       = &arg,
88756 -               .rpc_resp       = &res,
88757 -               .rpc_cred       = cred
88758 +               .rpc_argp       = &rdata->args,
88759 +               .rpc_resp       = &rdata->res,
88760 +               .rpc_cred       = rdata->cred,
88761         };
88762         int                     status;
88763  
88764 -       dprintk("NFS call  read %d @ %Ld\n", count, (long long)offset);
88765 +       dprintk("NFS call  read %d @ %Ld\n", rdata->args.count,
88766 +                       (long long) rdata->args.offset);
88767         fattr->valid = 0;
88768         status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
88769         if (status >= 0)
88770                 nfs_refresh_inode(inode, fattr);
88771         dprintk("NFS reply read: %d\n", status);
88772 -       *eofp = res.eof;
88773         return status;
88774  }
88775  
88776  static int
88777 -nfs3_proc_write(struct inode *inode, struct rpc_cred *cred,
88778 -               struct nfs_fattr *fattr, int flags,
88779 -               unsigned int base, unsigned int count,
88780 -               struct page *page, struct nfs_writeverf *verf)
88781 +nfs3_proc_write(struct nfs_write_data *wdata)
88782  {
88783 -       u64                     offset = page_offset(page) + base;
88784 -       struct nfs_writeargs    arg = {
88785 -               .fh             = NFS_FH(inode),
88786 -               .offset         = offset,
88787 -               .count          = count,
88788 -               .stable         = NFS_FILE_SYNC,
88789 -               .pgbase         = base,
88790 -               .pages          = &page
88791 -       };
88792 -       struct nfs_writeres     res = {
88793 -               .fattr          = fattr,
88794 -               .verf           = verf,
88795 -       };
88796 +       int                     rpcflags = wdata->flags;
88797 +       struct inode *          inode = wdata->inode;
88798 +       struct nfs_fattr *      fattr = wdata->res.fattr;
88799         struct rpc_message      msg = {
88800                 .rpc_proc       = &nfs3_procedures[NFS3PROC_WRITE],
88801 -               .rpc_argp       = &arg,
88802 -               .rpc_resp       = &res,
88803 -               .rpc_cred       = cred
88804 +               .rpc_argp       = &wdata->args,
88805 +               .rpc_resp       = &wdata->res,
88806 +               .rpc_cred       = wdata->cred,
88807         };
88808 -       int                     status, rpcflags = 0;
88809 +       int                     status;
88810  
88811 -       dprintk("NFS call  write %d @ %Ld\n", count, (long long)offset);
88812 +       dprintk("NFS call  write %d @ %Ld\n", wdata->args.count,
88813 +                       (long long) wdata->args.offset);
88814         fattr->valid = 0;
88815 -       if (flags & NFS_RW_SWAP)
88816 -               rpcflags |= NFS_RPC_SWAPFLAGS;
88817 -       arg.stable = (flags & NFS_RW_SYNC) ? NFS_FILE_SYNC : NFS_UNSTABLE;
88818 -
88819         status = rpc_call_sync(NFS_CLIENT(inode), &msg, rpcflags);
88820 -
88821         if (status >= 0)
88822                 nfs3_write_refresh_inode(inode, fattr);
88823 +       dprintk("NFS reply write: %d\n", status);
88824 +       return status < 0? status : wdata->res.count;
88825 +}
88826  
88827 -       dprintk("NFS reply read: %d\n", status);
88828 -       return status < 0? status : res.count;
88829 +static int
88830 +nfs3_proc_commit(struct nfs_write_data *cdata)
88831 +{
88832 +       struct inode *          inode = cdata->inode;
88833 +       struct nfs_fattr *      fattr = cdata->res.fattr;
88834 +       struct rpc_message      msg = {
88835 +               .rpc_proc       = &nfs3_procedures[NFS3PROC_COMMIT],
88836 +               .rpc_argp       = &cdata->args,
88837 +               .rpc_resp       = &cdata->res,
88838 +               .rpc_cred       = cdata->cred,
88839 +       };
88840 +       int                     status;
88841 +
88842 +       dprintk("NFS call  commit %d @ %Ld\n", cdata->args.count,
88843 +                       (long long) cdata->args.offset);
88844 +       fattr->valid = 0;
88845 +       status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
88846 +       if (status >= 0)
88847 +               nfs3_write_refresh_inode(inode, fattr);
88848 +       dprintk("NFS reply commit: %d\n", status);
88849 +       return status;
88850  }
88851  
88852  /*
88853 @@ -863,6 +856,7 @@ struct nfs_rpc_ops  nfs_v3_clientops = {
88854         .readlink       = nfs3_proc_readlink,
88855         .read           = nfs3_proc_read,
88856         .write          = nfs3_proc_write,
88857 +       .commit         = nfs3_proc_commit,
88858         .create         = nfs3_proc_create,
88859         .remove         = nfs3_proc_remove,
88860         .unlink_setup   = nfs3_proc_unlink_setup,
88861 --- linux-2.6.0-test6/fs/nfs/nfs4proc.c 2003-06-26 22:07:25.000000000 -0700
88862 +++ 25/fs/nfs/nfs4proc.c        2003-10-05 00:36:45.000000000 -0700
88863 @@ -1012,45 +1012,36 @@ nfs4_proc_readlink(struct inode *inode, 
88864  }
88865  
88866  static int
88867 -nfs4_proc_read(struct inode *inode, struct rpc_cred *cred,
88868 -              struct nfs_fattr *fattr, int flags,
88869 -              unsigned int base, unsigned int count,
88870 -              struct page *page, int *eofp)
88871 +nfs4_proc_read(struct nfs_read_data *rdata)
88872  {
88873 +       int flags = rdata->flags;
88874 +       struct inode *inode = rdata->inode;
88875 +       struct nfs_fattr *fattr = rdata->res.fattr;
88876 +       nfs4_stateid *stateid = &rdata->args.stateid;
88877         struct nfs_server *server = NFS_SERVER(inode);
88878         struct nfs4_shareowner  *sp;
88879 -       uint64_t offset = page_offset(page) + base;
88880 -       struct nfs_readargs arg = {
88881 -               .fh             = NFS_FH(inode),
88882 -               .offset         = offset,
88883 -               .count          = count,
88884 -               .pgbase         = base,
88885 -               .pages          = &page,
88886 -       };
88887 -       struct nfs_readres res = {
88888 -               .fattr          = fattr,
88889 -               .count          = count,
88890 -       };
88891         struct rpc_message msg = {
88892                 .rpc_proc       = &nfs4_procedures[NFSPROC4_CLNT_READ],
88893 -               .rpc_argp       = &arg,
88894 -               .rpc_resp       = &res,
88895 -               .rpc_cred       = cred,
88896 +               .rpc_argp       = &rdata->args,
88897 +               .rpc_resp       = &rdata->res,
88898 +               .rpc_cred       = rdata->cred,
88899         };
88900         unsigned long timestamp = jiffies;
88901         int status;
88902  
88903 -       dprintk("NFS call  read %d @ %Ld\n", count, (long long)offset);
88904 +       dprintk("NFS call  read %d @ %Ld\n", rdata->args.count,
88905 +                       (long long) rdata->args.offset);
88906 +
88907         /*
88908 -       * Try first to use O_RDONLY, then O_RDWR stateid.
88909 -       */
88910 +        * Try first to use O_RDONLY, then O_RDWR stateid.
88911 +        */
88912         sp = nfs4_get_inode_share(inode, O_RDONLY);
88913         if (!sp)
88914                 sp = nfs4_get_inode_share(inode, O_RDWR);
88915         if (sp)
88916 -               memcpy(arg.stateid,sp->so_stateid, sizeof(nfs4_stateid));
88917 +               memcpy(stateid, sp->so_stateid, sizeof(nfs4_stateid));
88918         else
88919 -               memcpy(arg.stateid, zero_stateid, sizeof(nfs4_stateid));
88920 +               memcpy(stateid, zero_stateid, sizeof(nfs4_stateid));
88921  
88922         fattr->valid = 0;
88923         status = rpc_call_sync(server->client, &msg, flags);
88924 @@ -1061,56 +1052,82 @@ nfs4_proc_read(struct inode *inode, stru
88925                         nfs_zap_caches(inode);
88926         }
88927         dprintk("NFS reply read: %d\n", status);
88928 -       *eofp = res.eof;
88929         return status;
88930  }
88931  
88932  static int
88933 -nfs4_proc_write(struct inode *inode, struct rpc_cred *cred,
88934 -               struct nfs_fattr *fattr, int flags,
88935 -               unsigned int base, unsigned int count,
88936 -               struct page *page, struct nfs_writeverf *verf)
88937 +nfs4_proc_write(struct nfs_write_data *wdata)
88938  {
88939 +       int rpcflags = wdata->flags;
88940 +       struct inode *inode = wdata->inode;
88941 +       struct nfs_fattr *fattr = wdata->res.fattr;
88942 +       nfs4_stateid *stateid = &wdata->args.stateid;
88943         struct nfs_server *server = NFS_SERVER(inode);
88944 -       struct nfs4_shareowner  *sp;
88945 -       uint64_t offset = page_offset(page) + base;
88946 -       struct nfs_writeargs arg = {
88947 -               .fh             = NFS_FH(inode),
88948 -               .offset         = offset,
88949 -               .count          = count,
88950 -               .stable         = (flags & NFS_RW_SYNC) ? NFS_FILE_SYNC : NFS_UNSTABLE,
88951 -               .pgbase         = base,
88952 -               .pages          = &page,
88953 -       };
88954 -       struct nfs_writeres res = {
88955 -               .fattr          = fattr,
88956 -               .count          = count,
88957 -               .verf           = verf,
88958 -       };
88959 +       struct nfs4_shareowner *sp;
88960         struct rpc_message msg = {
88961                 .rpc_proc       = &nfs4_procedures[NFSPROC4_CLNT_WRITE],
88962 -               .rpc_argp       = &arg,
88963 -               .rpc_resp       = &res,
88964 -               .rpc_cred       = cred,
88965 +               .rpc_argp       = &wdata->args,
88966 +               .rpc_resp       = &wdata->res,
88967 +               .rpc_cred       = wdata->cred,
88968 +       };
88969 +       int status;
88970 +
88971 +       dprintk("NFS call  write %d @ %Ld\n", wdata->args.count,
88972 +                       (long long) wdata->args.offset);
88973 +
88974 +       /*
88975 +        * Try first to use O_WRONLY, then O_RDWR stateid.
88976 +        */
88977 +       sp = nfs4_get_inode_share(inode, O_WRONLY);
88978 +       if (!sp)
88979 +               sp = nfs4_get_inode_share(inode, O_RDWR);
88980 +
88981 +       if (sp)
88982 +               memcpy(stateid, sp->so_stateid, sizeof(nfs4_stateid));
88983 +       else
88984 +               memcpy(stateid, zero_stateid, sizeof(nfs4_stateid));
88985 +
88986 +       fattr->valid = 0;
88987 +       status = rpc_call_sync(server->client, &msg, rpcflags);
88988 +       dprintk("NFS reply write: %d\n", status);
88989 +       return status;
88990 +}
88991 +
88992 +static int
88993 +nfs4_proc_commit(struct nfs_write_data *cdata)
88994 +{
88995 +       struct inode *inode = cdata->inode;
88996 +       struct nfs_fattr *fattr = cdata->res.fattr;
88997 +       nfs4_stateid *stateid = &cdata->args.stateid;
88998 +       struct nfs_server *server = NFS_SERVER(inode);
88999 +       struct nfs4_shareowner *sp;
89000 +       struct rpc_message msg = {
89001 +               .rpc_proc       = &nfs4_procedures[NFSPROC4_CLNT_COMMIT],
89002 +               .rpc_argp       = &cdata->args,
89003 +               .rpc_resp       = &cdata->res,
89004 +               .rpc_cred       = cdata->cred,
89005         };
89006 -       int                     rpcflags = (flags & NFS_RW_SWAP) ? NFS_RPC_SWAPFLAGS : 0;
89007 +       int status;
89008  
89009 -       dprintk("NFS call  write %d @ %Ld\n", count, (long long)offset);
89010 +       dprintk("NFS call  commit %d @ %Ld\n", cdata->args.count,
89011 +                       (long long) cdata->args.offset);
89012  
89013         /*
89014 -       * Try first to use O_WRONLY, then O_RDWR stateid.
89015 -       */
89016 +        * Try first to use O_WRONLY, then O_RDWR stateid.
89017 +        */
89018         sp = nfs4_get_inode_share(inode, O_WRONLY);
89019         if (!sp)
89020                 sp = nfs4_get_inode_share(inode, O_RDWR);
89021  
89022         if (sp)
89023 -               memcpy(arg.stateid,sp->so_stateid, sizeof(nfs4_stateid));
89024 +               memcpy(stateid, sp->so_stateid, sizeof(nfs4_stateid));
89025         else
89026 -               memcpy(arg.stateid, zero_stateid, sizeof(nfs4_stateid));
89027 +               memcpy(stateid, zero_stateid, sizeof(nfs4_stateid));
89028  
89029         fattr->valid = 0;
89030 -       return rpc_call_sync(server->client, &msg, rpcflags);
89031 +       status = rpc_call_sync(server->client, &msg, 0);
89032 +       dprintk("NFS reply commit: %d\n", status);
89033 +       return status;
89034  }
89035  
89036  /*
89037 @@ -1752,7 +1769,7 @@ struct nfs_rpc_ops        nfs_v4_clientops = {
89038         .readlink       = nfs4_proc_readlink,
89039         .read           = nfs4_proc_read,
89040         .write          = nfs4_proc_write,
89041 -       .commit         = NULL,
89042 +       .commit         = nfs4_proc_commit,
89043         .create         = nfs4_proc_create,
89044         .remove         = nfs4_proc_remove,
89045         .unlink_setup   = nfs4_proc_unlink_setup,
89046 --- linux-2.6.0-test6/fs/nfs/pagelist.c 2003-06-26 22:07:25.000000000 -0700
89047 +++ 25/fs/nfs/pagelist.c        2003-10-05 00:36:43.000000000 -0700
89048 @@ -154,26 +154,6 @@ nfs_release_request(struct nfs_page *req
89049  }
89050  
89051  /**
89052 - * nfs_release_list - cleanly dispose of an unattached list of page requests
89053 - * @list: list of doomed page requests
89054 - */
89055 -void
89056 -nfs_release_list(struct list_head *list)
89057 -{
89058 -       while (!list_empty(list)) {
89059 -               struct nfs_page *req = nfs_list_entry(list);
89060 -
89061 -               nfs_list_remove_request(req);
89062 -
89063 -               page_cache_release(req->wb_page);
89064 -
89065 -               /* Release struct file or cached credential */
89066 -               nfs_clear_request(req);
89067 -               nfs_page_free(req);
89068 -       }
89069 -}
89070 -
89071 -/**
89072   * nfs_list_add_request - Insert a request into a sorted list
89073   * @req: request
89074   * @head: head of list into which to insert the request.
89075 @@ -222,37 +202,6 @@ nfs_wait_on_request(struct nfs_page *req
89076  }
89077  
89078  /**
89079 - * nfs_wait_for_reads - wait for outstanding requests to complete
89080 - * @head: list of page requests to wait for
89081 - */
89082 -int
89083 -nfs_wait_for_reads(struct list_head *head)
89084 -{
89085 -       struct list_head *p = head->next;
89086 -       unsigned int res = 0;
89087 -
89088 -       while (p != head) {
89089 -               struct nfs_page *req = nfs_list_entry(p);
89090 -               int error;
89091 -
89092 -               if (!NFS_WBACK_BUSY(req))
89093 -                       continue;
89094 -
89095 -               req->wb_count++;
89096 -               error = nfs_wait_on_request(req);
89097 -               if (error < 0)
89098 -                       return error;
89099 -               nfs_list_remove_request(req);
89100 -               nfs_clear_request(req);
89101 -               nfs_page_free(req);
89102 -
89103 -               p = head->next;
89104 -               res++;
89105 -       }
89106 -       return res;
89107 -}
89108 -
89109 -/**
89110   * nfs_coalesce_requests - Split coalesced requests out from a list.
89111   * @head: source list
89112   * @dst: destination list
89113 --- linux-2.6.0-test6/fs/nfs/proc.c     2003-09-27 18:57:46.000000000 -0700
89114 +++ 25/fs/nfs/proc.c    2003-10-05 00:36:44.000000000 -0700
89115 @@ -149,82 +149,62 @@ nfs_proc_readlink(struct inode *inode, s
89116  }
89117  
89118  static int
89119 -nfs_proc_read(struct inode *inode, struct rpc_cred *cred,
89120 -             struct nfs_fattr *fattr, int flags,
89121 -             unsigned int base, unsigned int count, struct page *page,
89122 -             int *eofp)
89123 -{
89124 -       u64                     offset = page_offset(page) + base;
89125 -       struct nfs_readargs     arg = {
89126 -               .fh             = NFS_FH(inode),
89127 -               .offset         = offset,
89128 -               .count          = count,
89129 -               .pgbase         = base,
89130 -               .pages          = &page
89131 -       };
89132 -       struct nfs_readres      res = {
89133 -               .fattr          = fattr,
89134 -               .count          = count
89135 -       };
89136 +nfs_proc_read(struct nfs_read_data *rdata)
89137 +{
89138 +       int                     flags = rdata->flags;
89139 +       struct inode *          inode = rdata->inode;
89140 +       struct nfs_fattr *      fattr = rdata->res.fattr;
89141         struct rpc_message      msg = {
89142                 .rpc_proc       = &nfs_procedures[NFSPROC_READ],
89143 -               .rpc_argp       = &arg,
89144 -               .rpc_resp       = &res,
89145 -               .rpc_cred       = cred
89146 +               .rpc_argp       = &rdata->args,
89147 +               .rpc_resp       = &rdata->res,
89148 +               .rpc_cred       = rdata->cred,
89149         };
89150         int                     status;
89151  
89152 -       dprintk("NFS call  read %d @ %Ld\n", count, (long long)offset);
89153 +       dprintk("NFS call  read %d @ %Ld\n", rdata->args.count,
89154 +                       (long long) rdata->args.offset);
89155         fattr->valid = 0;
89156         status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
89157 -
89158 -       if (status >= 0)
89159 +       if (status >= 0) {
89160                 nfs_refresh_inode(inode, fattr);
89161 +               /* NFSv2 reads don't return an eof flag, so we make
89162 +                * up a value here.  XDR has already set eof to 0. */
89163 +               if (status < rdata->args.count)
89164 +                       rdata->res.eof = 1;
89165 +       }
89166         dprintk("NFS reply read: %d\n", status);
89167 -       *eofp = res.eof;
89168         return status;
89169  }
89170  
89171  static int
89172 -nfs_proc_write(struct inode *inode, struct rpc_cred *cred,
89173 -              struct nfs_fattr *fattr, int how,
89174 -              unsigned int base, unsigned int count,
89175 -              struct page *page, struct nfs_writeverf *verf)
89176 +nfs_proc_write(struct nfs_write_data *wdata)
89177  {
89178 -       u64                     offset = page_offset(page) + base;
89179 -       struct nfs_writeargs    arg = {
89180 -               .fh             = NFS_FH(inode),
89181 -               .offset         = offset,
89182 -               .count          = count,
89183 -               .stable         = NFS_FILE_SYNC,
89184 -               .pgbase         = base,
89185 -               .pages          = &page
89186 -       };
89187 -       struct nfs_writeres     res = {
89188 -               .fattr          = fattr,
89189 -               .verf           = verf,
89190 -               .count          = count
89191 -       };
89192 +       int                     flags = wdata->flags;
89193 +       struct inode *          inode = wdata->inode;
89194 +       struct nfs_fattr *      fattr = wdata->res.fattr;
89195         struct rpc_message      msg = {
89196                 .rpc_proc       = &nfs_procedures[NFSPROC_WRITE],
89197 -               .rpc_argp       = &arg,
89198 -               .rpc_resp       = &res,
89199 -               .rpc_cred       = cred
89200 +               .rpc_argp       = &wdata->args,
89201 +               .rpc_resp       = &wdata->res,
89202 +               .rpc_cred       = wdata->cred
89203         };
89204 -       int                     status, flags = 0;
89205 +       int                     status;
89206  
89207 -       dprintk("NFS call  write %d @ %Ld\n", count, (long long)offset);
89208 +       dprintk("NFS call  write %d @ %Ld\n", wdata->args.count,
89209 +                       (long long) wdata->args.offset);
89210         fattr->valid = 0;
89211 -       if (how & NFS_RW_SWAP)
89212 -               flags |= NFS_RPC_SWAPFLAGS;
89213         status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
89214 -
89215 -       if (status >= 0)
89216 +       if (status >= 0) {
89217                 nfs_write_refresh_inode(inode, fattr);
89218 -
89219 +               /* NFSv2 writes don't return a byte count or write
89220 +                * verifier, so we make up values here.  Note that
89221 +                * v2 writes are always NFS_FILE_SYNC writes. */
89222 +               wdata->res.count = wdata->args.count;
89223 +               wdata->verf.committed = NFS_FILE_SYNC;
89224 +       }
89225         dprintk("NFS reply write: %d\n", status);
89226 -       verf->committed = NFS_FILE_SYNC;      /* NFSv2 always syncs data */
89227 -       return status < 0? status : count;
89228 +       return status < 0? status : wdata->res.count;
89229  }
89230  
89231  static int
89232 --- linux-2.6.0-test6/fs/nfs/read.c     2003-06-26 22:07:25.000000000 -0700
89233 +++ 25/fs/nfs/read.c    2003-10-05 00:36:44.000000000 -0700
89234 @@ -69,19 +69,28 @@ void nfs_readdata_release(struct rpc_tas
89235  static int
89236  nfs_readpage_sync(struct file *file, struct inode *inode, struct page *page)
89237  {
89238 -       struct rpc_cred *cred = NULL;
89239 -       struct nfs_fattr fattr;
89240 -       unsigned int    offset = 0;
89241         unsigned int    rsize = NFS_SERVER(inode)->rsize;
89242         unsigned int    count = PAGE_CACHE_SIZE;
89243         int             result;
89244 -       int             flags = IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0;
89245 -       int             eof;
89246 +       struct nfs_read_data    rdata = {
89247 +               .flags          = (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0),
89248 +               .cred           = NULL,
89249 +               .inode          = inode,
89250 +               .args           = {
89251 +                       .fh             = NFS_FH(inode),
89252 +                       .pages          = &page,
89253 +                       .pgbase         = 0UL,
89254 +                       .count          = rsize,
89255 +               },
89256 +               .res            = {
89257 +                       .fattr          = &rdata.fattr,
89258 +               }
89259 +       };
89260  
89261         dprintk("NFS: nfs_readpage_sync(%p)\n", page);
89262  
89263         if (file)
89264 -               cred = nfs_file_cred(file);
89265 +               rdata.cred = nfs_file_cred(file);
89266  
89267         /*
89268          * This works now because the socket layer never tries to DMA
89269 @@ -89,17 +98,19 @@ nfs_readpage_sync(struct file *file, str
89270          */
89271         do {
89272                 if (count < rsize)
89273 -                       rsize = count;
89274 +                       rdata.args.count = count;
89275 +               rdata.res.count = rdata.args.count;
89276 +               rdata.args.offset = page_offset(page) + rdata.args.pgbase;
89277  
89278                 dprintk("NFS: nfs_proc_read(%s, (%s/%Ld), %Lu, %u)\n",
89279                         NFS_SERVER(inode)->hostname,
89280                         inode->i_sb->s_id,
89281                         (long long)NFS_FILEID(inode),
89282 -                       (unsigned long long)offset, rsize);
89283 +                       (unsigned long long)rdata.args.pgbase,
89284 +                       rdata.args.count);
89285  
89286                 lock_kernel();
89287 -               result = NFS_PROTO(inode)->read(inode, cred, &fattr, flags,
89288 -                                               offset, rsize, page, &eof);
89289 +               result = NFS_PROTO(inode)->read(&rdata);
89290                 unlock_kernel();
89291  
89292                 /*
89293 @@ -111,14 +122,15 @@ nfs_readpage_sync(struct file *file, str
89294                                 result = -EINVAL;
89295                         goto io_error;
89296                 }
89297 -               count  -= result;
89298 -               offset += result;
89299 -               if (result < rsize)     /* NFSv2ism */
89300 +               count -= result;
89301 +               rdata.args.pgbase += result;
89302 +
89303 +               if (rdata.res.eof)
89304                         break;
89305         } while (count);
89306  
89307         if (count)
89308 -               memclear_highpage_flush(page, offset, count);
89309 +               memclear_highpage_flush(page, rdata.args.pgbase, count);
89310         SetPageUptodate(page);
89311         if (PageError(page))
89312                 ClearPageError(page);
89313 --- linux-2.6.0-test6/fs/nfs/write.c    2003-08-22 19:23:42.000000000 -0700
89314 +++ 25/fs/nfs/write.c   2003-10-05 00:36:44.000000000 -0700
89315 @@ -132,66 +132,73 @@ static int
89316  nfs_writepage_sync(struct file *file, struct inode *inode, struct page *page,
89317                    unsigned int offset, unsigned int count)
89318  {
89319 -       struct rpc_cred *cred = NULL;
89320 -       loff_t          base;
89321         unsigned int    wsize = NFS_SERVER(inode)->wsize;
89322 -       int             result, refresh = 0, written = 0, flags;
89323 -       u8              *buffer;
89324 -       struct nfs_fattr fattr;
89325 -       struct nfs_writeverf verf;
89326 -
89327 +       int             result, written = 0;
89328 +       int             swapfile = IS_SWAPFILE(inode);
89329 +       struct nfs_write_data   wdata = {
89330 +               .flags          = swapfile ? NFS_RPC_SWAPFLAGS : 0,
89331 +               .cred           = NULL,
89332 +               .inode          = inode,
89333 +               .args           = {
89334 +                       .fh             = NFS_FH(inode),
89335 +                       .pages          = &page,
89336 +                       .stable         = NFS_FILE_SYNC,
89337 +                       .pgbase         = offset,
89338 +                       .count          = wsize,
89339 +               },
89340 +               .res            = {
89341 +                       .fattr          = &wdata.fattr,
89342 +                       .verf           = &wdata.verf,
89343 +               },
89344 +       };
89345  
89346         if (file)
89347 -               cred = get_rpccred(nfs_file_cred(file));
89348 -       if (!cred)
89349 -               cred = get_rpccred(NFS_I(inode)->mm_cred);
89350 +               wdata.cred = get_rpccred(nfs_file_cred(file));
89351 +       if (!wdata.cred)
89352 +               wdata.cred = get_rpccred(NFS_I(inode)->mm_cred);
89353  
89354         dprintk("NFS:      nfs_writepage_sync(%s/%Ld %d@%Ld)\n",
89355                 inode->i_sb->s_id,
89356                 (long long)NFS_FILEID(inode),
89357                 count, (long long)(page_offset(page) + offset));
89358  
89359 -       base = page_offset(page) + offset;
89360 -
89361 -       flags = ((IS_SWAPFILE(inode)) ? NFS_RW_SWAP : 0) | NFS_RW_SYNC;
89362 -
89363         do {
89364 -               if (count < wsize && !IS_SWAPFILE(inode))
89365 -                       wsize = count;
89366 +               if (count < wsize && !swapfile)
89367 +                       wdata.args.count = count;
89368 +               wdata.args.offset = page_offset(page) + wdata.args.pgbase;
89369  
89370 -               result = NFS_PROTO(inode)->write(inode, cred, &fattr, flags,
89371 -                                                offset, wsize, page, &verf);
89372 +               result = NFS_PROTO(inode)->write(&wdata);
89373  
89374                 if (result < 0) {
89375                         /* Must mark the page invalid after I/O error */
89376                         ClearPageUptodate(page);
89377                         goto io_error;
89378                 }
89379 -               if (result != wsize)
89380 -                       printk("NFS: short write, wsize=%u, result=%d\n",
89381 -                       wsize, result);
89382 -               refresh = 1;
89383 -               buffer  += wsize;
89384 -               base    += wsize;
89385 -               offset  += wsize;
89386 -               written += wsize;
89387 -               count   -= wsize;
89388 +               if (result < wdata.args.count)
89389 +                       printk(KERN_WARNING "NFS: short write, count=%u, result=%d\n",
89390 +                                       wdata.args.count, result);
89391 +
89392 +               wdata.args.offset += result;
89393 +               wdata.args.pgbase += result;
89394 +               written += result;
89395 +               count -= result;
89396 +
89397                 /*
89398                  * If we've extended the file, update the inode
89399                  * now so we don't invalidate the cache.
89400                  */
89401 -               if (base > i_size_read(inode))
89402 -                       i_size_write(inode, base);
89403 +               if (wdata.args.offset > i_size_read(inode))
89404 +                       i_size_write(inode, wdata.args.offset);
89405         } while (count);
89406  
89407         if (PageError(page))
89408                 ClearPageError(page);
89409  
89410  io_error:
89411 -       if (cred)
89412 -               put_rpccred(cred);
89413 +       if (wdata.cred)
89414 +               put_rpccred(wdata.cred);
89415  
89416 -       return written? written : result;
89417 +       return written ? written : result;
89418  }
89419  
89420  static int
89421 --- linux-2.6.0-test6/fs/open.c 2003-09-27 18:57:46.000000000 -0700
89422 +++ 25/fs/open.c        2003-10-05 00:36:52.000000000 -0700
89423 @@ -190,7 +190,9 @@ int do_truncate(struct dentry *dentry, l
89424         newattrs.ia_size = length;
89425         newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
89426         down(&dentry->d_inode->i_sem);
89427 +       down_write(&dentry->d_inode->i_alloc_sem);
89428         err = notify_change(dentry, &newattrs);
89429 +       up_write(&dentry->d_inode->i_alloc_sem);
89430         up(&dentry->d_inode->i_sem);
89431         return err;
89432  }
89433 @@ -772,7 +774,8 @@ struct file *dentry_open(struct dentry *
89434                         goto cleanup_file;
89435         }
89436  
89437 -       file_ra_state_init(&f->f_ra, inode->i_mapping);
89438 +       f->f_mapping = inode->i_mapping;
89439 +       file_ra_state_init(&f->f_ra, f->f_mapping);
89440         f->f_dentry = dentry;
89441         f->f_vfsmnt = mnt;
89442         f->f_pos = 0;
89443 @@ -788,8 +791,8 @@ struct file *dentry_open(struct dentry *
89444  
89445         /* NB: we're sure to have correct a_ops only after f_op->open */
89446         if (f->f_flags & O_DIRECT) {
89447 -               if (!inode->i_mapping || !inode->i_mapping->a_ops ||
89448 -                       !inode->i_mapping->a_ops->direct_IO) {
89449 +               if (!f->f_mapping || !f->f_mapping->a_ops ||
89450 +                       !f->f_mapping->a_ops->direct_IO) {
89451                                 fput(f);
89452                                 f = ERR_PTR(-EINVAL);
89453                 }
89454 @@ -1019,7 +1022,7 @@ out_unlock:
89455  asmlinkage long sys_vhangup(void)
89456  {
89457         if (capable(CAP_SYS_TTY_CONFIG)) {
89458 -               tty_vhangup(current->tty);
89459 +               tty_vhangup(process_tty(current));
89460                 return 0;
89461         }
89462         return -EPERM;
89463 --- linux-2.6.0-test6/fs/pipe.c 2003-08-22 19:23:42.000000000 -0700
89464 +++ 25/fs/pipe.c        2003-10-05 00:34:03.000000000 -0700
89465 @@ -580,6 +580,7 @@ int do_pipe(int *fd)
89466         d_add(dentry, inode);
89467         f1->f_vfsmnt = f2->f_vfsmnt = mntget(mntget(pipe_mnt));
89468         f1->f_dentry = f2->f_dentry = dget(dentry);
89469 +       f1->f_mapping = f2->f_mapping = inode->i_mapping;
89470  
89471         /* read file */
89472         f1->f_pos = f2->f_pos = 0;
89473 --- linux-2.6.0-test6/fs/proc/array.c   2003-09-27 18:57:46.000000000 -0700
89474 +++ 25/fs/proc/array.c  2003-10-05 00:36:15.000000000 -0700
89475 @@ -304,9 +304,9 @@ int proc_pid_stat(struct task_struct *ta
89476         mm = task->mm;
89477         if(mm)
89478                 mm = mmgrab(mm);
89479 -       if (task->tty) {
89480 -               tty_pgrp = task->tty->pgrp;
89481 -               tty_nr = new_encode_dev(tty_devnum(task->tty));
89482 +       if (process_tty(task)) {
89483 +               tty_pgrp = process_tty(task)->pgrp;
89484 +               tty_nr = new_encode_dev(tty_devnum(process_tty(task)));
89485         }
89486         task_unlock(task);
89487         if (mm) {
89488 @@ -345,7 +345,7 @@ int proc_pid_stat(struct task_struct *ta
89489                 state,
89490                 ppid,
89491                 process_group(task),
89492 -               task->session,
89493 +               process_session(task),
89494                 tty_nr,
89495                 tty_pgrp,
89496                 task->flags,
89497 --- linux-2.6.0-test6/fs/proc/base.c    2003-09-27 18:57:46.000000000 -0700
89498 +++ 25/fs/proc/base.c   2003-10-05 00:36:09.000000000 -0700
89499 @@ -53,6 +53,7 @@ enum pid_directory_inos {
89500         PROC_TGID_EXE,
89501         PROC_TGID_FD,
89502         PROC_TGID_ENVIRON,
89503 +       PROC_TGID_AUXV,
89504         PROC_TGID_CMDLINE,
89505         PROC_TGID_STAT,
89506         PROC_TGID_STATM,
89507 @@ -75,6 +76,7 @@ enum pid_directory_inos {
89508         PROC_TID_EXE,
89509         PROC_TID_FD,
89510         PROC_TID_ENVIRON,
89511 +       PROC_TID_AUXV,
89512         PROC_TID_CMDLINE,
89513         PROC_TID_STAT,
89514         PROC_TID_STATM,
89515 @@ -104,6 +106,7 @@ static struct pid_entry tgid_base_stuff[
89516         E(PROC_TGID_TASK,      "task",    S_IFDIR|S_IRUGO|S_IXUGO),
89517         E(PROC_TGID_FD,        "fd",      S_IFDIR|S_IRUSR|S_IXUSR),
89518         E(PROC_TGID_ENVIRON,   "environ", S_IFREG|S_IRUSR),
89519 +       E(PROC_TGID_AUXV,      "auxv",    S_IFREG|S_IRUSR),
89520         E(PROC_TGID_STATUS,    "status",  S_IFREG|S_IRUGO),
89521         E(PROC_TGID_CMDLINE,   "cmdline", S_IFREG|S_IRUGO),
89522         E(PROC_TGID_STAT,      "stat",    S_IFREG|S_IRUGO),
89523 @@ -125,6 +128,7 @@ static struct pid_entry tgid_base_stuff[
89524  static struct pid_entry tid_base_stuff[] = {
89525         E(PROC_TID_FD,         "fd",      S_IFDIR|S_IRUSR|S_IXUSR),
89526         E(PROC_TID_ENVIRON,    "environ", S_IFREG|S_IRUSR),
89527 +       E(PROC_TID_AUXV,       "auxv",    S_IFREG|S_IRUSR),
89528         E(PROC_TID_STATUS,     "status",  S_IFREG|S_IRUGO),
89529         E(PROC_TID_CMDLINE,    "cmdline", S_IFREG|S_IRUGO),
89530         E(PROC_TID_STAT,       "stat",    S_IFREG|S_IRUGO),
89531 @@ -322,6 +326,25 @@ out:
89532         return res;
89533  }
89534  
89535 +static int proc_pid_auxv(struct task_struct *task, char *buffer)
89536 +{
89537 +       int res = 0;
89538 +       struct mm_struct *mm = get_task_mm(task);
89539 +       if (mm) {
89540 +               unsigned int nwords = 0;
89541 +               do
89542 +                       nwords += 2;
89543 +               while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
89544 +               res = nwords * sizeof(mm->saved_auxv[0]);
89545 +               if (res > PAGE_SIZE)
89546 +                       res = PAGE_SIZE;
89547 +               memcpy(buffer, mm->saved_auxv, res);
89548 +               mmput(mm);
89549 +       }
89550 +       return res;
89551 +}
89552 +
89553 +
89554  #ifdef CONFIG_KALLSYMS
89555  /*
89556   * Provides a wchan file via kallsyms in a proper one-value-per-file format.
89557 @@ -1271,6 +1294,11 @@ static struct dentry *proc_pident_lookup
89558                         inode->i_fop = &proc_info_file_operations;
89559                         ei->op.proc_read = proc_pid_environ;
89560                         break;
89561 +               case PROC_TID_AUXV:
89562 +               case PROC_TGID_AUXV:
89563 +                       inode->i_fop = &proc_info_file_operations;
89564 +                       ei->op.proc_read = proc_pid_auxv;
89565 +                       break;
89566                 case PROC_TID_STATUS:
89567                 case PROC_TGID_STATUS:
89568                         inode->i_fop = &proc_info_file_operations;
89569 --- linux-2.6.0-test6/fs/proc/inode.c   2003-09-27 18:57:46.000000000 -0700
89570 +++ 25/fs/proc/inode.c  2003-10-05 00:33:24.000000000 -0700
89571 @@ -14,6 +14,7 @@
89572  #include <linux/limits.h>
89573  #include <linux/init.h>
89574  #include <linux/module.h>
89575 +#include <linux/parser.h>
89576  #include <linux/smp_lock.h>
89577  
89578  #include <asm/system.h>
89579 @@ -135,34 +136,47 @@ static struct super_operations proc_sops
89580         .statfs         = simple_statfs,
89581  };
89582  
89583 +enum {
89584 +       Opt_uid, Opt_gid, Opt_err
89585 +};
89586 +
89587 +static match_table_t tokens = {
89588 +       {Opt_uid, "uid=%u"},
89589 +       {Opt_gid, "gid=%u"},
89590 +       {Opt_err, NULL}
89591 +};
89592 +
89593  static int parse_options(char *options,uid_t *uid,gid_t *gid)
89594  {
89595 -       char *this_char,*value;
89596 +       char *p;
89597 +       int option;
89598  
89599         *uid = current->uid;
89600         *gid = current->gid;
89601         if (!options)
89602                 return 1;
89603 -       while ((this_char = strsep(&options,",")) != NULL) {
89604 -               if (!*this_char)
89605 +
89606 +       while ((p = strsep(&options, ",")) != NULL) {
89607 +               substring_t args[MAX_OPT_ARGS];
89608 +               int token;
89609 +               if (!*p)
89610                         continue;
89611 -               if ((value = strchr(this_char,'=')) != NULL)
89612 -                       *value++ = 0;
89613 -               if (!strcmp(this_char,"uid")) {
89614 -                       if (!value || !*value)
89615 -                               return 0;
89616 -                       *uid = simple_strtoul(value,&value,0);
89617 -                       if (*value)
89618 -                               return 0;
89619 -               }
89620 -               else if (!strcmp(this_char,"gid")) {
89621 -                       if (!value || !*value)
89622 +
89623 +               token = match_token(p, tokens, args);
89624 +               switch (token) {
89625 +               case Opt_uid:
89626 +                       if (match_int(args, &option))
89627                                 return 0;
89628 -                       *gid = simple_strtoul(value,&value,0);
89629 -                       if (*value)
89630 +                       *uid = option;
89631 +                       break;
89632 +               case Opt_gid:
89633 +                       if (match_int(args, &option))
89634                                 return 0;
89635 +                       *gid = option;
89636 +                       break;
89637 +               default:
89638 +                       return 0;
89639                 }
89640 -               else return 1;
89641         }
89642         return 1;
89643  }
89644 --- linux-2.6.0-test6/fs/proc/proc_misc.c       2003-09-27 18:57:46.000000000 -0700
89645 +++ 25/fs/proc/proc_misc.c      2003-10-05 00:36:40.000000000 -0700
89646 @@ -638,6 +638,36 @@ static void create_seq_entry(char *name,
89647                 entry->proc_fops = f;
89648  }
89649  
89650 +#ifdef CONFIG_LOCKMETER
89651 +extern ssize_t get_lockmeter_info(char *, size_t, loff_t *);
89652 +extern ssize_t put_lockmeter_info(const char *, size_t);
89653 +extern int get_lockmeter_info_size(void);
89654 +
89655 +/*
89656 + * This function accesses lock metering information.
89657 + */
89658 +static ssize_t read_lockmeter(struct file *file, char *buf,
89659 +                             size_t count, loff_t *ppos)
89660 +{
89661 +       return get_lockmeter_info(buf, count, ppos);
89662 +}
89663 +
89664 +/*
89665 + * Writing to /proc/lockmeter resets the counters
89666 + */
89667 +static ssize_t write_lockmeter(struct file * file, const char * buf,
89668 +                              size_t count, loff_t *ppos)
89669 +{
89670 +       return put_lockmeter_info(buf, count);
89671 +}
89672 +
89673 +static struct file_operations proc_lockmeter_operations = {
89674 +       NULL,           /* lseek */
89675 +       read:           read_lockmeter,
89676 +       write:          write_lockmeter,
89677 +};
89678 +#endif  /* CONFIG_LOCKMETER */
89679 +
89680  void __init proc_misc_init(void)
89681  {
89682         struct proc_dir_entry *entry;
89683 @@ -705,6 +735,13 @@ void __init proc_misc_init(void)
89684         if (entry)
89685                 entry->proc_fops = &proc_sysrq_trigger_operations;
89686  #endif
89687 +#ifdef CONFIG_LOCKMETER
89688 +       entry = create_proc_entry("lockmeter", S_IWUSR | S_IRUGO, NULL);
89689 +       if (entry) {
89690 +               entry->proc_fops = &proc_lockmeter_operations;
89691 +               entry->size = get_lockmeter_info_size();
89692 +       }
89693 +#endif
89694  #ifdef CONFIG_PPC32
89695         {
89696                 extern struct file_operations ppc_htab_operations;
89697 --- linux-2.6.0-test6/fs/read_write.c   2003-07-13 21:44:35.000000000 -0700
89698 +++ 25/fs/read_write.c  2003-10-05 00:34:07.000000000 -0700
89699 @@ -26,7 +26,7 @@ struct file_operations generic_ro_fops =
89700  loff_t generic_file_llseek(struct file *file, loff_t offset, int origin)
89701  {
89702         long long retval;
89703 -       struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
89704 +       struct inode *inode = file->f_mapping->host;
89705  
89706         down(&inode->i_sem);
89707         switch (origin) {
89708 --- linux-2.6.0-test6/fs/reiserfs/file.c        2003-09-27 18:57:46.000000000 -0700
89709 +++ 25/fs/reiserfs/file.c       2003-10-05 00:34:11.000000000 -0700
89710 @@ -1052,7 +1052,7 @@ ssize_t reiserfs_file_write( struct file
89711      /* Check if we can write to specified region of file, file
89712         is not overly big and this kind of stuff. Adjust pos and
89713         count, if needed */
89714 -    res = generic_write_checks(inode, file, &pos, &count, 0);
89715 +    res = generic_write_checks(file, &pos, &count, 0);
89716      if (res)
89717         goto out;
89718  
89719 @@ -1179,7 +1179,7 @@ ssize_t reiserfs_file_write( struct file
89720      }
89721  
89722      if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
89723 -       res = generic_osync_inode(inode, OSYNC_METADATA|OSYNC_DATA);
89724 +       res = generic_osync_inode(inode, file->f_mapping, OSYNC_METADATA|OSYNC_DATA);
89725  
89726      up(&inode->i_sem);
89727      return (already_written != 0)?already_written:res;
89728 --- linux-2.6.0-test6/fs/reiserfs/inode.c       2003-09-27 18:57:46.000000000 -0700
89729 +++ 25/fs/reiserfs/inode.c      2003-10-05 00:34:07.000000000 -0700
89730 @@ -2375,7 +2375,7 @@ static int reiserfs_direct_IO(int rw, st
89731                               loff_t offset, unsigned long nr_segs)
89732  {
89733      struct file *file = iocb->ki_filp;
89734 -    struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
89735 +    struct inode *inode = file->f_mapping->host;
89736  
89737      return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
89738                               offset, nr_segs, reiserfs_get_blocks_direct_io, NULL);
89739 --- linux-2.6.0-test6/fs/reiserfs/journal.c     2003-09-27 18:57:46.000000000 -0700
89740 +++ 25/fs/reiserfs/journal.c    2003-10-05 00:34:11.000000000 -0700
89741 @@ -1937,18 +1937,13 @@ static int journal_init_dev( struct supe
89742  
89743         journal -> j_dev_file = filp_open( jdev_name, 0, 0 );
89744         if( !IS_ERR( journal -> j_dev_file ) ) {
89745 -               struct inode *jdev_inode;
89746 -
89747 -               jdev_inode = journal -> j_dev_file -> f_dentry -> d_inode;
89748 -               journal -> j_dev_bd = jdev_inode -> i_bdev;
89749 +               struct inode *jdev_inode = journal->j_dev_file->f_mapping->host;
89750                 if( !S_ISBLK( jdev_inode -> i_mode ) ) {
89751                         printk( "journal_init_dev: '%s' is not a block device\n", jdev_name );
89752                         result = -ENOTBLK;
89753 -               } else if( jdev_inode -> i_bdev == NULL ) {
89754 -                       printk( "journal_init_dev: bdev uninitialized for '%s'\n", jdev_name );
89755 -                       result = -ENOMEM;
89756                 } else  {
89757                         /* ok */
89758 +                       journal->j_dev_bd = I_BDEV(jdev_inode);
89759                         set_blocksize(journal->j_dev_bd, super->s_blocksize);
89760                 }
89761         } else {
89762 --- linux-2.6.0-test6/fs/seq_file.c     2003-06-14 12:18:28.000000000 -0700
89763 +++ 25/fs/seq_file.c    2003-10-05 00:33:24.000000000 -0700
89764 @@ -6,6 +6,7 @@
89765   */
89766  
89767  #include <linux/fs.h>
89768 +#include <linux/module.h>
89769  #include <linux/seq_file.h>
89770  #include <linux/slab.h>
89771  
89772 @@ -37,6 +38,8 @@ int seq_open(struct file *file, struct s
89773         return 0;
89774  }
89775  
89776 +EXPORT_SYMBOL(seq_open);
89777 +
89778  /**
89779   *     seq_read -      ->read() method for sequential files.
89780   *     @file, @buf, @size, @ppos: see file_operations method
89781 @@ -144,6 +147,8 @@ Efault:
89782         goto Done;
89783  }
89784  
89785 +EXPORT_SYMBOL(seq_read);
89786 +
89787  static int traverse(struct seq_file *m, loff_t offset)
89788  {
89789         loff_t pos = 0;
89790 @@ -228,6 +233,8 @@ loff_t seq_lseek(struct file *file, loff
89791         return retval;
89792  }
89793  
89794 +EXPORT_SYMBOL(seq_lseek);
89795 +
89796  /**
89797   *     seq_release -   free the structures associated with sequential file.
89798   *     @file: file in question
89799 @@ -244,6 +251,8 @@ int seq_release(struct inode *inode, str
89800         return 0;
89801  }
89802  
89803 +EXPORT_SYMBOL(seq_release);
89804 +
89805  /**
89806   *     seq_escape -    print string into buffer, escaping some characters
89807   *     @m:     target buffer
89808 @@ -279,6 +288,8 @@ int seq_escape(struct seq_file *m, const
89809          return 0;
89810  }
89811  
89812 +EXPORT_SYMBOL(seq_escape);
89813 +
89814  int seq_printf(struct seq_file *m, const char *f, ...)
89815  {
89816         va_list args;
89817 @@ -297,9 +308,11 @@ int seq_printf(struct seq_file *m, const
89818         return -1;
89819  }
89820  
89821 +EXPORT_SYMBOL(seq_printf);
89822 +
89823  int seq_path(struct seq_file *m,
89824 -               struct vfsmount *mnt, struct dentry *dentry,
89825 -               char *esc)
89826 +            struct vfsmount *mnt, struct dentry *dentry,
89827 +            char *esc)
89828  {
89829         if (m->count < m->size) {
89830                 char *s = m->buf + m->count;
89831 @@ -328,6 +341,8 @@ int seq_path(struct seq_file *m,
89832         return -1;
89833  }
89834  
89835 +EXPORT_SYMBOL(seq_path);
89836 +
89837  static void *single_start(struct seq_file *p, loff_t *pos)
89838  {
89839         return NULL + (*pos == 0);
89840 @@ -343,7 +358,8 @@ static void single_stop(struct seq_file 
89841  {
89842  }
89843  
89844 -int single_open(struct file *file, int (*show)(struct seq_file *, void*), void *data)
89845 +int single_open(struct file *file, int (*show)(struct seq_file *, void *),
89846 +               void *data)
89847  {
89848         struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
89849         int res = -ENOMEM;
89850 @@ -362,6 +378,8 @@ int single_open(struct file *file, int (
89851         return res;
89852  }
89853  
89854 +EXPORT_SYMBOL(single_open);
89855 +
89856  int single_release(struct inode *inode, struct file *file)
89857  {
89858         struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
89859 @@ -370,6 +388,8 @@ int single_release(struct inode *inode, 
89860         return res;
89861  }
89862  
89863 +EXPORT_SYMBOL(single_release);
89864 +
89865  int seq_release_private(struct inode *inode, struct file *file)
89866  {
89867         struct seq_file *seq = file->private_data;
89868 @@ -379,3 +399,4 @@ int seq_release_private(struct inode *in
89869         return seq_release(inode, file);
89870  }
89871  
89872 +EXPORT_SYMBOL(seq_release_private);
89873 --- linux-2.6.0-test6/fs/smbfs/inode.c  2003-09-27 18:57:46.000000000 -0700
89874 +++ 25/fs/smbfs/inode.c 2003-10-05 00:33:24.000000000 -0700
89875 @@ -551,8 +551,8 @@ int smb_fill_super(struct super_block *s
89876         if (ver == SMB_MOUNT_OLDVERSION) {
89877                 mnt->version = oldmnt->version;
89878  
89879 -               mnt->uid = low2highuid(oldmnt->uid);
89880 -               mnt->gid = low2highuid(oldmnt->gid);
89881 +               mnt->uid = OLD_TO_NEW_UID(oldmnt->uid);
89882 +               mnt->gid = OLD_TO_NEW_GID(oldmnt->gid);
89883  
89884                 mnt->file_mode = (oldmnt->file_mode & S_IRWXUGO) | S_IFREG;
89885                 mnt->dir_mode = (oldmnt->dir_mode & S_IRWXUGO) | S_IFDIR;
89886 --- linux-2.6.0-test6/fs/super.c        2003-09-27 18:57:46.000000000 -0700
89887 +++ 25/fs/super.c       2003-10-05 00:36:10.000000000 -0700
89888 @@ -21,6 +21,7 @@
89889   */
89890  
89891  #include <linux/config.h>
89892 +#include <linux/module.h>
89893  #include <linux/slab.h>
89894  #include <linux/smp_lock.h>
89895  #include <linux/acct.h>
89896 @@ -134,9 +135,11 @@ void deactivate_super(struct super_block
89897         }
89898  }
89899  
89900 +EXPORT_SYMBOL(deactivate_super);
89901 +
89902  /**
89903 - *     grab_super      - acquire an active reference
89904 - *     @s      - reference we are trying to make active
89905 + *     grab_super - acquire an active reference
89906 + *     @s: reference we are trying to make active
89907   *
89908   *     Tries to acquire an active reference.  grab_super() is used when we
89909   *     had just found a superblock in super_blocks or fs_type->fs_supers
89910 @@ -214,6 +217,8 @@ void generic_shutdown_super(struct super
89911         up_write(&sb->s_umount);
89912  }
89913  
89914 +EXPORT_SYMBOL(generic_shutdown_super);
89915 +
89916  /**
89917   *     sget    -       find or create a superblock
89918   *     @type:  filesystem type superblock should belong to
89919 @@ -226,13 +231,10 @@ struct super_block *sget(struct file_sys
89920                         int (*set)(struct super_block *,void *),
89921                         void *data)
89922  {
89923 -       struct super_block *s = alloc_super();
89924 +       struct super_block *s = NULL;
89925         struct list_head *p;
89926         int err;
89927  
89928 -       if (!s)
89929 -               return ERR_PTR(-ENOMEM);
89930 -
89931  retry:
89932         spin_lock(&sb_lock);
89933         if (test) list_for_each(p, &type->fs_supers) {
89934 @@ -242,9 +244,18 @@ retry:
89935                         continue;
89936                 if (!grab_super(old))
89937                         goto retry;
89938 -               destroy_super(s);
89939 +               if (s)
89940 +                       destroy_super(s);
89941                 return old;
89942         }
89943 +       if (!s) {
89944 +               spin_unlock(&sb_lock);
89945 +               s = alloc_super();
89946 +               if (!s)
89947 +                       return ERR_PTR(-ENOMEM);
89948 +               goto retry;
89949 +       }
89950 +               
89951         err = set(s, data);
89952         if (err) {
89953                 spin_unlock(&sb_lock);
89954 @@ -259,12 +270,16 @@ retry:
89955         return s;
89956  }
89957  
89958 +EXPORT_SYMBOL(sget);
89959 +
89960  void drop_super(struct super_block *sb)
89961  {
89962         up_read(&sb->s_umount);
89963         put_super(sb);
89964  }
89965  
89966 +EXPORT_SYMBOL(drop_super);
89967 +
89968  static inline void write_super(struct super_block *sb)
89969  {
89970         lock_super(sb);
89971 @@ -353,8 +368,8 @@ restart:
89972  }
89973  
89974  /**
89975 - *     get_super       -       get the superblock of a device
89976 - *     @dev: device to get the superblock for
89977 + *     get_super - get the superblock of a device
89978 + *     @bdev: device to get the superblock for
89979   *     
89980   *     Scans the superblock list and finds the superblock of the file system
89981   *     mounted on the device given. %NULL is returned if no match is found.
89982 @@ -382,6 +397,8 @@ rescan:
89983         spin_unlock(&sb_lock);
89984         return NULL;
89985  }
89986 +
89987 +EXPORT_SYMBOL(get_super);
89988   
89989  struct super_block * user_get_super(dev_t dev)
89990  {
89991 @@ -405,6 +422,8 @@ rescan:
89992         return NULL;
89993  }
89994  
89995 +EXPORT_SYMBOL(user_get_super);
89996 +
89997  asmlinkage long sys_ustat(unsigned dev, struct ustat __user * ubuf)
89998  {
89999          struct super_block *s;
90000 @@ -442,10 +461,11 @@ static void mark_files_ro(struct super_b
90001  }
90002  
90003  /**
90004 - *     do_remount_sb   -       asks filesystem to change mount options.
90005 + *     do_remount_sb - asks filesystem to change mount options.
90006   *     @sb:    superblock in question
90007   *     @flags: numeric part of options
90008   *     @data:  the rest of options
90009 + *      @force: whether or not to force the change
90010   *
90011   *     Alters the mount options of a mounted file system.
90012   */
90013 @@ -534,6 +554,8 @@ int set_anon_super(struct super_block *s
90014         return 0;
90015  }
90016  
90017 +EXPORT_SYMBOL(set_anon_super);
90018 +
90019  void kill_anon_super(struct super_block *sb)
90020  {
90021         int slot = MINOR(sb->s_dev);
90022 @@ -543,6 +565,8 @@ void kill_anon_super(struct super_block 
90023         spin_unlock(&unnamed_dev_lock);
90024  }
90025  
90026 +EXPORT_SYMBOL(kill_anon_super);
90027 +
90028  void kill_litter_super(struct super_block *sb)
90029  {
90030         if (sb->s_root)
90031 @@ -550,6 +574,8 @@ void kill_litter_super(struct super_bloc
90032         kill_anon_super(sb);
90033  }
90034  
90035 +EXPORT_SYMBOL(kill_litter_super);
90036 +
90037  static int set_bdev_super(struct super_block *s, void *data)
90038  {
90039         s->s_bdev = data;
90040 @@ -608,6 +634,8 @@ out:
90041         return s;
90042  }
90043  
90044 +EXPORT_SYMBOL(get_sb_bdev);
90045 +
90046  void kill_block_super(struct super_block *sb)
90047  {
90048         struct block_device *bdev = sb->s_bdev;
90049 @@ -616,6 +644,8 @@ void kill_block_super(struct super_block
90050         close_bdev_excl(bdev, BDEV_FS);
90051  }
90052  
90053 +EXPORT_SYMBOL(kill_block_super);
90054 +
90055  struct super_block *get_sb_nodev(struct file_system_type *fs_type,
90056         int flags, void *data,
90057         int (*fill_super)(struct super_block *, void *, int))
90058 @@ -638,6 +668,8 @@ struct super_block *get_sb_nodev(struct 
90059         return s;
90060  }
90061  
90062 +EXPORT_SYMBOL(get_sb_nodev);
90063 +
90064  static int compare_single(struct super_block *s, void *p)
90065  {
90066         return 1;
90067 @@ -667,6 +699,8 @@ struct super_block *get_sb_single(struct
90068         return s;
90069  }
90070  
90071 +EXPORT_SYMBOL(get_sb_single);
90072 +
90073  struct vfsmount *
90074  do_kern_mount(const char *fstype, int flags, const char *name, void *data)
90075  {
90076 @@ -709,3 +743,5 @@ struct vfsmount *kern_mount(struct file_
90077  {
90078         return do_kern_mount(type->name, 0, type->name, NULL);
90079  }
90080 +
90081 +EXPORT_SYMBOL(kern_mount);
90082 --- linux-2.6.0-test6/fs/sysfs/dir.c    2003-09-27 18:57:46.000000000 -0700
90083 +++ 25/fs/sysfs/dir.c   2003-10-05 00:34:36.000000000 -0700
90084 @@ -82,8 +82,16 @@ static void remove_dir(struct dentry * d
90085  {
90086         struct dentry * parent = dget(d->d_parent);
90087         down(&parent->d_inode->i_sem);
90088 -       d_delete(d);
90089 -       simple_rmdir(parent->d_inode,d);
90090 +       /*
90091 +        * It is possible that parent has already been removed, in which
90092 +        * case directory is already unhashed and dput.
90093 +        * Note that this won't update parent->d_inode->i_nlink; OTOH
90094 +        * parent should already be dead
90095 +        */
90096 +       if (!d_unhashed(d)) {
90097 +               d_delete(d);
90098 +               simple_rmdir(parent->d_inode,d);
90099 +       }
90100  
90101         pr_debug(" o %s removing done (%d)\n",d->d_name.name,
90102                  atomic_read(&d->d_count));
90103 --- linux-2.6.0-test6/fs/udf/inode.c    2003-09-08 13:58:59.000000000 -0700
90104 +++ 25/fs/udf/inode.c   2003-10-05 00:33:24.000000000 -0700
90105 @@ -127,6 +127,7 @@ no_delete:
90106  void udf_clear_inode(struct inode *inode)
90107  {
90108         kfree(UDF_I_DATA(inode));
90109 +       UDF_I_DATA(inode) = NULL;
90110  }
90111  
90112  void udf_discard_prealloc(struct inode * inode)
90113 --- linux-2.6.0-test6/fs/udf/super.c    2003-09-08 13:58:59.000000000 -0700
90114 +++ 25/fs/udf/super.c   2003-10-05 00:33:24.000000000 -0700
90115 @@ -50,6 +50,7 @@
90116  #include <linux/slab.h>
90117  #include <linux/kernel.h>
90118  #include <linux/module.h>
90119 +#include <linux/parser.h>
90120  #include <linux/stat.h>
90121  #include <linux/cdrom.h>
90122  #include <linux/nls.h>
90123 @@ -132,8 +133,10 @@ static void init_once(void * foo, kmem_c
90124         struct udf_inode_info *ei = (struct udf_inode_info *) foo;
90125  
90126         if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
90127 -           SLAB_CTOR_CONSTRUCTOR)
90128 +           SLAB_CTOR_CONSTRUCTOR) {
90129 +               ei->i_ext.i_data = NULL;
90130                 inode_init_once(&ei->vfs_inode);
90131 +       }
90132  }
90133  
90134  static int init_inodecache(void)
90135 @@ -225,7 +228,7 @@ module_exit(exit_udf_fs)
90136   *     gid=            Set the default group.
90137   *     umask=          Set the default umask.
90138   *     uid=            Set the default user.
90139 - *     bs=                     Set the block size.
90140 + *     bs=             Set the block size.
90141   *     unhide          Show otherwise hidden files.
90142   *     undelete        Show deleted files in lists.
90143   *     adinicb         Embed data in the inode (default)
90144 @@ -259,18 +262,53 @@ module_exit(exit_udf_fs)
90145   *     uopts           Pointer to mount options variable.
90146   *
90147   * POST-CONDITIONS
90148 - *     <return>        0       Mount options parsed okay.
90149 - *     <return>        -1      Error parsing mount options.
90150 + *     <return>        1       Mount options parsed okay.
90151 + *     <return>        0       Error parsing mount options.
90152   *
90153   * HISTORY
90154   *     July 1, 1997 - Andrew E. Mileski
90155   *     Written, tested, and released.
90156   */
90157  
90158 +enum {
90159 +       Opt_novrs, Opt_nostrict, Opt_bs, Opt_unhide, Opt_undelete,
90160 +       Opt_noadinicb, Opt_adinicb, Opt_shortad, Opt_longad,
90161 +       Opt_gid, Opt_uid, Opt_umask, Opt_session, Opt_lastblock,
90162 +       Opt_anchor, Opt_volume, Opt_partition, Opt_fileset,
90163 +       Opt_rootdir, Opt_utf8, Opt_iocharset,
90164 +       Opt_err
90165 +};
90166 +
90167 +static match_table_t tokens = {
90168 +       {Opt_novrs, "novrs"},
90169 +       {Opt_nostrict, "nostrict"},
90170 +       {Opt_bs, "bs=%u"},
90171 +       {Opt_unhide, "unhide"},
90172 +       {Opt_undelete, "undelete"},
90173 +       {Opt_noadinicb, "noadinicb"},
90174 +       {Opt_adinicb, "adinicb"},
90175 +       {Opt_shortad, "shortad"},
90176 +       {Opt_longad, "longad"},
90177 +       {Opt_gid, "gid=%u"},
90178 +       {Opt_uid, "uid=%u"},
90179 +       {Opt_umask, "umask=%o"},
90180 +       {Opt_session, "session=%u"},
90181 +       {Opt_lastblock, "lastblock=%u"},
90182 +       {Opt_anchor, "anchor=%u"},
90183 +       {Opt_volume, "volume=%u"},
90184 +       {Opt_partition, "partition=%u"},
90185 +       {Opt_fileset, "fileset=%u"},
90186 +       {Opt_rootdir, "rootdir=%u"},
90187 +       {Opt_utf8, "utf8"},
90188 +       {Opt_iocharset, "iocharset=%s"},
90189 +       {Opt_err, NULL}
90190 +};
90191 +
90192  static int
90193  udf_parse_options(char *options, struct udf_options *uopt)
90194  {
90195 -       char *opt, *val;
90196 +       char *p;
90197 +       int option;
90198  
90199         uopt->novrs = 0;
90200         uopt->blocksize = 2048;
90201 @@ -286,71 +324,106 @@ udf_parse_options(char *options, struct 
90202         if (!options)
90203                 return 1;
90204  
90205 -       while ((opt = strsep(&options, ",")) != NULL)
90206 -       {
90207 -               if (!*opt)
90208 +       while ((p = strsep(&options, ",")) != NULL) {
90209 +               substring_t args[MAX_OPT_ARGS];
90210 +               int token;
90211 +               if (!*p)
90212                         continue;
90213 -               /* Make "opt=val" into two strings */
90214 -               val = strchr(opt, '=');
90215 -               if (val)
90216 -                       *(val++) = 0;
90217 -               if (!strcmp(opt, "novrs") && !val)
90218 +
90219 +               token = match_token(p, tokens, args);
90220 +               switch (token) {
90221 +               case Opt_novrs:
90222                         uopt->novrs = 1;
90223 -               else if (!strcmp(opt, "bs") && val)
90224 -                       uopt->blocksize = simple_strtoul(val, NULL, 0);
90225 -               else if (!strcmp(opt, "unhide") && !val)
90226 +                       break;
90227 +               case Opt_bs:
90228 +                       if (match_int(&args[0], &option))
90229 +                               return 0;
90230 +                       uopt->blocksize = option;
90231 +                       break;
90232 +               case Opt_unhide:
90233                         uopt->flags |= (1 << UDF_FLAG_UNHIDE);
90234 -               else if (!strcmp(opt, "undelete") && !val)
90235 +                       break;
90236 +               case Opt_undelete:
90237                         uopt->flags |= (1 << UDF_FLAG_UNDELETE);
90238 -               else if (!strcmp(opt, "noadinicb") && !val)
90239 +                       break;
90240 +               case Opt_noadinicb:
90241                         uopt->flags &= ~(1 << UDF_FLAG_USE_AD_IN_ICB);
90242 -               else if (!strcmp(opt, "adinicb") && !val)
90243 +                       break;
90244 +               case Opt_adinicb:
90245                         uopt->flags |= (1 << UDF_FLAG_USE_AD_IN_ICB);
90246 -               else if (!strcmp(opt, "shortad") && !val)
90247 +                       break;
90248 +               case Opt_shortad:
90249                         uopt->flags |= (1 << UDF_FLAG_USE_SHORT_AD);
90250 -               else if (!strcmp(opt, "longad") && !val)
90251 +                       break;
90252 +               case Opt_longad:
90253                         uopt->flags &= ~(1 << UDF_FLAG_USE_SHORT_AD);
90254 -               else if (!strcmp(opt, "gid") && val)
90255 -                       uopt->gid = simple_strtoul(val, NULL, 0);
90256 -               else if (!strcmp(opt, "umask") && val)
90257 -                       uopt->umask = simple_strtoul(val, NULL, 0);
90258 -               else if (!strcmp(opt, "nostrict") && !val)
90259 +                       break;
90260 +               case Opt_gid:
90261 +                       if (match_int(args, &option))
90262 +                               return 0;
90263 +                       uopt->gid = option;
90264 +                       break;
90265 +               case Opt_uid:
90266 +                       if (match_int(args, &option))
90267 +                               return 0;
90268 +                       uopt->uid = option;
90269 +                       break;
90270 +               case Opt_umask:
90271 +                       if (match_octal(args, &option))
90272 +                               return 0;
90273 +                       uopt->umask = option;
90274 +                       break;
90275 +               case Opt_nostrict:
90276                         uopt->flags &= ~(1 << UDF_FLAG_STRICT);
90277 -               else if (!strcmp(opt, "uid") && val)
90278 -                       uopt->uid = simple_strtoul(val, NULL, 0);
90279 -               else if (!strcmp(opt, "session") && val)
90280 -                       uopt->session = simple_strtoul(val, NULL, 0);
90281 -               else if (!strcmp(opt, "lastblock") && val)
90282 -                       uopt->lastblock = simple_strtoul(val, NULL, 0);
90283 -               else if (!strcmp(opt, "anchor") && val)
90284 -                       uopt->anchor = simple_strtoul(val, NULL, 0);
90285 -               else if (!strcmp(opt, "volume") && val)
90286 -                       uopt->volume = simple_strtoul(val, NULL, 0);
90287 -               else if (!strcmp(opt, "partition") && val)
90288 -                       uopt->partition = simple_strtoul(val, NULL, 0);
90289 -               else if (!strcmp(opt, "fileset") && val)
90290 -                       uopt->fileset = simple_strtoul(val, NULL, 0);
90291 -               else if (!strcmp(opt, "rootdir") && val)
90292 -                       uopt->rootdir = simple_strtoul(val, NULL, 0);
90293 +                       break;
90294 +               case Opt_session:
90295 +                       if (match_int(args, &option))
90296 +                               return 0;
90297 +                       uopt->session = option;
90298 +                       break;
90299 +               case Opt_lastblock:
90300 +                       if (match_int(args, &option))
90301 +                               return 0;
90302 +                       uopt->lastblock = option;
90303 +                       break;
90304 +               case Opt_anchor:
90305 +                       if (match_int(args, &option))
90306 +                               return 0;
90307 +                       uopt->anchor = option;
90308 +                       break;
90309 +               case Opt_volume:
90310 +                       if (match_int(args, &option))
90311 +                               return 0;
90312 +                       uopt->volume = option;
90313 +                       break;
90314 +               case Opt_partition:
90315 +                       if (match_int(args, &option))
90316 +                               return 0;
90317 +                       uopt->partition = option;
90318 +                       break;
90319 +               case Opt_fileset:
90320 +                       if (match_int(args, &option))
90321 +                               return 0;
90322 +                       uopt->fileset = option;
90323 +                       break;
90324 +               case Opt_rootdir:
90325 +                       if (match_int(args, &option))
90326 +                               return 0;
90327 +                       uopt->rootdir = option;
90328 +                       break;
90329 +               case Opt_utf8:
90330 +                       uopt->flags |= (1 << UDF_FLAG_UTF8);
90331 +                       break;
90332  #ifdef CONFIG_NLS
90333 -               else if (!strcmp(opt, "iocharset") && val)
90334 -               {
90335 -                       uopt->nls_map = load_nls(val);
90336 +               case Opt_iocharset:
90337 +                       uopt->nls_map = load_nls(args[0].from);
90338                         uopt->flags |= (1 << UDF_FLAG_NLS_MAP);
90339 -               }
90340 +                       break;
90341  #endif
90342 -               else if (!strcmp(opt, "utf8") && !val)
90343 -                       uopt->flags |= (1 << UDF_FLAG_UTF8);
90344 -               else if (val)
90345 -               {
90346 -                       printk(KERN_ERR "udf: bad mount option \"%s=%s\"\n",
90347 -                               opt, val);
90348 -                       return 0;
90349 -               }
90350 -               else
90351 -               {
90352 -                       printk(KERN_ERR "udf: bad mount option \"%s\"\n",
90353 -                               opt);
90354 +               default:
90355 +                       printk(KERN_ERR "udf: bad mount option \"%s\" "
90356 +                                       "or missing value\n",
90357 +                               p);
90358                         return 0;
90359                 }
90360         }
90361 --- linux-2.6.0-test6/fs/ufs/super.c    2003-06-22 12:04:44.000000000 -0700
90362 +++ 25/fs/ufs/super.c   2003-10-05 00:33:24.000000000 -0700
90363 @@ -79,6 +79,7 @@
90364  #include <linux/string.h>
90365  #include <linux/blkdev.h>
90366  #include <linux/init.h>
90367 +#include <linux/parser.h>
90368  #include <linux/smp_lock.h>
90369  #include <linux/buffer_head.h>
90370  #include <linux/vfs.h>
90371 @@ -250,64 +251,99 @@ void ufs_warning (struct super_block * s
90372                 sb->s_id, function, error_buf);
90373  }
90374  
90375 +enum {
90376 +       Opt_type_old, Opt_type_sunx86, Opt_type_sun, Opt_type_44bsd,
90377 +       Opt_type_hp, Opt_type_nextstepcd, Opt_type_nextstep,
90378 +       Opt_type_openstep, Opt_onerror_panic, Opt_onerror_lock,
90379 +       Opt_onerror_umount, Opt_onerror_repair, Opt_err
90380 +};
90381 +
90382 +static match_table_t tokens = {
90383 +       {Opt_type_old, "ufstype=old"},
90384 +       {Opt_type_sunx86, "ufstype=sunx86"},
90385 +       {Opt_type_sun, "ufstype=sun"},
90386 +       {Opt_type_44bsd, "ufstype=44bsd"},
90387 +       {Opt_type_hp, "ufstype=hp"},
90388 +       {Opt_type_nextstepcd, "ufstype=nextstep-cd"},
90389 +       {Opt_type_nextstep, "ufstype=nextstep"},
90390 +       {Opt_type_openstep, "ufstype=openstep"},
90391 +       {Opt_onerror_panic, "onerror=panic"},
90392 +       {Opt_onerror_lock, "onerror=lock"},
90393 +       {Opt_onerror_umount, "onerror=umount"},
90394 +       {Opt_onerror_repair, "onerror=repair"},
90395 +       {Opt_err, NULL}
90396 +};
90397 +
90398  static int ufs_parse_options (char * options, unsigned * mount_options)
90399  {
90400 -       char * this_char;
90401 -       char * value;
90402 +       char * p;
90403         
90404         UFSD(("ENTER\n"))
90405         
90406         if (!options)
90407                 return 1;
90408  
90409 -       while ((this_char = strsep (&options, ",")) != NULL) {
90410 -               if (!*this_char)
90411 +       while ((p = strsep(&options, ",")) != NULL) {
90412 +               substring_t args[MAX_OPT_ARGS];
90413 +               int token;
90414 +               if (!*p)
90415                         continue;
90416 -               if ((value = strchr (this_char, '=')) != NULL)
90417 -                       *value++ = 0;
90418 -               if (!strcmp (this_char, "ufstype")) {
90419 +
90420 +               token = match_token(p, tokens, args);
90421 +               switch (token) {
90422 +               case Opt_type_old:
90423                         ufs_clear_opt (*mount_options, UFSTYPE);
90424 -                       if (!strcmp (value, "old"))
90425 -                               ufs_set_opt (*mount_options, UFSTYPE_OLD);
90426 -                       else if (!strcmp (value, "sun"))
90427 -                               ufs_set_opt (*mount_options, UFSTYPE_SUN);
90428 -                       else if (!strcmp (value, "44bsd"))
90429 -                               ufs_set_opt (*mount_options, UFSTYPE_44BSD);
90430 -                       else if (!strcmp (value, "nextstep"))
90431 -                               ufs_set_opt (*mount_options, UFSTYPE_NEXTSTEP);
90432 -                       else if (!strcmp (value, "nextstep-cd"))
90433 -                               ufs_set_opt (*mount_options, UFSTYPE_NEXTSTEP_CD);
90434 -                       else if (!strcmp (value, "openstep"))
90435 -                               ufs_set_opt (*mount_options, UFSTYPE_OPENSTEP);
90436 -                       else if (!strcmp (value, "sunx86"))
90437 -                               ufs_set_opt (*mount_options, UFSTYPE_SUNx86);
90438 -                       else if (!strcmp (value, "hp"))
90439 -                               ufs_set_opt (*mount_options, UFSTYPE_HP);
90440 -                       else {
90441 -                               printk ("UFS-fs: Invalid type option: %s\n", value);
90442 -                               return 0;
90443 -                       }
90444 -               }
90445 -               else if (!strcmp (this_char, "onerror")) {
90446 +                       ufs_set_opt (*mount_options, UFSTYPE_OLD);
90447 +                       break;
90448 +               case Opt_type_sunx86:
90449 +                       ufs_clear_opt (*mount_options, UFSTYPE);
90450 +                       ufs_set_opt (*mount_options, UFSTYPE_SUNx86);
90451 +                       break;
90452 +               case Opt_type_sun:
90453 +                       ufs_clear_opt (*mount_options, UFSTYPE);
90454 +                       ufs_set_opt (*mount_options, UFSTYPE_SUN);
90455 +                       break;
90456 +               case Opt_type_44bsd:
90457 +                       ufs_clear_opt (*mount_options, UFSTYPE);
90458 +                       ufs_set_opt (*mount_options, UFSTYPE_44BSD);
90459 +                       break;
90460 +               case Opt_type_hp:
90461 +                       ufs_clear_opt (*mount_options, UFSTYPE);
90462 +                       ufs_set_opt (*mount_options, UFSTYPE_HP);
90463 +                       break;
90464 +               case Opt_type_nextstepcd:
90465 +                       ufs_clear_opt (*mount_options, UFSTYPE);
90466 +                       ufs_set_opt (*mount_options, UFSTYPE_NEXTSTEP_CD);
90467 +                       break;
90468 +               case Opt_type_nextstep:
90469 +                       ufs_clear_opt (*mount_options, UFSTYPE);
90470 +                       ufs_set_opt (*mount_options, UFSTYPE_NEXTSTEP);
90471 +                       break;
90472 +               case Opt_type_openstep:
90473 +                       ufs_clear_opt (*mount_options, UFSTYPE);
90474 +                       ufs_set_opt (*mount_options, UFSTYPE_OPENSTEP);
90475 +                       break;
90476 +               case Opt_onerror_panic:
90477                         ufs_clear_opt (*mount_options, ONERROR);
90478 -                       if (!strcmp (value, "panic"))
90479 -                               ufs_set_opt (*mount_options, ONERROR_PANIC);
90480 -                       else if (!strcmp (value, "lock"))
90481 -                               ufs_set_opt (*mount_options, ONERROR_LOCK);
90482 -                       else if (!strcmp (value, "umount"))
90483 -                               ufs_set_opt (*mount_options, ONERROR_UMOUNT);
90484 -                       else if (!strcmp (value, "repair")) {
90485 -                               printk("UFS-fs: Unable to do repair on error, "
90486 -                                       "will lock lock instead \n");
90487 -                               ufs_set_opt (*mount_options, ONERROR_REPAIR);
90488 -                       }
90489 -                       else {
90490 -                               printk ("UFS-fs: Invalid action onerror: %s\n", value);
90491 -                               return 0;
90492 -                       }
90493 -               }
90494 -               else {
90495 -                       printk("UFS-fs: Invalid option: %s\n", this_char);
90496 +                       ufs_set_opt (*mount_options, ONERROR_PANIC);
90497 +                       break;
90498 +               case Opt_onerror_lock:
90499 +                       ufs_clear_opt (*mount_options, ONERROR);
90500 +                       ufs_set_opt (*mount_options, ONERROR_LOCK);
90501 +                       break;
90502 +               case Opt_onerror_umount:
90503 +                       ufs_clear_opt (*mount_options, ONERROR);
90504 +                       ufs_set_opt (*mount_options, ONERROR_UMOUNT);
90505 +                       break;
90506 +               case Opt_onerror_repair:
90507 +                       printk("UFS-fs: Unable to do repair on error, "
90508 +                               "will lock lock instead\n");
90509 +                       ufs_clear_opt (*mount_options, ONERROR);
90510 +                       ufs_set_opt (*mount_options, ONERROR_REPAIR);
90511 +                       break;
90512 +               default:
90513 +                       printk("UFS-fs: Invalid option: \"%s\" "
90514 +                                       "or missing value\n", p);
90515                         return 0;
90516                 }
90517         }
90518 --- linux-2.6.0-test6/fs/xfs/linux/xfs_aops.c   2003-09-27 18:57:46.000000000 -0700
90519 +++ 25/fs/xfs/linux/xfs_aops.c  2003-10-05 00:36:53.000000000 -0700
90520 @@ -461,7 +461,8 @@ map_unwritten(
90521                 struct page             *page;
90522  
90523                 tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT;
90524 -               tloff = min(tlast, start_page->index + pb->pb_page_count - 1);
90525 +               tloff = (mp->pbm_offset + mp->pbm_bsize) >> PAGE_CACHE_SHIFT;
90526 +               tloff = min(tlast, tloff);
90527                 for (tindex = start_page->index + 1; tindex < tloff; tindex++) {
90528                         page = probe_unwritten_page(mapping, tindex, mp, pb,
90529                                                 PAGE_CACHE_SIZE, &bs, bbits);
90530 @@ -973,7 +974,7 @@ linvfs_direct_IO(
90531         unsigned long           nr_segs)
90532  {
90533         struct file     *file = iocb->ki_filp;
90534 -       struct inode    *inode = file->f_dentry->d_inode->i_mapping->host;
90535 +       struct inode    *inode = file->f_mapping->host;
90536         vnode_t         *vp = LINVFS_GET_VP(inode);
90537         page_buf_bmap_t pbmap;
90538         int             maps = 1;
90539 @@ -983,7 +984,7 @@ linvfs_direct_IO(
90540         if (error)
90541                 return -error;
90542  
90543 -        return blockdev_direct_IO(rw, iocb, inode,
90544 +        return blockdev_direct_IO_no_locking(rw, iocb, inode,
90545                 pbmap.pbm_target->pbr_bdev,
90546                 iov, offset, nr_segs,
90547                 linvfs_get_blocks_direct,
90548 @@ -1041,6 +1042,8 @@ count_page_state(
90549         do {
90550                 if (buffer_uptodate(bh) && !buffer_mapped(bh))
90551                         (*unmapped) = 1;
90552 +               else if (buffer_unwritten(bh) && !buffer_delay(bh))
90553 +                       clear_buffer_unwritten(bh);
90554                 else if (buffer_unwritten(bh))
90555                         (*unwritten) = 1;
90556                 else if (buffer_delay(bh))
90557 --- linux-2.6.0-test6/fs/xfs/linux/xfs_file.c   2003-08-22 19:23:42.000000000 -0700
90558 +++ 25/fs/xfs/linux/xfs_file.c  2003-10-05 00:34:07.000000000 -0700
90559 @@ -86,7 +86,7 @@ linvfs_write(
90560  {
90561         struct iovec    iov = {(void *)buf, count};
90562         struct file     *file = iocb->ki_filp;
90563 -       struct inode    *inode = file->f_dentry->d_inode->i_mapping->host;
90564 +       struct inode    *inode = file->f_mapping->host;
90565         vnode_t         *vp = LINVFS_GET_VP(inode);
90566         int             error;
90567         int             direct = file->f_flags & O_DIRECT;
90568 @@ -111,7 +111,7 @@ linvfs_readv(
90569         unsigned long           nr_segs,
90570         loff_t                  *ppos)
90571  {
90572 -       struct inode    *inode = file->f_dentry->d_inode->i_mapping->host;
90573 +       struct inode    *inode = file->f_mapping->host;
90574         vnode_t         *vp = LINVFS_GET_VP(inode);
90575         struct          kiocb kiocb;
90576         int             error;
90577 @@ -133,7 +133,7 @@ linvfs_writev(
90578         unsigned long           nr_segs,
90579         loff_t                  *ppos)
90580  {
90581 -       struct inode    *inode = file->f_dentry->d_inode->i_mapping->host;
90582 +       struct inode    *inode = file->f_mapping->host;
90583         vnode_t         *vp = LINVFS_GET_VP(inode);
90584         struct          kiocb kiocb;
90585         int             error;
90586 --- linux-2.6.0-test6/fs/xfs/linux/xfs_iops.c   2003-09-27 18:57:46.000000000 -0700
90587 +++ 25/fs/xfs/linux/xfs_iops.c  2003-10-05 00:33:24.000000000 -0700
90588 @@ -386,6 +386,7 @@ linvfs_readlink(
90589         uio.uio_segflg = UIO_USERSPACE;
90590         uio.uio_resid = size;
90591         uio.uio_iovcnt = 1;
90592 +       uio.uio_fmode = 0;
90593  
90594         VOP_READLINK(vp, &uio, NULL, error);
90595         if (error)
90596 --- linux-2.6.0-test6/fs/xfs/linux/xfs_lrw.c    2003-09-27 18:57:46.000000000 -0700
90597 +++ 25/fs/xfs/linux/xfs_lrw.c   2003-10-05 00:33:24.000000000 -0700
90598 @@ -218,7 +218,7 @@ xfs_read(
90599                 int error;
90600                 vrwlock_t locktype = VRWLOCK_READ;
90601  
90602 -               error = XFS_SEND_DATA(mp, DM_EVENT_READ, bdp, *offset, size,
90603 +               error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp), *offset, size,
90604                                       FILP_DELAY_FLAG(file), &locktype);
90605                 if (error) {
90606                         xfs_iunlock(ip, XFS_IOLOCK_SHARED);
90607 @@ -278,7 +278,7 @@ xfs_sendfile(
90608                 vrwlock_t locktype = VRWLOCK_READ;
90609                 int error;
90610  
90611 -               error = XFS_SEND_DATA(mp, DM_EVENT_READ, bdp, *offset, count,
90612 +               error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp), *offset, count,
90613                                       FILP_DELAY_FLAG(filp), &locktype);
90614                 if (error) {
90615                         xfs_iunlock(ip, XFS_IOLOCK_SHARED);
90616 @@ -612,7 +612,7 @@ start:
90617                 loff_t          savedsize = *offset;
90618  
90619                 xfs_iunlock(xip, XFS_ILOCK_EXCL);
90620 -               error = XFS_SEND_DATA(xip->i_mount, DM_EVENT_WRITE, bdp,
90621 +               error = XFS_SEND_DATA(xip->i_mount, DM_EVENT_WRITE, vp,
90622                                       *offset, size,
90623                                       FILP_DELAY_FLAG(file), &locktype);
90624                 if (error) {
90625 --- linux-2.6.0-test6/fs/xfs/linux/xfs_stats.c  2003-09-27 18:57:46.000000000 -0700
90626 +++ 25/fs/xfs/linux/xfs_stats.c 2003-10-05 00:33:24.000000000 -0700
90627 @@ -33,7 +33,7 @@
90628  #include "xfs.h"
90629  #include <linux/proc_fs.h>
90630  
90631 -struct xfsstats xfsstats;
90632 +DEFINE_PER_CPU(struct xfsstats, xfsstats);
90633  
90634  STATIC int
90635  xfs_read_xfsstats(
90636 @@ -44,7 +44,11 @@ xfs_read_xfsstats(
90637         int             *eof,
90638         void            *data)
90639  {
90640 -       int             i, j, len;
90641 +       int             c, i, j, len, val;
90642 +       __uint64_t      xs_xstrat_bytes = 0;
90643 +       __uint64_t      xs_write_bytes = 0;
90644 +       __uint64_t      xs_read_bytes = 0;
90645 +
90646         static struct xstats_entry {
90647                 char    *desc;
90648                 int     endpoint;
90649 @@ -65,21 +69,32 @@ xfs_read_xfsstats(
90650                 { "vnodes",             XFSSTAT_END_VNODE_OPS           },
90651         };
90652  
90653 +       /* Loop over all stats groups */
90654         for (i=j=len = 0; i < sizeof(xstats)/sizeof(struct xstats_entry); i++) {
90655                 len += sprintf(buffer + len, xstats[i].desc);
90656                 /* inner loop does each group */
90657                 while (j < xstats[i].endpoint) {
90658 -                       len += sprintf(buffer + len, " %u",
90659 -                                       *(((__u32*)&xfsstats) + j));
90660 +                       val = 0;
90661 +                       /* sum over all cpus */
90662 +                       for (c = 0; c < NR_CPUS; c++) {
90663 +                               if (!cpu_possible(c)) continue;
90664 +                               val += *(((__u32*)&per_cpu(xfsstats, c) + j));
90665 +                       }
90666 +                       len += sprintf(buffer + len, " %u", val);
90667                         j++;
90668                 }
90669                 buffer[len++] = '\n';
90670         }
90671         /* extra precision counters */
90672 +       for (i = 0; i < NR_CPUS; i++) {
90673 +               if (!cpu_possible(i)) continue;
90674 +               xs_xstrat_bytes += per_cpu(xfsstats, i).xs_xstrat_bytes;
90675 +               xs_write_bytes += per_cpu(xfsstats, i).xs_write_bytes;
90676 +               xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes;
90677 +       }
90678 +
90679         len += sprintf(buffer + len, "xpc %Lu %Lu %Lu\n",
90680 -                       xfsstats.xs_xstrat_bytes,
90681 -                       xfsstats.xs_write_bytes,
90682 -                       xfsstats.xs_read_bytes);
90683 +                       xs_xstrat_bytes, xs_write_bytes, xs_read_bytes);
90684         len += sprintf(buffer + len, "debug %u\n",
90685  #if defined(XFSDEBUG)
90686                 1);
90687 --- linux-2.6.0-test6/fs/xfs/linux/xfs_stats.h  2003-09-27 18:57:46.000000000 -0700
90688 +++ 25/fs/xfs/linux/xfs_stats.h 2003-10-05 00:33:24.000000000 -0700
90689 @@ -35,6 +35,8 @@
90690  
90691  #if defined(CONFIG_PROC_FS) && !defined(XFS_STATS_OFF)
90692  
90693 +#include <linux/percpu.h>
90694 +
90695  /*
90696   * XFS global statistics
90697   */
90698 @@ -126,11 +128,13 @@ struct xfsstats {
90699         __uint64_t              xs_read_bytes;
90700  };
90701  
90702 -extern struct xfsstats xfsstats;
90703 +DECLARE_PER_CPU(struct xfsstats, xfsstats);
90704  
90705 -# define XFS_STATS_INC(count)          ( xfsstats.count++ )
90706 -# define XFS_STATS_DEC(count)          ( xfsstats.count-- )
90707 -# define XFS_STATS_ADD(count, inc)     ( xfsstats.count += (inc) )
90708 +/* We don't disable preempt, not too worried about poking the
90709 + * wrong cpu's stat for now */
90710 +#define XFS_STATS_INC(count)           (__get_cpu_var(xfsstats).count++)
90711 +#define XFS_STATS_DEC(count)           (__get_cpu_var(xfsstats).count--)
90712 +#define XFS_STATS_ADD(count, inc)      (__get_cpu_var(xfsstats).count += (inc))
90713  
90714  extern void xfs_init_procfs(void);
90715  extern void xfs_cleanup_procfs(void);
90716 --- linux-2.6.0-test6/fs/xfs/linux/xfs_super.c  2003-09-27 18:57:46.000000000 -0700
90717 +++ 25/fs/xfs/linux/xfs_super.c 2003-10-05 00:33:24.000000000 -0700
90718 @@ -315,8 +315,8 @@ xfs_setsize_buftarg(
90719  
90720         if (set_blocksize(btp->pbr_bdev, sectorsize)) {
90721                 printk(KERN_WARNING
90722 -                       "XFS: Cannot set_blocksize to %u on device %u:%u\n",
90723 -                       sectorsize, MAJOR(btp->pbr_dev), MINOR(btp->pbr_dev));
90724 +                       "XFS: Cannot set_blocksize to %u on device %s\n",
90725 +                       sectorsize, XFS_BUFTARG_NAME(btp));
90726         }
90727  }
90728  
90729 --- linux-2.6.0-test6/fs/xfs/linux/xfs_sysctl.c 2003-09-27 18:57:46.000000000 -0700
90730 +++ 25/fs/xfs/linux/xfs_sysctl.c        2003-10-05 00:33:24.000000000 -0700
90731 @@ -48,17 +48,23 @@ xfs_stats_clear_proc_handler(
90732         void            *buffer,
90733         size_t          *lenp)
90734  {
90735 -       int             ret, *valp = ctl->data;
90736 +       int             c, ret, *valp = ctl->data;
90737         __uint32_t      vn_active;
90738  
90739         ret = proc_doulongvec_minmax(ctl, write, filp, buffer, lenp);
90740  
90741         if (!ret && write && *valp) {
90742                 printk("XFS Clearing xfsstats\n");
90743 -               /* save vn_active, it's a universal truth! */
90744 -               vn_active = xfsstats.vn_active;
90745 -               memset(&xfsstats, 0, sizeof(xfsstats));
90746 -               xfsstats.vn_active = vn_active;
90747 +               for (c = 0; c < NR_CPUS; c++) {
90748 +                       if (!cpu_possible(c)) continue;
90749 +                       preempt_disable();
90750 +                       /* save vn_active, it's a universal truth! */
90751 +                       vn_active = per_cpu(xfsstats, c).vn_active;
90752 +                       memset(&per_cpu(xfsstats, c), 0,
90753 +                              sizeof(struct xfsstats));
90754 +                       per_cpu(xfsstats, c).vn_active = vn_active;
90755 +                       preempt_enable();
90756 +               }
90757                 xfs_stats_clear = 0;
90758         }
90759  
90760 --- linux-2.6.0-test6/fs/xfs/linux/xfs_vnode.c  2003-09-27 18:57:46.000000000 -0700
90761 +++ 25/fs/xfs/linux/xfs_vnode.c 2003-10-05 00:33:24.000000000 -0700
90762 @@ -200,7 +200,7 @@ vn_revalidate(
90763         vn_trace_entry(vp, "vn_revalidate", (inst_t *)__return_address);
90764         ASSERT(vp->v_fbhv != NULL);
90765  
90766 -       va.va_mask = XFS_AT_STAT|XFS_AT_GENCOUNT;
90767 +       va.va_mask = XFS_AT_STAT|XFS_AT_XFLAGS;
90768         VOP_GETATTR(vp, &va, 0, NULL, error);
90769         if (!error) {
90770                 inode = LINVFS_GET_IP(vp);
90771 --- linux-2.6.0-test6/fs/xfs/linux/xfs_vnode.h  2003-08-08 22:55:13.000000000 -0700
90772 +++ 25/fs/xfs/linux/xfs_vnode.h 2003-10-05 00:33:24.000000000 -0700
90773 @@ -28,6 +28,37 @@
90774   * For further information regarding this notice, see:
90775   *
90776   * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
90777 + *
90778 + * Portions Copyright (c) 1989, 1993
90779 + *      The Regents of the University of California.  All rights reserved.
90780 + *
90781 + * Redistribution and use in source and binary forms, with or without
90782 + * modification, are permitted provided that the following conditions
90783 + * are met:
90784 + * 1. Redistributions of source code must retain the above copyright
90785 + *    notice, this list of conditions and the following disclaimer.
90786 + * 2. Redistributions in binary form must reproduce the above copyright
90787 + *    notice, this list of conditions and the following disclaimer in the
90788 + *    documentation and/or other materials provided with the distribution.
90789 + * 3. All advertising materials mentioning features or use of this software
90790 + *    must display the following acknowledgement:
90791 + *      This product includes software developed by the University of
90792 + *      California, Berkeley and its contributors.
90793 + * 4. Neither the name of the University nor the names of its contributors
90794 + *    may be used to endorse or promote products derived from this software
90795 + *    without specific prior written permission.
90796 + *
90797 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
90798 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
90799 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
90800 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
90801 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
90802 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
90803 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
90804 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
90805 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
90806 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
90807 + * SUCH DAMAGE.
90808   */
90809  #ifndef __XFS_VNODE_H__
90810  #define __XFS_VNODE_H__
90811 @@ -39,19 +70,9 @@ struct page_buf_bmap_s;
90812  struct attrlist_cursor_kern;
90813  
90814  /*
90815 - * Vnode types (unrelated to on-disk inodes).  VNON means no type.
90816 + * Vnode types.  VNON means no type.
90817   */
90818 -typedef enum vtype {
90819 -       VNON    = 0,
90820 -       VREG    = 1,
90821 -       VDIR    = 2,
90822 -       VBLK    = 3,
90823 -       VCHR    = 4,
90824 -       VLNK    = 5,
90825 -       VFIFO   = 6,
90826 -       VBAD    = 7,
90827 -       VSOCK   = 8
90828 -} vtype_t;
90829 +enum vtype     { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VFIFO, VBAD, VSOCK };
90830  
90831  typedef xfs_ino_t vnumber_t;
90832  typedef struct dentry vname_t;
90833 @@ -115,14 +136,15 @@ typedef enum {
90834  #define LINVFS_GET_IP(vp)      (&(vp)->v_inode)
90835  
90836  /*
90837 - * Conversion between vnode types/modes and encoded type/mode as
90838 - * seen by stat(2) and mknod(2).
90839 + * Convert between vnode types and inode formats (since POSIX.1
90840 + * defines mode word of stat structure in terms of inode formats).
90841   */
90842 -extern enum vtype       iftovt_tab[];
90843 -extern ushort           vttoif_tab[];
90844 -#define IFTOVT(M)       (iftovt_tab[((M) & S_IFMT) >> 12])
90845 -#define VTTOIF(T)       (vttoif_tab[(int)(T)])
90846 -#define MAKEIMODE(T, M)        (VTTOIF(T) | ((M) & ~S_IFMT))
90847 +extern enum vtype      iftovt_tab[];
90848 +extern u_short         vttoif_tab[];
90849 +#define IFTOVT(mode)   (iftovt_tab[((mode) & S_IFMT) >> 12])
90850 +#define VTTOIF(indx)   (vttoif_tab[(int)(indx)])
90851 +#define MAKEIMODE(indx, mode)  (int)(VTTOIF(indx) | (mode))
90852 +
90853  
90854  /*
90855   * Vnode flags.
90856 @@ -370,31 +392,29 @@ typedef struct vnodeops {
90857  
90858  /*
90859   * Vnode attributes.  va_mask indicates those attributes the caller
90860 - * wants to set (setattr) or extract (getattr).
90861 + * wants to set or extract.
90862   */
90863  typedef struct vattr {
90864 -       int             va_mask;        /* bit-mask of attributes */
90865 -       vtype_t         va_type;        /* vnode type (for create) */
90866 -       mode_t          va_mode;        /* file access mode */
90867 +       int             va_mask;        /* bit-mask of attributes present */
90868 +       enum vtype      va_type;        /* vnode type (for create) */
90869 +       mode_t          va_mode;        /* file access mode and type */
90870 +       nlink_t         va_nlink;       /* number of references to file */
90871         uid_t           va_uid;         /* owner user id */
90872         gid_t           va_gid;         /* owner group id */
90873 -       xfs_dev_t       va_fsid;        /* file system id (dev for now) */
90874 -       xfs_ino_t       va_nodeid;      /* node id */
90875 -       nlink_t         va_nlink;       /* number of references to file */
90876 +       xfs_ino_t       va_nodeid;      /* file id */
90877         xfs_off_t       va_size;        /* file size in bytes */
90878 -       timespec_t      va_atime;       /* time of last access */
90879 -       timespec_t      va_mtime;       /* time of last modification */
90880 -       timespec_t      va_ctime;       /* time file ``created'' */
90881 -       xfs_dev_t       va_rdev;        /* device the file represents */
90882 -       u_long          va_blksize;     /* fundamental block size */
90883 -       __int64_t       va_nblocks;     /* # of blocks allocated */
90884 -       u_long          va_vcode;       /* version code */
90885 +       u_long          va_blocksize;   /* blocksize preferred for i/o */
90886 +       struct timespec va_atime;       /* time of last access */
90887 +       struct timespec va_mtime;       /* time of last modification */
90888 +       struct timespec va_ctime;       /* time file changed */
90889 +       u_int           va_gen;         /* generation number of file */
90890 +       xfs_dev_t       va_rdev;        /* device the special file represents */
90891 +       __int64_t       va_nblocks;     /* number of blocks allocated */
90892         u_long          va_xflags;      /* random extended file flags */
90893         u_long          va_extsize;     /* file extent size */
90894         u_long          va_nextents;    /* number of extents in file */
90895         u_long          va_anextents;   /* number of attr extents in file */
90896         int             va_projid;      /* project id */
90897 -       u_int           va_gencount;    /* object generation count */
90898  } vattr_t;
90899  
90900  /*
90901 @@ -450,11 +470,17 @@ typedef struct vattr {
90902                 XFS_AT_TYPE|XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|\
90903                 XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_GENCOUNT)
90904  
90905 -#define VREAD          00400
90906 -#define VWRITE         00200
90907 -#define VEXEC          00100
90908 -#define VSGID          02000           /* set group id on execution */
90909 -#define MODEMASK       07777           /* mode bits plus permission bits */
90910 +/*
90911 + *  Modes.
90912 + */
90913 +#define VSUID  S_ISUID         /* set user id on execution */
90914 +#define VSGID  S_ISGID         /* set group id on execution */
90915 +#define VSVTX  S_ISVTX         /* save swapped text even after use */
90916 +#define VREAD  S_IRUSR         /* read, write, execute permissions */
90917 +#define VWRITE S_IWUSR
90918 +#define VEXEC  S_IXUSR
90919 +
90920 +#define MODEMASK S_IALLUGO     /* mode bits plus permission bits */
90921  
90922  /*
90923   * Check whether mandatory file locking is enabled.
90924 @@ -569,13 +595,9 @@ static __inline__ void vn_flagclr(struct
90925   * Flags to VOP_SETATTR/VOP_GETATTR.
90926   */
90927  #define        ATTR_UTIME      0x01    /* non-default utime(2) request */
90928 -#define        ATTR_EXEC       0x02    /* invocation from exec(2) */
90929 -#define        ATTR_COMM       0x04    /* yield common vp attributes */
90930  #define        ATTR_DMI        0x08    /* invocation from a DMI function */
90931  #define        ATTR_LAZY       0x80    /* set/get attributes lazily */
90932  #define        ATTR_NONBLOCK   0x100   /* return EAGAIN if operation would block */
90933 -#define ATTR_NOLOCK    0x200   /* Don't grab any conflicting locks */
90934 -#define ATTR_NOSIZETOK 0x400   /* Don't get the DVN_SIZE_READ token */
90935  
90936  /*
90937   * Flags to VOP_FSYNC and VOP_RECLAIM.
90938 --- linux-2.6.0-test6/fs/xfs/pagebuf/page_buf.c 2003-09-27 18:57:46.000000000 -0700
90939 +++ 25/fs/xfs/pagebuf/page_buf.c        2003-10-05 00:33:24.000000000 -0700
90940 @@ -141,7 +141,7 @@ pagebuf_param_t pb_params = {
90941   * Pagebuf statistics variables
90942   */
90943  
90944 -struct pbstats pbstats;
90945 +DEFINE_PER_CPU(struct pbstats, pbstats);
90946  
90947  /*
90948   * Pagebuf allocation / freeing.
90949 @@ -293,7 +293,7 @@ _pagebuf_initialize(
90950         atomic_set(&pb->pb_pin_count, 0);
90951         init_waitqueue_head(&pb->pb_waiters);
90952  
90953 -       PB_STATS_INC(pbstats.pb_create);
90954 +       PB_STATS_INC(pb_create);
90955         PB_TRACE(pb, PB_TRACE_REC(get), target);
90956  }
90957  
90958 @@ -485,7 +485,7 @@ _pagebuf_lookup_pages(
90959                         page = find_or_create_page(aspace, index, gfp_mask);
90960                         if (!page) {
90961                                 if (--retry_count > 0) {
90962 -                                       PB_STATS_INC(pbstats.pb_page_retries);
90963 +                                       PB_STATS_INC(pb_page_retries);
90964                                         pagebuf_daemon_wakeup(1);
90965                                         current->state = TASK_UNINTERRUPTIBLE;
90966                                         schedule_timeout(10);
90967 @@ -495,7 +495,7 @@ _pagebuf_lookup_pages(
90968                                 all_mapped = 0;
90969                                 continue;
90970                         }
90971 -                       PB_STATS_INC(pbstats.pb_page_found);
90972 +                       PB_STATS_INC(pb_page_found);
90973                         mark_page_accessed(page);
90974                         pb->pb_pages[pi] = page;
90975                 } else {
90976 @@ -645,7 +645,7 @@ _pagebuf_find(                              /* find buffer for blo
90977                 h->pb_count++;
90978                 list_add(&new_pb->pb_hash_list, &h->pb_hash);
90979         } else {
90980 -               PB_STATS_INC(pbstats.pb_miss_locked);
90981 +               PB_STATS_INC(pb_miss_locked);
90982         }
90983  
90984         spin_unlock(&h->pb_hash_lock);
90985 @@ -665,7 +665,7 @@ found:
90986                         /* wait for buffer ownership */
90987                         PB_TRACE(pb, PB_TRACE_REC(get_lk), 0);
90988                         pagebuf_lock(pb);
90989 -                       PB_STATS_INC(pbstats.pb_get_locked_waited);
90990 +                       PB_STATS_INC(pb_get_locked_waited);
90991                 } else {
90992                         /* We asked for a trylock and failed, no need
90993                          * to look at file offset and length here, we
90994 @@ -675,7 +675,7 @@ found:
90995                          */
90996  
90997                         pagebuf_rele(pb);
90998 -                       PB_STATS_INC(pbstats.pb_busy_locked);
90999 +                       PB_STATS_INC(pb_busy_locked);
91000                         return (NULL);
91001                 }
91002         } else {
91003 @@ -691,7 +691,7 @@ found:
91004                                 _PBF_ADDR_ALLOCATED | \
91005                                 _PBF_MEM_ALLOCATED;
91006         PB_TRACE(pb, PB_TRACE_REC(got_lk), 0);
91007 -       PB_STATS_INC(pbstats.pb_get_locked);
91008 +       PB_STATS_INC(pb_get_locked);
91009         return (pb);
91010  }
91011  
91012 @@ -747,7 +747,7 @@ pagebuf_get(                                /* allocate a buffer            */
91013                         return (NULL);
91014         }
91015  
91016 -       PB_STATS_INC(pbstats.pb_get);
91017 +       PB_STATS_INC(pb_get);
91018  
91019         /* fill in any missing pages */
91020         error = _pagebuf_lookup_pages(pb, pb->pb_target->pbr_mapping, flags);
91021 @@ -766,7 +766,7 @@ pagebuf_get(                                /* allocate a buffer            */
91022         if (flags & PBF_READ) {
91023                 if (PBF_NOT_DONE(pb)) {
91024                         PB_TRACE(pb, PB_TRACE_REC(get_read), flags);
91025 -                       PB_STATS_INC(pbstats.pb_get_read);
91026 +                       PB_STATS_INC(pb_get_read);
91027                         pagebuf_iostart(pb, flags);
91028                 } else if (flags & PBF_ASYNC) {
91029                         /*
91030 @@ -1677,6 +1677,9 @@ pagebuf_daemon(
91031                                         break;
91032                                 }
91033  
91034 +                               pb->pb_flags &= ~PBF_DELWRI;
91035 +                               pb->pb_flags |= PBF_WRITE;
91036 +
91037                                 list_del(&pb->pb_list);
91038                                 list_add(&pb->pb_list, &tmp);
91039  
91040 @@ -1688,8 +1691,6 @@ pagebuf_daemon(
91041                 while (!list_empty(&tmp)) {
91042                         pb = list_entry(tmp.next, page_buf_t, pb_list);
91043                         list_del_init(&pb->pb_list);
91044 -                       pb->pb_flags &= ~PBF_DELWRI;
91045 -                       pb->pb_flags |= PBF_WRITE;
91046  
91047                         pagebuf_iostrategy(pb);
91048                 }
91049 @@ -1720,6 +1721,7 @@ pagebuf_delwri_flush(
91050         int                     flush_cnt = 0;
91051  
91052         pagebuf_runall_queues(pagebuf_dataio_workqueue);
91053 +       pagebuf_runall_queues(pagebuf_logio_workqueue);
91054  
91055         spin_lock(&pbd_delwrite_lock);
91056         INIT_LIST_HEAD(&tmp);
91057 @@ -1742,47 +1744,32 @@ pagebuf_delwri_flush(
91058                         continue;
91059                 }
91060  
91061 -               if (flags & PBDF_TRYLOCK) {
91062 -                       if (!pagebuf_cond_lock(pb)) {
91063 -                               pincount++;
91064 -                               continue;
91065 -                       }
91066 -               }
91067 -
91068 -               list_del_init(&pb->pb_list);
91069 -               if (flags & PBDF_WAIT) {
91070 -                       list_add(&pb->pb_list, &tmp);
91071 -                       pb->pb_flags &= ~PBF_ASYNC;
91072 -               }
91073 -
91074 -               spin_unlock(&pbd_delwrite_lock);
91075 -
91076 -               if ((flags & PBDF_TRYLOCK) == 0) {
91077 -                       pagebuf_lock(pb);
91078 -               }
91079 -
91080                 pb->pb_flags &= ~PBF_DELWRI;
91081                 pb->pb_flags |= PBF_WRITE;
91082 +               list_move(&pb->pb_list, &tmp);
91083 +       }
91084 +       /* ok found all the items that can be worked on 
91085 +        * drop the lock and process the private list */
91086 +       spin_unlock(&pbd_delwrite_lock);
91087 +
91088 +       list_for_each_safe(curr, next, &tmp) {
91089 +               pb = list_entry(curr, page_buf_t, pb_list);
91090 +
91091 +               if (flags & PBDF_WAIT)
91092 +                       pb->pb_flags &= ~PBF_ASYNC;
91093 +               else
91094 +                       list_del_init(curr);
91095  
91096 +               pagebuf_lock(pb);
91097                 pagebuf_iostrategy(pb);
91098                 if (++flush_cnt > 32) {
91099                         blk_run_queues();
91100                         flush_cnt = 0;
91101                 }
91102 -
91103 -               spin_lock(&pbd_delwrite_lock);
91104         }
91105  
91106 -       spin_unlock(&pbd_delwrite_lock);
91107 -
91108         blk_run_queues();
91109  
91110 -       if (pinptr)
91111 -               *pinptr = pincount;
91112 -
91113 -       if ((flags & PBDF_WAIT) == 0)
91114 -               return;
91115 -
91116         while (!list_empty(&tmp)) {
91117                 pb = list_entry(tmp.next, page_buf_t, pb_list);
91118  
91119 @@ -1792,6 +1779,9 @@ pagebuf_delwri_flush(
91120                         pagebuf_unlock(pb);
91121                 pagebuf_rele(pb);
91122         }
91123 +
91124 +       if (pinptr)
91125 +               *pinptr = pincount;
91126  }
91127  
91128  STATIC int
91129 @@ -1846,14 +1836,18 @@ pb_stats_clear_handler(
91130         void                    *buffer,
91131         size_t                  *lenp)
91132  {
91133 -       int                     ret;
91134 +       int                     c, ret;
91135         int                     *valp = ctl->data;
91136  
91137         ret = proc_doulongvec_minmax(ctl, write, filp, buffer, lenp);
91138  
91139         if (!ret && write && *valp) {
91140                 printk("XFS Clearing pbstats\n");
91141 -               memset(&pbstats, 0, sizeof(pbstats));
91142 +               for (c = 0; c < NR_CPUS; c++) {
91143 +                       if (!cpu_possible(c)) continue;
91144 +                               memset(&per_cpu(pbstats, c), 0,
91145 +                                      sizeof(struct pbstats));
91146 +               }
91147                 pb_params.stats_clear.val = 0;
91148         }
91149  
91150 @@ -1907,13 +1901,17 @@ pagebuf_readstats(
91151         int                     *eof,
91152         void                    *data)
91153  {
91154 -       int                     i, len;
91155 +       int                     c, i, len, val;
91156  
91157         len = 0;
91158         len += sprintf(buffer + len, "pagebuf");
91159 -       for (i = 0; i < sizeof(pbstats) / sizeof(u_int32_t); i++) {
91160 -               len += sprintf(buffer + len, " %u",
91161 -                       *(((u_int32_t*)&pbstats) + i));
91162 +       for (i = 0; i < sizeof(struct pbstats) / sizeof(u_int32_t); i++) {
91163 +               val = 0;
91164 +               for (c = 0 ; c < NR_CPUS; c++) {
91165 +                       if (!cpu_possible(c)) continue;
91166 +                       val += *(((u_int32_t*)&per_cpu(pbstats, c) + i));
91167 +               }
91168 +               len += sprintf(buffer + len, " %u", val);
91169         }
91170         buffer[len++] = '\n';
91171  
91172 --- linux-2.6.0-test6/fs/xfs/pagebuf/page_buf.h 2003-08-22 19:23:42.000000000 -0700
91173 +++ 25/fs/xfs/pagebuf/page_buf.h        2003-10-05 00:33:24.000000000 -0700
91174 @@ -136,9 +136,6 @@ typedef enum page_buf_flags_e {             /* pb_f
91175  #define PBF_NOT_DONE(pb) (((pb)->pb_flags & (PBF_PARTIAL|PBF_NONE)) != 0)
91176  #define PBF_DONE(pb) (((pb)->pb_flags & (PBF_PARTIAL|PBF_NONE)) == 0)
91177  
91178 -#define PBR_SECTOR_ONLY        1       /* only use sector size buffer heads */
91179 -#define PBR_ALIGNED_ONLY 2     /* only use aligned I/O */
91180 -
91181  typedef struct pb_target {
91182         dev_t                   pbr_dev;
91183         struct block_device     *pbr_bdev;
91184 @@ -371,7 +368,6 @@ extern int pagebuf_ispin(           /* check if b
91185  /* Delayed Write Buffer Routines */
91186  
91187  #define PBDF_WAIT    0x01
91188 -#define PBDF_TRYLOCK 0x02
91189  extern void pagebuf_delwri_flush(
91190                 pb_target_t *,
91191                 unsigned long,
91192 --- linux-2.6.0-test6/fs/xfs/pagebuf/page_buf_internal.h        2003-09-27 18:57:46.000000000 -0700
91193 +++ 25/fs/xfs/pagebuf/page_buf_internal.h       2003-10-05 00:33:24.000000000 -0700
91194 @@ -37,6 +37,7 @@
91195  #ifndef __PAGE_BUF_PRIVATE_H__
91196  #define __PAGE_BUF_PRIVATE_H__
91197  
91198 +#include <linux/percpu.h>
91199  #include "page_buf.h"
91200  
91201  #define _PAGE_BUF_INTERNAL_
91202 @@ -120,9 +121,11 @@ struct pbstats {
91203         u_int32_t       pb_get_read;
91204  };
91205  
91206 -extern struct pbstats pbstats;
91207 +DECLARE_PER_CPU(struct pbstats, pbstats);
91208  
91209 -#define PB_STATS_INC(count)    ( count ++ )
91210 +/* We don't disable preempt, not too worried about poking the
91211 + * wrong cpu's stat for now */
91212 +#define PB_STATS_INC(count)    (__get_cpu_var(pbstats).count++)
91213  
91214  #ifndef STATIC
91215  # define STATIC        static
91216 --- linux-2.6.0-test6/fs/xfs/quota/xfs_dquot.c  2003-06-14 12:18:09.000000000 -0700
91217 +++ 25/fs/xfs/quota/xfs_dquot.c 2003-10-05 00:33:24.000000000 -0700
91218 @@ -87,9 +87,9 @@
91219  STATIC void            xfs_qm_dqflush_done(xfs_buf_t *, xfs_dq_logitem_t *);
91220  
91221  #ifdef DEBUG
91222 -dev_t xfs_dqerror_dev = 0;
91223 -int xfs_do_dqerror = 0;
91224 -int xfs_dqreq_num = 0;
91225 +xfs_buftarg_t *xfs_dqerror_target;
91226 +int xfs_do_dqerror;
91227 +int xfs_dqreq_num;
91228  int xfs_dqerror_mod = 33;
91229  #endif
91230  
91231 @@ -911,7 +911,7 @@ xfs_qm_dqget(
91232  
91233  #ifdef DEBUG
91234         if (xfs_do_dqerror) {
91235 -               if ((xfs_dqerror_dev == mp->m_dev) &&
91236 +               if ((xfs_dqerror_target == mp->m_ddev_targp) &&
91237                     (xfs_dqreq_num++ % xfs_dqerror_mod) == 0) {
91238                         cmn_err(CE_DEBUG, "Returning error in dqget");
91239                         return (EIO);
91240 --- linux-2.6.0-test6/fs/xfs/quota/xfs_qm.h     2003-06-14 12:18:06.000000000 -0700
91241 +++ 25/fs/xfs/quota/xfs_qm.h    2003-10-05 00:33:24.000000000 -0700
91242 @@ -165,9 +165,9 @@ typedef struct xfs_dquot_acct {
91243   * Users are allowed to have a usage exceeding their softlimit for
91244   * a period this long.
91245   */
91246 -#define XFS_QM_BTIMELIMIT      DQ_BTIMELIMIT
91247 -#define XFS_QM_RTBTIMELIMIT    DQ_BTIMELIMIT
91248 -#define XFS_QM_ITIMELIMIT      DQ_FTIMELIMIT
91249 +#define XFS_QM_BTIMELIMIT      (7 * 24*60*60)          /* 1 week */
91250 +#define XFS_QM_RTBTIMELIMIT    (7 * 24*60*60)          /* 1 week */
91251 +#define XFS_QM_ITIMELIMIT      (7 * 24*60*60)          /* 1 week */
91252  
91253  #define XFS_QM_BWARNLIMIT      5
91254  #define XFS_QM_IWARNLIMIT      5
91255 --- linux-2.6.0-test6/fs/xfs/support/move.c     2003-06-14 12:18:22.000000000 -0700
91256 +++ 25/fs/xfs/support/move.c    2003-10-05 00:33:24.000000000 -0700
91257 @@ -38,57 +38,37 @@
91258  #include "debug.h"
91259  #include "move.h"
91260  
91261 -/*
91262 - * Move "n" bytes at byte address "cp"; "rw" indicates the direction
91263 - * of the move, and the I/O parameters are provided in "uio", which is
91264 - * update to reflect the data which was moved.  Returns 0 on success or
91265 - * a non-zero errno on failure.
91266 +/* Read from kernel buffer at src to user/kernel buffer defined
91267 + * by the uio structure. Advance the pointer in the uio struct
91268 + * as we go.
91269   */
91270  int
91271 -uiomove(void *cp, size_t n, enum uio_rw rw, struct uio *uio)
91272 +uio_read(caddr_t src, size_t len, struct uio *uio)
91273  {
91274 -       register struct iovec *iov;
91275 +       struct iovec *iov;
91276         u_int cnt;
91277         int error;
91278  
91279 -       while (n > 0 && uio->uio_resid) {
91280 +       if (len > 0 && uio->uio_resid) {
91281                 iov = uio->uio_iov;
91282                 cnt = (u_int)iov->iov_len;
91283 -               if (cnt == 0) {
91284 -                       uio->uio_iov++;
91285 -                       uio->uio_iovcnt--;
91286 -                       continue;
91287 -               }
91288 -               if (cnt > n)
91289 -                       cnt = (u_int)n;
91290 -               switch (uio->uio_segflg) {
91291 -               case UIO_USERSPACE:
91292 -                       if (rw == UIO_READ)
91293 -                               error = copy_to_user(iov->iov_base, cp, cnt);
91294 -                       else
91295 -                               error = copy_from_user(cp, iov->iov_base, cnt);
91296 +               if (cnt == 0)
91297 +                       return 0;
91298 +               if (cnt > len)
91299 +                       cnt = (u_int)len;
91300 +               if (uio->uio_segflg == UIO_USERSPACE) {
91301 +                       error = copy_to_user(iov->iov_base, src, cnt);
91302                         if (error)
91303                                 return EFAULT;
91304 -                       break;
91305 -
91306 -
91307 -               case UIO_SYSSPACE:
91308 -                       if (rw == UIO_READ)
91309 -                               memcpy(iov->iov_base, cp, cnt);
91310 -                       else
91311 -                               memcpy(cp, iov->iov_base, cnt);
91312 -                       break;
91313 -
91314 -               default:
91315 +               } else if (uio->uio_segflg == UIO_SYSSPACE) {
91316 +                       memcpy(iov->iov_base, src, cnt);
91317 +               } else {
91318                         ASSERT(0);
91319 -                       break;
91320                 }
91321                 iov->iov_base = (void *)((char *)iov->iov_base + cnt);
91322                 iov->iov_len -= cnt;
91323                 uio->uio_resid -= cnt;
91324                 uio->uio_offset += cnt;
91325 -               cp = (void *)((char *)cp + cnt);
91326 -               n -= cnt;
91327         }
91328         return 0;
91329  }
91330 --- linux-2.6.0-test6/fs/xfs/support/move.h     2003-06-14 12:18:20.000000000 -0700
91331 +++ 25/fs/xfs/support/move.h    2003-10-05 00:33:24.000000000 -0700
91332 @@ -48,11 +48,6 @@ typedef struct uio {
91333  } uio_t;
91334  
91335  /*
91336 - * I/O direction.
91337 - */
91338 -typedef enum uio_rw { UIO_READ, UIO_WRITE } uio_rw_t;
91339 -
91340 -/*
91341   * Segment flag values.
91342   */
91343  typedef enum uio_seg {
91344 @@ -60,7 +55,6 @@ typedef enum uio_seg {
91345         UIO_SYSSPACE,           /* uio_iov describes system space */
91346  } uio_seg_t;
91347  
91348 -
91349 -extern int     uiomove (void *, size_t, uio_rw_t, uio_t *);
91350 +extern int     uio_read (caddr_t, size_t, uio_t *);
91351  
91352  #endif  /* __XFS_SUPPORT_MOVE_H__ */
91353 --- linux-2.6.0-test6/fs/xfs/xfs_attr_fetch.c   2003-06-14 12:18:25.000000000 -0700
91354 +++ /dev/null   2002-08-30 16:31:37.000000000 -0700
91355 @@ -1,100 +0,0 @@
91356 -/*
91357 - * Copyright (c) 2000, 2002 Silicon Graphics, Inc.  All Rights Reserved.
91358 - *
91359 - * This program is free software; you can redistribute it and/or modify it
91360 - * under the terms of version 2 of the GNU General Public License as
91361 - * published by the Free Software Foundation.
91362 - *
91363 - * This program is distributed in the hope that it would be useful, but
91364 - * WITHOUT ANY WARRANTY; without even the implied warranty of
91365 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
91366 - *
91367 - * Further, this software is distributed without any warranty that it is
91368 - * free of the rightful claim of any third person regarding infringement
91369 - * or the like.  Any license provided herein, whether implied or
91370 - * otherwise, applies only to this software file.  Patent licenses, if
91371 - * any, provided herein do not apply to combinations of this program with
91372 - * other software, or any other product whatsoever.
91373 - *
91374 - * You should have received a copy of the GNU General Public License along
91375 - * with this program; if not, write the Free Software Foundation, Inc., 59
91376 - * Temple Place - Suite 330, Boston MA 02111-1307, USA.
91377 - *
91378 - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
91379 - * Mountain View, CA  94043, or:
91380 - *
91381 - * http://www.sgi.com
91382 - *
91383 - * For further information regarding this notice, see:
91384 - *
91385 - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
91386 - */
91387 -
91388 -#include "xfs.h"
91389 -
91390 -#include "xfs_macros.h"
91391 -#include "xfs_types.h"
91392 -#include "xfs_inum.h"
91393 -#include "xfs_log.h"
91394 -#include "xfs_trans.h"
91395 -#include "xfs_sb.h"
91396 -#include "xfs_ag.h"
91397 -#include "xfs_dir.h"
91398 -#include "xfs_dir2.h"
91399 -#include "xfs_dmapi.h"
91400 -#include "xfs_mount.h"
91401 -#include "xfs_alloc_btree.h"
91402 -#include "xfs_bmap_btree.h"
91403 -#include "xfs_ialloc_btree.h"
91404 -#include "xfs_itable.h"
91405 -#include "xfs_btree.h"
91406 -#include "xfs_ialloc.h"
91407 -#include "xfs_alloc.h"
91408 -#include "xfs_attr_sf.h"
91409 -#include "xfs_dir_sf.h"
91410 -#include "xfs_dir2_sf.h"
91411 -#include "xfs_dinode.h"
91412 -#include "xfs_inode_item.h"
91413 -#include "xfs_inode.h"
91414 -#include "xfs_bmap.h"
91415 -#include "xfs_da_btree.h"
91416 -#include "xfs_attr.h"
91417 -#include "xfs_attr_leaf.h"
91418 -
91419 -int
91420 -xfs_attr_fetch(xfs_inode_t *ip, char *name, char *value, int valuelen)
91421 -{
91422 -       xfs_da_args_t args;
91423 -       int error;
91424 -
91425 -       if (XFS_IFORK_Q(ip) == 0)
91426 -               return ENOATTR;
91427 -       /*
91428 -        * Do the argument setup for the xfs_attr routines.
91429 -        */
91430 -       memset((char *)&args, 0, sizeof(args));
91431 -       args.dp = ip;
91432 -       args.flags = ATTR_ROOT;
91433 -       args.whichfork = XFS_ATTR_FORK;
91434 -       args.name = name;
91435 -       args.namelen = strlen(name);
91436 -       args.value = value;
91437 -       args.valuelen = valuelen;
91438 -       args.hashval = xfs_da_hashname(args.name, args.namelen);
91439 -       args.oknoent = 1;
91440 -
91441 -       /*
91442 -        * Decide on what work routines to call based on the inode size.
91443 -        */
91444 -       if (args.dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL)
91445 -               error = xfs_attr_shortform_getvalue(&args);
91446 -       else if (xfs_bmap_one_block(args.dp, XFS_ATTR_FORK))
91447 -               error = xfs_attr_leaf_get(&args);
91448 -       else
91449 -               error = xfs_attr_node_get(&args);
91450 -
91451 -       if (error == EEXIST)
91452 -               error = 0;
91453 -
91454 -       return(error);
91455 -}
91456 --- linux-2.6.0-test6/fs/xfs/xfs_bmap.c 2003-09-27 18:57:46.000000000 -0700
91457 +++ 25/fs/xfs/xfs_bmap.c        2003-10-05 00:33:24.000000000 -0700
91458 @@ -5553,7 +5553,7 @@ xfs_getbmap(
91459             && DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ)
91460             && whichfork == XFS_DATA_FORK) {
91461  
91462 -               error = XFS_SEND_DATA(mp, DM_EVENT_READ, bdp, 0, 0, 0, NULL);
91463 +               error = XFS_SEND_DATA(mp, DM_EVENT_READ, vp, 0, 0, 0, NULL);
91464                 if (error)
91465                         return XFS_ERROR(error);
91466         }
91467 --- linux-2.6.0-test6/fs/xfs/xfs_buf.h  2003-08-22 19:23:42.000000000 -0700
91468 +++ 25/fs/xfs/xfs_buf.h 2003-10-05 00:33:24.000000000 -0700
91469 @@ -194,7 +194,10 @@ extern inline xfs_caddr_t xfs_buf_offset
91470         (bp)->pb_target = (target)
91471  
91472  #define XFS_BUF_TARGET(bp)     ((bp)->pb_target)
91473 -#define XFS_BUF_TARGET_DEV(bp) ((bp)->pb_target->pbr_dev)
91474 +
91475 +#define XFS_BUFTARG_NAME(target) \
91476 +       ({ char __b[BDEVNAME_SIZE]; bdevname((target->pbr_bdev), __b); __b; })
91477 +       
91478  #define XFS_BUF_SET_VTYPE_REF(bp, type, ref)
91479  #define XFS_BUF_SET_VTYPE(bp, type)
91480  #define XFS_BUF_SET_REF(bp, ref)
91481 --- linux-2.6.0-test6/fs/xfs/xfs_buf_item.c     2003-06-14 12:17:56.000000000 -0700
91482 +++ 25/fs/xfs/xfs_buf_item.c    2003-10-05 00:33:24.000000000 -0700
91483 @@ -1007,7 +1007,7 @@ xfs_buf_iodone_callbacks(
91484  {
91485         xfs_log_item_t  *lip;
91486         static ulong    lasttime;
91487 -       static dev_t    lastdev;
91488 +       static xfs_buftarg_t *lasttarg;
91489         xfs_mount_t     *mp;
91490  
91491         ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL);
91492 @@ -1045,15 +1045,15 @@ xfs_buf_iodone_callbacks(
91493                         return;
91494                 }
91495  
91496 -               if ((XFS_BUF_TARGET_DEV(bp) != lastdev) ||
91497 +               if ((XFS_BUF_TARGET(bp) != lasttarg) ||
91498                     (time_after(jiffies, (lasttime + 5*HZ)))) {
91499                         lasttime = jiffies;
91500                         prdev("XFS write error in file system meta-data "
91501                               "block 0x%Lx in %s",
91502 -                             XFS_BUF_TARGET_DEV(bp),
91503 +                             XFS_BUF_TARGET(bp),
91504                               XFS_BUF_ADDR(bp), mp->m_fsname);
91505                 }
91506 -               lastdev = XFS_BUF_TARGET_DEV(bp);
91507 +               lasttarg = XFS_BUF_TARGET(bp);
91508  
91509                 if (XFS_BUF_ISASYNC(bp)) {
91510                         /*
91511 --- linux-2.6.0-test6/fs/xfs/xfs_da_btree.c     2003-09-27 18:57:46.000000000 -0700
91512 +++ 25/fs/xfs/xfs_da_btree.c    2003-10-05 00:33:24.000000000 -0700
91513 @@ -2450,7 +2450,7 @@ xfs_da_buf_make(int nbuf, xfs_buf_t **bp
91514         dabuf->dirty = 0;
91515  #ifdef XFS_DABUF_DEBUG
91516         dabuf->ra = ra;
91517 -       dabuf->dev = XFS_BUF_TARGET_DEV(bps[0]);
91518 +       dabuf->target = XFS_BUF_TARGET(bps[0]);
91519         dabuf->blkno = XFS_BUF_ADDR(bps[0]);
91520  #endif
91521         if (nbuf == 1) {
91522 @@ -2480,7 +2480,7 @@ xfs_da_buf_make(int nbuf, xfs_buf_t **bp
91523                 s = mutex_spinlock(&xfs_dabuf_global_lock);
91524                 for (p = xfs_dabuf_global_list; p; p = p->next) {
91525                         ASSERT(p->blkno != dabuf->blkno ||
91526 -                              p->dev != dabuf->dev);
91527 +                              p->target != dabuf->target);
91528                 }
91529                 dabuf->prev = NULL;
91530                 if (xfs_dabuf_global_list)
91531 --- linux-2.6.0-test6/fs/xfs/xfs_da_btree.h     2003-09-27 18:57:46.000000000 -0700
91532 +++ 25/fs/xfs/xfs_da_btree.h    2003-10-05 00:33:24.000000000 -0700
91533 @@ -212,7 +212,7 @@ typedef struct xfs_dabuf {
91534         inst_t          *ra;            /* return address of caller to make */
91535         struct xfs_dabuf *next;         /* next in global chain */
91536         struct xfs_dabuf *prev;         /* previous in global chain */
91537 -       dev_t           dev;            /* device for buffer */
91538 +       struct xfs_buftarg *target;     /* device for buffer */
91539         xfs_daddr_t     blkno;          /* daddr first in bps[0] */
91540  #endif
91541         struct xfs_buf  *bps[1];        /* actually nbuf of these */
91542 --- linux-2.6.0-test6/fs/xfs/xfs_dinode.h       2003-09-27 18:57:46.000000000 -0700
91543 +++ 25/fs/xfs/xfs_dinode.h      2003-10-05 00:33:24.000000000 -0700
91544 @@ -439,25 +439,21 @@ void xfs_dfork_next_set(xfs_dinode_t *di
91545  /*
91546   * File types (mode field)
91547   */
91548 -#define        IFMT            0170000         /* type of file */
91549 -#define        IFIFO           0010000         /* named pipe (fifo) */
91550 -#define        IFCHR           0020000         /* character special */
91551 -#define        IFDIR           0040000         /* directory */
91552 -#define        IFBLK           0060000         /* block special */
91553 -#define        IFREG           0100000         /* regular */
91554 -#define        IFLNK           0120000         /* symbolic link */
91555 -#define        IFSOCK          0140000         /* socket */
91556 -#define        IFMNT           0160000         /* mount point */
91557 +#define        IFMT            S_IFMT
91558 +#define        IFSOCK          S_IFSOCK
91559 +#define        IFLNK           S_IFLNK
91560 +#define        IFREG           S_IFREG
91561 +#define        IFBLK           S_IFBLK
91562 +#define        IFDIR           S_IFDIR
91563 +#define        IFCHR           S_IFCHR
91564 +#define        IFIFO           S_IFIFO
91565  
91566 -/*
91567 - * File execution and access modes.
91568 - */
91569 -#define        ISUID           04000           /* set user id on execution */
91570 -#define        ISGID           02000           /* set group id on execution */
91571 -#define        ISVTX           01000           /* sticky directory */
91572 -#define        IREAD           0400            /* read, write, execute permissions */
91573 -#define        IWRITE          0200
91574 -#define        IEXEC           0100
91575 +#define        ISUID           S_ISUID
91576 +#define        ISGID           S_ISGID
91577 +#define        ISVTX           S_ISVTX
91578 +#define        IREAD           S_IRUSR
91579 +#define        IWRITE          S_IWUSR
91580 +#define        IEXEC           S_IXUSR
91581  
91582  #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_DINODE)
91583  xfs_dinode_t *xfs_buf_to_dinode(struct xfs_buf *bp);
91584 --- linux-2.6.0-test6/fs/xfs/xfs_dir2.c 2003-09-27 18:57:46.000000000 -0700
91585 +++ 25/fs/xfs/xfs_dir2.c        2003-10-05 00:33:24.000000000 -0700
91586 @@ -773,7 +773,7 @@ xfs_dir2_put_dirent64_uio(
91587         idbp->d_off = pa->cook;
91588         idbp->d_name[namelen] = '\0';
91589         memcpy(idbp->d_name, pa->name, namelen);
91590 -       rval = uiomove((caddr_t)idbp, reclen, UIO_READ, uio);
91591 +       rval = uio_read((caddr_t)idbp, reclen, uio);
91592         pa->done = (rval == 0);
91593         return rval;
91594  }
91595 --- linux-2.6.0-test6/fs/xfs/xfs_dir_leaf.c     2003-09-27 18:57:46.000000000 -0700
91596 +++ 25/fs/xfs/xfs_dir_leaf.c    2003-10-05 00:33:24.000000000 -0700
91597 @@ -2225,7 +2225,7 @@ xfs_dir_put_dirent64_uio(xfs_dir_put_arg
91598         idbp->d_off = pa->cook.o;
91599         idbp->d_name[namelen] = '\0';
91600         memcpy(idbp->d_name, pa->name, namelen);
91601 -       retval = uiomove((caddr_t)idbp, reclen, UIO_READ, uio);
91602 +       retval = uio_read((caddr_t)idbp, reclen, uio);
91603         pa->done = (retval == 0);
91604         return retval;
91605  }
91606 --- linux-2.6.0-test6/fs/xfs/xfs_error.c        2003-09-27 18:57:46.000000000 -0700
91607 +++ 25/fs/xfs/xfs_error.c       2003-10-05 00:33:24.000000000 -0700
91608 @@ -329,6 +329,7 @@ xfs_corruption_error(
91609         int             linenum,
91610         inst_t          *ra)
91611  {
91612 -       xfs_hex_dump(p, 16);
91613 +       if (level <= xfs_error_level)
91614 +               xfs_hex_dump(p, 16);
91615         xfs_error_report(tag, level, mp, fname, linenum, ra);
91616  }
91617 --- linux-2.6.0-test6/fs/xfs/xfs_error.h        2003-09-27 18:57:46.000000000 -0700
91618 +++ 25/fs/xfs/xfs_error.h       2003-10-05 00:33:24.000000000 -0700
91619 @@ -32,8 +32,8 @@
91620  #ifndef        __XFS_ERROR_H__
91621  #define        __XFS_ERROR_H__
91622  
91623 -#define prdev(fmt,dev,args...) \
91624 -       printk("XFS: device %u:%u- " fmt "\n", MAJOR(dev), MINOR(dev), ## args)
91625 +#define prdev(fmt,targ,args...) \
91626 +       printk("XFS: device %s- " fmt "\n", XFS_BUFTARG_NAME(targ), ## args)
91627  
91628  #define XFS_ERECOVER   1       /* Failure to recover log */
91629  #define XFS_ELOGSTAT   2       /* Failure to stat log in user space */
91630 --- linux-2.6.0-test6/fs/xfs/xfs_fs.h   2003-09-27 18:57:46.000000000 -0700
91631 +++ 25/fs/xfs/xfs_fs.h  2003-10-05 00:33:24.000000000 -0700
91632 @@ -392,22 +392,17 @@ typedef struct xfs_fsop_attrmulti_handle
91633  } xfs_fsop_attrmulti_handlereq_t;
91634  
91635  /*
91636 - * File system identifier. Should be unique (at least per machine).
91637 + * per machine unique filesystem identifier types.
91638   */
91639 -typedef struct {
91640 -       __u32 val[2];                   /* file system id type */
91641 -} xfs_fsid_t;
91642 +typedef struct { __u32 val[2]; } xfs_fsid_t; /* file system id type */
91643 +
91644  
91645 -/*
91646 - * File identifier.  Should be unique per filesystem on a single machine.
91647 - * This is typically called by a stateless file server in order to generate
91648 - * "file handles".
91649 - */
91650  #ifndef HAVE_FID
91651  #define MAXFIDSZ       46
91652 +
91653  typedef struct fid {
91654         __u16           fid_len;                /* length of data in bytes */
91655 -       unsigned char   fid_data[MAXFIDSZ];     /* data (variable length)  */
91656 +       unsigned char   fid_data[MAXFIDSZ];     /* data (fid_len worth)  */
91657  } fid_t;
91658  #endif
91659  
91660 --- linux-2.6.0-test6/fs/xfs/xfsidbg.c  2003-09-27 18:57:46.000000000 -0700
91661 +++ 25/fs/xfs/xfsidbg.c 2003-10-05 00:33:24.000000000 -0700
91662 @@ -3739,9 +3739,9 @@ xfsidbg_xdabuf(xfs_dabuf_t *dabuf)
91663                 kdb_printf(" %d:0x%p", i, dabuf->bps[i]);
91664         kdb_printf("\n");
91665  #ifdef XFS_DABUF_DEBUG
91666 -       kdb_printf(" ra 0x%x prev 0x%x next 0x%x dev %u:%u blkno 0x%x\n",
91667 +       kdb_printf(" ra 0x%x prev 0x%x next 0x%x dev %s blkno 0x%x\n",
91668                 dabuf->ra, dabuf->prev, dabuf->next,
91669 -               MAJOR(dabuf->dev), MINOR(dabuf->dev), dabuf->blkno);
91670 +               XFS_BUFTARG_NAME(dabuf->dev), dabuf->blkno);
91671  #endif
91672  }
91673  
91674 @@ -4269,9 +4269,8 @@ xfsidbg_xlog(xlog_t *log)
91675                         xfsidbg_get_cstate(log->l_covered_state));
91676         kdb_printf("flags: ");
91677         printflags(log->l_flags, t_flags,"log");
91678 -       kdb_printf("  dev: %u:%u logBBstart: %lld logsize: %d logBBsize: %d\n",
91679 -               MAJOR(log->l_dev), MINOR(log->l_dev),
91680 -               (long long) log->l_logBBstart,
91681 +       kdb_printf("  dev: %s logBBstart: %lld logsize: %d logBBsize: %d\n",
91682 +               XFS_BUFTARG_NAME(log->l_targ), (long long) log->l_logBBstart,
91683                 log->l_logsize,log->l_logBBsize);
91684         kdb_printf("curr_cycle: %d  prev_cycle: %d  curr_block: %d  prev_block: %d\n",
91685              log->l_curr_cycle, log->l_prev_cycle, log->l_curr_block,
91686 @@ -4646,14 +4645,14 @@ xfsidbg_xmount(xfs_mount_t *mp)
91687                 XFS_MTOVFS(mp), mp->m_tid, &mp->m_ail_lock, &mp->m_ail);
91688         kdb_printf("ail_gen 0x%x &sb 0x%p\n",
91689                 mp->m_ail_gen, &mp->m_sb);
91690 -       kdb_printf("sb_lock 0x%p sb_bp 0x%p dev %u:%u logdev %u:%u rtdev %u:%u\n",
91691 +       kdb_printf("sb_lock 0x%p sb_bp 0x%p dev %s logdev %s rtdev %s\n",
91692                 &mp->m_sb_lock, mp->m_sb_bp,
91693 -               mp->m_ddev_targp ? MAJOR(mp->m_ddev_targp->pbr_dev) : 0,
91694 -               mp->m_ddev_targp ? MINOR(mp->m_ddev_targp->pbr_dev) : 0,
91695 -               mp->m_logdev_targp ? MAJOR(mp->m_logdev_targp->pbr_dev) : 0,
91696 -               mp->m_logdev_targp ? MINOR(mp->m_logdev_targp->pbr_dev) : 0,
91697 -               mp->m_rtdev_targp ? MAJOR(mp->m_rtdev_targp->pbr_dev) : 0,
91698 -               mp->m_rtdev_targp ? MINOR(mp->m_rtdev_targp->pbr_dev) : 0);
91699 +               mp->m_ddev_targp ?
91700 +                       XFS_BUFTARG_NAME(mp->m_ddev_targp) : "none",
91701 +               mp->m_logdev_targp ?
91702 +                       XFS_BUFTARG_NAME(mp->m_logdev_targp) : "none",
91703 +               mp->m_rtdev_targp ?
91704 +                       XFS_BUFTARG_NAME(mp->m_rtdev_targp) : "none");
91705         kdb_printf("bsize %d agfrotor %d agirotor %d ihash 0x%p ihsize %d\n",
91706                 mp->m_bsize, mp->m_agfrotor, mp->m_agirotor,
91707                 mp->m_ihash, mp->m_ihsize);
91708 @@ -4824,9 +4823,8 @@ xfsidbg_xnode(xfs_inode_t *ip)
91709                 ip->i_mnext,
91710                 ip->i_mprev,
91711                 XFS_ITOV_NULL(ip));
91712 -       kdb_printf("dev %u:%u ino %s\n",
91713 -               MAJOR(ip->i_mount->m_dev),
91714 -               MINOR(ip->i_mount->m_dev),
91715 +       kdb_printf("dev %s ino %s\n",
91716 +               XFS_BUFTARG_NAME(ip->i_mount->m_ddev_targp),
91717                 xfs_fmtino(ip->i_ino, ip->i_mount));
91718         kdb_printf("blkno 0x%llx len 0x%x boffset 0x%x\n",
91719                 (long long) ip->i_blkno,
91720 --- linux-2.6.0-test6/fs/xfs/xfs_inode.c        2003-09-27 18:57:46.000000000 -0700
91721 +++ 25/fs/xfs/xfs_inode.c       2003-10-05 00:33:24.000000000 -0700
91722 @@ -408,8 +408,9 @@ xfs_itobp(
91723                 if (unlikely(XFS_TEST_ERROR(!di_ok, mp, XFS_ERRTAG_ITOBP_INOTOBP,
91724                                  XFS_RANDOM_ITOBP_INOTOBP))) {
91725  #ifdef DEBUG
91726 -                       prdev("bad inode magic/vsn daddr 0x%llx #%d (magic=%x)",
91727 -                               mp->m_dev, (unsigned long long)imap.im_blkno, i,
91728 +                       prdev("bad inode magic/vsn daddr %lld #%d (magic=%x)",
91729 +                               mp->m_ddev_targp,
91730 +                               (unsigned long long)imap.im_blkno, i,
91731                                 INT_GET(dip->di_core.di_magic, ARCH_CONVERT));
91732  #endif
91733                         XFS_CORRUPTION_ERROR("xfs_itobp", XFS_ERRLEVEL_HIGH,
91734 --- linux-2.6.0-test6/fs/xfs/xfs_log.c  2003-09-27 18:57:46.000000000 -0700
91735 +++ 25/fs/xfs/xfs_log.c 2003-10-05 00:33:24.000000000 -0700
91736 @@ -65,7 +65,7 @@ STATIC int     xlog_bdstrat_cb(struct xfs_b
91737  STATIC int      xlog_commit_record(xfs_mount_t *mp, xlog_ticket_t *ticket,
91738                                     xlog_in_core_t **, xfs_lsn_t *);
91739  STATIC xlog_t *  xlog_alloc_log(xfs_mount_t    *mp,
91740 -                               dev_t           log_dev,
91741 +                               xfs_buftarg_t   *log_target,
91742                                 xfs_daddr_t     blk_offset,
91743                                 int             num_bblks);
91744  STATIC int      xlog_space_left(xlog_t *log, int cycle, int bytes);
91745 @@ -155,7 +155,7 @@ int xlog_error_mod = 33;
91746   */
91747  #if defined(XLOG_NOLOG) || defined(DEBUG)
91748  int   xlog_debug = 1;
91749 -dev_t xlog_devt  = 0;
91750 +xfs_buftarg_t *xlog_target;
91751  #endif
91752  
91753  #if defined(XFS_LOG_TRACE)
91754 @@ -274,7 +274,7 @@ xfs_log_done(xfs_mount_t    *mp,
91755         xfs_lsn_t       lsn     = 0;
91756  
91757  #if defined(DEBUG) || defined(XLOG_NOLOG)
91758 -       if (! xlog_debug && xlog_devt == log->l_dev)
91759 +       if (!xlog_debug && xlog_target == log->l_targ)
91760                 return 0;
91761  #endif
91762  
91763 @@ -339,7 +339,7 @@ xfs_log_force(xfs_mount_t *mp,
91764         xlog_t *log = mp->m_log;
91765  
91766  #if defined(DEBUG) || defined(XLOG_NOLOG)
91767 -       if (! xlog_debug && xlog_devt == log->l_dev)
91768 +       if (!xlog_debug && xlog_target == log->l_targ)
91769                 return 0;
91770  #endif
91771  
91772 @@ -378,7 +378,7 @@ xfs_log_notify(xfs_mount_t    *mp,          /* mo
91773         int     abortflg, spl;
91774  
91775  #if defined(DEBUG) || defined(XLOG_NOLOG)
91776 -       if (! xlog_debug && xlog_devt == log->l_dev)
91777 +       if (!xlog_debug && xlog_target == log->l_targ)
91778                 return 0;
91779  #endif
91780         cb->cb_next = 0;
91781 @@ -436,7 +436,7 @@ xfs_log_reserve(xfs_mount_t  *mp,
91782         int             retval;
91783  
91784  #if defined(DEBUG) || defined(XLOG_NOLOG)
91785 -       if (! xlog_debug && xlog_devt == log->l_dev)
91786 +       if (!xlog_debug && xlog_target == log->l_targ)
91787                 return 0;
91788  #endif
91789         retval = 0;
91790 @@ -472,7 +472,7 @@ xfs_log_reserve(xfs_mount_t  *mp,
91791   * Mount a log filesystem
91792   *
91793   * mp          - ubiquitous xfs mount point structure
91794 - * log_dev     - device number of on-disk log device
91795 + * log_target  - buftarg of on-disk log device
91796   * blk_offset  - Start block # where block size is 512 bytes (BBSIZE)
91797   * num_bblocks - Number of BBSIZE blocks in on-disk log
91798   *
91799 @@ -480,7 +480,7 @@ xfs_log_reserve(xfs_mount_t  *mp,
91800   */
91801  int
91802  xfs_log_mount(xfs_mount_t      *mp,
91803 -             dev_t             log_dev,
91804 +             xfs_buftarg_t     *log_target,
91805               xfs_daddr_t       blk_offset,
91806               int               num_bblks)
91807  {
91808 @@ -493,12 +493,11 @@ xfs_log_mount(xfs_mount_t *mp,
91809                 ASSERT(XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY);
91810         }
91811  
91812 -       mp->m_log = xlog_alloc_log(mp, log_dev, blk_offset, num_bblks);
91813 +       mp->m_log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks);
91814  
91815  #if defined(DEBUG) || defined(XLOG_NOLOG)
91816 -       if (! xlog_debug) {
91817 -               cmn_err(CE_NOTE, "log dev: %u:%u",
91818 -                       MAJOR(log_dev), MINOR(log_dev));
91819 +       if (!xlog_debug) {
91820 +               cmn_err(CE_NOTE, "log dev: %s", XFS_BUFTARG_NAME(log_target));
91821                 return 0;
91822         }
91823  #endif
91824 @@ -606,7 +605,7 @@ xfs_log_unmount_write(xfs_mount_t *mp)
91825         } magic = { XLOG_UNMOUNT_TYPE, 0, 0 };
91826  
91827  #if defined(DEBUG) || defined(XLOG_NOLOG)
91828 -       if (! xlog_debug && xlog_devt == log->l_dev)
91829 +       if (!xlog_debug && xlog_target == log->l_targ)
91830                 return 0;
91831  #endif
91832  
91833 @@ -734,9 +733,9 @@ xfs_log_write(xfs_mount_t * mp,
91834  {
91835         int     error;
91836         xlog_t *log = mp->m_log;
91837 -#if defined(DEBUG) || defined(XLOG_NOLOG)
91838  
91839 -       if (! xlog_debug && xlog_devt == log->l_dev) {
91840 +#if defined(DEBUG) || defined(XLOG_NOLOG)
91841 +       if (!xlog_debug && xlog_target == log->l_targ) {
91842                 *start_lsn = 0;
91843                 return 0;
91844         }
91845 @@ -761,7 +760,7 @@ xfs_log_move_tail(xfs_mount_t       *mp,
91846         SPLDECL(s);
91847  
91848  #if defined(DEBUG) || defined(XLOG_NOLOG)
91849 -       if (!xlog_debug && xlog_devt == log->l_dev)
91850 +       if (!xlog_debug && xlog_target == log->l_targ)
91851                 return;
91852  #endif
91853         /* XXXsup tmp */
91854 @@ -1059,14 +1058,14 @@ xlog_get_iclog_buffer_size(xfs_mount_t  *
91855         /*
91856          * When logbufs == 0, someone has disabled the log from the FSTAB
91857          * file.  This is not a documented feature.  We need to set xlog_debug
91858 -        * to zero (this deactivates the log) and set xlog_devt to the
91859 +        * to zero (this deactivates the log) and set xlog_target to the
91860          * appropriate dev_t.  Only one filesystem may be affected as such
91861          * since this is just a performance hack to test what we might be able
91862          * to get if the log were not present.
91863          */
91864         if (mp->m_logbufs == 0) {
91865                 xlog_debug = 0;
91866 -               xlog_devt = log->l_dev;
91867 +               xlog_target = log->l_targ;
91868                 log->l_iclog_bufs = XLOG_MIN_ICLOGS;
91869         } else
91870  #endif
91871 @@ -1089,8 +1088,8 @@ xlog_get_iclog_buffer_size(xfs_mount_t    *
91872  
91873  #if defined(DEBUG) || defined(XLOG_NOLOG)
91874                 /* We are reactivating a filesystem after it was active */
91875 -               if (log->l_dev == xlog_devt) {
91876 -                       xlog_devt = 1;
91877 +               if (log->l_targ == xlog_target) {
91878 +                       xlog_target = 1; /* XXX(hch): WTF? */
91879                         xlog_debug = 1;
91880                 }
91881  #endif
91882 @@ -1176,7 +1175,7 @@ xlog_get_iclog_buffer_size(xfs_mount_t    *
91883   */
91884  STATIC xlog_t *
91885  xlog_alloc_log(xfs_mount_t     *mp,
91886 -              dev_t            log_dev,
91887 +              xfs_buftarg_t    *log_target,
91888                xfs_daddr_t      blk_offset,
91889                int              num_bblks)
91890  {
91891 @@ -1191,7 +1190,7 @@ xlog_alloc_log(xfs_mount_t        *mp,
91892         log = (xlog_t *)kmem_zalloc(sizeof(xlog_t), KM_SLEEP);
91893  
91894         log->l_mp          = mp;
91895 -       log->l_dev         = log_dev;
91896 +       log->l_targ        = log_target;
91897         log->l_logsize     = BBTOB(num_bblks);
91898         log->l_logBBstart  = blk_offset;
91899         log->l_logBBsize   = num_bblks;
91900 --- linux-2.6.0-test6/fs/xfs/xfs_log.h  2003-06-14 12:18:52.000000000 -0700
91901 +++ 25/fs/xfs/xfs_log.h 2003-10-05 00:33:24.000000000 -0700
91902 @@ -153,10 +153,10 @@ xfs_lsn_t xfs_log_done(struct xfs_mount 
91903  int      xfs_log_force(struct xfs_mount *mp,
91904                         xfs_lsn_t        lsn,
91905                         uint             flags);
91906 -int      xfs_log_mount(struct xfs_mount *mp,
91907 -                       dev_t            log_dev,
91908 -                       xfs_daddr_t              start_block,
91909 -                       int              num_bblocks);
91910 +int      xfs_log_mount(struct xfs_mount        *mp,
91911 +                       struct xfs_buftarg      *log_target,
91912 +                       xfs_daddr_t             start_block,
91913 +                       int                     num_bblocks);
91914  int      xfs_log_mount_finish(struct xfs_mount *mp, int);
91915  void     xfs_log_move_tail(struct xfs_mount    *mp,
91916                             xfs_lsn_t           tail_lsn);
91917 --- linux-2.6.0-test6/fs/xfs/xfs_log_priv.h     2003-08-08 22:55:13.000000000 -0700
91918 +++ 25/fs/xfs/xfs_log_priv.h    2003-10-05 00:33:24.000000000 -0700
91919 @@ -504,7 +504,7 @@ typedef struct log {
91920         struct xfs_mount        *l_mp;          /* mount point */
91921         struct xfs_buf          *l_xbuf;        /* extra buffer for log
91922                                                  * wrapping */
91923 -       dev_t                   l_dev;          /* dev_t of log */
91924 +       struct xfs_buftarg      *l_targ;        /* buftarg of log */
91925         xfs_daddr_t             l_logBBstart;   /* start block of log */
91926         int                     l_logsize;      /* size of log in bytes */
91927         int                     l_logBBsize;    /* size of log in BB chunks */
91928 --- linux-2.6.0-test6/fs/xfs/xfs_log_recover.c  2003-09-27 18:57:46.000000000 -0700
91929 +++ 25/fs/xfs/xfs_log_recover.c 2003-10-05 00:33:24.000000000 -0700
91930 @@ -2179,8 +2179,8 @@ xlog_recover_do_buffer_trans(
91931                 break;
91932         default:
91933                 xfs_fs_cmn_err(CE_ALERT, log->l_mp,
91934 -                       "xfs_log_recover: unknown buffer type 0x%x, dev %u:%u",
91935 -                       buf_f->blf_type, MAJOR(log->l_dev), MINOR(log->l_dev));
91936 +                       "xfs_log_recover: unknown buffer type 0x%x, dev %s",
91937 +                       buf_f->blf_type, XFS_BUFTARG_NAME(log->l_targ));
91938                 XFS_ERROR_REPORT("xlog_recover_do_buffer_trans",
91939                                  XFS_ERRLEVEL_LOW, log->l_mp);
91940                 return XFS_ERROR(EFSCORRUPTED);
91941 @@ -3889,9 +3889,8 @@ xlog_recover(
91942                 }
91943  
91944                 cmn_err(CE_NOTE,
91945 -                       "Starting XFS recovery on filesystem: %s (dev: %d/%d)",
91946 -                       log->l_mp->m_fsname, MAJOR(log->l_dev),
91947 -                       MINOR(log->l_dev));
91948 +                       "Starting XFS recovery on filesystem: %s (dev: %s)",
91949 +                       log->l_mp->m_fsname, XFS_BUFTARG_NAME(log->l_targ));
91950  
91951                 error = xlog_do_recover(log, head_blk, tail_blk);
91952                 log->l_flags |= XLOG_RECOVERY_NEEDED;
91953 @@ -3939,10 +3938,8 @@ xlog_recover_finish(
91954                 xlog_recover_check_summary(log);
91955  
91956                 cmn_err(CE_NOTE,
91957 -                       "Ending XFS recovery on filesystem: %s (dev: %d/%d)",
91958 -                       log->l_mp->m_fsname, MAJOR(log->l_dev),
91959 -                       MINOR(log->l_dev));
91960 -
91961 +                       "Ending XFS recovery on filesystem: %s (dev: %s)",
91962 +                       log->l_mp->m_fsname, XFS_BUFTARG_NAME(log->l_targ));
91963                 log->l_flags &= ~XLOG_RECOVERY_NEEDED;
91964         } else {
91965                 cmn_err(CE_DEBUG,
91966 --- linux-2.6.0-test6/fs/xfs/xfs_mount.c        2003-09-27 18:57:46.000000000 -0700
91967 +++ 25/fs/xfs/xfs_mount.c       2003-10-05 00:33:24.000000000 -0700
91968 @@ -285,9 +285,9 @@ xfs_mount_validate_sb(
91969  #if !XFS_BIG_BLKNOS
91970         if (unlikely(
91971             (sbp->sb_dblocks << (__uint64_t)(sbp->sb_blocklog - BBSHIFT))
91972 -               > INT_MAX ||
91973 +               > UINT_MAX ||
91974             (sbp->sb_rblocks << (__uint64_t)(sbp->sb_blocklog - BBSHIFT))
91975 -               > INT_MAX)) {
91976 +               > UINT_MAX)) {
91977                 cmn_err(CE_WARN,
91978         "XFS: File system is too large to be mounted on this system.");
91979                 return XFS_ERROR(E2BIG);
91980 @@ -949,7 +949,7 @@ xfs_mountfs(
91981          * log's mount-time initialization. Perform 1st part recovery if needed
91982          */
91983         if (likely(sbp->sb_logblocks > 0)) {    /* check for volume case */
91984 -               error = xfs_log_mount(mp, mp->m_logdev_targp->pbr_dev,
91985 +               error = xfs_log_mount(mp, mp->m_logdev_targp,
91986                                       XFS_FSB_TO_DADDR(mp, sbp->sb_logstart),
91987                                       XFS_FSB_TO_BB(mp, sbp->sb_logblocks));
91988                 if (error) {
91989 @@ -980,7 +980,7 @@ xfs_mountfs(
91990         if (unlikely((rip->i_d.di_mode & IFMT) != IFDIR)) {
91991                 cmn_err(CE_WARN, "XFS: corrupted root inode");
91992                 prdev("Root inode %llu is not a directory",
91993 -                     mp->m_dev, (unsigned long long)rip->i_ino);
91994 +                     mp->m_ddev_targp, (unsigned long long)rip->i_ino);
91995                 xfs_iunlock(rip, XFS_ILOCK_EXCL);
91996                 XFS_ERROR_REPORT("xfs_mountfs_int(2)", XFS_ERRLEVEL_LOW,
91997                                  mp);
91998 --- linux-2.6.0-test6/fs/xfs/xfs_mount.h        2003-09-27 18:57:46.000000000 -0700
91999 +++ 25/fs/xfs/xfs_mount.h       2003-10-05 00:33:24.000000000 -0700
92000 @@ -91,10 +91,10 @@ struct xfs_bmap_free;
92001   * Prototypes and functions for the Data Migration subsystem.
92002   */
92003  
92004 -typedef int    (*xfs_send_data_t)(int, struct bhv_desc *,
92005 +typedef int    (*xfs_send_data_t)(int, struct vnode *,
92006                         xfs_off_t, size_t, int, vrwlock_t *);
92007  typedef int    (*xfs_send_mmap_t)(struct vm_area_struct *, uint);
92008 -typedef int    (*xfs_send_destroy_t)(struct bhv_desc *, dm_right_t);
92009 +typedef int    (*xfs_send_destroy_t)(struct vnode *, dm_right_t);
92010  typedef int    (*xfs_send_namesp_t)(dm_eventtype_t, struct vnode *,
92011                         dm_right_t, struct vnode *, dm_right_t,
92012                         char *, char *, mode_t, int, int);
92013 @@ -109,12 +109,12 @@ typedef struct xfs_dmops {
92014         xfs_send_unmount_t      xfs_send_unmount;
92015  } xfs_dmops_t;
92016  
92017 -#define XFS_SEND_DATA(mp, ev,bdp,off,len,fl,lock) \
92018 -       (*(mp)->m_dm_ops.xfs_send_data)(ev,bdp,off,len,fl,lock)
92019 +#define XFS_SEND_DATA(mp, ev,vp,off,len,fl,lock) \
92020 +       (*(mp)->m_dm_ops.xfs_send_data)(ev,vp,off,len,fl,lock)
92021  #define XFS_SEND_MMAP(mp, vma,fl) \
92022         (*(mp)->m_dm_ops.xfs_send_mmap)(vma,fl)
92023 -#define XFS_SEND_DESTROY(mp, bdp,right) \
92024 -       (*(mp)->m_dm_ops.xfs_send_destroy)(bdp,right)
92025 +#define XFS_SEND_DESTROY(mp, vp,right) \
92026 +       (*(mp)->m_dm_ops.xfs_send_destroy)(vp,right)
92027  #define XFS_SEND_NAMESP(mp, ev,b1,r1,b2,r2,n1,n2,mode,rval,fl) \
92028         (*(mp)->m_dm_ops.xfs_send_namesp)(ev,b1,r1,b2,r2,n1,n2,mode,rval,fl)
92029  #define XFS_SEND_UNMOUNT(mp, vfsp,vp,right,mode,rval,fl) \
92030 --- linux-2.6.0-test6/fs/xfs/xfs_rw.c   2003-09-27 18:57:46.000000000 -0700
92031 +++ 25/fs/xfs/xfs_rw.c  2003-10-05 00:33:24.000000000 -0700
92032 @@ -260,11 +260,10 @@ xfs_ioerror_alert(
92033         xfs_daddr_t             blkno)
92034  {
92035         cmn_err(CE_ALERT,
92036 - "I/O error in filesystem (\"%s\") meta-data dev %u:%u block 0x%llx"
92037 + "I/O error in filesystem (\"%s\") meta-data dev %s block 0x%llx"
92038   "       (\"%s\") error %d buf count %u",
92039                 (!mp || !mp->m_fsname) ? "(fs name not set)" : mp->m_fsname,
92040 -               MAJOR(XFS_BUF_TARGET_DEV(bp)),
92041 -               MINOR(XFS_BUF_TARGET_DEV(bp)),
92042 +               XFS_BUFTARG_NAME(bp->pb_target),
92043                 (__uint64_t)blkno,
92044                 func,
92045                 XFS_BUF_GETERROR(bp),
92046 --- linux-2.6.0-test6/fs/xfs/xfs_trans_buf.c    2003-06-14 12:17:57.000000000 -0700
92047 +++ 25/fs/xfs/xfs_trans_buf.c   2003-10-05 00:33:24.000000000 -0700
92048 @@ -264,7 +264,7 @@ xfs_trans_getsb(xfs_trans_t *tp,
92049  }
92050  
92051  #ifdef DEBUG
92052 -dev_t  xfs_error_dev = 0;
92053 +xfs_buftarg_t *xfs_error_target;
92054  int    xfs_do_error;
92055  int    xfs_req_num;
92056  int    xfs_error_mod = 33;
92057 @@ -322,7 +322,7 @@ xfs_trans_read_buf(
92058                 }
92059  #ifdef DEBUG
92060                 if (xfs_do_error && (bp != NULL)) {
92061 -                       if (xfs_error_dev == target->pbr_dev) {
92062 +                       if (xfs_error_target == target) {
92063                                 if (((xfs_req_num++) % xfs_error_mod) == 0) {
92064                                         xfs_buf_relse(bp);
92065                                         printk("Returning error!\n");
92066 @@ -425,7 +425,7 @@ xfs_trans_read_buf(
92067         }
92068  #ifdef DEBUG
92069         if (xfs_do_error && !(tp->t_flags & XFS_TRANS_DIRTY)) {
92070 -               if (xfs_error_dev == target->pbr_dev) {
92071 +               if (xfs_error_target == target) {
92072                         if (((xfs_req_num++) % xfs_error_mod) == 0) {
92073                                 xfs_force_shutdown(tp->t_mountp,
92074                                                    XFS_METADATA_IO_ERROR);
92075 --- linux-2.6.0-test6/fs/xfs/xfs_trans.h        2003-08-08 22:55:13.000000000 -0700
92076 +++ 25/fs/xfs/xfs_trans.h       2003-10-05 00:33:24.000000000 -0700
92077 @@ -995,7 +995,6 @@ void                xfs_trans_dquot_buf(xfs_trans_t *,
92078  void           xfs_trans_inode_alloc_buf(xfs_trans_t *, struct xfs_buf *);
92079  int            xfs_trans_iget(struct xfs_mount *, xfs_trans_t *,
92080                                xfs_ino_t , uint, struct xfs_inode **);
92081 -void           xfs_trans_iput(xfs_trans_t *, struct xfs_inode *, uint);
92082  void           xfs_trans_ijoin(xfs_trans_t *, struct xfs_inode *, uint);
92083  void           xfs_trans_ihold(xfs_trans_t *, struct xfs_inode *);
92084  void           xfs_trans_ihold_release(xfs_trans_t *, struct xfs_inode *);
92085 --- linux-2.6.0-test6/fs/xfs/xfs_trans_inode.c  2003-06-14 12:17:56.000000000 -0700
92086 +++ 25/fs/xfs/xfs_trans_inode.c 2003-10-05 00:33:24.000000000 -0700
92087 @@ -188,106 +188,6 @@ xfs_trans_iget(
92088  
92089  
92090  /*
92091 - * Release the inode ip which was previously acquired with xfs_trans_iget()
92092 - * or added with xfs_trans_ijoin(). This will decrement the lock
92093 - * recursion count of the inode item.  If the count goes to less than 0,
92094 - * the inode will be unlocked and disassociated from the transaction.
92095 - *
92096 - * If the inode has been modified within the transaction, it will not be
92097 - * unlocked until the transaction commits.
92098 - */
92099 -void
92100 -xfs_trans_iput(
92101 -       xfs_trans_t     *tp,
92102 -       xfs_inode_t     *ip,
92103 -       uint            lock_flags)
92104 -{
92105 -       xfs_inode_log_item_t    *iip;
92106 -       xfs_log_item_desc_t     *lidp;
92107 -
92108 -       /*
92109 -        * If the transaction pointer is NULL, just call xfs_iput().
92110 -        */
92111 -       if (tp == NULL) {
92112 -               xfs_iput(ip, lock_flags);
92113 -       }
92114 -
92115 -       ASSERT(ip->i_transp == tp);
92116 -       iip = ip->i_itemp;
92117 -       ASSERT(iip != NULL);
92118 -
92119 -       /*
92120 -        * Find the item descriptor pointing to this inode's
92121 -        * log item.  It must be there.
92122 -        */
92123 -       lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)iip);
92124 -       ASSERT(lidp != NULL);
92125 -       ASSERT(lidp->lid_item == (xfs_log_item_t*)iip);
92126 -
92127 -       /*
92128 -        * Be consistent about the bookkeeping for the inode's
92129 -        * io lock, but it doesn't mean much really.
92130 -        */
92131 -       ASSERT((iip->ili_flags & XFS_ILI_IOLOCKED_ANY) != XFS_ILI_IOLOCKED_ANY);
92132 -       if (lock_flags & (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED)) {
92133 -               ASSERT(iip->ili_flags & XFS_ILI_IOLOCKED_ANY);
92134 -               ASSERT((!(lock_flags & XFS_IOLOCK_EXCL)) ||
92135 -                      (iip->ili_flags & XFS_ILI_IOLOCKED_EXCL));
92136 -               ASSERT((!(lock_flags & XFS_IOLOCK_SHARED)) ||
92137 -                      (iip->ili_flags &
92138 -                       (XFS_ILI_IOLOCKED_EXCL | XFS_ILI_IOLOCKED_SHARED)));
92139 -               if (iip->ili_iolock_recur > 0) {
92140 -                       iip->ili_iolock_recur--;
92141 -               }
92142 -       }
92143 -
92144 -       /*
92145 -        * If the release is just for a recursive lock on the inode lock,
92146 -        * then decrement the count and return.  We can assert that
92147 -        * the caller is dropping an EXCL lock on the inode, because
92148 -        * inode must be locked EXCL within transactions.
92149 -        */
92150 -       ASSERT(lock_flags & XFS_ILOCK_EXCL);
92151 -       if (iip->ili_ilock_recur > 0) {
92152 -               iip->ili_ilock_recur--;
92153 -               return;
92154 -       }
92155 -       ASSERT(iip->ili_iolock_recur == 0);
92156 -
92157 -       /*
92158 -        * If the inode was dirtied within this transaction, it cannot
92159 -        * be released until the transaction commits.
92160 -        */
92161 -       if (lidp->lid_flags & XFS_LID_DIRTY) {
92162 -               return;
92163 -       }
92164 -
92165 -       xfs_trans_free_item(tp, lidp);
92166 -
92167 -       /*
92168 -        * Clear the hold and iolocked flags in the inode log item.
92169 -        * We wouldn't want the next user of the inode to
92170 -        * get confused.  Assert that if the iolocked flag is set
92171 -        * in the item then we are unlocking it in the call to xfs_iput()
92172 -        * below.
92173 -        */
92174 -       ASSERT((!(iip->ili_flags & XFS_ILI_IOLOCKED_ANY)) ||
92175 -              (lock_flags & (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED)));
92176 -       if (iip->ili_flags & (XFS_ILI_HOLD | XFS_ILI_IOLOCKED_ANY)) {
92177 -               iip->ili_flags &= ~(XFS_ILI_HOLD | XFS_ILI_IOLOCKED_ANY);
92178 -       }
92179 -
92180 -       /*
92181 -        * Unlike xfs_brelse() the inode log item cannot be
92182 -        * freed, because it is embedded within the inode.
92183 -        * All we have to do is release the inode.
92184 -        */
92185 -       xfs_iput(ip, lock_flags);
92186 -       return;
92187 -}
92188 -
92189 -
92190 -/*
92191   * Add the locked inode to the transaction.
92192   * The inode must be locked, and it cannot be associated with any
92193   * transaction.  The caller must specify the locks already held
92194 --- linux-2.6.0-test6/fs/xfs/xfs_types.h        2003-09-27 18:57:46.000000000 -0700
92195 +++ 25/fs/xfs/xfs_types.h       2003-10-05 00:33:24.000000000 -0700
92196 @@ -83,7 +83,7 @@ typedef __uint64_t __psunsigned_t;
92197   * XFS_BIG_INUMS needs the VFS inode number to be 64 bits, as well
92198   * as requiring XFS_BIG_BLKNOS to be set.
92199   */
92200 -#if defined(CONFIG_LBD) || (defined(HAVE_SECTOR_T) && (BITS_PER_LONG == 64))
92201 +#if defined(CONFIG_LBD) || (BITS_PER_LONG == 64)
92202  # define XFS_BIG_BLKNOS        1
92203  # if BITS_PER_LONG == 64
92204  #  define XFS_BIG_INUMS        1
92205 --- linux-2.6.0-test6/fs/xfs/xfs_vfsops.c       2003-09-27 18:57:46.000000000 -0700
92206 +++ 25/fs/xfs/xfs_vfsops.c      2003-10-05 00:33:24.000000000 -0700
92207 @@ -1776,7 +1776,6 @@ xfs_showargs(
92208         };
92209         struct proc_xfs_info    *xfs_infop;
92210         struct xfs_mount        *mp = XFS_BHVTOM(bhv);
92211 -       char                    b[BDEVNAME_SIZE];
92212  
92213         for (xfs_infop = xfs_info; xfs_infop->flag; xfs_infop++) {
92214                 if (mp->m_flags & xfs_infop->flag)
92215 @@ -1792,14 +1791,13 @@ xfs_showargs(
92216         if (mp->m_logbsize > 0)
92217                 seq_printf(m, "," MNTOPT_LOGBSIZE "=%d", mp->m_logbsize);
92218  
92219 -       if (mp->m_ddev_targp->pbr_dev != mp->m_logdev_targp->pbr_dev)
92220 +       if (mp->m_ddev_targp != mp->m_logdev_targp)
92221                 seq_printf(m, "," MNTOPT_LOGDEV "=%s",
92222 -                               bdevname(mp->m_logdev_targp->pbr_bdev, b));
92223 +                               XFS_BUFTARG_NAME(mp->m_logdev_targp));
92224  
92225 -       if (mp->m_rtdev_targp &&
92226 -           mp->m_ddev_targp->pbr_dev != mp->m_rtdev_targp->pbr_dev)
92227 +       if (mp->m_rtdev_targp && mp->m_ddev_targp != mp->m_rtdev_targp)
92228                 seq_printf(m, "," MNTOPT_RTDEV "=%s",
92229 -                               bdevname(mp->m_rtdev_targp->pbr_bdev, b));
92230 +                               XFS_BUFTARG_NAME(mp->m_rtdev_targp));
92231  
92232         if (mp->m_dalign > 0)
92233                 seq_printf(m, "," MNTOPT_SUNIT "=%d",
92234 --- linux-2.6.0-test6/fs/xfs/xfs_vnodeops.c     2003-09-27 18:57:46.000000000 -0700
92235 +++ 25/fs/xfs/xfs_vnodeops.c    2003-10-05 00:33:24.000000000 -0700
92236 @@ -144,14 +144,11 @@ xfs_getattr(
92237                 xfs_ilock(ip, XFS_ILOCK_SHARED);
92238  
92239         vap->va_size = ip->i_d.di_size;
92240 -       if (vap->va_mask == XFS_AT_SIZE) {
92241 -               if (!(flags & ATTR_LAZY))
92242 -                       xfs_iunlock(ip, XFS_ILOCK_SHARED);
92243 -               return 0;
92244 -       }
92245 +       if (vap->va_mask == XFS_AT_SIZE)
92246 +               goto all_done;
92247 +
92248         vap->va_nblocks =
92249                 XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
92250 -       vap->va_fsid = mp->m_dev;
92251         vap->va_nodeid = ip->i_ino;
92252  #if XFS_BIG_INUMS
92253         vap->va_nodeid += mp->m_inoadd;
92254 @@ -163,11 +160,8 @@ xfs_getattr(
92255          */
92256         if ((vap->va_mask &
92257             ~(XFS_AT_SIZE|XFS_AT_FSID|XFS_AT_NODEID|
92258 -             XFS_AT_NLINK|XFS_AT_BLKSIZE)) == 0) {
92259 -               if (!(flags & ATTR_LAZY))
92260 -                       xfs_iunlock(ip, XFS_ILOCK_SHARED);
92261 -               return 0;
92262 -       }
92263 +             XFS_AT_NLINK|XFS_AT_BLKSIZE)) == 0)
92264 +               goto all_done;
92265  
92266         /*
92267          * Copy from in-core inode.
92268 @@ -194,7 +188,7 @@ xfs_getattr(
92269                          * stripe size through is not a good
92270                          * idea for now.
92271                          */
92272 -                       vap->va_blksize = mp->m_swidth ?
92273 +                       vap->va_blocksize = mp->m_swidth ?
92274                                 /*
92275                                  * If the underlying volume is a stripe, then
92276                                  * return the stripe width in bytes as the
92277 @@ -211,7 +205,7 @@ xfs_getattr(
92278                                                mp->m_writeio_log));
92279  
92280  #else
92281 -                       vap->va_blksize =
92282 +                       vap->va_blocksize =
92283                                 /*
92284                                  * Return the largest of the preferred buffer
92285                                  * sizes since doing small I/Os into larger
92286 @@ -229,13 +223,13 @@ xfs_getattr(
92287                          * realtime extent size or the realtime volume's
92288                          * extent size.
92289                          */
92290 -                       vap->va_blksize = ip->i_d.di_extsize ?
92291 +                       vap->va_blocksize = ip->i_d.di_extsize ?
92292                                 (ip->i_d.di_extsize << mp->m_sb.sb_blocklog) :
92293                                 (mp->m_sb.sb_rextsize << mp->m_sb.sb_blocklog);
92294                 }
92295         } else {
92296                 vap->va_rdev = ip->i_df.if_u2.if_rdev;
92297 -               vap->va_blksize = BLKDEV_IOSIZE;
92298 +               vap->va_blocksize = BLKDEV_IOSIZE;
92299         }
92300  
92301         vap->va_atime.tv_sec = ip->i_d.di_atime.t_sec;
92302 @@ -251,46 +245,53 @@ xfs_getattr(
92303          */
92304         if ((vap->va_mask &
92305              (XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|
92306 -             XFS_AT_GENCOUNT|XFS_AT_VCODE)) == 0) {
92307 -               if (!(flags & ATTR_LAZY))
92308 -                       xfs_iunlock(ip, XFS_ILOCK_SHARED);
92309 -               return 0;
92310 -       }
92311 +             XFS_AT_GENCOUNT|XFS_AT_VCODE)) == 0)
92312 +               goto all_done;
92313 +
92314         /*
92315          * convert di_flags to xflags
92316          */
92317 -       vap->va_xflags =
92318 -               ((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
92319 -                       XFS_XFLAG_REALTIME : 0) |
92320 -               ((ip->i_d.di_flags & XFS_DIFLAG_PREALLOC) ?
92321 -                       XFS_XFLAG_PREALLOC : 0) |
92322 -               ((ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE) ?
92323 -                       XFS_XFLAG_IMMUTABLE : 0) |
92324 -               ((ip->i_d.di_flags & XFS_DIFLAG_APPEND) ?
92325 -                       XFS_XFLAG_APPEND : 0) |
92326 -               ((ip->i_d.di_flags & XFS_DIFLAG_SYNC) ?
92327 -                       XFS_XFLAG_SYNC : 0) |
92328 -               ((ip->i_d.di_flags & XFS_DIFLAG_NOATIME) ?
92329 -                       XFS_XFLAG_NOATIME : 0) |
92330 -               ((ip->i_d.di_flags & XFS_DIFLAG_NODUMP) ?
92331 -                       XFS_XFLAG_NODUMP: 0) |
92332 -               (XFS_IFORK_Q(ip) ?
92333 -                       XFS_XFLAG_HASATTR : 0);
92334 +       vap->va_xflags = 0;
92335 +       if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME)
92336 +               vap->va_xflags |= XFS_XFLAG_REALTIME;
92337 +       if (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC)
92338 +               vap->va_xflags |= XFS_XFLAG_PREALLOC;
92339 +       if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
92340 +               vap->va_xflags |= XFS_XFLAG_IMMUTABLE;
92341 +       if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
92342 +               vap->va_xflags |= XFS_XFLAG_APPEND;
92343 +       if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
92344 +               vap->va_xflags |= XFS_XFLAG_SYNC;
92345 +       if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
92346 +               vap->va_xflags |= XFS_XFLAG_NOATIME;
92347 +       if (ip->i_d.di_flags & XFS_DIFLAG_NODUMP)
92348 +               vap->va_xflags |= XFS_XFLAG_NODUMP;
92349 +       if (XFS_IFORK_Q(ip))
92350 +               vap->va_xflags |= XFS_XFLAG_HASATTR;
92351 +       /*
92352 +        * Exit for inode revalidate.  See if any of the rest of
92353 +        * the fields to be filled in are needed.
92354 +        */
92355 +       if ((vap->va_mask &
92356 +            (XFS_AT_EXTSIZE|XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|
92357 +             XFS_AT_GENCOUNT|XFS_AT_VCODE)) == 0)
92358 +               goto all_done;
92359 +
92360         vap->va_extsize = ip->i_d.di_extsize << mp->m_sb.sb_blocklog;
92361         vap->va_nextents =
92362                 (ip->i_df.if_flags & XFS_IFEXTENTS) ?
92363                         ip->i_df.if_bytes / sizeof(xfs_bmbt_rec_t) :
92364                         ip->i_d.di_nextents;
92365 -       if (ip->i_afp != NULL)
92366 +       if (ip->i_afp)
92367                 vap->va_anextents =
92368                         (ip->i_afp->if_flags & XFS_IFEXTENTS) ?
92369                                 ip->i_afp->if_bytes / sizeof(xfs_bmbt_rec_t) :
92370                                  ip->i_d.di_anextents;
92371         else
92372                 vap->va_anextents = 0;
92373 -       vap->va_gencount = ip->i_d.di_gen;
92374 -       vap->va_vcode = 0L;
92375 +       vap->va_gen = ip->i_d.di_gen;
92376  
92377 + all_done:
92378         if (!(flags & ATTR_LAZY))
92379                 xfs_iunlock(ip, XFS_ILOCK_SHARED);
92380         return 0;
92381 @@ -415,7 +416,7 @@ xfs_setattr(
92382         } else {
92383                 if (DM_EVENT_ENABLED (vp->v_vfsp, ip, DM_EVENT_TRUNCATE) &&
92384                     !(flags & ATTR_DMI)) {
92385 -                       code = XFS_SEND_DATA(mp, DM_EVENT_TRUNCATE, bdp,
92386 +                       code = XFS_SEND_DATA(mp, DM_EVENT_TRUNCATE, vp,
92387                                 vap->va_size, 0, AT_DELAY_FLAG(flags), NULL);
92388                         if (code) {
92389                                 lock_flags = 0;
92390 @@ -1042,7 +1043,7 @@ xfs_readlink(
92391         pathlen = (int)ip->i_d.di_size;
92392  
92393         if (ip->i_df.if_flags & XFS_IFINLINE) {
92394 -               error = uiomove(ip->i_df.if_u1.if_data, pathlen, UIO_READ, uiop);
92395 +               error = uio_read(ip->i_df.if_u1.if_data, pathlen, uiop);
92396         }
92397         else {
92398                 /*
92399 @@ -1073,8 +1074,7 @@ xfs_readlink(
92400                                 byte_cnt = pathlen;
92401                         pathlen -= byte_cnt;
92402  
92403 -                       error = uiomove(XFS_BUF_PTR(bp), byte_cnt,
92404 -                                        UIO_READ, uiop);
92405 +                       error = uio_read(XFS_BUF_PTR(bp), byte_cnt, uiop);
92406                         xfs_buf_relse (bp);
92407                 }
92408  
92409 @@ -1729,7 +1729,7 @@ xfs_inactive(
92410  
92411         if (ip->i_d.di_nlink == 0 &&
92412             DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_DESTROY)) {
92413 -               (void) XFS_SEND_DESTROY(mp, bdp, DM_RIGHT_NULL);
92414 +               (void) XFS_SEND_DESTROY(mp, vp, DM_RIGHT_NULL);
92415         }
92416  
92417         error = 0;
92418 @@ -4163,7 +4163,7 @@ xfs_alloc_file_space(
92419                 end_dmi_offset = offset+len;
92420                 if (end_dmi_offset > ip->i_d.di_size)
92421                         end_dmi_offset = ip->i_d.di_size;
92422 -               error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, XFS_ITOBHV(ip),
92423 +               error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, XFS_ITOV(ip),
92424                         offset, end_dmi_offset - offset,
92425                         0, NULL);
92426                 if (error)
92427 @@ -4410,7 +4410,7 @@ xfs_free_file_space(
92428             DM_EVENT_ENABLED(XFS_MTOVFS(mp), ip, DM_EVENT_WRITE)) {
92429                 if (end_dmi_offset > ip->i_d.di_size)
92430                         end_dmi_offset = ip->i_d.di_size;
92431 -               error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, XFS_ITOBHV(ip),
92432 +               error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, XFS_ITOV(ip),
92433                                 offset, end_dmi_offset - offset,
92434                                 AT_DELAY_FLAG(attr_flags), NULL);
92435                 if (error)
92436 --- linux-2.6.0-test6/include/acpi/acconfig.h   2003-08-22 19:23:42.000000000 -0700
92437 +++ 25/include/acpi/acconfig.h  2003-10-05 00:33:24.000000000 -0700
92438 @@ -64,7 +64,7 @@
92439  
92440  /* Version string */
92441  
92442 -#define ACPI_CA_VERSION                 0x20030813
92443 +#define ACPI_CA_VERSION                 0x20030918
92444  
92445  /* Maximum objects in the various object caches */
92446  
92447 --- linux-2.6.0-test6/include/acpi/acdisasm.h   2003-06-14 12:18:22.000000000 -0700
92448 +++ 25/include/acpi/acdisasm.h  2003-10-05 00:33:24.000000000 -0700
92449 @@ -152,10 +152,6 @@ void
92450  acpi_dm_decode_internal_object (
92451         union acpi_operand_object       *obj_desc);
92452  
92453 -void
92454 -acpi_dm_decode_node (
92455 -       struct acpi_namespace_node      *node);
92456 -
92457  u32
92458  acpi_dm_block_type (
92459         union acpi_parse_object         *op);
92460 --- linux-2.6.0-test6/include/acpi/acstruct.h   2003-06-14 12:17:57.000000000 -0700
92461 +++ 25/include/acpi/acstruct.h  2003-10-05 00:33:24.000000000 -0700
92462 @@ -91,11 +91,12 @@ struct acpi_walk_state
92463         struct acpi_namespace_node          arguments[ACPI_METHOD_NUM_ARGS];    /* Control method arguments */
92464         union acpi_operand_object           **caller_return_desc;
92465         union acpi_generic_state            *control_state;                     /* List of control states (nested IFs) */
92466 +       struct acpi_namespace_node          *deferred_node;                      /* Used when executing deferred opcodes */
92467         struct acpi_namespace_node          local_variables[ACPI_METHOD_NUM_LOCALS];    /* Control method locals */
92468         struct acpi_namespace_node          *method_call_node;                  /* Called method Node*/
92469         union acpi_parse_object             *method_call_op;                    /* method_call Op if running a method */
92470         union acpi_operand_object           *method_desc;                       /* Method descriptor if running a method */
92471 -       struct acpi_namespace_node          *method_node;                       /* Method Node if running a method */
92472 +       struct acpi_namespace_node          *method_node;                       /* Method node if running a method. */
92473         union acpi_parse_object             *op;                                /* Current parser op */
92474         union acpi_operand_object           *operands[ACPI_OBJ_NUM_OPERANDS+1]; /* Operands passed to the interpreter (+1 for NULL terminator) */
92475         const struct acpi_opcode_info       *op_info;                           /* Info on current opcode */
92476 --- linux-2.6.0-test6/include/asm-alpha/cacheflush.h    2003-06-14 12:18:25.000000000 -0700
92477 +++ 25/include/asm-alpha/cacheflush.h   2003-10-05 00:33:24.000000000 -0700
92478 @@ -10,6 +10,8 @@
92479  #define flush_cache_range(vma, start, end)     do { } while (0)
92480  #define flush_cache_page(vma, vmaddr)          do { } while (0)
92481  #define flush_dcache_page(page)                        do { } while (0)
92482 +#define flush_cache_vmap(start, end)           do { } while (0)
92483 +#define flush_cache_vunmap(start, end)         do { } while (0)
92484  
92485  /* Note that the following two definitions are _highly_ dependent
92486     on the contexts in which they are used in the kernel.  I personally
92487 @@ -60,4 +62,11 @@ extern void flush_icache_user_range(stru
92488  #define flush_icache_page(vma, page) \
92489    flush_icache_user_range((vma), (page), 0, 0)
92490  
92491 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
92492 +do { memcpy(dst, src, len); \
92493 +     flush_icache_user_range(vma, page, vaddr, len); \
92494 +} while (0)
92495 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
92496 +       memcpy(dst, src, len)
92497 +
92498  #endif /* _ALPHA_CACHEFLUSH_H */
92499 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
92500 +++ 25/include/asm-alpha/lockmeter.h    2003-10-05 00:36:40.000000000 -0700
92501 @@ -0,0 +1,90 @@
92502 +/*
92503 + *  Written by John Hawkes (hawkes@sgi.com)
92504 + *  Based on klstat.h by Jack Steiner (steiner@sgi.com)
92505 + *
92506 + *  Modified by Peter Rival (frival@zk3.dec.com)
92507 + */
92508 +
92509 +#ifndef _ALPHA_LOCKMETER_H
92510 +#define _ALPHA_LOCKMETER_H
92511 +
92512 +#include <asm/hwrpb.h>
92513 +#define CPU_CYCLE_FREQUENCY    hwrpb->cycle_freq
92514 +
92515 +#define get_cycles64()         get_cycles()
92516 +
92517 +#define THIS_CPU_NUMBER                smp_processor_id()
92518 +
92519 +#include <linux/version.h>
92520 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
92521 +#define local_irq_save(x) \
92522 +       __save_and_cli(x)
92523 +#define local_irq_restore(x) \
92524 +       __restore_flags(x)
92525 +#endif /* Linux version 2.2.x */
92526 +
92527 +#define SPINLOCK_MAGIC_INIT /**/
92528 +
92529 +/*
92530 + * Macros to cache and retrieve an index value inside of a lock
92531 + * these macros assume that there are less than 65536 simultaneous
92532 + * (read mode) holders of a rwlock.
92533 + * We also assume that the hash table has less than 32767 entries.
92534 + * the high order bit is used for write locking a rw_lock
92535 + * Note: although these defines and macros are the same as what is being used
92536 + *       in include/asm-i386/lockmeter.h, they are present here to easily
92537 + *      allow an alternate Alpha implementation.
92538 + */
92539 +/*
92540 + * instrumented spinlock structure -- never used to allocate storage
92541 + * only used in macros below to overlay a spinlock_t
92542 + */
92543 +typedef struct inst_spinlock_s {
92544 +       /* remember, Alpha is little endian */
92545 +       unsigned short lock;
92546 +       unsigned short index;
92547 +} inst_spinlock_t;
92548 +#define PUT_INDEX(lock_ptr,indexv)     ((inst_spinlock_t *)(lock_ptr))->index = indexv
92549 +#define GET_INDEX(lock_ptr)            ((inst_spinlock_t *)(lock_ptr))->index
92550 +
92551 +/*
92552 + * macros to cache and retrieve an index value in a read/write lock
92553 + * as well as the cpu where a reader busy period started
92554 + * we use the 2nd word (the debug word) for this, so require the
92555 + * debug word to be present
92556 + */
92557 +/*
92558 + * instrumented rwlock structure -- never used to allocate storage
92559 + * only used in macros below to overlay a rwlock_t
92560 + */
92561 +typedef struct inst_rwlock_s {
92562 +       volatile int lock;
92563 +       unsigned short index;
92564 +       unsigned short cpu;
92565 +} inst_rwlock_t;
92566 +#define PUT_RWINDEX(rwlock_ptr,indexv) ((inst_rwlock_t *)(rwlock_ptr))->index = indexv
92567 +#define GET_RWINDEX(rwlock_ptr)                ((inst_rwlock_t *)(rwlock_ptr))->index
92568 +#define PUT_RW_CPU(rwlock_ptr,cpuv)    ((inst_rwlock_t *)(rwlock_ptr))->cpu = cpuv
92569 +#define GET_RW_CPU(rwlock_ptr)         ((inst_rwlock_t *)(rwlock_ptr))->cpu
92570 +
92571 +/*
92572 + * return true if rwlock is write locked
92573 + * (note that other lock attempts can cause the lock value to be negative)
92574 + */
92575 +#define RWLOCK_IS_WRITE_LOCKED(rwlock_ptr) (((inst_rwlock_t *)rwlock_ptr)->lock & 1)
92576 +#define IABS(x) ((x) > 0 ? (x) : -(x))
92577 +
92578 +#define RWLOCK_READERS(rwlock_ptr)     rwlock_readers(rwlock_ptr)
92579 +extern inline int rwlock_readers(rwlock_t *rwlock_ptr)
92580 +{
92581 +       int tmp = (int) ((inst_rwlock_t *)rwlock_ptr)->lock;
92582 +       /* readers subtract 2, so we have to:           */
92583 +       /*      - andnot off a possible writer (bit 0)  */
92584 +       /*      - get the absolute value                */
92585 +       /*      - divide by 2 (right shift by one)      */
92586 +       /* to find the number of readers                */
92587 +       if (tmp == 0) return(0);
92588 +       else return(IABS(tmp & ~1)>>1);
92589 +}
92590 +
92591 +#endif /* _ALPHA_LOCKMETER_H */
92592 --- linux-2.6.0-test6/include/asm-alpha/numnodes.h      2003-06-14 12:17:58.000000000 -0700
92593 +++ 25/include/asm-alpha/numnodes.h     2003-10-05 00:34:38.000000000 -0700
92594 @@ -1,6 +1,7 @@
92595  #ifndef _ASM_MAX_NUMNODES_H
92596  #define _ASM_MAX_NUMNODES_H
92597  
92598 -#define MAX_NUMNODES           128 /* Marvel */
92599 +/* Max 128 Nodes - Marvel */
92600 +#define NODES_SHIFT    7
92601  
92602  #endif /* _ASM_MAX_NUMNODES_H */
92603 --- linux-2.6.0-test6/include/asm-alpha/pgtable.h       2003-06-14 12:18:06.000000000 -0700
92604 +++ 25/include/asm-alpha/pgtable.h      2003-10-05 00:33:24.000000000 -0700
92605 @@ -49,7 +49,6 @@
92606  #else
92607  #define VMALLOC_START          (-2*PGDIR_SIZE)
92608  #endif
92609 -#define VMALLOC_VMADDR(x)      ((unsigned long)(x))
92610  #define VMALLOC_END            (-PGDIR_SIZE)
92611  
92612  /*
92613 --- linux-2.6.0-test6/include/asm-alpha/spinlock.h      2003-06-26 22:07:25.000000000 -0700
92614 +++ 25/include/asm-alpha/spinlock.h     2003-10-05 00:36:40.000000000 -0700
92615 @@ -6,6 +6,10 @@
92616  #include <linux/kernel.h>
92617  #include <asm/current.h>
92618  
92619 +#ifdef CONFIG_LOCKMETER
92620 +#undef DEBUG_SPINLOCK
92621 +#undef DEBUG_RWLOCK
92622 +#endif
92623  
92624  /*
92625   * Simple spin lock operations.  There are two variants, one clears IRQ's
92626 @@ -95,9 +99,18 @@ static inline int _raw_spin_trylock(spin
92627  
92628  typedef struct {
92629         volatile int write_lock:1, read_counter:31;
92630 +#ifdef CONFIG_LOCKMETER
92631 +       /* required for LOCKMETER since all bits in lock are used */
92632 +       /* need this storage for CPU and lock INDEX ............. */
92633 +       unsigned magic;
92634 +#endif
92635  } /*__attribute__((aligned(32)))*/ rwlock_t;
92636  
92637 +#ifdef CONFIG_LOCKMETER
92638 +#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, 0 }
92639 +#else
92640  #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 }
92641 +#endif
92642  
92643  #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
92644  #define rwlock_is_locked(x)    (*(volatile int *)(x) != 0)
92645 @@ -169,4 +182,41 @@ static inline void _raw_read_unlock(rwlo
92646         : "m" (*lock) : "memory");
92647  }
92648  
92649 +#ifdef CONFIG_LOCKMETER
92650 +static inline int _raw_write_trylock(rwlock_t *lock)
92651 +{
92652 +       long temp,result;
92653 +
92654 +       __asm__ __volatile__(
92655 +       "       ldl_l %1,%0\n"
92656 +       "       mov $31,%2\n"
92657 +       "       bne %1,1f\n"
92658 +       "       or $31,1,%2\n"
92659 +       "       stl_c %2,%0\n"
92660 +       "1:     mb\n"
92661 +       : "=m" (*(volatile int *)lock), "=&r" (temp), "=&r" (result)
92662 +       : "m" (*(volatile int *)lock)
92663 +       );
92664 +
92665 +       return (result);
92666 +}
92667 +
92668 +static inline int _raw_read_trylock(rwlock_t *lock)
92669 +{
92670 +       unsigned long temp,result;
92671 +
92672 +       __asm__ __volatile__(
92673 +       "       ldl_l %1,%0\n"
92674 +       "       mov $31,%2\n"
92675 +       "       blbs %1,1f\n"
92676 +       "       subl %1,2,%2\n"
92677 +       "       stl_c %2,%0\n"
92678 +       "1:     mb\n"
92679 +       : "=m" (*(volatile int *)lock), "=&r" (temp), "=&r" (result)
92680 +       : "m" (*(volatile int *)lock)
92681 +       );
92682 +       return (result);
92683 +}
92684 +#endif /* CONFIG_LOCKMETER */
92685 +
92686  #endif /* _ALPHA_SPINLOCK_H */
92687 --- linux-2.6.0-test6/include/asm-arm26/cacheflush.h    2003-06-14 12:18:29.000000000 -0700
92688 +++ 25/include/asm-arm26/cacheflush.h   2003-10-05 00:33:24.000000000 -0700
92689 @@ -25,6 +25,8 @@
92690  #define flush_cache_range(vma,start,end)        do { } while (0)
92691  #define flush_cache_page(vma,vmaddr)            do { } while (0)
92692  #define flush_page_to_ram(page)                 do { } while (0)
92693 +#define flush_cache_vmap(start, end)           do { } while (0)
92694 +#define flush_cache_vunmap(start, end)         do { } while (0)
92695  
92696  #define invalidate_dcache_range(start,end)      do { } while (0)
92697  #define clean_dcache_range(start,end)           do { } while (0)
92698 @@ -37,6 +39,11 @@
92699  #define flush_icache_range(start,end)           do { } while (0)
92700  #define flush_icache_page(vma,page)             do { } while (0)
92701  
92702 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
92703 +       memcpy(dst, src, len)
92704 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
92705 +       memcpy(dst, src, len)
92706 +
92707  /* DAG: ARM3 will flush cache on MEMC updates anyway? so don't bother */
92708  /* IM : Yes, it will, but only if setup to do so (we do this). */
92709  #define clean_cache_area(_start,_size)          do { } while (0)
92710 --- linux-2.6.0-test6/include/asm-arm26/pgtable.h       2003-07-10 18:50:32.000000000 -0700
92711 +++ 25/include/asm-arm26/pgtable.h      2003-10-05 00:33:24.000000000 -0700
92712 @@ -173,7 +173,6 @@ extern struct page *empty_zero_page;
92713   * area for the same reason. ;) FIXME: surely 1 page not 4k ?
92714   */
92715  #define VMALLOC_START     0x01a00000
92716 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
92717  #define VMALLOC_END       0x01c00000
92718  
92719  /* Is pmd_page supposed to return a pointer to a page in some arches? ours seems to
92720 --- linux-2.6.0-test6/include/asm-arm/arch-adifcc/vmalloc.h     2003-06-14 12:17:58.000000000 -0700
92721 +++ 25/include/asm-arm/arch-adifcc/vmalloc.h    2003-10-05 00:33:24.000000000 -0700
92722 @@ -12,7 +12,6 @@
92723   */
92724  #define VMALLOC_OFFSET   (8*1024*1024)
92725  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
92726 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
92727  #define VMALLOC_END       (0xe8000000)
92728  
92729  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
92730 --- linux-2.6.0-test6/include/asm-arm/arch-anakin/vmalloc.h     2003-06-14 12:18:04.000000000 -0700
92731 +++ 25/include/asm-arm/arch-anakin/vmalloc.h    2003-10-05 00:33:24.000000000 -0700
92732 @@ -19,8 +19,7 @@
92733   * linux/arch/arm/kernel/traps.c)
92734   */
92735  #define VMALLOC_ARCH_OFFSET    (8 * 1024 * 1024)
92736 -#define VMALLOC_VMADDR(a)      ((unsigned int) (a))
92737 -#define VMALLOC_START          ((VMALLOC_VMADDR(high_memory) + VMALLOC_ARCH_OFFSET) & ~(VMALLOC_ARCH_OFFSET - 1))
92738 +#define VMALLOC_START          (((unsigned long) (high_memory) + VMALLOC_ARCH_OFFSET) & ~(VMALLOC_ARCH_OFFSET - 1))
92739  #define VMALLOC_END            (PAGE_OFFSET + 0x10000000)
92740  
92741  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
92742 --- linux-2.6.0-test6/include/asm-arm/arch-cl7500/vmalloc.h     2003-06-14 12:18:32.000000000 -0700
92743 +++ 25/include/asm-arm/arch-cl7500/vmalloc.h    2003-10-05 00:33:24.000000000 -0700
92744 @@ -12,7 +12,6 @@
92745   */
92746  #define VMALLOC_OFFSET   (8*1024*1024)
92747  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
92748 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
92749  #define VMALLOC_END       (PAGE_OFFSET + 0x1c000000)
92750  
92751  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
92752 --- linux-2.6.0-test6/include/asm-arm/arch-clps711x/memory.h    2003-06-14 12:17:56.000000000 -0700
92753 +++ 25/include/asm-arm/arch-clps711x/memory.h   2003-10-05 00:34:40.000000000 -0700
92754 @@ -109,8 +109,6 @@
92755   *     node 3:  0xd8000000 - 0xdfffffff
92756   */
92757  
92758 -#define NR_NODES       4
92759 -
92760  /*
92761   * Given a kernel address, find the home node of the underlying memory.
92762   */
92763 --- linux-2.6.0-test6/include/asm-arm/arch-clps711x/vmalloc.h   2003-06-14 12:17:56.000000000 -0700
92764 +++ 25/include/asm-arm/arch-clps711x/vmalloc.h  2003-10-05 00:33:24.000000000 -0700
92765 @@ -28,7 +28,6 @@
92766   */
92767  #define VMALLOC_OFFSET   (8*1024*1024)
92768  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
92769 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
92770  #define VMALLOC_END       (PAGE_OFFSET + 0x10000000)
92771  
92772  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
92773 --- linux-2.6.0-test6/include/asm-arm/arch-ebsa110/vmalloc.h    2003-06-14 12:18:07.000000000 -0700
92774 +++ 25/include/asm-arm/arch-ebsa110/vmalloc.h   2003-10-05 00:33:24.000000000 -0700
92775 @@ -18,7 +18,6 @@
92776   */
92777  #define VMALLOC_OFFSET   (8*1024*1024)
92778  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
92779 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
92780  #define VMALLOC_END       (PAGE_OFFSET + 0x1f000000)
92781  
92782  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
92783 --- linux-2.6.0-test6/include/asm-arm/arch-ebsa285/vmalloc.h    2003-06-14 12:18:08.000000000 -0700
92784 +++ 25/include/asm-arm/arch-ebsa285/vmalloc.h   2003-10-05 00:33:24.000000000 -0700
92785 @@ -18,7 +18,6 @@
92786   */
92787  #define VMALLOC_OFFSET   (8*1024*1024)
92788  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
92789 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
92790  
92791  #ifdef CONFIG_ARCH_FOOTBRIDGE
92792  #define VMALLOC_END       (PAGE_OFFSET + 0x30000000)
92793 --- linux-2.6.0-test6/include/asm-arm/arch-epxa10db/vmalloc.h   2003-06-14 12:17:58.000000000 -0700
92794 +++ 25/include/asm-arm/arch-epxa10db/vmalloc.h  2003-10-05 00:33:24.000000000 -0700
92795 @@ -28,7 +28,6 @@
92796   */
92797  #define VMALLOC_OFFSET   (8*1024*1024)
92798  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
92799 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
92800  #define VMALLOC_END       (PAGE_OFFSET + 0x10000000)
92801  
92802  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
92803 --- linux-2.6.0-test6/include/asm-arm/arch-integrator/irqs.h    2003-06-14 12:17:57.000000000 -0700
92804 +++ 25/include/asm-arm/arch-integrator/irqs.h   2003-10-05 00:33:24.000000000 -0700
92805 @@ -19,116 +19,39 @@
92806   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
92807   */
92808  
92809 -/* Use the integrator definitions */
92810 -#include <asm/arch/platform.h>
92811 -
92812 -/* 
92813 - *  IRQ interrupts definitions are the same the INT definitions
92814 - *  held within platform.h
92815 - */
92816 -#define IRQ_SOFTINT                     INT_SOFTINT
92817 -#define IRQ_UARTINT0                    INT_UARTINT0
92818 -#define IRQ_UARTINT1                    INT_UARTINT1
92819 -#define IRQ_KMIINT0                     INT_KMIINT0
92820 -#define IRQ_KMIINT1                     INT_KMIINT1
92821 -#define IRQ_TIMERINT0                   INT_TIMERINT0
92822 -#define IRQ_TIMERINT1                   INT_TIMERINT1
92823 -#define IRQ_TIMERINT2                   INT_TIMERINT2
92824 -#define IRQ_RTCINT                      INT_RTCINT
92825 -#define IRQ_EXPINT0                     INT_EXPINT0
92826 -#define IRQ_EXPINT1                     INT_EXPINT1
92827 -#define IRQ_EXPINT2                     INT_EXPINT2
92828 -#define IRQ_EXPINT3                     INT_EXPINT3
92829 -#define IRQ_PCIINT0                     INT_PCIINT0
92830 -#define IRQ_PCIINT1                     INT_PCIINT1
92831 -#define IRQ_PCIINT2                     INT_PCIINT2
92832 -#define IRQ_PCIINT3                     INT_PCIINT3
92833 -#define IRQ_V3INT                       INT_V3INT
92834 -#define IRQ_CPINT0                      INT_CPINT0
92835 -#define IRQ_CPINT1                      INT_CPINT1
92836 -#define IRQ_LBUSTIMEOUT                 INT_LBUSTIMEOUT
92837 -#define IRQ_APCINT                      INT_APCINT
92838 -
92839 -#define IRQMASK_SOFTINT                 INTMASK_SOFTINT
92840 -#define IRQMASK_UARTINT0                INTMASK_UARTINT0
92841 -#define IRQMASK_UARTINT1                INTMASK_UARTINT1
92842 -#define IRQMASK_KMIINT0                 INTMASK_KMIINT0
92843 -#define IRQMASK_KMIINT1                 INTMASK_KMIINT1
92844 -#define IRQMASK_TIMERINT0               INTMASK_TIMERINT0
92845 -#define IRQMASK_TIMERINT1               INTMASK_TIMERINT1
92846 -#define IRQMASK_TIMERINT2               INTMASK_TIMERINT2
92847 -#define IRQMASK_RTCINT                  INTMASK_RTCINT
92848 -#define IRQMASK_EXPINT0                 INTMASK_EXPINT0
92849 -#define IRQMASK_EXPINT1                 INTMASK_EXPINT1
92850 -#define IRQMASK_EXPINT2                 INTMASK_EXPINT2
92851 -#define IRQMASK_EXPINT3                 INTMASK_EXPINT3
92852 -#define IRQMASK_PCIINT0                 INTMASK_PCIINT0
92853 -#define IRQMASK_PCIINT1                 INTMASK_PCIINT1
92854 -#define IRQMASK_PCIINT2                 INTMASK_PCIINT2
92855 -#define IRQMASK_PCIINT3                 INTMASK_PCIINT3
92856 -#define IRQMASK_V3INT                   INTMASK_V3INT
92857 -#define IRQMASK_CPINT0                  INTMASK_CPINT0
92858 -#define IRQMASK_CPINT1                  INTMASK_CPINT1
92859 -#define IRQMASK_LBUSTIMEOUT             INTMASK_LBUSTIMEOUT
92860 -#define IRQMASK_APCINT                  INTMASK_APCINT
92861 -
92862  /* 
92863 - *  FIQ interrupts definitions are the same the INT definitions.
92864 + *  Interrupt numbers
92865   */
92866 -#define FIQ_SOFTINT                     INT_SOFTINT
92867 -#define FIQ_UARTINT0                    INT_UARTINT0
92868 -#define FIQ_UARTINT1                    INT_UARTINT1
92869 -#define FIQ_KMIINT0                     INT_KMIINT0
92870 -#define FIQ_KMIINT1                     INT_KMIINT1
92871 -#define FIQ_TIMERINT0                   INT_TIMERINT0
92872 -#define FIQ_TIMERINT1                   INT_TIMERINT1
92873 -#define FIQ_TIMERINT2                   INT_TIMERINT2
92874 -#define FIQ_RTCINT                      INT_RTCINT
92875 -#define FIQ_EXPINT0                     INT_EXPINT0
92876 -#define FIQ_EXPINT1                     INT_EXPINT1
92877 -#define FIQ_EXPINT2                     INT_EXPINT2
92878 -#define FIQ_EXPINT3                     INT_EXPINT3
92879 -#define FIQ_PCIINT0                     INT_PCIINT0
92880 -#define FIQ_PCIINT1                     INT_PCIINT1
92881 -#define FIQ_PCIINT2                     INT_PCIINT2
92882 -#define FIQ_PCIINT3                     INT_PCIINT3
92883 -#define FIQ_V3INT                       INT_V3INT
92884 -#define FIQ_CPINT0                      INT_CPINT0
92885 -#define FIQ_CPINT1                      INT_CPINT1
92886 -#define FIQ_LBUSTIMEOUT                 INT_LBUSTIMEOUT
92887 -#define FIQ_APCINT                      INT_APCINT
92888 -
92889 -#define FIQMASK_SOFTINT                 INTMASK_SOFTINT
92890 -#define FIQMASK_UARTINT0                INTMASK_UARTINT0
92891 -#define FIQMASK_UARTINT1                INTMASK_UARTINT1
92892 -#define FIQMASK_KMIINT0                 INTMASK_KMIINT0
92893 -#define FIQMASK_KMIINT1                 INTMASK_KMIINT1
92894 -#define FIQMASK_TIMERINT0               INTMASK_TIMERINT0
92895 -#define FIQMASK_TIMERINT1               INTMASK_TIMERINT1
92896 -#define FIQMASK_TIMERINT2               INTMASK_TIMERINT2
92897 -#define FIQMASK_RTCINT                  INTMASK_RTCINT
92898 -#define FIQMASK_EXPINT0                 INTMASK_EXPINT0
92899 -#define FIQMASK_EXPINT1                 INTMASK_EXPINT1
92900 -#define FIQMASK_EXPINT2                 INTMASK_EXPINT2
92901 -#define FIQMASK_EXPINT3                 INTMASK_EXPINT3
92902 -#define FIQMASK_PCIINT0                 INTMASK_PCIINT0
92903 -#define FIQMASK_PCIINT1                 INTMASK_PCIINT1
92904 -#define FIQMASK_PCIINT2                 INTMASK_PCIINT2
92905 -#define FIQMASK_PCIINT3                 INTMASK_PCIINT3
92906 -#define FIQMASK_V3INT                   INTMASK_V3INT
92907 -#define FIQMASK_CPINT0                  INTMASK_CPINT0
92908 -#define FIQMASK_CPINT1                  INTMASK_CPINT1
92909 -#define FIQMASK_LBUSTIMEOUT             INTMASK_LBUSTIMEOUT
92910 -#define FIQMASK_APCINT                  INTMASK_APCINT
92911 -
92912 -/* 
92913 - *  Misc. interrupt definitions
92914 - */
92915 -#define IRQ_KEYBDINT                    INT_KMIINT0
92916 -#define IRQ_MOUSEINT                    INT_KMIINT1
92917 -
92918 -#define IRQMASK_KEYBDINT                INTMASK_KMIINT0
92919 -#define IRQMASK_MOUSEINT                INTMASK_KMIINT1
92920 +#define IRQ_PIC_START                  0
92921 +#define IRQ_SOFTINT                    0
92922 +#define IRQ_UARTINT0                   1
92923 +#define IRQ_UARTINT1                   2
92924 +#define IRQ_KMIINT0                    3
92925 +#define IRQ_KMIINT1                    4
92926 +#define IRQ_TIMERINT0                  5
92927 +#define IRQ_TIMERINT1                  6
92928 +#define IRQ_TIMERINT2                  7
92929 +#define IRQ_RTCINT                     8
92930 +#define IRQ_AP_EXPINT0                 9
92931 +#define IRQ_AP_EXPINT1                 10
92932 +#define IRQ_AP_EXPINT2                 11
92933 +#define IRQ_AP_EXPINT3                 12
92934 +#define IRQ_AP_PCIINT0                 13
92935 +#define IRQ_AP_PCIINT1                 14
92936 +#define IRQ_AP_PCIINT2                 15
92937 +#define IRQ_AP_PCIINT3                 16
92938 +#define IRQ_AP_V3INT                   17
92939 +#define IRQ_AP_CPINT0                  18
92940 +#define IRQ_AP_CPINT1                  19
92941 +#define IRQ_AP_LBUSTIMEOUT             20
92942 +#define IRQ_AP_APCINT                  21
92943 +#define IRQ_PIC_END                    31
92944 +
92945 +#define IRQ_CIC_START                  32
92946 +#define IRQ_CM_SOFTINT                 32
92947 +#define IRQ_CM_COMMRX                  33
92948 +#define IRQ_CM_COMMTX                  34
92949 +#define IRQ_CIC_END                    34
92950  
92951 -#define NR_IRQS                         (MAXIRQNUM + 1)
92952 +#define NR_IRQS                         47
92953  
92954 --- linux-2.6.0-test6/include/asm-arm/arch-integrator/platform.h        2003-06-14 12:18:22.000000000 -0700
92955 +++ 25/include/asm-arm/arch-integrator/platform.h       2003-10-05 00:33:24.000000000 -0700
92956 @@ -386,85 +386,6 @@
92957   * 
92958   */
92959  
92960 -/* 
92961 - *  As the interrupt bit definitions for FIQ/IRQ there is a common
92962 - *  set of definitions prefixed INT/INTMASK.  The FIQ/IRQ definitions
92963 - *  have been left to maintain backwards compatible.
92964 - * 
92965 - */
92966 -
92967 -/* 
92968 - *  Interrupt numbers
92969 - * 
92970 - */
92971 -#define INT_SOFTINT                     0
92972 -#define INT_UARTINT0                    1
92973 -#define INT_UARTINT1                    2
92974 -#define INT_KMIINT0                     3
92975 -#define INT_KMIINT1                     4
92976 -#define INT_TIMERINT0                   5
92977 -#define INT_TIMERINT1                   6
92978 -#define INT_TIMERINT2                   7
92979 -#define INT_RTCINT                      8
92980 -#define INT_EXPINT0                     9
92981 -#define INT_EXPINT1                     10
92982 -#define INT_EXPINT2                     11
92983 -#define INT_EXPINT3                     12
92984 -#define INT_PCIINT0                     13
92985 -#define INT_PCIINT1                     14
92986 -#define INT_PCIINT2                     15
92987 -#define INT_PCIINT3                     16
92988 -#define INT_V3INT                       17
92989 -#define INT_CPINT0                      18
92990 -#define INT_CPINT1                      19
92991 -#define INT_LBUSTIMEOUT                 20
92992 -#define INT_APCINT                      21
92993 -#define INT_CM_SOFTINT                  24
92994 -#define INT_CM_COMMRX                   25
92995 -#define INT_CM_COMMTX                   26
92996 -
92997 -/* 
92998 - *  Interrupt bit positions
92999 - * 
93000 - */
93001 -#define INTMASK_SOFTINT                 (1 << INT_SOFTINT)
93002 -#define INTMASK_UARTINT0                (1 << INT_UARTINT0)
93003 -#define INTMASK_UARTINT1                (1 << INT_UARTINT1)
93004 -#define INTMASK_KMIINT0                 (1 << INT_KMIINT0)
93005 -#define INTMASK_KMIINT1                 (1 << INT_KMIINT1)
93006 -#define INTMASK_TIMERINT0               (1 << INT_TIMERINT0)
93007 -#define INTMASK_TIMERINT1               (1 << INT_TIMERINT1)
93008 -#define INTMASK_TIMERINT2               (1 << INT_TIMERINT2)
93009 -#define INTMASK_RTCINT                  (1 << INT_RTCINT)
93010 -#define INTMASK_EXPINT0                 (1 << INT_EXPINT0)
93011 -#define INTMASK_EXPINT1                 (1 << INT_EXPINT1)
93012 -#define INTMASK_EXPINT2                 (1 << INT_EXPINT2)
93013 -#define INTMASK_EXPINT3                 (1 << INT_EXPINT3)
93014 -#define INTMASK_PCIINT0                 (1 << INT_PCIINT0)
93015 -#define INTMASK_PCIINT1                 (1 << INT_PCIINT1)
93016 -#define INTMASK_PCIINT2                 (1 << INT_PCIINT2)
93017 -#define INTMASK_PCIINT3                 (1 << INT_PCIINT3)
93018 -#define INTMASK_V3INT                   (1 << INT_V3INT)
93019 -#define INTMASK_CPINT0                  (1 << INT_CPINT0)
93020 -#define INTMASK_CPINT1                  (1 << INT_CPINT1)
93021 -#define INTMASK_LBUSTIMEOUT             (1 << INT_LBUSTIMEOUT)
93022 -#define INTMASK_APCINT                  (1 << INT_APCINT)
93023 -#define INTMASK_CM_SOFTINT              (1 << INT_CM_SOFTINT)
93024 -#define INTMASK_CM_COMMRX               (1 << INT_CM_COMMRX)
93025 -#define INTMASK_CM_COMMTX               (1 << INT_CM_COMMTX)
93026 -
93027 -/* 
93028 - *  INTEGRATOR_CM_INT0      - Interrupt number of first CM interrupt
93029 - *  INTEGRATOR_SC_VALID_INT - Mask of valid system controller interrupts
93030 - * 
93031 - */
93032 -#define INTEGRATOR_CM_INT0              INT_CM_SOFTINT
93033 -#define INTEGRATOR_SC_VALID_INT         0x003FFFFF
93034 -
93035 -#define MAXIRQNUM                       31
93036 -#define MAXFIQNUM                       31
93037 -#define MAXSWINUM                       31
93038
93039  /* ------------------------------------------------------------------------
93040   *  LED's - The header LED is not accessible via the uHAL API
93041   * ------------------------------------------------------------------------
93042 --- linux-2.6.0-test6/include/asm-arm/arch-integrator/time.h    2003-06-14 12:18:29.000000000 -0700
93043 +++ 25/include/asm-arm/arch-integrator/time.h   2003-10-05 00:33:24.000000000 -0700
93044 @@ -86,7 +86,7 @@ static unsigned long integrator_gettimeo
93045         /*
93046          * Interrupt pending?  If so, we've reloaded once already.
93047          */
93048 -       if (status & IRQMASK_TIMERINT1)
93049 +       if (status & (1 << IRQ_TIMERINT1))
93050                 ticks1 += TIMER_RELOAD;
93051  
93052         /*
93053 --- linux-2.6.0-test6/include/asm-arm/arch-integrator/vmalloc.h 2003-06-14 12:17:57.000000000 -0700
93054 +++ 25/include/asm-arm/arch-integrator/vmalloc.h        2003-10-05 00:33:24.000000000 -0700
93055 @@ -28,7 +28,6 @@
93056   */
93057  #define VMALLOC_OFFSET   (8*1024*1024)
93058  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
93059 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
93060  #define VMALLOC_END       (PAGE_OFFSET + 0x10000000)
93061  
93062  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
93063 --- linux-2.6.0-test6/include/asm-arm/arch-iop3xx/vmalloc.h     2003-06-14 12:18:25.000000000 -0700
93064 +++ 25/include/asm-arm/arch-iop3xx/vmalloc.h    2003-10-05 00:33:24.000000000 -0700
93065 @@ -12,7 +12,6 @@
93066   */
93067  #define VMALLOC_OFFSET   (8*1024*1024)
93068  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
93069 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
93070  #define VMALLOC_END       (0xe8000000)
93071  
93072  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
93073 --- linux-2.6.0-test6/include/asm-arm/arch-l7200/vmalloc.h      2003-06-14 12:17:59.000000000 -0700
93074 +++ 25/include/asm-arm/arch-l7200/vmalloc.h     2003-10-05 00:33:24.000000000 -0700
93075 @@ -12,7 +12,6 @@
93076   */
93077  #define VMALLOC_OFFSET   (8*1024*1024)
93078  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
93079 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
93080  #define VMALLOC_END       (PAGE_OFFSET + 0x10000000)
93081  
93082  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
93083 --- linux-2.6.0-test6/include/asm-arm/arch-nexuspci/vmalloc.h   2003-06-14 12:18:21.000000000 -0700
93084 +++ 25/include/asm-arm/arch-nexuspci/vmalloc.h  2003-10-05 00:33:24.000000000 -0700
93085 @@ -12,7 +12,6 @@
93086   */
93087  #define VMALLOC_OFFSET   (8*1024*1024)
93088  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
93089 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
93090  #define VMALLOC_END       (PAGE_OFFSET + 0x20000000)
93091  
93092  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
93093 --- linux-2.6.0-test6/include/asm-arm/arch-pxa/irqs.h   2003-09-27 18:57:46.000000000 -0700
93094 +++ 25/include/asm-arm/arch-pxa/irqs.h  2003-10-05 00:33:24.000000000 -0700
93095 @@ -13,7 +13,7 @@
93096  #include <linux/config.h>
93097  
93098  #define PXA_IRQ_SKIP   7       /* The first 7 IRQs are not yet used */
93099 -#define PXA_IRQ(x)             ((x) - PXA_IRQ_SKIP)
93100 +#define PXA_IRQ(x)     ((x) - PXA_IRQ_SKIP)
93101  
93102  #define IRQ_HWUART     PXA_IRQ(7)      /* HWUART Transmit/Receive/Error */
93103  #define        IRQ_GPIO0       PXA_IRQ(8)      /* GPIO0 Edge Detect */
93104 @@ -47,7 +47,7 @@
93105  
93106  #define IRQ_TO_GPIO_2_80(i)    \
93107                         ((i) - PXA_IRQ(32) + 2)
93108 -#define IRQ_TO_GPIO(i) ((i) - (((i) > IRQ_GPIO1) ? IRQ_GPIO(2) : IRQ_GPIO(0)))
93109 +#define IRQ_TO_GPIO(i) ((i) - (((i) > IRQ_GPIO1) ? IRQ_GPIO(2) - 2 : IRQ_GPIO(0)))
93110  
93111  /*
93112   * The next 16 interrupts are for board specific purposes.  Since
93113 @@ -131,8 +131,10 @@
93114  #define LUBBOCK_IRQ(x)         (IRQ_BOARD_START + (x))
93115  #define LUBBOCK_SD_IRQ         LUBBOCK_IRQ(0)
93116  #define LUBBOCK_SA1111_IRQ     LUBBOCK_IRQ(1)
93117 -#define LUBBOCK_USB_IRQ                LUBBOCK_IRQ(2)
93118 +#define LUBBOCK_USB_IRQ                LUBBOCK_IRQ(2)  /* usb connect */
93119  #define LUBBOCK_ETH_IRQ                LUBBOCK_IRQ(3)
93120  #define LUBBOCK_UCB1400_IRQ    LUBBOCK_IRQ(4)
93121  #define LUBBOCK_BB_IRQ         LUBBOCK_IRQ(5)
93122 +#define LUBBOCK_USB_DISC_IRQ   LUBBOCK_IRQ(6)  /* usb disconnect */
93123 +#define LUBBOCK_LAST_IRQ       LUBBOCK_IRQ(6)
93124  
93125 --- linux-2.6.0-test6/include/asm-arm/arch-pxa/lubbock.h        2003-06-14 12:17:59.000000000 -0700
93126 +++ 25/include/asm-arm/arch-pxa/lubbock.h       2003-10-05 00:33:24.000000000 -0700
93127 @@ -12,7 +12,8 @@
93128  
93129  #define LUBBOCK_FPGA_PHYS      PXA_CS2_PHYS
93130  #define LUBBOCK_FPGA_VIRT      (0xf0000000)    /* phys 0x08000000 */
93131 -#define LUBBOCK_ETH_BASE       (0xf1000000)    /* phys 0x0c000000 */
93132 +#define LUBBOCK_ETH_PHYS       PXA_CS3_PHYS
93133 +#define LUBBOCK_ETH_VIRT       (0xf1000000)
93134  
93135  #define LUB_P2V(x)             ((x) - LUBBOCK_FPGA_PHYS + LUBBOCK_FPGA_VIRT)
93136  #define LUB_V2P(x)             ((x) - LUBBOCK_FPGA_VIRT + LUBBOCK_FPGA_PHYS)
93137 --- linux-2.6.0-test6/include/asm-arm/arch-pxa/vmalloc.h        2003-06-14 12:18:21.000000000 -0700
93138 +++ 25/include/asm-arm/arch-pxa/vmalloc.h       2003-10-05 00:33:24.000000000 -0700
93139 @@ -19,7 +19,6 @@
93140   */
93141  #define VMALLOC_OFFSET   (8*1024*1024)
93142  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
93143 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
93144  #define VMALLOC_END       (0xe8000000)
93145  
93146  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
93147 --- linux-2.6.0-test6/include/asm-arm/arch-rpc/vmalloc.h        2003-06-14 12:18:25.000000000 -0700
93148 +++ 25/include/asm-arm/arch-rpc/vmalloc.h       2003-10-05 00:33:24.000000000 -0700
93149 @@ -18,7 +18,6 @@
93150   */
93151  #define VMALLOC_OFFSET   (8*1024*1024)
93152  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
93153 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
93154  #define VMALLOC_END       (PAGE_OFFSET + 0x1c000000)
93155  
93156  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
93157 --- linux-2.6.0-test6/include/asm-arm/arch-sa1100/memory.h      2003-06-14 12:17:56.000000000 -0700
93158 +++ 25/include/asm-arm/arch-sa1100/memory.h     2003-10-05 00:34:40.000000000 -0700
93159 @@ -74,8 +74,6 @@
93160   *     node 3:  0xd8000000 - 0xdfffffff
93161   */
93162  
93163 -#define NR_NODES       4
93164 -
93165  /*
93166   * Given a kernel address, find the home node of the underlying memory.
93167   */
93168 --- linux-2.6.0-test6/include/asm-arm/arch-sa1100/vmalloc.h     2003-06-14 12:18:51.000000000 -0700
93169 +++ 25/include/asm-arm/arch-sa1100/vmalloc.h    2003-10-05 00:33:24.000000000 -0700
93170 @@ -12,7 +12,6 @@
93171   */
93172  #define VMALLOC_OFFSET   (8*1024*1024)
93173  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
93174 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
93175  #define VMALLOC_END       (0xe8000000)
93176  
93177  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
93178 --- linux-2.6.0-test6/include/asm-arm/arch-shark/vmalloc.h      2003-06-14 12:17:59.000000000 -0700
93179 +++ 25/include/asm-arm/arch-shark/vmalloc.h     2003-10-05 00:33:24.000000000 -0700
93180 @@ -12,7 +12,6 @@
93181   */
93182  #define VMALLOC_OFFSET   (8*1024*1024)
93183  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
93184 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
93185  #define VMALLOC_END       (PAGE_OFFSET + 0x10000000)
93186  
93187  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
93188 --- linux-2.6.0-test6/include/asm-arm/arch-tbox/vmalloc.h       2003-06-14 12:17:56.000000000 -0700
93189 +++ 25/include/asm-arm/arch-tbox/vmalloc.h      2003-10-05 00:33:24.000000000 -0700
93190 @@ -12,7 +12,6 @@
93191   */
93192  #define VMALLOC_OFFSET   (8*1024*1024)
93193  #define VMALLOC_START    (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
93194 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
93195  #define VMALLOC_END       (PAGE_OFFSET + 0x10000000)
93196  
93197  #define MODULE_START   (PAGE_OFFSET - 16*1048576)
93198 --- linux-2.6.0-test6/include/asm-arm/cacheflush.h      2003-09-27 18:57:46.000000000 -0700
93199 +++ 25/include/asm-arm/cacheflush.h     2003-10-05 00:33:24.000000000 -0700
93200 @@ -207,6 +207,15 @@ extern void dmac_inv_range(unsigned long
93201  extern void dmac_clean_range(unsigned long, unsigned long);
93202  extern void dmac_flush_range(unsigned long, unsigned long);
93203  
93204 +#define flush_cache_vmap(start, end)           flush_cache_all()
93205 +#define flush_cache_vunmap(start, end)         flush_cache_all()
93206 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
93207 +do { memcpy(dst, src, len); \
93208 +     flush_icache_user_range(vma, page, vaddr, len); \
93209 +} while (0)
93210 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
93211 +       memcpy(dst, src, len)
93212 +
93213  #endif
93214  
93215  /*
93216 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
93217 +++ 25/include/asm-arm/mach/flash.h     2003-10-05 00:33:24.000000000 -0700
93218 @@ -0,0 +1,19 @@
93219 +/*
93220 + *  linux/include/asm-arm/mach/flash.h
93221 + *
93222 + *  Copyright (C) 2003 Russell King, All Rights Reserved.
93223 + */
93224 +#ifndef ASMARM_MACH_FLASH_H
93225 +#define ASMAMR_MACH_FLASH_H
93226 +
93227 +struct mtd_partition;
93228 +
93229 +struct flash_platform_data {
93230 +       const char      *map_name;
93231 +       int             width;
93232 +       int             (*init)(void);
93233 +       void            (*exit)(void);
93234 +       void            (*set_vpp)(int on);
93235 +};
93236 +
93237 +#endif
93238 --- linux-2.6.0-test6/include/asm-arm/memory.h  2003-09-08 13:58:59.000000000 -0700
93239 +++ 25/include/asm-arm/memory.h 2003-10-05 00:34:41.000000000 -0700
93240 @@ -84,24 +84,24 @@ static inline void *phys_to_virt(unsigne
93241  
93242  #define PHYS_TO_NID(addr)      (0)
93243  
93244 -#else
93245 +#else /* CONFIG_DISCONTIGMEM */
93246 +
93247  /*
93248   * This is more complex.  We have a set of mem_map arrays spread
93249   * around in memory.
93250   */
93251 +#include <linux/numa.h>
93252 +
93253  #define page_to_pfn(page)                                      \
93254         (( (page) - page_zone(page)->zone_mem_map)              \
93255           + page_zone(page)->zone_start_pfn)
93256 -
93257  #define pfn_to_page(pfn)                                       \
93258         (PFN_TO_MAPBASE(pfn) + LOCAL_MAP_NR((pfn) << PAGE_SHIFT))
93259 -
93260 -#define pfn_valid(pfn)         (PFN_TO_NID(pfn) < NR_NODES)
93261 +#define pfn_valid(pfn)         (PFN_TO_NID(pfn) < MAX_NUMNODES)
93262  
93263  #define virt_to_page(kaddr)                                    \
93264         (ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr))
93265 -
93266 -#define virt_addr_valid(kaddr) (KVADDR_TO_NID(kaddr) < NR_NODES)
93267 +#define virt_addr_valid(kaddr) (KVADDR_TO_NID(kaddr) < MAX_NUMNODES)
93268  
93269  /*
93270   * Common discontigmem stuff.
93271 @@ -109,7 +109,7 @@ static inline void *phys_to_virt(unsigne
93272   */
93273  #define PHYS_TO_NID(addr)      PFN_TO_NID((addr) >> PAGE_SHIFT)
93274  
93275 -#endif
93276 +#endif /* !CONFIG_DISCONTIGMEM */
93277  
93278  /*
93279   * For BIO.  "will die".  Kill me when bio_to_phys() and bvec_to_phys() die.
93280 --- linux-2.6.0-test6/include/asm-arm/numnodes.h        2003-06-14 12:18:07.000000000 -0700
93281 +++ 25/include/asm-arm/numnodes.h       2003-10-05 00:34:40.000000000 -0700
93282 @@ -10,8 +10,7 @@
93283  #ifndef __ASM_ARM_NUMNODES_H
93284  #define __ASM_ARM_NUMNODES_H
93285  
93286 -#include <asm/memory.h>
93287 -
93288 -#define MAX_NUMNODES   NR_NODES
93289 +/* Max 4 Nodes */
93290 +#define NODES_SHIFT    2
93291  
93292  #endif
93293 --- linux-2.6.0-test6/include/asm-arm/unistd.h  2003-09-08 13:58:59.000000000 -0700
93294 +++ 25/include/asm-arm/unistd.h 2003-10-05 00:33:24.000000000 -0700
93295 @@ -32,7 +32,7 @@
93296  #define __NR_write                     (__NR_SYSCALL_BASE+  4)
93297  #define __NR_open                      (__NR_SYSCALL_BASE+  5)
93298  #define __NR_close                     (__NR_SYSCALL_BASE+  6)
93299 -#define __NR_waitpid                   (__NR_SYSCALL_BASE+  7) /* removed */
93300 +                                       /* 7 was sys_waitpid */
93301  #define __NR_creat                     (__NR_SYSCALL_BASE+  8)
93302  #define __NR_link                      (__NR_SYSCALL_BASE+  9)
93303  #define __NR_unlink                    (__NR_SYSCALL_BASE+ 10)
93304 @@ -42,7 +42,7 @@
93305  #define __NR_mknod                     (__NR_SYSCALL_BASE+ 14)
93306  #define __NR_chmod                     (__NR_SYSCALL_BASE+ 15)
93307  #define __NR_lchown                    (__NR_SYSCALL_BASE+ 16)
93308 -#define __NR_break                     (__NR_SYSCALL_BASE+ 17) /* removed */
93309 +                                       /* 17 was sys_break */
93310                                         /* 18 was sys_stat */
93311  #define __NR_lseek                     (__NR_SYSCALL_BASE+ 19)
93312  #define __NR_getpid                    (__NR_SYSCALL_BASE+ 20)
93313 @@ -53,14 +53,14 @@
93314  #define __NR_stime                     (__NR_SYSCALL_BASE+ 25)
93315  #define __NR_ptrace                    (__NR_SYSCALL_BASE+ 26)
93316  #define __NR_alarm                     (__NR_SYSCALL_BASE+ 27)
93317 -
93318 +                                       /* 28 was sys_fstat */
93319  #define __NR_pause                     (__NR_SYSCALL_BASE+ 29)
93320  #define __NR_utime                     (__NR_SYSCALL_BASE+ 30)
93321 -#define __NR_stty                      (__NR_SYSCALL_BASE+ 31) /* removed */
93322 -#define __NR_gtty                      (__NR_SYSCALL_BASE+ 32) /* removed */
93323 +                                       /* 31 was sys_stty */
93324 +                                       /* 32 was sys_gtty */
93325  #define __NR_access                    (__NR_SYSCALL_BASE+ 33)
93326  #define __NR_nice                      (__NR_SYSCALL_BASE+ 34)
93327 -#define __NR_ftime                     (__NR_SYSCALL_BASE+ 35) /* removed */
93328 +                                       /* 35 was sys_ftime */
93329  #define __NR_sync                      (__NR_SYSCALL_BASE+ 36)
93330  #define __NR_kill                      (__NR_SYSCALL_BASE+ 37)
93331  #define __NR_rename                    (__NR_SYSCALL_BASE+ 38)
93332 @@ -69,21 +69,21 @@
93333  #define __NR_dup                       (__NR_SYSCALL_BASE+ 41)
93334  #define __NR_pipe                      (__NR_SYSCALL_BASE+ 42)
93335  #define __NR_times                     (__NR_SYSCALL_BASE+ 43)
93336 -#define __NR_prof                      (__NR_SYSCALL_BASE+ 44) /* removed */
93337 +                                       /* 44 was sys_prof */
93338  #define __NR_brk                       (__NR_SYSCALL_BASE+ 45)
93339  #define __NR_setgid                    (__NR_SYSCALL_BASE+ 46)
93340  #define __NR_getgid                    (__NR_SYSCALL_BASE+ 47)
93341 -#define __NR_signal                    (__NR_SYSCALL_BASE+ 48) /* removed */
93342 +                                       /* 48 was sys_signal */
93343  #define __NR_geteuid                   (__NR_SYSCALL_BASE+ 49)
93344  #define __NR_getegid                   (__NR_SYSCALL_BASE+ 50)
93345  #define __NR_acct                      (__NR_SYSCALL_BASE+ 51)
93346  #define __NR_umount2                   (__NR_SYSCALL_BASE+ 52)
93347 -#define __NR_lock                      (__NR_SYSCALL_BASE+ 53) /* removed */
93348 +                                       /* 53 was sys_lock */
93349  #define __NR_ioctl                     (__NR_SYSCALL_BASE+ 54)
93350  #define __NR_fcntl                     (__NR_SYSCALL_BASE+ 55)
93351 -#define __NR_mpx                       (__NR_SYSCALL_BASE+ 56) /* removed */
93352 +                                       /* 56 was sys_mpx */
93353  #define __NR_setpgid                   (__NR_SYSCALL_BASE+ 57)
93354 -#define __NR_ulimit                    (__NR_SYSCALL_BASE+ 58) /* removed */
93355 +                                       /* 58 was sys_ulimit */
93356                                         /* 59 was sys_olduname */
93357  #define __NR_umask                     (__NR_SYSCALL_BASE+ 60)
93358  #define __NR_chroot                    (__NR_SYSCALL_BASE+ 61)
93359 @@ -93,8 +93,8 @@
93360  #define __NR_getpgrp                   (__NR_SYSCALL_BASE+ 65)
93361  #define __NR_setsid                    (__NR_SYSCALL_BASE+ 66)
93362  #define __NR_sigaction                 (__NR_SYSCALL_BASE+ 67)
93363 -#define __NR_sgetmask                  (__NR_SYSCALL_BASE+ 68) /* removed */
93364 -#define __NR_ssetmask                  (__NR_SYSCALL_BASE+ 69) /* removed */
93365 +                                       /* 68 was sys_sgetmask */
93366 +                                       /* 69 was sys_ssetmask */
93367  #define __NR_setreuid                  (__NR_SYSCALL_BASE+ 70)
93368  #define __NR_setregid                  (__NR_SYSCALL_BASE+ 71)
93369  #define __NR_sigsuspend                        (__NR_SYSCALL_BASE+ 72)
93370 @@ -123,10 +123,10 @@
93371  #define __NR_fchown                    (__NR_SYSCALL_BASE+ 95)
93372  #define __NR_getpriority               (__NR_SYSCALL_BASE+ 96)
93373  #define __NR_setpriority               (__NR_SYSCALL_BASE+ 97)
93374 -#define __NR_profil                    (__NR_SYSCALL_BASE+ 98) /* removed */
93375 +                                       /* 98 was sys_profil */
93376  #define __NR_statfs                    (__NR_SYSCALL_BASE+ 99)
93377  #define __NR_fstatfs                   (__NR_SYSCALL_BASE+100)
93378 -#define __NR_ioperm                    (__NR_SYSCALL_BASE+101)
93379 +                                       /* 101 was sys_ioperm */
93380  #define __NR_socketcall                        (__NR_SYSCALL_BASE+102)
93381  #define __NR_syslog                    (__NR_SYSCALL_BASE+103)
93382  #define __NR_setitimer                 (__NR_SYSCALL_BASE+104)
93383 @@ -137,7 +137,7 @@
93384                                         /* 109 was sys_uname */
93385                                         /* 110 was sys_iopl */
93386  #define __NR_vhangup                   (__NR_SYSCALL_BASE+111)
93387 -#define __NR_idle                      (__NR_SYSCALL_BASE+112)
93388 +                                       /* 112 was sys_idle */
93389  #define __NR_syscall                   (__NR_SYSCALL_BASE+113) /* syscall to call a syscall! */
93390  #define __NR_wait4                     (__NR_SYSCALL_BASE+114)
93391  #define __NR_swapoff                   (__NR_SYSCALL_BASE+115)
93392 @@ -148,21 +148,21 @@
93393  #define __NR_clone                     (__NR_SYSCALL_BASE+120)
93394  #define __NR_setdomainname             (__NR_SYSCALL_BASE+121)
93395  #define __NR_uname                     (__NR_SYSCALL_BASE+122)
93396 -#define __NR_modify_ldt                        (__NR_SYSCALL_BASE+123)
93397 +                                       /* 123 was sys_modify_ldt */
93398  #define __NR_adjtimex                  (__NR_SYSCALL_BASE+124)
93399  #define __NR_mprotect                  (__NR_SYSCALL_BASE+125)
93400  #define __NR_sigprocmask               (__NR_SYSCALL_BASE+126)
93401 -#define __NR_create_module             (__NR_SYSCALL_BASE+127) /* removed */
93402 +                                       /* 127 was sys_create_module */
93403  #define __NR_init_module               (__NR_SYSCALL_BASE+128)
93404  #define __NR_delete_module             (__NR_SYSCALL_BASE+129)
93405 -#define __NR_get_kernel_syms           (__NR_SYSCALL_BASE+130) /* removed */
93406 +                                       /* 130 was sys_get_kernel_syms */
93407  #define __NR_quotactl                  (__NR_SYSCALL_BASE+131)
93408  #define __NR_getpgid                   (__NR_SYSCALL_BASE+132)
93409  #define __NR_fchdir                    (__NR_SYSCALL_BASE+133)
93410  #define __NR_bdflush                   (__NR_SYSCALL_BASE+134)
93411  #define __NR_sysfs                     (__NR_SYSCALL_BASE+135)
93412  #define __NR_personality               (__NR_SYSCALL_BASE+136)
93413 -#define __NR_afs_syscall               (__NR_SYSCALL_BASE+137) /* Syscall for Andrew File System */
93414 +                                       /* 137 was sys_afs_syscall */
93415  #define __NR_setfsuid                  (__NR_SYSCALL_BASE+138)
93416  #define __NR_setfsgid                  (__NR_SYSCALL_BASE+139)
93417  #define __NR__llseek                   (__NR_SYSCALL_BASE+140)
93418 @@ -191,8 +191,8 @@
93419  #define __NR_mremap                    (__NR_SYSCALL_BASE+163)
93420  #define __NR_setresuid                 (__NR_SYSCALL_BASE+164)
93421  #define __NR_getresuid                 (__NR_SYSCALL_BASE+165)
93422 -#define __NR_vm86                      (__NR_SYSCALL_BASE+166) /* removed */
93423 -#define __NR_query_module              (__NR_SYSCALL_BASE+167) /* removed */
93424 +                                       /* 166 was sys_vm86 */
93425 +                                       /* 167 was sys_query_module */
93426  #define __NR_poll                      (__NR_SYSCALL_BASE+168)
93427  #define __NR_nfsservctl                        (__NR_SYSCALL_BASE+169)
93428  #define __NR_setresgid                 (__NR_SYSCALL_BASE+170)
93429 --- linux-2.6.0-test6/include/asm-cris/arch-v10/pgtable.h       2003-07-10 18:50:32.000000000 -0700
93430 +++ 25/include/asm-cris/arch-v10/pgtable.h      2003-10-05 00:33:24.000000000 -0700
93431 @@ -7,11 +7,9 @@
93432  
93433  #ifdef CONFIG_CRIS_LOW_MAP
93434  #define VMALLOC_START     KSEG_7
93435 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
93436  #define VMALLOC_END       KSEG_8
93437  #else
93438  #define VMALLOC_START     KSEG_D
93439 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
93440  #define VMALLOC_END       KSEG_E
93441  #endif
93442  
93443 --- linux-2.6.0-test6/include/asm-cris/cacheflush.h     2003-07-10 18:50:32.000000000 -0700
93444 +++ 25/include/asm-cris/cacheflush.h    2003-10-05 00:33:24.000000000 -0700
93445 @@ -16,6 +16,13 @@
93446  #define flush_icache_range(start, end)         do { } while (0)
93447  #define flush_icache_page(vma,pg)              do { } while (0)
93448  #define flush_icache_user_range(vma,pg,adr,len)        do { } while (0)
93449 +#define flush_cache_vmap(start, end)           do { } while (0)
93450 +#define flush_cache_vunmap(start, end)         do { } while (0)
93451 +
93452 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
93453 +       memcpy(dst, src, len)
93454 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
93455 +       memcpy(dst, src, len)
93456  
93457  void global_flush_tlb(void); 
93458  int change_page_attr(struct page *page, int numpages, pgprot_t prot);
93459 --- linux-2.6.0-test6/include/asm-h8300/cacheflush.h    2003-06-14 12:18:07.000000000 -0700
93460 +++ 25/include/asm-h8300/cacheflush.h   2003-10-05 00:33:24.000000000 -0700
93461 @@ -11,7 +11,6 @@
93462   */
93463  
93464  #define flush_cache_all()
93465 -#define        flush_cache_all()
93466  #define        flush_cache_mm(mm)
93467  #define        flush_cache_range(vma,a,b)
93468  #define        flush_cache_page(vma,p)
93469 @@ -20,6 +19,8 @@
93470  #define        flush_icache()
93471  #define        flush_icache_page(vma,page)
93472  #define        flush_icache_range(start,len)
93473 +#define flush_cache_vmap(start, end)
93474 +#define flush_cache_vunmap(start, end)
93475  #define        cache_push_v(vaddr,len)
93476  #define        cache_push(paddr,len)
93477  #define        cache_clear(paddr,len)
93478 @@ -28,4 +29,9 @@
93479  
93480  #define        flush_icache_user_range(vma,page,addr,len)
93481  
93482 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
93483 +       memcpy(dst, src, len)
93484 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
93485 +       memcpy(dst, src, len)
93486 +
93487  #endif /* _ASM_H8300_CACHEFLUSH_H */
93488 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
93489 +++ 25/include/asm-i386/atomic_kmap.h   2003-10-05 00:36:48.000000000 -0700
93490 @@ -0,0 +1,95 @@
93491 +/*
93492 + * atomic_kmap.h: temporary virtual kernel memory mappings
93493 + *
93494 + * Copyright (C) 2003 Ingo Molnar <mingo@redhat.com>
93495 + */
93496 +
93497 +#ifndef _ASM_ATOMIC_KMAP_H
93498 +#define _ASM_ATOMIC_KMAP_H
93499 +
93500 +#ifdef __KERNEL__
93501 +
93502 +#include <linux/config.h>
93503 +#include <asm/tlbflush.h>
93504 +
93505 +#ifdef CONFIG_DEBUG_HIGHMEM
93506 +#define HIGHMEM_DEBUG 1
93507 +#else
93508 +#define HIGHMEM_DEBUG 0
93509 +#endif
93510 +
93511 +extern pte_t *kmap_pte;
93512 +#define kmap_prot PAGE_KERNEL
93513 +
93514 +#define PKMAP_BASE (0xff000000UL)
93515 +#define NR_SHARED_PMDS ((0xffffffff-PKMAP_BASE+1)/PMD_SIZE)
93516 +
93517 +static inline unsigned long __kmap_atomic_vaddr(enum km_type type)
93518 +{
93519 +       enum fixed_addresses idx;
93520 +
93521 +       idx = type + KM_TYPE_NR*smp_processor_id();
93522 +       return __fix_to_virt(FIX_KMAP_BEGIN + idx);
93523 +}
93524 +
93525 +static inline void *__kmap_atomic_noflush(struct page *page, enum km_type type)
93526 +{
93527 +       enum fixed_addresses idx;
93528 +       unsigned long vaddr;
93529 +
93530 +       idx = type + KM_TYPE_NR*smp_processor_id();
93531 +       vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
93532 +       /*
93533 +        * NOTE: entries that rely on some secondary TLB-flush
93534 +        * effect must not be global:
93535 +        */
93536 +       set_pte(kmap_pte-idx, mk_pte(page, PAGE_KERNEL));
93537 +
93538 +       return (void*) vaddr;
93539 +}
93540 +
93541 +static inline void *__kmap_atomic(struct page *page, enum km_type type)
93542 +{
93543 +       enum fixed_addresses idx;
93544 +       unsigned long vaddr;
93545 +
93546 +       idx = type + KM_TYPE_NR*smp_processor_id();
93547 +       vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
93548 +#if HIGHMEM_DEBUG
93549 +       BUG_ON(!pte_none(*(kmap_pte-idx)));
93550 +#else
93551 +       /*
93552 +        * Performance optimization - do not flush if the new
93553 +        * pte is the same as the old one:
93554 +        */
93555 +       if (pte_val(*(kmap_pte-idx)) == pte_val(mk_pte(page, kmap_prot)))
93556 +               return (void *) vaddr;
93557 +#endif
93558 +       set_pte(kmap_pte-idx, mk_pte(page, kmap_prot));
93559 +       __flush_tlb_one(vaddr);
93560 +
93561 +       return (void*) vaddr;
93562 +}
93563 +
93564 +static inline void __kunmap_atomic(void *kvaddr, enum km_type type)
93565 +{
93566 +#if HIGHMEM_DEBUG
93567 +       unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
93568 +       enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
93569 +
93570 +       BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN+idx));
93571 +       /*
93572 +        * force other mappings to Oops if they'll try to access
93573 +        * this pte without first remap it
93574 +        */
93575 +       pte_clear(kmap_pte-idx);
93576 +       __flush_tlb_one(vaddr);
93577 +#endif
93578 +}
93579 +
93580 +#define __kunmap_atomic_type(type) \
93581 +               __kunmap_atomic((void *)__kmap_atomic_vaddr(type), (type))
93582 +
93583 +#endif /* __KERNEL__ */
93584 +
93585 +#endif /* _ASM_ATOMIC_KMAP_H */
93586 --- linux-2.6.0-test6/include/asm-i386/bugs.h   2003-09-08 13:58:59.000000000 -0700
93587 +++ 25/include/asm-i386/bugs.h  2003-10-05 00:33:38.000000000 -0700
93588 @@ -1,11 +1,11 @@
93589  /*
93590   *  include/asm-i386/bugs.h
93591   *
93592 - *  Copyright (C) 1994  Linus Torvalds
93593 + *  Copyright (C) 1994 Linus Torvalds
93594   *
93595   *  Cyrix stuff, June 1998 by:
93596   *     - Rafael R. Reilova (moved everything from head.S),
93597 - *        <rreilova@ececs.uc.edu>
93598 + *       <rreilova@ececs.uc.edu>
93599   *     - Channing Corn (tests & fixes),
93600   *     - Andrew D. Balsa (code cleanup).
93601   *
93602 @@ -25,7 +25,20 @@
93603  #include <asm/processor.h>
93604  #include <asm/i387.h>
93605  #include <asm/msr.h>
93606 -
93607 +#ifdef CONFIG_KGDB
93608 +/*
93609 + * Provied the command line "gdb" initial break
93610 + */
93611 +int __init kgdb_initial_break(char * str)
93612 +{
93613 +       if (*str == '\0'){
93614 +               breakpoint();
93615 +               return 1;
93616 +       }
93617 +       return 0;
93618 +}
93619 +__setup("gdb",kgdb_initial_break);
93620 +#endif
93621  static int __init no_halt(char *s)
93622  {
93623         boot_cpu_data.hlt_works_ok = 0;
93624 @@ -140,7 +153,7 @@ static void __init check_popad(void)
93625           : "ecx", "edi" );
93626         /* If this fails, it means that any user program may lock the CPU hard. Too bad. */
93627         if (res != 12345678) printk( "Buggy.\n" );
93628 -                       else printk( "OK.\n" );
93629 +                       else printk( "OK.\n" );
93630  #endif
93631  }
93632  
93633 --- linux-2.6.0-test6/include/asm-i386/cacheflush.h     2003-07-10 18:50:32.000000000 -0700
93634 +++ 25/include/asm-i386/cacheflush.h    2003-10-05 00:33:24.000000000 -0700
93635 @@ -13,6 +13,13 @@
93636  #define flush_icache_range(start, end)         do { } while (0)
93637  #define flush_icache_page(vma,pg)              do { } while (0)
93638  #define flush_icache_user_range(vma,pg,adr,len)        do { } while (0)
93639 +#define flush_cache_vmap(start, end)           do { } while (0)
93640 +#define flush_cache_vunmap(start, end)         do { } while (0)
93641 +
93642 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
93643 +       memcpy(dst, src, len)
93644 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
93645 +       memcpy(dst, src, len)
93646  
93647  void global_flush_tlb(void); 
93648  int change_page_attr(struct page *page, int numpages, pgprot_t prot);
93649 --- linux-2.6.0-test6/include/asm-i386/checksum.h       2003-06-14 12:18:29.000000000 -0700
93650 +++ 25/include/asm-i386/checksum.h      2003-10-05 00:36:48.000000000 -0700
93651 @@ -25,7 +25,7 @@ asmlinkage unsigned int csum_partial(con
93652   * better 64-bit) boundary
93653   */
93654  
93655 -asmlinkage unsigned int csum_partial_copy_generic( const char *src, char *dst, int len, int sum,
93656 +asmlinkage unsigned int direct_csum_partial_copy_generic( const char *src, char *dst, int len, int sum,
93657                                                    int *src_err_ptr, int *dst_err_ptr);
93658  
93659  /*
93660 @@ -39,14 +39,19 @@ static __inline__
93661  unsigned int csum_partial_copy_nocheck ( const char *src, char *dst,
93662                                         int len, int sum)
93663  {
93664 -       return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL);
93665 +       /*
93666 +        * The direct function is OK for kernel-space => kernel-space copies:
93667 +        */
93668 +       return direct_csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL);
93669  }
93670  
93671  static __inline__
93672  unsigned int csum_partial_copy_from_user ( const char *src, char *dst,
93673                                                 int len, int sum, int *err_ptr)
93674  {
93675 -       return csum_partial_copy_generic ( src, dst, len, sum, err_ptr, NULL);
93676 +       if (copy_from_user(dst, src, len))
93677 +               *err_ptr = -EFAULT;
93678 +       return csum_partial(dst, len, sum);
93679  }
93680  
93681  /*
93682 @@ -171,11 +176,26 @@ static __inline__ unsigned short int csu
93683   *     Copy and checksum to user
93684   */
93685  #define HAVE_CSUM_COPY_USER
93686 -static __inline__ unsigned int csum_and_copy_to_user(const char *src, char *dst,
93687 +static __inline__ unsigned int direct_csum_and_copy_to_user(const char *src, char *dst,
93688                                     int len, int sum, int *err_ptr)
93689  {
93690         if (access_ok(VERIFY_WRITE, dst, len))
93691 -               return csum_partial_copy_generic(src, dst, len, sum, NULL, err_ptr);
93692 +               return direct_csum_partial_copy_generic(src, dst, len, sum, NULL, err_ptr);
93693 +
93694 +       if (len)
93695 +               *err_ptr = -EFAULT;
93696 +
93697 +       return -1; /* invalid checksum */
93698 +}
93699 +
93700 +static __inline__ unsigned int csum_and_copy_to_user(const char *src, char *dst,
93701 +                                   int len, int sum, int *err_ptr)
93702 +{
93703 +       if (access_ok(VERIFY_WRITE, dst, len)) {
93704 +               if (copy_to_user(dst, src, len))
93705 +                       *err_ptr = -EFAULT;
93706 +               return csum_partial(src, len, sum);
93707 +       }
93708  
93709         if (len)
93710                 *err_ptr = -EFAULT;
93711 --- linux-2.6.0-test6/include/asm-i386/desc.h   2003-06-14 12:17:55.000000000 -0700
93712 +++ 25/include/asm-i386/desc.h  2003-10-05 00:36:48.000000000 -0700
93713 @@ -21,6 +21,13 @@ struct Xgt_desc_struct {
93714  
93715  extern struct Xgt_desc_struct idt_descr, cpu_gdt_descr[NR_CPUS];
93716  
93717 +extern void trap_init_virtual_IDT(void);
93718 +extern void trap_init_virtual_GDT(void);
93719 +
93720 +asmlinkage int system_call(void);
93721 +asmlinkage void lcall7(void);
93722 +asmlinkage void lcall27(void);
93723 +
93724  #define load_TR_desc() __asm__ __volatile__("ltr %%ax"::"a" (GDT_ENTRY_TSS*8))
93725  #define load_LDT_desc() __asm__ __volatile__("lldt %%ax"::"a" (GDT_ENTRY_LDT*8))
93726  
93727 @@ -30,6 +37,7 @@ extern struct Xgt_desc_struct idt_descr,
93728   */
93729  extern struct desc_struct default_ldt[];
93730  extern void set_intr_gate(unsigned int irq, void * addr);
93731 +extern void set_trap_gate(unsigned int n, void *addr);
93732  
93733  #define _set_tssldt_desc(n,addr,limit,type) \
93734  __asm__ __volatile__ ("movw %w3,0(%2)\n\t" \
93735 @@ -90,31 +98,8 @@ static inline void load_TLS(struct threa
93736  #undef C
93737  }
93738  
93739 -static inline void clear_LDT(void)
93740 -{
93741 -       int cpu = get_cpu();
93742 -
93743 -       set_ldt_desc(cpu, &default_ldt[0], 5);
93744 -       load_LDT_desc();
93745 -       put_cpu();
93746 -}
93747 -
93748 -/*
93749 - * load one particular LDT into the current CPU
93750 - */
93751 -static inline void load_LDT_nolock(mm_context_t *pc, int cpu)
93752 -{
93753 -       void *segments = pc->ldt;
93754 -       int count = pc->size;
93755 -
93756 -       if (likely(!count)) {
93757 -               segments = &default_ldt[0];
93758 -               count = 5;
93759 -       }
93760 -               
93761 -       set_ldt_desc(cpu, segments, count);
93762 -       load_LDT_desc();
93763 -}
93764 +extern struct page *default_ldt_page;
93765 +extern void load_LDT_nolock(mm_context_t *pc, int cpu);
93766  
93767  static inline void load_LDT(mm_context_t *pc)
93768  {
93769 @@ -123,6 +108,6 @@ static inline void load_LDT(mm_context_t
93770         put_cpu();
93771  }
93772  
93773 -#endif /* !__ASSEMBLY__ */
93774  
93775 +#endif /* !__ASSEMBLY__ */
93776  #endif
93777 --- linux-2.6.0-test6/include/asm-i386/elf.h    2003-06-14 12:18:25.000000000 -0700
93778 +++ 25/include/asm-i386/elf.h   2003-10-05 00:33:24.000000000 -0700
93779 @@ -127,11 +127,6 @@ extern int dump_task_extended_fpu (struc
93780  #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
93781  #define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) dump_task_extended_fpu(tsk, elf_xfpregs)
93782  
93783 -#ifdef CONFIG_SMP
93784 -extern void dump_smp_unlazy_fpu(void);
93785 -#define ELF_CORE_SYNC dump_smp_unlazy_fpu
93786 -#endif
93787 -
93788  #define VSYSCALL_BASE  (__fix_to_virt(FIX_VSYSCALL))
93789  #define VSYSCALL_EHDR  ((const struct elfhdr *) VSYSCALL_BASE)
93790  #define VSYSCALL_ENTRY ((unsigned long) &__kernel_vsyscall)
93791 @@ -162,7 +157,10 @@ do {                                                                             \
93792         for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) {                        \
93793                 struct elf_phdr phdr = vsyscall_phdrs[i];                     \
93794                 if (phdr.p_type == PT_LOAD) {                                 \
93795 +                       BUG_ON(ofs != 0);                                     \
93796                         ofs = phdr.p_offset = offset;                         \
93797 +                       phdr.p_memsz = PAGE_ALIGN(phdr.p_memsz);              \
93798 +                       phdr.p_filesz = phdr.p_memsz;                         \
93799                         offset += phdr.p_filesz;                              \
93800                 }                                                             \
93801                 else                                                          \
93802 @@ -180,7 +178,7 @@ do {                                                                              \
93803         for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) {                        \
93804                 if (vsyscall_phdrs[i].p_type == PT_LOAD)                      \
93805                         DUMP_WRITE((void *) vsyscall_phdrs[i].p_vaddr,        \
93806 -                                  vsyscall_phdrs[i].p_filesz);               \
93807 +                                  PAGE_ALIGN(vsyscall_phdrs[i].p_memsz));    \
93808         }                                                                     \
93809  } while (0)
93810  
93811 --- linux-2.6.0-test6/include/asm-i386/fixmap.h 2003-06-14 12:17:57.000000000 -0700
93812 +++ 25/include/asm-i386/fixmap.h        2003-10-05 00:36:48.000000000 -0700
93813 @@ -18,17 +18,15 @@
93814  #include <asm/acpi.h>
93815  #include <asm/apicdef.h>
93816  #include <asm/page.h>
93817 -#ifdef CONFIG_HIGHMEM
93818  #include <linux/threads.h>
93819  #include <asm/kmap_types.h>
93820 -#endif
93821  
93822  /*
93823   * Here we define all the compile-time 'special' virtual
93824   * addresses. The point is to have a constant address at
93825   * compile time, but to set the physical address only
93826 - * in the boot process. We allocate these special addresses
93827 - * from the end of virtual memory (0xfffff000) backwards.
93828 + * in the boot process. We allocate these special  addresses
93829 + * from the end of virtual memory (0xffffe000) backwards.
93830   * Also this lets us do fail-safe vmalloc(), we
93831   * can guarantee that these special addresses and
93832   * vmalloc()-ed addresses never overlap.
93833 @@ -41,11 +39,20 @@
93834   * TLB entries of such buffers will not be flushed across
93835   * task switches.
93836   */
93837 +
93838 +/*
93839 + * on UP currently we will have no trace of the fixmap mechanizm,
93840 + * no page table allocations, etc. This might change in the
93841 + * future, say framebuffers for the console driver(s) could be
93842 + * fix-mapped?
93843 + */
93844  enum fixed_addresses {
93845         FIX_HOLE,
93846         FIX_VSYSCALL,
93847  #ifdef CONFIG_X86_LOCAL_APIC
93848         FIX_APIC_BASE,  /* local (CPU) APIC) -- required for SMP or not */
93849 +#else
93850 +       FIX_VSTACK_HOLE_1,
93851  #endif
93852  #ifdef CONFIG_X86_IO_APIC
93853         FIX_IO_APIC_BASE_0,
93854 @@ -57,16 +64,21 @@ enum fixed_addresses {
93855         FIX_LI_PCIA,    /* Lithium PCI Bridge A */
93856         FIX_LI_PCIB,    /* Lithium PCI Bridge B */
93857  #endif
93858 -#ifdef CONFIG_X86_F00F_BUG
93859 -       FIX_F00F_IDT,   /* Virtual mapping for IDT */
93860 -#endif
93861 +       FIX_IDT,
93862 +       FIX_GDT_1,
93863 +       FIX_GDT_0,
93864 +       FIX_TSS_3,
93865 +       FIX_TSS_2,
93866 +       FIX_TSS_1,
93867 +       FIX_TSS_0,
93868 +       FIX_ENTRY_TRAMPOLINE_1,
93869 +       FIX_ENTRY_TRAMPOLINE_0,
93870  #ifdef CONFIG_X86_CYCLONE_TIMER
93871         FIX_CYCLONE_TIMER, /*cyclone timer register*/
93872 +       FIX_VSTACK_HOLE_2,
93873  #endif 
93874 -#ifdef CONFIG_HIGHMEM
93875         FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
93876         FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
93877 -#endif
93878  #ifdef CONFIG_ACPI_BOOT
93879         FIX_ACPI_BEGIN,
93880         FIX_ACPI_END = FIX_ACPI_BEGIN + FIX_ACPI_PAGES - 1,
93881 @@ -95,12 +107,15 @@ extern void __set_fixmap (enum fixed_add
93882                 __set_fixmap(idx, 0, __pgprot(0))
93883  
93884  /*
93885 - * used by vmalloc.c.
93886 + * used by vmalloc.c and various other places.
93887   *
93888   * Leave one empty page between vmalloc'ed areas and
93889   * the start of the fixmap.
93890 + *
93891 + * IMPORTANT: dont change FIXADDR_TOP without adjusting KM_VSTACK0
93892 + * and KM_VSTACK1 so that the virtual stack is 8K aligned.
93893   */
93894 -#define FIXADDR_TOP    (0xfffff000UL)
93895 +#define FIXADDR_TOP    (0xffffe000UL)
93896  #define __FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT)
93897  #define FIXADDR_START  (FIXADDR_TOP - __FIXADDR_SIZE)
93898  
93899 --- linux-2.6.0-test6/include/asm-i386/highmem.h        2003-08-22 19:23:42.000000000 -0700
93900 +++ 25/include/asm-i386/highmem.h       2003-10-05 00:36:48.000000000 -0700
93901 @@ -25,26 +25,19 @@
93902  #include <linux/threads.h>
93903  #include <asm/kmap_types.h>
93904  #include <asm/tlbflush.h>
93905 +#include <asm/atomic_kmap.h>
93906  
93907  /* declarations for highmem.c */
93908  extern unsigned long highstart_pfn, highend_pfn;
93909  
93910 -extern pte_t *kmap_pte;
93911 -extern pgprot_t kmap_prot;
93912  extern pte_t *pkmap_page_table;
93913 -
93914 -extern void kmap_init(void);
93915 +extern void kmap_init(void) __init;
93916  
93917  /*
93918   * Right now we initialize only a single pte table. It can be extended
93919   * easily, subsequent pte tables have to be allocated in one physical
93920   * chunk of RAM.
93921   */
93922 -#if NR_CPUS <= 32
93923 -#define PKMAP_BASE (0xff800000UL)
93924 -#else
93925 -#define PKMAP_BASE (0xff600000UL)
93926 -#endif
93927  #ifdef CONFIG_X86_PAE
93928  #define LAST_PKMAP 512
93929  #else
93930 @@ -63,6 +56,8 @@ void *kmap_atomic(struct page *page, enu
93931  void kunmap_atomic(void *kvaddr, enum km_type type);
93932  struct page *kmap_atomic_to_page(void *ptr);
93933  
93934 +#define flush_cache_kmaps()    do { } while (0)
93935 +
93936  #endif /* __KERNEL__ */
93937  
93938  #endif /* _ASM_HIGHMEM_H */
93939 --- linux-2.6.0-test6/include/asm-i386/hw_irq.h 2003-08-22 19:23:42.000000000 -0700
93940 +++ 25/include/asm-i386/hw_irq.h        2003-10-05 00:36:27.000000000 -0700
93941 @@ -25,8 +25,9 @@
93942   * Interrupt entry/exit code at both C and assembly level
93943   */
93944  
93945 -extern int irq_vector[NR_IRQS];
93946 -#define IO_APIC_VECTOR(irq)    irq_vector[irq]
93947 +extern u8 *irq_vector;
93948 +#define IO_APIC_VECTOR(irq)    ((int)irq_vector[(irq)])
93949 +extern int nr_irqs;
93950  
93951  extern void (*interrupt[NR_IRQS])(void);
93952  
93953 @@ -41,6 +42,7 @@ asmlinkage void apic_timer_interrupt(voi
93954  asmlinkage void error_interrupt(void);
93955  asmlinkage void spurious_interrupt(void);
93956  asmlinkage void thermal_interrupt(struct pt_regs);
93957 +#define platform_legacy_irq(irq)       ((irq) < 16)
93958  #endif
93959  
93960  void mask_irq(unsigned int irq);
93961 --- linux-2.6.0-test6/include/asm-i386/io_apic.h        2003-08-22 19:23:42.000000000 -0700
93962 +++ 25/include/asm-i386/io_apic.h       2003-10-05 00:36:21.000000000 -0700
93963 @@ -13,6 +13,46 @@
93964  
93965  #ifdef CONFIG_X86_IO_APIC
93966  
93967 +#ifdef CONFIG_PCI_USE_VECTOR
93968 +static inline int use_pci_vector(void) {return 1;}
93969 +static inline void disable_edge_ioapic_vector(unsigned int vector) { }
93970 +static inline void mask_and_ack_level_ioapic_vector(unsigned int vector) { }
93971 +static inline void end_edge_ioapic_vector (unsigned int vector) { }
93972 +#define startup_level_ioapic   startup_level_ioapic_vector
93973 +#define shutdown_level_ioapic  mask_IO_APIC_vector
93974 +#define enable_level_ioapic    unmask_IO_APIC_vector
93975 +#define disable_level_ioapic   mask_IO_APIC_vector
93976 +#define mask_and_ack_level_ioapic mask_and_ack_level_ioapic_vector
93977 +#define end_level_ioapic       end_level_ioapic_vector
93978 +#define set_ioapic_affinity    set_ioapic_affinity_vector
93979 +
93980 +#define startup_edge_ioapic    startup_edge_ioapic_vector
93981 +#define shutdown_edge_ioapic   disable_edge_ioapic_vector
93982 +#define enable_edge_ioapic     unmask_IO_APIC_vector
93983 +#define disable_edge_ioapic    disable_edge_ioapic_vector
93984 +#define ack_edge_ioapic        ack_edge_ioapic_vector
93985 +#define end_edge_ioapic        end_edge_ioapic_vector
93986 +#else
93987 +static inline int use_pci_vector(void) {return 0;}
93988 +static inline void disable_edge_ioapic_irq(unsigned int irq) { }
93989 +static inline void mask_and_ack_level_ioapic_irq(unsigned int irq) { }
93990 +static inline void end_edge_ioapic_irq (unsigned int irq) { }
93991 +#define startup_level_ioapic   startup_level_ioapic_irq
93992 +#define shutdown_level_ioapic  mask_IO_APIC_irq
93993 +#define enable_level_ioapic    unmask_IO_APIC_irq
93994 +#define disable_level_ioapic   mask_IO_APIC_irq
93995 +#define mask_and_ack_level_ioapic mask_and_ack_level_ioapic_irq
93996 +#define end_level_ioapic       end_level_ioapic_irq
93997 +#define set_ioapic_affinity    set_ioapic_affinity_irq
93998 +
93999 +#define startup_edge_ioapic    startup_edge_ioapic_irq
94000 +#define shutdown_edge_ioapic   disable_edge_ioapic_irq
94001 +#define enable_edge_ioapic     unmask_IO_APIC_irq
94002 +#define disable_edge_ioapic    disable_edge_ioapic_irq
94003 +#define ack_edge_ioapic        ack_edge_ioapic_irq
94004 +#define end_edge_ioapic        end_edge_ioapic_irq
94005 +#endif
94006 +
94007  #define APIC_MISMATCH_DEBUG
94008  
94009  #define IO_APIC_BASE(idx) \
94010 @@ -177,4 +217,6 @@ extern int io_apic_set_pci_routing (int 
94011  #define io_apic_assign_pci_irqs 0
94012  #endif
94013  
94014 +extern int assign_irq_vector(int irq);
94015 +
94016  #endif
94017 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
94018 +++ 25/include/asm-i386/kgdb.h  2003-10-05 00:33:50.000000000 -0700
94019 @@ -0,0 +1,76 @@
94020 +#ifndef __KGDB
94021 +#define __KGDB
94022 +
94023 +/*
94024 + * This file should not include ANY others.  This makes it usable
94025 + * most anywhere without the fear of include order or inclusion.
94026 + * Make it so!
94027 + *
94028 + * This file may be included all the time.  It is only active if
94029 + * CONFIG_KGDB is defined, otherwise it stubs out all the macros
94030 + * and entry points.
94031 + */
94032 +#if defined(CONFIG_KGDB) && !defined(__ASSEMBLY__)
94033 +
94034 +extern void breakpoint(void);
94035 +#define INIT_KGDB_INTS kgdb_enable_ints()
94036 +
94037 +#ifndef BREAKPOINT
94038 +#define BREAKPOINT   asm("   int $3")
94039 +#endif
94040 +
94041 +struct sk_buff;
94042 +
94043 +extern int kgdb_eth;
94044 +extern unsigned kgdb_remoteip;
94045 +extern unsigned short kgdb_listenport;
94046 +extern unsigned short kgdb_sendport;
94047 +extern unsigned char kgdb_remotemac[6];
94048 +extern unsigned char kgdb_localmac[6];
94049 +extern int kgdb_eth_need_breakpoint[];
94050 +
94051 +extern int kgdb_tty_hook(void);
94052 +extern int kgdb_eth_hook(void);
94053 +extern int gdb_net_interrupt(struct sk_buff *skb);
94054 +
94055 +/*
94056 + * GDB debug stub (or any debug stub) can point the 'linux_debug_hook'
94057 + * pointer to its routine and it will be entered as the first thing
94058 + * when a trap occurs.
94059 + *
94060 + * Return values are, at present, undefined.
94061 + *
94062 + * The debug hook routine does not necessarily return to its caller.
94063 + * It has the register image and thus may choose to resume execution
94064 + * anywhere it pleases.
94065 + */
94066 +struct pt_regs;
94067 +struct sk_buff;
94068 +
94069 +extern int kgdb_handle_exception(int trapno,
94070 +                                int signo, int err_code, struct pt_regs *regs);
94071 +extern int in_kgdb(struct pt_regs *regs);
94072 +extern int kgdb_net_interrupt(struct sk_buff *skb);
94073 +
94074 +#ifdef CONFIG_KGDB_TS
94075 +void kgdb_tstamp(int line, char *source, int data0, int data1);
94076 +/*
94077 + * This is the time stamp function.  The macro adds the source info and
94078 + * does a cast on the data to allow most any 32-bit value.
94079 + */
94080 +
94081 +#define kgdb_ts(data0,data1) kgdb_tstamp(__LINE__,__FILE__,(int)data0,(int)data1)
94082 +#else
94083 +#define kgdb_ts(data0,data1)
94084 +#endif
94085 +#else                          /* CONFIG_KGDB  && ! __ASSEMBLY__ ,stubs follow... */
94086 +#ifndef BREAKPOINT
94087 +#define BREAKPOINT
94088 +#endif
94089 +#define kgdb_ts(data0,data1)
94090 +#define in_kgdb
94091 +#define kgdb_handle_exception
94092 +#define breakpoint
94093 +#define INIT_KGDB_INTS
94094 +#endif
94095 +#endif                         /* __KGDB */
94096 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
94097 +++ 25/include/asm-i386/kgdb_local.h    2003-10-05 00:33:38.000000000 -0700
94098 @@ -0,0 +1,102 @@
94099 +#ifndef __KGDB_LOCAL
94100 +#define ___KGDB_LOCAL
94101 +#include <linux/config.h>
94102 +#include <linux/types.h>
94103 +#include <linux/serial.h>
94104 +#include <linux/serialP.h>
94105 +#include <linux/spinlock.h>
94106 +#include <asm/processor.h>
94107 +#include <asm/msr.h>
94108 +#include <asm/kgdb.h>
94109 +
94110 +#define PORT 0x3f8
94111 +#ifdef CONFIG_KGDB_PORT
94112 +#undef PORT
94113 +#define PORT CONFIG_KGDB_PORT
94114 +#endif
94115 +#define IRQ 4
94116 +#ifdef CONFIG_KGDB_IRQ
94117 +#undef IRQ
94118 +#define IRQ CONFIG_KGDB_IRQ
94119 +#endif
94120 +#define SB_CLOCK 1843200
94121 +#define SB_BASE (SB_CLOCK/16)
94122 +#define SB_BAUD9600 SB_BASE/9600
94123 +#define SB_BAUD192  SB_BASE/19200
94124 +#define SB_BAUD384  SB_BASE/38400
94125 +#define SB_BAUD576  SB_BASE/57600
94126 +#define SB_BAUD1152 SB_BASE/115200
94127 +#ifdef CONFIG_KGDB_9600BAUD
94128 +#define SB_BAUD SB_BAUD9600
94129 +#endif
94130 +#ifdef CONFIG_KGDB_19200BAUD
94131 +#define SB_BAUD SB_BAUD192
94132 +#endif
94133 +#ifdef CONFIG_KGDB_38400BAUD
94134 +#define SB_BAUD SB_BAUD384
94135 +#endif
94136 +#ifdef CONFIG_KGDB_57600BAUD
94137 +#define SB_BAUD SB_BAUD576
94138 +#endif
94139 +#ifdef CONFIG_KGDB_115200BAUD
94140 +#define SB_BAUD SB_BAUD1152
94141 +#endif
94142 +#ifndef SB_BAUD
94143 +#define SB_BAUD SB_BAUD1152    /* Start with this if not given */
94144 +#endif
94145 +
94146 +#ifndef CONFIG_X86_TSC
94147 +#undef rdtsc
94148 +#define rdtsc(a,b) if (a++ > 10000){a = 0; b++;}
94149 +#undef rdtscll
94150 +#define rdtscll(s) s++
94151 +#endif
94152 +
94153 +#ifdef _raw_read_unlock                /* must use a name that is "define"ed, not an inline */
94154 +#undef spin_lock
94155 +#undef spin_trylock
94156 +#undef spin_unlock
94157 +#define spin_lock       _raw_spin_lock
94158 +#define spin_trylock    _raw_spin_trylock
94159 +#define spin_unlock     _raw_spin_unlock
94160 +#else
94161 +#endif
94162 +#undef spin_unlock_wait
94163 +#define spin_unlock_wait(x)  do { cpu_relax(); barrier();} \
94164 +                                     while(spin_is_locked(x))
94165 +
94166 +#define SB_IER 1
94167 +#define SB_MCR UART_MCR_OUT2 | UART_MCR_DTR | UART_MCR_RTS
94168 +
94169 +#define FLAGS 0
94170 +#define SB_STATE { \
94171 +     magic: SSTATE_MAGIC, \
94172 +     baud_base: SB_BASE,  \
94173 +     port:      PORT,     \
94174 +     irq:       IRQ,      \
94175 +     flags:     FLAGS,    \
94176 +     custom_divisor:SB_BAUD}
94177 +#define SB_INFO  { \
94178 +      magic: SERIAL_MAGIC, \
94179 +      port:  PORT,0,FLAGS, \
94180 +      state: &state,       \
94181 +      tty:   (struct tty_struct *)&state, \
94182 +      IER:   SB_IER,       \
94183 +      MCR:   SB_MCR}
94184 +extern void putDebugChar(int);
94185 +/* RTAI support needs us to really stop/start interrupts */
94186 +
94187 +#define kgdb_sti() __asm__ __volatile__("sti": : :"memory")
94188 +#define kgdb_cli() __asm__ __volatile__("cli": : :"memory")
94189 +#define kgdb_local_save_flags(x) __asm__ __volatile__(\
94190 +                                   "pushfl ; popl %0":"=g" (x): /* no input */)
94191 +#define kgdb_local_irq_restore(x) __asm__ __volatile__(\
94192 +                                   "pushl %0 ; popfl": \
94193 +                                     /* no output */ :"g" (x):"memory", "cc")
94194 +#define kgdb_local_irq_save(x) kgdb_local_save_flags(x); kgdb_cli()
94195 +
94196 +#ifdef CONFIG_SERIAL
94197 +extern void shutdown_for_kgdb(struct async_struct *info);
94198 +#endif
94199 +#define INIT_KDEBUG putDebugChar("+");
94200 +#endif                         /* __KGDB_LOCAL */
94201 --- linux-2.6.0-test6/include/asm-i386/kmap_types.h     2003-06-14 12:18:28.000000000 -0700
94202 +++ 25/include/asm-i386/kmap_types.h    2003-10-05 00:36:48.000000000 -0700
94203 @@ -3,30 +3,36 @@
94204  
94205  #include <linux/config.h>
94206  
94207 -#ifdef CONFIG_DEBUG_HIGHMEM
94208 -# define D(n) __KM_FENCE_##n ,
94209 -#else
94210 -# define D(n)
94211 -#endif
94212 -
94213  enum km_type {
94214 -D(0)   KM_BOUNCE_READ,
94215 -D(1)   KM_SKB_SUNRPC_DATA,
94216 -D(2)   KM_SKB_DATA_SOFTIRQ,
94217 -D(3)   KM_USER0,
94218 -D(4)   KM_USER1,
94219 -D(5)   KM_BIO_SRC_IRQ,
94220 -D(6)   KM_BIO_DST_IRQ,
94221 -D(7)   KM_PTE0,
94222 -D(8)   KM_PTE1,
94223 -D(9)   KM_PTE2,
94224 -D(10)  KM_IRQ0,
94225 -D(11)  KM_IRQ1,
94226 -D(12)  KM_SOFTIRQ0,
94227 -D(13)  KM_SOFTIRQ1,
94228 -D(14)  KM_TYPE_NR
94229 -};
94230 -
94231 -#undef D
94232 +       /*
94233 +        * IMPORTANT: don't move these 3 entries, and only add entries in
94234 +        * pairs: the 4G/4G virtual stack must be 8K aligned on each cpu.
94235 +        */
94236 +       KM_BOUNCE_READ,
94237 +       KM_VSTACK1,
94238 +       KM_VSTACK0,
94239  
94240 +       KM_LDT_PAGE15,
94241 +       KM_LDT_PAGE0 = KM_LDT_PAGE15 + 16-1,
94242 +       KM_USER_COPY,
94243 +       KM_VSTACK_HOLE,
94244 +       KM_SKB_SUNRPC_DATA,
94245 +       KM_SKB_DATA_SOFTIRQ,
94246 +       KM_USER0,
94247 +       KM_USER1,
94248 +       KM_BIO_SRC_IRQ,
94249 +       KM_BIO_DST_IRQ,
94250 +       KM_PTE0,
94251 +       KM_PTE1,
94252 +       KM_PTE2,
94253 +       KM_IRQ0,
94254 +       KM_IRQ1,
94255 +       KM_SOFTIRQ0,
94256 +       KM_SOFTIRQ1,
94257 +       /*
94258 +        * Add new entries in pairs:
94259 +        * the 4G/4G virtual stack must be 8K aligned on each cpu.
94260 +        */
94261 +       KM_TYPE_NR
94262 +};
94263  #endif
94264 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
94265 +++ 25/include/asm-i386/lockmeter.h     2003-10-05 00:36:40.000000000 -0700
94266 @@ -0,0 +1,127 @@
94267 +/*
94268 + *  Copyright (C) 1999,2000 Silicon Graphics, Inc.
94269 + *
94270 + *  Written by John Hawkes (hawkes@sgi.com)
94271 + *  Based on klstat.h by Jack Steiner (steiner@sgi.com)
94272 + *
94273 + *  Modified by Ray Bryant (raybry@us.ibm.com)
94274 + *  Changes Copyright (C) 2000 IBM, Inc.
94275 + *  Added save of index in spinlock_t to improve efficiency
94276 + *  of "hold" time reporting for spinlocks.
94277 + *  Added support for hold time statistics for read and write
94278 + *  locks.
94279 + *  Moved machine dependent code here from include/lockmeter.h.
94280 + *
94281 + */
94282 +
94283 +#ifndef _I386_LOCKMETER_H
94284 +#define _I386_LOCKMETER_H
94285 +
94286 +#include <asm/spinlock.h>
94287 +#include <asm/rwlock.h>
94288 +
94289 +#include <linux/version.h>
94290 +
94291 +#ifdef __KERNEL__
94292 +extern unsigned long cpu_khz;
94293 +#define CPU_CYCLE_FREQUENCY    (cpu_khz * 1000)
94294 +#else
94295 +#define CPU_CYCLE_FREQUENCY    450000000
94296 +#endif
94297 +
94298 +#define THIS_CPU_NUMBER                smp_processor_id()
94299 +
94300 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
94301 +#define local_irq_save(x) \
94302 +    __asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (x): /* no input */ :"memory")
94303 +
94304 +#define local_irq_restore(x) \
94305 +    __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
94306 +#endif /* Linux version 2.2.x */
94307 +
94308 +/*
94309 + * macros to cache and retrieve an index value inside of a spin lock
94310 + * these macros assume that there are less than 65536 simultaneous
94311 + * (read mode) holders of a rwlock.  Not normally a problem!!
94312 + * we also assume that the hash table has less than 65535 entries.
94313 + */
94314 +/*
94315 + * instrumented spinlock structure -- never used to allocate storage
94316 + * only used in macros below to overlay a spinlock_t
94317 + */
94318 +typedef struct inst_spinlock_s {
94319 +       /* remember, Intel is little endian */
94320 +       unsigned short lock;
94321 +       unsigned short index;
94322 +} inst_spinlock_t;
94323 +#define PUT_INDEX(lock_ptr,indexv) ((inst_spinlock_t *)(lock_ptr))->index = indexv
94324 +#define GET_INDEX(lock_ptr)        ((inst_spinlock_t *)(lock_ptr))->index
94325 +
94326 +/*
94327 + * macros to cache and retrieve an index value in a read/write lock
94328 + * as well as the cpu where a reader busy period started
94329 + * we use the 2nd word (the debug word) for this, so require the
94330 + * debug word to be present
94331 + */
94332 +/*
94333 + * instrumented rwlock structure -- never used to allocate storage
94334 + * only used in macros below to overlay a rwlock_t
94335 + */
94336 +typedef struct inst_rwlock_s {
94337 +       volatile int lock;
94338 +       unsigned short index;
94339 +       unsigned short cpu;
94340 +} inst_rwlock_t;
94341 +#define PUT_RWINDEX(rwlock_ptr,indexv) ((inst_rwlock_t *)(rwlock_ptr))->index = indexv
94342 +#define GET_RWINDEX(rwlock_ptr)        ((inst_rwlock_t *)(rwlock_ptr))->index
94343 +#define PUT_RW_CPU(rwlock_ptr,cpuv)    ((inst_rwlock_t *)(rwlock_ptr))->cpu = cpuv
94344 +#define GET_RW_CPU(rwlock_ptr)         ((inst_rwlock_t *)(rwlock_ptr))->cpu
94345 +
94346 +/*
94347 + * return the number of readers for a rwlock_t
94348 + */
94349 +#define RWLOCK_READERS(rwlock_ptr)   rwlock_readers(rwlock_ptr)
94350 +
94351 +extern inline int rwlock_readers(rwlock_t *rwlock_ptr)
94352 +{
94353 +       int tmp = (int) rwlock_ptr->lock;
94354 +       /* read and write lock attempts may cause the lock value to temporarily */
94355 +       /* be negative.  Until it is >= 0 we know nothing (i. e. can't tell if  */
94356 +       /* is -1 because it was write locked and somebody tried to read lock it */
94357 +       /* or if it is -1 because it was read locked and somebody tried to write*/
94358 +       /* lock it. ........................................................... */
94359 +       do {
94360 +               tmp = (int) rwlock_ptr->lock;
94361 +       } while (tmp < 0);
94362 +       if (tmp == 0) return(0);
94363 +       else return(RW_LOCK_BIAS-tmp);
94364 +}
94365 +
94366 +/*
94367 + * return true if rwlock is write locked
94368 + * (note that other lock attempts can cause the lock value to be negative)
94369 + */
94370 +#define RWLOCK_IS_WRITE_LOCKED(rwlock_ptr) ((rwlock_ptr)->lock <= 0)
94371 +#define IABS(x) ((x) > 0 ? (x) : -(x))
94372 +#define RWLOCK_IS_READ_LOCKED(rwlock_ptr)  ((IABS((rwlock_ptr)->lock) % RW_LOCK_BIAS) != 0)
94373 +
94374 +/* this is a lot of typing just to get gcc to emit "rdtsc" */
94375 +static inline long long get_cycles64 (void)
94376 +{
94377 +#ifndef CONFIG_X86_TSC
94378 +       #error this code requires CONFIG_X86_TSC
94379 +#else
94380 +       union longlong_u {
94381 +               long long intlong;
94382 +               struct intint_s {
94383 +                       uint32_t eax;
94384 +                       uint32_t edx;
94385 +               } intint;
94386 +       } longlong;
94387 +
94388 +       rdtsc(longlong.intint.eax,longlong.intint.edx);
94389 +       return longlong.intlong;
94390 +#endif
94391 +}
94392 +
94393 +#endif /* _I386_LOCKMETER_H */
94394 --- linux-2.6.0-test6/include/asm-i386/mach-default/irq_vectors.h       2003-06-14 12:18:04.000000000 -0700
94395 +++ 25/include/asm-i386/mach-default/irq_vectors.h      2003-10-05 00:36:20.000000000 -0700
94396 @@ -76,11 +76,21 @@
94397   * Since vectors 0x00-0x1f are used/reserved for the CPU,
94398   * the usable vector space is 0x20-0xff (224 vectors)
94399   */
94400 +/*
94401 + * The maximum number of vectors supported by i386 processors
94402 + * is limited to 256. For processors other than i386, NR_VECTORS
94403 + * should be changed accordingly.
94404 + */
94405 +#define NR_VECTORS 256
94406 +#ifdef CONFIG_PCI_USE_VECTOR
94407 +#define NR_IRQS FIRST_SYSTEM_VECTOR
94408 +#else
94409  #ifdef CONFIG_X86_IO_APIC
94410  #define NR_IRQS 224
94411  #else
94412  #define NR_IRQS 16
94413  #endif
94414 +#endif
94415  
94416  #define FPU_IRQ                        13
94417  
94418 --- linux-2.6.0-test6/include/asm-i386/mman.h   2003-09-27 18:57:47.000000000 -0700
94419 +++ 25/include/asm-i386/mman.h  2003-10-05 00:33:24.000000000 -0700
94420 @@ -8,8 +8,6 @@
94421  #define PROT_NONE      0x0             /* page can not be accessed */
94422  #define PROT_GROWSDOWN 0x01000000      /* mprotect flag: extend change to start of growsdown vma */
94423  #define PROT_GROWSUP   0x02000000      /* mprotect flag: extend change to end of growsup vma */
94424 -#define PROT_GROWSDOWN 0x01000000      /* mprotect flag: extend change to start of growsdown vma */
94425 -#define PROT_GROWSUP   0x02000000      /* mprotect flag: extend change to end of growsup vma */
94426  
94427  #define MAP_SHARED     0x01            /* Share changes */
94428  #define MAP_PRIVATE    0x02            /* Changes are private */
94429 --- linux-2.6.0-test6/include/asm-i386/mmu_context.h    2003-08-22 19:23:42.000000000 -0700
94430 +++ 25/include/asm-i386/mmu_context.h   2003-10-05 00:36:48.000000000 -0700
94431 @@ -29,6 +29,10 @@ static inline void switch_mm(struct mm_s
94432  {
94433         int cpu = smp_processor_id();
94434  
94435 +#ifdef CONFIG_X86_SWITCH_PAGETABLES
94436 +       if (tsk->mm)
94437 +               tsk->thread_info->user_pgd = (void *)__pa(tsk->mm->pgd);
94438 +#endif
94439         if (likely(prev != next)) {
94440                 /* stop flush ipis for the previous mm */
94441                 cpu_clear(cpu, prev->cpu_vm_mask);
94442 @@ -39,12 +43,14 @@ static inline void switch_mm(struct mm_s
94443                 cpu_set(cpu, next->cpu_vm_mask);
94444  
94445                 /* Re-load page tables */
94446 +#if !defined(CONFIG_X86_SWITCH_PAGETABLES)
94447                 load_cr3(next->pgd);
94448 +#endif
94449  
94450                 /*
94451                  * load the LDT, if the LDT is different:
94452                  */
94453 -               if (unlikely(prev->context.ldt != next->context.ldt))
94454 +               if (unlikely(prev->context.size + next->context.size))
94455                         load_LDT_nolock(&next->context, cpu);
94456         }
94457  #ifdef CONFIG_SMP
94458 @@ -56,7 +62,9 @@ static inline void switch_mm(struct mm_s
94459                         /* We were in lazy tlb mode and leave_mm disabled 
94460                          * tlb flush IPI delivery. We must reload %cr3.
94461                          */
94462 +#if !defined(CONFIG_X86_SWITCH_PAGETABLES)
94463                         load_cr3(next->pgd);
94464 +#endif
94465                         load_LDT_nolock(&next->context, cpu);
94466                 }
94467         }
94468 @@ -67,6 +75,6 @@ static inline void switch_mm(struct mm_s
94469         asm("movl %0,%%fs ; movl %0,%%gs": :"r" (0))
94470  
94471  #define activate_mm(prev, next) \
94472 -       switch_mm((prev),(next),NULL)
94473 +       switch_mm((prev),(next),current)
94474  
94475  #endif
94476 --- linux-2.6.0-test6/include/asm-i386/mmu.h    2003-06-14 12:18:24.000000000 -0700
94477 +++ 25/include/asm-i386/mmu.h   2003-10-05 00:36:48.000000000 -0700
94478 @@ -8,10 +8,13 @@
94479   *
94480   * cpu_vm_mask is used to optimize ldt flushing.
94481   */
94482 +
94483 +#define MAX_LDT_PAGES 16
94484 +
94485  typedef struct { 
94486         int size;
94487         struct semaphore sem;
94488 -       void *ldt;
94489 +       struct page *ldt_pages[MAX_LDT_PAGES];
94490  } mm_context_t;
94491  
94492  #endif
94493 --- linux-2.6.0-test6/include/asm-i386/numaq.h  2003-09-27 18:57:47.000000000 -0700
94494 +++ 25/include/asm-i386/numaq.h 2003-10-05 00:34:38.000000000 -0700
94495 @@ -28,7 +28,6 @@
94496  
94497  #ifdef CONFIG_X86_NUMAQ
94498  
94499 -#define MAX_NUMNODES           16
94500  extern int get_memcfg_numaq(void);
94501  
94502  /*
94503 --- linux-2.6.0-test6/include/asm-i386/numnodes.h       2003-09-27 18:57:47.000000000 -0700
94504 +++ 25/include/asm-i386/numnodes.h      2003-10-05 00:34:38.000000000 -0700
94505 @@ -4,11 +4,15 @@
94506  #include <linux/config.h>
94507  
94508  #ifdef CONFIG_X86_NUMAQ
94509 -#include <asm/numaq.h>
94510 -#elif CONFIG_ACPI_SRAT
94511 -#include <asm/srat.h>
94512 -#else
94513 -#define MAX_NUMNODES   1
94514 +
94515 +/* Max 16 Nodes */
94516 +#define NODES_SHIFT    4
94517 +
94518 +#elif defined(CONFIG_ACPI_SRAT)
94519 +
94520 +/* Max 8 Nodes */
94521 +#define NODES_SHIFT    3
94522 +
94523  #endif /* CONFIG_X86_NUMAQ */
94524  
94525  #endif /* _ASM_MAX_NUMNODES_H */
94526 --- linux-2.6.0-test6/include/asm-i386/page.h   2003-06-26 22:07:25.000000000 -0700
94527 +++ 25/include/asm-i386/page.h  2003-10-05 00:36:48.000000000 -0700
94528 @@ -1,6 +1,8 @@
94529  #ifndef _I386_PAGE_H
94530  #define _I386_PAGE_H
94531  
94532 +#include <linux/config.h>
94533 +
94534  /* PAGE_SHIFT determines the page size */
94535  #define PAGE_SHIFT     12
94536  #define PAGE_SIZE      (1UL << PAGE_SHIFT)
94537 @@ -9,11 +11,10 @@
94538  #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
94539  #define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
94540  
94541 -#ifdef __KERNEL__
94542 -#ifndef __ASSEMBLY__
94543 -
94544  #include <linux/config.h>
94545  
94546 +#ifdef __KERNEL__
94547 +#ifndef __ASSEMBLY__
94548  #ifdef CONFIG_X86_USE_3DNOW
94549  
94550  #include <asm/mmx.h>
94551 @@ -88,8 +89,19 @@ typedef struct { unsigned long pgprot; }
94552   *
94553   * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
94554   * and CONFIG_HIGHMEM64G options in the kernel configuration.
94555 + *
94556 + * Note: on PAE the kernel must never go below 32 MB, we use the
94557 + * first 8 entries of the 2-level boot pgd for PAE magic.
94558   */
94559  
94560 +#ifdef CONFIG_X86_4G_VM_LAYOUT
94561 +#define __PAGE_OFFSET          (0x02000000)
94562 +#define TASK_SIZE              (0xff000000)
94563 +#else
94564 +#define __PAGE_OFFSET          (0xc0000000)
94565 +#define TASK_SIZE              (0xc0000000)
94566 +#endif
94567 +
94568  /*
94569   * This much address space is reserved for vmalloc() and iomap()
94570   * as well as fixmap mappings.
94571 @@ -114,16 +126,10 @@ static __inline__ int get_order(unsigned
94572  
94573  #endif /* __ASSEMBLY__ */
94574  
94575 -#ifdef __ASSEMBLY__
94576 -#define __PAGE_OFFSET          (0xC0000000)
94577 -#else
94578 -#define __PAGE_OFFSET          (0xC0000000UL)
94579 -#endif
94580 -
94581 -
94582  #define PAGE_OFFSET            ((unsigned long)__PAGE_OFFSET)
94583  #define VMALLOC_RESERVE                ((unsigned long)__VMALLOC_RESERVE)
94584 -#define MAXMEM                 (-__PAGE_OFFSET-__VMALLOC_RESERVE)
94585 +#define __MAXMEM               (-__PAGE_OFFSET-__VMALLOC_RESERVE)
94586 +#define MAXMEM                 ((unsigned long)(-PAGE_OFFSET-VMALLOC_RESERVE))
94587  #define __pa(x)                        ((unsigned long)(x)-PAGE_OFFSET)
94588  #define __va(x)                        ((void *)((unsigned long)(x)+PAGE_OFFSET))
94589  #define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
94590 --- linux-2.6.0-test6/include/asm-i386/pgtable.h        2003-08-08 22:55:13.000000000 -0700
94591 +++ 25/include/asm-i386/pgtable.h       2003-10-05 00:36:48.000000000 -0700
94592 @@ -32,16 +32,17 @@
94593  #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
94594  extern unsigned long empty_zero_page[1024];
94595  extern pgd_t swapper_pg_dir[1024];
94596 -extern kmem_cache_t *pgd_cache;
94597 -extern kmem_cache_t *pmd_cache;
94598 +extern kmem_cache_t *pgd_cache, *pmd_cache, *kpmd_cache;
94599  extern spinlock_t pgd_lock;
94600  extern struct list_head pgd_list;
94601  
94602  void pmd_ctor(void *, kmem_cache_t *, unsigned long);
94603 +void kpmd_ctor(void *, kmem_cache_t *, unsigned long);
94604  void pgd_ctor(void *, kmem_cache_t *, unsigned long);
94605  void pgd_dtor(void *, kmem_cache_t *, unsigned long);
94606  void pgtable_cache_init(void);
94607  void paging_init(void);
94608 +void setup_identity_mappings(pgd_t *pgd_base, unsigned long start, unsigned long end);
94609  
94610  #endif /* !__ASSEMBLY__ */
94611  
94612 @@ -51,6 +52,11 @@ void paging_init(void);
94613   * newer 3-level PAE-mode page tables.
94614   */
94615  #ifndef __ASSEMBLY__
94616 +
94617 +extern void set_system_gate(unsigned int n, void *addr);
94618 +extern void init_entry_mappings(void);
94619 +extern void entry_trampoline_setup(void);
94620 +
94621  #ifdef CONFIG_X86_PAE
94622  # include <asm/pgtable-3level.h>
94623  #else
94624 @@ -63,7 +69,12 @@ void paging_init(void);
94625  #define PGDIR_SIZE     (1UL << PGDIR_SHIFT)
94626  #define PGDIR_MASK     (~(PGDIR_SIZE-1))
94627  
94628 -#define USER_PTRS_PER_PGD      (TASK_SIZE/PGDIR_SIZE)
94629 +#if defined(CONFIG_X86_PAE) && defined(CONFIG_X86_4G_VM_LAYOUT)
94630 +# define USER_PTRS_PER_PGD     4
94631 +#else
94632 +# define USER_PTRS_PER_PGD     ((TASK_SIZE/PGDIR_SIZE) + ((TASK_SIZE % PGDIR_SIZE) + PGDIR_SIZE-1)/PGDIR_SIZE)
94633 +#endif
94634 +
94635  #define FIRST_USER_PGD_NR      0
94636  
94637  #define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
94638 @@ -85,7 +96,6 @@ void paging_init(void);
94639  #define VMALLOC_OFFSET (8*1024*1024)
94640  #define VMALLOC_START  (((unsigned long) high_memory + 2*VMALLOC_OFFSET-1) & \
94641                                                 ~(VMALLOC_OFFSET-1))
94642 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
94643  #ifdef CONFIG_HIGHMEM
94644  # define VMALLOC_END   (PKMAP_BASE-2*PAGE_SIZE)
94645  #else
94646 @@ -234,6 +244,7 @@ static inline void ptep_mkdirty(pte_t *p
94647  
94648  #define mk_pte(page, pgprot)   pfn_pte(page_to_pfn(page), (pgprot))
94649  #define mk_pte_huge(entry) ((entry).pte_low |= _PAGE_PRESENT | _PAGE_PSE)
94650 +#define mk_pte_phys(physpage, pgprot) pfn_pte((physpage) >> PAGE_SHIFT, pgprot)
94651  
94652  static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
94653  {
94654 --- linux-2.6.0-test6/include/asm-i386/processor.h      2003-09-27 18:57:47.000000000 -0700
94655 +++ 25/include/asm-i386/processor.h     2003-10-05 00:36:49.000000000 -0700
94656 @@ -291,11 +291,6 @@ extern unsigned int machine_submodel_id;
94657  extern unsigned int BIOS_revision;
94658  extern unsigned int mca_pentium_flag;
94659  
94660 -/*
94661 - * User space process size: 3GB (default).
94662 - */
94663 -#define TASK_SIZE      (PAGE_OFFSET)
94664 -
94665  /* This decides where the kernel will search for a free chunk of vm
94666   * space during mmap's.
94667   */
94668 @@ -406,6 +401,7 @@ struct tss_struct {
94669  struct thread_struct {
94670  /* cached TLS descriptors. */
94671         struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
94672 +       void *stack_page0, *stack_page1;
94673         unsigned long   esp0;
94674         unsigned long   eip;
94675         unsigned long   esp;
94676 @@ -491,6 +487,13 @@ extern void prepare_to_copy(struct task_
94677   */
94678  extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
94679  
94680 +#ifdef CONFIG_X86_HIGH_ENTRY
94681 +#define virtual_esp0(tsk) \
94682 +       ((unsigned long)(tsk)->thread_info->virtual_stack + ((tsk)->thread.esp0 - (unsigned long)(tsk)->thread_info->real_stack))
94683 +#else
94684 +# define virtual_esp0(tsk) ((tsk)->thread.esp0)
94685 +#endif
94686 +
94687  extern unsigned long thread_saved_pc(struct task_struct *tsk);
94688  void show_trace(struct task_struct *task, unsigned long *stack);
94689  
94690 @@ -585,12 +588,12 @@ static inline void rep_nop(void)
94691  
94692  /* Prefetch instructions for Pentium III and AMD Athlon */
94693  /* It's not worth to care about 3dnow! prefetches for the K6
94694 -   because they are microcoded there and very slow. */
94695 +   because they are microcoded there and very slow.
94696 +   However we don't do prefetches for pre XP Athlons currently
94697 +   That should be fixed. */
94698  #define ARCH_HAS_PREFETCH
94699  extern inline void prefetch(const void *x)
94700  {
94701 -       if (cpu_data[0].x86_vendor == X86_VENDOR_AMD)
94702 -               return;         /* Some athlons fault if the address is bad */
94703         alternative_input(ASM_NOP4,
94704                           "prefetchnta (%1)",
94705                           X86_FEATURE_XMM,
94706 --- linux-2.6.0-test6/include/asm-i386/rwlock.h 2003-06-26 22:07:25.000000000 -0700
94707 +++ 25/include/asm-i386/rwlock.h        2003-10-05 00:34:17.000000000 -0700
94708 @@ -20,28 +20,52 @@
94709  #define RW_LOCK_BIAS            0x01000000
94710  #define RW_LOCK_BIAS_STR       "0x01000000"
94711  
94712 -#define __build_read_lock_ptr(rw, helper)   \
94713 -       asm volatile(LOCK "subl $1,(%0)\n\t" \
94714 -                    "js 2f\n" \
94715 -                    "1:\n" \
94716 -                    LOCK_SECTION_START("") \
94717 -                    "2:\tcall " helper "\n\t" \
94718 -                    "jmp 1b\n" \
94719 -                    LOCK_SECTION_END \
94720 -                    ::"a" (rw) : "memory")
94721 -
94722 -#define __build_read_lock_const(rw, helper)   \
94723 -       asm volatile(LOCK "subl $1,%0\n\t" \
94724 -                    "js 2f\n" \
94725 -                    "1:\n" \
94726 -                    LOCK_SECTION_START("") \
94727 -                    "2:\tpushl %%eax\n\t" \
94728 -                    "leal %0,%%eax\n\t" \
94729 -                    "call " helper "\n\t" \
94730 -                    "popl %%eax\n\t" \
94731 -                    "jmp 1b\n" \
94732 -                    LOCK_SECTION_END \
94733 -                    :"=m" (*(volatile int *)rw) : : "memory")
94734 +#ifdef CONFIG_SPINLINE
94735 +
94736 +       #define __build_read_lock_ptr(rw, helper)   \
94737 +               asm volatile(LOCK "subl $1,(%0)\n\t" \
94738 +                            "jns 1f\n\t" \
94739 +                            "call " helper "\n\t" \
94740 +                            "1:\t" \
94741 +                            ::"a" (rw) : "memory")
94742 +
94743 +       #define __build_read_lock_const(rw, helper)   \
94744 +               asm volatile(LOCK "subl $1,%0\n\t" \
94745 +                            "jns 1f\n\t" \
94746 +                            "pushl %%eax\n\t" \
94747 +                            "leal %0,%%eax\n\t" \
94748 +                            "call " helper "\n\t" \
94749 +                            "popl %%eax\n\t" \
94750 +                            "1:\t" \
94751 +                            :"=m" (*(volatile int *)rw) : : "memory")
94752 +
94753 +#else /* !CONFIG_SPINLINE */
94754 +
94755 +       #define __build_read_lock_ptr(rw, helper)   \
94756 +               asm volatile(LOCK "subl $1,(%0)\n\t" \
94757 +                            "js 2f\n" \
94758 +                            "1:\n" \
94759 +                            LOCK_SECTION_START("") \
94760 +                            "2:\tcall " helper "\n\t" \
94761 +                            "jmp 1b\n" \
94762 +                            LOCK_SECTION_END \
94763 +                            ::"a" (rw) : "memory")
94764 +
94765 +       #define __build_read_lock_const(rw, helper)   \
94766 +               asm volatile(LOCK "subl $1,%0\n\t" \
94767 +                            "js 2f\n" \
94768 +                            "1:\n" \
94769 +                            LOCK_SECTION_START("") \
94770 +                            "2:\tpushl %%eax\n\t" \
94771 +                            "leal %0,%%eax\n\t" \
94772 +                            "call " helper "\n\t" \
94773 +                            "popl %%eax\n\t" \
94774 +                            "jmp 1b\n" \
94775 +                            LOCK_SECTION_END \
94776 +                            :"=m" (*(volatile int *)rw) : : "memory")
94777 +
94778 +#endif /* CONFIG_SPINLINE */
94779 +
94780  
94781  #define __build_read_lock(rw, helper)  do { \
94782                                                 if (__builtin_constant_p(rw)) \
94783 @@ -50,28 +74,51 @@
94784                                                         __build_read_lock_ptr(rw, helper); \
94785                                         } while (0)
94786  
94787 -#define __build_write_lock_ptr(rw, helper) \
94788 -       asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \
94789 -                    "jnz 2f\n" \
94790 -                    "1:\n" \
94791 -                    LOCK_SECTION_START("") \
94792 -                    "2:\tcall " helper "\n\t" \
94793 -                    "jmp 1b\n" \
94794 -                    LOCK_SECTION_END \
94795 -                    ::"a" (rw) : "memory")
94796 -
94797 -#define __build_write_lock_const(rw, helper) \
94798 -       asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",%0\n\t" \
94799 -                    "jnz 2f\n" \
94800 -                    "1:\n" \
94801 -                    LOCK_SECTION_START("") \
94802 -                    "2:\tpushl %%eax\n\t" \
94803 -                    "leal %0,%%eax\n\t" \
94804 -                    "call " helper "\n\t" \
94805 -                    "popl %%eax\n\t" \
94806 -                    "jmp 1b\n" \
94807 -                    LOCK_SECTION_END \
94808 -                    :"=m" (*(volatile int *)rw) : : "memory")
94809 +#ifdef CONFIG_SPINLINE
94810 +
94811 +       #define __build_write_lock_ptr(rw, helper) \
94812 +               asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \
94813 +                            "jz 1f\n\t" \
94814 +                            "call " helper "\n\t" \
94815 +                            "1:\n" \
94816 +                            ::"a" (rw) : "memory")
94817 +
94818 +       #define __build_write_lock_const(rw, helper) \
94819 +               asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",%0\n\t" \
94820 +                            "jz 1f\n\t" \
94821 +                            "pushl %%eax\n\t" \
94822 +                            "leal %0,%%eax\n\t" \
94823 +                            "call " helper "\n\t" \
94824 +                            "popl %%eax\n\t" \
94825 +                            "1:\n" \
94826 +                            :"=m" (*(volatile int *)rw) : : "memory")
94827 +
94828 +#else /* !CONFIG_SPINLINE */
94829 +
94830 +       #define __build_write_lock_ptr(rw, helper) \
94831 +               asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \
94832 +                            "jnz 2f\n" \
94833 +                            "1:\n" \
94834 +                            LOCK_SECTION_START("") \
94835 +                            "2:\tcall " helper "\n\t" \
94836 +                            "jmp 1b\n" \
94837 +                            LOCK_SECTION_END \
94838 +                            ::"a" (rw) : "memory")
94839 +
94840 +       #define __build_write_lock_const(rw, helper) \
94841 +               asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",%0\n\t" \
94842 +                            "jnz 2f\n" \
94843 +                            "1:\n" \
94844 +                            LOCK_SECTION_START("") \
94845 +                            "2:\tpushl %%eax\n\t" \
94846 +                            "leal %0,%%eax\n\t" \
94847 +                            "call " helper "\n\t" \
94848 +                            "popl %%eax\n\t" \
94849 +                            "jmp 1b\n" \
94850 +                            LOCK_SECTION_END \
94851 +                            :"=m" (*(volatile int *)rw) : : "memory")
94852 +
94853 +#endif /* CONFIG_SPINLINE */
94854  
94855  #define __build_write_lock(rw, helper) do { \
94856                                                 if (__builtin_constant_p(rw)) \
94857 --- linux-2.6.0-test6/include/asm-i386/setup.h  2003-09-27 18:57:47.000000000 -0700
94858 +++ 25/include/asm-i386/setup.h 2003-10-05 00:36:22.000000000 -0700
94859 @@ -29,6 +29,11 @@
94860  #define IST_INFO   (*(struct ist_info *) (PARAM+0x60))
94861  #define DRIVE_INFO (*(struct drive_info_struct *) (PARAM+0x80))
94862  #define SYS_DESC_TABLE (*(struct sys_desc_table_struct*)(PARAM+0xa0))
94863 +#define EFI_SYSTAB ((efi_system_table_t *) *((unsigned long *)(PARAM+0x1c4)))
94864 +#define EFI_MEMDESC_SIZE (*((unsigned long *) (PARAM+0x1c8)))
94865 +#define EFI_MEMDESC_VERSION (*((unsigned long *) (PARAM+0x1cc)))
94866 +#define EFI_MEMMAP ((efi_memory_desc_t *) *((unsigned long *)(PARAM+0x1d0)))
94867 +#define EFI_MEMMAP_SIZE (*((unsigned long *) (PARAM+0x1d4)))
94868  #define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAM+0x1F2))
94869  #define RAMDISK_FLAGS (*(unsigned short *) (PARAM+0x1F8))
94870  #define VIDEO_MODE (*(unsigned short *) (PARAM+0x1FA))
94871 --- linux-2.6.0-test6/include/asm-i386/spinlock.h       2003-06-26 22:07:25.000000000 -0700
94872 +++ 25/include/asm-i386/spinlock.h      2003-10-05 00:36:40.000000000 -0700
94873 @@ -43,18 +43,35 @@ typedef struct {
94874  #define spin_is_locked(x)      (*(volatile signed char *)(&(x)->lock) <= 0)
94875  #define spin_unlock_wait(x)    do { barrier(); } while(spin_is_locked(x))
94876  
94877 -#define spin_lock_string \
94878 -       "\n1:\t" \
94879 -       "lock ; decb %0\n\t" \
94880 -       "js 2f\n" \
94881 -       LOCK_SECTION_START("") \
94882 -       "2:\t" \
94883 -       "rep;nop\n\t" \
94884 -       "cmpb $0,%0\n\t" \
94885 -       "jle 2b\n\t" \
94886 -       "jmp 1b\n" \
94887 -       LOCK_SECTION_END
94888 +#ifdef CONFIG_SPINLINE
94889  
94890 +       #define spin_lock_string \
94891 +               "\n1:\t" \
94892 +               "lock ; decb %0\n\t" \
94893 +               "js 2f\n" \
94894 +               "jmp 3f\n" \
94895 +               "2:\t" \
94896 +               "rep;nop\n\t" \
94897 +               "cmpb $0,%0\n\t" \
94898 +               "jle 2b\n\t" \
94899 +               "jmp 1b\n" \
94900 +               "3:\t"
94901 +
94902 +#else /* !CONFIG_SPINLINE */
94903 +
94904 +       #define spin_lock_string \
94905 +               "\n1:\t" \
94906 +               "lock ; decb %0\n\t" \
94907 +               "js 2f\n" \
94908 +               LOCK_SECTION_START("") \
94909 +               "2:\t" \
94910 +               "rep;nop\n\t" \
94911 +               "cmpb $0,%0\n\t" \
94912 +               "jle 2b\n\t" \
94913 +               "jmp 1b\n" \
94914 +               LOCK_SECTION_END
94915 +
94916 +#endif /* CONFIG_SPINLINE */
94917  /*
94918   * This works. Despite all the confusion.
94919   * (except on PPro SMP or if we are using OOSTORE)
94920 @@ -138,6 +155,11 @@ here:
94921   */
94922  typedef struct {
94923         volatile unsigned int lock;
94924 +#ifdef CONFIG_LOCKMETER
94925 +       /* required for LOCKMETER since all bits in lock are used */
94926 +       /* and we need this storage for CPU and lock INDEX        */
94927 +       unsigned lockmeter_magic;
94928 +#endif
94929  #ifdef CONFIG_DEBUG_SPINLOCK
94930         unsigned magic;
94931  #endif
94932 @@ -145,11 +167,19 @@ typedef struct {
94933  
94934  #define RWLOCK_MAGIC   0xdeaf1eed
94935  
94936 +#ifdef CONFIG_LOCKMETER
94937 +#ifdef CONFIG_DEBUG_SPINLOCK
94938 +#define RWLOCK_MAGIC_INIT      , 0, RWLOCK_MAGIC
94939 +#else
94940 +#define RWLOCK_MAGIC_INIT      , 0
94941 +#endif
94942 +#else /* !CONFIG_LOCKMETER */
94943  #ifdef CONFIG_DEBUG_SPINLOCK
94944  #define RWLOCK_MAGIC_INIT      , RWLOCK_MAGIC
94945  #else
94946  #define RWLOCK_MAGIC_INIT      /* */
94947  #endif
94948 +#endif /* !CONFIG_LOCKMETER */
94949  
94950  #define RW_LOCK_UNLOCKED (rwlock_t) { RW_LOCK_BIAS RWLOCK_MAGIC_INIT }
94951  
94952 @@ -196,4 +226,58 @@ static inline int _raw_write_trylock(rwl
94953         return 0;
94954  }
94955  
94956 +#ifdef CONFIG_LOCKMETER
94957 +static inline int _raw_read_trylock(rwlock_t *lock)
94958 +{
94959 +/* FIXME -- replace with assembler */
94960 +       atomic_t *count = (atomic_t *)lock;
94961 +       atomic_dec(count);
94962 +       if (count->counter > 0)
94963 +               return 1;
94964 +       atomic_inc(count);
94965 +       return 0;
94966 +}
94967 +#endif
94968 +
94969 +#if defined(CONFIG_LOCKMETER) && defined(CONFIG_HAVE_DEC_LOCK)
94970 +extern void _metered_spin_lock  (spinlock_t *lock);
94971 +extern void _metered_spin_unlock(spinlock_t *lock);
94972 +
94973 +/*
94974 + *  Matches what is in arch/i386/lib/dec_and_lock.c, except this one is
94975 + *  "static inline" so that the spin_lock(), if actually invoked, is charged
94976 + *  against the real caller, not against the catch-all atomic_dec_and_lock
94977 + */
94978 +static inline int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
94979 +{
94980 +       int counter;
94981 +       int newcount;
94982 +
94983 +repeat:
94984 +       counter = atomic_read(atomic);
94985 +       newcount = counter-1;
94986 +
94987 +       if (!newcount)
94988 +               goto slow_path;
94989 +
94990 +       asm volatile("lock; cmpxchgl %1,%2"
94991 +               :"=a" (newcount)
94992 +               :"r" (newcount), "m" (atomic->counter), "0" (counter));
94993 +
94994 +       /* If the above failed, "eax" will have changed */
94995 +       if (newcount != counter)
94996 +               goto repeat;
94997 +       return 0;
94998 +
94999 +slow_path:
95000 +       _metered_spin_lock(lock);
95001 +       if (atomic_dec_and_test(atomic))
95002 +               return 1;
95003 +       _metered_spin_unlock(lock);
95004 +       return 0;
95005 +}
95006 +
95007 +#define ATOMIC_DEC_AND_LOCK
95008 +#endif
95009 +
95010  #endif /* __ASM_SPINLOCK_H */
95011 --- linux-2.6.0-test6/include/asm-i386/srat.h   2003-09-27 18:57:47.000000000 -0700
95012 +++ 25/include/asm-i386/srat.h  2003-10-05 00:34:38.000000000 -0700
95013 @@ -31,7 +31,6 @@
95014  #error CONFIG_ACPI_SRAT not defined, and srat.h header has been included
95015  #endif
95016  
95017 -#define MAX_NUMNODES           8
95018  extern int get_memcfg_from_srat(void);
95019  extern unsigned long *get_zholes_size(int);
95020  
95021 --- linux-2.6.0-test6/include/asm-i386/string.h 2003-06-14 12:18:51.000000000 -0700
95022 +++ 25/include/asm-i386/string.h        2003-10-05 00:36:48.000000000 -0700
95023 @@ -56,6 +56,29 @@ __asm__ __volatile__(
95024  return dest;
95025  }
95026  
95027 +/*
95028 + * This is a more generic variant of strncpy_count() suitable for
95029 + * implementing string-access routines with all sorts of return
95030 + * code semantics. It's used by mm/usercopy.c.
95031 + */
95032 +static inline size_t strncpy_count(char * dest,const char *src,size_t count)
95033 +{
95034 +       __asm__ __volatile__(
95035 +
95036 +       "1:\tdecl %0\n\t"
95037 +       "js 2f\n\t"
95038 +       "lodsb\n\t"
95039 +       "stosb\n\t"
95040 +       "testb %%al,%%al\n\t"
95041 +       "jne 1b\n\t"
95042 +       "2:"
95043 +       "incl %0"
95044 +       : "=c" (count)
95045 +       :"S" (src),"D" (dest),"0" (count) : "memory");
95046 +
95047 +       return count;
95048 +}
95049 +
95050  #define __HAVE_ARCH_STRCAT
95051  static inline char * strcat(char * dest,const char * src)
95052  {
95053 --- linux-2.6.0-test6/include/asm-i386/thread_info.h    2003-07-27 12:14:40.000000000 -0700
95054 +++ 25/include/asm-i386/thread_info.h   2003-10-05 00:36:48.000000000 -0700
95055 @@ -33,23 +33,12 @@ struct thread_info {
95056                                                    0-0xBFFFFFFF for user-thead
95057                                                    0-0xFFFFFFFF for kernel-thread
95058                                                 */
95059 -       struct restart_block    restart_block;
95060 +       void *real_stack, *virtual_stack, *user_pgd;
95061  
95062 +       struct restart_block    restart_block;
95063         __u8                    supervisor_stack[0];
95064  };
95065  
95066 -#else /* !__ASSEMBLY__ */
95067 -
95068 -/* offsets into the thread_info struct for assembly code access */
95069 -#define TI_TASK                0x00000000
95070 -#define TI_EXEC_DOMAIN 0x00000004
95071 -#define TI_FLAGS       0x00000008
95072 -#define TI_STATUS      0x0000000C
95073 -#define TI_CPU         0x00000010
95074 -#define TI_PRE_COUNT   0x00000014
95075 -#define TI_ADDR_LIMIT  0x00000018
95076 -#define TI_RESTART_BLOCK 0x000001C
95077 -
95078  #endif
95079  
95080  #define PREEMPT_ACTIVE         0x4000000
95081 @@ -61,7 +50,7 @@ struct thread_info {
95082   */
95083  #ifndef __ASSEMBLY__
95084  
95085 -#define INIT_THREAD_INFO(tsk)                  \
95086 +#define INIT_THREAD_INFO(tsk, thread_info)     \
95087  {                                              \
95088         .task           = &tsk,                 \
95089         .exec_domain    = &default_exec_domain, \
95090 @@ -72,6 +61,7 @@ struct thread_info {
95091         .restart_block = {                      \
95092                 .fn = do_no_restart_syscall,    \
95093         },                                      \
95094 +       .real_stack     = &thread_info,         \
95095  }
95096  
95097  #define init_thread_info       (init_thread_union.thread_info)
95098 @@ -113,6 +103,7 @@ static inline struct thread_info *curren
95099  #define TIF_NEED_RESCHED       3       /* rescheduling necessary */
95100  #define TIF_SINGLESTEP         4       /* restore singlestep on return to user mode */
95101  #define TIF_IRET               5       /* return with iret */
95102 +#define TIF_DB7                        6       /* has debug registers */
95103  #define TIF_POLLING_NRFLAG     16      /* true if poll_idle() is polling TIF_NEED_RESCHED */
95104  
95105  #define _TIF_SYSCALL_TRACE     (1<<TIF_SYSCALL_TRACE)
95106 @@ -121,6 +112,7 @@ static inline struct thread_info *curren
95107  #define _TIF_NEED_RESCHED      (1<<TIF_NEED_RESCHED)
95108  #define _TIF_SINGLESTEP                (1<<TIF_SINGLESTEP)
95109  #define _TIF_IRET              (1<<TIF_IRET)
95110 +#define _TIF_DB7               (1<<TIF_DB7)
95111  #define _TIF_POLLING_NRFLAG    (1<<TIF_POLLING_NRFLAG)
95112  
95113  #define _TIF_WORK_MASK         0x0000FFFE      /* work to do on interrupt/exception return */
95114 --- linux-2.6.0-test6/include/asm-i386/tlbflush.h       2003-06-14 12:18:35.000000000 -0700
95115 +++ 25/include/asm-i386/tlbflush.h      2003-10-05 00:36:48.000000000 -0700
95116 @@ -85,22 +85,28 @@ extern unsigned long pgkern_mask;
95117  
95118  static inline void flush_tlb_mm(struct mm_struct *mm)
95119  {
95120 +#ifndef CONFIG_X86_SWITCH_PAGETABLES
95121         if (mm == current->active_mm)
95122                 __flush_tlb();
95123 +#endif
95124  }
95125  
95126  static inline void flush_tlb_page(struct vm_area_struct *vma,
95127         unsigned long addr)
95128  {
95129 +#ifndef CONFIG_X86_SWITCH_PAGETABLES
95130         if (vma->vm_mm == current->active_mm)
95131                 __flush_tlb_one(addr);
95132 +#endif
95133  }
95134  
95135  static inline void flush_tlb_range(struct vm_area_struct *vma,
95136         unsigned long start, unsigned long end)
95137  {
95138 +#ifndef CONFIG_X86_SWITCH_PAGETABLES
95139         if (vma->vm_mm == current->active_mm)
95140                 __flush_tlb();
95141 +#endif
95142  }
95143  
95144  #else
95145 @@ -111,11 +117,10 @@ static inline void flush_tlb_range(struc
95146         __flush_tlb()
95147  
95148  extern void flush_tlb_all(void);
95149 -extern void flush_tlb_current_task(void);
95150  extern void flush_tlb_mm(struct mm_struct *);
95151  extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
95152  
95153 -#define flush_tlb()    flush_tlb_current_task()
95154 +#define flush_tlb()    flush_tlb_all()
95155  
95156  static inline void flush_tlb_range(struct vm_area_struct * vma, unsigned long start, unsigned long end)
95157  {
95158 --- linux-2.6.0-test6/include/asm-i386/uaccess.h        2003-09-27 18:57:47.000000000 -0700
95159 +++ 25/include/asm-i386/uaccess.h       2003-10-05 00:36:48.000000000 -0700
95160 @@ -26,7 +26,7 @@
95161  
95162  
95163  #define KERNEL_DS      MAKE_MM_SEG(0xFFFFFFFFUL)
95164 -#define USER_DS                MAKE_MM_SEG(PAGE_OFFSET)
95165 +#define USER_DS                MAKE_MM_SEG(TASK_SIZE)
95166  
95167  #define get_ds()       (KERNEL_DS)
95168  #define get_fs()       (current_thread_info()->addr_limit)
95169 @@ -149,6 +149,45 @@ extern void __get_user_4(void);
95170                 :"=a" (ret),"=d" (x) \
95171                 :"0" (ptr))
95172  
95173 +extern int get_user_size(unsigned int size, void *val, const void *ptr);
95174 +extern int put_user_size(unsigned int size, const void *val, void *ptr);
95175 +extern int zero_user_size(unsigned int size, void *ptr);
95176 +extern int copy_str_fromuser_size(unsigned int size, void *val, const void *ptr);
95177 +extern int strlen_fromuser_size(unsigned int size, const void *ptr);
95178 +
95179 +
95180 +# define indirect_get_user(x,ptr)                                      \
95181 +({     int __ret_gu,__val_gu;                                          \
95182 +       __typeof__(ptr) __ptr_gu = (ptr);                               \
95183 +       __ret_gu = get_user_size(sizeof(*__ptr_gu), &__val_gu,__ptr_gu) ? -EFAULT : 0;\
95184 +       (x) = (__typeof__(*__ptr_gu))__val_gu;                          \
95185 +       __ret_gu;                                                       \
95186 +})
95187 +#define indirect_put_user(x,ptr)                                       \
95188 +({                                                                     \
95189 +       __typeof__(*(ptr)) *__ptr_pu = (ptr), __x_pu = (x);             \
95190 +       put_user_size(sizeof(*__ptr_pu), &__x_pu, __ptr_pu) ? -EFAULT : 0; \
95191 +})
95192 +#define __indirect_put_user indirect_put_user
95193 +#define __indirect_get_user indirect_get_user
95194 +
95195 +#define indirect_copy_from_user(to,from,n) get_user_size(n,to,from)
95196 +#define indirect_copy_to_user(to,from,n) put_user_size(n,from,to)
95197 +
95198 +#define __indirect_copy_from_user indirect_copy_from_user
95199 +#define __indirect_copy_to_user indirect_copy_to_user
95200 +
95201 +#define indirect_strncpy_from_user(dst, src, count) \
95202 +               copy_str_fromuser_size(count, dst, src)
95203 +
95204 +extern int strlen_fromuser_size(unsigned int size, const void *ptr);
95205 +#define indirect_strnlen_user(str, n) strlen_fromuser_size(n, str)
95206 +#define indirect_strlen_user(str) indirect_strnlen_user(str, ~0UL >> 1)
95207 +
95208 +extern int zero_user_size(unsigned int size, void *ptr);
95209 +
95210 +#define indirect_clear_user(mem, len) zero_user_size(len, mem)
95211 +#define __indirect_clear_user clear_user
95212  
95213  /* Careful: we have to cast the result to the type of the pointer for sign reasons */
95214  /**
95215 @@ -168,7 +207,7 @@ extern void __get_user_4(void);
95216   * Returns zero on success, or -EFAULT on error.
95217   * On error, the variable @x is set to zero.
95218   */
95219 -#define get_user(x,ptr)                                                        \
95220 +#define direct_get_user(x,ptr)                                         \
95221  ({     int __ret_gu,__val_gu;                                          \
95222         switch(sizeof (*(ptr))) {                                       \
95223         case 1:  __get_user_x(1,__ret_gu,__val_gu,ptr); break;          \
95224 @@ -198,7 +237,7 @@ extern void __put_user_bad(void);
95225   *
95226   * Returns zero on success, or -EFAULT on error.
95227   */
95228 -#define put_user(x,ptr)                                                        \
95229 +#define direct_put_user(x,ptr)                                         \
95230    __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
95231  
95232  
95233 @@ -222,7 +261,7 @@ extern void __put_user_bad(void);
95234   * Returns zero on success, or -EFAULT on error.
95235   * On error, the variable @x is set to zero.
95236   */
95237 -#define __get_user(x,ptr) \
95238 +#define __direct_get_user(x,ptr) \
95239    __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
95240  
95241  
95242 @@ -245,7 +284,7 @@ extern void __put_user_bad(void);
95243   *
95244   * Returns zero on success, or -EFAULT on error.
95245   */
95246 -#define __put_user(x,ptr) \
95247 +#define __direct_put_user(x,ptr) \
95248    __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
95249  
95250  #define __put_user_nocheck(x,ptr,size)                         \
95251 @@ -396,7 +435,7 @@ unsigned long __copy_from_user_ll(void *
95252   * On success, this will be zero.
95253   */
95254  static inline unsigned long
95255 -__copy_to_user(void __user *to, const void *from, unsigned long n)
95256 +__direct_copy_to_user(void __user *to, const void *from, unsigned long n)
95257  {
95258         if (__builtin_constant_p(n)) {
95259                 unsigned long ret;
95260 @@ -434,7 +473,7 @@ __copy_to_user(void __user *to, const vo
95261   * data to the requested size using zero bytes.
95262   */
95263  static inline unsigned long
95264 -__copy_from_user(void *to, const void __user *from, unsigned long n)
95265 +__direct_copy_from_user(void *to, const void __user *from, unsigned long n)
95266  {
95267         if (__builtin_constant_p(n)) {
95268                 unsigned long ret;
95269 @@ -468,11 +507,11 @@ __copy_from_user(void *to, const void __
95270   * On success, this will be zero.
95271   */
95272  static inline unsigned long
95273 -copy_to_user(void __user *to, const void *from, unsigned long n)
95274 +direct_copy_to_user(void __user *to, const void *from, unsigned long n)
95275  {
95276         might_sleep();
95277         if (access_ok(VERIFY_WRITE, to, n))
95278 -               n = __copy_to_user(to, from, n);
95279 +               n = __direct_copy_to_user(to, from, n);
95280         return n;
95281  }
95282  
95283 @@ -493,11 +532,11 @@ copy_to_user(void __user *to, const void
95284   * data to the requested size using zero bytes.
95285   */
95286  static inline unsigned long
95287 -copy_from_user(void *to, const void __user *from, unsigned long n)
95288 +direct_copy_from_user(void *to, const void __user *from, unsigned long n)
95289  {
95290         might_sleep();
95291         if (access_ok(VERIFY_READ, from, n))
95292 -               n = __copy_from_user(to, from, n);
95293 +               n = __direct_copy_from_user(to, from, n);
95294         else
95295                 memset(to, 0, n);
95296         return n;
95297 @@ -520,10 +559,68 @@ long __strncpy_from_user(char *dst, cons
95298   * If there is a limit on the length of a valid string, you may wish to
95299   * consider using strnlen_user() instead.
95300   */
95301 -#define strlen_user(str) strnlen_user(str, ~0UL >> 1)
95302  
95303 -long strnlen_user(const char __user *str, long n);
95304 -unsigned long clear_user(void __user *mem, unsigned long len);
95305 -unsigned long __clear_user(void __user *mem, unsigned long len);
95306 +long direct_strncpy_from_user(char *dst, const char *src, long count);
95307 +long __direct_strncpy_from_user(char *dst, const char *src, long count);
95308 +#define direct_strlen_user(str) direct_strnlen_user(str, ~0UL >> 1)
95309 +long direct_strnlen_user(const char *str, long n);
95310 +unsigned long direct_clear_user(void *mem, unsigned long len);
95311 +unsigned long __direct_clear_user(void *mem, unsigned long len);
95312 +
95313 +extern int indirect_uaccess;
95314 +
95315 +#ifdef CONFIG_X86_UACCESS_INDIRECT
95316 +
95317 +/*
95318 + * Return code and zeroing semantics:
95319 +
95320 + __clear_user          0                      <-> bytes not done
95321 + clear_user            0                      <-> bytes not done
95322 + __copy_to_user        0                      <-> bytes not done
95323 + copy_to_user          0                      <-> bytes not done
95324 + __copy_from_user      0                      <-> bytes not done, zero rest
95325 + copy_from_user        0                      <-> bytes not done, zero rest
95326 + __get_user            0                      <-> -EFAULT
95327 + get_user              0                      <-> -EFAULT
95328 + __put_user            0                      <-> -EFAULT
95329 + put_user              0                      <-> -EFAULT
95330 + strlen_user           strlen + 1             <-> 0
95331 + strnlen_user          strlen + 1 (or n+1)    <-> 0
95332 + strncpy_from_user     strlen (or n)          <-> -EFAULT
95333 +
95334 + */
95335 +
95336 +#define __clear_user(mem,len) __indirect_clear_user(mem,len)
95337 +#define clear_user(mem,len) indirect_clear_user(mem,len)
95338 +#define __copy_to_user(to,from,n) __indirect_copy_to_user(to,from,n)
95339 +#define copy_to_user(to,from,n) indirect_copy_to_user(to,from,n)
95340 +#define __copy_from_user(to,from,n) __indirect_copy_from_user(to,from,n)
95341 +#define copy_from_user(to,from,n) indirect_copy_from_user(to,from,n)
95342 +#define __get_user(val,ptr) __indirect_get_user(val,ptr)
95343 +#define get_user(val,ptr) indirect_get_user(val,ptr)
95344 +#define __put_user(val,ptr) __indirect_put_user(val,ptr)
95345 +#define put_user(val,ptr) indirect_put_user(val,ptr)
95346 +#define strlen_user(str) indirect_strlen_user(str)
95347 +#define strnlen_user(src,count) indirect_strnlen_user(src,count)
95348 +#define strncpy_from_user(dst,src,count) \
95349 +                       indirect_strncpy_from_user(dst,src,count)
95350 +
95351 +#else
95352 +
95353 +#define __clear_user __direct_clear_user
95354 +#define clear_user direct_clear_user
95355 +#define __copy_to_user __direct_copy_to_user
95356 +#define copy_to_user direct_copy_to_user
95357 +#define __copy_from_user __direct_copy_from_user
95358 +#define copy_from_user direct_copy_from_user
95359 +#define __get_user __direct_get_user
95360 +#define get_user direct_get_user
95361 +#define __put_user __direct_put_user
95362 +#define put_user direct_put_user
95363 +#define strlen_user direct_strlen_user
95364 +#define strnlen_user direct_strnlen_user
95365 +#define strncpy_from_user direct_strncpy_from_user
95366 +
95367 +#endif /* CONFIG_X86_UACCESS_INDIRECT */
95368  
95369  #endif /* __i386_UACCESS_H */
95370 --- linux-2.6.0-test6/include/asm-i386/unistd.h 2003-08-22 19:23:42.000000000 -0700
95371 +++ 25/include/asm-i386/unistd.h        2003-10-05 00:33:24.000000000 -0700
95372 @@ -278,8 +278,9 @@
95373  #define __NR_tgkill            270
95374  #define __NR_utimes            271
95375  #define __NR_fadvise64_64      272
95376 +#define __NR_vserver           273
95377  
95378 -#define NR_syscalls 273
95379 +#define NR_syscalls 274
95380  
95381  /* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
95382  
95383 --- linux-2.6.0-test6/include/asm-ia64/acpi.h   2003-09-27 18:57:47.000000000 -0700
95384 +++ 25/include/asm-ia64/acpi.h  2003-10-05 00:34:41.000000000 -0700
95385 @@ -99,7 +99,7 @@ int acpi_get_addr_space (void *obj, u8 t
95386  /* Proximity bitmap length; _PXM is at most 255 (8 bit)*/
95387  #define MAX_PXM_DOMAINS (256)
95388  extern int __initdata pxm_to_nid_map[MAX_PXM_DOMAINS];
95389 -extern int __initdata nid_to_pxm_map[NR_NODES];
95390 +extern int __initdata nid_to_pxm_map[MAX_NUMNODES];
95391  #endif
95392  
95393  #endif /*__KERNEL__*/
95394 --- linux-2.6.0-test6/include/asm-ia64/cacheflush.h     2003-06-14 12:18:00.000000000 -0700
95395 +++ 25/include/asm-ia64/cacheflush.h    2003-10-05 00:33:24.000000000 -0700
95396 @@ -21,6 +21,8 @@
95397  #define flush_cache_range(vma, start, end)     do { } while (0)
95398  #define flush_cache_page(vma, vmaddr)          do { } while (0)
95399  #define flush_icache_page(vma,page)            do { } while (0)
95400 +#define flush_cache_vmap(start, end)           do { } while (0)
95401 +#define flush_cache_vunmap(start, end)         do { } while (0)
95402  
95403  #define flush_dcache_page(page)                        \
95404  do {                                           \
95405 @@ -35,4 +37,11 @@ do {                                                                                         \
95406         flush_icache_range(_addr, _addr + (len));                                               \
95407  } while (0)
95408  
95409 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
95410 +do { memcpy(dst, src, len); \
95411 +     flush_icache_user_range(vma, page, vaddr, len); \
95412 +} while (0)
95413 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
95414 +       memcpy(dst, src, len)
95415 +
95416  #endif /* _ASM_IA64_CACHEFLUSH_H */
95417 --- linux-2.6.0-test6/include/asm-ia64/elf.h    2003-07-27 12:14:40.000000000 -0700
95418 +++ 25/include/asm-ia64/elf.h   2003-10-05 00:33:24.000000000 -0700
95419 @@ -206,42 +206,46 @@ do {                                                                              \
95420         NEW_AUX_ENT(AT_SYSINFO_EHDR, (unsigned long) GATE_EHDR);                \
95421  } while (0)
95422  
95423 +
95424  /*
95425 - * These macros parameterize elf_core_dump in fs/binfmt_elf.c to write out extra segments
95426 - * containing the gate DSO contents.  Dumping its contents makes post-mortem fully
95427 - * interpretable later without matching up the same kernel and hardware config to see what
95428 - * IP values meant.  Dumping its extra ELF program headers includes all the other
95429 - * information a debugger needs to easily find how the gate DSO was being used.
95430 + * These macros parameterize elf_core_dump in fs/binfmt_elf.c to write out
95431 + * extra segments containing the gate DSO contents.  Dumping its
95432 + * contents makes post-mortem fully interpretable later without matching up
95433 + * the same kernel and hardware config to see what PC values meant.
95434 + * Dumping its extra ELF program headers includes all the other information
95435 + * a debugger needs to easily find how the gate DSO was being used.
95436   */
95437  #define ELF_CORE_EXTRA_PHDRS           (GATE_EHDR->e_phnum)
95438  #define ELF_CORE_WRITE_EXTRA_PHDRS                                             \
95439  do {                                                                           \
95440 -       const struct elf_phdr *const gate_phdrs =                               \
95441 -               (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff);     \
95442 +       const struct elf_phdr *const vsyscall_phdrs =                         \
95443 +               (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff);   \
95444         int i;                                                                  \
95445 -       Elf64_Off ofs = 0;                                                      \
95446 +       Elf32_Off ofs = 0;                                                    \
95447         for (i = 0; i < GATE_EHDR->e_phnum; ++i) {                              \
95448 -               struct elf_phdr phdr = gate_phdrs[i];                           \
95449 +               struct elf_phdr phdr = vsyscall_phdrs[i];                     \
95450                 if (phdr.p_type == PT_LOAD) {                                   \
95451 +                       BUG_ON(ofs != 0);                                     \
95452                         ofs = phdr.p_offset = offset;                           \
95453 +                       phdr.p_memsz = PAGE_ALIGN(phdr.p_memsz);              \
95454 +                       phdr.p_filesz = phdr.p_memsz;                         \
95455                         offset += phdr.p_filesz;                                \
95456 -               } else                                                          \
95457 +               }                                                             \
95458 +               else                                                          \
95459                         phdr.p_offset += ofs;                                   \
95460                 phdr.p_paddr = 0; /* match other core phdrs */                  \
95461                 DUMP_WRITE(&phdr, sizeof(phdr));                                \
95462         }                                                                       \
95463  } while (0)
95464 -
95465  #define ELF_CORE_WRITE_EXTRA_DATA                                      \
95466  do {                                                                   \
95467 -       const struct elf_phdr *const gate_phdrs =                       \
95468 -               (const struct elf_phdr *) (GATE_ADDR                    \
95469 -                                          + GATE_EHDR->e_phoff);       \
95470 +       const struct elf_phdr *const vsyscall_phdrs =                         \
95471 +               (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff);   \
95472         int i;                                                          \
95473         for (i = 0; i < GATE_EHDR->e_phnum; ++i) {                      \
95474 -               if (gate_phdrs[i].p_type == PT_LOAD)                    \
95475 -                       DUMP_WRITE((void *) gate_phdrs[i].p_vaddr,      \
95476 -                                  gate_phdrs[i].p_filesz);             \
95477 +               if (vsyscall_phdrs[i].p_type == PT_LOAD)                      \
95478 +                       DUMP_WRITE((void *) vsyscall_phdrs[i].p_vaddr,        \
95479 +                                  PAGE_ALIGN(vsyscall_phdrs[i].p_memsz));    \
95480         }                                                               \
95481  } while (0)
95482  
95483 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
95484 +++ 25/include/asm-ia64/lockmeter.h     2003-10-05 00:36:40.000000000 -0700
95485 @@ -0,0 +1,72 @@
95486 +/*
95487 + *  Copyright (C) 1999,2000 Silicon Graphics, Inc.
95488 + *
95489 + *  Written by John Hawkes (hawkes@sgi.com)
95490 + *  Based on klstat.h by Jack Steiner (steiner@sgi.com)
95491 + */
95492 +
95493 +#ifndef _IA64_LOCKMETER_H
95494 +#define _IA64_LOCKMETER_H
95495 +
95496 +#ifdef local_cpu_data
95497 +#define CPU_CYCLE_FREQUENCY    local_cpu_data->itc_freq
95498 +#else
95499 +#define CPU_CYCLE_FREQUENCY    my_cpu_data.itc_freq
95500 +#endif
95501 +#define get_cycles64()         get_cycles()
95502 +
95503 +#define THIS_CPU_NUMBER                smp_processor_id()
95504 +
95505 +/*
95506 + * macros to cache and retrieve an index value inside of a lock
95507 + * these macros assume that there are less than 65536 simultaneous
95508 + * (read mode) holders of a rwlock.
95509 + * we also assume that the hash table has less than 32767 entries.
95510 + */
95511 +/*
95512 + * instrumented spinlock structure -- never used to allocate storage
95513 + * only used in macros below to overlay a spinlock_t
95514 + */
95515 +typedef struct inst_spinlock_s {
95516 +       /* remember, Intel is little endian */
95517 +       volatile unsigned short lock;
95518 +       volatile unsigned short index;
95519 +} inst_spinlock_t;
95520 +#define PUT_INDEX(lock_ptr,indexv) ((inst_spinlock_t *)(lock_ptr))->index = indexv
95521 +#define GET_INDEX(lock_ptr)        ((inst_spinlock_t *)(lock_ptr))->index
95522 +
95523 +/*
95524 + * macros to cache and retrieve an index value in a read/write lock
95525 + * as well as the cpu where a reader busy period started
95526 + * we use the 2nd word (the debug word) for this, so require the
95527 + * debug word to be present
95528 + */
95529 +/*
95530 + * instrumented rwlock structure -- never used to allocate storage
95531 + * only used in macros below to overlay a rwlock_t
95532 + */
95533 +typedef struct inst_rwlock_s {
95534 +       volatile int read_counter:31;
95535 +       volatile int write_lock:1;
95536 +       volatile unsigned short index;
95537 +       volatile unsigned short cpu;
95538 +} inst_rwlock_t;
95539 +#define PUT_RWINDEX(rwlock_ptr,indexv) ((inst_rwlock_t *)(rwlock_ptr))->index = indexv
95540 +#define GET_RWINDEX(rwlock_ptr)        ((inst_rwlock_t *)(rwlock_ptr))->index
95541 +#define PUT_RW_CPU(rwlock_ptr,cpuv)    ((inst_rwlock_t *)(rwlock_ptr))->cpu = cpuv
95542 +#define GET_RW_CPU(rwlock_ptr)         ((inst_rwlock_t *)(rwlock_ptr))->cpu
95543 +
95544 +/*
95545 + * return the number of readers for a rwlock_t
95546 + */
95547 +#define RWLOCK_READERS(rwlock_ptr)     ((rwlock_ptr)->read_counter)
95548 +
95549 +/*
95550 + * return true if rwlock is write locked
95551 + * (note that other lock attempts can cause the lock value to be negative)
95552 + */
95553 +#define RWLOCK_IS_WRITE_LOCKED(rwlock_ptr) ((rwlock_ptr)->write_lock)
95554 +#define RWLOCK_IS_READ_LOCKED(rwlock_ptr)  ((rwlock_ptr)->read_counter)
95555 +
95556 +#endif /* _IA64_LOCKMETER_H */
95557 +
95558 --- linux-2.6.0-test6/include/asm-ia64/mmzone.h 2003-06-14 12:18:52.000000000 -0700
95559 +++ 25/include/asm-ia64/mmzone.h        2003-10-05 00:34:41.000000000 -0700
95560 @@ -92,14 +92,12 @@
95561  extern unsigned long max_low_pfn;
95562  
95563  
95564 -#ifdef CONFIG_IA64_DIG
95565 +#if defined(CONFIG_IA64_DIG)
95566  
95567  /*
95568   * Platform definitions for DIG platform with contiguous memory.
95569   */
95570 -#define MAX_PHYSNODE_ID        8       /* Maximum node number +1 */
95571 -#define NR_NODES       8       /* Maximum number of nodes in SSI */
95572 -
95573 +#define MAX_PHYSNODE_ID        8               /* Maximum node number +1 */
95574  #define MAX_PHYS_MEMORY        (1UL << 40)     /* 1 TB */
95575  
95576  /*
95577 @@ -119,37 +117,34 @@ extern unsigned long max_low_pfn;
95578  # error Unsupported bank and nodesize!
95579  #endif
95580  #define BANKSIZE               (1UL << BANKSHIFT)
95581 -#define BANK_OFFSET(addr)      ((unsigned long)(addr) & (BANKSIZE-1))
95582 -#define NR_BANKS               (NR_BANKS_PER_NODE * NR_NODES)
95583 -
95584 -/*
95585 - * VALID_MEM_KADDR returns a boolean to indicate if a kaddr is
95586 - * potentially a valid cacheable identity mapped RAM memory address.
95587 - * Note that the RAM may or may not actually be present!!
95588 - */
95589 -#define VALID_MEM_KADDR(kaddr) 1
95590 -
95591 -/*
95592 - * Given a nodeid & a bank number, find the address of the mem_map
95593 - * entry for the first page of the bank.
95594 - */
95595 -#define BANK_MEM_MAP_INDEX(kaddr) \
95596 -       (((unsigned long)(kaddr) & (MAX_PHYS_MEMORY-1)) >> BANKSHIFT)
95597  
95598  #elif defined(CONFIG_IA64_SGI_SN2)
95599 +
95600  /*
95601   * SGI SN2 discontig definitions
95602   */
95603  #define MAX_PHYSNODE_ID        2048    /* 2048 node ids (also called nasid) */
95604 -#define NR_NODES       128     /* Maximum number of nodes in SSI */
95605  #define MAX_PHYS_MEMORY        (1UL << 49)
95606  
95607 -#define BANKSHIFT              38
95608  #define NR_BANKS_PER_NODE      4
95609 +#define BANKSHIFT              38
95610  #define SN2_NODE_SIZE          (64UL*1024*1024*1024)   /* 64GB per node */
95611  #define BANKSIZE               (SN2_NODE_SIZE/NR_BANKS_PER_NODE)
95612 +
95613 +#endif /* CONFIG_IA64_DIG */
95614 +
95615 +#if defined(CONFIG_IA64_DIG) || defined (CONFIG_IA64_SGI_SN2)
95616 +/* Common defines for both platforms */
95617 +#include <asm/numnodes.h>
95618  #define BANK_OFFSET(addr)      ((unsigned long)(addr) & (BANKSIZE-1))
95619 -#define NR_BANKS               (NR_BANKS_PER_NODE * NR_NODES)
95620 +#define NR_BANKS               (NR_BANKS_PER_NODE * (1 << NODES_SHIFT))
95621 +#define NR_MEMBLKS             (NR_BANKS)
95622 +
95623 +/*
95624 + * VALID_MEM_KADDR returns a boolean to indicate if a kaddr is
95625 + * potentially a valid cacheable identity mapped RAM memory address.
95626 + * Note that the RAM may or may not actually be present!!
95627 + */
95628  #define VALID_MEM_KADDR(kaddr) 1
95629  
95630  /*
95631 @@ -159,5 +154,6 @@ extern unsigned long max_low_pfn;
95632  #define BANK_MEM_MAP_INDEX(kaddr) \
95633         (((unsigned long)(kaddr) & (MAX_PHYS_MEMORY-1)) >> BANKSHIFT)
95634  
95635 -#endif /* CONFIG_IA64_DIG */
95636 +#endif /* CONFIG_IA64_DIG || CONFIG_IA64_SGI_SN2 */
95637 +
95638  #endif /* _ASM_IA64_MMZONE_H */
95639 --- linux-2.6.0-test6/include/asm-ia64/nodedata.h       2003-06-22 12:04:45.000000000 -0700
95640 +++ 25/include/asm-ia64/nodedata.h      2003-10-05 00:34:41.000000000 -0700
95641 @@ -8,12 +8,10 @@
95642   * Copyright (c) 2002 Erich Focht <efocht@ess.nec.de>
95643   * Copyright (c) 2002 Kimio Suganuma <k-suganuma@da.jp.nec.com>
95644   */
95645 -
95646 -
95647  #ifndef _ASM_IA64_NODEDATA_H
95648  #define _ASM_IA64_NODEDATA_H
95649  
95650 -
95651 +#include <linux/numa.h>
95652  #include <asm/mmzone.h>
95653  
95654  /*
95655 @@ -24,9 +22,9 @@ struct pglist_data;
95656  struct ia64_node_data {
95657         short                   active_cpu_count;
95658         short                   node;
95659 -        struct pglist_data     *pg_data_ptrs[NR_NODES];
95660 +       struct pglist_data      *pg_data_ptrs[MAX_NUMNODES];
95661         struct page             *bank_mem_map_base[NR_BANKS];
95662 -       struct ia64_node_data   *node_data_ptrs[NR_NODES];
95663 +       struct ia64_node_data   *node_data_ptrs[MAX_NUMNODES];
95664         short                   node_id_map[NR_BANKS];
95665  };
95666  
95667 --- linux-2.6.0-test6/include/asm-ia64/numa.h   2003-09-27 18:57:47.000000000 -0700
95668 +++ 25/include/asm-ia64/numa.h  2003-10-05 00:34:41.000000000 -0700
95669 @@ -16,17 +16,11 @@
95670  
95671  #ifdef CONFIG_NUMA
95672  
95673 -#ifdef CONFIG_DISCONTIGMEM
95674 -# include <asm/mmzone.h>
95675 -# define NR_MEMBLKS   (NR_BANKS)
95676 -#else
95677 -# define NR_NODES     (8)
95678 -# define NR_MEMBLKS   (NR_NODES * 8)
95679 -#endif
95680 -
95681 +#include <linux/numa.h>
95682  #include <linux/cache.h>
95683 +
95684  extern volatile char cpu_to_node_map[NR_CPUS] __cacheline_aligned;
95685 -extern volatile cpumask_t node_to_cpu_mask[NR_NODES] __cacheline_aligned;
95686 +extern volatile cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned;
95687  
95688  /* Stuff below this line could be architecture independent */
95689  
95690 @@ -60,7 +54,7 @@ extern struct node_cpuid_s node_cpuid[NR
95691   * proportional to the memory access latency ratios.
95692   */
95693  
95694 -extern u8 numa_slit[NR_NODES * NR_NODES];
95695 +extern u8 numa_slit[MAX_NUMNODES * MAX_NUMNODES];
95696  #define node_distance(from,to) (numa_slit[from * numnodes + to])
95697  
95698  extern int paddr_to_nid(unsigned long paddr);
95699 --- linux-2.6.0-test6/include/asm-ia64/numnodes.h       2003-06-14 12:18:52.000000000 -0700
95700 +++ 25/include/asm-ia64/numnodes.h      2003-10-05 00:34:41.000000000 -0700
95701 @@ -1,7 +1,12 @@
95702  #ifndef _ASM_MAX_NUMNODES_H
95703  #define _ASM_MAX_NUMNODES_H
95704  
95705 -#include <asm/mmzone.h>
95706 -#define MAX_NUMNODES   NR_NODES
95707 +#ifdef CONFIG_IA64_DIG
95708 +/* Max 8 Nodes */
95709 +#define NODES_SHIFT    3
95710 +#elif defined(CONFIG_IA64_SGI_SN2)
95711 +/* Max 128 Nodes */
95712 +#define NODES_SHIFT    7
95713 +#endif
95714  
95715  #endif /* _ASM_MAX_NUMNODES_H */
95716 --- linux-2.6.0-test6/include/asm-ia64/pgtable.h        2003-06-22 12:04:45.000000000 -0700
95717 +++ 25/include/asm-ia64/pgtable.h       2003-10-05 00:33:24.000000000 -0700
95718 @@ -207,7 +207,6 @@ ia64_phys_addr_valid (unsigned long addr
95719  #define RGN_KERNEL     7
95720  
95721  #define VMALLOC_START          0xa000000200000000
95722 -#define VMALLOC_VMADDR(x)      ((unsigned long)(x))
95723  #ifdef CONFIG_VIRTUAL_MEM_MAP
95724  # define VMALLOC_END_INIT      (0xa000000000000000 + (1UL << (4*PAGE_SHIFT - 9)))
95725  # define VMALLOC_END           vmalloc_end
95726 --- linux-2.6.0-test6/include/asm-ia64/sn/pda.h 2003-06-22 12:04:45.000000000 -0700
95727 +++ 25/include/asm-ia64/sn/pda.h        2003-10-05 00:34:41.000000000 -0700
95728 @@ -10,6 +10,7 @@
95729  
95730  #include <linux/config.h>
95731  #include <linux/cache.h>
95732 +#include <linux/numa.h>
95733  #include <asm/percpu.h>
95734  #include <asm/system.h>
95735  #include <asm/processor.h>
95736 @@ -56,7 +57,7 @@ typedef struct pda_s {
95737  
95738         unsigned long   sn_soft_irr[4];
95739         unsigned long   sn_in_service_ivecs[4];
95740 -       short           cnodeid_to_nasid_table[NR_NODES];       
95741 +       short           cnodeid_to_nasid_table[MAX_NUMNODES];
95742         int             sn_lb_int_war_ticks;
95743         int             sn_last_irq;
95744         int             sn_first_irq;
95745 --- linux-2.6.0-test6/include/asm-ia64/spinlock.h       2003-09-27 18:57:47.000000000 -0700
95746 +++ 25/include/asm-ia64/spinlock.h      2003-10-05 00:36:40.000000000 -0700
95747 @@ -110,8 +110,18 @@ do {                                                                                       \
95748  typedef struct {
95749         volatile int read_counter       : 31;
95750         volatile int write_lock         :  1;
95751 +#ifdef CONFIG_LOCKMETER
95752 +       /* required for LOCKMETER since all bits in lock are used */
95753 +       /* and we need this storage for CPU and lock INDEX        */
95754 +       unsigned lockmeter_magic;
95755 +#endif
95756  } rwlock_t;
95757 +
95758 +#ifdef CONFIG_LOCKMETER
95759 +#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, 0 }
95760 +#else
95761  #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 }
95762 +#endif
95763  
95764  #define rwlock_init(x)         do { *(x) = RW_LOCK_UNLOCKED; } while(0)
95765  #define rwlock_is_locked(x)    (*(volatile int *) (x) != 0)
95766 @@ -127,6 +137,48 @@ do {                                                                                       \
95767         }                                                                               \
95768  } while (0)
95769  
95770 +#ifdef CONFIG_LOCKMETER
95771 +/*
95772 + * HACK: This works, but still have a timing window that affects performance:
95773 + * we see that no one owns the Write lock, then someone * else grabs for Write
95774 + * lock before we do a read_lock().
95775 + * This means that on rare occasions our read_lock() will stall and spin-wait
95776 + * until we acquire for Read, instead of simply returning a trylock failure.
95777 + */
95778 +static inline int _raw_read_trylock(rwlock_t *rw)
95779 +{
95780 +       if (rw->write_lock) {
95781 +               return 0;
95782 +       } else {
95783 +               _raw_read_lock(rw);
95784 +               return 1;
95785 +       }
95786 +}
95787 +
95788 +static inline int _raw_write_trylock(rwlock_t *rw)
95789 +{
95790 +       if (!(rw->write_lock)) {
95791 +           /* isn't currently write-locked... that looks promising... */
95792 +           if (test_and_set_bit(31, rw) == 0) {
95793 +               /* now it is write-locked by me... */
95794 +               if (rw->read_counter) {
95795 +                   /* really read-locked, so release write-lock and fail */
95796 +                   clear_bit(31, rw);
95797 +               } else {
95798 +                   /* we've the the write-lock, no read-lockers... success! */
95799 +                   barrier();
95800 +                   return 1;
95801 +               }
95802 +
95803 +           }
95804 +       }
95805 +
95806 +       /* falls through ... fails to write-lock */
95807 +       barrier();
95808 +       return 0;
95809 +}
95810 +#endif
95811 +
95812  #define _raw_read_unlock(rw)                                   \
95813  do {                                                           \
95814         rwlock_t *__read_lock_ptr = (rw);                       \
95815 @@ -190,4 +242,25 @@ do {                                                                               \
95816         clear_bit(31, (x));                                                             \
95817  })
95818  
95819 +#ifdef CONFIG_LOCKMETER
95820 +extern void _metered_spin_lock  (spinlock_t *lock);
95821 +extern void _metered_spin_unlock(spinlock_t *lock);
95822 +
95823 +/*
95824 + *  Use a less efficient, and inline, atomic_dec_and_lock() if lockmetering
95825 + *  so we can see the callerPC of who is actually doing the spin_lock().
95826 + *  Otherwise, all we see is the generic rollup of all locks done by
95827 + *  atomic_dec_and_lock().
95828 + */
95829 +static inline int atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
95830 +{
95831 +       _metered_spin_lock(lock);
95832 +       if (atomic_dec_and_test(atomic))
95833 +               return 1;
95834 +       _metered_spin_unlock(lock);
95835 +       return 0;
95836 +}
95837 +#define ATOMIC_DEC_AND_LOCK
95838 +#endif
95839 +
95840  #endif /*  _ASM_IA64_SPINLOCK_H */
95841 --- linux-2.6.0-test6/include/asm-m68k/bitops.h 2003-06-14 12:18:52.000000000 -0700
95842 +++ 25/include/asm-m68k/bitops.h        2003-10-05 00:33:24.000000000 -0700
95843 @@ -164,9 +164,10 @@ extern __inline__ int test_bit(int nr, c
95844         return ((1UL << (nr & 31)) & (((const volatile unsigned long *) vaddr)[nr >> 5])) != 0;
95845  }
95846  
95847 -extern __inline__ int find_first_zero_bit(unsigned long * vaddr, unsigned size)
95848 +extern __inline__ int find_first_zero_bit(const unsigned long *vaddr,
95849 +                                         unsigned size)
95850  {
95851 -       unsigned long *p = vaddr, *addr = vaddr;
95852 +       const unsigned long *p = vaddr, *addr = vaddr;
95853         unsigned long allones = ~0UL;
95854         int res;
95855         unsigned long num;
95856 @@ -187,11 +188,11 @@ extern __inline__ int find_first_zero_bi
95857         return ((p - addr) << 5) + (res ^ 31);
95858  }
95859  
95860 -extern __inline__ int find_next_zero_bit (unsigned long *vaddr, int size,
95861 +extern __inline__ int find_next_zero_bit (const unsigned long *vaddr, int size,
95862                                       int offset)
95863  {
95864 -       unsigned long *addr = vaddr;
95865 -       unsigned long *p = addr + (offset >> 5);
95866 +       const unsigned long *addr = vaddr;
95867 +       const unsigned long *p = addr + (offset >> 5);
95868         int set = 0, bit = offset & 31UL, res;
95869  
95870         if (offset >= size)
95871 @@ -263,7 +264,7 @@ static inline int fls(int x)
95872   * unlikely to be set. It's guaranteed that at least one of the 140
95873   * bits is cleared.
95874   */
95875 -static inline int sched_find_first_bit(unsigned long *b)
95876 +static inline int sched_find_first_bit(const unsigned long *b)
95877  {
95878         if (unlikely(b[0]))
95879                 return __ffs(b[0]);
95880 --- linux-2.6.0-test6/include/asm-m68k/cacheflush.h     2003-07-27 12:14:40.000000000 -0700
95881 +++ 25/include/asm-m68k/cacheflush.h    2003-10-05 00:33:24.000000000 -0700
95882 @@ -80,6 +80,9 @@ extern void cache_push_v(unsigned long v
95883  
95884  #define flush_cache_all() __flush_cache_all()
95885  
95886 +#define flush_cache_vmap(start, end)           flush_cache_all()
95887 +#define flush_cache_vunmap(start, end)         flush_cache_all()
95888 +
95889  extern inline void flush_cache_mm(struct mm_struct *mm)
95890  {
95891         if (mm == current->mm)
95892 @@ -127,6 +130,10 @@ extern inline void __flush_page_to_ram(v
95893  #define flush_dcache_page(page)                __flush_page_to_ram(page_address(page))
95894  #define flush_icache_page(vma, page)   __flush_page_to_ram(page_address(page))
95895  #define flush_icache_user_range(vma,pg,adr,len)        do { } while (0)
95896 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
95897 +       memcpy(dst, src, len)
95898 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
95899 +       memcpy(dst, src, len)
95900  
95901  extern void flush_icache_range(unsigned long address, unsigned long endaddr);
95902  
95903 --- linux-2.6.0-test6/include/asm-m68knommu/cacheflush.h        2003-06-14 12:18:34.000000000 -0700
95904 +++ 25/include/asm-m68knommu/cacheflush.h       2003-10-05 00:33:24.000000000 -0700
95905 @@ -15,7 +15,13 @@
95906  #define flush_icache_range(start,len)          __flush_cache_all()
95907  #define flush_icache_page(vma,pg)              do { } while (0)
95908  #define flush_icache_user_range(vma,pg,adr,len)        do { } while (0)
95909 +#define flush_cache_vmap(start, end)           flush_cache_all()
95910 +#define flush_cache_vunmap(start, end)         flush_cache_all()
95911  
95912 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
95913 +       memcpy(dst, src, len)
95914 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
95915 +       memcpy(dst, src, len)
95916  
95917  extern inline void __flush_cache_all(void)
95918  {
95919 --- linux-2.6.0-test6/include/asm-m68k/pci.h    2003-06-14 12:18:09.000000000 -0700
95920 +++ 25/include/asm-m68k/pci.h   2003-10-05 00:33:24.000000000 -0700
95921 @@ -7,6 +7,8 @@
95922   * Written by Wout Klaren.
95923   */
95924  
95925 +#include <asm/scatterlist.h>
95926 +
95927  struct pci_ops;
95928  
95929  /*
95930 --- linux-2.6.0-test6/include/asm-m68k/pgtable.h        2003-06-14 12:18:32.000000000 -0700
95931 +++ 25/include/asm-m68k/pgtable.h       2003-10-05 00:33:24.000000000 -0700
95932 @@ -79,12 +79,10 @@
95933   */
95934  #define VMALLOC_OFFSET (8*1024*1024)
95935  #define VMALLOC_START (((unsigned long) high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
95936 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
95937  #define VMALLOC_END KMAP_START
95938  #else
95939  extern unsigned long vmalloc_end;
95940  #define VMALLOC_START 0x0f800000
95941 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
95942  #define VMALLOC_END vmalloc_end
95943  #endif /* CONFIG_SUN3 */
95944  
95945 --- linux-2.6.0-test6/include/asm-m68k/zorro.h  2003-06-14 12:18:03.000000000 -0700
95946 +++ 25/include/asm-m68k/zorro.h 2003-10-05 00:33:24.000000000 -0700
95947 @@ -42,4 +42,4 @@ extern inline void *z_remap_fullcache(un
95948  #define z_iounmap iounmap
95949  #define z_ioremap z_remap_nocache_ser
95950  
95951 -#endif /* _ASM_ZORRO_H */
95952 +#endif /* _ASM_M68K_ZORRO_H */
95953 --- linux-2.6.0-test6/include/asm-mips/cacheflush.h     2003-08-08 22:55:13.000000000 -0700
95954 +++ 25/include/asm-mips/cacheflush.h    2003-10-05 00:33:24.000000000 -0700
95955 @@ -43,7 +43,15 @@ extern void (*flush_icache_page)(struct 
95956  extern void (*flush_icache_range)(unsigned long start, unsigned long end);
95957  #define flush_icache_user_range(vma, page, addr, len)   \
95958                                         flush_icache_page(vma, page)
95959 +#define flush_cache_vmap(start, end)           flush_cache_all()
95960 +#define flush_cache_vunmap(start, end)         flush_cache_all()
95961  
95962 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
95963 +do { memcpy(dst, src, len); \
95964 +     flush_icache_user_range(vma, page, vaddr, len); \
95965 +} while (0)
95966 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
95967 +       memcpy(dst, src, len)
95968  
95969  extern void (*flush_cache_sigtramp)(unsigned long addr);
95970  extern void (*flush_icache_all)(void);
95971 --- linux-2.6.0-test6/include/asm-mips/highmem.h        2003-07-02 14:53:17.000000000 -0700
95972 +++ 25/include/asm-mips/highmem.h       2003-10-05 00:33:24.000000000 -0700
95973 @@ -54,6 +54,8 @@ extern void *kmap_atomic(struct page *pa
95974  extern void kunmap_atomic(void *kvaddr, enum km_type type);
95975  extern struct page *kmap_atomic_to_page(void *ptr);
95976  
95977 +#define flush_cache_kmaps()    flush_cache_all()
95978 +
95979  #endif /* __KERNEL__ */
95980  
95981  #endif /* _ASM_HIGHMEM_H */
95982 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
95983 +++ 25/include/asm-mips/lockmeter.h     2003-10-05 00:36:40.000000000 -0700
95984 @@ -0,0 +1,126 @@
95985 +/*
95986 + *  Copyright (C) 1999,2000 Silicon Graphics, Inc.
95987 + *
95988 + *  Written by John Hawkes (hawkes@sgi.com)
95989 + *  Based on klstat.h by Jack Steiner (steiner@sgi.com)
95990 + *  Ported to mips32 for Asita Technologies
95991 + *   by D.J. Barrow ( dj.barrow@asitatechnologies.com )
95992 + */
95993 +#ifndef _ASM_LOCKMETER_H
95994 +#define _ASM_LOCKMETER_H
95995 +
95996 +/* do_gettimeoffset is a function pointer on mips */
95997 +/* & it is not included by <linux/time.h> */
95998 +#include <asm/time.h>
95999 +#include <linux/time.h>
96000 +#include <asm/div64.h>
96001 +
96002 +#define SPINLOCK_MAGIC_INIT    /* */
96003 +
96004 +#define CPU_CYCLE_FREQUENCY    get_cpu_cycle_frequency()
96005 +
96006 +#define THIS_CPU_NUMBER                smp_processor_id()
96007 +
96008 +static uint32_t cpu_cycle_frequency = 0;
96009 +
96010 +static uint32_t get_cpu_cycle_frequency(void)
96011 +{
96012 +    /* a total hack, slow and invasive, but ... it works */
96013 +    int sec;
96014 +    uint32_t start_cycles;
96015 +    struct timeval tv;
96016 +
96017 +    if (cpu_cycle_frequency == 0) {    /* uninitialized */
96018 +       do_gettimeofday(&tv);
96019 +       sec = tv.tv_sec;        /* set up to catch the tv_sec rollover */
96020 +       while (sec == tv.tv_sec) { do_gettimeofday(&tv); }
96021 +       sec = tv.tv_sec;        /* rolled over to a new sec value */
96022 +       start_cycles = get_cycles();
96023 +       while (sec == tv.tv_sec) { do_gettimeofday(&tv); }
96024 +       cpu_cycle_frequency = get_cycles() - start_cycles;
96025 +    }
96026 +
96027 +    return cpu_cycle_frequency;
96028 +}
96029 +
96030 +extern struct timeval xtime;
96031 +
96032 +static uint64_t get_cycles64(void)
96033 +{
96034 +    static uint64_t last_get_cycles64 = 0;
96035 +    uint64_t ret;
96036 +    unsigned long sec;
96037 +    unsigned long usec, usec_offset;
96038 +
96039 +again:
96040 +    sec  = xtime.tv_sec;
96041 +    usec = xtime.tv_usec;
96042 +    usec_offset = do_gettimeoffset();
96043 +    if ((xtime.tv_sec != sec)  ||
96044 +       (xtime.tv_usec != usec)||
96045 +       (usec_offset >= 20000))
96046 +       goto again;
96047 +
96048 +    ret = ((uint64_t)(usec + usec_offset) * cpu_cycle_frequency);
96049 +    /* We can't do a normal 64 bit division on mips without libgcc.a */
96050 +    do_div(ret,1000000);
96051 +    ret +=  ((uint64_t)sec * cpu_cycle_frequency);
96052 +
96053 +    /* XXX why does time go backwards?  do_gettimeoffset?  general time adj? */
96054 +    if (ret <= last_get_cycles64)
96055 +       ret  = last_get_cycles64+1;
96056 +    last_get_cycles64 = ret;
96057 +
96058 +    return ret;
96059 +}
96060 +
96061 +/*
96062 + * macros to cache and retrieve an index value inside of a lock
96063 + * these macros assume that there are less than 65536 simultaneous
96064 + * (read mode) holders of a rwlock.
96065 + * we also assume that the hash table has less than 32767 entries.
96066 + * the high order bit is used for write locking a rw_lock
96067 + */
96068 +#define INDEX_MASK   0x7FFF0000
96069 +#define READERS_MASK 0x0000FFFF
96070 +#define INDEX_SHIFT 16
96071 +#define PUT_INDEX(lockp,index)   \
96072 +        lockp->lock = (((lockp->lock) & ~INDEX_MASK) | (index) << INDEX_SHIFT)
96073 +#define GET_INDEX(lockp) \
96074 +        (((lockp->lock) & INDEX_MASK) >> INDEX_SHIFT)
96075 +
96076 +/*
96077 + * macros to cache and retrieve an index value in a read/write lock
96078 + * as well as the cpu where a reader busy period started
96079 + * we use the 2nd word (the debug word) for this, so require the
96080 + * debug word to be present
96081 + */
96082 +/*
96083 + * instrumented rwlock structure -- never used to allocate storage
96084 + * only used in macros below to overlay a rwlock_t
96085 + */
96086 +typedef struct inst_rwlock_s {
96087 +       volatile int lock;
96088 +       unsigned short index;
96089 +       unsigned short cpu;
96090 +} inst_rwlock_t;
96091 +#define PUT_RWINDEX(rwlock_ptr,indexv) ((inst_rwlock_t *)(rwlock_ptr))->index = indexv
96092 +#define GET_RWINDEX(rwlock_ptr)        ((inst_rwlock_t *)(rwlock_ptr))->index
96093 +#define PUT_RW_CPU(rwlock_ptr,cpuv)    ((inst_rwlock_t *)(rwlock_ptr))->cpu = cpuv
96094 +#define GET_RW_CPU(rwlock_ptr)         ((inst_rwlock_t *)(rwlock_ptr))->cpu
96095 +
96096 +/*
96097 + * return the number of readers for a rwlock_t
96098 + */
96099 +#define RWLOCK_READERS(rwlock_ptr)   rwlock_readers(rwlock_ptr)
96100 +
96101 +extern inline int rwlock_readers(rwlock_t *rwlock_ptr)
96102 +{
96103 +       int tmp = (int) rwlock_ptr->lock;
96104 +       return (tmp >= 0) ? tmp : 0;
96105 +}
96106 +
96107 +#define RWLOCK_IS_WRITE_LOCKED(rwlock_ptr) ((rwlock_ptr)->lock < 0)
96108 +#define RWLOCK_IS_READ_LOCKED(rwlock_ptr)  ((rwlock_ptr)->lock > 0)
96109 +
96110 +#endif /* _ASM_LOCKMETER_H */
96111 --- linux-2.6.0-test6/include/asm-mips/pgtable-32.h     2003-08-08 22:55:13.000000000 -0700
96112 +++ 25/include/asm-mips/pgtable-32.h    2003-10-05 00:33:24.000000000 -0700
96113 @@ -79,7 +79,6 @@ extern int add_temporary_entry(unsigned 
96114  #define FIRST_USER_PGD_NR      0
96115  
96116  #define VMALLOC_START     KSEG2
96117 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
96118  
96119  #if CONFIG_HIGHMEM
96120  # define VMALLOC_END   (PKMAP_BASE-2*PAGE_SIZE)
96121 --- linux-2.6.0-test6/include/asm-mips/pgtable-64.h     2003-08-08 22:55:13.000000000 -0700
96122 +++ 25/include/asm-mips/pgtable-64.h    2003-10-05 00:33:24.000000000 -0700
96123 @@ -64,7 +64,6 @@
96124  #define FIRST_USER_PGD_NR      0
96125  
96126  #define VMALLOC_START          XKSEG
96127 -#define VMALLOC_VMADDR(x)      ((unsigned long)(x))
96128  #define VMALLOC_END    \
96129         (VMALLOC_START + ((1 << PGD_ORDER) * PTRS_PER_PTE * PAGE_SIZE))
96130  
96131 --- linux-2.6.0-test6/include/asm-mips/spinlock.h       2003-07-02 14:53:17.000000000 -0700
96132 +++ 25/include/asm-mips/spinlock.h      2003-10-05 00:36:40.000000000 -0700
96133 @@ -91,9 +91,18 @@ static inline unsigned int _raw_spin_try
96134  
96135  typedef struct {
96136         volatile unsigned int lock;
96137 +#ifdef CONFIG_LOCKMETER
96138 +       /* required for LOCKMETER since all bits in lock are used */
96139 +       /* and we need this storage for CPU and lock INDEX        */
96140 +       unsigned lockmeter_magic;
96141 +#endif
96142  } rwlock_t;
96143  
96144 +#ifdef CONFIG_LOCKMETER
96145 +#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 }
96146 +#else
96147  #define RW_LOCK_UNLOCKED (rwlock_t) { 0 }
96148 +#endif
96149  
96150  #define rwlock_init(x)  do { *(x) = RW_LOCK_UNLOCKED; } while(0)
96151  
96152 --- linux-2.6.0-test6/include/asm-parisc/atomic.h       2003-09-27 18:57:47.000000000 -0700
96153 +++ 25/include/asm-parisc/atomic.h      2003-10-05 00:33:24.000000000 -0700
96154 @@ -129,8 +129,9 @@ __cmpxchg(volatile void *ptr, unsigned l
96155  
96156  
96157  /* It's possible to reduce all atomic operations to either
96158 - * __atomic_add_return, __atomic_set and __atomic_ret (the latter
96159 - * is there only for consistency). */
96160 + * __atomic_add_return, atomic_set and atomic_read (the latter
96161 + * is there only for consistency).
96162 + */
96163  
96164  static __inline__ int __atomic_add_return(int i, atomic_t *v)
96165  {
96166 @@ -144,7 +145,7 @@ static __inline__ int __atomic_add_retur
96167         return ret;
96168  }
96169  
96170 -static __inline__ void __atomic_set(atomic_t *v, int i) 
96171 +static __inline__ void atomic_set(atomic_t *v, int i) 
96172  {
96173         unsigned long flags;
96174         SPIN_LOCK_IRQSAVE(ATOMIC_HASH(v), flags);
96175 @@ -154,28 +155,25 @@ static __inline__ void __atomic_set(atom
96176         SPIN_UNLOCK_IRQRESTORE(ATOMIC_HASH(v), flags);
96177  }
96178  
96179 -static __inline__ int __atomic_read(atomic_t *v)
96180 +static __inline__ int atomic_read(const atomic_t *v)
96181  {
96182         return v->counter;
96183  }
96184  
96185  /* exported interface */
96186  
96187 -#define atomic_add(i,v)                ((void)(__atomic_add_return( (i),(v))))
96188 -#define atomic_sub(i,v)                ((void)(__atomic_add_return(-(i),(v))))
96189 -#define atomic_inc(v)          ((void)(__atomic_add_return(   1,(v))))
96190 -#define atomic_dec(v)          ((void)(__atomic_add_return(  -1,(v))))
96191 +#define atomic_add(i,v)        ((void)(__atomic_add_return( ((int)i),(v))))
96192 +#define atomic_sub(i,v)        ((void)(__atomic_add_return(-((int)i),(v))))
96193 +#define atomic_inc(v)  ((void)(__atomic_add_return(   1,(v))))
96194 +#define atomic_dec(v)  ((void)(__atomic_add_return(  -1,(v))))
96195  
96196 -#define atomic_add_return(i,v) (__atomic_add_return( (i),(v)))
96197 -#define atomic_sub_return(i,v) (__atomic_add_return(-(i),(v)))
96198 +#define atomic_add_return(i,v) (__atomic_add_return( ((int)i),(v)))
96199 +#define atomic_sub_return(i,v) (__atomic_add_return(-((int)i),(v)))
96200  #define atomic_inc_return(v)   (__atomic_add_return(   1,(v)))
96201  #define atomic_dec_return(v)   (__atomic_add_return(  -1,(v)))
96202  
96203  #define atomic_dec_and_test(v) (atomic_dec_return(v) == 0)
96204  
96205 -#define atomic_set(v,i)                (__atomic_set((v),i))
96206 -#define atomic_read(v)         (__atomic_read(v))
96207 -
96208  #define ATOMIC_INIT(i) { (i) }
96209  
96210  #define smp_mb__before_atomic_dec()    smp_mb()
96211 --- linux-2.6.0-test6/include/asm-parisc/bitops.h       2003-09-27 18:57:47.000000000 -0700
96212 +++ 25/include/asm-parisc/bitops.h      2003-10-05 00:33:24.000000000 -0700
96213 @@ -232,24 +232,24 @@ static __inline__ unsigned long __ffs(un
96214  #if BITS_PER_LONG > 32
96215                 " ldi       63,%1\n"
96216                 " extrd,u,*<>  %0,63,32,%%r0\n"
96217 -               " extrd,u,*TR  %0,31,32,%0\n"
96218 +               " extrd,u,*TR  %0,31,32,%0\n"   /* move top 32-bits down */
96219                 " addi    -32,%1,%1\n"
96220  #else
96221                 " ldi       31,%1\n"
96222  #endif
96223                 " extru,<>  %0,31,16,%%r0\n"
96224 -               " extru,TR  %0,15,16,%0\n"
96225 +               " extru,TR  %0,15,16,%0\n"      /* xxxx0000 -> 0000xxxx */
96226                 " addi    -16,%1,%1\n"
96227                 " extru,<>  %0,31,8,%%r0\n"
96228 -               " extru,TR  %0,23,8,%0\n"
96229 +               " extru,TR  %0,23,8,%0\n"       /* 0000xx00 -> 000000xx */
96230                 " addi    -8,%1,%1\n"
96231                 " extru,<>  %0,31,4,%%r0\n"
96232 -               " extru,TR  %0,27,4,%0\n"
96233 +               " extru,TR  %0,27,4,%0\n"       /* 000000x0 -> 0000000x */
96234                 " addi    -4,%1,%1\n"
96235                 " extru,<>  %0,31,2,%%r0\n"
96236 -               " extru,TR  %0,29,2,%0\n"
96237 +               " extru,TR  %0,29,2,%0\n"       /* 0000000y, 1100b -> 0011b */
96238                 " addi    -2,%1,%1\n"
96239 -               " extru,=  %0,31,1,%%r0\n"
96240 +               " extru,=  %0,31,1,%%r0\n"      /* check last bit */
96241                 " addi    -1,%1,%1\n"
96242                         : "+r" (x), "=r" (ret) );
96243         return ret;
96244 @@ -291,7 +291,7 @@ static __inline__ int fls(int x)
96245         "       zdep,TR         %0,27,28,%0\n"          /* x0000000 */
96246         "       addi            4,%1,%1\n"
96247         "       extru,<>        %0,1,2,%%r0\n"
96248 -       "       zdep,TR         %0,29,30,%0\n"          /* y0000000 (y&3 = 0 */
96249 +       "       zdep,TR         %0,29,30,%0\n"          /* y0000000 (y&3 = 0) */
96250         "       addi            2,%1,%1\n"
96251         "       extru,=         %0,0,1,%%r0\n"
96252         "       addi            1,%1,%1\n"              /* if y & 8, add 1 */
96253 --- linux-2.6.0-test6/include/asm-parisc/cacheflush.h   2003-09-27 18:57:47.000000000 -0700
96254 +++ 25/include/asm-parisc/cacheflush.h  2003-10-05 00:33:24.000000000 -0700
96255 @@ -30,6 +30,9 @@ static inline void flush_cache_all(void)
96256         on_each_cpu(cacheflush_h_tmp_function, NULL, 1, 1);
96257  }
96258  
96259 +#define flush_cache_vmap(start, end)           flush_cache_all()
96260 +#define flush_cache_vunmap(start, end)         flush_cache_all()
96261 +
96262  /* The following value needs to be tuned and probably scaled with the
96263   * cache size.
96264   */
96265 @@ -82,6 +85,13 @@ static inline void flush_dcache_page(str
96266          flush_user_dcache_range(addr, addr + len); \
96267         flush_user_icache_range(addr, addr + len); } while (0)
96268  
96269 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
96270 +do { memcpy(dst, src, len); \
96271 +     flush_icache_user_range(vma, page, vaddr, len); \
96272 +} while (0)
96273 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
96274 +       memcpy(dst, src, len)
96275 +
96276  static inline void flush_cache_range(struct vm_area_struct *vma,
96277                 unsigned long start, unsigned long end)
96278  {
96279 --- linux-2.6.0-test6/include/asm-parisc/dma-mapping.h  2003-06-14 12:18:07.000000000 -0700
96280 +++ 25/include/asm-parisc/dma-mapping.h 2003-10-05 00:33:24.000000000 -0700
96281 @@ -2,6 +2,7 @@
96282  #define _PARISC_DMA_MAPPING_H
96283  
96284  #include <linux/mm.h>
96285 +#include <linux/config.h>
96286  #include <asm/cacheflush.h>
96287  
96288  /*
96289 --- linux-2.6.0-test6/include/asm-parisc/elf.h  2003-09-27 18:57:47.000000000 -0700
96290 +++ 25/include/asm-parisc/elf.h 2003-10-05 00:33:24.000000000 -0700
96291 @@ -144,6 +144,30 @@
96292  #define R_PARISC_LTOFF_TP16DF  231     /* 16 bits LT-TP-rel. address.  */
96293  #define R_PARISC_HIRESERVE     255
96294  
96295 +#define PA_PLABEL_FDESC                0x02    /* bit set if PLABEL points to
96296 +                                        * a function descriptor, not
96297 +                                        * an address */
96298 +
96299 +/* The following are PA function descriptors 
96300 + *
96301 + * addr:       the absolute address of the function
96302 + * gp:         either the data pointer (r27) for non-PIC code or the
96303 + *             the PLT pointer (r19) for PIC code */
96304 +
96305 +/* Format for the Elf32 Function descriptor */
96306 +typedef struct elf32_fdesc {
96307 +       __u32   addr;
96308 +       __u32   gp;
96309 +} Elf32_Fdesc;
96310 +
96311 +/* Format for the Elf64 Function descriptor */
96312 +typedef struct elf64_fdesc {
96313 +       __u64   dummy[2]; /* FIXME: nothing uses these, why waste
96314 +                          * the space */
96315 +       __u64   addr;
96316 +       __u64   gp;
96317 +} Elf64_Fdesc;
96318 +
96319  /* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr.  */
96320  
96321  #define PT_HP_TLS              (PT_LOOS + 0x0)
96322 @@ -215,7 +239,10 @@ typedef unsigned long elf_greg_t;
96323  
96324  #ifdef __KERNEL__
96325  #define SET_PERSONALITY(ex, ibcs2) \
96326 -       current->personality = PER_LINUX
96327 +       current->personality = PER_LINUX; \
96328 +       current->thread.map_base = DEFAULT_MAP_BASE; \
96329 +       current->thread.task_size = DEFAULT_TASK_SIZE \
96330 +
96331  #endif
96332  
96333  /*
96334 --- linux-2.6.0-test6/include/asm-parisc/ioctl.h        2003-06-14 12:17:55.000000000 -0700
96335 +++ 25/include/asm-parisc/ioctl.h       2003-10-05 00:33:24.000000000 -0700
96336 @@ -44,11 +44,21 @@
96337          ((nr)   << _IOC_NRSHIFT) | \
96338          ((size) << _IOC_SIZESHIFT))
96339  
96340 +/* provoke compile error for invalid uses of size argument */
96341 +extern int __invalid_size_argument_for_IOC;
96342 +#define _IOC_TYPECHECK(t) \
96343 +       ((sizeof(t) == sizeof(t[1]) && \
96344 +         sizeof(t) < (1 << _IOC_SIZEBITS)) ? \
96345 +         sizeof(t) : __invalid_size_argument_for_IOC)
96346 +
96347  /* used to create numbers */
96348  #define _IO(type,nr)           _IOC(_IOC_NONE,(type),(nr),0)
96349 -#define _IOR(type,nr,size)     _IOC(_IOC_READ,(type),(nr),sizeof(size))
96350 -#define _IOW(type,nr,size)     _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
96351 -#define _IOWR(type,nr,size)    _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
96352 +#define _IOR(type,nr,size)     _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
96353 +#define _IOW(type,nr,size)     _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
96354 +#define _IOWR(type,nr,size)    _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
96355 +#define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
96356 +#define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
96357 +#define _IOWR_BAD(type,nr,size)        _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
96358  
96359  /* used to decode ioctl numbers.. */
96360  #define _IOC_DIR(nr)           (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
96361 --- linux-2.6.0-test6/include/asm-parisc/irq.h  2003-06-14 12:18:07.000000000 -0700
96362 +++ 25/include/asm-parisc/irq.h 2003-10-05 00:33:24.000000000 -0700
96363 @@ -17,6 +17,7 @@
96364  
96365  #include <linux/string.h>
96366  #include <linux/interrupt.h>
96367 +#include <linux/config.h>
96368  
96369  
96370  #define CPU_IRQ_REGION         1
96371 --- linux-2.6.0-test6/include/asm-parisc/keyboard.h     2003-06-14 12:18:04.000000000 -0700
96372 +++ 25/include/asm-parisc/keyboard.h    2003-10-05 00:33:24.000000000 -0700
96373 @@ -25,8 +25,6 @@
96374  #ifndef _PARISC_KEYBOARD_H
96375  #define _PARISC_KEYBOARD_H
96376  
96377 -#include <linux/config.h>
96378 -
96379  #ifdef __KERNEL__
96380  
96381  #include <linux/kernel.h>
96382 --- linux-2.6.0-test6/include/asm-parisc/page.h 2003-06-14 12:18:00.000000000 -0700
96383 +++ 25/include/asm-parisc/page.h        2003-10-05 00:33:24.000000000 -0700
96384 @@ -7,6 +7,7 @@
96385  #define PAGE_MASK      (~(PAGE_SIZE-1))
96386  
96387  #ifdef __KERNEL__
96388 +#include <linux/config.h>
96389  #ifndef __ASSEMBLY__
96390  
96391  #include <asm/cache.h>
96392 --- linux-2.6.0-test6/include/asm-parisc/param.h        2003-06-14 12:18:08.000000000 -0700
96393 +++ 25/include/asm-parisc/param.h       2003-10-05 00:33:24.000000000 -0700
96394 @@ -2,6 +2,7 @@
96395  #define _ASMPARISC_PARAM_H
96396  
96397  #ifdef __KERNEL__
96398 +#include <linux/config.h>
96399  # ifdef CONFIG_PA20
96400  #  define HZ           1000            /* Faster machines */
96401  # else
96402 --- linux-2.6.0-test6/include/asm-parisc/pci.h  2003-06-14 12:18:29.000000000 -0700
96403 +++ 25/include/asm-parisc/pci.h 2003-10-05 00:33:24.000000000 -0700
96404 @@ -1,6 +1,7 @@
96405  #ifndef __ASM_PARISC_PCI_H
96406  #define __ASM_PARISC_PCI_H
96407  
96408 +#include <linux/config.h>
96409  #include <asm/scatterlist.h>
96410  
96411  /*
96412 --- linux-2.6.0-test6/include/asm-parisc/pdc.h  2003-06-14 12:17:55.000000000 -0700
96413 +++ 25/include/asm-parisc/pdc.h 2003-10-05 00:33:24.000000000 -0700
96414 @@ -1,6 +1,8 @@
96415  #ifndef _PARISC_PDC_H
96416  #define _PARISC_PDC_H
96417  
96418 +#include <linux/config.h>
96419 +
96420  /*
96421   *     PDC return values ...
96422   *     All PDC calls return a subset of these errors. 
96423 @@ -191,8 +193,8 @@ typedef struct {
96424  
96425  #define PDC_IO         135             /* log error info, reset IO system */
96426  #define PDC_IO_READ_AND_CLEAR_ERRORS   0
96427 -#define PDC_IO_READ_AND_LOG_ERRORS     1
96428 -#define PDC_IO_SUSPEND_USB             2
96429 +#define PDC_IO_RESET                   1
96430 +#define PDC_IO_RESET_DEVICES           2
96431  /* sets bits 6&7 (little endian) of the HcControl Register */
96432  #define PDC_IO_USB_SUSPEND     0xC000000000000000
96433  #define PDC_IO_EEPROM_IO_ERR_TABLE_FULL        -5      /* return value */
96434 @@ -951,7 +953,8 @@ int pdc_do_firm_test_reset(unsigned long
96435  int pdc_do_reset(void);
96436  int pdc_soft_power_info(unsigned long *power_reg);
96437  int pdc_soft_power_button(int sw_control);
96438 -void pdc_suspend_usb(void);
96439 +void pdc_io_reset(void);
96440 +void pdc_io_reset_devices(void);
96441  int pdc_iodc_getc(void);
96442  void pdc_iodc_putc(unsigned char c);
96443  void pdc_iodc_outc(unsigned char c);
96444 --- linux-2.6.0-test6/include/asm-parisc/pgalloc.h      2003-06-14 12:18:35.000000000 -0700
96445 +++ 25/include/asm-parisc/pgalloc.h     2003-10-05 00:33:24.000000000 -0700
96446 @@ -1,7 +1,6 @@
96447  #ifndef _ASM_PGALLOC_H
96448  #define _ASM_PGALLOC_H
96449  
96450 -#include <linux/config.h>
96451  #include <linux/gfp.h>
96452  #include <linux/mm.h>
96453  #include <linux/threads.h>
96454 --- linux-2.6.0-test6/include/asm-parisc/pgtable.h      2003-07-13 21:44:35.000000000 -0700
96455 +++ 25/include/asm-parisc/pgtable.h     2003-10-05 00:33:24.000000000 -0700
96456 @@ -1,6 +1,7 @@
96457  #ifndef _PARISC_PGTABLE_H
96458  #define _PARISC_PGTABLE_H
96459  
96460 +#include <linux/config.h>
96461  #include <asm/fixmap.h>
96462  
96463  #ifndef __ASSEMBLY__
96464 @@ -108,7 +109,6 @@
96465  extern  void *vmalloc_start;
96466  #define PCXL_DMA_MAP_SIZE   (8*1024*1024)
96467  #define VMALLOC_START   ((unsigned long)vmalloc_start)
96468 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
96469  /* this is a fixmap remnant, see fixmap.h */
96470  #define VMALLOC_END    (TMPALIAS_MAP_START)
96471  #endif
96472 --- linux-2.6.0-test6/include/asm-parisc/processor.h    2003-09-27 18:57:47.000000000 -0700
96473 +++ 25/include/asm-parisc/processor.h   2003-10-05 00:33:24.000000000 -0700
96474 @@ -36,10 +36,18 @@
96475  #define current_text_addr() ({ void *pc; __asm__("\n\tblr 0,%0\n\tnop":"=r" (pc)); pc; })
96476  
96477  #define TASK_SIZE               (current->thread.task_size)
96478 -#define DEFAULT_TASK_SIZE       (0xFFF00000UL)
96479 -
96480  #define TASK_UNMAPPED_BASE      (current->thread.map_base)
96481 -#define DEFAULT_MAP_BASE        (0x40000000UL)
96482 +
96483 +#define DEFAULT_TASK_SIZE32    (0xFFF00000UL)
96484 +#define DEFAULT_MAP_BASE32     (0x40000000UL)
96485 +
96486 +#ifdef __LP64__
96487 +#define DEFAULT_TASK_SIZE       (MAX_ADDRESS-0xf000000)
96488 +#define DEFAULT_MAP_BASE        (0x200000000UL)
96489 +#else
96490 +#define DEFAULT_TASK_SIZE      DEFAULT_TASK_SIZE32
96491 +#define DEFAULT_MAP_BASE       DEFAULT_MAP_BASE32
96492 +#endif
96493  
96494  #ifndef __ASSEMBLY__
96495  
96496 @@ -247,8 +255,18 @@ on downward growing arches, it looks lik
96497   *
96498   * Note that the S/390 people took the easy way out and hacked their
96499   * GCC to make the stack grow downwards.
96500 + *
96501 + * Final Note: For entry from syscall, the W (wide) bit of the PSW
96502 + * is stuffed into the lowest bit of the user sp (%r30), so we fill
96503 + * it in here from the current->personality
96504   */
96505  
96506 +#ifdef __LP64__
96507 +#define USER_WIDE_MODE (personality(current->personality) == PER_LINUX)
96508 +#else
96509 +#define USER_WIDE_MODE 0
96510 +#endif
96511 +
96512  #define start_thread(regs, new_pc, new_sp) do {                \
96513         elf_addr_t *sp = (elf_addr_t *)new_sp;          \
96514         __u32 spaceid = (__u32)current->mm->context;    \
96515 @@ -266,12 +284,12 @@ on downward growing arches, it looks lik
96516         regs->sr[5] = spaceid;                          \
96517         regs->sr[6] = spaceid;                          \
96518         regs->sr[7] = spaceid;                          \
96519 -       regs->gr[ 0] = USER_PSW;                        \
96520 +       regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \
96521         regs->fr[ 0] = 0LL;                             \
96522         regs->fr[ 1] = 0LL;                             \
96523         regs->fr[ 2] = 0LL;                             \
96524         regs->fr[ 3] = 0LL;                             \
96525 -       regs->gr[30] = ((unsigned long)sp + 63) &~ 63;  \
96526 +       regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \
96527         regs->gr[31] = pc;                              \
96528                                                         \
96529         get_user(regs->gr[25], (argv - 1));             \
96530 @@ -299,8 +317,6 @@ static inline unsigned long get_wchan(st
96531  #define KSTK_EIP(tsk)  ((tsk)->thread.regs.iaoq[0])
96532  #define KSTK_ESP(tsk)  ((tsk)->thread.regs.gr[30])
96533  
96534 -#endif /* __ASSEMBLY__ */
96535 -
96536  #ifdef  CONFIG_PA20
96537  #define ARCH_HAS_PREFETCH
96538  extern inline void prefetch(const void *addr)
96539 @@ -317,4 +333,6 @@ extern inline void prefetchw(const void 
96540  
96541  #define cpu_relax()    barrier()
96542  
96543 +#endif /* __ASSEMBLY__ */
96544 +
96545  #endif /* __ASM_PARISC_PROCESSOR_H */
96546 --- linux-2.6.0-test6/include/asm-parisc/rt_sigframe.h  2003-06-14 12:18:08.000000000 -0700
96547 +++ 25/include/asm-parisc/rt_sigframe.h 2003-10-05 00:33:24.000000000 -0700
96548 @@ -13,7 +13,20 @@ struct rt_sigframe {
96549   * which Linux/parisc uses is sp-20 for the saved return pointer...)
96550   * Then, the stack pointer must be rounded to a cache line (64 bytes).
96551   */
96552 +#define SIGFRAME32             64
96553 +#define FUNCTIONCALLFRAME32    48
96554 +#define PARISC_RT_SIGFRAME_SIZE32                                      \
96555 +       (((sizeof(struct rt_sigframe) + FUNCTIONCALLFRAME32) + SIGFRAME32) & -SIGFRAME32)
96556 +
96557 +#ifdef __LP64__
96558 +#define        SIGFRAME                128
96559 +#define FUNCTIONCALLFRAME      96
96560  #define PARISC_RT_SIGFRAME_SIZE                                        \
96561 -       (((sizeof(struct rt_sigframe) + 48) + 63) & -64)
96562 +       (((sizeof(struct rt_sigframe) + FUNCTIONCALLFRAME) + SIGFRAME) & -SIGFRAME)
96563 +#else
96564 +#define        SIGFRAME                SIGFRAME32
96565 +#define FUNCTIONCALLFRAME      FUNCTIONCALLFRAME32
96566 +#define PARISC_RT_SIGFRAME_SIZE        PARISC_RT_SIGFRAME_SIZE32
96567 +#endif
96568  
96569  #endif
96570 --- linux-2.6.0-test6/include/asm-parisc/tlbflush.h     2003-06-14 12:18:51.000000000 -0700
96571 +++ 25/include/asm-parisc/tlbflush.h    2003-10-05 00:33:24.000000000 -0700
96572 @@ -3,6 +3,7 @@
96573  
96574  /* TLB flushing routines.... */
96575  
96576 +#include <linux/config.h>
96577  #include <linux/mm.h>
96578  #include <asm/mmu_context.h>
96579  
96580 --- linux-2.6.0-test6/include/asm-ppc64/cacheflush.h    2003-06-14 12:17:57.000000000 -0700
96581 +++ 25/include/asm-ppc64/cacheflush.h   2003-10-05 00:33:24.000000000 -0700
96582 @@ -14,12 +14,22 @@
96583  #define flush_cache_range(vma, start, end)     do { } while (0)
96584  #define flush_cache_page(vma, vmaddr)          do { } while (0)
96585  #define flush_icache_page(vma, page)           do { } while (0)
96586 +#define flush_cache_vmap(start, end)           do { } while (0)
96587 +#define flush_cache_vunmap(start, end)         do { } while (0)
96588  
96589  extern void flush_dcache_page(struct page *page);
96590  extern void flush_icache_range(unsigned long, unsigned long);
96591  extern void flush_icache_user_range(struct vm_area_struct *vma,
96592                                     struct page *page, unsigned long addr,
96593                                     int len);
96594 +
96595 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
96596 +do { memcpy(dst, src, len); \
96597 +     flush_icache_user_range(vma, page, vaddr, len); \
96598 +} while (0)
96599 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
96600 +       memcpy(dst, src, len)
96601 +
96602  extern void __flush_dcache_icache(void *page_va);
96603  
96604  #endif /* _PPC64_CACHEFLUSH_H */
96605 --- linux-2.6.0-test6/include/asm-ppc64/elf.h   2003-06-14 12:18:29.000000000 -0700
96606 +++ 25/include/asm-ppc64/elf.h  2003-10-05 00:33:24.000000000 -0700
96607 @@ -128,11 +128,6 @@ static inline int dump_task_regs(struct 
96608  extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *); 
96609  #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
96610  
96611 -#ifdef CONFIG_SMP
96612 -extern void dump_smp_unlazy_fpu(void);
96613 -#define ELF_CORE_SYNC dump_smp_unlazy_fpu
96614 -#endif
96615 -
96616  #endif
96617  
96618  /* This yields a mask that user programs can use to figure out what
96619 --- linux-2.6.0-test6/include/asm-ppc64/numnodes.h      2003-06-14 12:18:30.000000000 -0700
96620 +++ 25/include/asm-ppc64/numnodes.h     2003-10-05 00:34:38.000000000 -0700
96621 @@ -1,6 +1,7 @@
96622  #ifndef _ASM_MAX_NUMNODES_H
96623  #define _ASM_MAX_NUMNODES_H
96624  
96625 -#define MAX_NUMNODES 16
96626 +/* Max 16 Nodes */
96627 +#define NODES_SHIFT    4
96628  
96629  #endif /* _ASM_MAX_NUMNODES_H */
96630 --- linux-2.6.0-test6/include/asm-ppc64/pgtable.h       2003-09-27 18:57:47.000000000 -0700
96631 +++ 25/include/asm-ppc64/pgtable.h      2003-10-05 00:33:24.000000000 -0700
96632 @@ -45,7 +45,6 @@
96633   * Define the address range of the vmalloc VM area.
96634   */
96635  #define VMALLOC_START (0xD000000000000000)
96636 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
96637  #define VMALLOC_END   (VMALLOC_START + VALID_EA_BITS)
96638  
96639  /*
96640 --- linux-2.6.0-test6/include/asm-ppc64/semaphore.h     2003-09-27 18:57:47.000000000 -0700
96641 +++ 25/include/asm-ppc64/semaphore.h    2003-10-05 00:34:19.000000000 -0700
96642 @@ -22,6 +22,7 @@ struct semaphore {
96643          * sleeping on `wait'.
96644          */
96645         atomic_t count;
96646 +       int sleepers;
96647         wait_queue_head_t wait;
96648  #ifdef WAITQUEUE_DEBUG
96649         long __magic;
96650 @@ -37,6 +38,7 @@ struct semaphore {
96651  
96652  #define __SEMAPHORE_INITIALIZER(name, count) \
96653         { ATOMIC_INIT(count), \
96654 +         0, \
96655           __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
96656           __SEM_DEBUG_INIT(name) }
96657  
96658 @@ -52,6 +54,7 @@ struct semaphore {
96659  static inline void sema_init (struct semaphore *sem, int val)
96660  {
96661         atomic_set(&sem->count, val);
96662 +       sem->sleepers = 0;
96663         init_waitqueue_head(&sem->wait);
96664  #ifdef WAITQUEUE_DEBUG
96665         sem->__magic = (long)&sem->__magic;
96666 --- linux-2.6.0-test6/include/asm-ppc/cacheflush.h      2003-06-14 12:18:29.000000000 -0700
96667 +++ 25/include/asm-ppc/cacheflush.h     2003-10-05 00:33:24.000000000 -0700
96668 @@ -24,12 +24,21 @@
96669  #define flush_cache_range(vma, a, b)   do { } while (0)
96670  #define flush_cache_page(vma, p)       do { } while (0)
96671  #define flush_icache_page(vma, page)   do { } while (0)
96672 +#define flush_cache_vmap(start, end)   do { } while (0)
96673 +#define flush_cache_vunmap(start, end) do { } while (0)
96674  
96675  extern void flush_dcache_page(struct page *page);
96676  extern void flush_icache_range(unsigned long, unsigned long);
96677  extern void flush_icache_user_range(struct vm_area_struct *vma,
96678                 struct page *page, unsigned long addr, int len);
96679  
96680 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
96681 +do { memcpy(dst, src, len); \
96682 +     flush_icache_user_range(vma, page, vaddr, len); \
96683 +} while (0)
96684 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
96685 +       memcpy(dst, src, len)
96686 +
96687  extern void __flush_dcache_icache(void *page_va);
96688  extern void __flush_dcache_icache_phys(unsigned long physaddr);
96689  
96690 --- linux-2.6.0-test6/include/asm-ppc/highmem.h 2003-09-27 18:57:47.000000000 -0700
96691 +++ 25/include/asm-ppc/highmem.h        2003-10-05 00:33:24.000000000 -0700
96692 @@ -132,6 +132,8 @@ static inline struct page *kmap_atomic_t
96693         return pte_page(kmap_pte[idx]);
96694  }
96695  
96696 +#define flush_cache_kmaps()    flush_cache_all()
96697 +
96698  #endif /* __KERNEL__ */
96699  
96700  #endif /* _ASM_HIGHMEM_H */
96701 --- linux-2.6.0-test6/include/asm-ppc/pgtable.h 2003-09-27 18:57:47.000000000 -0700
96702 +++ 25/include/asm-ppc/pgtable.h        2003-10-05 00:33:24.000000000 -0700
96703 @@ -129,7 +129,6 @@ extern unsigned long ioremap_bot, iorema
96704  #else
96705  #define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
96706  #endif
96707 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
96708  #define VMALLOC_END    ioremap_bot
96709  
96710  /*
96711 --- linux-2.6.0-test6/include/asm-ppc/zorro.h   2003-06-14 12:18:30.000000000 -0700
96712 +++ 25/include/asm-ppc/zorro.h  2003-10-05 00:33:24.000000000 -0700
96713 @@ -27,4 +27,4 @@ extern void *__ioremap(unsigned long add
96714  #define z_ioremap ioremap
96715  #define z_iounmap iounmap
96716  
96717 -#endif /* _ASM_ZORRO_H */
96718 +#endif /* _ASM_PPC_ZORRO_H */
96719 --- linux-2.6.0-test6/include/asm-s390/cacheflush.h     2003-06-14 12:18:51.000000000 -0700
96720 +++ 25/include/asm-s390/cacheflush.h    2003-10-05 00:33:24.000000000 -0700
96721 @@ -13,5 +13,12 @@
96722  #define flush_icache_range(start, end)         do { } while (0)
96723  #define flush_icache_page(vma,pg)              do { } while (0)
96724  #define flush_icache_user_range(vma,pg,adr,len)        do { } while (0)
96725 +#define flush_cache_vmap(start, end)           do { } while (0)
96726 +#define flush_cache_vunmap(start, end)         do { } while (0)
96727 +
96728 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
96729 +       memcpy(dst, src, len)
96730 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
96731 +       memcpy(dst, src, len)
96732  
96733  #endif /* _S390_CACHEFLUSH_H */
96734 --- linux-2.6.0-test6/include/asm-s390/pgtable.h        2003-06-14 12:18:30.000000000 -0700
96735 +++ 25/include/asm-s390/pgtable.h       2003-10-05 00:33:24.000000000 -0700
96736 @@ -117,7 +117,6 @@ extern char empty_zero_page[PAGE_SIZE];
96737  #define VMALLOC_OFFSET  (8*1024*1024)
96738  #define VMALLOC_START   (((unsigned long) high_memory + VMALLOC_OFFSET) \
96739                          & ~(VMALLOC_OFFSET-1))
96740 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
96741  #ifndef __s390x__
96742  # define VMALLOC_END     (0x7fffffffL)
96743  #else /* __s390x__ */
96744 --- linux-2.6.0-test6/include/asm-sh/cacheflush.h       2003-07-02 14:53:18.000000000 -0700
96745 +++ 25/include/asm-sh/cacheflush.h      2003-10-05 00:33:24.000000000 -0700
96746 @@ -10,4 +10,14 @@ extern void __flush_purge_region(void *s
96747  /* Flush (invalidate only) a region (smaller than a page) */
96748  extern void __flush_invalidate_region(void *start, int size);
96749  
96750 +#define flush_cache_vmap(start, end)           flush_cache_all()
96751 +#define flush_cache_vunmap(start, end)         flush_cache_all()
96752 +
96753 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
96754 +do { memcpy(dst, src, len); \
96755 +     flush_icache_user_range(vma, page, vaddr, len); \
96756 +} while (0)
96757 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
96758 +       memcpy(dst, src, len)
96759 +
96760  #endif /* __ASM_SH_CACHEFLUSH_H */
96761 --- linux-2.6.0-test6/include/asm-sh/mmzone.h   2003-07-02 14:53:18.000000000 -0700
96762 +++ 25/include/asm-sh/mmzone.h  2003-10-05 00:34:40.000000000 -0700
96763 @@ -10,14 +10,14 @@
96764  
96765  #include <linux/config.h>
96766  
96767 +#ifdef CONFIG_DISCONTIGMEM
96768 +
96769  /* Currently, just for HP690 */
96770  #define PHYSADDR_TO_NID(phys)  ((((phys) - __MEMORY_START) >= 0x01000000)?1:0)
96771 -#define NR_NODES 2
96772  
96773 -extern pg_data_t discontig_page_data[NR_NODES];
96774 -extern bootmem_data_t discontig_node_bdata[NR_NODES];
96775 +extern pg_data_t discontig_page_data[MAX_NUMNODES];
96776 +extern bootmem_data_t discontig_node_bdata[MAX_NUMNODES];
96777  
96778 -#ifdef CONFIG_DISCONTIGMEM
96779  /*
96780   * Following are macros that each numa implmentation must define.
96781   */
96782 @@ -46,7 +46,7 @@ static inline int is_valid_page(struct p
96783  {
96784         unsigned int i;
96785  
96786 -       for (i = 0; i < NR_NODES; i++) {
96787 +       for (i = 0; i < MAX_NUMNODES; i++) {
96788                 if (page >= NODE_MEM_MAP(i) &&
96789                     page < NODE_MEM_MAP(i) + NODE_DATA(i)->node_size)
96790                         return 1;
96791 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
96792 +++ 25/include/asm-sh/numnodes.h        2003-10-05 00:34:40.000000000 -0700
96793 @@ -0,0 +1,7 @@
96794 +#ifndef _ASM_MAX_NUMNODES_H
96795 +#define _ASM_MAX_NUMNODES_H
96796 +
96797 +/* Max 2 Nodes */
96798 +#define NODES_SHIFT    1
96799 +
96800 +#endif /* _ASM_MAX_NUMNODES_H */
96801 --- linux-2.6.0-test6/include/asm-sh/pgtable.h  2003-07-02 14:53:18.000000000 -0700
96802 +++ 25/include/asm-sh/pgtable.h 2003-10-05 00:33:24.000000000 -0700
96803 @@ -51,7 +51,6 @@ extern unsigned long empty_zero_page[102
96804   * Currently only 4-enty (16kB) is used (see arch/sh/mm/cache.c)
96805   */
96806  #define VMALLOC_START  (P3SEG+0x00100000)
96807 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
96808  #define VMALLOC_END    P4SEG
96809  
96810  /*                     0x001     WT-bit on SH-4, 0 on SH-3 */
96811 --- linux-2.6.0-test6/include/asm-sparc64/cacheflush.h  2003-06-14 12:18:35.000000000 -0700
96812 +++ 25/include/asm-sparc64/cacheflush.h 2003-10-05 00:33:24.000000000 -0700
96813 @@ -33,21 +33,17 @@ extern void flush_dcache_page_all(struct
96814  
96815  extern void __flush_dcache_range(unsigned long start, unsigned long end);
96816  
96817 -extern void __flush_cache_all(void);
96818 -
96819 -#ifndef CONFIG_SMP
96820 -
96821 -#define flush_cache_all()      __flush_cache_all()
96822 -
96823 -#else /* CONFIG_SMP */
96824 -
96825 -extern void smp_flush_cache_all(void);
96826 -
96827 -#endif /* ! CONFIG_SMP */
96828 -
96829  #define flush_icache_page(vma, pg)     do { } while(0)
96830  #define flush_icache_user_range(vma,pg,adr,len)        do { } while (0)
96831  
96832 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
96833 +       memcpy(dst, src, len)
96834 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
96835 +       memcpy(dst, src, len)
96836 +
96837  extern void flush_dcache_page(struct page *page);
96838  
96839 +#define flush_cache_vmap(start, end)           do { } while (0)
96840 +#define flush_cache_vunmap(start, end)         do { } while (0)
96841 +
96842  #endif /* _SPARC64_CACHEFLUSH_H */
96843 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
96844 +++ 25/include/asm-sparc64/lockmeter.h  2003-10-05 00:36:40.000000000 -0700
96845 @@ -0,0 +1,45 @@
96846 +/*
96847 + * Copyright (C) 2000 Anton Blanchard (anton@linuxcare.com)
96848 + * Copyright (C) 2003 David S. Miller (davem@redhat.com)
96849 + */
96850 +
96851 +#ifndef _SPARC64_LOCKMETER_H
96852 +#define _SPARC64_LOCKMETER_H
96853 +
96854 +#include <linux/smp.h>
96855 +#include <asm/spinlock.h>
96856 +#include <asm/timer.h>
96857 +#include <asm/timex.h>
96858 +
96859 +/* Actually, this is not the CPU frequency by the system tick
96860 + * frequency which is good enough for lock metering.
96861 + */
96862 +#define CPU_CYCLE_FREQUENCY    (timer_tick_offset * HZ)
96863 +#define THIS_CPU_NUMBER                smp_processor_id()
96864 +
96865 +#define PUT_INDEX(lock_ptr,indexv)     (lock_ptr)->index = (indexv)
96866 +#define GET_INDEX(lock_ptr)            (lock_ptr)->index
96867 +
96868 +#define PUT_RWINDEX(rwlock_ptr,indexv) (rwlock_ptr)->index = (indexv)
96869 +#define GET_RWINDEX(rwlock_ptr)        (rwlock_ptr)->index
96870 +#define PUT_RW_CPU(rwlock_ptr,cpuv)    (rwlock_ptr)->cpu = (cpuv)
96871 +#define GET_RW_CPU(rwlock_ptr)         (rwlock_ptr)->cpu
96872 +
96873 +#define RWLOCK_READERS(rwlock_ptr)     rwlock_readers(rwlock_ptr)
96874 +
96875 +extern inline int rwlock_readers(rwlock_t *rwlock_ptr)
96876 +{
96877 +       signed int tmp = rwlock_ptr->lock;
96878 +
96879 +       if (tmp > 0)
96880 +               return tmp;
96881 +       else
96882 +               return 0;
96883 +}
96884 +
96885 +#define RWLOCK_IS_WRITE_LOCKED(rwlock_ptr)     ((signed int)((rwlock_ptr)->lock) < 0)
96886 +#define RWLOCK_IS_READ_LOCKED(rwlock_ptr)      ((signed int)((rwlock_ptr)->lock) > 0)
96887 +
96888 +#define get_cycles64() get_cycles()
96889 +
96890 +#endif /* _SPARC64_LOCKMETER_H */
96891 --- linux-2.6.0-test6/include/asm-sparc64/pgtable.h     2003-06-14 12:17:56.000000000 -0700
96892 +++ 25/include/asm-sparc64/pgtable.h    2003-10-05 00:33:24.000000000 -0700
96893 @@ -30,7 +30,6 @@
96894  #define MODULES_LEN            0x000000007e000000
96895  #define MODULES_END            0x0000000080000000
96896  #define VMALLOC_START          0x0000000140000000
96897 -#define VMALLOC_VMADDR(x)      ((unsigned long)(x))
96898  #define VMALLOC_END            0x0000000200000000
96899  #define LOW_OBP_ADDRESS                0x00000000f0000000
96900  #define HI_OBP_ADDRESS         0x0000000100000000
96901 --- linux-2.6.0-test6/include/asm-sparc64/spinlock.h    2003-06-26 22:07:26.000000000 -0700
96902 +++ 25/include/asm-sparc64/spinlock.h   2003-10-05 00:36:40.000000000 -0700
96903 @@ -30,15 +30,23 @@
96904  
96905  #ifndef CONFIG_DEBUG_SPINLOCK
96906  
96907 -typedef unsigned char spinlock_t;
96908 -#define SPIN_LOCK_UNLOCKED     0
96909 +typedef struct {
96910 +       unsigned char lock;
96911 +       unsigned int  index;
96912 +} spinlock_t;
96913  
96914 -#define spin_lock_init(lock)   (*((unsigned char *)(lock)) = 0)
96915 -#define spin_is_locked(lock)   (*((volatile unsigned char *)(lock)) != 0)
96916 +#ifdef CONFIG_LOCKMETER
96917 +#define SPIN_LOCK_UNLOCKED     (spinlock_t) {0, 0}
96918 +#else
96919 +#define SPIN_LOCK_UNLOCKED     (spinlock_t) { 0 }
96920 +#endif
96921  
96922 -#define spin_unlock_wait(lock) \
96923 +#define spin_lock_init(__lock) do { *(__lock) = SPIN_LOCK_UNLOCKED; } while(0)
96924 +#define spin_is_locked(__lock) (*((volatile unsigned char *)(&((__lock)->lock))) != 0)
96925 +
96926 +#define spin_unlock_wait(__lock)       \
96927  do {   membar("#LoadLoad");    \
96928 -} while(*((volatile unsigned char *)lock))
96929 +} while(*((volatile unsigned char *)(&(((spinlock_t *)__lock)->lock))))
96930  
96931  static __inline__ void _raw_spin_lock(spinlock_t *lock)
96932  {
96933 @@ -109,18 +117,34 @@ extern int _spin_trylock (spinlock_t *lo
96934  
96935  #ifndef CONFIG_DEBUG_SPINLOCK
96936  
96937 -typedef unsigned int rwlock_t;
96938 -#define RW_LOCK_UNLOCKED       0
96939 -#define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0)
96940 -#define rwlock_is_locked(x) (*(x) != RW_LOCK_UNLOCKED)
96941 +#ifdef CONFIG_LOCKMETER
96942 +typedef struct {
96943 +       unsigned int lock;
96944 +       unsigned int index;
96945 +       unsigned int cpu;
96946 +} rwlock_t;
96947 +#define RW_LOCK_UNLOCKED       (rwlock_t) { 0, 0, 0xff }
96948 +#else
96949 +typedef struct {
96950 +       unsigned int lock;
96951 +} rwlock_t;
96952 +#define RW_LOCK_UNLOCKED        (rwlock_t) { 0 }
96953 +#endif
96954 +
96955 +#define rwlock_init(lp)                do { *(lp) = RW_LOCK_UNLOCKED; } while(0)
96956 +#define rwlock_is_locked(x)    ((x)->lock != 0)
96957  
96958 +extern int __read_trylock(rwlock_t *);
96959  extern void __read_lock(rwlock_t *);
96960  extern void __read_unlock(rwlock_t *);
96961 +extern int __write_trylock(rwlock_t *);
96962  extern void __write_lock(rwlock_t *);
96963  extern void __write_unlock(rwlock_t *);
96964  
96965 +#define _raw_read_trylock(p)   __read_trylock(p)
96966  #define _raw_read_lock(p)      __read_lock(p)
96967  #define _raw_read_unlock(p)    __read_unlock(p)
96968 +#define _raw_write_trylock(p)  __write_trylock(p)
96969  #define _raw_write_lock(p)     __write_lock(p)
96970  #define _raw_write_unlock(p)   __write_unlock(p)
96971  
96972 --- linux-2.6.0-test6/include/asm-sparc64/tlbflush.h    2003-06-14 12:18:29.000000000 -0700
96973 +++ 25/include/asm-sparc64/tlbflush.h   2003-10-05 00:33:24.000000000 -0700
96974 @@ -70,7 +70,6 @@ extern void smp_flush_tlb_range(struct m
96975  extern void smp_flush_tlb_kernel_range(unsigned long start, unsigned long end);
96976  extern void smp_flush_tlb_page(struct mm_struct *mm, unsigned long page);
96977  
96978 -#define flush_cache_all()      smp_flush_cache_all()
96979  #define flush_tlb_all()                smp_flush_tlb_all()
96980  #define flush_tlb_mm(mm)       smp_flush_tlb_mm(mm)
96981  #define flush_tlb_range(vma, start, end) \
96982 --- linux-2.6.0-test6/include/asm-sparc64/unistd.h      2003-09-08 13:58:59.000000000 -0700
96983 +++ 25/include/asm-sparc64/unistd.h     2003-10-05 00:33:24.000000000 -0700
96984 @@ -285,7 +285,8 @@
96985  #define __NR_timer_getoverrun  264
96986  #define __NR_timer_delete      265
96987  #define __NR_timer_create      266
96988 -/* WARNING: You MAY NOT add syscall numbers larger than 266, since
96989 +/* #define __NR_vserver                267 Reserved for VSERVER */
96990 +/* WARNING: You MAY NOT add syscall numbers larger than 267, since
96991   *          all of the syscall tables in the Sparc kernel are
96992   *          sized to have 267 entries (starting at zero).  Therefore
96993   *          find a free slot in the 0-266 range.
96994 --- linux-2.6.0-test6/include/asm-sparc64/visasm.h      2003-06-14 12:17:58.000000000 -0700
96995 +++ 25/include/asm-sparc64/visasm.h     2003-10-05 00:33:24.000000000 -0700
96996 @@ -17,7 +17,8 @@
96997         andcc           %o5, (FPRS_FEF|FPRS_DU), %g0;   \
96998         be,pt           %icc, 297f;                     \
96999          sethi          %hi(297f), %g7;                 \
97000 -       ba,pt           %xcc, VISenter;                 \
97001 +       sethi           %hi(VISenter), %g1;             \
97002 +       jmpl            %g1 + %lo(VISenter), %g0;       \
97003          or             %g7, %lo(297f), %g7;            \
97004  297:   wr              %g0, FPRS_FEF, %fprs;           \
97005  
97006 @@ -32,7 +33,8 @@
97007         andcc           %o5, FPRS_FEF, %g0;             \
97008         be,pt           %icc, 297f;                     \
97009          sethi          %hi(298f), %g7;                 \
97010 -       ba,pt           %xcc, VISenterhalf;             \
97011 +       sethi           %hi(VISenterhalf), %g1;         \
97012 +       jmpl            %g1 + %lo(VISenterhalf), %g0;   \
97013          or             %g7, %lo(298f), %g7;            \
97014         clr             %o5;                            \
97015  297:   wr              %o5, FPRS_FEF, %fprs;           \
97016 @@ -48,7 +50,8 @@ static __inline__ void save_and_clear_fp
97017  "              andcc %%o5, %0, %%g0\n"
97018  "              be,pt %%icc, 299f\n"
97019  "               sethi %%hi(298f), %%g7\n"
97020 -"              ba VISenter     ! Note. This cannot be bp, as it may be too far from VISenter.\n"
97021 +"              sethi %%hi(VISenter), %%g1\n"
97022 +"              jmpl %%g1 + %%lo(VISenter), %%g0\n"
97023  "               or %%g7, %%lo(298f), %%g7\n"
97024  "      298:    wr %%g0, 0, %%fprs\n"
97025  "      299:\n"
97026 --- linux-2.6.0-test6/include/asm-sparc/cacheflush.h    2003-06-14 12:18:06.000000000 -0700
97027 +++ 25/include/asm-sparc/cacheflush.h   2003-10-05 00:33:24.000000000 -0700
97028 @@ -56,6 +56,11 @@ BTFIXUPDEF_CALL(void, flush_cache_page, 
97029  
97030  #define flush_icache_user_range(vma,pg,adr,len)        do { } while (0)
97031  
97032 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
97033 +       memcpy(dst, src, len)
97034 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
97035 +       memcpy(dst, src, len)
97036 +
97037  BTFIXUPDEF_CALL(void, __flush_page_to_ram, unsigned long)
97038  BTFIXUPDEF_CALL(void, flush_sig_insns, struct mm_struct *, unsigned long)
97039  
97040 @@ -66,4 +71,7 @@ extern void sparc_flush_page_to_ram(stru
97041  
97042  #define flush_dcache_page(page)                        sparc_flush_page_to_ram(page)
97043  
97044 +#define flush_cache_vmap(start, end)           flush_cache_all()
97045 +#define flush_cache_vunmap(start, end)         flush_cache_all()
97046 +
97047  #endif /* _SPARC_CACHEFLUSH_H */
97048 --- linux-2.6.0-test6/include/asm-sparc/highmem.h       2003-06-14 12:18:51.000000000 -0700
97049 +++ 25/include/asm-sparc/highmem.h      2003-10-05 00:33:24.000000000 -0700
97050 @@ -89,6 +89,8 @@ static inline struct page *kmap_atomic_t
97051         return pte_page(*pte);
97052  }
97053  
97054 +#define flush_cache_kmaps()    flush_cache_all()
97055 +
97056  #endif /* __KERNEL__ */
97057  
97058  #endif /* _ASM_HIGHMEM_H */
97059 --- linux-2.6.0-test6/include/asm-sparc/pgtable.h       2003-06-14 12:18:22.000000000 -0700
97060 +++ 25/include/asm-sparc/pgtable.h      2003-10-05 00:33:24.000000000 -0700
97061 @@ -101,8 +101,6 @@ BTFIXUPDEF_SIMM13(ptrs_per_pmd)
97062  BTFIXUPDEF_SIMM13(ptrs_per_pgd)
97063  BTFIXUPDEF_SIMM13(user_ptrs_per_pgd)
97064  
97065 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
97066 -
97067  #define pte_ERROR(e)   __builtin_trap()
97068  #define pmd_ERROR(e)   __builtin_trap()
97069  #define pgd_ERROR(e)   __builtin_trap()
97070 --- linux-2.6.0-test6/include/asm-sparc/unistd.h        2003-09-08 13:58:59.000000000 -0700
97071 +++ 25/include/asm-sparc/unistd.h       2003-10-05 00:33:24.000000000 -0700
97072 @@ -283,7 +283,8 @@
97073  #define __NR_timer_getoverrun  264
97074  #define __NR_timer_delete      265
97075  #define __NR_timer_create      266
97076 -/* WARNING: You MAY NOT add syscall numbers larger than 266, since
97077 +/* #define __NR_vserver                267 Reserved for VSERVER */
97078 +/* WARNING: You MAY NOT add syscall numbers larger than 267, since
97079   *          all of the syscall tables in the Sparc kernel are
97080   *          sized to have 267 entries (starting at zero).  Therefore
97081   *          find a free slot in the 0-266 range.
97082 --- linux-2.6.0-test6/include/asm-um/archparam-i386.h   2003-06-14 12:18:30.000000000 -0700
97083 +++ 25/include/asm-um/archparam-i386.h  2003-10-05 00:34:32.000000000 -0700
97084 @@ -56,6 +56,65 @@ typedef elf_greg_t elf_gregset_t[ELF_NGR
97085         pr_reg[16] = PT_REGS_SS(regs);          \
97086  } while(0);
97087  
97088 +#define VSYSCALL_BASE  (__fix_to_virt(FIX_VSYSCALL))
97089 +#define VSYSCALL_EHDR  ((const struct elfhdr *) VSYSCALL_BASE)
97090 +#define VSYSCALL_ENTRY ((unsigned long) &__kernel_vsyscall)
97091 +extern void *__kernel_vsyscall;
97092 +
97093 +/*
97094 + * Architecture-neutral AT_ values in 0-17, leave some room
97095 + * for more of them, start the x86-specific ones at 32.
97096 + */
97097 +#define AT_SYSINFO             32
97098 +#define AT_SYSINFO_EHDR                33
97099 +
97100 +#define ARCH_DLINFO                                            \
97101 +do {                                                           \
97102 +               NEW_AUX_ENT(AT_SYSINFO, VSYSCALL_ENTRY);        \
97103 +               NEW_AUX_ENT(AT_SYSINFO_EHDR, VSYSCALL_BASE);    \
97104 +} while (0)
97105 +
97106 +/*
97107 + * These macros parameterize elf_core_dump in fs/binfmt_elf.c to write out
97108 + * extra segments containing the vsyscall DSO contents.  Dumping its
97109 + * contents makes post-mortem fully interpretable later without matching up
97110 + * the same kernel and hardware config to see what PC values meant.
97111 + * Dumping its extra ELF program headers includes all the other information
97112 + * a debugger needs to easily find how the vsyscall DSO was being used.
97113 + */
97114 +#define ELF_CORE_EXTRA_PHDRS           (VSYSCALL_EHDR->e_phnum)
97115 +#define ELF_CORE_WRITE_EXTRA_PHDRS                                           \
97116 +do {                                                                         \
97117 +       const struct elf_phdr *const vsyscall_phdrs =                         \
97118 +               (const struct elf_phdr *) (VSYSCALL_BASE                      \
97119 +                                          + VSYSCALL_EHDR->e_phoff);         \
97120 +       int i;                                                                \
97121 +       Elf32_Off ofs = 0;                                                    \
97122 +       for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) {                        \
97123 +               struct elf_phdr phdr = vsyscall_phdrs[i];                     \
97124 +               if (phdr.p_type == PT_LOAD) {                                 \
97125 +                       ofs = phdr.p_offset = offset;                         \
97126 +                       offset += phdr.p_filesz;                              \
97127 +               }                                                             \
97128 +               else                                                          \
97129 +                       phdr.p_offset += ofs;                                 \
97130 +               phdr.p_paddr = 0; /* match other core phdrs */                \
97131 +               DUMP_WRITE(&phdr, sizeof(phdr));                              \
97132 +       }                                                                     \
97133 +} while (0)
97134 +#define ELF_CORE_WRITE_EXTRA_DATA                                            \
97135 +do {                                                                         \
97136 +       const struct elf_phdr *const vsyscall_phdrs =                         \
97137 +               (const struct elf_phdr *) (VSYSCALL_BASE                      \
97138 +                                          + VSYSCALL_EHDR->e_phoff);         \
97139 +       int i;                                                                \
97140 +       for (i = 0; i < VSYSCALL_EHDR->e_phnum; ++i) {                        \
97141 +               if (vsyscall_phdrs[i].p_type == PT_LOAD)                      \
97142 +                       DUMP_WRITE((void *) vsyscall_phdrs[i].p_vaddr,        \
97143 +                                  vsyscall_phdrs[i].p_filesz);               \
97144 +       }                                                                     \
97145 +} while (0)
97146 +
97147  /********* Bits for asm-um/delay.h **********/
97148  
97149  typedef unsigned long um_udelay_t;
97150 --- linux-2.6.0-test6/include/asm-um/common.lds.S       2003-06-14 12:18:00.000000000 -0700
97151 +++ 25/include/asm-um/common.lds.S      2003-10-05 00:34:32.000000000 -0700
97152 @@ -1,3 +1,5 @@
97153 +#include <asm-generic/vmlinux.lds.h>
97154 +
97155    .fini      : { *(.fini)    } =0x9090
97156    _etext = .;
97157    PROVIDE (etext = .);
97158 @@ -67,6 +69,10 @@
97159    }
97160    __initcall_end = .;
97161  
97162 +  __con_initcall_start = .;
97163 +  .con_initcall.init : { *(.con_initcall.init) }
97164 +  __con_initcall_end = .;
97165 +
97166    __uml_initcall_start = .;
97167    .uml.initcall.init : { *(.uml.initcall.init) }
97168    __uml_initcall_end = .;
97169 @@ -80,7 +86,33 @@
97170    .uml.exitcall : { *(.uml.exitcall.exit) }
97171    __uml_exitcall_end = .;
97172  
97173 -  . = ALIGN(4096);
97174 +  . = ALIGN(4);
97175 +  __alt_instructions = .;
97176 +  .altinstructions : { *(.altinstructions) } 
97177 +  __alt_instructions_end = .; 
97178 +  .altinstr_replacement : { *(.altinstr_replacement) } 
97179 +  /* .exit.text is discard at runtime, not link time, to deal with references
97180 +     from .altinstructions and .eh_frame */
97181 +  .exit.text : { *(.exit.text) }
97182 +  .exit.data : { *(.exit.data) }
97183
97184 +  __preinit_array_start = .;
97185 +  .preinit_array : { *(.preinit_array) }
97186 +  __preinit_array_end = .;
97187 +  __init_array_start = .;
97188 +  .init_array : { *(.init_array) }
97189 +  __init_array_end = .;
97190 +  __fini_array_start = .;
97191 +  .fini_array : { *(.fini_array) }
97192 +  __fini_array_end = .;
97193 +
97194 +   . = ALIGN(4096);
97195    __initramfs_start = .;
97196    .init.ramfs : { *(.init.ramfs) }
97197    __initramfs_end = .;
97198 +
97199 +  /* Sections to be discarded */
97200 +  /DISCARD/ : {
97201 +       *(.exitcall.exit)
97202 +  }
97203
97204 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
97205 +++ 25/include/asm-um/cpufeature.h      2003-10-05 00:34:32.000000000 -0700
97206 @@ -0,0 +1,6 @@
97207 +#ifndef __UM_CPUFEATURE_H
97208 +#define __UM_CPUFEATURE_H
97209 +
97210 +#include "asm/arch/cpufeature.h"
97211 +
97212 +#endif
97213 --- linux-2.6.0-test6/include/asm-um/current.h  2003-06-14 12:17:57.000000000 -0700
97214 +++ 25/include/asm-um/current.h 2003-10-05 00:34:32.000000000 -0700
97215 @@ -16,8 +16,10 @@ struct thread_info;
97216  #define CURRENT_THREAD(dummy) (((unsigned long) &dummy) & \
97217                                 (PAGE_MASK << CONFIG_KERNEL_STACK_ORDER))
97218  
97219 -#define current ({ int dummy; \
97220 -                   ((struct thread_info *) CURRENT_THREAD(dummy))->task; })
97221 +#define current_thread \
97222 +       ({ int dummy; ((struct thread_info *) CURRENT_THREAD(dummy)); })
97223 +
97224 +#define current (current_thread->task)
97225  
97226  #endif /* __ASSEMBLY__ */
97227  
97228 --- linux-2.6.0-test6/include/asm-um/fixmap.h   2003-06-14 12:18:33.000000000 -0700
97229 +++ 25/include/asm-um/fixmap.h  2003-10-05 00:34:32.000000000 -0700
97230 @@ -34,6 +34,7 @@ enum fixed_addresses {
97231         FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
97232         FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
97233  #endif
97234 +       FIX_VSYSCALL,
97235         __end_of_fixed_addresses
97236  };
97237  
97238 @@ -63,6 +64,13 @@ extern unsigned long get_kmem_end(void);
97239  #define __fix_to_virt(x)       (FIXADDR_TOP - ((x) << PAGE_SHIFT))
97240  #define __virt_to_fix(x)      ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
97241  
97242 +/*
97243 + * This is the range that is readable by user mode, and things
97244 + * acting like user mode such as get_user_pages.
97245 + */
97246 +#define FIXADDR_USER_START     (__fix_to_virt(FIX_VSYSCALL))
97247 +#define FIXADDR_USER_END       (FIXADDR_USER_START + PAGE_SIZE)
97248 +
97249  extern void __this_fixmap_does_not_exist(void);
97250  
97251  /*
97252 --- linux-2.6.0-test6/include/asm-um/irq.h      2003-06-14 12:18:49.000000000 -0700
97253 +++ 25/include/asm-um/irq.h     2003-10-05 00:34:32.000000000 -0700
97254 @@ -1,15 +1,6 @@
97255  #ifndef __UM_IRQ_H
97256  #define __UM_IRQ_H
97257  
97258 -/* The i386 irq.h has a struct task_struct in a prototype without including
97259 - * sched.h.  This forward declaration kills the resulting warning.
97260 - */
97261 -struct task_struct;
97262 -
97263 -#include "asm/ptrace.h"
97264 -
97265 -#undef NR_IRQS
97266 -
97267  #define TIMER_IRQ              0
97268  #define UMN_IRQ                        1
97269  #define CONSOLE_IRQ            2
97270 @@ -28,8 +19,4 @@ struct task_struct;
97271  #define LAST_IRQ XTERM_IRQ
97272  #define NR_IRQS (LAST_IRQ + 1)
97273  
97274 -extern int um_request_irq(unsigned int irq, int fd, int type,
97275 -                         void (*handler)(int, void *, struct pt_regs *),
97276 -                         unsigned long irqflags,  const char * devname,
97277 -                         void *dev_id);
97278  #endif
97279 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
97280 +++ 25/include/asm-um/local.h   2003-10-05 00:34:32.000000000 -0700
97281 @@ -0,0 +1,6 @@
97282 +#ifndef __UM_LOCAL_H
97283 +#define __UM_LOCAL_H
97284 +
97285 +#include "asm/arch/local.h"
97286 +
97287 +#endif
97288 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
97289 +++ 25/include/asm-um/module-generic.h  2003-10-05 00:34:32.000000000 -0700
97290 @@ -0,0 +1,6 @@
97291 +#ifndef __UM_MODULE_GENERIC_H
97292 +#define __UM_MODULE_GENERIC_H
97293 +
97294 +#include "asm/arch/module.h"
97295 +
97296 +#endif
97297 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
97298 +++ 25/include/asm-um/module-i386.h     2003-10-05 00:34:32.000000000 -0700
97299 @@ -0,0 +1,13 @@
97300 +#ifndef __UM_MODULE_I386_H
97301 +#define __UM_MODULE_I386_H
97302 +
97303 +/* UML is simple */
97304 +struct mod_arch_specific
97305 +{
97306 +};
97307 +
97308 +#define Elf_Shdr Elf32_Shdr
97309 +#define Elf_Sym Elf32_Sym
97310 +#define Elf_Ehdr Elf32_Ehdr
97311 +
97312 +#endif
97313 --- linux-2.6.0-test6/include/asm-um/page.h     2003-06-14 12:18:23.000000000 -0700
97314 +++ 25/include/asm-um/page.h    2003-10-05 00:34:32.000000000 -0700
97315 @@ -4,7 +4,6 @@
97316  struct page;
97317  
97318  #include "asm/arch/page.h"
97319 -#include "asm/bug.h"
97320  
97321  #undef __pa
97322  #undef __va
97323 --- linux-2.6.0-test6/include/asm-um/pgtable.h  2003-06-14 12:18:52.000000000 -0700
97324 +++ 25/include/asm-um/pgtable.h 2003-10-05 00:34:32.000000000 -0700
97325 @@ -69,7 +69,6 @@ extern unsigned long high_physmem;
97326  
97327  #define VMALLOC_OFFSET (__va_space)
97328  #define VMALLOC_START  (((unsigned long) high_physmem + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
97329 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
97330  
97331  #ifdef CONFIG_HIGHMEM
97332  # define VMALLOC_END   (PKMAP_BASE-2*PAGE_SIZE)
97333 @@ -79,12 +78,13 @@ extern unsigned long high_physmem;
97334  
97335  #define _PAGE_PRESENT  0x001
97336  #define _PAGE_NEWPAGE  0x002
97337 -#define _PAGE_PROTNONE 0x004   /* If not present */
97338 -#define _PAGE_RW       0x008
97339 -#define _PAGE_USER     0x010
97340 -#define _PAGE_ACCESSED 0x020
97341 -#define _PAGE_DIRTY    0x040
97342 -#define _PAGE_NEWPROT   0x080
97343 +#define _PAGE_NEWPROT   0x004
97344 +#define _PAGE_FILE     0x008   /* set:pagecache unset:swap */
97345 +#define _PAGE_PROTNONE 0x010   /* If not present */
97346 +#define _PAGE_RW       0x020
97347 +#define _PAGE_USER     0x040
97348 +#define _PAGE_ACCESSED 0x080
97349 +#define _PAGE_DIRTY    0x100
97350  
97351  #define REGION_MASK    0xf0000000
97352  #define REGION_SHIFT   28
97353 @@ -203,6 +203,16 @@ extern unsigned long pfn_to_phys(unsigne
97354  #define pfn_pte(pfn, prot) __pte(pfn_to_phys(pfn) | pgprot_val(prot))
97355  #define pfn_pmd(pfn, prot) __pmd(pfn_to_phys(pfn) | pgprot_val(prot))
97356  
97357 +/*
97358 + * Bits 0 through 3 are taken
97359 + */
97360 +#define PTE_FILE_MAX_BITS      28
97361 +
97362 +#define pte_to_pgoff(pte) ((pte).pte_low >> 4)
97363 +
97364 +#define pgoff_to_pte(off) \
97365 +       ((pte_t) { ((off) << 4) + _PAGE_FILE })
97366 +
97367  static inline pte_t pte_mknewprot(pte_t pte)
97368  {
97369         pte_val(pte) |= _PAGE_NEWPROT;
97370 @@ -236,6 +246,12 @@ static inline void set_pte(pte_t *pteptr
97371   * The following only work if pte_present() is true.
97372   * Undefined behaviour if not..
97373   */
97374 +static inline int pte_user(pte_t pte)
97375 +{ 
97376 +       return((pte_val(pte) & _PAGE_USER) && 
97377 +              !(pte_val(pte) & _PAGE_PROTNONE));
97378 +}
97379 +
97380  static inline int pte_read(pte_t pte)
97381  { 
97382         return((pte_val(pte) & _PAGE_USER) && 
97383 @@ -253,6 +269,14 @@ static inline int pte_write(pte_t pte)
97384                !(pte_val(pte) & _PAGE_PROTNONE));
97385  }
97386  
97387 +/*
97388 + * The following only works if pte_present() is not true.
97389 + */
97390 +static inline int pte_file(pte_t pte)
97391 +{ 
97392 +       return (pte).pte_low & _PAGE_FILE; 
97393 +}
97394 +
97395  static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
97396  static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
97397  static inline int pte_newpage(pte_t pte) { return pte_val(pte) & _PAGE_NEWPAGE; }
97398 @@ -355,14 +379,26 @@ static inline pte_t pte_modify(pte_t pte
97399  #define pmd_page(pmd) (phys_mem_map(pmd_val(pmd) & PAGE_MASK) + \
97400                        ((phys_addr(pmd_val(pmd)) >> PAGE_SHIFT)))
97401  
97402 -/* to find an entry in a page-table-directory. */
97403 +/*
97404 + * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD]
97405 + *
97406 + * this macro returns the index of the entry in the pgd page which would
97407 + * control the given virtual address
97408 + */
97409  #define pgd_index(address) ((address >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
97410  
97411 -/* to find an entry in a page-table-directory */
97412 +/*
97413 + * pgd_offset() returns a (pgd_t *)
97414 + * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
97415 + */
97416  #define pgd_offset(mm, address) \
97417  ((mm)->pgd + ((address) >> PGDIR_SHIFT))
97418  
97419 -/* to find an entry in a kernel page-table-directory */
97420 +
97421 +/*
97422 + * a shortcut which implies the use of the kernel's pgd, instead
97423 + * of a process's
97424 + */
97425  #define pgd_offset_k(address) pgd_offset(&init_mm, address)
97426  
97427  #define pmd_index(address) \
97428 @@ -374,7 +410,12 @@ static inline pmd_t * pmd_offset(pgd_t *
97429         return (pmd_t *) dir;
97430  }
97431  
97432 -/* Find an entry in the third-level page table.. */ 
97433 +/*
97434 + * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE]
97435 + *
97436 + * this macro returns the index of the entry in the pte page which would
97437 + * control the given virtual address
97438 + */
97439  #define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
97440  #define pte_offset_kernel(dir, address) \
97441         ((pte_t *) pmd_page_kernel(*(dir)) +  pte_index(address))
97442 @@ -400,11 +441,11 @@ typedef pte_t *pte_addr_t;
97443  #define update_mmu_cache(vma,address,pte) do ; while (0)
97444  
97445  /* Encode and de-code a swap entry */
97446 -#define __swp_type(x)                  (((x).val >> 3) & 0x7f)
97447 -#define __swp_offset(x)                        ((x).val >> 10)
97448 +#define __swp_type(x)                  (((x).val >> 4) & 0x3f)
97449 +#define __swp_offset(x)                        ((x).val >> 11)
97450  
97451  #define __swp_entry(type, offset) \
97452 -       ((swp_entry_t) { ((type) << 3) | ((offset) << 10) })
97453 +       ((swp_entry_t) { ((type) << 4) | ((offset) << 11) })
97454  #define __pte_to_swp_entry(pte) \
97455         ((swp_entry_t) { pte_val(pte_mkuptodate(pte)) })
97456  #define __swp_entry_to_pte(x)          ((pte_t) { (x).val })
97457 --- linux-2.6.0-test6/include/asm-um/processor-generic.h        2003-06-14 12:17:59.000000000 -0700
97458 +++ 25/include/asm-um/processor-generic.h       2003-10-05 00:34:32.000000000 -0700
97459 @@ -11,9 +11,7 @@ struct pt_regs;
97460  struct task_struct;
97461  
97462  #include "linux/config.h"
97463 -#include "linux/signal.h"
97464  #include "asm/ptrace.h"
97465 -#include "asm/siginfo.h"
97466  #include "choose-mode.h"
97467  
97468  struct mm_struct;
97469 @@ -101,14 +99,19 @@ typedef struct {
97470  } mm_segment_t;
97471  
97472  extern struct task_struct *alloc_task_struct(void);
97473 -extern void free_task_struct(struct task_struct *task);
97474  
97475  extern void release_thread(struct task_struct *);
97476  extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
97477  extern void dump_thread(struct pt_regs *regs, struct user *u);
97478 +extern void prepare_to_copy(struct task_struct *tsk);
97479  
97480  extern unsigned long thread_saved_pc(struct task_struct *t);
97481  
97482 +static inline void mm_copy_segments(struct mm_struct *from_mm, 
97483 +                                   struct mm_struct *new_mm)
97484 +{
97485 +}
97486 +
97487  #define init_stack     (init_thread_union.stack)
97488  
97489  /*
97490 --- linux-2.6.0-test6/include/asm-um/processor-i386.h   2003-06-14 12:17:57.000000000 -0700
97491 +++ 25/include/asm-um/processor-i386.h  2003-10-05 00:34:32.000000000 -0700
97492 @@ -6,8 +6,8 @@
97493  #ifndef __UM_PROCESSOR_I386_H
97494  #define __UM_PROCESSOR_I386_H
97495  
97496 -extern int cpu_has_xmm;
97497 -extern int cpu_has_cmov;
97498 +extern int host_has_xmm;
97499 +extern int host_has_cmov;
97500  
97501  struct arch_thread {
97502         unsigned long debugregs[8];
97503 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
97504 +++ 25/include/asm-um/sections.h        2003-10-05 00:34:32.000000000 -0700
97505 @@ -0,0 +1,7 @@
97506 +#ifndef _UM_SECTIONS_H
97507 +#define _UM_SECTIONS_H
97508 +
97509 +/* nothing to see, move along */
97510 +#include <asm-generic/sections.h>
97511 +
97512 +#endif
97513 --- linux-2.6.0-test6/include/asm-um/smp.h      2003-08-22 19:23:42.000000000 -0700
97514 +++ 25/include/asm-um/smp.h     2003-10-05 00:34:32.000000000 -0700
97515 @@ -10,7 +10,7 @@
97516  
97517  extern cpumask_t cpu_online_map;
97518  
97519 -#define smp_processor_id() (current->thread_info->cpu)
97520 +#define smp_processor_id() (current_thread->cpu)
97521  #define cpu_logical_map(n) (n)
97522  #define cpu_number_map(n) (n)
97523  #define PROC_CHANGE_PENALTY    15 /* Pick a number, any number */
97524 --- linux-2.6.0-test6/include/asm-um/system-generic.h   2003-06-14 12:18:51.000000000 -0700
97525 +++ 25/include/asm-um/system-generic.h  2003-10-05 00:34:32.000000000 -0700
97526 @@ -23,8 +23,10 @@ extern int get_signals(void);
97527  extern void block_signals(void);
97528  extern void unblock_signals(void);
97529  
97530 -#define local_save_flags(flags) do { (flags) = get_signals(); } while(0)
97531 -#define local_irq_restore(flags) do { set_signals(flags); } while(0)
97532 +#define local_save_flags(flags) do { typecheck(unsigned long, flags); \
97533 +                                    (flags) = get_signals(); } while(0)
97534 +#define local_irq_restore(flags) do { typecheck(unsigned long, flags); \
97535 +                                     set_signals(flags); } while(0)
97536  
97537  #define local_irq_save(flags) do { local_save_flags(flags); \
97538                                     local_irq_disable(); } while(0)
97539 @@ -39,4 +41,7 @@ extern void unblock_signals(void);
97540          (flags == 0);                   \
97541  })
97542  
97543 +extern void *_switch_to(void *prev, void *next, void *last);
97544 +#define switch_to(prev, next, last) prev = _switch_to(prev, next, last)
97545 +
97546  #endif
97547 --- linux-2.6.0-test6/include/asm-um/thread_info.h      2003-06-14 12:18:06.000000000 -0700
97548 +++ 25/include/asm-um/thread_info.h     2003-10-05 00:34:32.000000000 -0700
97549 @@ -9,6 +9,7 @@
97550  #ifndef __ASSEMBLY__
97551  
97552  #include <asm/processor.h>
97553 +#include <asm/types.h>
97554  
97555  struct thread_info {
97556         struct task_struct      *task;          /* main task structure */
97557 @@ -43,15 +44,18 @@ struct thread_info {
97558  static inline struct thread_info *current_thread_info(void)
97559  {
97560         struct thread_info *ti;
97561 -       __asm__("andl %%esp,%0; ":"=r" (ti) : "0" (~16383UL));
97562 +       unsigned long mask = PAGE_SIZE * 
97563 +               (1 << CONFIG_KERNEL_STACK_ORDER) - 1;
97564 +       __asm__("andl %%esp,%0; ":"=r" (ti) : "0" (~mask));
97565         return ti;
97566  }
97567  
97568  /* thread information allocation */
97569 -#define THREAD_SIZE (4*PAGE_SIZE)
97570 -#define alloc_thread_info(tsk) ((struct thread_info *) \
97571 -       __get_free_pages(GFP_KERNEL,2))
97572 -#define free_thread_info(ti) free_pages((unsigned long) (ti), 2)
97573 +#define THREAD_SIZE ((1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE)
97574 +#define alloc_thread_info(tsk) \
97575 +       ((struct thread_info *) kmalloc(THREAD_SIZE, GFP_KERNEL))
97576 +#define free_thread_info(ti) kfree(ti)
97577 +       
97578  #define get_thread_info(ti) get_task_struct((ti)->task)
97579  #define put_thread_info(ti) put_task_struct((ti)->task)
97580  
97581 @@ -65,11 +69,13 @@ static inline struct thread_info *curren
97582  #define TIF_POLLING_NRFLAG      3       /* true if poll_idle() is polling 
97583                                          * TIF_NEED_RESCHED 
97584                                          */
97585 +#define TIF_RESTART_BLOCK      4
97586  
97587  #define _TIF_SYSCALL_TRACE     (1 << TIF_SYSCALL_TRACE)
97588  #define _TIF_SIGPENDING                (1 << TIF_SIGPENDING)
97589  #define _TIF_NEED_RESCHED      (1 << TIF_NEED_RESCHED)
97590  #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
97591 +#define _TIF_RESTART_BLOCK     (1 << TIF_RESTART_BLOCK)
97592  
97593  #endif
97594  
97595 --- linux-2.6.0-test6/include/asm-um/timex.h    2003-06-14 12:18:24.000000000 -0700
97596 +++ 25/include/asm-um/timex.h   2003-10-05 00:34:32.000000000 -0700
97597 @@ -1,8 +1,6 @@
97598  #ifndef __UM_TIMEX_H
97599  #define __UM_TIMEX_H
97600  
97601 -#include "linux/time.h"
97602 -
97603  typedef unsigned long cycles_t;
97604  
97605  #define cacheflush_time (0)
97606 --- linux-2.6.0-test6/include/asm-v850/cacheflush.h     2003-07-27 12:14:40.000000000 -0700
97607 +++ 25/include/asm-v850/cacheflush.h    2003-10-05 00:33:24.000000000 -0700
97608 @@ -27,6 +27,8 @@
97609  #define flush_cache_range(vma, start, end)     ((void)0)
97610  #define flush_cache_page(vma, vmaddr)          ((void)0)
97611  #define flush_dcache_page(page)                        ((void)0)
97612 +#define flush_cache_vmap(start, end)           ((void)0)
97613 +#define flush_cache_vunmap(start, end)         ((void)0)
97614  
97615  #ifdef CONFIG_NO_CACHE
97616  
97617 @@ -55,5 +57,11 @@ extern void flush_cache_sigtramp (unsign
97618  
97619  #endif /* CONFIG_NO_CACHE */
97620  
97621 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
97622 +do { memcpy(dst, src, len); \
97623 +     flush_icache_user_range(vma, page, vaddr, len); \
97624 +} while (0)
97625 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
97626 +       memcpy(dst, src, len)
97627  
97628  #endif /* __V850_CACHEFLUSH_H__ */
97629 --- linux-2.6.0-test6/include/asm-x86_64/cacheflush.h   2003-06-14 12:17:59.000000000 -0700
97630 +++ 25/include/asm-x86_64/cacheflush.h  2003-10-05 00:33:24.000000000 -0700
97631 @@ -13,6 +13,13 @@
97632  #define flush_icache_range(start, end)         do { } while (0)
97633  #define flush_icache_page(vma,pg)              do { } while (0)
97634  #define flush_icache_user_range(vma,pg,adr,len)        do { } while (0)
97635 +#define flush_cache_vmap(start, end)           do { } while (0)
97636 +#define flush_cache_vunmap(start, end)         do { } while (0)
97637 +
97638 +#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
97639 +       memcpy(dst, src, len)
97640 +#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
97641 +       memcpy(dst, src, len)
97642  
97643  void global_flush_tlb(void); 
97644  int change_page_attr(struct page *page, int numpages, pgprot_t prot);
97645 --- linux-2.6.0-test6/include/asm-x86_64/elf.h  2003-06-14 12:18:30.000000000 -0700
97646 +++ 25/include/asm-x86_64/elf.h 2003-10-05 00:33:24.000000000 -0700
97647 @@ -150,11 +150,6 @@ extern int dump_task_fpu (struct task_st
97648  #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
97649  #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
97650  
97651 -#ifdef CONFIG_SMP
97652 -extern void dump_smp_unlazy_fpu(void);
97653 -#define ELF_CORE_SYNC dump_smp_unlazy_fpu
97654 -#endif
97655 -
97656  #endif
97657  
97658  #endif
97659 --- linux-2.6.0-test6/include/asm-x86_64/mmzone.h       2003-07-10 18:50:32.000000000 -0700
97660 +++ 25/include/asm-x86_64/mmzone.h      2003-10-05 00:34:38.000000000 -0700
97661 @@ -10,7 +10,6 @@
97662  
97663  #define VIRTUAL_BUG_ON(x) 
97664  
97665 -#include <asm/numnodes.h>
97666  #include <asm/smp.h>
97667  
97668  #define MAXNODE 8 
97669 --- linux-2.6.0-test6/include/asm-x86_64/numnodes.h     2003-06-14 12:18:08.000000000 -0700
97670 +++ 25/include/asm-x86_64/numnodes.h    2003-10-05 00:34:38.000000000 -0700
97671 @@ -3,10 +3,7 @@
97672  
97673  #include <linux/config.h>
97674  
97675 -#ifdef CONFIG_DISCONTIGMEM
97676 -#define MAX_NUMNODES 8 /* APIC limit currently */
97677 -#else
97678 -#define MAX_NUMNODES 1
97679 -#endif
97680 +/* Max 8 Nodes - APIC limit currently */
97681 +#define NODES_SHIFT    3
97682  
97683  #endif
97684 --- linux-2.6.0-test6/include/asm-x86_64/pgtable.h      2003-07-02 14:53:18.000000000 -0700
97685 +++ 25/include/asm-x86_64/pgtable.h     2003-10-05 00:33:24.000000000 -0700
97686 @@ -126,7 +126,6 @@ static inline void set_pml4(pml4_t *dst,
97687  #ifndef __ASSEMBLY__
97688  #define VMALLOC_START    0xffffff0000000000
97689  #define VMALLOC_END      0xffffff7fffffffff
97690 -#define VMALLOC_VMADDR(x) ((unsigned long)(x))
97691  #define MODULES_VADDR    0xffffffffa0000000
97692  #define MODULES_END      0xffffffffafffffff
97693  #define MODULES_LEN   (MODULES_END - MODULES_VADDR)
97694 --- linux-2.6.0-test6/include/linux/acpi.h      2003-08-22 19:23:42.000000000 -0700
97695 +++ 25/include/linux/acpi.h     2003-10-05 00:33:24.000000000 -0700
97696 @@ -424,17 +424,17 @@ int ec_write(u8 addr, u8 val);
97697  
97698  #endif /*CONFIG_ACPI_EC*/
97699  
97700 -#ifdef CONFIG_ACPI
97701 +#ifdef CONFIG_ACPI_INTERPRETER
97702  
97703  int acpi_blacklisted(void);
97704  
97705 -#else
97706 +#else /*!CONFIG_ACPI_INTERPRETER*/
97707  
97708  static inline int acpi_blacklisted(void)
97709  {
97710         return 0;
97711  }
97712  
97713 -#endif /*CONFIG_ACPI*/
97714 +#endif /*!CONFIG_ACPI_INTERPRETER*/
97715  
97716  #endif /*_LINUX_ACPI_H*/
97717 --- linux-2.6.0-test6/include/linux/aio.h       2003-06-26 22:07:26.000000000 -0700
97718 +++ 25/include/linux/aio.h      2003-10-05 00:37:05.000000000 -0700
97719 @@ -29,21 +29,26 @@ struct kioctx;
97720  #define KIF_LOCKED             0
97721  #define KIF_KICKED             1
97722  #define KIF_CANCELLED          2
97723 +#define KIF_SYNCED             3
97724  
97725  #define kiocbTryLock(iocb)     test_and_set_bit(KIF_LOCKED, &(iocb)->ki_flags)
97726  #define kiocbTryKick(iocb)     test_and_set_bit(KIF_KICKED, &(iocb)->ki_flags)
97727 +#define kiocbTrySync(iocb)     test_and_set_bit(KIF_SYNCED, &(iocb)->ki_flags)
97728  
97729  #define kiocbSetLocked(iocb)   set_bit(KIF_LOCKED, &(iocb)->ki_flags)
97730  #define kiocbSetKicked(iocb)   set_bit(KIF_KICKED, &(iocb)->ki_flags)
97731  #define kiocbSetCancelled(iocb)        set_bit(KIF_CANCELLED, &(iocb)->ki_flags)
97732 +#define kiocbSetSynced(iocb)   set_bit(KIF_SYNCED, &(iocb)->ki_flags)
97733  
97734  #define kiocbClearLocked(iocb) clear_bit(KIF_LOCKED, &(iocb)->ki_flags)
97735  #define kiocbClearKicked(iocb) clear_bit(KIF_KICKED, &(iocb)->ki_flags)
97736  #define kiocbClearCancelled(iocb)      clear_bit(KIF_CANCELLED, &(iocb)->ki_flags)
97737 +#define kiocbClearSynced(iocb) clear_bit(KIF_SYNCED, &(iocb)->ki_flags)
97738  
97739  #define kiocbIsLocked(iocb)    test_bit(KIF_LOCKED, &(iocb)->ki_flags)
97740  #define kiocbIsKicked(iocb)    test_bit(KIF_KICKED, &(iocb)->ki_flags)
97741  #define kiocbIsCancelled(iocb) test_bit(KIF_CANCELLED, &(iocb)->ki_flags)
97742 +#define kiocbIsSynced(iocb)    test_bit(KIF_SYNCED, &(iocb)->ki_flags)
97743  
97744  struct kiocb {
97745         struct list_head        ki_run_list;
97746 @@ -54,7 +59,7 @@ struct kiocb {
97747         struct file             *ki_filp;
97748         struct kioctx           *ki_ctx;        /* may be NULL for sync ops */
97749         int                     (*ki_cancel)(struct kiocb *, struct io_event *);
97750 -       long                    (*ki_retry)(struct kiocb *);
97751 +       ssize_t                 (*ki_retry)(struct kiocb *);
97752  
97753         struct list_head        ki_list;        /* the aio core uses this
97754                                                  * for cancellation */
97755 @@ -63,6 +68,16 @@ struct kiocb {
97756         __u64                   ki_user_data;   /* user's data for completion */
97757         loff_t                  ki_pos;
97758  
97759 +       /* State that we remember to be able to restart/retry  */
97760 +       unsigned short          ki_opcode;
97761 +       size_t                  ki_nbytes;      /* copy of iocb->aio_nbytes */
97762 +       char                    *ki_buf;        /* remaining iocb->aio_buf */
97763 +       size_t                  ki_left;        /* remaining bytes */
97764 +       wait_queue_t            ki_wait;
97765 +       long                    ki_retried;     /* just for testing */
97766 +       long                    ki_kicked;      /* just for testing */
97767 +       long                    ki_queued;      /* just for testing */
97768 +
97769         char                    private[KIOCB_PRIVATE_SIZE];
97770  };
97771  
97772 @@ -77,6 +92,8 @@ struct kiocb {
97773                 (x)->ki_ctx = &tsk->active_mm->default_kioctx;  \
97774                 (x)->ki_cancel = NULL;                  \
97775                 (x)->ki_user_obj = tsk;                 \
97776 +               (x)->ki_user_data = 0;                  \
97777 +               init_wait((&(x)->ki_wait));             \
97778         } while (0)
97779  
97780  #define AIO_RING_MAGIC                 0xa10a10a1
97781 @@ -159,6 +176,17 @@ int FASTCALL(io_submit_one(struct kioctx
97782  #define get_ioctx(kioctx)      do { if (unlikely(atomic_read(&(kioctx)->users) <= 0)) BUG(); atomic_inc(&(kioctx)->users); } while (0)
97783  #define put_ioctx(kioctx)      do { if (unlikely(atomic_dec_and_test(&(kioctx)->users))) __put_ioctx(kioctx); else if (unlikely(atomic_read(&(kioctx)->users) < 0)) BUG(); } while (0)
97784  
97785 +#define in_aio() !is_sync_wait(current->io_wait)
97786 +/* may be used for debugging */
97787 +#define warn_if_async()        if (in_aio()) {\
97788 +       printk(KERN_ERR "%s(%s:%d) called in async context!\n", \
97789 +       __FUNCTION__, __FILE__, __LINE__); \
97790 +       dump_stack(); \
97791 +       }
97792 +
97793 +#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait)
97794 +#define is_retried_kiocb(iocb) ((iocb)->ki_retried > 1)
97795 +
97796  #include <linux/aio_abi.h>
97797  
97798  static inline struct kiocb *list_kiocb(struct list_head *h)
97799 --- linux-2.6.0-test6/include/linux/blkdev.h    2003-09-27 18:57:47.000000000 -0700
97800 +++ 25/include/linux/blkdev.h   2003-10-05 00:36:58.000000000 -0700
97801 @@ -585,6 +585,7 @@ extern void blk_queue_free_tags(request_
97802  extern int blk_queue_resize_tags(request_queue_t *, int);
97803  extern void blk_queue_invalidate_tags(request_queue_t *);
97804  extern void blk_congestion_wait(int rw, long timeout);
97805 +extern int blk_congestion_wait_wq(int rw, long timeout, wait_queue_t *wait);
97806  
97807  extern void blk_rq_bio_prep(request_queue_t *, struct request *, struct bio *);
97808  extern void blk_rq_prep_restart(struct request *);
97809 --- linux-2.6.0-test6/include/linux/buffer_head.h       2003-08-22 19:23:42.000000000 -0700
97810 +++ 25/include/linux/buffer_head.h      2003-10-05 00:37:00.000000000 -0700
97811 @@ -162,6 +162,7 @@ void mark_buffer_async_write(struct buff
97812  void invalidate_bdev(struct block_device *, int);
97813  int sync_blockdev(struct block_device *bdev);
97814  void __wait_on_buffer(struct buffer_head *);
97815 +int __wait_on_buffer_wq(struct buffer_head *, wait_queue_t *wait);
97816  wait_queue_head_t *bh_waitq_head(struct buffer_head *bh);
97817  void wake_up_buffer(struct buffer_head *bh);
97818  int fsync_bdev(struct block_device *);
97819 @@ -173,6 +174,8 @@ void __brelse(struct buffer_head *);
97820  void __bforget(struct buffer_head *);
97821  void __breadahead(struct block_device *, sector_t block, int size);
97822  struct buffer_head *__bread(struct block_device *, sector_t block, int size);
97823 +struct buffer_head *__bread_wq(struct block_device *, sector_t block,
97824 +       int size, wait_queue_t *wait);
97825  struct buffer_head *alloc_buffer_head(int gfp_flags);
97826  void free_buffer_head(struct buffer_head * bh);
97827  void FASTCALL(unlock_buffer(struct buffer_head *bh));
97828 @@ -207,12 +210,6 @@ int nobh_prepare_write(struct page*, uns
97829  int nobh_commit_write(struct file *, struct page *, unsigned, unsigned);
97830  int nobh_truncate_page(struct address_space *, loff_t);
97831  
97832 -#define OSYNC_METADATA (1<<0)
97833 -#define OSYNC_DATA     (1<<1)
97834 -#define OSYNC_INODE    (1<<2)
97835 -int generic_osync_inode(struct inode *, int);
97836 -
97837 -
97838  /*
97839   * inline definitions
97840   */
97841 @@ -230,13 +227,13 @@ static inline void put_bh(struct buffer_
97842  
97843  static inline void brelse(struct buffer_head *bh)
97844  {
97845 -       if (bh)
97846 +       if (bh && !IS_ERR(bh))
97847                 __brelse(bh);
97848  }
97849  
97850  static inline void bforget(struct buffer_head *bh)
97851  {
97852 -       if (bh)
97853 +       if (bh && !IS_ERR(bh))
97854                 __bforget(bh);
97855  }
97856  
97857 @@ -253,7 +250,12 @@ sb_breadahead(struct super_block *sb, se
97858  }
97859  
97860  static inline struct buffer_head *
97861 -sb_getblk(struct super_block *sb, sector_t block)
97862 +sb_bread_wq(struct super_block *sb, sector_t block, wait_queue_t *wait)
97863 +{
97864 +       return __bread_wq(sb->s_bdev, block, sb->s_blocksize, wait);
97865 +}
97866 +
97867 +static inline struct buffer_head *sb_getblk(struct super_block *sb, sector_t block)
97868  {
97869         return __getblk(sb->s_bdev, block, sb->s_blocksize);
97870  }
97871 @@ -277,16 +279,34 @@ map_bh(struct buffer_head *bh, struct su
97872   * __wait_on_buffer() just to trip a debug check.  Because debug code in inline
97873   * functions is bloaty.
97874   */
97875 -static inline void wait_on_buffer(struct buffer_head *bh)
97876 +
97877 +static inline int wait_on_buffer_wq(struct buffer_head *bh, wait_queue_t *wait)
97878  {
97879         if (buffer_locked(bh) || atomic_read(&bh->b_count) == 0)
97880 -               __wait_on_buffer(bh);
97881 +               return __wait_on_buffer_wq(bh, wait);
97882 +
97883 +       return 0;
97884 +}
97885 +
97886 +static inline void wait_on_buffer(struct buffer_head *bh)
97887 +{
97888 +       wait_on_buffer_wq(bh, NULL);
97889 +}
97890 +
97891 +static inline int lock_buffer_wq(struct buffer_head *bh, wait_queue_t *wait)
97892 +{
97893 +       while (test_set_buffer_locked(bh)) {
97894 +               int ret = __wait_on_buffer_wq(bh, wait);
97895 +               if (ret)
97896 +                       return ret;
97897 +       }
97898 +
97899 +       return 0;
97900  }
97901  
97902  static inline void lock_buffer(struct buffer_head *bh)
97903  {
97904 -       while (test_set_buffer_locked(bh))
97905 -               __wait_on_buffer(bh);
97906 +       lock_buffer_wq(bh, NULL);
97907  }
97908  
97909  #endif /* _LINUX_BUFFER_HEAD_H */
97910 --- linux-2.6.0-test6/include/linux/cdrom.h     2003-07-02 14:53:18.000000000 -0700
97911 +++ 25/include/linux/cdrom.h    2003-10-05 00:33:59.000000000 -0700
97912 @@ -743,6 +743,7 @@ struct cdrom_device_info {
97913  /* per-device flags */
97914          __u8 sanyo_slot                : 2;    /* Sanyo 3 CD changer support */
97915          __u8 reserved          : 6;    /* not used yet */
97916 +       int for_data;
97917         struct cdrom_write_settings write;
97918  };
97919  
97920 @@ -776,9 +777,9 @@ struct cdrom_device_ops {
97921  };
97922  
97923  /* the general block_device operations structure: */
97924 -extern int cdrom_open(struct cdrom_device_info *, struct inode *, struct file *);
97925 -extern int cdrom_release(struct cdrom_device_info *, struct file *);
97926 -extern int cdrom_ioctl(struct cdrom_device_info *, struct inode *, unsigned, unsigned long);
97927 +extern int cdrom_open(struct cdrom_device_info *, struct block_device *, struct file *);
97928 +extern int cdrom_release(struct cdrom_device_info *);
97929 +extern int cdrom_ioctl(struct cdrom_device_info *, struct block_device *, unsigned, unsigned long);
97930  extern int cdrom_media_changed(struct cdrom_device_info *);
97931  
97932  extern int register_cdrom(struct cdrom_device_info *cdi);
97933 --- linux-2.6.0-test6/include/linux/compat.h    2003-08-22 19:23:42.000000000 -0700
97934 +++ 25/include/linux/compat.h   2003-10-05 00:34:44.000000000 -0700
97935 @@ -90,5 +90,12 @@ struct compat_statfs64 {
97936         __u32 f_spare[5];
97937  };
97938  
97939 +struct compat_dirent {
97940 +       u32             d_ino;
97941 +       compat_off_t    d_off;
97942 +       u16             d_reclen;
97943 +       char            d_name[256];
97944 +};
97945 +
97946  #endif /* CONFIG_COMPAT */
97947  #endif /* _LINUX_COMPAT_H */
97948 --- linux-2.6.0-test6/include/linux/compat_ioctl.h      2003-09-27 18:57:47.000000000 -0700
97949 +++ 25/include/linux/compat_ioctl.h     2003-10-05 00:33:24.000000000 -0700
97950 @@ -68,7 +68,7 @@ COMPATIBLE_IOCTL(HDIO_SET_MULTCOUNT)
97951  COMPATIBLE_IOCTL(HDIO_DRIVE_CMD)
97952  COMPATIBLE_IOCTL(HDIO_SET_PIO_MODE)
97953  COMPATIBLE_IOCTL(HDIO_SET_NICE)
97954 -#ifndef CONFIG_ARCH_S390
97955 +#ifdef CONFIG_BLK_DEV_FD
97956  /* 0x02 -- Floppy ioctls */
97957  COMPATIBLE_IOCTL(FDMSGON)
97958  COMPATIBLE_IOCTL(FDMSGOFF)
97959 --- linux-2.6.0-test6/include/linux/compiler-gcc.h      2003-09-27 18:57:47.000000000 -0700
97960 +++ 25/include/linux/compiler-gcc.h     2003-10-05 00:34:18.000000000 -0700
97961 @@ -13,5 +13,5 @@
97962     shouldn't recognize the original var, and make assumptions about it */
97963  #define RELOC_HIDE(ptr, off)                                   \
97964    ({ unsigned long __ptr;                                      \
97965 -    __asm__ ("" : "=g"(__ptr) : "0"(ptr));             \
97966 +       __asm__ ("" : "=r"(__ptr) : "0"(ptr));                  \
97967      (typeof(ptr)) (__ptr + (off)); })
97968 --- linux-2.6.0-test6/include/linux/config.h    2003-06-26 22:07:26.000000000 -0700
97969 +++ 25/include/linux/config.h   2003-10-05 00:33:43.000000000 -0700
97970 @@ -2,5 +2,8 @@
97971  #define _LINUX_CONFIG_H
97972  
97973  #include <linux/autoconf.h>
97974 +#if defined(__i386__) && !defined(IN_BOOTLOADER)
97975 +#include <asm/kgdb.h>
97976 +#endif
97977  
97978  #endif
97979 --- linux-2.6.0-test6/include/linux/dqblk_xfs.h 2003-06-14 12:18:29.000000000 -0700
97980 +++ 25/include/linux/dqblk_xfs.h        2003-10-05 00:33:24.000000000 -0700
97981 @@ -105,15 +105,6 @@ typedef struct fs_disk_quota {
97982  #define FS_DQ_TIMER_MASK       (FS_DQ_BTIMER | FS_DQ_ITIMER | FS_DQ_RTBTIMER)
97983  
97984  /*
97985 - * The following constants define the default amount of time given a user
97986 - * before the soft limits are treated as hard limits (usually resulting
97987 - * in an allocation failure).  These may be modified by the quotactl(2)
97988 - * system call with the Q_XSETQLIM command.
97989 - */
97990 -#define        DQ_FTIMELIMIT   (7 * 24*60*60)          /* 1 week */
97991 -#define        DQ_BTIMELIMIT   (7 * 24*60*60)          /* 1 week */
97992 -
97993 -/*
97994   * Various flags related to quotactl(2).  Only relevant to XFS filesystems.
97995   */
97996  #define XFS_QUOTA_UDQ_ACCT     (1<<0)  /* user quota accounting */
97997 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
97998 +++ 25/include/linux/dwarf2.h   2003-10-05 00:33:38.000000000 -0700
97999 @@ -0,0 +1,738 @@
98000 +/* Declarations and definitions of codes relating to the DWARF2 symbolic
98001 +   debugging information format.
98002 +   Copyright (C) 1992, 1993, 1995, 1996, 1997, 1999, 2000, 2001, 2002
98003 +   Free Software Foundation, Inc.
98004 +
98005 +   Written by Gary Funck (gary@intrepid.com) The Ada Joint Program
98006 +   Office (AJPO), Florida State Unviversity and Silicon Graphics Inc.
98007 +   provided support for this effort -- June 21, 1995.
98008 +
98009 +   Derived from the DWARF 1 implementation written by Ron Guilmette
98010 +   (rfg@netcom.com), November 1990.
98011 +
98012 +   This file is part of GCC.
98013 +
98014 +   GCC is free software; you can redistribute it and/or modify it under
98015 +   the terms of the GNU General Public License as published by the Free
98016 +   Software Foundation; either version 2, or (at your option) any later
98017 +   version.
98018 +
98019 +   GCC is distributed in the hope that it will be useful, but WITHOUT
98020 +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
98021 +   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
98022 +   License for more details.
98023 +
98024 +   You should have received a copy of the GNU General Public License
98025 +   along with GCC; see the file COPYING.  If not, write to the Free
98026 +   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
98027 +   02111-1307, USA.  */
98028 +
98029 +/* This file is derived from the DWARF specification (a public document)
98030 +   Revision 2.0.0 (July 27, 1993) developed by the UNIX International
98031 +   Programming Languages Special Interest Group (UI/PLSIG) and distributed
98032 +   by UNIX International.  Copies of this specification are available from
98033 +   UNIX International, 20 Waterview Boulevard, Parsippany, NJ, 07054.
98034 +
98035 +   This file also now contains definitions from the DWARF 3 specification.  */
98036 +
98037 +/* This file is shared between GCC and GDB, and should not contain
98038 +   prototypes. */
98039 +
98040 +#ifndef _ELF_DWARF2_H
98041 +#define _ELF_DWARF2_H
98042 +
98043 +/* Structure found in the .debug_line section. */
98044 +#ifndef __ASSEMBLY__
98045 +typedef struct
98046 +{
98047 +  unsigned char li_length         [4];
98048 +  unsigned char li_version        [2];
98049 +  unsigned char li_prologue_length [4];
98050 +  unsigned char li_min_insn_length [1];
98051 +  unsigned char li_default_is_stmt [1];
98052 +  unsigned char li_line_base      [1];
98053 +  unsigned char li_line_range     [1];
98054 +  unsigned char li_opcode_base    [1];
98055 +}
98056 +DWARF2_External_LineInfo;
98057 +
98058 +typedef struct
98059 +{
98060 +  unsigned long  li_length;
98061 +  unsigned short li_version;
98062 +  unsigned int  li_prologue_length;
98063 +  unsigned char  li_min_insn_length;
98064 +  unsigned char  li_default_is_stmt;
98065 +  int           li_line_base;
98066 +  unsigned char  li_line_range;
98067 +  unsigned char  li_opcode_base;
98068 +}
98069 +DWARF2_Internal_LineInfo;
98070 +
98071 +/* Structure found in .debug_pubnames section. */
98072 +typedef struct
98073 +{
98074 +  unsigned char pn_length  [4];
98075 +  unsigned char pn_version [2];
98076 +  unsigned char pn_offset  [4];
98077 +  unsigned char pn_size    [4];
98078 +}
98079 +DWARF2_External_PubNames;
98080 +
98081 +typedef struct
98082 +{
98083 +  unsigned long  pn_length;
98084 +  unsigned short pn_version;
98085 +  unsigned long  pn_offset;
98086 +  unsigned long  pn_size;
98087 +}
98088 +DWARF2_Internal_PubNames;
98089 +
98090 +/* Structure found in .debug_info section.  */
98091 +typedef struct
98092 +{
98093 +  unsigned char  cu_length       [4];
98094 +  unsigned char  cu_version      [2];
98095 +  unsigned char  cu_abbrev_offset [4];
98096 +  unsigned char  cu_pointer_size  [1];
98097 +}
98098 +DWARF2_External_CompUnit;
98099 +
98100 +typedef struct
98101 +{
98102 +  unsigned long  cu_length;
98103 +  unsigned short cu_version;
98104 +  unsigned long  cu_abbrev_offset;
98105 +  unsigned char  cu_pointer_size;
98106 +}
98107 +DWARF2_Internal_CompUnit;
98108 +
98109 +typedef struct
98110 +{
98111 +  unsigned char  ar_length      [4];
98112 +  unsigned char  ar_version     [2];
98113 +  unsigned char  ar_info_offset  [4];
98114 +  unsigned char  ar_pointer_size [1];
98115 +  unsigned char  ar_segment_size [1];
98116 +}
98117 +DWARF2_External_ARange;
98118 +
98119 +typedef struct
98120 +{
98121 +  unsigned long  ar_length;
98122 +  unsigned short ar_version;
98123 +  unsigned long  ar_info_offset;
98124 +  unsigned char  ar_pointer_size;
98125 +  unsigned char  ar_segment_size;
98126 +}
98127 +DWARF2_Internal_ARange;
98128 +
98129 +#define ENUM(name) enum name {
98130 +#define IF_NOT_ASM(a) a
98131 +#define COMMA ,
98132 +#else
98133 +#define ENUM(name)
98134 +#define IF_NOT_ASM(a)
98135 +#define COMMA
98136 +
98137 +#endif
98138 +
98139 +/* Tag names and codes.  */
98140 +ENUM(dwarf_tag)
98141 +
98142 +    DW_TAG_padding = 0x00 COMMA
98143 +    DW_TAG_array_type = 0x01 COMMA
98144 +    DW_TAG_class_type = 0x02 COMMA
98145 +    DW_TAG_entry_point = 0x03 COMMA
98146 +    DW_TAG_enumeration_type = 0x04 COMMA
98147 +    DW_TAG_formal_parameter = 0x05 COMMA
98148 +    DW_TAG_imported_declaration = 0x08 COMMA
98149 +    DW_TAG_label = 0x0a COMMA
98150 +    DW_TAG_lexical_block = 0x0b COMMA
98151 +    DW_TAG_member = 0x0d COMMA
98152 +    DW_TAG_pointer_type = 0x0f COMMA
98153 +    DW_TAG_reference_type = 0x10 COMMA
98154 +    DW_TAG_compile_unit = 0x11 COMMA
98155 +    DW_TAG_string_type = 0x12 COMMA
98156 +    DW_TAG_structure_type = 0x13 COMMA
98157 +    DW_TAG_subroutine_type = 0x15 COMMA
98158 +    DW_TAG_typedef = 0x16 COMMA
98159 +    DW_TAG_union_type = 0x17 COMMA
98160 +    DW_TAG_unspecified_parameters = 0x18 COMMA
98161 +    DW_TAG_variant = 0x19 COMMA
98162 +    DW_TAG_common_block = 0x1a COMMA
98163 +    DW_TAG_common_inclusion = 0x1b COMMA
98164 +    DW_TAG_inheritance = 0x1c COMMA
98165 +    DW_TAG_inlined_subroutine = 0x1d COMMA
98166 +    DW_TAG_module = 0x1e COMMA
98167 +    DW_TAG_ptr_to_member_type = 0x1f COMMA
98168 +    DW_TAG_set_type = 0x20 COMMA
98169 +    DW_TAG_subrange_type = 0x21 COMMA
98170 +    DW_TAG_with_stmt = 0x22 COMMA
98171 +    DW_TAG_access_declaration = 0x23 COMMA
98172 +    DW_TAG_base_type = 0x24 COMMA
98173 +    DW_TAG_catch_block = 0x25 COMMA
98174 +    DW_TAG_const_type = 0x26 COMMA
98175 +    DW_TAG_constant = 0x27 COMMA
98176 +    DW_TAG_enumerator = 0x28 COMMA
98177 +    DW_TAG_file_type = 0x29 COMMA
98178 +    DW_TAG_friend = 0x2a COMMA
98179 +    DW_TAG_namelist = 0x2b COMMA
98180 +    DW_TAG_namelist_item = 0x2c COMMA
98181 +    DW_TAG_packed_type = 0x2d COMMA
98182 +    DW_TAG_subprogram = 0x2e COMMA
98183 +    DW_TAG_template_type_param = 0x2f COMMA
98184 +    DW_TAG_template_value_param = 0x30 COMMA
98185 +    DW_TAG_thrown_type = 0x31 COMMA
98186 +    DW_TAG_try_block = 0x32 COMMA
98187 +    DW_TAG_variant_part = 0x33 COMMA
98188 +    DW_TAG_variable = 0x34 COMMA
98189 +    DW_TAG_volatile_type = 0x35 COMMA
98190 +    /* DWARF 3.  */
98191 +    DW_TAG_dwarf_procedure = 0x36 COMMA
98192 +    DW_TAG_restrict_type = 0x37 COMMA
98193 +    DW_TAG_interface_type = 0x38 COMMA
98194 +    DW_TAG_namespace = 0x39 COMMA
98195 +    DW_TAG_imported_module = 0x3a COMMA
98196 +    DW_TAG_unspecified_type = 0x3b COMMA
98197 +    DW_TAG_partial_unit = 0x3c COMMA
98198 +    DW_TAG_imported_unit = 0x3d COMMA
98199 +    /* SGI/MIPS Extensions.  */
98200 +    DW_TAG_MIPS_loop = 0x4081 COMMA
98201 +    /* GNU extensions. */
98202 +    DW_TAG_format_label = 0x4101 COMMA /* For FORTRAN 77 and Fortran 90.  */
98203 +    DW_TAG_function_template = 0x4102 COMMA    /* For C++.  */
98204 +    DW_TAG_class_template = 0x4103 COMMA       /* For C++.  */
98205 +    DW_TAG_GNU_BINCL = 0x4104 COMMA
98206 +    DW_TAG_GNU_EINCL = 0x4105 COMMA
98207 +    /* Extensions for UPC.  See: http://upc.gwu.edu/~upc.  */
98208 +    DW_TAG_upc_shared_type = 0x8765 COMMA
98209 +    DW_TAG_upc_strict_type = 0x8766 COMMA
98210 +    DW_TAG_upc_relaxed_type = 0x8767
98211 +IF_NOT_ASM(};)
98212 +
98213 +#define DW_TAG_lo_user 0x4080
98214 +#define DW_TAG_hi_user 0xffff
98215 +
98216 +/* Flag that tells whether entry has a child or not.  */
98217 +#define DW_children_no  0
98218 +#define        DW_children_yes  1
98219 +
98220 +/* Form names and codes.  */
98221 +ENUM(dwarf_form)
98222 +
98223 +    DW_FORM_addr = 0x01 COMMA
98224 +    DW_FORM_block2 = 0x03 COMMA
98225 +    DW_FORM_block4 = 0x04 COMMA
98226 +    DW_FORM_data2 = 0x05 COMMA
98227 +    DW_FORM_data4 = 0x06 COMMA
98228 +    DW_FORM_data8 = 0x07 COMMA
98229 +    DW_FORM_string = 0x08 COMMA
98230 +    DW_FORM_block = 0x09 COMMA
98231 +    DW_FORM_block1 = 0x0a COMMA
98232 +    DW_FORM_data1 = 0x0b COMMA
98233 +    DW_FORM_flag = 0x0c COMMA
98234 +    DW_FORM_sdata = 0x0d COMMA
98235 +    DW_FORM_strp = 0x0e COMMA
98236 +    DW_FORM_udata = 0x0f COMMA
98237 +    DW_FORM_ref_addr = 0x10 COMMA
98238 +    DW_FORM_ref1 = 0x11 COMMA
98239 +    DW_FORM_ref2 = 0x12 COMMA
98240 +    DW_FORM_ref4 = 0x13 COMMA
98241 +    DW_FORM_ref8 = 0x14 COMMA
98242 +    DW_FORM_ref_udata = 0x15 COMMA
98243 +    DW_FORM_indirect = 0x16
98244 +IF_NOT_ASM(};)
98245 +
98246 +/* Attribute names and codes.  */
98247 +
98248 +ENUM(dwarf_attribute)
98249 +
98250 +    DW_AT_sibling = 0x01 COMMA
98251 +    DW_AT_location = 0x02 COMMA
98252 +    DW_AT_name = 0x03 COMMA
98253 +    DW_AT_ordering = 0x09 COMMA
98254 +    DW_AT_subscr_data = 0x0a COMMA
98255 +    DW_AT_byte_size = 0x0b COMMA
98256 +    DW_AT_bit_offset = 0x0c COMMA
98257 +    DW_AT_bit_size = 0x0d COMMA
98258 +    DW_AT_element_list = 0x0f COMMA
98259 +    DW_AT_stmt_list = 0x10 COMMA
98260 +    DW_AT_low_pc = 0x11 COMMA
98261 +    DW_AT_high_pc = 0x12 COMMA
98262 +    DW_AT_language = 0x13 COMMA
98263 +    DW_AT_member = 0x14 COMMA
98264 +    DW_AT_discr = 0x15 COMMA
98265 +    DW_AT_discr_value = 0x16 COMMA
98266 +    DW_AT_visibility = 0x17 COMMA
98267 +    DW_AT_import = 0x18 COMMA
98268 +    DW_AT_string_length = 0x19 COMMA
98269 +    DW_AT_common_reference = 0x1a COMMA
98270 +    DW_AT_comp_dir = 0x1b COMMA
98271 +    DW_AT_const_value = 0x1c COMMA
98272 +    DW_AT_containing_type = 0x1d COMMA
98273 +    DW_AT_default_value = 0x1e COMMA
98274 +    DW_AT_inline = 0x20 COMMA
98275 +    DW_AT_is_optional = 0x21 COMMA
98276 +    DW_AT_lower_bound = 0x22 COMMA
98277 +    DW_AT_producer = 0x25 COMMA
98278 +    DW_AT_prototyped = 0x27 COMMA
98279 +    DW_AT_return_addr = 0x2a COMMA
98280 +    DW_AT_start_scope = 0x2c COMMA
98281 +    DW_AT_stride_size = 0x2e COMMA
98282 +    DW_AT_upper_bound = 0x2f COMMA
98283 +    DW_AT_abstract_origin = 0x31 COMMA
98284 +    DW_AT_accessibility = 0x32 COMMA
98285 +    DW_AT_address_class = 0x33 COMMA
98286 +    DW_AT_artificial = 0x34 COMMA
98287 +    DW_AT_base_types = 0x35 COMMA
98288 +    DW_AT_calling_convention = 0x36 COMMA
98289 +    DW_AT_count = 0x37 COMMA
98290 +    DW_AT_data_member_location = 0x38 COMMA
98291 +    DW_AT_decl_column = 0x39 COMMA
98292 +    DW_AT_decl_file = 0x3a COMMA
98293 +    DW_AT_decl_line = 0x3b COMMA
98294 +    DW_AT_declaration = 0x3c COMMA
98295 +    DW_AT_discr_list = 0x3d COMMA
98296 +    DW_AT_encoding = 0x3e COMMA
98297 +    DW_AT_external = 0x3f COMMA
98298 +    DW_AT_frame_base = 0x40 COMMA
98299 +    DW_AT_friend = 0x41 COMMA
98300 +    DW_AT_identifier_case = 0x42 COMMA
98301 +    DW_AT_macro_info = 0x43 COMMA
98302 +    DW_AT_namelist_items = 0x44 COMMA
98303 +    DW_AT_priority = 0x45 COMMA
98304 +    DW_AT_segment = 0x46 COMMA
98305 +    DW_AT_specification = 0x47 COMMA
98306 +    DW_AT_static_link = 0x48 COMMA
98307 +    DW_AT_type = 0x49 COMMA
98308 +    DW_AT_use_location = 0x4a COMMA
98309 +    DW_AT_variable_parameter = 0x4b COMMA
98310 +    DW_AT_virtuality = 0x4c COMMA
98311 +    DW_AT_vtable_elem_location = 0x4d COMMA
98312 +    /* DWARF 3 values. */
98313 +    DW_AT_allocated    = 0x4e COMMA
98314 +    DW_AT_associated   = 0x4f COMMA
98315 +    DW_AT_data_location = 0x50 COMMA
98316 +    DW_AT_stride       = 0x51 COMMA
98317 +    DW_AT_entry_pc     = 0x52 COMMA
98318 +    DW_AT_use_UTF8     = 0x53 COMMA
98319 +    DW_AT_extension    = 0x54 COMMA
98320 +    DW_AT_ranges       = 0x55 COMMA
98321 +    DW_AT_trampoline   = 0x56 COMMA
98322 +    DW_AT_call_column  = 0x57 COMMA
98323 +    DW_AT_call_file    = 0x58 COMMA
98324 +    DW_AT_call_line    = 0x59 COMMA
98325 +    /* SGI/MIPS extensions.  */
98326 +    DW_AT_MIPS_fde = 0x2001 COMMA
98327 +    DW_AT_MIPS_loop_begin = 0x2002 COMMA
98328 +    DW_AT_MIPS_tail_loop_begin = 0x2003 COMMA
98329 +    DW_AT_MIPS_epilog_begin = 0x2004 COMMA
98330 +    DW_AT_MIPS_loop_unroll_factor = 0x2005 COMMA
98331 +    DW_AT_MIPS_software_pipeline_depth = 0x2006 COMMA
98332 +    DW_AT_MIPS_linkage_name = 0x2007 COMMA
98333 +    DW_AT_MIPS_stride = 0x2008 COMMA
98334 +    DW_AT_MIPS_abstract_name = 0x2009 COMMA
98335 +    DW_AT_MIPS_clone_origin = 0x200a COMMA
98336 +    DW_AT_MIPS_has_inlines = 0x200b COMMA
98337 +    /* GNU extensions. */
98338 +    DW_AT_sf_names   = 0x2101 COMMA
98339 +    DW_AT_src_info   = 0x2102 COMMA
98340 +    DW_AT_mac_info   = 0x2103 COMMA
98341 +    DW_AT_src_coords = 0x2104 COMMA
98342 +    DW_AT_body_begin = 0x2105 COMMA
98343 +    DW_AT_body_end   = 0x2106 COMMA
98344 +    DW_AT_GNU_vector = 0x2107 COMMA
98345 +    /* VMS extensions. */
98346 +    DW_AT_VMS_rtnbeg_pd_address = 0x2201 COMMA
98347 +    /* UPC extension.  */
98348 +    DW_AT_upc_threads_scaled = 0x3210
98349 +IF_NOT_ASM(};)
98350 +
98351 +#define DW_AT_lo_user  0x2000  /* Implementation-defined range start.  */
98352 +#define DW_AT_hi_user  0x3ff0  /* Implementation-defined range end.  */
98353 +
98354 +/* Location atom names and codes.  */
98355 +ENUM(dwarf_location_atom)
98356 +
98357 +    DW_OP_addr = 0x03 COMMA
98358 +    DW_OP_deref = 0x06 COMMA
98359 +    DW_OP_const1u = 0x08 COMMA
98360 +    DW_OP_const1s = 0x09 COMMA
98361 +    DW_OP_const2u = 0x0a COMMA
98362 +    DW_OP_const2s = 0x0b COMMA
98363 +    DW_OP_const4u = 0x0c COMMA
98364 +    DW_OP_const4s = 0x0d COMMA
98365 +    DW_OP_const8u = 0x0e COMMA
98366 +    DW_OP_const8s = 0x0f COMMA
98367 +    DW_OP_constu = 0x10 COMMA
98368 +    DW_OP_consts = 0x11 COMMA
98369 +    DW_OP_dup = 0x12 COMMA
98370 +    DW_OP_drop = 0x13 COMMA
98371 +    DW_OP_over = 0x14 COMMA
98372 +    DW_OP_pick = 0x15 COMMA
98373 +    DW_OP_swap = 0x16 COMMA
98374 +    DW_OP_rot = 0x17 COMMA
98375 +    DW_OP_xderef = 0x18 COMMA
98376 +    DW_OP_abs = 0x19 COMMA
98377 +    DW_OP_and = 0x1a COMMA
98378 +    DW_OP_div = 0x1b COMMA
98379 +    DW_OP_minus = 0x1c COMMA
98380 +    DW_OP_mod = 0x1d COMMA
98381 +    DW_OP_mul = 0x1e COMMA
98382 +    DW_OP_neg = 0x1f COMMA
98383 +    DW_OP_not = 0x20 COMMA
98384 +    DW_OP_or = 0x21 COMMA
98385 +    DW_OP_plus = 0x22 COMMA
98386 +    DW_OP_plus_uconst = 0x23 COMMA
98387 +    DW_OP_shl = 0x24 COMMA
98388 +    DW_OP_shr = 0x25 COMMA
98389 +    DW_OP_shra = 0x26 COMMA
98390 +    DW_OP_xor = 0x27 COMMA
98391 +    DW_OP_bra = 0x28 COMMA
98392 +    DW_OP_eq = 0x29 COMMA
98393 +    DW_OP_ge = 0x2a COMMA
98394 +    DW_OP_gt = 0x2b COMMA
98395 +    DW_OP_le = 0x2c COMMA
98396 +    DW_OP_lt = 0x2d COMMA
98397 +    DW_OP_ne = 0x2e COMMA
98398 +    DW_OP_skip = 0x2f COMMA
98399 +    DW_OP_lit0 = 0x30 COMMA
98400 +    DW_OP_lit1 = 0x31 COMMA
98401 +    DW_OP_lit2 = 0x32 COMMA
98402 +    DW_OP_lit3 = 0x33 COMMA
98403 +    DW_OP_lit4 = 0x34 COMMA
98404 +    DW_OP_lit5 = 0x35 COMMA
98405 +    DW_OP_lit6 = 0x36 COMMA
98406 +    DW_OP_lit7 = 0x37 COMMA
98407 +    DW_OP_lit8 = 0x38 COMMA
98408 +    DW_OP_lit9 = 0x39 COMMA
98409 +    DW_OP_lit10 = 0x3a COMMA
98410 +    DW_OP_lit11 = 0x3b COMMA
98411 +    DW_OP_lit12 = 0x3c COMMA
98412 +    DW_OP_lit13 = 0x3d COMMA
98413 +    DW_OP_lit14 = 0x3e COMMA
98414 +    DW_OP_lit15 = 0x3f COMMA
98415 +    DW_OP_lit16 = 0x40 COMMA
98416 +    DW_OP_lit17 = 0x41 COMMA
98417 +    DW_OP_lit18 = 0x42 COMMA
98418 +    DW_OP_lit19 = 0x43 COMMA
98419 +    DW_OP_lit20 = 0x44 COMMA
98420 +    DW_OP_lit21 = 0x45 COMMA
98421 +    DW_OP_lit22 = 0x46 COMMA
98422 +    DW_OP_lit23 = 0x47 COMMA
98423 +    DW_OP_lit24 = 0x48 COMMA
98424 +    DW_OP_lit25 = 0x49 COMMA
98425 +    DW_OP_lit26 = 0x4a COMMA
98426 +    DW_OP_lit27 = 0x4b COMMA
98427 +    DW_OP_lit28 = 0x4c COMMA
98428 +    DW_OP_lit29 = 0x4d COMMA
98429 +    DW_OP_lit30 = 0x4e COMMA
98430 +    DW_OP_lit31 = 0x4f COMMA
98431 +    DW_OP_reg0 = 0x50 COMMA
98432 +    DW_OP_reg1 = 0x51 COMMA
98433 +    DW_OP_reg2 = 0x52 COMMA
98434 +    DW_OP_reg3 = 0x53 COMMA
98435 +    DW_OP_reg4 = 0x54 COMMA
98436 +    DW_OP_reg5 = 0x55 COMMA
98437 +    DW_OP_reg6 = 0x56 COMMA
98438 +    DW_OP_reg7 = 0x57 COMMA
98439 +    DW_OP_reg8 = 0x58 COMMA
98440 +    DW_OP_reg9 = 0x59 COMMA
98441 +    DW_OP_reg10 = 0x5a COMMA
98442 +    DW_OP_reg11 = 0x5b COMMA
98443 +    DW_OP_reg12 = 0x5c COMMA
98444 +    DW_OP_reg13 = 0x5d COMMA
98445 +    DW_OP_reg14 = 0x5e COMMA
98446 +    DW_OP_reg15 = 0x5f COMMA
98447 +    DW_OP_reg16 = 0x60 COMMA
98448 +    DW_OP_reg17 = 0x61 COMMA
98449 +    DW_OP_reg18 = 0x62 COMMA
98450 +    DW_OP_reg19 = 0x63 COMMA
98451 +    DW_OP_reg20 = 0x64 COMMA
98452 +    DW_OP_reg21 = 0x65 COMMA
98453 +    DW_OP_reg22 = 0x66 COMMA
98454 +    DW_OP_reg23 = 0x67 COMMA
98455 +    DW_OP_reg24 = 0x68 COMMA
98456 +    DW_OP_reg25 = 0x69 COMMA
98457 +    DW_OP_reg26 = 0x6a COMMA
98458 +    DW_OP_reg27 = 0x6b COMMA
98459 +    DW_OP_reg28 = 0x6c COMMA
98460 +    DW_OP_reg29 = 0x6d COMMA
98461 +    DW_OP_reg30 = 0x6e COMMA
98462 +    DW_OP_reg31 = 0x6f COMMA
98463 +    DW_OP_breg0 = 0x70 COMMA
98464 +    DW_OP_breg1 = 0x71 COMMA
98465 +    DW_OP_breg2 = 0x72 COMMA
98466 +    DW_OP_breg3 = 0x73 COMMA
98467 +    DW_OP_breg4 = 0x74 COMMA
98468 +    DW_OP_breg5 = 0x75 COMMA
98469 +    DW_OP_breg6 = 0x76 COMMA
98470 +    DW_OP_breg7 = 0x77 COMMA
98471 +    DW_OP_breg8 = 0x78 COMMA
98472 +    DW_OP_breg9 = 0x79 COMMA
98473 +    DW_OP_breg10 = 0x7a COMMA
98474 +    DW_OP_breg11 = 0x7b COMMA
98475 +    DW_OP_breg12 = 0x7c COMMA
98476 +    DW_OP_breg13 = 0x7d COMMA
98477 +    DW_OP_breg14 = 0x7e COMMA
98478 +    DW_OP_breg15 = 0x7f COMMA
98479 +    DW_OP_breg16 = 0x80 COMMA
98480 +    DW_OP_breg17 = 0x81 COMMA
98481 +    DW_OP_breg18 = 0x82 COMMA
98482 +    DW_OP_breg19 = 0x83 COMMA
98483 +    DW_OP_breg20 = 0x84 COMMA
98484 +    DW_OP_breg21 = 0x85 COMMA
98485 +    DW_OP_breg22 = 0x86 COMMA
98486 +    DW_OP_breg23 = 0x87 COMMA
98487 +    DW_OP_breg24 = 0x88 COMMA
98488 +    DW_OP_breg25 = 0x89 COMMA
98489 +    DW_OP_breg26 = 0x8a COMMA
98490 +    DW_OP_breg27 = 0x8b COMMA
98491 +    DW_OP_breg28 = 0x8c COMMA
98492 +    DW_OP_breg29 = 0x8d COMMA
98493 +    DW_OP_breg30 = 0x8e COMMA
98494 +    DW_OP_breg31 = 0x8f COMMA
98495 +    DW_OP_regx = 0x90 COMMA
98496 +    DW_OP_fbreg = 0x91 COMMA
98497 +    DW_OP_bregx = 0x92 COMMA
98498 +    DW_OP_piece = 0x93 COMMA
98499 +    DW_OP_deref_size = 0x94 COMMA
98500 +    DW_OP_xderef_size = 0x95 COMMA
98501 +    DW_OP_nop = 0x96 COMMA
98502 +    /* DWARF 3 extensions.  */
98503 +    DW_OP_push_object_address = 0x97 COMMA
98504 +    DW_OP_call2 = 0x98 COMMA
98505 +    DW_OP_call4 = 0x99 COMMA
98506 +    DW_OP_call_ref = 0x9a COMMA
98507 +    /* GNU extensions. */
98508 +    DW_OP_GNU_push_tls_address = 0xe0
98509 +IF_NOT_ASM(};)
98510 +
98511 +#define DW_OP_lo_user  0xe0    /* Implementation-defined range start.  */
98512 +#define DW_OP_hi_user  0xff    /* Implementation-defined range end.  */
98513 +
98514 +/* Type encodings.  */
98515 +ENUM(dwarf_type)
98516 +
98517 +    DW_ATE_void = 0x0 COMMA
98518 +    DW_ATE_address = 0x1 COMMA
98519 +    DW_ATE_boolean = 0x2 COMMA
98520 +    DW_ATE_complex_float = 0x3 COMMA
98521 +    DW_ATE_float = 0x4 COMMA
98522 +    DW_ATE_signed = 0x5 COMMA
98523 +    DW_ATE_signed_char = 0x6 COMMA
98524 +    DW_ATE_unsigned = 0x7 COMMA
98525 +    DW_ATE_unsigned_char = 0x8 COMMA
98526 +    /* DWARF 3.  */
98527 +    DW_ATE_imaginary_float = 0x9
98528 +IF_NOT_ASM(};)
98529 +
98530 +#define        DW_ATE_lo_user 0x80
98531 +#define        DW_ATE_hi_user 0xff
98532 +
98533 +/* Array ordering names and codes.  */
98534 +ENUM(dwarf_array_dim_ordering)
98535 +
98536 +    DW_ORD_row_major = 0 COMMA
98537 +    DW_ORD_col_major = 1
98538 +IF_NOT_ASM(};)
98539 +
98540 +/* Access attribute.  */
98541 +ENUM(dwarf_access_attribute)
98542 +
98543 +    DW_ACCESS_public = 1 COMMA
98544 +    DW_ACCESS_protected = 2 COMMA
98545 +    DW_ACCESS_private = 3
98546 +IF_NOT_ASM(};)
98547 +
98548 +/* Visibility. */
98549 +ENUM(dwarf_visibility_attribute)
98550 +
98551 +    DW_VIS_local = 1 COMMA
98552 +    DW_VIS_exported = 2 COMMA
98553 +    DW_VIS_qualified = 3
98554 +IF_NOT_ASM(};)
98555 +
98556 +/* Virtuality. */
98557 +ENUM(dwarf_virtuality_attribute)
98558 +
98559 +    DW_VIRTUALITY_none = 0 COMMA
98560 +    DW_VIRTUALITY_virtual = 1 COMMA
98561 +    DW_VIRTUALITY_pure_virtual = 2
98562 +IF_NOT_ASM(};)
98563 +
98564 +/* Case sensitivity.  */
98565 +ENUM(dwarf_id_case)
98566 +
98567 +    DW_ID_case_sensitive = 0 COMMA
98568 +    DW_ID_up_case = 1 COMMA
98569 +    DW_ID_down_case = 2 COMMA
98570 +    DW_ID_case_insensitive = 3
98571 +IF_NOT_ASM(};)
98572 +
98573 +/* Calling convention. */
98574 +ENUM(dwarf_calling_convention)
98575 +
98576 +    DW_CC_normal = 0x1 COMMA
98577 +    DW_CC_program = 0x2 COMMA
98578 +    DW_CC_nocall = 0x3
98579 +IF_NOT_ASM(};)
98580 +
98581 +#define DW_CC_lo_user 0x40
98582 +#define DW_CC_hi_user 0xff
98583 +
98584 +/* Inline attribute.  */
98585 +ENUM(dwarf_inline_attribute)
98586 +
98587 +    DW_INL_not_inlined = 0 COMMA
98588 +    DW_INL_inlined = 1 COMMA
98589 +    DW_INL_declared_not_inlined = 2 COMMA
98590 +    DW_INL_declared_inlined = 3
98591 +IF_NOT_ASM(};)
98592 +
98593 +/* Discriminant lists. */
98594 +ENUM(dwarf_discrim_list)
98595 +
98596 +    DW_DSC_label = 0 COMMA
98597 +    DW_DSC_range = 1
98598 +IF_NOT_ASM(};)
98599 +
98600 +/* Line number opcodes.  */
98601 +ENUM(dwarf_line_number_ops)
98602 +
98603 +    DW_LNS_extended_op = 0 COMMA
98604 +    DW_LNS_copy = 1 COMMA
98605 +    DW_LNS_advance_pc = 2 COMMA
98606 +    DW_LNS_advance_line = 3 COMMA
98607 +    DW_LNS_set_file = 4 COMMA
98608 +    DW_LNS_set_column = 5 COMMA
98609 +    DW_LNS_negate_stmt = 6 COMMA
98610 +    DW_LNS_set_basic_block = 7 COMMA
98611 +    DW_LNS_const_add_pc = 8 COMMA
98612 +    DW_LNS_fixed_advance_pc = 9 COMMA
98613 +    /* DWARF 3.  */
98614 +    DW_LNS_set_prologue_end = 10 COMMA
98615 +    DW_LNS_set_epilogue_begin = 11 COMMA
98616 +    DW_LNS_set_isa = 12
98617 +IF_NOT_ASM(};)
98618 +
98619 +/* Line number extended opcodes.  */
98620 +ENUM(dwarf_line_number_x_ops)
98621 +
98622 +    DW_LNE_end_sequence = 1 COMMA
98623 +    DW_LNE_set_address = 2 COMMA
98624 +    DW_LNE_define_file = 3
98625 +IF_NOT_ASM(};)
98626 +
98627 +/* Call frame information.  */
98628 +ENUM(dwarf_call_frame_info)
98629 +
98630 +    DW_CFA_advance_loc = 0x40 COMMA
98631 +    DW_CFA_offset = 0x80 COMMA
98632 +    DW_CFA_restore = 0xc0 COMMA
98633 +    DW_CFA_nop = 0x00 COMMA
98634 +    DW_CFA_set_loc = 0x01 COMMA
98635 +    DW_CFA_advance_loc1 = 0x02 COMMA
98636 +    DW_CFA_advance_loc2 = 0x03 COMMA
98637 +    DW_CFA_advance_loc4 = 0x04 COMMA
98638 +    DW_CFA_offset_extended = 0x05 COMMA
98639 +    DW_CFA_restore_extended = 0x06 COMMA
98640 +    DW_CFA_undefined = 0x07 COMMA
98641 +    DW_CFA_same_value = 0x08 COMMA
98642 +    DW_CFA_register = 0x09 COMMA
98643 +    DW_CFA_remember_state = 0x0a COMMA
98644 +    DW_CFA_restore_state = 0x0b COMMA
98645 +    DW_CFA_def_cfa = 0x0c COMMA
98646 +    DW_CFA_def_cfa_register = 0x0d COMMA
98647 +    DW_CFA_def_cfa_offset = 0x0e COMMA
98648 +
98649 +    /* DWARF 3.  */
98650 +    DW_CFA_def_cfa_expression = 0x0f COMMA
98651 +    DW_CFA_expression = 0x10 COMMA
98652 +    DW_CFA_offset_extended_sf = 0x11 COMMA
98653 +    DW_CFA_def_cfa_sf = 0x12 COMMA
98654 +    DW_CFA_def_cfa_offset_sf = 0x13 COMMA
98655 +
98656 +    /* SGI/MIPS specific.  */
98657 +    DW_CFA_MIPS_advance_loc8 = 0x1d COMMA
98658 +
98659 +    /* GNU extensions. */
98660 +    DW_CFA_GNU_window_save = 0x2d COMMA
98661 +    DW_CFA_GNU_args_size = 0x2e COMMA
98662 +    DW_CFA_GNU_negative_offset_extended = 0x2f
98663 +IF_NOT_ASM(};)
98664 +
98665 +#define DW_CIE_ID        0xffffffff
98666 +#define DW_CIE_VERSION   1
98667 +
98668 +#define DW_CFA_extended   0
98669 +#define DW_CFA_lo_user   0x1c
98670 +#define DW_CFA_hi_user   0x3f
98671 +
98672 +#define DW_CHILDREN_no              0x00
98673 +#define DW_CHILDREN_yes                     0x01
98674 +
98675 +#define DW_ADDR_none           0
98676 +
98677 +/* Source language names and codes.  */
98678 +ENUM(dwarf_source_language)
98679 +
98680 +    DW_LANG_C89 = 0x0001 COMMA
98681 +    DW_LANG_C = 0x0002 COMMA
98682 +    DW_LANG_Ada83 = 0x0003 COMMA
98683 +    DW_LANG_C_plus_plus = 0x0004 COMMA
98684 +    DW_LANG_Cobol74 = 0x0005 COMMA
98685 +    DW_LANG_Cobol85 = 0x0006 COMMA
98686 +    DW_LANG_Fortran77 = 0x0007 COMMA
98687 +    DW_LANG_Fortran90 = 0x0008 COMMA
98688 +    DW_LANG_Pascal83 = 0x0009 COMMA
98689 +    DW_LANG_Modula2 = 0x000a COMMA
98690 +    DW_LANG_Java = 0x000b COMMA
98691 +    /* DWARF 3.  */
98692 +    DW_LANG_C99 = 0x000c COMMA
98693 +    DW_LANG_Ada95 = 0x000d COMMA
98694 +    DW_LANG_Fortran95 = 0x000e COMMA
98695 +    /* MIPS.  */
98696 +    DW_LANG_Mips_Assembler = 0x8001 COMMA
98697 +    /* UPC.  */
98698 +    DW_LANG_Upc = 0x8765
98699 +IF_NOT_ASM(};)
98700 +
98701 +#define DW_LANG_lo_user 0x8000 /* Implementation-defined range start.  */
98702 +#define DW_LANG_hi_user 0xffff /* Implementation-defined range start.  */
98703 +
98704 +/* Names and codes for macro information.  */
98705 +ENUM(dwarf_macinfo_record_type)
98706 +
98707 +    DW_MACINFO_define = 1 COMMA
98708 +    DW_MACINFO_undef = 2 COMMA
98709 +    DW_MACINFO_start_file = 3 COMMA
98710 +    DW_MACINFO_end_file = 4 COMMA
98711 +    DW_MACINFO_vendor_ext = 255
98712 +IF_NOT_ASM(};)
98713 +\f
98714 +/* @@@ For use with GNU frame unwind information.  */
98715 +
98716 +#define DW_EH_PE_absptr                0x00
98717 +#define DW_EH_PE_omit          0xff
98718 +
98719 +#define DW_EH_PE_uleb128       0x01
98720 +#define DW_EH_PE_udata2                0x02
98721 +#define DW_EH_PE_udata4                0x03
98722 +#define DW_EH_PE_udata8                0x04
98723 +#define DW_EH_PE_sleb128       0x09
98724 +#define DW_EH_PE_sdata2                0x0A
98725 +#define DW_EH_PE_sdata4                0x0B
98726 +#define DW_EH_PE_sdata8                0x0C
98727 +#define DW_EH_PE_signed                0x08
98728 +
98729 +#define DW_EH_PE_pcrel         0x10
98730 +#define DW_EH_PE_textrel       0x20
98731 +#define DW_EH_PE_datarel       0x30
98732 +#define DW_EH_PE_funcrel       0x40
98733 +#define DW_EH_PE_aligned       0x50
98734 +
98735 +#define DW_EH_PE_indirect      0x80
98736 +
98737 +#endif /* _ELF_DWARF2_H */
98738 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
98739 +++ 25/include/linux/dwarf2-lang.h      2003-10-05 00:33:38.000000000 -0700
98740 @@ -0,0 +1,132 @@
98741 +#ifndef DWARF2_LANG
98742 +#define DWARF2_LANG
98743 +#include <linux/dwarf2.h>
98744 +
98745 +/*
98746 + * This is free software; you can redistribute it and/or modify it under
98747 + * the terms of the GNU General Public License as published by the Free
98748 + * Software Foundation; either version 2, or (at your option) any later
98749 + * version.
98750 + */
98751 +/*
98752 + * This file defines macros that allow generation of DWARF debug records
98753 + * for asm files.  This file is platform independent.  Register numbers
98754 + * (which are about the only thing that is platform dependent) are to be
98755 + * supplied by a platform defined file.
98756 + */
98757 +#define DWARF_preamble()       .section        .debug_frame,"",@progbits
98758 +/*
98759 + * This macro starts a debug frame section.  The debug_frame describes
98760 + * where to find the registers that the enclosing function saved on
98761 + * entry.
98762 + *
98763 + * ORD is use by the label generator and should be the same as what is
98764 + * passed to CFI_postamble.
98765 + *
98766 + * pc, pc register gdb ordinal.
98767 + *
98768 + * code_align this is the factor used to define locations or regions
98769 + * where the given definitions apply.  If you use labels to define these
98770 + * this should be 1.
98771 + *
98772 + * data_align this is the factor used to define register offsets.  If
98773 + * you use struct offset, this should be the size of the register in
98774 + * bytes or the negative of that.  This is how it is used: you will
98775 + * define a register as the reference register, say the stack pointer,
98776 + * then you will say where a register is located relative to this
98777 + * reference registers value, say 40 for register 3 (the gdb register
98778 + * number).  The <40> will be multiplied by <data_align> to define the
98779 + * byte offset of the given register (3, in this example).  So if your
98780 + * <40> is the byte offset and the reference register points at the
98781 + * begining, you would want 1 for the data_offset.  If <40> was the 40th
98782 + * 4-byte element in that structure you would want 4.  And if your
98783 + * reference register points at the end of the structure you would want
98784 + * a negative data_align value(and you would have to do other math as
98785 + * well).
98786 + */
98787 +
98788 +#define CFI_preamble(ORD, pc, code_align, data_align)  \
98789 +.section       .debug_frame,"",@progbits ;             \
98790 +frame/**/_/**/ORD:                                             \
98791 +       .long end/**/_/**/ORD-start/**/_/**/ORD;                        \
98792 +start/**/_/**/ORD:                                             \
98793 +       .long   DW_CIE_ID;                              \
98794 +       .byte   DW_CIE_VERSION;                 \
98795 +       .byte 0  ;                              \
98796 +       .uleb128 code_align;                            \
98797 +       .sleb128 data_align;                            \
98798 +       .byte pc;
98799 +
98800 +/*
98801 + * After the above macro and prior to the CFI_postamble, you need to
98802 + * define the initial state.  This starts with defining the reference
98803 + * register and, usually the pc.  Here are some helper macros:
98804 + */
98805 +
98806 +#define CFA_define_reference(reg, offset)      \
98807 +       .byte DW_CFA_def_cfa;                   \
98808 +       .uleb128 reg;                           \
98809 +       .uleb128 (offset);
98810 +
98811 +#define CFA_define_offset(reg, offset)         \
98812 +       .byte (DW_CFA_offset + reg);            \
98813 +       .uleb128 (offset);
98814 +
98815 +#define CFI_postamble(ORD)                     \
98816 +       .align 4;                               \
98817 +end/**/_/**/ORD:
98818 +/*
98819 + * So now your code pushs stuff on the stack, you need a new location
98820 + * and the rules for what to do.  This starts a running description of
98821 + * the call frame.  You need to describe what changes with respect to
98822 + * the call registers as the location of the pc moves through the code.
98823 + * The following builds an FDE (fram descriptor entry?).  Like the
98824 + * above, it has a preamble and a postamble.  It also is tied to the CFI
98825 + * above.
98826 + * The first entry after the preamble must be the location in the code
98827 + * that the call frame is being described for.
98828 + */
98829 +#define FDE_preamble(ORD, fde_no, initial_address, length)     \
98830 +       .long FDE_end/**/_/**/fde_no-FDE_start/**/_/**/fde_no;          \
98831 +FDE_start/**/_/**/fde_no:                                              \
98832 +       .long frame/**/_/**/ORD;                                        \
98833 +       .long initial_address;                                  \
98834 +       .long length;
98835 +
98836 +#define FDE_postamble(fde_no)                  \
98837 +       .align 4;                               \
98838 +FDE_end/**/_/**/fde_no:
98839 +/*
98840 + * That done, you can now add registers, subtract registers, move the
98841 + * reference and even change the reference.  You can also define a new
98842 + * area of code the info applies to.  For discontinuous bits you should
98843 + * start a new FDE.  You may have as many as you like.
98844 + */
98845 +
98846 +/*
98847 + * To advance the address by <bytes>
98848 + */
98849 +
98850 +#define FDE_advance(bytes)                     \
98851 +       .byte DW_CFA_advance_loc4               \
98852 +       .long bytes
98853 +
98854 +
98855 +
98856 +/*
98857 + * With the above you can define all the register locations.  But
98858 + * suppose the reference register moves... Takes the new offset NOT an
98859 + * increment.  This is how esp is tracked if it is not saved.
98860 + */
98861 +
98862 +#define CFA_define_cfa_offset(offset) \
98863 +       .byte $DW_CFA_def_cfa_offset; \
98864 +       .uleb128 (offset);
98865 +/*
98866 + * Or suppose you want to use a different reference register...
98867 + */
98868 +#define CFA_define_cfa_register(reg)           \
98869 +       .byte DW_CFA_def_cfa_register;          \
98870 +       .uleb128 reg;
98871 +
98872 +#endif
98873 --- linux-2.6.0-test6/include/linux/efi.h       2003-08-08 22:55:14.000000000 -0700
98874 +++ 25/include/linux/efi.h      2003-10-05 00:36:22.000000000 -0700
98875 @@ -16,6 +16,8 @@
98876  #include <linux/time.h>
98877  #include <linux/types.h>
98878  #include <linux/proc_fs.h>
98879 +#include <linux/rtc.h>
98880 +#include <linux/ioport.h>
98881  
98882  #include <asm/page.h>
98883  #include <asm/system.h>
98884 @@ -89,6 +91,11 @@ typedef      struct {
98885  
98886  #define EFI_PAGE_SHIFT         12
98887  
98888 +/*
98889 + * For current x86 implementations of EFI, there is
98890 + * additional padding in the mem descriptors.  This is not
98891 + * the case in ia64.  Need to have this fixed in the f/w.
98892 + */
98893  typedef struct {
98894         u32 type;
98895         u32 pad;
98896 @@ -96,6 +103,9 @@ typedef struct {
98897         u64 virt_addr;
98898         u64 num_pages;
98899         u64 attribute;
98900 +#if defined (__i386__)
98901 +       u64 pad1;
98902 +#endif
98903  } efi_memory_desc_t;
98904  
98905  typedef int efi_freemem_callback_t (unsigned long start, unsigned long end, void *arg);
98906 @@ -132,6 +142,7 @@ typedef struct {
98907   */
98908  #define EFI_RESET_COLD 0
98909  #define EFI_RESET_WARM 1
98910 +#define EFI_RESET_SHUTDOWN 2
98911  
98912  /*
98913   * EFI Runtime Services table
98914 @@ -169,6 +180,10 @@ typedef efi_status_t efi_set_variable_t 
98915  typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count);
98916  typedef void efi_reset_system_t (int reset_type, efi_status_t status,
98917                                  unsigned long data_size, efi_char16_t *data);
98918 +typedef efi_status_t efi_set_virtual_address_map_t (unsigned long memory_map_size,
98919 +                                               unsigned long descriptor_size,
98920 +                                               u32 descriptor_version,
98921 +                                               efi_memory_desc_t *virtual_map);
98922  
98923  /*
98924   *  EFI Configuration Table and GUID definitions
98925 @@ -194,6 +209,9 @@ typedef void efi_reset_system_t (int res
98926  #define HCDP_TABLE_GUID        \
98927      EFI_GUID(  0xf951938d, 0x620b, 0x42ef, 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 )
98928  
98929 +#define UGA_IO_PROTOCOL_GUID \
98930 +    EFI_GUID(  0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0xb, 0x7, 0xa2 )
98931 +
98932  typedef struct {
98933         efi_guid_t guid;
98934         unsigned long table;
98935 @@ -218,6 +236,13 @@ typedef struct {
98936         unsigned long tables;
98937  } efi_system_table_t;
98938  
98939 +struct efi_memory_map {
98940 +       efi_memory_desc_t *phys_map;
98941 +       efi_memory_desc_t *map;
98942 +       int nr_map;
98943 +       unsigned long desc_version;
98944 +};
98945 +
98946  /*
98947   * All runtime access to EFI goes through this structure:
98948   */
98949 @@ -230,6 +255,7 @@ extern struct efi {
98950         void *sal_systab;               /* SAL system table */
98951         void *boot_info;                /* boot info table */
98952         void *hcdp;                     /* HCDP table */
98953 +       void *uga;                      /* UGA table */
98954         efi_get_time_t *get_time;
98955         efi_set_time_t *set_time;
98956         efi_get_wakeup_time_t *get_wakeup_time;
98957 @@ -239,6 +265,7 @@ extern struct efi {
98958         efi_set_variable_t *set_variable;
98959         efi_get_next_high_mono_count_t *get_next_high_mono_count;
98960         efi_reset_system_t *reset_system;
98961 +       efi_set_virtual_address_map_t *set_virtual_address_map;
98962  } efi;
98963  
98964  static inline int
98965 @@ -260,12 +287,18 @@ efi_guid_unparse(efi_guid_t *guid, char 
98966  
98967  extern void efi_init (void);
98968  extern void efi_map_pal_code (void);
98969 +extern void efi_map_memmap(void);
98970  extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg);
98971  extern void efi_gettimeofday (struct timespec *ts);
98972  extern void efi_enter_virtual_mode (void);     /* switch EFI to virtual mode, if possible */
98973  extern u64 efi_get_iobase (void);
98974  extern u32 efi_mem_type (unsigned long phys_addr);
98975  extern u64 efi_mem_attributes (unsigned long phys_addr);
98976 +extern void efi_initialize_iomem_resources(struct resource *code_resource,
98977 +                                       struct resource *data_resource);
98978 +extern efi_status_t phys_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc);
98979 +extern struct efi_memory_map memmap;
98980 +extern int efi_enabled;
98981  
98982  /*
98983   * Variable Attributes
98984 --- linux-2.6.0-test6/include/linux/eisa.h      2003-09-27 18:57:47.000000000 -0700
98985 +++ 25/include/linux/eisa.h     2003-10-05 00:36:11.000000000 -0700
98986 @@ -4,16 +4,6 @@
98987  #include <linux/ioport.h>
98988  #include <linux/device.h>
98989  
98990 -#ifdef CONFIG_EISA
98991 -# ifdef CONFIG_EISA_ALWAYS
98992 -#  define EISA_bus 1
98993 -# else
98994 -   extern int EISA_bus;
98995 -# endif
98996 -#else
98997 -# define EISA_bus 0
98998 -#endif
98999 -
99000  #define EISA_SIG_LEN   8
99001  #define EISA_MAX_SLOTS 8
99002  
99003 @@ -108,4 +98,10 @@ struct eisa_root_device {
99004  
99005  int eisa_root_register (struct eisa_root_device *root);
99006  
99007 +#ifdef CONFIG_EISA
99008 +extern int EISA_bus;
99009 +#else
99010 +# define EISA_bus 0
99011 +#endif
99012 +
99013  #endif
99014 --- linux-2.6.0-test6/include/linux/elevator.h  2003-09-27 18:57:47.000000000 -0700
99015 +++ 25/include/linux/elevator.h 2003-10-05 00:34:17.000000000 -0700
99016 @@ -94,6 +94,11 @@ extern elevator_t iosched_deadline;
99017   */
99018  extern elevator_t iosched_as;
99019  
99020 +/*
99021 + * completely fair queueing I/O scheduler
99022 + */
99023 +extern elevator_t iosched_cfq;
99024 +
99025  extern int elevator_init(request_queue_t *, elevator_t *);
99026  extern void elevator_exit(request_queue_t *);
99027  extern inline int elv_rq_merge_ok(struct request *, struct bio *);
99028 --- linux-2.6.0-test6/include/linux/elf.h       2003-09-27 18:57:47.000000000 -0700
99029 +++ 25/include/linux/elf.h      2003-10-05 00:33:24.000000000 -0700
99030 @@ -395,6 +395,7 @@ typedef struct elf64_shdr {
99031  #define NT_PRFPREG     2
99032  #define NT_PRPSINFO    3
99033  #define NT_TASKSTRUCT  4
99034 +#define NT_AUXV                6
99035  #define NT_PRXFPREG     0x46e62b7f      /* copied from gdb5.1/include/elf/common.h */
99036  
99037  
99038 --- linux-2.6.0-test6/include/linux/errno.h     2003-06-26 22:07:26.000000000 -0700
99039 +++ 25/include/linux/errno.h    2003-10-05 00:36:54.000000000 -0700
99040 @@ -22,6 +22,7 @@
99041  #define EBADTYPE       527     /* Type not supported by server */
99042  #define EJUKEBOX       528     /* Request initiated, but will not complete before timeout */
99043  #define EIOCBQUEUED    529     /* iocb queued, will get completion event */
99044 +#define EIOCBRETRY     530     /* iocb queued, will trigger a retry */
99045  
99046  #endif
99047  
99048 --- linux-2.6.0-test6/include/linux/ext3_fs_i.h 2003-07-10 18:50:32.000000000 -0700
99049 +++ 25/include/linux/ext3_fs_i.h        2003-10-05 00:36:12.000000000 -0700
99050 @@ -106,7 +106,7 @@ struct ext3_inode_info {
99051          * during recovery.  Hence we must fix the get_block-vs-truncate race
99052          * by other means, so we have truncate_sem.
99053          */
99054 -       struct rw_semaphore truncate_sem;
99055 +       struct semaphore truncate_sem;
99056         struct inode vfs_inode;
99057  };
99058  
99059 --- linux-2.6.0-test6/include/linux/fb.h        2003-06-14 12:18:06.000000000 -0700
99060 +++ 25/include/linux/fb.h       2003-10-05 00:34:22.000000000 -0700
99061 @@ -2,7 +2,6 @@
99062  #define _LINUX_FB_H
99063  
99064  #include <linux/tty.h>
99065 -#include <linux/workqueue.h>
99066  #include <asm/types.h>
99067  #include <asm/io.h>
99068  
99069 @@ -326,28 +325,38 @@ struct fb_cursor {
99070         struct fb_image image;  /* Cursor image */
99071  };
99072  
99073 +#ifdef __KERNEL__
99074 +
99075 +#include <linux/fs.h>
99076 +#include <linux/init.h>
99077 +#include <linux/workqueue.h>
99078 +#include <linux/devfs_fs_kernel.h>
99079 +
99080 +/*
99081 + * The purpose of this structure is to translate data
99082 + * from the hardwre independent format of fbdev to what
99083 + * format the hardware needs.
99084 + */
99085 +
99086  #define FB_PIXMAP_DEFAULT 1     /* used internally by fbcon */
99087  #define FB_PIXMAP_SYSTEM  2     /* memory is in system RAM  */
99088  #define FB_PIXMAP_IO      4     /* memory is iomapped       */
99089  #define FB_PIXMAP_SYNC    256   /* set if GPU can DMA       */
99090  
99091  struct fb_pixmap {
99092 -        __u8  *addr;                      /* pointer to memory             */  
99093 -       __u32 size;                       /* size of buffer in bytes       */
99094 -       __u32 offset;                     /* current offset to buffer      */
99095 -       __u32 buf_align;                  /* byte alignment of each bitmap */
99096 -       __u32 scan_align;                 /* alignment per scanline        */
99097 -       __u32 flags;                      /* see FB_PIXMAP_*               */
99098 -                                         /* access methods                */
99099 -       void (*outbuf)(u8 *dst, u8 *addr, unsigned int size); 
99100 -       u8   (*inbuf) (u8 *addr);
99101 -       spinlock_t lock;                  /* spinlock                      */
99102 +       u8  *addr;              /* pointer to memory                    */
99103 +       u32 size;               /* size of buffer in bytes              */
99104 +       u32 offset;             /* current offset to buffer             */
99105 +       u32 buf_align;          /* byte alignment of each bitmap        */
99106 +       u32 scan_align;         /* alignment per scanline               */
99107 +       u32 access_align;       /* alignment per read/write             */
99108 +       u32 flags;              /* see FB_PIXMAP_*                      */
99109 +       spinlock_t lock;        /* spinlock                             */
99110         atomic_t count;
99111 +       /* access methods */
99112 +       void (*outbuf)(u8 *addr, u8 *dst, unsigned int size);
99113 +       u8   (*inbuf) (u8 *addr);
99114  };
99115 -#ifdef __KERNEL__
99116 -
99117 -#include <linux/fs.h>
99118 -#include <linux/init.h>
99119  
99120  struct fb_info;
99121  struct vm_area_struct;
99122 @@ -396,24 +405,24 @@ struct fb_ops {
99123  };
99124  
99125  struct fb_info {
99126 -   int node;
99127 -   int flags;
99128 -   int open;                            /* Has this been open already ? */
99129 +       int node;
99130 +       int flags;
99131  #define FBINFO_FLAG_MODULE     1       /* Low-level driver is a module */
99132 -   struct fb_var_screeninfo var;        /* Current var */
99133 -   struct fb_fix_screeninfo fix;        /* Current fix */
99134 -   struct fb_monspecs monspecs;         /* Current Monitor specs */
99135 -   struct fb_cursor cursor;            /* Current cursor */    
99136 -   struct work_struct queue;           /* Framebuffer event queue */
99137 -   struct fb_pixmap pixmap;            /* Current pixmap */
99138 -   struct fb_cmap cmap;                 /* Current cmap */
99139 -   struct fb_ops *fbops;
99140 -   char *screen_base;                   /* Virtual address */
99141 -   struct vc_data *display_fg;         /* Console visible on this display */
99142 -   int currcon;                                /* Current VC. */       
99143 -   void *pseudo_palette;                /* Fake palette of 16 colors */ 
99144 -   /* From here on everything is device dependent */
99145 -   void *par;  
99146 +       struct fb_var_screeninfo var;   /* Current var */
99147 +       struct fb_fix_screeninfo fix;   /* Current fix */
99148 +       struct fb_monspecs monspecs;    /* Current Monitor specs */
99149 +       struct fb_cursor cursor;        /* Current cursor */
99150 +       struct work_struct queue;       /* Framebuffer event queue */
99151 +       struct fb_pixmap pixmap;        /* Image HW mapper */
99152 +       struct fb_pixmap sprite;        /* Cursor HW mapper */
99153 +       struct fb_cmap cmap;            /* Current cmap */
99154 +       struct fb_ops *fbops;
99155 +       char *screen_base;              /* Virtual address */
99156 +       struct vc_data *display_fg;     /* Console visible on this display */
99157 +       void *pseudo_palette;           /* Fake palette of 16 colors */
99158 +       int currcon;                    /* Current VC. */
99159 +       /* From here on everything is device dependent */
99160 +       void *par;
99161  };
99162  
99163  #ifdef MODULE
99164 @@ -481,12 +490,12 @@ extern int register_framebuffer(struct f
99165  extern int unregister_framebuffer(struct fb_info *fb_info);
99166  extern int fb_prepare_logo(struct fb_info *fb_info);
99167  extern int fb_show_logo(struct fb_info *fb_info);
99168 -extern u32 fb_get_buffer_offset(struct fb_info *info, u32 size);
99169 -extern void move_buf_unaligned(struct fb_info *info, u8 *dst, u8 *src, u32 d_pitch,
99170 -                               u32 height, u32 mask, u32 shift_high, u32 shift_low,
99171 +extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size);
99172 +extern void move_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf, u8 *dst, u8 *src,
99173 +                               u32 d_pitch, u32 height, u32 mask, u32 shift_high, u32 shift_low,
99174                                 u32 mod, u32 idx);
99175 -extern void move_buf_aligned(struct fb_info *info, u8 *dst, u8 *src, u32 d_pitch,
99176 -                            u32 s_pitch, u32 height);
99177 +extern void move_buf_aligned(struct fb_info *info, struct fb_pixmap *buf, u8 *dst, u8 *src,
99178 +                            u32 d_pitch, u32 s_pitch, u32 height);
99179  extern struct fb_info *registered_fb[FB_MAX];
99180  extern int num_registered_fb;
99181  
99182 --- linux-2.6.0-test6/include/linux/fs.h        2003-09-27 18:57:47.000000000 -0700
99183 +++ 25/include/linux/fs.h       2003-10-05 00:37:00.000000000 -0700
99184 @@ -388,6 +388,7 @@ struct inode {
99185         unsigned short          i_bytes;
99186         spinlock_t              i_lock; /* i_blocks, i_bytes, maybe i_size */
99187         struct semaphore        i_sem;
99188 +       struct rw_semaphore     i_alloc_sem;
99189         struct inode_operations *i_op;
99190         struct file_operations  *i_fop; /* former ->i_op->default_file_ops */
99191         struct super_block      *i_sb;
99192 @@ -480,6 +481,8 @@ static inline unsigned imajor(struct ino
99193         return MAJOR(inode->i_rdev);
99194  }
99195  
99196 +extern struct block_device *I_BDEV(struct inode *inode);
99197 +
99198  struct fown_struct {
99199         rwlock_t lock;          /* protects pid, uid, euid fields */
99200         int pid;                /* pid or -pgrp where SIGIO should be sent */
99201 @@ -526,6 +529,7 @@ struct file {
99202         /* Used by fs/eventpoll.c to link all the hooks to this file */
99203         struct list_head        f_ep_links;
99204         spinlock_t              f_ep_lock;
99205 +       struct address_space    *f_mapping;
99206  };
99207  extern spinlock_t files_lock;
99208  #define file_list_lock() spin_lock(&files_lock);
99209 @@ -749,6 +753,11 @@ extern int vfs_rename(struct inode *, st
99210  #define DT_SOCK                12
99211  #define DT_WHT         14
99212  
99213 +#define OSYNC_METADATA (1<<0)
99214 +#define OSYNC_DATA     (1<<1)
99215 +#define OSYNC_INODE    (1<<2)
99216 +int generic_osync_inode(struct inode *, struct address_space *, int);
99217 +
99218  /*
99219   * This is the "filldir" function type, used by readdir() to let
99220   * the kernel specify what kind of dirent layout it wants to have.
99221 @@ -758,9 +767,9 @@ extern int vfs_rename(struct inode *, st
99222  typedef int (*filldir_t)(void *, const char *, int, loff_t, ino_t, unsigned);
99223  
99224  struct block_device_operations {
99225 -       int (*open) (struct inode *, struct file *);
99226 -       int (*release) (struct inode *, struct file *);
99227 -       int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
99228 +       int (*open) (struct block_device *, struct file *);
99229 +       int (*release) (struct gendisk *);
99230 +       int (*ioctl) (struct block_device *, struct file *, unsigned, unsigned long);
99231         int (*media_changed) (struct gendisk *);
99232         int (*revalidate_disk) (struct gendisk *);
99233         struct module *owner;
99234 @@ -1123,11 +1132,9 @@ enum {BDEV_FILE, BDEV_SWAP, BDEV_FS, BDE
99235  extern int register_blkdev(unsigned int, const char *);
99236  extern int unregister_blkdev(unsigned int, const char *);
99237  extern struct block_device *bdget(dev_t);
99238 -extern int bd_acquire(struct inode *inode);
99239  extern void bd_forget(struct inode *inode);
99240  extern void bdput(struct block_device *);
99241  extern int blkdev_open(struct inode *, struct file *);
99242 -extern int blkdev_close(struct inode *, struct file *);
99243  extern struct block_device *open_by_devnum(dev_t, unsigned, int);
99244  extern struct file_operations def_blk_fops;
99245  extern struct address_space_operations def_blk_aops;
99246 @@ -1135,7 +1142,7 @@ extern struct file_operations def_chr_fo
99247  extern struct file_operations bad_sock_fops;
99248  extern struct file_operations def_fifo_fops;
99249  extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
99250 -extern int blkdev_ioctl(struct inode *, struct file *, unsigned, unsigned long);
99251 +extern int blkdev_ioctl(struct block_device *, struct file *, unsigned, unsigned long);
99252  extern int blkdev_get(struct block_device *, mode_t, unsigned, int);
99253  extern int blkdev_put(struct block_device *, int);
99254  extern int bd_claim(struct block_device *, void *);
99255 @@ -1202,6 +1209,7 @@ extern void write_inode_now(struct inode
99256  extern int filemap_fdatawrite(struct address_space *);
99257  extern int filemap_flush(struct address_space *);
99258  extern int filemap_fdatawait(struct address_space *);
99259 +extern int filemap_write_and_wait(struct address_space *mapping);
99260  extern void sync_supers(void);
99261  extern void sync_filesystems(int wait);
99262  extern void emergency_sync(void);
99263 @@ -1295,8 +1303,7 @@ extern int generic_file_readonly_mmap(st
99264  extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
99265  extern int file_send_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
99266  extern ssize_t generic_file_read(struct file *, char __user *, size_t, loff_t *);
99267 -int generic_write_checks(struct inode *inode, struct file *file,
99268 -                       loff_t *pos, size_t *count, int isblk);
99269 +int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk);
99270  extern ssize_t generic_file_write(struct file *, const char __user *, size_t, loff_t *);
99271  extern ssize_t generic_file_aio_read(struct kiocb *, char __user *, size_t, loff_t);
99272  extern ssize_t __generic_file_aio_read(struct kiocb *, const struct iovec *, unsigned long, loff_t *);
99273 @@ -1314,9 +1321,6 @@ extern void
99274  file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
99275  extern ssize_t generic_file_direct_IO(int rw, struct kiocb *iocb,
99276         const struct iovec *iov, loff_t offset, unsigned long nr_segs);
99277 -extern int blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, 
99278 -       struct block_device *bdev, const struct iovec *iov, loff_t offset, 
99279 -       unsigned long nr_segs, get_blocks_t *get_blocks, dio_iodone_t *end_io);
99280  extern ssize_t generic_file_readv(struct file *filp, const struct iovec *iov, 
99281         unsigned long nr_segs, loff_t *ppos);
99282  ssize_t generic_file_writev(struct file *filp, const struct iovec *iov, 
99283 @@ -1330,7 +1334,7 @@ static inline void do_generic_file_read(
99284                                         read_descriptor_t * desc,
99285                                         read_actor_t actor)
99286  {
99287 -       do_generic_mapping_read(filp->f_dentry->d_inode->i_mapping,
99288 +       do_generic_mapping_read(filp->f_mapping,
99289                                 &filp->f_ra,
99290                                 filp,
99291                                 ppos,
99292 @@ -1338,6 +1342,32 @@ static inline void do_generic_file_read(
99293                                 actor);
99294  }
99295  
99296 +int __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
99297 +       struct block_device *bdev, const struct iovec *iov, loff_t offset,
99298 +       unsigned long nr_segs, get_blocks_t get_blocks, dio_iodone_t end_io,
99299 +       int needs_special_locking);
99300 +
99301 +/*
99302 + * For filesystems which need locking between buffered and direct access
99303 + */
99304 +static inline int blockdev_direct_IO(int rw, struct kiocb *iocb,
99305 +       struct inode *inode, struct block_device *bdev, const struct iovec *iov,
99306 +       loff_t offset, unsigned long nr_segs, get_blocks_t get_blocks,
99307 +       dio_iodone_t end_io)
99308 +{
99309 +       return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
99310 +                               nr_segs, get_blocks, end_io, 1);
99311 +}
99312 +
99313 +static inline int blockdev_direct_IO_no_locking(int rw, struct kiocb *iocb,
99314 +       struct inode *inode, struct block_device *bdev, const struct iovec *iov,
99315 +       loff_t offset, unsigned long nr_segs, get_blocks_t get_blocks,
99316 +       dio_iodone_t end_io)
99317 +{
99318 +       return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
99319 +                               nr_segs, get_blocks, end_io, 0);
99320 +}
99321 +
99322  extern struct file_operations generic_ro_fops;
99323  
99324  #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
99325 --- linux-2.6.0-test6/include/linux/ftape.h     2003-09-27 18:57:47.000000000 -0700
99326 +++ 25/include/linux/ftape.h    2003-10-05 00:33:24.000000000 -0700
99327 @@ -35,7 +35,6 @@
99328  #include <linux/mm.h>
99329  #endif
99330  #include <linux/types.h>
99331 -#include <linux/version.h>
99332  #include <linux/config.h>
99333  #include <linux/mtio.h>
99334  
99335 --- linux-2.6.0-test6/include/linux/hdlcdrv.h   2003-09-27 18:57:47.000000000 -0700
99336 +++ 25/include/linux/hdlcdrv.h  2003-10-05 00:33:24.000000000 -0700
99337 @@ -359,11 +359,11 @@ static inline int hdlcdrv_ptt(struct hdl
99338  void hdlcdrv_receiver(struct net_device *, struct hdlcdrv_state *);
99339  void hdlcdrv_transmitter(struct net_device *, struct hdlcdrv_state *);
99340  void hdlcdrv_arbitrate(struct net_device *, struct hdlcdrv_state *);
99341 -int hdlcdrv_register_hdlcdrv(struct net_device *dev, const struct hdlcdrv_ops *ops,
99342 -                            unsigned int privsize, char *ifname,
99343 -                            unsigned int baseaddr, unsigned int irq, 
99344 -                            unsigned int dma);
99345 -int hdlcdrv_unregister_hdlcdrv(struct net_device *dev);
99346 +struct net_device *hdlcdrv_register(const struct hdlcdrv_ops *ops,
99347 +                                   unsigned int privsize, const char *ifname,
99348 +                                   unsigned int baseaddr, unsigned int irq, 
99349 +                                   unsigned int dma);
99350 +void hdlcdrv_unregister(struct net_device *dev);
99351  
99352  /* -------------------------------------------------------------------- */
99353  
99354 --- linux-2.6.0-test6/include/linux/hfs_fs.h    2003-07-10 18:50:32.000000000 -0700
99355 +++ 25/include/linux/hfs_fs.h   2003-10-05 00:33:24.000000000 -0700
99356 @@ -267,9 +267,9 @@ extern void hfs_nat_drop_dentry(struct d
99357  
99358  /* file.c */
99359  extern hfs_s32 hfs_do_read(struct inode *, struct hfs_fork *, hfs_u32,
99360 -                          char *, hfs_u32);
99361 +                          char __user *, hfs_u32);
99362  extern hfs_s32 hfs_do_write(struct inode *, struct hfs_fork *, hfs_u32,
99363 -                           const char *, hfs_u32);
99364 +                           const char __user *, hfs_u32);
99365  extern void hfs_file_fix_mode(struct hfs_cat_entry *entry);
99366  extern struct inode_operations hfs_file_inode_operations;
99367  extern struct file_operations hfs_file_operations;
99368 --- linux-2.6.0-test6/include/linux/highuid.h   2003-06-14 12:18:23.000000000 -0700
99369 +++ 25/include/linux/highuid.h  2003-10-05 00:33:24.000000000 -0700
99370 @@ -56,6 +56,8 @@ extern int overflowgid;
99371  #define SET_GID16(var, gid)    var = high2lowgid(gid)
99372  #define NEW_TO_OLD_UID(uid)    high2lowuid(uid)
99373  #define NEW_TO_OLD_GID(gid)    high2lowgid(gid)
99374 +#define OLD_TO_NEW_UID(uid)    low2highuid(uid)
99375 +#define OLD_TO_NEW_GID(gid)    low2highgid(gid)
99376  
99377  /* specific to fs/stat.c */
99378  #define SET_OLDSTAT_UID(stat, uid)     (stat).st_uid = high2lowuid(uid)
99379 @@ -69,6 +71,8 @@ extern int overflowgid;
99380  #define SET_GID16(var, gid)    do { ; } while (0)
99381  #define NEW_TO_OLD_UID(uid)    (uid)
99382  #define NEW_TO_OLD_GID(gid)    (gid)
99383 +#define OLD_TO_NEW_UID(uid)    (uid)
99384 +#define OLD_TO_NEW_GID(gid)    (gid)
99385  
99386  #define SET_OLDSTAT_UID(stat, uid)     (stat).st_uid = (uid)
99387  #define SET_OLDSTAT_GID(stat, gid)     (stat).st_gid = (gid)
99388 --- linux-2.6.0-test6/include/linux/init_task.h 2003-08-22 19:23:42.000000000 -0700
99389 +++ 25/include/linux/init_task.h        2003-10-05 00:36:54.000000000 -0700
99390 @@ -108,6 +108,7 @@
99391         .proc_lock      = SPIN_LOCK_UNLOCKED,                           \
99392         .switch_lock    = SPIN_LOCK_UNLOCKED,                           \
99393         .journal_info   = NULL,                                         \
99394 +       .io_wait        = NULL,                                         \
99395  }
99396  
99397  
99398 --- linux-2.6.0-test6/include/linux/input.h     2003-09-27 18:57:47.000000000 -0700
99399 +++ 25/include/linux/input.h    2003-10-05 00:34:14.000000000 -0700
99400 @@ -870,6 +870,7 @@ struct input_handler {
99401         char *name;
99402  
99403         struct input_device_id *id_table;
99404 +       struct input_device_id *blacklist;
99405  
99406         struct list_head        h_list;
99407         struct list_head        node;
99408 --- linux-2.6.0-test6/include/linux/istallion.h 2003-06-14 12:18:01.000000000 -0700
99409 +++ 25/include/linux/istallion.h        2003-10-05 00:33:24.000000000 -0700
99410 @@ -21,6 +21,8 @@
99411   *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
99412   */
99413  
99414 +#include <linux/version.h>
99415 +
99416  /*****************************************************************************/
99417  #ifndef        _ISTALLION_H
99418  #define        _ISTALLION_H
99419 --- linux-2.6.0-test6/include/linux/linux_logo.h        2003-06-14 12:18:05.000000000 -0700
99420 +++ 25/include/linux/linux_logo.h       2003-10-05 00:34:22.000000000 -0700
99421 @@ -16,13 +16,11 @@
99422  
99423  #include <linux/init.h>
99424  
99425 -
99426  #define LINUX_LOGO_MONO                1       /* monochrome black/white */
99427  #define LINUX_LOGO_VGA16       2       /* 16 colors VGA text palette */
99428  #define LINUX_LOGO_CLUT224     3       /* 224 colors */
99429  #define LINUX_LOGO_GRAY256     4       /* 256 levels grayscale */
99430  
99431 -
99432  struct linux_logo {
99433         int type;                       /* one of LINUX_LOGO_* */
99434         unsigned int width;
99435 @@ -32,6 +30,6 @@ struct linux_logo {
99436         const unsigned char *data;
99437  };
99438  
99439 -extern const struct linux_logo *fb_find_logo(int depth);
99440 +extern const struct linux_logo *find_logo(int depth);
99441  
99442  #endif /* _LINUX_LINUX_LOGO_H */
99443 --- linux-2.6.0-test6/include/linux/list.h      2003-06-26 22:07:26.000000000 -0700
99444 +++ 25/include/linux/list.h     2003-10-05 00:36:37.000000000 -0700
99445 @@ -142,8 +142,11 @@ static inline void __list_del(struct lis
99446   * Note: list_empty on entry does not return true after this, the entry is
99447   * in an undefined state.
99448   */
99449 +#include <linux/kernel.h>      /* BUG_ON */
99450  static inline void list_del(struct list_head *entry)
99451  {
99452 +       BUG_ON(entry->prev->next != entry);
99453 +       BUG_ON(entry->next->prev != entry);
99454         __list_del(entry->prev, entry->next);
99455         entry->next = LIST_POISON1;
99456         entry->prev = LIST_POISON2;
99457 @@ -325,6 +328,19 @@ static inline void list_splice_init(stru
99458              pos = list_entry(pos->member.prev, typeof(*pos), member),  \
99459                      prefetch(pos->member.prev))
99460  
99461 +/**
99462 + * list_for_each_entry_continue -      iterate over list of given type
99463 + *                     continuing after existing point
99464 + * @pos:       the type * to use as a loop counter.
99465 + * @head:      the head for your list.
99466 + * @member:    the name of the list_struct within the struct.
99467 + */
99468 +#define list_for_each_entry_continue(pos, head, member)                \
99469 +       for (pos = list_entry(pos->member.next, typeof(*pos), member),  \
99470 +                    prefetch(pos->member.next);                        \
99471 +            &pos->member != (head);                                    \
99472 +            pos = list_entry(pos->member.next, typeof(*pos), member),  \
99473 +                    prefetch(pos->member.next))
99474  
99475  /**
99476   * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
99477 @@ -436,7 +452,7 @@ static __inline__ void hlist_del(struct 
99478  
99479  /**
99480   * hlist_del_rcu - deletes entry from hash list without re-initialization
99481 - * @entry: the element to delete from the hash list.
99482 + * @n: the element to delete from the hash list.
99483   *
99484   * Note: list_unhashed() on entry does not return true after this, 
99485   * the entry is in an undefined state. It is useful for RCU based
99486 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
99487 +++ 25/include/linux/lockmeter.h        2003-10-05 00:36:40.000000000 -0700
99488 @@ -0,0 +1,320 @@
99489 +/*
99490 + *  Copyright (C) 1999-2002 Silicon Graphics, Inc.
99491 + *
99492 + *  Written by John Hawkes (hawkes@sgi.com)
99493 + *  Based on klstat.h by Jack Steiner (steiner@sgi.com)
99494 + *
99495 + *  Modified by Ray Bryant (raybry@us.ibm.com) Feb-Apr 2000
99496 + *  Changes Copyright (C) 2000 IBM, Inc.
99497 + *  Added save of index in spinlock_t to improve efficiency
99498 + *  of "hold" time reporting for spinlocks
99499 + *  Added support for hold time statistics for read and write
99500 + *  locks.
99501 + *  Moved machine dependent code to include/asm/lockmeter.h.
99502 + *
99503 + */
99504 +
99505 +#ifndef _LINUX_LOCKMETER_H
99506 +#define _LINUX_LOCKMETER_H
99507 +
99508 +
99509 +/*---------------------------------------------------
99510 + *     architecture-independent lockmeter.h
99511 + *-------------------------------------------------*/
99512 +
99513 +/*
99514 + * raybry -- version 2: added efficient hold time statistics
99515 + *           requires lstat recompile, so flagged as new version
99516 + * raybry -- version 3: added global reader lock data
99517 + * hawkes -- version 4: removed some unnecessary fields to simplify mips64 port
99518 + */
99519 +#define LSTAT_VERSION  5
99520 +
99521 +int    lstat_update(void*, void*, int);
99522 +int    lstat_update_time(void*, void*, int, uint32_t);
99523 +
99524 +/*
99525 + * Currently, the mips64 and sparc64 kernels talk to a 32-bit lockstat, so we
99526 + * need to force compatibility in the inter-communication data structure.
99527 + */
99528 +
99529 +#if defined(CONFIG_MIPS32_COMPAT)
99530 +#define TIME_T         uint32_t
99531 +#elif defined(CONFIG_SPARC) || defined(CONFIG_SPARC64)
99532 +#define TIME_T         uint64_t
99533 +#else
99534 +#define TIME_T         time_t
99535 +#endif
99536 +
99537 +#if defined(__KERNEL__) || (!defined(CONFIG_MIPS32_COMPAT) && !defined(CONFIG_SPARC) && !defined(CONFIG_SPARC64)) || (_MIPS_SZLONG==32)
99538 +#define POINTER                void *
99539 +#else
99540 +#define        POINTER         int64_t
99541 +#endif
99542 +
99543 +/*
99544 + * Values for the "action" parameter passed to lstat_update.
99545 + *     ZZZ - do we want a try-success status here???
99546 + */
99547 +#define LSTAT_ACT_NO_WAIT      0
99548 +#define LSTAT_ACT_SPIN         1
99549 +#define LSTAT_ACT_REJECT       2
99550 +#define LSTAT_ACT_WW_SPIN       3
99551 +#define LSTAT_ACT_SLEPT                4 /* UNUSED */
99552 +
99553 +#define LSTAT_ACT_MAX_VALUES   4 /* NOTE: Increase to 5 if use ACT_SLEPT */
99554 +
99555 +/*
99556 + * Special values for the low 2 bits of an RA passed to
99557 + * lstat_update.
99558 + */
99559 +/* we use these values to figure out what kind of lock data */
99560 +/* is stored in the statistics table entry at index ....... */
99561 +#define LSTAT_RA_SPIN           0  /* spin lock data */
99562 +#define LSTAT_RA_READ           1  /* read lock statistics */
99563 +#define LSTAT_RA_SEMA          2  /* RESERVED */
99564 +#define LSTAT_RA_WRITE          3  /* write lock statistics*/
99565 +
99566 +#define LSTAT_RA(n)    \
99567 +       ((void*)( ((unsigned long)__builtin_return_address(0) & ~3) | n) )
99568 +
99569 +/*
99570 + * Constants used for lock addresses in the lstat_directory
99571 + * to indicate special values of the lock address.
99572 + */
99573 +#define        LSTAT_MULTI_LOCK_ADDRESS        NULL
99574 +
99575 +/*
99576 + * Maximum size of the lockstats tables. Increase this value
99577 + * if its not big enough. (Nothing bad happens if its not
99578 + * big enough although some locks will not be monitored.)
99579 + * We record overflows of this quantity in lstat_control.dir_overflows
99580 + *
99581 + * Note:  The max value here must fit into the field set
99582 + * and obtained by the macro's PUT_INDEX() and GET_INDEX().
99583 + * This value depends on how many bits are available in the
99584 + * lock word in the particular machine implementation we are on.
99585 + */
99586 +#define LSTAT_MAX_STAT_INDEX           2000
99587 +
99588 +/*
99589 + * Size and mask for the hash table into the directory.
99590 + */
99591 +#define LSTAT_HASH_TABLE_SIZE          4096            /* must be 2**N */
99592 +#define LSTAT_HASH_TABLE_MASK          (LSTAT_HASH_TABLE_SIZE-1)
99593 +
99594 +#define DIRHASH(ra)      ((unsigned long)(ra)>>2 & LSTAT_HASH_TABLE_MASK)
99595 +
99596 +/*
99597 + *     This defines an entry in the lockstat directory. It contains
99598 + *     information about a lock being monitored.
99599 + *     A directory entry only contains the lock identification -
99600 + *     counts on usage of the lock are kept elsewhere in a per-cpu
99601 + *     data structure to minimize cache line pinging.
99602 + */
99603 +typedef struct {
99604 +       POINTER caller_ra;                /* RA of code that set lock */
99605 +       POINTER lock_ptr;                 /* lock address */
99606 +       ushort  next_stat_index;  /* Used to link multiple locks that have the same hash table value */
99607 +} lstat_directory_entry_t;
99608 +
99609 +/*
99610 + *     A multi-dimensioned array used to contain counts for lock accesses.
99611 + *     The array is 3-dimensional:
99612 + *             - CPU number. Keep from thrashing cache lines between CPUs
99613 + *             - Directory entry index. Identifies the lock
99614 + *             - Action. Indicates what kind of contention occurred on an
99615 + *               access to the lock.
99616 + *
99617 + *     The index of an entry in the directory is the same as the 2nd index
99618 + *     of the entry in the counts array.
99619 + */
99620 +/*
99621 + *  This table contains data for spin_locks, write locks, and read locks
99622 + *  Not all data is used for all cases.  In particular, the hold time
99623 + *  information is not stored here for read locks since that is a global
99624 + *  (e. g. cannot be separated out by return address) quantity.
99625 + *  See the lstat_read_lock_counts_t structure for the global read lock
99626 + *  hold time.
99627 + */
99628 +typedef struct {
99629 +       uint64_t    cum_wait_ticks;     /* sum of wait times               */
99630 +                                       /* for write locks, sum of time a  */
99631 +                                       /* writer is waiting for a reader  */
99632 +       int64_t     cum_hold_ticks;     /* cumulative sum of holds         */
99633 +                                       /* not used for read mode locks    */
99634 +                                       /* must be signed. ............... */
99635 +       uint32_t    max_wait_ticks;     /* max waiting time                */
99636 +       uint32_t    max_hold_ticks;     /* max holding time                */
99637 +       uint64_t    cum_wait_ww_ticks;  /* sum times writer waits on writer*/
99638 +       uint32_t    max_wait_ww_ticks;  /* max wait time writer vs writer  */
99639 +                                       /* prev 2 only used for write locks*/
99640 +       uint32_t    acquire_time;       /* time lock acquired this CPU     */
99641 +       uint32_t    count[LSTAT_ACT_MAX_VALUES];
99642 +} lstat_lock_counts_t;
99643 +
99644 +typedef lstat_lock_counts_t    lstat_cpu_counts_t[LSTAT_MAX_STAT_INDEX];
99645 +
99646 +/*
99647 + * User request to:
99648 + *     - turn statistic collection on/off, or to reset
99649 + */
99650 +#define LSTAT_OFF       0
99651 +#define LSTAT_ON        1
99652 +#define LSTAT_RESET      2
99653 +#define LSTAT_RELEASE    3
99654 +
99655 +#define LSTAT_MAX_READ_LOCK_INDEX 1000
99656 +typedef struct {
99657 +       POINTER     lock_ptr;            /* address of lock for output stats */
99658 +       uint32_t    read_lock_count;
99659 +       int64_t     cum_hold_ticks;       /* sum of read lock hold times over */
99660 +                                         /* all callers. ....................*/
99661 +       uint32_t    write_index;          /* last write lock hash table index */
99662 +       uint32_t    busy_periods;         /* count of busy periods ended this */
99663 +       uint64_t    start_busy;           /* time this busy period started. ..*/
99664 +       uint64_t    busy_ticks;           /* sum of busy periods this lock. ..*/
99665 +       uint64_t    max_busy;             /* longest busy period for this lock*/
99666 +       uint32_t    max_readers;          /* maximum number of readers ...... */
99667 +#ifdef USER_MODE_TESTING
99668 +       rwlock_t    entry_lock;           /* lock for this read lock entry... */
99669 +                                         /* avoid having more than one rdr at*/
99670 +                                         /* needed for user space testing... */
99671 +                                         /* not needed for kernel 'cause it  */
99672 +                                         /* is non-preemptive. ............. */
99673 +#endif
99674 +} lstat_read_lock_counts_t;
99675 +typedef lstat_read_lock_counts_t       lstat_read_lock_cpu_counts_t[LSTAT_MAX_READ_LOCK_INDEX];
99676 +
99677 +#if defined(__KERNEL__) || defined(USER_MODE_TESTING)
99678 +
99679 +#ifndef USER_MODE_TESTING
99680 +#include <asm/lockmeter.h>
99681 +#else
99682 +#include "asm_newlockmeter.h"
99683 +#endif
99684 +
99685 +/*
99686 + * Size and mask for the hash table into the directory.
99687 + */
99688 +#define LSTAT_HASH_TABLE_SIZE          4096            /* must be 2**N */
99689 +#define LSTAT_HASH_TABLE_MASK          (LSTAT_HASH_TABLE_SIZE-1)
99690 +
99691 +#define DIRHASH(ra)      ((unsigned long)(ra)>>2 & LSTAT_HASH_TABLE_MASK)
99692 +
99693 +/*
99694 + * This version eliminates the per processor lock stack.  What we do is to
99695 + * store the index of the lock hash structure in unused bits in the lock
99696 + * itself.  Then on unlock we can find the statistics record without doing
99697 + * any additional hash or lock stack lookup.  This works for spin_locks.
99698 + * Hold time reporting is now basically as cheap as wait time reporting
99699 + * so we ignore the difference between LSTAT_ON_HOLD and LSTAT_ON_WAIT
99700 + * as in version 1.1.* of lockmeter.
99701 + *
99702 + * For rw_locks, we store the index of a global reader stats structure in
99703 + * the lock and the writer index is stored in the latter structure.
99704 + * For read mode locks we hash at the time of the lock to find an entry
99705 + * in the directory for reader wait time and the like.
99706 + * At unlock time for read mode locks, we update just the global structure
99707 + * so we don't need to know the reader directory index value at unlock time.
99708 + *
99709 + */
99710 +
99711 +/*
99712 + * Protocol to change lstat_control.state
99713 + *   This is complicated because we don't want the cum_hold_time for
99714 + * a rw_lock to be decremented in _read_lock_ without making sure it
99715 + * is incremented in _read_lock_ and vice versa.  So here is the
99716 + * way we change the state of lstat_control.state:
99717 + * I.  To Turn Statistics On
99718 + *     After allocating storage, set lstat_control.state non-zero.
99719 + * This works because we don't start updating statistics for in use
99720 + * locks until the reader lock count goes to zero.
99721 + * II. To Turn Statistics Off:
99722 + * (0)  Disable interrupts on this CPU
99723 + * (1)  Seize the lstat_control.directory_lock
99724 + * (2)  Obtain the current value of lstat_control.next_free_read_lock_index
99725 + * (3)  Store a zero in lstat_control.state.
99726 + * (4)  Release the lstat_control.directory_lock
99727 + * (5)  For each lock in the read lock list up to the saved value
99728 + *      (well, -1) of the next_free_read_lock_index, do the following:
99729 + *      (a)  Check validity of the stored lock address
99730 + *           by making sure that the word at the saved addr
99731 + *           has an index that matches this entry.  If not
99732 + *           valid, then skip this entry.
99733 + *      (b)  If there is a write lock already set on this lock,
99734 + *           skip to (d) below.
99735 + *      (c)  Set a non-metered write lock on the lock
99736 + *      (d)  set the cached INDEX in the lock to zero
99737 + *      (e)  Release the non-metered write lock.
99738 + * (6)  Re-enable interrupts
99739 + *
99740 + * These rules ensure that a read lock will not have its statistics
99741 + * partially updated even though the global lock recording state has
99742 + * changed.  See put_lockmeter_info() for implementation.
99743 + *
99744 + * The reason for (b) is that there may be write locks set on the
99745 + * syscall path to put_lockmeter_info() from user space.  If we do
99746 + * not do this check, then we can deadlock.  A similar problem would
99747 + * occur if the lock was read locked by the current CPU.  At the
99748 + * moment this does not appear to happen.
99749 + */
99750 +
99751 +/*
99752 + * Main control structure for lockstat. Used to turn statistics on/off
99753 + * and to maintain directory info.
99754 + */
99755 +typedef struct {
99756 +       int                             state;
99757 +       spinlock_t              control_lock;           /* used to serialize turning statistics on/off   */
99758 +       spinlock_t              directory_lock;         /* for serialize adding entries to directory     */
99759 +       volatile int    next_free_dir_index;/* next free entry in the directory */
99760 +       /* FIXME not all of these fields are used / needed .............. */
99761 +                /* the following fields represent data since     */
99762 +               /* first "lstat on" or most recent "lstat reset" */
99763 +       TIME_T      first_started_time;     /* time when measurement first enabled */
99764 +       TIME_T      started_time;           /* time when measurement last started  */
99765 +       TIME_T      ending_time;            /* time when measurement last disabled */
99766 +       uint64_t    started_cycles64;       /* cycles when measurement last started          */
99767 +       uint64_t    ending_cycles64;        /* cycles when measurement last disabled         */
99768 +       uint64_t    enabled_cycles64;       /* total cycles with measurement enabled         */
99769 +       int         intervals;              /* number of measurement intervals recorded      */
99770 +                                           /* i. e. number of times did lstat on;lstat off  */
99771 +       lstat_directory_entry_t *dir;           /* directory */
99772 +       int         dir_overflow;           /* count of times ran out of space in directory  */
99773 +       int         rwlock_overflow;        /* count of times we couldn't allocate a rw block*/
99774 +       ushort          *hashtab;                           /* hash table for quick dir scans */
99775 +       lstat_cpu_counts_t      *counts[NR_CPUS];        /* Array of pointers to per-cpu stats */
99776 +    int         next_free_read_lock_index;   /* next rwlock reader (global) stats block  */
99777 +    lstat_read_lock_cpu_counts_t *read_lock_counts[NR_CPUS]; /* per cpu read lock stats  */
99778 +} lstat_control_t;
99779 +
99780 +#endif /* defined(__KERNEL__) || defined(USER_MODE_TESTING) */
99781 +
99782 +typedef struct {
99783 +       short           lstat_version;          /* version of the data */
99784 +       short           state;                  /* the current state is returned */
99785 +       int             maxcpus;                /* Number of cpus present */
99786 +       int             next_free_dir_index;    /* index of the next free directory entry */
99787 +       TIME_T          first_started_time;     /* when measurement enabled for first time */
99788 +       TIME_T          started_time;           /* time in secs since 1969 when stats last turned on  */
99789 +       TIME_T          ending_time;            /* time in secs since 1969 when stats last turned off */
99790 +       uint32_t        cycleval;               /* cycles per second */
99791 +#ifdef notyet
99792 +       void            *kernel_magic_addr;     /* address of kernel_magic */
99793 +       void            *kernel_end_addr;       /* contents of kernel magic (points to "end") */
99794 +#endif
99795 +       int              next_free_read_lock_index; /* index of next (global) read lock stats struct */
99796 +       uint64_t         started_cycles64;      /* cycles when measurement last started        */
99797 +       uint64_t         ending_cycles64;       /* cycles when stats last turned off           */
99798 +       uint64_t         enabled_cycles64;      /* total cycles with measurement enabled       */
99799 +       int              intervals;             /* number of measurement intervals recorded      */
99800 +                                               /* i.e. number of times we did lstat on;lstat off*/
99801 +       int              dir_overflow;          /* number of times we wanted more space in directory */
99802 +       int              rwlock_overflow;       /* # of times we wanted more space in read_locks_count */
99803 +       struct new_utsname   uts;               /* info about machine where stats are measured */
99804 +                                               /* -T option of lockstat allows data to be     */
99805 +                                               /* moved to another machine. ................. */
99806 +} lstat_user_request_t;
99807 +
99808 +#endif /* _LINUX_LOCKMETER_H */
99809 --- linux-2.6.0-test6/include/linux/mca.h       2003-08-22 19:23:42.000000000 -0700
99810 +++ 25/include/linux/mca.h      2003-10-05 00:33:24.000000000 -0700
99811 @@ -136,10 +136,6 @@ extern void mca_unregister_driver(struct
99812  /* WARNING: only called by the boot time device setup */
99813  extern int mca_register_device(int bus, struct mca_device *mca_dev);
99814  
99815 -#ifdef CONFIG_MCA_LEGACY
99816 -#include <linux/mca-legacy.h>
99817 -#endif
99818 -
99819  #ifdef CONFIG_MCA_PROC_FS
99820  extern void mca_do_proc_init(void);
99821  extern void mca_set_adapter_procfn(int slot, MCA_ProcFn, void* dev);
99822 --- linux-2.6.0-test6/include/linux/mca-legacy.h        2003-06-14 12:18:51.000000000 -0700
99823 +++ 25/include/linux/mca-legacy.h       2003-10-05 00:33:24.000000000 -0700
99824 @@ -7,6 +7,8 @@
99825  #ifndef _LINUX_MCA_LEGACY_H
99826  #define _LINUX_MCA_LEGACY_H
99827  
99828 +#include <linux/mca.h>
99829 +
99830  #warning "MCA legacy - please move your driver to the new sysfs api"
99831  
99832  /* MCA_NOTFOUND is an error condition.  The other two indicate
99833 --- linux-2.6.0-test6/include/linux/mman.h      2003-09-08 13:58:59.000000000 -0700
99834 +++ 25/include/linux/mman.h     2003-10-05 00:34:49.000000000 -0700
99835 @@ -28,8 +28,13 @@ static inline void vm_unacct_memory(long
99836         vm_acct_memory(-pages);
99837  }
99838  
99839 -/* Optimisation macro. */
99840 -#define _calc_vm_trans(x,bit1,bit2) \
99841 +/*
99842 + * Optimisation macro.  It is equivalent to:
99843 + *      (x & bit1) ? bit2 : 0
99844 + * but this version is faster.
99845 + * ("bit1" and "bit2" must be single bits)
99846 + */
99847 +#define _calc_vm_trans(x, bit1, bit2) \
99848    ((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \
99849     : ((x) & (bit1)) / ((bit1) / (bit2)))
99850  
99851 --- linux-2.6.0-test6/include/linux/mm.h        2003-09-27 18:57:47.000000000 -0700
99852 +++ 25/include/linux/mm.h       2003-10-05 00:34:41.000000000 -0700
99853 @@ -196,7 +196,7 @@ struct page {
99854  #if defined(WANT_PAGE_VIRTUAL)
99855         void *virtual;                  /* Kernel virtual address (NULL if
99856                                            not kmapped, ie. highmem) */
99857 -#endif /* CONFIG_HIGMEM || WANT_PAGE_VIRTUAL */
99858 +#endif /* WANT_PAGE_VIRTUAL */
99859  };
99860  
99861  /*
99862 @@ -323,7 +323,6 @@ static inline void put_page(struct page 
99863   * The zone field is never updated after free_area_init_core()
99864   * sets it, so none of the operations on it need to be atomic.
99865   */
99866 -#define NODE_SHIFT 4
99867  #define ZONE_SHIFT (BITS_PER_LONG - 8)
99868  
99869  struct zone;
99870 --- linux-2.6.0-test6/include/linux/mmzone.h    2003-09-08 13:58:59.000000000 -0700
99871 +++ 25/include/linux/mmzone.h   2003-10-05 00:34:41.000000000 -0700
99872 @@ -10,13 +10,8 @@
99873  #include <linux/wait.h>
99874  #include <linux/cache.h>
99875  #include <linux/threads.h>
99876 +#include <linux/numa.h>
99877  #include <asm/atomic.h>
99878 -#ifdef CONFIG_DISCONTIGMEM
99879 -#include <asm/numnodes.h>
99880 -#endif
99881 -#ifndef MAX_NUMNODES
99882 -#define MAX_NUMNODES 1
99883 -#endif
99884  
99885  /* Free memory management - zoned buddy allocator.  */
99886  #ifndef CONFIG_FORCE_MAX_ZONEORDER
99887 @@ -303,19 +298,34 @@ extern void setup_per_zone_pages_min(voi
99888  #define numa_node_id()         (cpu_to_node(smp_processor_id()))
99889  
99890  #ifndef CONFIG_DISCONTIGMEM
99891 +
99892  extern struct pglist_data contig_page_data;
99893  #define NODE_DATA(nid)         (&contig_page_data)
99894  #define NODE_MEM_MAP(nid)      mem_map
99895 -#define MAX_NR_NODES           1
99896 +#define MAX_NODES_SHIFT                0
99897 +
99898  #else /* CONFIG_DISCONTIGMEM */
99899  
99900  #include <asm/mmzone.h>
99901  
99902 -/* page->zone is currently 8 bits ... */
99903 -#define MAX_NR_NODES           (255 / MAX_NR_ZONES)
99904 +#if BITS_PER_LONG == 32
99905 +/*
99906 + * with 32 bit flags field, page->zone is currently 8 bits.
99907 + * there are 3 zones (2 bits) and this leaves 8-2=6 bits for nodes.
99908 + */
99909 +#define MAX_NODES_SHIFT                6
99910 +#elif BITS_PER_LONG == 64
99911 +/*
99912 + * with 64 bit flags field, there's plenty of room.
99913 + */
99914 +#define MAX_NODES_SHIFT                10
99915 +#endif
99916  
99917  #endif /* !CONFIG_DISCONTIGMEM */
99918  
99919 +#if NODES_SHIFT > MAX_NODES_SHIFT
99920 +#error NODES_SHIFT > MAX_NODES_SHIFT
99921 +#endif
99922  
99923  extern DECLARE_BITMAP(node_online_map, MAX_NUMNODES);
99924  extern DECLARE_BITMAP(memblk_online_map, MAX_NR_MEMBLKS);
99925 --- linux-2.6.0-test6/include/linux/moduleparam.h       2003-06-16 22:32:21.000000000 -0700
99926 +++ 25/include/linux/moduleparam.h      2003-10-05 00:33:24.000000000 -0700
99927 @@ -3,6 +3,7 @@
99928  /* (C) Copyright 2001, 2002 Rusty Russell IBM Corporation */
99929  #include <linux/init.h>
99930  #include <linux/stringify.h>
99931 +#include <linux/kernel.h>
99932  
99933  /* You can override this manually, but generally this should match the
99934     module name. */
99935 @@ -33,6 +34,17 @@ struct kparam_string {
99936         char *string;
99937  };
99938  
99939 +/* Special one for arrays */
99940 +struct kparam_array
99941 +{
99942 +       unsigned int max;
99943 +       unsigned int *num;
99944 +       param_set_fn set;
99945 +       param_get_fn get;
99946 +       unsigned int elemsize;
99947 +       void *elem;
99948 +};
99949 +
99950  /* This is the fundamental function for registering boot/module
99951     parameters.  perm sets the visibility in driverfs: 000 means it's
99952     not there, read bits mean it's readable, write bits mean it's
99953 @@ -112,10 +124,16 @@ extern int param_set_invbool(const char 
99954  extern int param_get_invbool(char *buffer, struct kernel_param *kp);
99955  #define param_check_invbool(name, p) __param_check(name, p, int)
99956  
99957 -/* First two elements are the max and min array length (which don't change) */
99958 -extern int param_set_intarray(const char *val, struct kernel_param *kp);
99959 -extern int param_get_intarray(char *buffer, struct kernel_param *kp);
99960 -#define param_check_intarray(name, p) __param_check(name, p, int *)
99961 +/* Comma-separated array: num is set to number they actually specified. */
99962 +#define module_param_array(name, type, num, perm)                      \
99963 +       static struct kparam_array __param_arr_##name                   \
99964 +       = { ARRAY_SIZE(name), &num, param_set_##type, param_get_##type, \
99965 +           sizeof(name[0]), name };                                    \
99966 +       module_param_call(name, param_array_set, param_array_get,       \
99967 +                         &__param_arr_##name, perm)
99968 +
99969 +extern int param_array_set(const char *val, struct kernel_param *kp);
99970 +extern int param_array_get(char *buffer, struct kernel_param *kp);
99971  
99972  extern int param_set_copystring(const char *val, struct kernel_param *kp);
99973  
99974 @@ -123,5 +141,6 @@ int param_array(const char *name,
99975                 const char *val,
99976                 unsigned int min, unsigned int max,
99977                 void *elem, int elemsize,
99978 -               int (*set)(const char *, struct kernel_param *kp));
99979 +               int (*set)(const char *, struct kernel_param *kp),
99980 +               int *num);
99981  #endif /* _LINUX_MODULE_PARAM_TYPES_H */
99982 --- linux-2.6.0-test6/include/linux/netdevice.h 2003-09-27 18:57:47.000000000 -0700
99983 +++ 25/include/linux/netdevice.h        2003-10-05 00:33:46.000000000 -0700
99984 @@ -456,6 +456,13 @@ struct net_device
99985         /* bridge stuff */
99986         struct net_bridge_port  *br_port;
99987  
99988 +#ifdef CONFIG_KGDB
99989 +       int                     kgdb_is_trapped;
99990 +#endif
99991 +#ifdef CONFIG_NET_POLL_CONTROLLER
99992 +       void                    (*poll_controller)(struct net_device *);
99993 +#endif
99994 +
99995  #ifdef CONFIG_NET_FASTROUTE
99996  #define NETDEV_FASTROUTE_HMASK 0xF
99997         /* Semi-private data. Keep it at the end of device struct. */
99998 @@ -530,6 +537,11 @@ extern int         dev_new_index(void);
99999  extern struct net_device       *dev_get_by_index(int ifindex);
100000  extern struct net_device       *__dev_get_by_index(int ifindex);
100001  extern int             dev_restart(struct net_device *dev);
100002 +#ifdef CONFIG_KGDB
100003 +extern int             kgdb_eth_is_trapped(void);
100004 +extern int             kgdb_net_interrupt(struct sk_buff *skb);
100005 +extern void            kgdb_send_arp_request(void);
100006 +#endif
100007  
100008  typedef int gifconf_func_t(struct net_device * dev, char * bufptr, int len);
100009  extern int             register_gifconf(unsigned int family, gifconf_func_t * gifconf);
100010 @@ -588,12 +600,22 @@ static inline void netif_start_queue(str
100011  
100012  static inline void netif_wake_queue(struct net_device *dev)
100013  {
100014 +#ifdef CONFIG_KGDB
100015 +       if (kgdb_eth_is_trapped()) {
100016 +               return;
100017 +       }
100018 +#endif
100019         if (test_and_clear_bit(__LINK_STATE_XOFF, &dev->state))
100020                 __netif_schedule(dev);
100021  }
100022  
100023  static inline void netif_stop_queue(struct net_device *dev)
100024  {
100025 +#ifdef CONFIG_KGDB
100026 +       if (kgdb_eth_is_trapped()) {
100027 +               return;
100028 +       }
100029 +#endif
100030         set_bit(__LINK_STATE_XOFF, &dev->state);
100031  }
100032  
100033 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
100034 +++ 25/include/linux/netfilter_bridge/ebt_limit.h       2003-10-05 00:33:24.000000000 -0700
100035 @@ -0,0 +1,23 @@
100036 +#ifndef __LINUX_BRIDGE_EBT_LIMIT_H
100037 +#define __LINUX_BRIDGE_EBT_LIMIT_H
100038 +
100039 +#define EBT_LIMIT_MATCH "limit"
100040 +
100041 +/* timings are in milliseconds. */
100042 +#define EBT_LIMIT_SCALE 10000
100043 +
100044 +/* 1/10,000 sec period => max of 10,000/sec.  Min rate is then 429490
100045 +   seconds, or one every 59 hours. */
100046 +
100047 +struct ebt_limit_info
100048 +{
100049 +       u_int32_t avg;    /* Average secs between packets * scale */
100050 +       u_int32_t burst;  /* Period multiplier for upper limit. */
100051 +
100052 +       /* Used internally by the kernel */
100053 +       unsigned long prev;
100054 +       u_int32_t credit;
100055 +       u_int32_t credit_cap, cost;
100056 +};
100057 +
100058 +#endif
100059 --- linux-2.6.0-test6/include/linux/netfilter_ipv4/ip_conntrack_tuple.h 2003-06-14 12:18:29.000000000 -0700
100060 +++ 25/include/linux/netfilter_ipv4/ip_conntrack_tuple.h        2003-10-05 00:33:24.000000000 -0700
100061 @@ -62,6 +62,14 @@ struct ip_conntrack_tuple
100062         } dst;
100063  };
100064  
100065 +/* This is optimized opposed to a memset of the whole structure.  Everything we
100066 + * really care about is the  source/destination unions */
100067 +#define IP_CT_TUPLE_U_BLANK(tuple)                             \
100068 +       do {                                                    \
100069 +               (tuple)->src.u.all = 0;                         \
100070 +               (tuple)->dst.u.all = 0;                         \
100071 +       } while (0)
100072 +
100073  enum ip_conntrack_dir
100074  {
100075         IP_CT_DIR_ORIGINAL,
100076 --- linux-2.6.0-test6/include/linux/netfilter_ipv4/ip_nat_rule.h        2003-06-14 12:18:33.000000000 -0700
100077 +++ 25/include/linux/netfilter_ipv4/ip_nat_rule.h       2003-10-05 00:33:24.000000000 -0700
100078 @@ -14,5 +14,10 @@ extern int ip_nat_rule_find(struct sk_bu
100079                             const struct net_device *out,
100080                             struct ip_conntrack *ct,
100081                             struct ip_nat_info *info);
100082 +
100083 +extern unsigned int
100084 +alloc_null_binding(struct ip_conntrack *conntrack,
100085 +                  struct ip_nat_info *info,
100086 +                  unsigned int hooknum);
100087  #endif
100088  #endif /* _IP_NAT_RULE_H */
100089 --- linux-2.6.0-test6/include/linux/nfs_fs.h    2003-07-27 12:14:40.000000000 -0700
100090 +++ 25/include/linux/nfs_fs.h   2003-10-05 00:36:42.000000000 -0700
100091 @@ -271,7 +271,7 @@ nfs_file_cred(struct file *file)
100092  /*
100093   * linux/fs/nfs/direct.c
100094   */
100095 -extern int nfs_direct_IO(int, struct file *, const struct iovec *, loff_t,
100096 +extern int nfs_direct_IO(int, struct kiocb *, const struct iovec *, loff_t,
100097                         unsigned long);
100098  
100099  /*
100100 --- linux-2.6.0-test6/include/linux/nfs_page.h  2003-06-26 22:07:26.000000000 -0700
100101 +++ 25/include/linux/nfs_page.h 2003-10-05 00:36:43.000000000 -0700
100102 @@ -46,7 +46,6 @@ extern        struct nfs_page *nfs_create_reque
100103                                             unsigned int, unsigned int);
100104  extern void nfs_clear_request(struct nfs_page *req);
100105  extern void nfs_release_request(struct nfs_page *req);
100106 -extern void nfs_release_list(struct list_head *list);
100107  
100108  
100109  extern void nfs_list_add_request(struct nfs_page *, struct list_head *);
100110 @@ -56,7 +55,6 @@ extern        int nfs_scan_list(struct list_hea
100111  extern int nfs_coalesce_requests(struct list_head *, struct list_head *,
100112                                   unsigned int);
100113  extern  int nfs_wait_on_request(struct nfs_page *);
100114 -extern int nfs_wait_for_reads(struct list_head *);
100115  
100116  extern spinlock_t nfs_wreq_lock;
100117  
100118 --- linux-2.6.0-test6/include/linux/nfs_xdr.h   2003-09-08 13:58:59.000000000 -0700
100119 +++ 25/include/linux/nfs_xdr.h  2003-10-05 00:36:45.000000000 -0700
100120 @@ -591,6 +591,7 @@ struct nfs4_compound {
100121  #endif /* CONFIG_NFS_V4 */
100122  
100123  struct nfs_read_data {
100124 +       int                     flags;
100125         struct rpc_task         task;
100126         struct inode            *inode;
100127         struct rpc_cred         *cred;
100128 @@ -605,6 +606,7 @@ struct nfs_read_data {
100129  };
100130  
100131  struct nfs_write_data {
100132 +       int                     flags;
100133         struct rpc_task         task;
100134         struct inode            *inode;
100135         struct rpc_cred         *cred;
100136 @@ -634,16 +636,9 @@ struct nfs_rpc_ops {
100137                             struct nfs_fh *, struct nfs_fattr *);
100138         int     (*access)  (struct inode *, struct rpc_cred *, int);
100139         int     (*readlink)(struct inode *, struct page *);
100140 -       int     (*read)    (struct inode *, struct rpc_cred *,
100141 -                           struct nfs_fattr *,
100142 -                           int, unsigned int, unsigned int,
100143 -                           struct page *, int *eofp);
100144 -       int     (*write)   (struct inode *, struct rpc_cred *,
100145 -                           struct nfs_fattr *,
100146 -                           int, unsigned int, unsigned int,
100147 -                           struct page *, struct nfs_writeverf *verfp);
100148 -       int     (*commit)  (struct inode *, struct nfs_fattr *,
100149 -                           unsigned long, unsigned int);
100150 +       int     (*read)    (struct nfs_read_data *);
100151 +       int     (*write)   (struct nfs_write_data *);
100152 +       int     (*commit)  (struct nfs_write_data *);
100153         int     (*create)  (struct inode *, struct qstr *, struct iattr *,
100154                             int, struct nfs_fh *, struct nfs_fattr *);
100155         int     (*remove)  (struct inode *, struct qstr *);
100156 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
100157 +++ 25/include/linux/numa.h     2003-10-05 00:34:41.000000000 -0700
100158 @@ -0,0 +1,16 @@
100159 +#ifndef _LINUX_NUMA_H
100160 +#define _LINUX_NUMA_H
100161 +
100162 +#include <linux/config.h>
100163 +
100164 +#ifdef CONFIG_DISCONTIGMEM
100165 +#include <asm/numnodes.h>
100166 +#endif
100167 +
100168 +#ifndef NODES_SHIFT
100169 +#define NODES_SHIFT     0
100170 +#endif
100171 +
100172 +#define MAX_NUMNODES    (1 << NODES_SHIFT)
100173 +
100174 +#endif /* _LINUX_NUMA_H */
100175 --- linux-2.6.0-test6/include/linux/pagemap.h   2003-08-22 19:23:42.000000000 -0700
100176 +++ 25/include/linux/pagemap.h  2003-10-05 00:37:03.000000000 -0700
100177 @@ -71,7 +71,7 @@ extern struct page * find_trylock_page(s
100178  extern struct page * find_or_create_page(struct address_space *mapping,
100179                                 unsigned long index, unsigned int gfp_mask);
100180  extern unsigned int find_get_pages(struct address_space *mapping,
100181 -                               pgoff_t start, unsigned int nr_pages,
100182 +                               pgoff_t *next, unsigned int nr_pages,
100183                                 struct page **pages);
100184  
100185  /*
100186 @@ -153,17 +153,27 @@ static inline void ___add_to_page_cache(
100187  extern void FASTCALL(__lock_page(struct page *page));
100188  extern void FASTCALL(unlock_page(struct page *page));
100189  
100190 -static inline void lock_page(struct page *page)
100191 +
100192 +extern int FASTCALL(__lock_page_wq(struct page *page, wait_queue_t *wait));
100193 +static inline int lock_page_wq(struct page *page, wait_queue_t *wait)
100194  {
100195         if (TestSetPageLocked(page))
100196 -               __lock_page(page);
100197 +               return __lock_page_wq(page, wait);
100198 +       else
100199 +               return 0;
100200 +}
100201 +
100202 +static inline void lock_page(struct page *page)
100203 +{
100204 +       lock_page_wq(page, NULL);
100205  }
100206         
100207  /*
100208   * This is exported only for wait_on_page_locked/wait_on_page_writeback.
100209   * Never use this directly!
100210   */
100211 -extern void FASTCALL(wait_on_page_bit(struct page *page, int bit_nr));
100212 +extern int FASTCALL(wait_on_page_bit_wq(struct page *page, int bit_nr,
100213 +       wait_queue_t *wait));
100214  
100215  /* 
100216   * Wait for a page to be unlocked.
100217 @@ -172,19 +182,33 @@ extern void FASTCALL(wait_on_page_bit(st
100218   * ie with increased "page->count" so that the page won't
100219   * go away during the wait..
100220   */
100221 -static inline void wait_on_page_locked(struct page *page)
100222 +static inline int wait_on_page_locked_wq(struct page *page, wait_queue_t *wait)
100223  {
100224         if (PageLocked(page))
100225 -               wait_on_page_bit(page, PG_locked);
100226 +               return wait_on_page_bit_wq(page, PG_locked, wait);
100227 +       return 0;
100228 +}
100229 +
100230 +static inline int wait_on_page_writeback_wq(struct page *page,
100231 +                                               wait_queue_t *wait)
100232 +{
100233 +       if (PageWriteback(page))
100234 +               return wait_on_page_bit_wq(page, PG_writeback, wait);
100235 +       return 0;
100236 +}
100237 +
100238 +static inline void wait_on_page_locked(struct page *page)
100239 +{
100240 +       wait_on_page_locked_wq(page, NULL);
100241  }
100242  
100243  /* 
100244   * Wait for a page to complete writeback
100245   */
100246 +
100247  static inline void wait_on_page_writeback(struct page *page)
100248  {
100249 -       if (PageWriteback(page))
100250 -               wait_on_page_bit(page, PG_writeback);
100251 +       wait_on_page_writeback_wq(page, NULL);
100252  }
100253  
100254  extern void end_page_writeback(struct page *page);
100255 --- linux-2.6.0-test6/include/linux/pagevec.h   2003-06-14 12:18:51.000000000 -0700
100256 +++ 25/include/linux/pagevec.h  2003-10-05 00:37:03.000000000 -0700
100257 @@ -23,7 +23,7 @@ void __pagevec_lru_add(struct pagevec *p
100258  void __pagevec_lru_add_active(struct pagevec *pvec);
100259  void pagevec_strip(struct pagevec *pvec);
100260  unsigned int pagevec_lookup(struct pagevec *pvec, struct address_space *mapping,
100261 -               pgoff_t start, unsigned int nr_pages);
100262 +               pgoff_t *next, unsigned int nr_pages);
100263  
100264  static inline void pagevec_init(struct pagevec *pvec, int cold)
100265  {
100266 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
100267 +++ 25/include/linux/parser.h   2003-10-05 00:33:24.000000000 -0700
100268 @@ -0,0 +1,21 @@
100269 +struct match_token {
100270 +       int token;
100271 +       char *pattern;
100272 +};
100273 +
100274 +typedef struct match_token match_table_t[];
100275 +
100276 +enum {MAX_OPT_ARGS = 3};
100277 +
100278 +typedef struct {
100279 +       char *from;
100280 +       char *to;
100281 +} substring_t;
100282 +
100283 +int match_token(char *s, match_table_t table, substring_t args[]);
100284 +
100285 +int match_int(substring_t *, int *result);
100286 +int match_octal(substring_t *, int *result);
100287 +int match_hex(substring_t *, int *result);
100288 +void match_strcpy(char *, substring_t *);
100289 +char *match_strdup(substring_t *);
100290 --- linux-2.6.0-test6/include/linux/pci.h       2003-08-22 19:23:42.000000000 -0700
100291 +++ 25/include/linux/pci.h      2003-10-05 00:36:20.000000000 -0700
100292 @@ -36,6 +36,7 @@
100293  #define  PCI_COMMAND_WAIT      0x80    /* Enable address/data stepping */
100294  #define  PCI_COMMAND_SERR      0x100   /* Enable SERR */
100295  #define  PCI_COMMAND_FAST_BACK 0x200   /* Enable back-to-back writes */
100296 +#define  PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */
100297  
100298  #define PCI_STATUS             0x06    /* 16 bits */
100299  #define  PCI_STATUS_CAP_LIST   0x10    /* Support Capability List */
100300 @@ -198,6 +199,8 @@
100301  #define  PCI_CAP_ID_MSI                0x05    /* Message Signalled Interrupts */
100302  #define  PCI_CAP_ID_CHSWP      0x06    /* CompactPCI HotSwap */
100303  #define  PCI_CAP_ID_PCIX       0x07    /* PCI-X */
100304 +#define  PCI_CAP_ID_EXP        0x10    /* PCI Express */
100305 +#define  PCI_CAP_ID_MSIX       0x11    /* MSI-X */
100306  #define PCI_CAP_LIST_NEXT      1       /* Next capability in the list */
100307  #define PCI_CAP_FLAGS          2       /* Capability defined flags (16 bits) */
100308  #define PCI_CAP_SIZEOF         4
100309 @@ -275,11 +278,13 @@
100310  #define  PCI_MSI_FLAGS_QSIZE   0x70    /* Message queue size configured */
100311  #define  PCI_MSI_FLAGS_QMASK   0x0e    /* Maximum queue size available */
100312  #define  PCI_MSI_FLAGS_ENABLE  0x01    /* MSI feature enabled */
100313 +#define  PCI_MSI_FLAGS_MASKBIT 0x100   /* 64-bit mask bits allowed */
100314  #define PCI_MSI_RFU            3       /* Rest of capability flags */
100315  #define PCI_MSI_ADDRESS_LO     4       /* Lower 32 bits */
100316  #define PCI_MSI_ADDRESS_HI     8       /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */
100317  #define PCI_MSI_DATA_32                8       /* 16 bits of data for 32-bit devices */
100318  #define PCI_MSI_DATA_64                12      /* 16 bits of data for 64-bit devices */
100319 +#define PCI_MSI_MASK_BIT       16      /* Mask bits register */
100320  
100321  /* CompactPCI Hotswap Register */
100322  
100323 @@ -515,7 +520,6 @@ struct pci_driver {
100324         const struct pci_device_id *id_table;   /* must be non-NULL for probe to be called */
100325         int  (*probe)  (struct pci_dev *dev, const struct pci_device_id *id);   /* New device inserted */
100326         void (*remove) (struct pci_dev *dev);   /* Device removed (NULL if not a hot-plug capable driver) */
100327 -       int  (*save_state) (struct pci_dev *dev, u32 state);    /* Save Device Context */
100328         int  (*suspend) (struct pci_dev *dev, u32 state);       /* Device suspended */
100329         int  (*resume) (struct pci_dev *dev);                   /* Device woken up */
100330         int  (*enable_wake) (struct pci_dev *dev, u32 state, int enable);   /* Enable wake event */
100331 @@ -696,6 +700,18 @@ void pci_pool_free (struct pci_pool *poo
100332  extern struct pci_dev *isa_bridge;
100333  #endif
100334  
100335 +#ifndef CONFIG_PCI_USE_VECTOR
100336 +static inline void pci_scan_msi_device(struct pci_dev *dev) {}
100337 +static inline int pci_enable_msi(struct pci_dev *dev) {return -1;}
100338 +static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev) {}
100339 +#else
100340 +extern void pci_scan_msi_device(struct pci_dev *dev);
100341 +extern int pci_enable_msi(struct pci_dev *dev);
100342 +extern void msi_remove_pci_irq_vectors(struct pci_dev *dev);
100343 +extern int msi_alloc_vectors(struct pci_dev* dev, int *vector, int nvec);
100344 +extern int msi_free_vectors(struct pci_dev* dev, int *vector, int nvec);
100345 +#endif
100346 +
100347  #endif /* CONFIG_PCI */
100348  
100349  /* Include architecture-dependent settings and functions */
100350 --- linux-2.6.0-test6/include/linux/pci_ids.h   2003-09-08 13:58:59.000000000 -0700
100351 +++ 25/include/linux/pci_ids.h  2003-10-05 00:36:28.000000000 -0700
100352 @@ -519,6 +519,7 @@
100353  #define PCI_DEVICE_ID_CT_65550         0x00e0
100354  #define PCI_DEVICE_ID_CT_65554         0x00e4
100355  #define PCI_DEVICE_ID_CT_65555         0x00e5
100356 +#define PCI_DEVICE_ID_CT_69000         0x00c0
100357  
100358  #define PCI_VENDOR_ID_MIRO             0x1031
100359  #define PCI_DEVICE_ID_MIRO_36050       0x5601
100360 @@ -896,6 +897,7 @@
100361  
100362  #define PCI_VENDOR_ID_SGI              0x10a9
100363  #define PCI_DEVICE_ID_SGI_IOC3         0x0003
100364 +#define PCI_DEVICE_ID_SGI_IOC4         0x100a
100365  #define PCI_VENDOR_ID_SGI_LITHIUM      0x1002
100366  
100367  #define PCI_VENDOR_ID_ACC              0x10aa
100368 @@ -1060,6 +1062,16 @@
100369  #define PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL    0x0258
100370  #define PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL    0x0259
100371  #define PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL    0x025B
100372 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800  0x0280
100373 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4280  0x0281
100374 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800_SE 0x0282
100375 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_4200_GO  0x0286
100376 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800_U 0x0301
100377 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5800   0x0302
100378 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600_U 0x0311
100379 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5600   0x0312
100380 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200_U 0x0321
100381 +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_FX_5200   0x0322
100382  
100383  #define PCI_VENDOR_ID_IMS              0x10e0
100384  #define PCI_DEVICE_ID_IMS_8849         0x8849
100385 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
100386 +++ 25/include/linux/pci_msi.h  2003-10-05 00:36:20.000000000 -0700
100387 @@ -0,0 +1,193 @@
100388 +/*
100389 + *     ../include/linux/pci_msi.h
100390 + *
100391 + */
100392 +
100393 +#ifndef _ASM_PCI_MSI_H
100394 +#define _ASM_PCI_MSI_H
100395 +
100396 +#include <linux/pci.h>
100397 +
100398 +#define MSI_AUTO -1
100399 +#define NR_REPEATS     23
100400 +#define NR_RESERVED_VECTORS 3 /*FIRST_DEVICE_VECTOR,FIRST_SYSTEM_VECTOR,0x80 */
100401 +
100402 +/*
100403 + * Assume the maximum number of hot plug slots supported by the system is about
100404 + * ten. The worstcase is that each of these slots is hot-added with a device,
100405 + * which has two MSI/MSI-X capable functions. To avoid any MSI-X driver, which
100406 + * attempts to request all available vectors, NR_HP_RESERVED_VECTORS is defined
100407 + * as below to ensure at least one message is assigned to each detected MSI/
100408 + * MSI-X device function.
100409 + */
100410 +#define NR_HP_RESERVED_VECTORS         20
100411 +
100412 +extern int vector_irq[NR_IRQS];
100413 +extern cpumask_t pending_irq_balance_cpumask[NR_IRQS];
100414 +extern void (*interrupt[NR_IRQS])(void);
100415 +
100416 +#ifdef CONFIG_SMP
100417 +#define set_msi_irq_affinity   set_msi_affinity
100418 +#else
100419 +#define set_msi_irq_affinity   NULL
100420 +static inline void move_msi(int vector) {}
100421 +#endif
100422 +
100423 +#ifndef CONFIG_X86_IO_APIC
100424 +static inline int get_ioapic_vector(struct pci_dev *dev) { return -1;}
100425 +static inline void restore_ioapic_irq_handler(int irq) {}
100426 +#else
100427 +extern void restore_ioapic_irq_handler(int irq);
100428 +#endif
100429 +
100430 +/*
100431 + * MSI-X Address Register
100432 + */
100433 +#define PCI_MSIX_FLAGS_QSIZE           0x7FF
100434 +#define PCI_MSIX_FLAGS_ENABLE          (1 << 15)
100435 +#define PCI_MSIX_FLAGS_BIRMASK         (7 << 0)
100436 +#define PCI_MSIX_FLAGS_BITMASK         (1 << 0)
100437 +
100438 +#define PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET       0
100439 +#define PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET       4
100440 +#define PCI_MSIX_ENTRY_DATA_OFFSET             8
100441 +#define PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET      12
100442 +#define PCI_MSIX_ENTRY_SIZE                    16
100443 +
100444 +#define msi_control_reg(base)          (base + PCI_MSI_FLAGS)
100445 +#define msi_lower_address_reg(base)    (base + PCI_MSI_ADDRESS_LO)
100446 +#define msi_upper_address_reg(base)    (base + PCI_MSI_ADDRESS_HI)
100447 +#define msi_data_reg(base, is64bit)    \
100448 +       ( (is64bit == 1) ? base+PCI_MSI_DATA_64 : base+PCI_MSI_DATA_32 )
100449 +#define msi_mask_bits_reg(base, is64bit) \
100450 +       ( (is64bit == 1) ? base+PCI_MSI_MASK_BIT : base+PCI_MSI_MASK_BIT-4)
100451 +#define msi_disable(control)           control &= ~PCI_MSI_FLAGS_ENABLE
100452 +#define multi_msi_capable(control) \
100453 +       (1 << ((control & PCI_MSI_FLAGS_QMASK) >> 1))
100454 +#define multi_msi_enable(control, num) \
100455 +       control |= (((num >> 1) << 4) & PCI_MSI_FLAGS_QSIZE);
100456 +#define is_64bit_address(control)      (control & PCI_MSI_FLAGS_64BIT)
100457 +#define is_mask_bit_support(control)   (control & PCI_MSI_FLAGS_MASKBIT)
100458 +#define msi_enable(control, num) multi_msi_enable(control, num); \
100459 +       control |= PCI_MSI_FLAGS_ENABLE
100460 +
100461 +#define msix_control_reg               msi_control_reg
100462 +#define msix_table_offset_reg(base)    (base + 0x04)
100463 +#define msix_pba_offset_reg(base)      (base + 0x08)
100464 +#define msix_enable(control)           control |= PCI_MSIX_FLAGS_ENABLE
100465 +#define msix_disable(control)          control &= ~PCI_MSIX_FLAGS_ENABLE
100466 +#define msix_table_size(control)       ((control & PCI_MSIX_FLAGS_QSIZE)+1)
100467 +#define multi_msix_capable             msix_table_size
100468 +#define msix_unmask(address)           (address & ~PCI_MSIX_FLAGS_BITMASK)
100469 +#define msix_mask(address)             (address | PCI_MSIX_FLAGS_BITMASK)
100470 +#define msix_is_pending(address)       (address & PCI_MSIX_FLAGS_PENDMASK)
100471 +
100472 +extern char __dbg_str_buf[256];
100473 +#define _DEFINE_DBG_BUFFER     char __dbg_str_buf[256];
100474 +#define _DBG_K_TRACE_ENTRY     ((unsigned int)0x00000001)
100475 +#define _DBG_K_TRACE_EXIT      ((unsigned int)0x00000002)
100476 +#define _DBG_K_INFO            ((unsigned int)0x00000004)
100477 +#define _DBG_K_ERROR           ((unsigned int)0x00000008)
100478 +#define _DBG_K_TRACE   (_DBG_K_TRACE_ENTRY | _DBG_K_TRACE_EXIT)
100479 +
100480 +#define _DEBUG_LEVEL   (_DBG_K_INFO | _DBG_K_ERROR | _DBG_K_TRACE)
100481 +#define _DBG_PRINT( dbg_flags, args... )               \
100482 +if ( _DEBUG_LEVEL & (dbg_flags) )                      \
100483 +{                                                      \
100484 +       int len;                                        \
100485 +       len = sprintf(__dbg_str_buf, "%s:%d: %s ",      \
100486 +               __FILE__, __LINE__, __FUNCTION__ );     \
100487 +       sprintf(__dbg_str_buf + len, args);             \
100488 +       printk(KERN_INFO "%s\n", __dbg_str_buf);        \
100489 +}
100490 +
100491 +#define MSI_FUNCTION_TRACE_ENTER       \
100492 +       _DBG_PRINT (_DBG_K_TRACE_ENTRY, "%s", "[Entry]");
100493 +#define MSI_FUNCTION_TRACE_EXIT                \
100494 +       _DBG_PRINT (_DBG_K_TRACE_EXIT, "%s", "[Entry]");
100495 +
100496 +/*
100497 + * MSI Defined Data Structures
100498 + */
100499 +#define MSI_ADDRESS_HEADER             0xfee
100500 +#define MSI_ADDRESS_HEADER_SHIFT       12
100501 +#define MSI_ADDRESS_HEADER_MASK                0xfff000
100502 +#define MSI_TARGET_CPU_SHIFT           4
100503 +#define MSI_TARGET_CPU_MASK            0xff
100504 +#define MSI_DELIVERY_MODE              0
100505 +#define MSI_LEVEL_MODE                 1       /* Edge always assert */
100506 +#define MSI_TRIGGER_MODE               0       /* MSI is edge sensitive */
100507 +#define MSI_LOGICAL_MODE               1
100508 +#define MSI_REDIRECTION_HINT_MODE      0
100509 +#ifdef CONFIG_SMP
100510 +#define MSI_TARGET_CPU                 logical_smp_processor_id()
100511 +#else
100512 +#define MSI_TARGET_CPU                 TARGET_CPUS
100513 +#endif
100514 +
100515 +struct msg_data {
100516 +#if defined(__LITTLE_ENDIAN_BITFIELD)
100517 +       __u32   vector          :  8;
100518 +       __u32   delivery_mode   :  3;   /* 000b: FIXED | 001b: lowest prior */
100519 +       __u32   reserved_1      :  3;
100520 +       __u32   level           :  1;   /* 0: deassert | 1: assert */
100521 +       __u32   trigger         :  1;   /* 0: edge | 1: level */
100522 +       __u32   reserved_2      : 16;
100523 +#elif defined(__BIG_ENDIAN_BITFIELD)
100524 +       __u32   reserved_2      : 16;
100525 +       __u32   trigger         :  1;   /* 0: edge | 1: level */
100526 +       __u32   level           :  1;   /* 0: deassert | 1: assert */
100527 +       __u32   reserved_1      :  3;
100528 +       __u32   delivery_mode   :  3;   /* 000b: FIXED | 001b: lowest prior */
100529 +       __u32   vector          :  8;
100530 +#else
100531 +#error "Bitfield endianness not defined! Check your byteorder.h"
100532 +#endif
100533 +} __attribute__ ((packed));
100534 +
100535 +struct msg_address {
100536 +       union {
100537 +               struct {
100538 +#if defined(__LITTLE_ENDIAN_BITFIELD)
100539 +                       __u32   reserved_1      :  2;
100540 +                       __u32   dest_mode       :  1;   /*0:physic | 1:logic */
100541 +                       __u32   redirection_hint:  1;   /*0: dedicated CPU
100542 +                                                         1: lowest priority */
100543 +                       __u32   reserved_2      :  4;
100544 +                       __u32   dest_id         : 24;   /* Destination ID */
100545 +#elif defined(__BIG_ENDIAN_BITFIELD)
100546 +                       __u32   dest_id         : 24;   /* Destination ID */
100547 +                       __u32   reserved_2      :  4;
100548 +                       __u32   redirection_hint:  1;   /*0: dedicated CPU
100549 +                                                         1: lowest priority */
100550 +                       __u32   dest_mode       :  1;   /*0:physic | 1:logic */
100551 +                       __u32   reserved_1      :  2;
100552 +#else
100553 +#error "Bitfield endianness not defined! Check your byteorder.h"
100554 +#endif
100555 +               }u;
100556 +                       __u32  value;
100557 +       }lo_address;
100558 +       __u32   hi_address;
100559 +} __attribute__ ((packed));
100560 +
100561 +struct msi_desc {
100562 +       struct {
100563 +               __u8    type    : 5;    /* {0: unused, 5h:MSI, 11h:MSI-X} */
100564 +               __u8    maskbit : 1;    /* mask-pending bit supported ?   */
100565 +               __u8    reserved: 2;    /* reserved                       */
100566 +               __u8    entry_nr;       /* specific enabled entry         */
100567 +               __u8    default_vector; /* default pre-assigned vector    */
100568 +               __u8    current_cpu;    /* current destination cpu        */
100569 +       }msi_attrib;
100570 +
100571 +       struct {
100572 +               __u16   head;
100573 +               __u16   tail;
100574 +       }link;
100575 +
100576 +       unsigned long mask_base;
100577 +       struct pci_dev *dev;
100578 +};
100579 +
100580 +#endif /* _ASM_PCI_MSI_H */
100581 --- linux-2.6.0-test6/include/linux/raw.h       2003-06-14 12:18:25.000000000 -0700
100582 +++ 25/include/linux/raw.h      2003-10-05 00:33:24.000000000 -0700
100583 @@ -13,4 +13,6 @@ struct raw_config_request 
100584         __u64   block_minor;
100585  };
100586  
100587 +#define MAX_RAW_MINORS CONFIG_MAX_RAW_DEVS
100588 +
100589  #endif /* __LINUX_RAW_H */
100590 --- linux-2.6.0-test6/include/linux/rcupdate.h  2003-08-22 19:23:42.000000000 -0700
100591 +++ 25/include/linux/rcupdate.h 2003-10-05 00:33:24.000000000 -0700
100592 @@ -15,7 +15,7 @@
100593   * along with this program; if not, write to the Free Software
100594   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
100595   *
100596 - * Copyright (c) IBM Corporation, 2001
100597 + * Copyright (C) IBM Corporation, 2001
100598   *
100599   * Author: Dipankar Sarma <dipankar@in.ibm.com>
100600   * 
100601 --- linux-2.6.0-test6/include/linux/sched.h     2003-09-27 18:57:47.000000000 -0700
100602 +++ 25/include/linux/sched.h    2003-10-05 00:36:54.000000000 -0700
100603 @@ -151,6 +151,7 @@ extern void init_idle(task_t *idle, int 
100604  
100605  extern void show_state(void);
100606  extern void show_regs(struct pt_regs *);
100607 +extern void show_trace_task(task_t *tsk);
100608  
100609  /*
100610   * TASK is a pointer to the task whose backtrace we want to see (or NULL for current
100611 @@ -207,6 +208,8 @@ struct mm_struct {
100612         cpumask_t cpu_vm_mask;
100613         unsigned long swap_address;
100614  
100615 +       unsigned long saved_auxv[40]; /* for /proc/PID/auxv */
100616 +
100617         unsigned dumpable:1;
100618  #ifdef CONFIG_HUGETLB_PAGE
100619         int used_hugetlb;
100620 @@ -262,6 +265,15 @@ struct signal_struct {
100621  
100622         /* thread group stop support, overloads group_exit_code too */
100623         int                     group_stop_count;
100624 +
100625 +       /* job control IDs */
100626 +       pid_t pgrp;
100627 +       pid_t tty_old_pgrp;
100628 +       pid_t session;
100629 +       /* boolean value for session group leader */
100630 +       int leader;
100631 +
100632 +       struct tty_struct *tty; /* NULL if no tty */
100633  };
100634  
100635  /*
100636 @@ -364,12 +376,7 @@ struct task_struct {
100637         unsigned long personality;
100638         int did_exec:1;
100639         pid_t pid;
100640 -       pid_t __pgrp;           /* Accessed via process_group() */
100641 -       pid_t tty_old_pgrp;
100642 -       pid_t session;
100643         pid_t tgid;
100644 -       /* boolean value for session group leader */
100645 -       int leader;
100646         /* 
100647          * pointers to (original) parent process, youngest child, younger sibling,
100648          * older sibling, respectively.  (p->father can be replaced with 
100649 @@ -413,7 +420,6 @@ struct task_struct {
100650         char comm[16];
100651  /* file system info */
100652         int link_count, total_link_count;
100653 -       struct tty_struct *tty; /* NULL if no tty */
100654         unsigned int locks; /* How many file locks are being held */
100655  /* ipc stuff */
100656         struct sysv_sem sysvsem;
100657 @@ -463,11 +469,33 @@ struct task_struct {
100658  
100659         unsigned long ptrace_message;
100660         siginfo_t *last_siginfo; /* For ptrace use.  */
100661 +/*
100662 + * current io wait handle: wait queue entry to use for io waits
100663 + * If this thread is processing aio, this points at the waitqueue
100664 + * inside the currently handled kiocb. It may be NULL (i.e. default
100665 + * to a stack based synchronous wait) if its doing sync IO.
100666 + */
100667 +       wait_queue_t *io_wait;
100668  };
100669  
100670  static inline pid_t process_group(struct task_struct *tsk)
100671  {
100672 -       return tsk->group_leader->__pgrp;
100673 +       return tsk->signal->pgrp;
100674 +}
100675 +
100676 +static inline pid_t process_session(struct task_struct *tsk)
100677 +{
100678 +       return tsk->signal->session;
100679 +}
100680 +
100681 +static inline int process_session_leader(struct task_struct *tsk)
100682 +{
100683 +       return tsk->signal->leader;
100684 +}
100685 +
100686 +static inline struct tty_struct *process_tty(struct task_struct *tsk)
100687 +{
100688 +       return tsk->signal->tty;
100689  }
100690  
100691  extern void __put_task_struct(struct task_struct *tsk);
100692 --- linux-2.6.0-test6/include/linux/sctp.h      2003-09-08 13:58:59.000000000 -0700
100693 +++ 25/include/linux/sctp.h     2003-10-05 00:33:24.000000000 -0700
100694 @@ -524,113 +524,4 @@ typedef struct sctp_addip_chunk {
100695         sctp_addiphdr_t addip_hdr;
100696  } sctp_addip_chunk_t __attribute__((packed));
100697  
100698 -/* FIXME:  Cleanup needs to continue below this line. */
100699 -
100700 -
100701 -/* ADDIP Section 3.1.1
100702 - *
100703 - * ASCONF-Request Correlation ID: 32 bits (unsigned integer)
100704 - *
100705 - * This is an opaque integer assigned by the sender to identify each
100706 - * request parameter. It is in host byte order and is only meaningful
100707 - * to the sender. The receiver of the ASCONF Chunk will copy this 32
100708 - * bit value into the ASCONF Correlation ID field of the
100709 - * ASCONF-ACK. The sender of the ASCONF can use this same value in the
100710 - * ASCONF-ACK to find which request the response is for.
100711 - *
100712 - * ASCONF Parameter: TLV format
100713 - *
100714 - * Each Address configuration change is represented by a TLV parameter
100715 - * as defined in Section 3.2. One or more requests may be present in
100716 - * an ASCONF Chunk.
100717 - */
100718 -typedef struct {
100719 -       __u32   correlation;
100720 -       sctp_paramhdr_t p;
100721 -       __u8            payload[0];
100722 -} sctpAsconfReq_t;
100723 -
100724 -/* ADDIP
100725 - * 3.1.1  Address/Stream Configuration Change Chunk (ASCONF)
100726 - *
100727 - * This chunk is used to communicate to the remote endpoint one of the
100728 - * configuration change requests that MUST be acknowledged.  The
100729 - * information carried in the ASCONF Chunk uses the form of a
100730 - * Tag-Length-Value (TLV), as described in "3.2.1
100731 - * Optional/Variable-length Parameter Format" in [RFC2960], for all
100732 - * variable parameters.
100733 - */
100734 -typedef struct {
100735 -       __u32   serial;
100736 -       __u8    reserved[3];
100737 -       __u8    addr_type;
100738 -       __u32   addr[4];
100739 -       sctpAsconfReq_t requests[0];
100740 -} sctpAsconf_t;
100741 -
100742 -/* ADDIP
100743 - * 3.1.2 Address/Stream Configuration Acknowledgment Chunk (ASCONF-ACK)
100744 - *
100745 - * ASCONF-Request Correlation ID: 32 bits (unsigned integer)
100746 - *
100747 - * This value is copied from the ASCONF Correlation ID received in the
100748 - * ASCONF Chunk. It is used by the receiver of the ASCONF-ACK to identify
100749 - * which ASCONF parameter this response is associated with.
100750 - *
100751 - * ASCONF Parameter Response : TLV format
100752 - *
100753 - * The ASCONF Parameter Response is used in the ASCONF-ACK to report
100754 - * status of ASCONF processing. By default, if a responding endpoint
100755 - * does not include any Error Cause, a success is indicated. Thus a
100756 - * sender of an ASCONF-ACK MAY indicate complete success of all TLVs in
100757 - * an ASCONF by returning only the Chunk Type, Chunk Flags, Chunk Length
100758 - * (set to 8) and the Serial Number.
100759 - */
100760 -typedef union {
100761 -       struct {
100762 -               __u32           correlation;
100763 -               sctp_paramhdr_t header; /* success report */
100764 -       } success;
100765 -       struct {
100766 -               __u32           correlation;
100767 -               sctp_paramhdr_t header; /* error cause indication */
100768 -               sctp_paramhdr_t errcause;
100769 -               uint8_t request[0];     /* original request from ASCONF */
100770 -       } error;
100771 -#define __correlation  success.correlation
100772 -#define __header       success.header
100773 -#define __cause                error.errcause
100774 -#define __request      error.request
100775 -}  sctpAsconfAckRsp_t;
100776 -
100777 -/* ADDIP
100778 - * 3.1.2 Address/Stream Configuration Acknowledgment Chunk (ASCONF-ACK)
100779 - *
100780 - * This chunk is used by the receiver of an ASCONF Chunk to
100781 - * acknowledge the reception. It carries zero or more results for any
100782 - * ASCONF Parameters that were processed by the receiver.
100783 - */
100784 -typedef struct {
100785 -       __u32   serial;
100786 -       sctpAsconfAckRsp_t responses[0];
100787 -} sctpAsconfAck_t;
100788 -
100789 -/*********************************************************************
100790 - * Internal structures
100791 - *
100792 - * These are data structures which never go out on the wire.
100793 - *********************************************************************/
100794 -
100795 -/* What is this data structure for?  The TLV isn't one--it is just a
100796 - * value.  Perhaps this data structure ought to have a type--otherwise
100797 - * it is not unambigiously parseable.  --piggy
100798 - */
100799 -typedef struct {
100800 -       struct list_head hook;
100801 -       int length;     /* length of the TLV */
100802 -
100803 -       /* the actually TLV to be copied into ASCONF_ACK */
100804 -       sctpAsconfAckRsp_t TLV;
100805 -} sctpAsconfAckRspNode_t;
100806 -
100807  #endif /* __LINUX_SCTP_H__ */
100808 --- linux-2.6.0-test6/include/linux/security.h  2003-07-10 18:50:32.000000000 -0700
100809 +++ 25/include/linux/security.h 2003-10-05 00:33:24.000000000 -0700
100810 @@ -334,6 +334,7 @@ struct swap_info_struct;
100811   *     called when the actual read/write operations are performed.
100812   *     @inode contains the inode structure to check.
100813   *     @mask contains the permission mask.
100814 + *     @nd contains the nameidata (may be NULL).
100815   *     Return 0 if permission is granted.
100816   * @inode_setattr:
100817   *     Check permission before setting file attributes.  Note that the kernel
100818 @@ -1055,7 +1056,7 @@ struct security_operations {
100819                                    struct dentry *new_dentry);
100820         int (*inode_readlink) (struct dentry *dentry);
100821         int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
100822 -       int (*inode_permission) (struct inode *inode, int mask);
100823 +       int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
100824         int (*inode_setattr)    (struct dentry *dentry, struct iattr *attr);
100825         int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
100826          void (*inode_delete) (struct inode *inode);
100827 @@ -1474,9 +1475,10 @@ static inline int security_inode_follow_
100828         return security_ops->inode_follow_link (dentry, nd);
100829  }
100830  
100831 -static inline int security_inode_permission (struct inode *inode, int mask)
100832 +static inline int security_inode_permission (struct inode *inode, int mask,
100833 +                                            struct nameidata *nd)
100834  {
100835 -       return security_ops->inode_permission (inode, mask);
100836 +       return security_ops->inode_permission (inode, mask, nd);
100837  }
100838  
100839  static inline int security_inode_setattr (struct dentry *dentry,
100840 @@ -2110,7 +2112,8 @@ static inline int security_inode_follow_
100841         return 0;
100842  }
100843  
100844 -static inline int security_inode_permission (struct inode *inode, int mask)
100845 +static inline int security_inode_permission (struct inode *inode, int mask,
100846 +                                            struct nameidata *nd)
100847  {
100848         return 0;
100849  }
100850 --- linux-2.6.0-test6/include/linux/serial_core.h       2003-09-27 18:57:47.000000000 -0700
100851 +++ 25/include/linux/serial_core.h      2003-10-05 00:33:38.000000000 -0700
100852 @@ -158,7 +158,9 @@ struct uart_port {
100853         unsigned char           x_char;                 /* xon/xoff char */
100854         unsigned char           regshift;               /* reg offset shift */
100855         unsigned char           iotype;                 /* io access style */
100856 -
100857 +#ifdef CONFIG_KGDB
100858 +       int                     kgdb;                   /* in use by kgdb */
100859 +#endif
100860  #define UPIO_PORT              (0)
100861  #define UPIO_HUB6              (1)
100862  #define UPIO_MEM               (2)
100863 --- linux-2.6.0-test6/include/linux/serialP.h   2003-06-14 12:17:57.000000000 -0700
100864 +++ 25/include/linux/serialP.h  2003-10-05 00:33:25.000000000 -0700
100865 @@ -19,6 +19,7 @@
100866   * For definitions of the flags field, see tty.h
100867   */
100868  
100869 +#include <linux/version.h>
100870  #include <linux/config.h>
100871  #include <linux/termios.h>
100872  #include <linux/workqueue.h>
100873 --- linux-2.6.0-test6/include/linux/serio.h     2003-09-27 18:57:47.000000000 -0700
100874 +++ 25/include/linux/serio.h    2003-10-05 00:34:15.000000000 -0700
100875 @@ -53,6 +53,7 @@ struct serio_dev {
100876         irqreturn_t (*interrupt)(struct serio *, unsigned char,
100877                         unsigned int, struct pt_regs *);
100878         void (*connect)(struct serio *, struct serio_dev *dev);
100879 +       int  (*reconnect)(struct serio *);
100880         void (*disconnect)(struct serio *);
100881         void (*cleanup)(struct serio *);
100882  
100883 @@ -62,12 +63,13 @@ struct serio_dev {
100884  int serio_open(struct serio *serio, struct serio_dev *dev);
100885  void serio_close(struct serio *serio);
100886  void serio_rescan(struct serio *serio);
100887 +void serio_reconnect(struct serio *serio);
100888  irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags, struct pt_regs *regs);
100889  
100890  void serio_register_port(struct serio *serio);
100891 -void serio_register_slave_port(struct serio *serio);
100892 +void __serio_register_port(struct serio *serio);
100893  void serio_unregister_port(struct serio *serio);
100894 -void serio_unregister_slave_port(struct serio *serio);
100895 +void __serio_unregister_port(struct serio *serio);
100896  void serio_register_device(struct serio_dev *dev);
100897  void serio_unregister_device(struct serio_dev *dev);
100898  
100899 --- linux-2.6.0-test6/include/linux/skbuff.h    2003-09-27 18:57:47.000000000 -0700
100900 +++ 25/include/linux/skbuff.h   2003-10-05 00:36:10.000000000 -0700
100901 @@ -152,6 +152,7 @@ struct skb_shared_info {
100902   *     @sk: Socket we are owned by
100903   *     @stamp: Time we arrived
100904   *     @dev: Device we arrived on/are leaving by
100905 + *      @real_dev: The real device we are using
100906   *     @h: Transport layer header
100907   *     @nh: Network layer header
100908   *     @mac: Link layer header
100909 @@ -179,6 +180,7 @@ struct skb_shared_info {
100910   *     @nfct: Associated connection, if any
100911   *     @nf_debug: Netfilter debugging
100912   *     @nf_bridge: Saved data about a bridged frame - see br_netfilter.c
100913 + *      @private: Data which is private to the HIPPI implementation
100914   *     @tc_index: Traffic control index
100915   */
100916  
100917 @@ -885,7 +887,7 @@ static inline char *__skb_pull(struct sk
100918   */
100919  static inline unsigned char *skb_pull(struct sk_buff *skb, unsigned int len)
100920  {
100921 -       return (len > skb->len) ? NULL : __skb_pull(skb, len);
100922 +       return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len);
100923  }
100924  
100925  extern unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta);
100926 @@ -901,7 +903,7 @@ static inline char *__pskb_pull(struct s
100927  
100928  static inline unsigned char *pskb_pull(struct sk_buff *skb, unsigned int len)
100929  {
100930 -       return (len > skb->len) ? NULL : __pskb_pull(skb, len);
100931 +       return unlikely(len > skb->len) ? NULL : __pskb_pull(skb, len);
100932  }
100933  
100934  static inline int pskb_may_pull(struct sk_buff *skb, unsigned int len)
100935 @@ -1052,7 +1054,7 @@ static inline struct sk_buff *__dev_allo
100936                                               int gfp_mask)
100937  {
100938         struct sk_buff *skb = alloc_skb(length + 16, gfp_mask);
100939 -       if (skb)
100940 +       if (likely(skb))
100941                 skb_reserve(skb, 16);
100942         return skb;
100943  }
100944 --- linux-2.6.0-test6/include/linux/spinlock.h  2003-07-02 14:53:18.000000000 -0700
100945 +++ 25/include/linux/spinlock.h 2003-10-05 00:36:40.000000000 -0700
100946 @@ -15,6 +15,12 @@
100947  
100948  #include <asm/processor.h>     /* for cpu relax */
100949  #include <asm/system.h>
100950 +#ifdef CONFIG_KGDB
100951 +#include <asm/current.h>
100952 +#define SET_WHO(x, him) (x)->who = him;
100953 +#else
100954 +#define SET_WHO(x, him)
100955 +#endif
100956  
100957  /*
100958   * Must define these before including other files, inline functions need them
100959 @@ -55,6 +61,9 @@ typedef struct {
100960         const char *module;
100961         char *owner;
100962         int oline;
100963 +#ifdef CONFIG_KGDB
100964 +       struct task_struct *who;
100965 +#endif
100966  } spinlock_t;
100967  #define SPIN_LOCK_UNLOCKED (spinlock_t) { SPINLOCK_MAGIC, 0, 10, __FILE__ , NULL, 0}
100968  
100969 @@ -66,6 +75,7 @@ typedef struct {
100970                 (x)->module = __FILE__; \
100971                 (x)->owner = NULL; \
100972                 (x)->oline = 0; \
100973 +                SET_WHO(x, NULL) \
100974         } while (0)
100975  
100976  #define CHECK_LOCK(x) \
100977 @@ -88,6 +98,7 @@ typedef struct {
100978                 (x)->lock = 1; \
100979                 (x)->owner = __FILE__; \
100980                 (x)->oline = __LINE__; \
100981 +                SET_WHO(x, current)       \
100982         } while (0)
100983  
100984  /* without debugging, spin_is_locked on UP always says
100985 @@ -118,6 +129,7 @@ typedef struct {
100986                 (x)->lock = 1; \
100987                 (x)->owner = __FILE__; \
100988                 (x)->oline = __LINE__; \
100989 +                SET_WHO(x, current)       \
100990                 1; \
100991         })
100992  
100993 @@ -184,6 +196,17 @@ typedef struct {
100994  
100995  #endif /* !SMP */
100996  
100997 +#ifdef CONFIG_LOCKMETER
100998 +extern void _metered_spin_lock   (spinlock_t *lock);
100999 +extern void _metered_spin_unlock (spinlock_t *lock);
101000 +extern int  _metered_spin_trylock(spinlock_t *lock);
101001 +extern void _metered_read_lock    (rwlock_t *lock);
101002 +extern void _metered_read_unlock  (rwlock_t *lock);
101003 +extern void _metered_write_lock   (rwlock_t *lock);
101004 +extern void _metered_write_unlock (rwlock_t *lock);
101005 +extern int  _metered_write_trylock(rwlock_t *lock);
101006 +#endif
101007 +
101008  /*
101009   * Define the various spin_lock and rw_lock methods.  Note we define these
101010   * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The various
101011 @@ -389,6 +412,141 @@ do { \
101012                                 _raw_spin_trylock(lock) ? 1 : \
101013                                 ({preempt_enable(); local_bh_enable(); 0;});})
101014  
101015 +#ifdef CONFIG_LOCKMETER
101016 +#undef spin_lock
101017 +#undef spin_trylock
101018 +#undef spin_unlock
101019 +#undef spin_lock_irqsave
101020 +#undef spin_lock_irq
101021 +#undef spin_lock_bh
101022 +#undef read_lock
101023 +#undef read_unlock
101024 +#undef write_lock
101025 +#undef write_unlock
101026 +#undef write_trylock
101027 +#undef spin_unlock_bh
101028 +#undef read_lock_irqsave
101029 +#undef read_lock_irq
101030 +#undef read_lock_bh
101031 +#undef read_unlock_bh
101032 +#undef write_lock_irqsave
101033 +#undef write_lock_irq
101034 +#undef write_lock_bh
101035 +#undef write_unlock_bh
101036 +
101037 +#define spin_lock(lock) \
101038 +do { \
101039 +       preempt_disable(); \
101040 +       _metered_spin_lock(lock); \
101041 +} while(0)
101042 +
101043 +#define spin_trylock(lock)     ({preempt_disable(); _metered_spin_trylock(lock) ? \
101044 +                               1 : ({preempt_enable(); 0;});})
101045 +#define spin_unlock(lock) \
101046 +do { \
101047 +       _metered_spin_unlock(lock); \
101048 +       preempt_enable(); \
101049 +} while (0)
101050 +
101051 +#define spin_lock_irqsave(lock, flags) \
101052 +do { \
101053 +       local_irq_save(flags); \
101054 +       preempt_disable(); \
101055 +       _metered_spin_lock(lock); \
101056 +} while (0)
101057 +
101058 +#define spin_lock_irq(lock) \
101059 +do { \
101060 +       local_irq_disable(); \
101061 +       preempt_disable(); \
101062 +       _metered_spin_lock(lock); \
101063 +} while (0)
101064 +
101065 +#define spin_lock_bh(lock) \
101066 +do { \
101067 +       local_bh_disable(); \
101068 +       preempt_disable(); \
101069 +       _metered_spin_lock(lock); \
101070 +} while (0)
101071 +
101072 +#define spin_unlock_bh(lock) \
101073 +do { \
101074 +       _metered_spin_unlock(lock); \
101075 +       preempt_enable(); \
101076 +       local_bh_enable(); \
101077 +} while (0)
101078 +
101079 +
101080 +#define read_lock(lock)                ({preempt_disable(); _metered_read_lock(lock);})
101081 +#define read_unlock(lock)      ({_metered_read_unlock(lock); preempt_enable();})
101082 +#define write_lock(lock)       ({preempt_disable(); _metered_write_lock(lock);})
101083 +#define write_unlock(lock)     ({_metered_write_unlock(lock); preempt_enable();})
101084 +#define write_trylock(lock)    ({preempt_disable();_metered_write_trylock(lock) ? \
101085 +                               1 : ({preempt_enable(); 0;});})
101086 +#define spin_unlock_no_resched(lock) \
101087 +do { \
101088 +       _metered_spin_unlock(lock); \
101089 +       preempt_enable_no_resched(); \
101090 +} while (0)
101091 +
101092 +#define read_lock_irqsave(lock, flags) \
101093 +do { \
101094 +       local_irq_save(flags); \
101095 +       preempt_disable(); \
101096 +       _metered_read_lock(lock); \
101097 +} while (0)
101098 +
101099 +#define read_lock_irq(lock) \
101100 +do { \
101101 +       local_irq_disable(); \
101102 +       preempt_disable(); \
101103 +       _metered_read_lock(lock); \
101104 +} while (0)
101105 +
101106 +#define read_lock_bh(lock) \
101107 +do { \
101108 +       local_bh_disable(); \
101109 +       preempt_disable(); \
101110 +       _metered_read_lock(lock); \
101111 +} while (0)
101112 +
101113 +#define read_unlock_bh(lock) \
101114 +do { \
101115 +       _metered_read_unlock(lock); \
101116 +       preempt_enable(); \
101117 +       local_bh_enable(); \
101118 +} while (0)
101119 +
101120 +#define write_lock_irqsave(lock, flags) \
101121 +do { \
101122 +       local_irq_save(flags); \
101123 +       preempt_disable(); \
101124 +       _metered_write_lock(lock); \
101125 +} while (0)
101126 +
101127 +#define write_lock_irq(lock) \
101128 +do { \
101129 +       local_irq_disable(); \
101130 +       preempt_disable(); \
101131 +       _metered_write_lock(lock); \
101132 +} while (0)
101133 +
101134 +#define write_lock_bh(lock) \
101135 +do { \
101136 +       local_bh_disable(); \
101137 +       preempt_disable(); \
101138 +       _metered_write_lock(lock); \
101139 +} while (0)
101140 +
101141 +#define write_unlock_bh(lock) \
101142 +do { \
101143 +       _metered_write_unlock(lock); \
101144 +       preempt_enable(); \
101145 +       local_bh_enable(); \
101146 +} while (0)
101147 +
101148 +#endif /* !CONFIG_LOCKMETER */
101149 +
101150  /* "lock on reference count zero" */
101151  #ifndef ATOMIC_DEC_AND_LOCK
101152  #include <asm/atomic.h>
101153 --- linux-2.6.0-test6/include/linux/stallion.h  2003-06-14 12:18:32.000000000 -0700
101154 +++ 25/include/linux/stallion.h 2003-10-05 00:33:25.000000000 -0700
101155 @@ -21,6 +21,8 @@
101156   *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
101157   */
101158  
101159 +#include <linux/version.h>
101160 +
101161  /*****************************************************************************/
101162  #ifndef        _STALLION_H
101163  #define        _STALLION_H
101164 --- linux-2.6.0-test6/include/linux/sysctl.h    2003-09-08 13:58:59.000000000 -0700
101165 +++ 25/include/linux/sysctl.h   2003-10-05 00:33:25.000000000 -0700
101166 @@ -244,6 +244,7 @@ enum
101167         NET_IPV4_NEIGH=17,
101168         NET_IPV4_ROUTE=18,
101169         NET_IPV4_FIB_HASH=19,
101170 +       NET_IPV4_NETFILTER=20,
101171  
101172         NET_IPV4_TCP_TIMESTAMPS=33,
101173         NET_IPV4_TCP_WINDOW_SCALING=34,
101174 @@ -358,6 +359,24 @@ enum
101175         NET_IPV4_CONF_NOPOLICY=16,
101176  };
101177  
101178 +/* /proc/sys/net/ipv4/netfilter */
101179 +enum
101180 +{
101181 +       NET_IPV4_NF_CONNTRACK_MAX=1,
101182 +       NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT=2,
101183 +       NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV=3,
101184 +       NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED=4,
101185 +       NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT=5,
101186 +       NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT=6,
101187 +       NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK=7,
101188 +       NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT=8,
101189 +       NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE=9,
101190 +       NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT=10,
101191 +       NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT_STREAM=11,
101192 +       NET_IPV4_NF_CONNTRACK_ICMP_TIMEOUT=12,
101193 +       NET_IPV4_NF_CONNTRACK_GENERIC_TIMEOUT=13,
101194 +};
101195
101196  /* /proc/sys/net/ipv6 */
101197  enum {
101198         NET_IPV6_CONF=16,
101199 --- linux-2.6.0-test6/include/linux/toshiba.h   2003-09-08 13:58:59.000000000 -0700
101200 +++ 25/include/linux/toshiba.h  2003-10-05 00:33:25.000000000 -0700
101201 @@ -33,4 +33,13 @@ typedef struct {
101202         unsigned int edi __attribute__ ((packed));
101203  } SMMRegisters;
101204  
101205 +#ifdef CONFIG_PROC_FS
101206 +static int tosh_get_info(char *, char **, off_t, int);
101207 +#else /* !CONFIG_PROC_FS */
101208 +inline int tosh_get_info(char *buffer, char **start, off_t fpos, int lenght)
101209 +{
101210 +       return 0;
101211 +}
101212 +#endif /* CONFIG_PROC_FS */
101213 +
101214  #endif
101215 --- linux-2.6.0-test6/include/linux/usb.h       2003-09-27 18:57:47.000000000 -0700
101216 +++ 25/include/linux/usb.h      2003-10-05 00:33:25.000000000 -0700
101217 @@ -1038,9 +1038,9 @@ void usb_show_string(struct usb_device *
101218  #define dbg(format, arg...) do {} while (0)
101219  #endif
101220  
101221 -#define err(format, arg...) printk(KERN_ERR __FILE__ ": " format "\n" , ## arg)
101222 -#define info(format, arg...) printk(KERN_INFO __FILE__ ": " format "\n" , ## arg)
101223 -#define warn(format, arg...) printk(KERN_WARNING __FILE__ ": " format "\n" , ## arg)
101224 +#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , __FILE__ , ## arg)
101225 +#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , __FILE__ , ## arg)
101226 +#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , __FILE__ , ## arg)
101227  
101228  
101229  #endif  /* __KERNEL__ */
101230 --- linux-2.6.0-test6/include/linux/wait.h      2003-09-08 13:58:59.000000000 -0700
101231 +++ 25/include/linux/wait.h     2003-10-05 00:36:54.000000000 -0700
101232 @@ -80,6 +80,15 @@ static inline int waitqueue_active(wait_
101233         return !list_empty(&q->task_list);
101234  }
101235  
101236 +/*
101237 + * Used to distinguish between sync and async io wait context:
101238 + * sync i/o typically specifies a NULL wait queue entry or a wait
101239 + * queue entry bound to a task (current task) to wake up.
101240 + * aio specifies a wait queue entry with an async notification
101241 + * callback routine, not associated with any task.
101242 + */
101243 +#define is_sync_wait(wait)     (!(wait) || ((wait)->task))
101244 +
101245  extern void FASTCALL(add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait));
101246  extern void FASTCALL(add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait));
101247  extern void FASTCALL(remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait));
101248 --- linux-2.6.0-test6/include/linux/writeback.h 2003-09-27 18:57:47.000000000 -0700
101249 +++ 25/include/linux/writeback.h        2003-10-05 00:37:01.000000000 -0700
101250 @@ -84,9 +84,13 @@ int dirty_writeback_centisecs_handler(st
101251                                       void __user *, size_t *);
101252  
101253  void page_writeback_init(void);
101254 -void balance_dirty_pages_ratelimited(struct address_space *mapping);
101255 +int balance_dirty_pages_ratelimited(struct address_space *mapping);
101256  int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0);
101257  int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
101258 +ssize_t sync_page_range(struct inode *inode, struct address_space *mapping,
101259 +                       loff_t pos, size_t count);
101260 +ssize_t sync_page_range_nolock(struct inode *inode, struct address_space
101261 +               *mapping, loff_t pos, size_t count);
101262  
101263  /* pdflush.c */
101264  extern int nr_pdflush_threads; /* Global so it can be exported to sysctl
101265 --- linux-2.6.0-test6/include/net/irda/irda_device.h    2003-08-22 19:23:42.000000000 -0700
101266 +++ 25/include/net/irda/irda_device.h   2003-10-05 00:33:25.000000000 -0700
101267 @@ -128,6 +128,7 @@ struct dongle_reg {
101268         void (*close)(dongle_t *dongle);
101269         int  (*reset)(struct irda_task *task);
101270         int  (*change_speed)(struct irda_task *task);
101271 +       struct module *owner;
101272  };
101273  
101274  /* 
101275 @@ -223,6 +224,7 @@ int  irda_device_set_raw_mode(struct net
101276  int  irda_device_set_dtr_rts(struct net_device *dev, int dtr, int rts);
101277  int  irda_device_change_speed(struct net_device *dev, __u32 speed);
101278  void irda_device_setup(struct net_device *dev);
101279 +struct net_device *alloc_irdadev(int sizeof_priv);
101280  
101281  /* Dongle interface */
101282  void irda_device_unregister_dongle(struct dongle_reg *dongle);
101283 --- linux-2.6.0-test6/include/net/pkt_sched.h   2003-08-08 22:55:14.000000000 -0700
101284 +++ 25/include/net/pkt_sched.h  2003-10-05 00:33:25.000000000 -0700
101285 @@ -8,6 +8,7 @@
101286  #define PSCHED_CLOCK_SOURCE    PSCHED_JIFFIES
101287  
101288  #include <linux/config.h>
101289 +#include <linux/netdevice.h>
101290  #include <linux/types.h>
101291  #include <linux/pkt_sched.h>
101292  #include <net/pkt_cls.h>
101293 --- linux-2.6.0-test6/include/net/scm.h 2003-06-14 12:18:20.000000000 -0700
101294 +++ 25/include/net/scm.h        2003-10-05 00:33:25.000000000 -0700
101295 @@ -39,7 +39,7 @@ static __inline__ int scm_send(struct so
101296         memset(scm, 0, sizeof(*scm));
101297         scm->creds.uid = current->uid;
101298         scm->creds.gid = current->gid;
101299 -       scm->creds.pid = current->pid;
101300 +       scm->creds.pid = current->tgid;
101301         if (msg->msg_controllen <= 0)
101302                 return 0;
101303         return __scm_send(sock, msg, scm);
101304 --- linux-2.6.0-test6/include/net/sctp/command.h        2003-08-08 22:55:14.000000000 -0700
101305 +++ 25/include/net/sctp/command.h       2003-10-05 00:33:25.000000000 -0700
101306 @@ -1,5 +1,6 @@
101307 -/* SCTP kernel reference Implementation Copyright (C) 1999-2001
101308 - * Cisco, Motorola, and IBM
101309 +/* SCTP kernel reference Implementation
101310 + * (C) Copyright IBM Corp. 2001, 2003
101311 + * Copyright (C) 1999-2001 Cisco, Motorola
101312   *
101313   * This file is part of the SCTP kernel reference Implementation
101314   *
101315 @@ -88,6 +89,7 @@ typedef enum {
101316         SCTP_CMD_PART_DELIVER,   /* Partial data delivery considerations. */
101317         SCTP_CMD_RENEGE,         /* Renege data on an association. */
101318         SCTP_CMD_SETUP_T4,       /* ADDIP, setup T4 RTO timer parms. */
101319 +       SCTP_CMD_PROCESS_OPERR,  /* Process an ERROR chunk. */
101320         SCTP_CMD_LAST
101321  } sctp_verb_t;
101322  
101323 --- linux-2.6.0-test6/include/net/sctp/sctp.h   2003-09-08 13:58:59.000000000 -0700
101324 +++ 25/include/net/sctp/sctp.h  2003-10-05 00:33:25.000000000 -0700
101325 @@ -116,6 +116,9 @@
101326  #define SCTP_STATIC static
101327  #endif
101328  
101329 +#define MSECS_TO_JIFFIES(msec) (msec * HZ / 1000)
101330 +#define JIFFIES_TO_MSECS(jiff) (jiff * 1000 / HZ)
101331 +
101332  /*
101333   * Function declarations.
101334   */
101335 @@ -495,22 +498,19 @@ for (err = (sctp_errhdr_t *)((void *)chu
101336  #define tv_lt(s, t) \
101337     (s.tv_sec < t.tv_sec || (s.tv_sec == t.tv_sec && s.tv_usec < t.tv_usec))
101338  
101339 -/* Stolen from net/profile.h.  Using it from there is more grief than
101340 - * it is worth.
101341 - */
101342 -static inline void tv_add(const struct timeval *entered, struct timeval *leaved)
101343 -{
101344 -       time_t usecs = leaved->tv_usec + entered->tv_usec;
101345 -       time_t secs = leaved->tv_sec + entered->tv_sec;
101346 -
101347 -       if (usecs >= 1000000) {
101348 -               usecs -= 1000000;
101349 -               secs++;
101350 -       }
101351 -       leaved->tv_sec = secs;
101352 -       leaved->tv_usec = usecs;
101353 -}
101354 -
101355 +/* Add tv1 to tv2. */
101356 +#define TIMEVAL_ADD(tv1, tv2) \
101357 +({ \
101358 +        suseconds_t usecs = (tv2).tv_usec + (tv1).tv_usec; \
101359 +        time_t secs = (tv2).tv_sec + (tv1).tv_sec; \
101360 +\
101361 +        if (usecs >= 1000000) { \
101362 +                usecs -= 1000000; \
101363 +                secs++; \
101364 +        } \
101365 +        (tv2).tv_sec = secs; \
101366 +        (tv2).tv_usec = usecs; \
101367 +})
101368  
101369  /* External references. */
101370  
101371 --- linux-2.6.0-test6/include/net/sctp/sm.h     2003-09-08 13:58:59.000000000 -0700
101372 +++ 25/include/net/sctp/sm.h    2003-10-05 00:33:25.000000000 -0700
101373 @@ -265,13 +265,19 @@ struct sctp_chunk *sctp_make_op_error(co
101374  struct sctp_chunk *sctp_make_asconf(struct sctp_association *asoc,
101375                                     union sctp_addr *addr,
101376                                     int vparam_len);
101377 +struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *,
101378 +                                             union sctp_addr *,
101379 +                                             struct sockaddr *,
101380 +                                             int, int);
101381 +struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc,
101382 +                                            union sctp_addr *addr);
101383 +struct sctp_chunk *sctp_make_asconf_ack(struct sctp_association *asoc,
101384 +                                       int serial, int vparam_len);
101385 +
101386  struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
101387                                        struct sctp_chunk *asconf,
101388                                        int vparam_len);
101389  
101390 -struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc,
101391 -                                            union sctp_addr *addr);
101392 -
101393  void sctp_chunk_assign_tsn(struct sctp_chunk *);
101394  void sctp_chunk_assign_ssn(struct sctp_chunk *);
101395  
101396 --- linux-2.6.0-test6/include/net/sctp/structs.h        2003-09-08 13:58:59.000000000 -0700
101397 +++ 25/include/net/sctp/structs.h       2003-10-05 00:33:25.000000000 -0700
101398 @@ -1085,6 +1085,10 @@ int sctp_add_bind_addr(struct sctp_bind_
101399  int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *);
101400  int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *,
101401                          struct sctp_opt *);
101402 +union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr  *bp,
101403 +                                       const union sctp_addr   *addrs,
101404 +                                       int                     addrcnt,
101405 +                                       struct sctp_opt         *opt);
101406  union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp,
101407                                          int *addrs_len, int gfp);
101408  int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len,
101409 @@ -1389,6 +1393,10 @@ struct sctp_association {
101410                 __u8    ipv4_address;    /* Peer understands IPv4 addresses? */
101411                 __u8    ipv6_address;    /* Peer understands IPv6 addresses? */
101412                 __u8    hostname_address;/* Peer understands DNS addresses? */
101413 +
101414 +               /* Does peer support ADDIP? */
101415 +               __u8    asconf_capable;
101416 +
101417                 struct sctp_inithdr i;
101418                 int cookie_len;
101419                 void *cookie;
101420 --- linux-2.6.0-test6/include/sound/sndmagic.h  2003-06-14 12:18:06.000000000 -0700
101421 +++ 25/include/sound/sndmagic.h 2003-10-05 00:33:25.000000000 -0700
101422 @@ -198,6 +198,8 @@ static inline int _snd_magic_bad(void *o
101423  #define vx_pipe_t_magic                                0xa15a4112
101424  #define azf3328_t_magic                                0xa15a4200
101425  
101426 +#define snd_card_harmony_t_magic               0xa15a4300
101427 +
101428  #else
101429  
101430  #define snd_magic_kcalloc(type, extra, flags) (type *) snd_kcalloc(sizeof(type) + extra, flags)
101431 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
101432 +++ 25/include/video/epson1355.h        2003-10-05 00:34:22.000000000 -0700
101433 @@ -0,0 +1,64 @@
101434 +/*
101435 + * include/video/epson13xx.h -- Epson 13xx frame buffer
101436 + *
101437 + * Copyright (C) Hewlett-Packard Company.  All rights reserved.
101438 + *
101439 + * Written by Christopher Hoover <ch@hpl.hp.com>
101440 + *
101441 + */
101442 +
101443 +#ifndef _EPSON13XX_H_
101444 +#define _EPSON13XX_H_
101445 +
101446 +#define REG_REVISION_CODE              0x00
101447 +#define REG_MEMORY_CONFIG              0x01
101448 +#define REG_PANEL_TYPE                 0x02
101449 +#define REG_MOD_RATE                   0x03
101450 +#define REG_HORZ_DISP_WIDTH            0x04
101451 +#define REG_HORZ_NONDISP_PERIOD        0x05
101452 +#define REG_HRTC_START_POSITION        0x06
101453 +#define REG_HRTC_PULSE_WIDTH           0x07
101454 +#define REG_VERT_DISP_HEIGHT0          0x08
101455 +#define REG_VERT_DISP_HEIGHT1          0x09
101456 +#define REG_VERT_NONDISP_PERIOD        0x0A
101457 +#define REG_VRTC_START_POSITION        0x0B
101458 +#define REG_VRTC_PULSE_WIDTH           0x0C
101459 +#define REG_DISPLAY_MODE               0x0D
101460 +#define REG_SCRN1_LINE_COMPARE0        0x0E
101461 +#define REG_SCRN1_LINE_COMPARE1        0x0F
101462 +#define REG_SCRN1_DISP_START_ADDR0     0x10
101463 +#define REG_SCRN1_DISP_START_ADDR1     0x11
101464 +#define REG_SCRN1_DISP_START_ADDR2     0x12
101465 +#define REG_SCRN2_DISP_START_ADDR0     0x13
101466 +#define REG_SCRN2_DISP_START_ADDR1     0x14
101467 +#define REG_SCRN2_DISP_START_ADDR2     0x15
101468 +#define REG_MEM_ADDR_OFFSET0           0x16
101469 +#define REG_MEM_ADDR_OFFSET1           0x17
101470 +#define REG_PIXEL_PANNING              0x18
101471 +#define REG_CLOCK_CONFIG               0x19
101472 +#define REG_POWER_SAVE_CONFIG          0x1A
101473 +#define REG_MISC                       0x1B
101474 +#define REG_MD_CONFIG_READBACK0        0x1C
101475 +#define REG_MD_CONFIG_READBACK1        0x1D
101476 +#define REG_GPIO_CONFIG0               0x1E
101477 +#define REG_GPIO_CONFIG1               0x1F
101478 +#define REG_GPIO_CONTROL0              0x20
101479 +#define REG_GPIO_CONTROL1              0x21
101480 +#define REG_PERF_ENHANCEMENT0          0x22
101481 +#define REG_PERF_ENHANCEMENT1          0x23
101482 +#define REG_LUT_ADDR                   0x24
101483 +#define REG_RESERVED_1                 0x25
101484 +#define REG_LUT_DATA                   0x26
101485 +#define REG_INK_CURSOR_CONTROL         0x27
101486 +#define REG_CURSOR_X_POSITION0         0x28
101487 +#define REG_CURSOR_X_POSITION1         0x29
101488 +#define REG_CURSOR_Y_POSITION0         0x2A
101489 +#define REG_CURSOR_Y_POSITION1         0x2B
101490 +#define REG_INK_CURSOR_COLOR0_0        0x2C
101491 +#define REG_INK_CURSOR_COLOR0_1        0x2D
101492 +#define REG_INK_CURSOR_COLOR1_0        0x2E
101493 +#define REG_INK_CURSOR_COLOR1_1        0x2F
101494 +#define REG_INK_CURSOR_START_ADDR      0x30
101495 +#define REG_ALTERNATE_FRM              0x31
101496 +
101497 +#endif
101498 --- linux-2.6.0-test6/include/video/neomagic.h  2003-06-14 12:18:07.000000000 -0700
101499 +++ 25/include/video/neomagic.h 2003-10-05 00:34:22.000000000 -0700
101500 @@ -55,6 +55,20 @@
101501  #define NEO_MODE1_X_1600        0x1c00
101502  #define NEO_MODE1_BLT_ON_ADDR   0x2000
101503  
101504 +/* These are offseted in MMIO space by par->CursorOff */
101505 +#define NEOREG_CURSCNTL                0x00
101506 +#define NEOREG_CURSX           0x04
101507 +#define NEOREG_CURSY           0x08
101508 +#define NEOREG_CURSBGCOLOR     0x0C
101509 +#define NEOREG_CURSFGCOLOR     0x10
101510 +#define NEOREG_CURSMEMPOS      0x14
101511 +
101512 +#define NEO_CURS_DISABLE       0x00000000
101513 +#define NEO_CURS_ENABLE                0x00000001
101514 +#define NEO_ICON64_ENABLE      0x00000008
101515 +#define NEO_ICON128_ENABLE     0x0000000C
101516 +#define NEO_ICON_BLANK         0x00000010
101517 +
101518  #ifdef __KERNEL__
101519  
101520  #ifdef NEOFB_DEBUG
101521 @@ -75,45 +89,45 @@
101522  
101523  
101524  struct xtimings {
101525 -  unsigned int pixclock;
101526 -  unsigned int HDisplay;
101527 -  unsigned int HSyncStart;
101528 -  unsigned int HSyncEnd;
101529 -  unsigned int HTotal;
101530 -  unsigned int VDisplay;
101531 -  unsigned int VSyncStart;
101532 -  unsigned int VSyncEnd;
101533 -  unsigned int VTotal;
101534 -  unsigned int sync;
101535 -  int         dblscan;
101536 -  int         interlaced;
101537 +       unsigned int pixclock;
101538 +       unsigned int HDisplay;
101539 +       unsigned int HSyncStart;
101540 +       unsigned int HSyncEnd;
101541 +       unsigned int HTotal;
101542 +       unsigned int VDisplay;
101543 +       unsigned int VSyncStart;
101544 +       unsigned int VSyncEnd;
101545 +       unsigned int VTotal;
101546 +       unsigned int sync;
101547 +       int dblscan;
101548 +       int interlaced;
101549  };
101550  
101551  
101552  /* --------------------------------------------------------------------- */
101553  
101554  typedef volatile struct {
101555 -  __u32 bltStat;
101556 -  __u32 bltCntl;
101557 -  __u32 xpColor;
101558 -  __u32 fgColor;
101559 -  __u32 bgColor;
101560 -  __u32 pitch;
101561 -  __u32 clipLT;
101562 -  __u32 clipRB;
101563 -  __u32 srcBitOffset;
101564 -  __u32 srcStart;
101565 -  __u32 reserved0;
101566 -  __u32 dstStart;
101567 -  __u32 xyExt;
101568 -
101569 -  __u32 reserved1[19];
101570 -
101571 -  __u32 pageCntl;
101572 -  __u32 pageBase;
101573 -  __u32 postBase;
101574 -  __u32 postPtr;
101575 -  __u32 dataPtr;
101576 +       __u32 bltStat;
101577 +       __u32 bltCntl;
101578 +       __u32 xpColor;
101579 +       __u32 fgColor;
101580 +       __u32 bgColor;
101581 +       __u32 pitch;
101582 +       __u32 clipLT;
101583 +       __u32 clipRB;
101584 +       __u32 srcBitOffset;
101585 +       __u32 srcStart;
101586 +       __u32 reserved0;
101587 +       __u32 dstStart;
101588 +       __u32 xyExt;
101589 +
101590 +       __u32 reserved1[19];
101591 +
101592 +       __u32 pageCntl;
101593 +       __u32 pageBase;
101594 +       __u32 postBase;
101595 +       __u32 postPtr;
101596 +       __u32 dataPtr;
101597  } Neo2200;
101598  
101599  #define NR_PALETTE     256
101600 @@ -124,142 +138,69 @@ typedef volatile struct {
101601  #define NEO_EXT_GR_MAX 0xC7
101602  
101603  struct neofb_par {
101604 -  
101605 -  unsigned char MiscOutReg;     /* Misc */
101606 -  unsigned char CRTC[25];       /* Crtc Controller */
101607 -  unsigned char Sequencer[5];   /* Video Sequencer */
101608 -  unsigned char Graphics[9];    /* Video Graphics */
101609 -  unsigned char Attribute[21];  /* Video Atribute */
101610 -
101611 -  unsigned char GeneralLockReg;
101612 -  unsigned char ExtCRTDispAddr;
101613 -  unsigned char ExtCRTOffset;
101614 -  unsigned char SysIfaceCntl1;
101615 -  unsigned char SysIfaceCntl2;
101616 -  unsigned char ExtColorModeSelect;
101617 -  unsigned char biosMode;
101618 -
101619 -  unsigned char PanelDispCntlReg1;
101620 -  unsigned char PanelDispCntlReg2;
101621 -  unsigned char PanelDispCntlReg3;
101622 -  unsigned char PanelVertCenterReg1;
101623 -  unsigned char PanelVertCenterReg2;
101624 -  unsigned char PanelVertCenterReg3;
101625 -  unsigned char PanelVertCenterReg4;
101626 -  unsigned char PanelVertCenterReg5;
101627 -  unsigned char PanelHorizCenterReg1;
101628 -  unsigned char PanelHorizCenterReg2;
101629 -  unsigned char PanelHorizCenterReg3;
101630 -  unsigned char PanelHorizCenterReg4;
101631 -  unsigned char PanelHorizCenterReg5;
101632 -
101633 -  int           ProgramVCLK;
101634 -  unsigned char VCLK3NumeratorLow;
101635 -  unsigned char VCLK3NumeratorHigh;
101636 -  unsigned char VCLK3Denominator;
101637 -  unsigned char VerticalExt;
101638 +       struct vgastate state;
101639 +       atomic_t ref_count;
101640 +
101641 +       unsigned char MiscOutReg;       /* Misc */
101642 +       unsigned char CRTC[25];         /* Crtc Controller */
101643 +       unsigned char Sequencer[5];     /* Video Sequencer */
101644 +       unsigned char Graphics[9];      /* Video Graphics */
101645 +       unsigned char Attribute[21];    /* Video Atribute */
101646 +
101647 +       unsigned char GeneralLockReg;
101648 +       unsigned char ExtCRTDispAddr;
101649 +       unsigned char ExtCRTOffset;
101650 +       unsigned char SysIfaceCntl1;
101651 +       unsigned char SysIfaceCntl2;
101652 +       unsigned char ExtColorModeSelect;
101653 +       unsigned char biosMode;
101654 +
101655 +       unsigned char PanelDispCntlReg1;
101656 +       unsigned char PanelDispCntlReg2;
101657 +       unsigned char PanelDispCntlReg3;
101658 +       unsigned char PanelVertCenterReg1;
101659 +       unsigned char PanelVertCenterReg2;
101660 +       unsigned char PanelVertCenterReg3;
101661 +       unsigned char PanelVertCenterReg4;
101662 +       unsigned char PanelVertCenterReg5;
101663 +       unsigned char PanelHorizCenterReg1;
101664 +       unsigned char PanelHorizCenterReg2;
101665 +       unsigned char PanelHorizCenterReg3;
101666 +       unsigned char PanelHorizCenterReg4;
101667 +       unsigned char PanelHorizCenterReg5;
101668 +
101669 +       int ProgramVCLK;
101670 +       unsigned char VCLK3NumeratorLow;
101671 +       unsigned char VCLK3NumeratorHigh;
101672 +       unsigned char VCLK3Denominator;
101673 +       unsigned char VerticalExt;
101674  
101675  #ifdef CONFIG_MTRR
101676 -  int    mtrr;
101677 +       int mtrr;
101678  #endif
101679 -  u8    *mmio_vbase;
101680 -
101681 -  Neo2200 *neo2200;
101682 -
101683 -  /* Panels size */
101684 -  int NeoPanelWidth;
101685 -  int NeoPanelHeight;
101686 -
101687 -  int maxClock;
101688 -
101689 -  int pci_burst;
101690 -  int lcd_stretch;
101691 -  int internal_display;
101692 -  int external_display;
101693 -  int libretto;
101694 +       u8 *mmio_vbase;
101695 +       u8 cursorOff;
101696 +       u8 *cursorPad;          /* Must die !! */
101697 +
101698 +       Neo2200 *neo2200;
101699 +
101700 +       /* Panels size */
101701 +       int NeoPanelWidth;
101702 +       int NeoPanelHeight;
101703 +
101704 +       int maxClock;
101705 +
101706 +       int pci_burst;
101707 +       int lcd_stretch;
101708 +       int internal_display;
101709 +       int external_display;
101710 +       int libretto;
101711  };
101712  
101713  typedef struct {
101714 -    int x_res;
101715 -    int y_res;
101716 -    int mode;
101717 +       int x_res;
101718 +       int y_res;
101719 +       int mode;
101720  } biosMode;
101721  
101722 -/* vga IO functions */
101723 -static inline u8 VGArCR (u8 index)
101724 -{
101725 -  outb (index, 0x3d4);
101726 -  return inb (0x3d5);
101727 -}
101728 -
101729 -static inline void VGAwCR (u8 index, u8 val)
101730 -{
101731 -  outb (index, 0x3d4);
101732 -  outb (val, 0x3d5);
101733 -}
101734 -
101735 -static inline u8 VGArGR (u8 index)
101736 -{
101737 -  outb (index, 0x3ce);
101738 -  return inb (0x3cf);
101739 -}
101740 -
101741 -static inline void VGAwGR (u8 index, u8 val)
101742 -{
101743 -  outb (index, 0x3ce);
101744 -  outb (val, 0x3cf);
101745 -}
101746 -
101747 -static inline u8 VGArSEQ (u8 index)
101748 -{
101749 -  outb (index, 0x3c4);
101750 -  return inb (0x3c5);
101751 -}
101752 -
101753 -static inline void VGAwSEQ (u8 index, u8 val)
101754 -{
101755 -  outb (index, 0x3c4);
101756 -  outb (val, 0x3c5);
101757 -}
101758 -
101759 -
101760 -static int paletteEnabled = 0;
101761 -
101762 -static inline void VGAenablePalette (void)
101763 -{
101764 -  u8 tmp;
101765 -
101766 -  tmp = inb (0x3da);
101767 -  outb (0x00, 0x3c0);
101768 -  paletteEnabled = 1;
101769 -}
101770 -
101771 -static inline void VGAdisablePalette (void)
101772 -{
101773 -  u8 tmp;
101774 -
101775 -  tmp = inb (0x3da);
101776 -  outb (0x20, 0x3c0);
101777 -  paletteEnabled = 0;
101778 -}
101779 -
101780 -static inline void VGAwATTR (u8 index, u8 value)
101781 -{
101782 -  u8 tmp;
101783 -
101784 -  if (paletteEnabled)
101785 -    index &= ~0x20;
101786 -  else
101787 -    index |= 0x20;
101788 -
101789 -  tmp = inb (0x3da);
101790 -  outb (index, 0x3c0);
101791 -  outb (value, 0x3c0);
101792 -}
101793 -
101794 -static inline void VGAwMISC (u8 value)
101795 -{
101796 -  outb (value, 0x3c2);
101797 -}
101798  #endif
101799 -
101800 --- linux-2.6.0-test6/include/video/sisfb.h     2003-09-08 13:58:59.000000000 -0700
101801 +++ 25/include/video/sisfb.h    2003-10-05 00:34:22.000000000 -0700
101802 @@ -6,6 +6,53 @@
101803  #include <asm/ioctl.h>
101804  #include <asm/types.h>
101805  
101806 +/* TW: vbflags */
101807 +#define CRT2_DEFAULT            0x00000001
101808 +#define CRT2_LCD                0x00000002  /* TW: Never change the order of the CRT2_XXX entries */
101809 +#define CRT2_TV                 0x00000004  /*     (see SISCycleCRT2Type())                       */
101810 +#define CRT2_VGA                0x00000008
101811 +#define CRT2_ENABLE            (CRT2_LCD | CRT2_TV | CRT2_VGA)
101812 +#define VB_DISPTYPE_DISP2      CRT2_ENABLE
101813 +#define VB_DISPTYPE_CRT2       CRT2_ENABLE
101814 +#define TV_NTSC                 0x00000010
101815 +#define TV_PAL                  0x00000020
101816 +#define TV_HIVISION             0x00000040
101817 +#define TV_HIVISION_LV          0x00000080
101818 +#define TV_TYPE                 (TV_NTSC | TV_PAL | TV_HIVISION | TV_HIVISION_LV)
101819 +#define TV_AVIDEO               0x00000100
101820 +#define TV_SVIDEO               0x00000200
101821 +#define TV_SCART                0x00000400
101822 +#define TV_INTERFACE            (TV_AVIDEO | TV_SVIDEO | TV_SCART | TV_CHSCART | TV_CHHDTV)
101823 +#define VB_USELCDA             0x00000800
101824 +#define TV_PALM                 0x00001000
101825 +#define TV_PALN                 0x00002000
101826 +#define TV_CHSCART              0x00008000
101827 +#define TV_CHHDTV               0x00010000
101828 +#define VGA2_CONNECTED          0x00040000
101829 +#define VB_DISPTYPE_CRT1       0x00080000      /* CRT1 connected and used */
101830 +#define VBDISPTYPE_DISP1       VB_DISPTYPE_CRT1
101831 +#define VB_301                  0x00100000     /* Video bridge type */
101832 +#define VB_301B                 0x00200000
101833 +#define VB_302B                 0x00400000
101834 +#define VB_30xBDH              0x00800000      /* 30xB DH version (w/o LCD support) */
101835 +#define VB_LVDS                 0x01000000
101836 +#define VB_CHRONTEL             0x02000000
101837 +#define VB_301LV                0x04000000
101838 +#define VB_302LV                0x08000000
101839 +#define VB_TRUMPION            0x10000000
101840 +#define VB_VIDEOBRIDGE         (VB_301|VB_301B|VB_302B|VB_301LV|VB_302LV| \
101841 +                                VB_LVDS|VB_CHRONTEL|VB_TRUMPION)
101842 +#define VB_SISBRIDGE            (VB_301|VB_301B|VB_302B|VB_301LV|VB_302LV)
101843 +#define VB_SINGLE_MODE          0x20000000      /* CRT1 or CRT2; determined by VB_DISPTYPE_CRTx */
101844 +#define VB_DISPMODE_SINGLE     VB_SINGLE_MODE
101845 +#define VB_MIRROR_MODE         0x40000000       /* CRT1 + CRT2 identical (mirror mode) */
101846 +#define VB_DISPMODE_MIRROR     VB_MIRROR_MODE
101847 +#define VB_DUALVIEW_MODE       0x80000000       /* CRT1 + CRT2 independent (dual head mode) */
101848 +#define VB_DISPMODE_DUAL       VB_DUALVIEW_MODE
101849 +#define VB_DISPLAY_MODE         (VB_SINGLE_MODE | VB_MIRROR_MODE | VB_DUALVIEW_MODE)
101850 +
101851 +
101852 +/* entries for disp_state - deprecated as of 1.6.02 */
101853  #define DISPTYPE_CRT1       0x00000008L
101854  #define DISPTYPE_CRT2       0x00000004L
101855  #define DISPTYPE_LCD        0x00000002L
101856 @@ -16,6 +63,7 @@
101857  #define DISPMODE_MIRROR            0x00000010L
101858  #define DISPMODE_DUALVIEW   0x00000040L
101859  
101860 +/* Deprecated as of 1.6.02 - use vbflags instead */
101861  #define HASVB_NONE             0x00
101862  #define HASVB_301              0x01
101863  #define HASVB_LVDS             0x02
101864 @@ -39,6 +87,8 @@ typedef enum _SIS_CHIP_TYPE {
101865         SIS_650,
101866         SIS_740,
101867         SIS_330,
101868 +       SIS_660,
101869 +       SIS_760,
101870         MAX_SIS_CHIP
101871  } SIS_CHIP_TYPE;
101872  
101873 @@ -83,13 +133,15 @@ struct ap_data {
101874         struct mode_info minfo;
101875         unsigned long iobase;
101876         unsigned int  mem_size;
101877 -       unsigned long disp_state;       
101878 +       unsigned long disp_state;  /* deprecated */
101879         SIS_CHIP_TYPE chip;
101880         unsigned char hasVB;
101881 -       SIS_TV_TYPE TV_type;
101882 -       SIS_TV_PLUG TV_plug;
101883 +       SIS_TV_TYPE TV_type;       /* deprecated */
101884 +       SIS_TV_PLUG TV_plug;       /* deprecated */
101885         unsigned long version;
101886 -       char reserved[256];
101887 +       unsigned long vbflags;     /* replaces deprecated entries above */
101888 +       unsigned long currentvbflags;
101889 +       char reserved[248];
101890  };
101891  
101892  struct video_info {
101893 @@ -114,10 +166,10 @@ struct video_info {
101894         int    video_linelength;
101895         unsigned int refresh_rate;
101896  
101897 -       unsigned long disp_state;
101898 -       unsigned char hasVB;
101899 -       unsigned char TV_type;
101900 -       unsigned char TV_plug;
101901 +       unsigned long disp_state;               /* DEPRECATED */
101902 +       unsigned char hasVB;                    /* DEPRECATED */
101903 +       unsigned char TV_type;                  /* DEPRECATED */
101904 +       unsigned char TV_plug;                  /* DEPRECATED */
101905  
101906         SIS_CHIP_TYPE chip;
101907         unsigned char revision_id;
101908 @@ -137,7 +189,18 @@ struct video_info {
101909         unsigned short subsysvendor;
101910         unsigned short subsysdevice;
101911  
101912 -       char reserved[236];
101913 +       unsigned long  vbflags;                 /* Replacing deprecated stuff from above */
101914 +       unsigned long  currentvbflags;
101915 +
101916 +       int    current_bpp;
101917 +       int    current_width;
101918 +       int    current_height;
101919 +       int    current_htotal;
101920 +       int    current_vtotal;
101921 +       __u32  current_pixclock;
101922 +       int    current_refresh_rate;
101923 +
101924 +       char reserved[200];
101925  };
101926  
101927  
101928 @@ -185,7 +248,13 @@ struct _SISFB_INFO {
101929         
101930         unsigned char sisfb_lcda;       /* Detected status of LCDA for low res/text modes */
101931  
101932 -       char reserved[235];             /* for future use */
101933 +       unsigned long sisfb_vbflags;
101934 +       unsigned long sisfb_currentvbflags;
101935 +
101936 +       int sisfb_scalelcd;
101937 +       unsigned long sisfb_specialtiming;
101938 +
101939 +       char reserved[219];             /* for future use */
101940  };
101941  
101942  #ifdef __KERNEL__
101943 --- linux-2.6.0-test6/init/do_mounts.h  2003-09-27 18:57:47.000000000 -0700
101944 +++ 25/init/do_mounts.h 2003-10-05 00:33:25.000000000 -0700
101945 @@ -104,4 +104,3 @@ void md_run_setup(void);
101946  static inline void md_run_setup(void) {}
101947  
101948  #endif
101949 -
101950 --- linux-2.6.0-test6/init/do_mounts_initrd.c   2003-09-27 18:57:47.000000000 -0700
101951 +++ 25/init/do_mounts_initrd.c  2003-10-05 00:33:53.000000000 -0700
101952 @@ -9,6 +9,8 @@
101953  
101954  #include "do_mounts.h"
101955  
101956 +unsigned long initrd_start, initrd_end;
101957 +int initrd_below_start_ok;
101958  unsigned int real_root_dev;    /* do_proc_dointvec cannot handle kdev_t */
101959  static int __initdata old_fd, root_fd;
101960  static int __initdata mount_initrd = 1;
101961 @@ -99,18 +101,20 @@ static void __init handle_initrd(void)
101962  
101963  int __init initrd_load(void)
101964  {
101965 -       if (!mount_initrd)
101966 -               return 0;
101967 -
101968 -       create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, 0), NULL);
101969 -       create_dev("/dev/initrd", MKDEV(RAMDISK_MAJOR, INITRD_MINOR), NULL);
101970 -       /* Load the initrd data into /dev/ram0. Execute it as initrd unless
101971 -        * /dev/ram0 is supposed to be our actual root device, in
101972 -        * that case the ram disk is just set up here, and gets
101973 -        * mounted in the normal path. */
101974 -       if (rd_load_image("/dev/initrd") && ROOT_DEV != Root_RAM0) {
101975 -               handle_initrd();
101976 -               return 1;
101977 +       if (mount_initrd) {
101978 +               create_dev("/dev/ram", Root_RAM0, NULL);
101979 +               /*
101980 +                * Load the initrd data into /dev/ram0. Execute it as initrd
101981 +                * unless /dev/ram0 is supposed to be our actual root device,
101982 +                * in that case the ram disk is just set up here, and gets
101983 +                * mounted in the normal path.
101984 +                */
101985 +               if (rd_load_image("/dev/initrd") && ROOT_DEV != Root_RAM0) {
101986 +                       sys_unlink("/dev/initrd");
101987 +                       handle_initrd();
101988 +                       return 1;
101989 +               }
101990         }
101991 +       sys_unlink("/dev/initrd");
101992         return 0;
101993  }
101994 --- linux-2.6.0-test6/init/initramfs.c  2003-09-27 18:57:47.000000000 -0700
101995 +++ 25/init/initramfs.c 2003-10-05 00:33:53.000000000 -0700
101996 @@ -8,9 +8,11 @@
101997  #include <linux/delay.h>
101998  #include <linux/string.h>
101999  
102000 +static __initdata char *message;
102001  static void __init error(char *x)
102002  {
102003 -       panic("populate_root: %s\n", x);
102004 +       if (!message)
102005 +               message = x;
102006  }
102007  
102008  static void __init *malloc(int size)
102009 @@ -63,7 +65,7 @@ static char __init *find_link(int major,
102010         }
102011         q = (struct hash *)malloc(sizeof(struct hash));
102012         if (!q)
102013 -               error("can't allocate link hash entry");
102014 +               panic("can't allocate link hash entry");
102015         q->ino = ino;
102016         q->minor = minor;
102017         q->major = major;
102018 @@ -119,7 +121,7 @@ static void __init parse_header(char *s)
102019  
102020  /* FSM */
102021  
102022 -enum state {
102023 +static __initdata enum state {
102024         Start,
102025         Collect,
102026         GotHeader,
102027 @@ -130,9 +132,11 @@ enum state {
102028         Reset
102029  } state, next_state;
102030  
102031 -char *victim;
102032 -unsigned count;
102033 -loff_t this_header, next_header;
102034 +static __initdata char *victim;
102035 +static __initdata unsigned count;
102036 +static __initdata loff_t this_header, next_header;
102037 +
102038 +static __initdata int dry_run;
102039  
102040  static inline void eat(unsigned n)
102041  {
102042 @@ -185,23 +189,30 @@ static int __init do_collect(void)
102043  
102044  static int __init do_header(void)
102045  {
102046 +       if (memcmp(collected, "070701", 6)) {
102047 +               error("no cpio magic");
102048 +               return 1;
102049 +       }
102050         parse_header(collected);
102051         next_header = this_header + N_ALIGN(name_len) + body_len;
102052         next_header = (next_header + 3) & ~3;
102053 +       if (dry_run) {
102054 +               read_into(name_buf, N_ALIGN(name_len), GotName);
102055 +               return 0;
102056 +       }
102057 +       state = SkipIt;
102058         if (name_len <= 0 || name_len > PATH_MAX)
102059 -               state = SkipIt;
102060 -       else if (S_ISLNK(mode)) {
102061 +               return 0;
102062 +       if (S_ISLNK(mode)) {
102063                 if (body_len > PATH_MAX)
102064 -                       state = SkipIt;
102065 -               else {
102066 -                       collect = collected = symlink_buf;
102067 -                       remains = N_ALIGN(name_len) + body_len;
102068 -                       next_state = GotSymlink;
102069 -                       state = Collect;
102070 -               }
102071 -       } else if (body_len && !S_ISREG(mode))
102072 -               state = SkipIt;
102073 -       else
102074 +                       return 0;
102075 +               collect = collected = symlink_buf;
102076 +               remains = N_ALIGN(name_len) + body_len;
102077 +               next_state = GotSymlink;
102078 +               state = Collect;
102079 +               return 0;
102080 +       }
102081 +       if (S_ISREG(mode) || !body_len)
102082                 read_into(name_buf, N_ALIGN(name_len), GotName);
102083         return 0;
102084  }
102085 @@ -248,6 +259,8 @@ static int __init do_name(void)
102086                 next_state = Reset;
102087                 return 0;
102088         }
102089 +       if (dry_run)
102090 +               return 0;
102091         if (S_ISREG(mode)) {
102092                 if (maybe_link() >= 0) {
102093                         wfd = sys_open(collected, O_WRONLY|O_CREAT, mode);
102094 @@ -268,8 +281,7 @@ static int __init do_name(void)
102095                         sys_chown(collected, uid, gid);
102096                         sys_chmod(collected, mode);
102097                 }
102098 -       } else
102099 -               panic("populate_root: bogus mode: %o\n", mode);
102100 +       }
102101         return 0;
102102  }
102103  
102104 @@ -323,13 +335,14 @@ static int __init write_buffer(char *buf
102105  static void __init flush_buffer(char *buf, unsigned len)
102106  {
102107         int written;
102108 -       while ((written = write_buffer(buf, len)) < len) {
102109 +       if (message)
102110 +               return;
102111 +       while ((written = write_buffer(buf, len)) < len && !message) {
102112                 char c = buf[written];
102113                 if (c == '0') {
102114                         buf += written;
102115                         len -= written;
102116                         state = Start;
102117 -                       continue;
102118                 } else
102119                         error("junk in compressed archive");
102120         }
102121 @@ -408,18 +421,20 @@ static void __init flush_window(void)
102122         outcnt = 0;
102123  }
102124  
102125 -static void __init unpack_to_rootfs(char *buf, unsigned len)
102126 +char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
102127  {
102128         int written;
102129 +       dry_run = check_only;
102130         header_buf = malloc(110);
102131         symlink_buf = malloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1);
102132         name_buf = malloc(N_ALIGN(PATH_MAX));
102133         window = malloc(WSIZE);
102134         if (!window || !header_buf || !symlink_buf || !name_buf)
102135 -               error("can't allocate buffers");
102136 +               panic("can't allocate buffers");
102137         state = Start;
102138         this_header = 0;
102139 -       while (len) {
102140 +       message = NULL;
102141 +       while (!message && len) {
102142                 loff_t saved_offset = this_header;
102143                 if (*buf == '0' && !(this_header & 3)) {
102144                         state = Start;
102145 @@ -427,7 +442,8 @@ static void __init unpack_to_rootfs(char
102146                         buf += written;
102147                         len -= written;
102148                         continue;
102149 -               } else if (!*buf) {
102150 +               }
102151 +               if (!*buf) {
102152                         buf++;
102153                         len--;
102154                         this_header++;
102155 @@ -442,7 +458,7 @@ static void __init unpack_to_rootfs(char
102156                 crc = (ulg)0xffffffffL; /* shift register contents */
102157                 makecrc();
102158                 if (gunzip())
102159 -                       error("ungzip failed");
102160 +                       message = "ungzip failed";
102161                 if (state != Reset)
102162                         error("junk in gzipped archive");
102163                 this_header = saved_offset + inptr;
102164 @@ -453,12 +469,41 @@ static void __init unpack_to_rootfs(char
102165         free(name_buf);
102166         free(symlink_buf);
102167         free(header_buf);
102168 +       return message;
102169  }
102170  
102171  extern char __initramfs_start, __initramfs_end;
102172 +#ifdef CONFIG_BLK_DEV_INITRD
102173 +#include <linux/initrd.h>
102174 +#endif
102175  
102176  void __init populate_rootfs(void)
102177  {
102178 -       unpack_to_rootfs(&__initramfs_start,
102179 -                        &__initramfs_end - &__initramfs_start);
102180 +       char *err = unpack_to_rootfs(&__initramfs_start,
102181 +                        &__initramfs_end - &__initramfs_start, 0);
102182 +       if (err)
102183 +               panic(err);
102184 +#ifdef CONFIG_BLK_DEV_INITRD
102185 +       if (initrd_start) {
102186 +               int fd;
102187 +               printk(KERN_INFO "checking if image is initramfs...");
102188 +               err = unpack_to_rootfs((char *)initrd_start,
102189 +                       initrd_end - initrd_start, 1);
102190 +               if (!err) {
102191 +                       printk(" it is\n");
102192 +                       unpack_to_rootfs((char *)initrd_start,
102193 +                               initrd_end - initrd_start, 0);
102194 +                       free_initrd_mem(initrd_start, initrd_end);
102195 +                       return;
102196 +               }
102197 +               printk("it isn't (%s); looks like an initrd\n", err);
102198 +               fd = sys_open("/dev/initrd", O_WRONLY|O_CREAT, 700);
102199 +               if (fd >= 0) {
102200 +                       sys_write(fd, (char *)initrd_start,
102201 +                                       initrd_end - initrd_start);
102202 +                       sys_close(fd);
102203 +                       free_initrd_mem(initrd_start, initrd_end);
102204 +               }
102205 +       }
102206 +#endif
102207  }
102208 --- linux-2.6.0-test6/init/main.c       2003-09-27 18:57:47.000000000 -0700
102209 +++ 25/init/main.c      2003-10-05 00:36:25.000000000 -0700
102210 @@ -37,6 +37,7 @@
102211  #include <linux/moduleparam.h>
102212  #include <linux/writeback.h>
102213  #include <linux/cpu.h>
102214 +#include <linux/efi.h>
102215  
102216  #include <asm/io.h>
102217  #include <asm/bugs.h>
102218 @@ -436,6 +437,10 @@ asmlinkage void __init start_kernel(void
102219         pidmap_init();
102220         pgtable_cache_init();
102221         pte_chain_init();
102222 +#ifdef CONFIG_X86
102223 +       if (efi_enabled)
102224 +               efi_enter_virtual_mode();
102225 +#endif
102226         fork_init(num_physpages);
102227         proc_caches_init();
102228         buffer_init();
102229 --- linux-2.6.0-test6/kernel/acct.c     2003-09-27 18:57:47.000000000 -0700
102230 +++ 25/kernel/acct.c    2003-10-05 00:36:15.000000000 -0700
102231 @@ -343,7 +343,7 @@ static void do_acct_process(long exitcod
102232         /* we really need to bite the bullet and change layout */
102233         ac.ac_uid = current->uid;
102234         ac.ac_gid = current->gid;
102235 -       ac.ac_tty = current->tty ? old_encode_dev(tty_devnum(current->tty)) : 0;
102236 +       ac.ac_tty = process_tty(current) ? old_encode_dev(tty_devnum(process_tty(current))) : 0;
102237  
102238         ac.ac_flag = 0;
102239         if (current->flags & PF_FORKNOEXEC)
102240 --- linux-2.6.0-test6/kernel/exit.c     2003-09-27 18:57:47.000000000 -0700
102241 +++ 25/kernel/exit.c    2003-10-05 00:36:15.000000000 -0700
102242 @@ -119,13 +119,13 @@ int session_of_pgrp(int pgrp)
102243  
102244         read_lock(&tasklist_lock);
102245         for_each_task_pid(pgrp, PIDTYPE_PGID, p, l, pid)
102246 -               if (p->session > 0) {
102247 -                       sid = p->session;
102248 +               if (process_session(p) > 0) {
102249 +                       sid = process_session(p);
102250                         goto out;
102251                 }
102252         p = find_task_by_pid(pgrp);
102253         if (p)
102254 -               sid = p->session;
102255 +               sid = process_session(p);
102256  out:
102257         read_unlock(&tasklist_lock);
102258         
102259 @@ -153,7 +153,7 @@ static int will_become_orphaned_pgrp(int
102260                                 || p->real_parent->pid == 1)
102261                         continue;
102262                 if (process_group(p->real_parent) != pgrp
102263 -                           && p->real_parent->session == p->session) {
102264 +                           && process_session(p->real_parent) == process_session(p)) {
102265                         ret = 0;
102266                         break;
102267                 }
102268 @@ -242,14 +242,14 @@ void __set_special_pids(pid_t session, p
102269  {
102270         struct task_struct *curr = current;
102271  
102272 -       if (curr->session != session) {
102273 +       if (process_session(curr) != session) {
102274                 detach_pid(curr, PIDTYPE_SID);
102275 -               curr->session = session;
102276 +               curr->signal->session = session;
102277                 attach_pid(curr, PIDTYPE_SID, session);
102278         }
102279         if (process_group(curr) != pgrp) {
102280                 detach_pid(curr, PIDTYPE_PGID);
102281 -               curr->group_leader->__pgrp = pgrp;
102282 +               curr->signal->pgrp = pgrp;
102283                 attach_pid(curr, PIDTYPE_PGID, pgrp);
102284         }
102285  }
102286 @@ -303,7 +303,7 @@ void daemonize(const char *name, ...)
102287         exit_mm(current);
102288  
102289         set_special_pids(1, 1);
102290 -       current->tty = NULL;
102291 +       current->signal->tty = NULL;
102292  
102293         /* Block and flush all signals */
102294         sigfillset(&blocked);
102295 @@ -509,7 +509,7 @@ static inline void reparent_thread(task_
102296          * outside, so the child pgrp is now orphaned.
102297          */
102298         if ((process_group(p) != process_group(father)) &&
102299 -           (p->session == father->session)) {
102300 +           (process_session(p) == process_session(father))) {
102301                 int pgrp = process_group(p);
102302  
102303                 if (will_become_orphaned_pgrp(pgrp, NULL) && has_stopped_jobs(pgrp)) {
102304 @@ -619,7 +619,7 @@ static void exit_notify(struct task_stru
102305         t = tsk->real_parent;
102306         
102307         if ((process_group(t) != process_group(tsk)) &&
102308 -           (t->session == tsk->session) &&
102309 +           (process_session(t) == process_session(tsk)) &&
102310             will_become_orphaned_pgrp(process_group(tsk), tsk) &&
102311             has_stopped_jobs(process_group(tsk))) {
102312                 __kill_pg_info(SIGHUP, (void *)1, process_group(tsk));
102313 @@ -714,7 +714,7 @@ NORET_TYPE void do_exit(long code)
102314         exit_itimers(tsk);
102315         exit_thread();
102316  
102317 -       if (tsk->leader)
102318 +       if (process_session_leader(tsk))
102319                 disassociate_ctty(1);
102320  
102321         module_put(tsk->thread_info->exec_domain->module);
102322 --- linux-2.6.0-test6/kernel/fork.c     2003-09-27 18:57:47.000000000 -0700
102323 +++ 25/kernel/fork.c    2003-10-05 00:36:54.000000000 -0700
102324 @@ -121,7 +121,12 @@ void prepare_to_wait(wait_queue_head_t *
102325  {
102326         unsigned long flags;
102327  
102328 -       __set_current_state(state);
102329 +       /*
102330 +        * don't alter the task state if this is just going to
102331 +        * queue an async wait queue callback
102332 +        */
102333 +       if (is_sync_wait(wait))
102334 +               __set_current_state(state);
102335         wait->flags &= ~WQ_FLAG_EXCLUSIVE;
102336         spin_lock_irqsave(&q->lock, flags);
102337         if (list_empty(&wait->task_list))
102338 @@ -134,7 +139,12 @@ prepare_to_wait_exclusive(wait_queue_hea
102339  {
102340         unsigned long flags;
102341  
102342 -       __set_current_state(state);
102343 +       /*
102344 +        * don't alter the task state if this is just going to
102345 +        * queue an async wait queue callback
102346 +        */
102347 +       if (is_sync_wait(wait))
102348 +               __set_current_state(state);
102349         wait->flags |= WQ_FLAG_EXCLUSIVE;
102350         spin_lock_irqsave(&q->lock, flags);
102351         if (list_empty(&wait->task_list))
102352 @@ -274,9 +284,9 @@ static inline int dup_mmap(struct mm_str
102353                                 atomic_dec(&inode->i_writecount);
102354        
102355                         /* insert tmp into the share list, just after mpnt */
102356 -                       down(&inode->i_mapping->i_shared_sem);
102357 +                       down(&file->f_mapping->i_shared_sem);
102358                         list_add_tail(&tmp->shared, &mpnt->shared);
102359 -                       up(&inode->i_mapping->i_shared_sem);
102360 +                       up(&file->f_mapping->i_shared_sem);
102361                 }
102362  
102363                 /*
102364 @@ -725,6 +735,12 @@ static inline int copy_signal(unsigned l
102365         sig->curr_target = NULL;
102366         init_sigpending(&sig->shared_pending);
102367  
102368 +       sig->tty = process_tty(current);
102369 +       sig->pgrp = process_group(current);
102370 +       sig->session = process_session(current);
102371 +       sig->leader = 0;        /* session leadership doesn't inherit */
102372 +       sig->tty_old_pgrp = 0;
102373 +
102374         return 0;
102375  }
102376  
102377 @@ -771,7 +787,9 @@ struct task_struct *copy_process(unsigne
102378          * Thread groups must share signals as well, and detached threads
102379          * can only be started up within the thread group.
102380          */
102381 -       if ((clone_flags & CLONE_THREAD) && !(clone_flags & CLONE_SIGHAND))
102382 +       if ((clone_flags & CLONE_THREAD) &&
102383 +               (clone_flags & (CLONE_SIGHAND|CLONE_DETACHED)) !=
102384 +                       (CLONE_SIGHAND|CLONE_DETACHED))
102385                 return ERR_PTR(-EINVAL);
102386  
102387         /*
102388 @@ -876,8 +894,6 @@ struct task_struct *copy_process(unsigne
102389         init_timer(&p->real_timer);
102390         p->real_timer.data = (unsigned long) p;
102391  
102392 -       p->leader = 0;          /* session leadership doesn't inherit */
102393 -       p->tty_old_pgrp = 0;
102394         p->utime = p->stime = 0;
102395         p->cutime = p->cstime = 0;
102396         p->array = NULL;
102397 @@ -885,6 +901,7 @@ struct task_struct *copy_process(unsigne
102398         p->start_time = get_jiffies_64();
102399         p->security = NULL;
102400         p->io_context = NULL;
102401 +       p->io_wait = NULL;
102402  
102403         retval = -ENOMEM;
102404         if ((retval = security_task_alloc(p)))
102405 @@ -1022,7 +1039,7 @@ struct task_struct *copy_process(unsigne
102406         if (thread_group_leader(p)) {
102407                 attach_pid(p, PIDTYPE_TGID, p->tgid);
102408                 attach_pid(p, PIDTYPE_PGID, process_group(p));
102409 -               attach_pid(p, PIDTYPE_SID, p->session);
102410 +               attach_pid(p, PIDTYPE_SID, process_session(p));
102411                 if (p->pid)
102412                         __get_cpu_var(process_counts)++;
102413         } else
102414 --- linux-2.6.0-test6/kernel/futex.c    2003-09-27 18:57:47.000000000 -0700
102415 +++ 25/kernel/futex.c   2003-10-05 00:34:38.000000000 -0700
102416 @@ -45,6 +45,9 @@
102417   * Futexes are matched on equal values of this key.
102418   * The key type depends on whether it's a shared or private mapping.
102419   * Don't rearrange members without looking at hash_futex().
102420 + *
102421 + * offset is aligned to a multiple of sizeof(u32) (== 4) by definition.
102422 + * We set bit 0 to indicate if it's an inode-based key.
102423   */
102424  union futex_key {
102425         struct {
102426 @@ -66,12 +69,20 @@ union futex_key {
102427  
102428  /*
102429   * We use this hashed waitqueue instead of a normal wait_queue_t, so
102430 - * we can wake only the relevant ones (hashed queues may be shared):
102431 + * we can wake only the relevant ones (hashed queues may be shared).
102432 + *
102433 + * A futex_q has a woken state, just like tasks have TASK_RUNNING.
102434 + * It is considered woken when list_empty(&q->list) || q->lock_ptr == 0.
102435 + * The order of wakup is always to make the first condition true, then
102436 + * wake up q->waiters, then make the second condition true.
102437   */
102438  struct futex_q {
102439         struct list_head list;
102440         wait_queue_head_t waiters;
102441  
102442 +       /* Which hash list lock to use. */
102443 +       spinlock_t *lock_ptr;
102444 +
102445         /* Key which the futex is hashed on. */
102446         union futex_key key;
102447  
102448 @@ -124,8 +135,7 @@ static inline int match_futex(union fute
102449   * Returns: 0, or negative error code.
102450   * The key words are stored in *key on success.
102451   *
102452 - * Should be called with &current->mm->mmap_sem,
102453 - * but NOT &futex_lock or &current->mm->page_table_lock.
102454 + * Should be called with &current->mm->mmap_sem but NOT any spinlocks.
102455   */
102456  static int get_futex_key(unsigned long uaddr, union futex_key *key)
102457  {
102458 @@ -172,9 +182,10 @@ static int get_futex_key(unsigned long u
102459         }
102460  
102461         /*
102462 -        * Linear mappings are also simple.
102463 +        * Linear file mappings are also simple.
102464          */
102465         key->shared.inode = vma->vm_file->f_dentry->d_inode;
102466 +       key->both.offset++; /* Bit 0 of offset indicates inode-based key. */
102467         if (likely(!(vma->vm_flags & VM_NONLINEAR))) {
102468                 key->shared.pgoff = (((uaddr - vma->vm_start) >> PAGE_SHIFT)
102469                                      + vma->vm_pgoff);
102470 @@ -214,16 +225,68 @@ static int get_futex_key(unsigned long u
102471         return err;
102472  }
102473  
102474 +/*
102475 + * Take a reference to the resource addressed by a key.
102476 + * Can be called while holding spinlocks.
102477 + *
102478 + * NOTE: mmap_sem MUST be held between get_futex_key() and calling this
102479 + * function, if it is called at all.  mmap_sem keeps key->shared.inode valid.
102480 + */
102481 +static inline void get_key_refs(union futex_key *key)
102482 +{
102483 +       if (key->both.ptr != 0) {
102484 +               if (key->both.offset & 1)
102485 +                       atomic_inc(&key->shared.inode->i_count);
102486 +               else
102487 +                       atomic_inc(&key->private.mm->mm_count);
102488 +       }
102489 +}
102490 +
102491 +/*
102492 + * Drop a reference to the resource addressed by a key.
102493 + * The hash bucket spinlock must not be held.
102494 + */
102495 +static void drop_key_refs(union futex_key *key)
102496 +{
102497 +       if (key->both.ptr != 0) {
102498 +               if (key->both.offset & 1)
102499 +                       iput(key->shared.inode);
102500 +               else
102501 +                       mmdrop(key->private.mm);
102502 +       }
102503 +}
102504 +
102505 +/*
102506 + * The hash bucket lock must be held when this is called.
102507 + * Afterwards, the futex_q must not be accessed.
102508 + */
102509 +static void wake_futex(struct futex_q *q)
102510 +{
102511 +       list_del_init(&q->list);
102512 +       if (q->filp)
102513 +               send_sigio(&q->filp->f_owner, q->fd, POLL_IN);
102514 +       /*
102515 +        * The lock in wake_up_all() is a crucial memory barrier after the
102516 +        * list_del_init() and also before assigning to q->lock_ptr.
102517 +        */
102518 +       wake_up_all(&q->waiters);
102519 +       /*
102520 +        * The waiting task can free the futex_q as soon as this is written,
102521 +        * without taking any locks.  This must come last.
102522 +        */
102523 +       q->lock_ptr = 0;
102524 +}
102525  
102526  /*
102527   * Wake up all waiters hashed on the physical page that is mapped
102528   * to this virtual address:
102529   */
102530 -static int futex_wake(unsigned long uaddr, int num)
102531 +static int futex_wake(unsigned long uaddr, int nr_wake)
102532  {
102533 -       struct list_head *i, *next, *head;
102534 -       struct futex_hash_bucket *bh;
102535         union futex_key key;
102536 +       struct futex_hash_bucket *bh;
102537 +       struct list_head *head;
102538 +       struct futex_q *this, *next;
102539         int ret;
102540  
102541         down_read(&current->mm->mmap_sem);
102542 @@ -236,21 +299,15 @@ static int futex_wake(unsigned long uadd
102543         spin_lock(&bh->lock);
102544         head = &bh->chain;
102545  
102546 -       list_for_each_safe(i, next, head) {
102547 -               struct futex_q *this = list_entry(i, struct futex_q, list);
102548 -
102549 +       list_for_each_entry_safe(this, next, head, list) {
102550                 if (match_futex (&this->key, &key)) {
102551 -                       list_del_init(i);
102552 -                       wake_up_all(&this->waiters);
102553 -                       if (this->filp)
102554 -                               send_sigio(&this->filp->f_owner, this->fd, POLL_IN);
102555 -                       ret++;
102556 -                       if (ret >= num)
102557 +                       wake_futex(this);
102558 +                       if (++ret >= nr_wake)
102559                                 break;
102560                 }
102561         }
102562 -       spin_unlock(&bh->lock);
102563  
102564 +       spin_unlock(&bh->lock);
102565  out:
102566         up_read(&current->mm->mmap_sem);
102567         return ret;
102568 @@ -263,10 +320,11 @@ out:
102569  static int futex_requeue(unsigned long uaddr1, unsigned long uaddr2,
102570                                 int nr_wake, int nr_requeue)
102571  {
102572 -       struct list_head *i, *next, *head1, *head2;
102573 -       struct futex_hash_bucket *bh1, *bh2;
102574         union futex_key key1, key2;
102575 -       int ret;
102576 +       struct futex_hash_bucket *bh1, *bh2;
102577 +       struct list_head *head1;
102578 +       struct futex_q *this, *next;
102579 +       int ret, drop_count = 0;
102580  
102581         down_read(&current->mm->mmap_sem);
102582  
102583 @@ -279,78 +337,107 @@ static int futex_requeue(unsigned long u
102584  
102585         bh1 = hash_futex(&key1);
102586         bh2 = hash_futex(&key2);
102587 -       if (bh1 < bh2) {
102588 +
102589 +       if (bh1 < bh2)
102590 +               spin_lock(&bh1->lock);
102591 +       spin_lock(&bh2->lock);
102592 +       if (bh1 > bh2)
102593                 spin_lock(&bh1->lock);
102594 -               spin_lock(&bh2->lock);
102595 -       } else {
102596 -               spin_lock(&bh2->lock);
102597 -               if (bh1 > bh2)
102598 -                       spin_lock(&bh1->lock);
102599 -       }
102600 -       head1 = &bh1->chain;
102601 -       head2 = &bh2->chain;
102602  
102603 -       list_for_each_safe(i, next, head1) {
102604 -               struct futex_q *this = list_entry(i, struct futex_q, list);
102605 +       head1 = &bh1->chain;
102606 +       list_for_each_entry_safe(this, next, head1, list) {
102607 +               if (!match_futex (&this->key, &key1))
102608 +                       continue;
102609 +               if (++ret <= nr_wake) {
102610 +                       wake_futex(this);
102611 +               } else {
102612 +                       list_move_tail(&this->list, &bh2->chain);
102613 +                       this->lock_ptr = &bh2->lock;
102614 +                       this->key = key2;
102615 +                       get_key_refs(&key2);
102616 +                       drop_count++;
102617  
102618 -               if (match_futex (&this->key, &key1)) {
102619 -                       list_del_init(i);
102620 -                       if (++ret <= nr_wake) {
102621 -                               wake_up_all(&this->waiters);
102622 -                               if (this->filp)
102623 -                                       send_sigio(&this->filp->f_owner,
102624 -                                                       this->fd, POLL_IN);
102625 -                       } else {
102626 -                               list_add_tail(i, head2);
102627 -                               this->key = key2;
102628 -                               if (ret - nr_wake >= nr_requeue)
102629 -                                       break;
102630 -                               /* Make sure to stop if key1 == key2 */
102631 -                               if (head1 == head2 && head1 != next)
102632 -                                       head1 = i;
102633 -                       }
102634 +                       if (ret - nr_wake >= nr_requeue)
102635 +                               break;
102636 +                       /* Make sure to stop if key1 == key2 */
102637 +                       if (head1 == &bh2->chain && head1 != &next->list)
102638 +                               head1 = &this->list;
102639                 }
102640         }
102641 -       if (bh1 < bh2) {
102642 -               spin_unlock(&bh2->lock);
102643 -               spin_unlock(&bh1->lock);
102644 -       } else {
102645 -               if (bh1 > bh2)
102646 -                       spin_unlock(&bh1->lock);
102647 +
102648 +       spin_unlock(&bh1->lock);
102649 +       if (bh1 != bh2)
102650                 spin_unlock(&bh2->lock);
102651 -       }
102652 +
102653 +       /* drop_key_refs() must be called outside the spinlocks. */
102654 +       while (--drop_count >= 0)
102655 +               drop_key_refs(&key1);
102656 +
102657  out:
102658         up_read(&current->mm->mmap_sem);
102659         return ret;
102660  }
102661  
102662 -static inline void queue_me(struct futex_q *q, union futex_key *key,
102663 -                           int fd, struct file *filp)
102664 +/*
102665 + * queue_me and unqueue_me must be called as a pair, each
102666 + * exactly once.  They are called with the hashed spinlock held.
102667 + */
102668 +
102669 +/* The key must be already stored in q->key. */
102670 +static void queue_me(struct futex_q *q, int fd, struct file *filp)
102671  {
102672 -       struct futex_hash_bucket *bh = hash_futex(key);
102673 -       struct list_head *head = &bh->chain;
102674 +       struct futex_hash_bucket *bh;
102675  
102676 -       q->key = *key;
102677         q->fd = fd;
102678         q->filp = filp;
102679  
102680 +       init_waitqueue_head(&q->waiters);
102681 +
102682 +       get_key_refs(&q->key);
102683 +       bh = hash_futex(&q->key);
102684 +       q->lock_ptr = &bh->lock;
102685 +
102686         spin_lock(&bh->lock);
102687 -       list_add_tail(&q->list, head);
102688 +       list_add_tail(&q->list, &bh->chain);
102689         spin_unlock(&bh->lock);
102690  }
102691  
102692  /* Return 1 if we were still queued (ie. 0 means we were woken) */
102693 -static inline int unqueue_me(struct futex_q *q)
102694 +static int unqueue_me(struct futex_q *q)
102695  {
102696 -       struct futex_hash_bucket *bh = hash_futex(&q->key);
102697         int ret = 0;
102698 +       spinlock_t *lock_ptr;
102699  
102700 -       spin_lock(&bh->lock);
102701 -       if (!list_empty(&q->list)) {
102702 -               list_del(&q->list);
102703 -               ret = 1;
102704 +       /* In the common case we don't take the spinlock, which is nice. */
102705 + retry:
102706 +       lock_ptr = q->lock_ptr;
102707 +       if (lock_ptr != 0) {
102708 +               spin_lock(lock_ptr);
102709 +               /*
102710 +                * q->lock_ptr can change between reading it and
102711 +                * spin_lock(), causing us to take the wrong lock.  This
102712 +                * corrects the race condition.
102713 +                *
102714 +                * Reasoning goes like this: if we have the wrong lock,
102715 +                * q->lock_ptr must have changed (maybe several times)
102716 +                * between reading it and the spin_lock().  It can
102717 +                * change again after the spin_lock() but only if it was
102718 +                * already changed before the spin_lock().  It cannot,
102719 +                * however, change back to the original value.  Therefore
102720 +                * we can detect whether we acquired the correct lock.
102721 +                */
102722 +               if (unlikely(lock_ptr != q->lock_ptr)) {
102723 +                       spin_unlock(lock_ptr);
102724 +                       goto retry;
102725 +               }
102726 +               if (likely(!list_empty(&q->list))) {
102727 +                       list_del(&q->list);
102728 +                       ret = 1;
102729 +               }
102730 +               spin_unlock(lock_ptr);
102731         }
102732 -       spin_unlock(&bh->lock);
102733 +
102734 +       drop_key_refs(&q->key);
102735         return ret;
102736  }
102737  
102738 @@ -358,19 +445,15 @@ static int futex_wait(unsigned long uadd
102739  {
102740         DECLARE_WAITQUEUE(wait, current);
102741         int ret, curval;
102742 -       union futex_key key;
102743         struct futex_q q;
102744 -       struct futex_hash_bucket *bh = NULL;
102745 -
102746 -       init_waitqueue_head(&q.waiters);
102747  
102748         down_read(&current->mm->mmap_sem);
102749  
102750 -       ret = get_futex_key(uaddr, &key);
102751 +       ret = get_futex_key(uaddr, &q.key);
102752         if (unlikely(ret != 0))
102753                 goto out_release_sem;
102754  
102755 -       queue_me(&q, &key, -1, NULL);
102756 +       queue_me(&q, -1, NULL);
102757  
102758         /*
102759          * Access the page after the futex is queued.
102760 @@ -400,23 +483,17 @@ static int futex_wait(unsigned long uadd
102761          * rely on the futex_wake() code removing us from hash when it
102762          * wakes us up.
102763          */
102764 -       add_wait_queue(&q.waiters, &wait);
102765 -       bh = hash_futex(&key);
102766 -       spin_lock(&bh->lock);
102767 -       set_current_state(TASK_INTERRUPTIBLE);
102768 -
102769 -       if (unlikely(list_empty(&q.list))) {
102770 -               /*
102771 -                * We were woken already.
102772 -                */
102773 -               spin_unlock(&bh->lock);
102774 -               set_current_state(TASK_RUNNING);
102775 -               return 0;
102776 -       }
102777  
102778 -       spin_unlock(&bh->lock);
102779 -       time = schedule_timeout(time);
102780 -       set_current_state(TASK_RUNNING);
102781 +       /* add_wait_queue is the barrier after __set_current_state. */
102782 +       __set_current_state(TASK_INTERRUPTIBLE);
102783 +       add_wait_queue(&q.waiters, &wait);
102784 +       /*
102785 +        * !list_empty() is safe here without any lock.
102786 +        * q.lock_ptr != 0 is not safe, because of ordering against wakeup.
102787 +        */
102788 +       if (likely(!list_empty(&q.list)))
102789 +               time = schedule_timeout(time);
102790 +       __set_current_state(TASK_RUNNING);
102791  
102792         /*
102793          * NOTE: we don't remove ourselves from the waitqueue because
102794 @@ -446,7 +523,7 @@ static int futex_close(struct inode *ino
102795         struct futex_q *q = filp->private_data;
102796  
102797         unqueue_me(q);
102798 -       kfree(filp->private_data);
102799 +       kfree(q);
102800         return 0;
102801  }
102802  
102803 @@ -455,14 +532,16 @@ static unsigned int futex_poll(struct fi
102804                                struct poll_table_struct *wait)
102805  {
102806         struct futex_q *q = filp->private_data;
102807 -       struct futex_hash_bucket *bh = hash_futex(&q->key);
102808         int ret = 0;
102809  
102810         poll_wait(filp, &q->waiters, wait);
102811 -       spin_lock(&bh->lock);
102812 +
102813 +       /*
102814 +        * list_empty() is safe here without any lock.
102815 +        * q->lock_ptr != 0 is not safe, because of ordering against wakeup.
102816 +        */
102817         if (list_empty(&q->list))
102818                 ret = POLLIN | POLLRDNORM;
102819 -       spin_unlock(&bh->lock);
102820  
102821         return ret;
102822  }
102823 @@ -472,12 +551,13 @@ static struct file_operations futex_fops
102824         .poll           = futex_poll,
102825  };
102826  
102827 -/* Signal allows caller to avoid the race which would occur if they
102828 -   set the sigio stuff up afterwards. */
102829 +/*
102830 + * Signal allows caller to avoid the race which would occur if they
102831 + * set the sigio stuff up afterwards.
102832 + */
102833  static int futex_fd(unsigned long uaddr, int signal)
102834  {
102835         struct futex_q *q;
102836 -       union futex_key key;
102837         struct file *filp;
102838         int ret, err;
102839  
102840 @@ -497,6 +577,7 @@ static int futex_fd(unsigned long uaddr,
102841         filp->f_op = &futex_fops;
102842         filp->f_vfsmnt = mntget(futex_mnt);
102843         filp->f_dentry = dget(futex_mnt->mnt_root);
102844 +       filp->f_mapping = filp->f_dentry->d_inode->i_mapping;
102845  
102846         if (signal) {
102847                 int err;
102848 @@ -519,20 +600,24 @@ static int futex_fd(unsigned long uaddr,
102849         }
102850  
102851         down_read(&current->mm->mmap_sem);
102852 -       err = get_futex_key(uaddr, &key);
102853 -       up_read(&current->mm->mmap_sem);
102854 +       err = get_futex_key(uaddr, &q->key);
102855  
102856         if (unlikely(err != 0)) {
102857 +               up_read(&current->mm->mmap_sem);
102858                 put_unused_fd(ret);
102859                 put_filp(filp);
102860                 kfree(q);
102861                 return err;
102862         }
102863  
102864 -       init_waitqueue_head(&q->waiters);
102865 +       /*
102866 +        * queue_me() must be called before releasing mmap_sem, because
102867 +        * key->shared.inode needs to be referenced while holding it.
102868 +        */
102869         filp->private_data = q;
102870  
102871 -       queue_me(q, &key, ret, filp);
102872 +       queue_me(q, ret, filp);
102873 +       up_read(&current->mm->mmap_sem);
102874  
102875         /* Now we map fd to filp, so userspace can access it */
102876         fd_install(ret, filp);
102877 --- linux-2.6.0-test6/kernel/kmod.c     2003-09-08 13:58:59.000000000 -0700
102878 +++ 25/kernel/kmod.c    2003-10-05 00:36:10.000000000 -0700
102879 @@ -47,7 +47,8 @@ char modprobe_path[256] = "/sbin/modprob
102880  
102881  /**
102882   * request_module - try to load a kernel module
102883 - * @module_name: Name of module
102884 + * @fmt:     printf style format string for the name of the module
102885 + * @varargs: arguements as specified in the format string
102886   *
102887   * Load a module using the user mode module loader. The function returns
102888   * zero on success or a negative errno code on failure. Note that a
102889 @@ -184,14 +185,19 @@ static int wait_for_helper(void *data)
102890  
102891         sub_info->retval = 0;
102892         pid = kernel_thread(____call_usermodehelper, sub_info, SIGCHLD);
102893 -       if (pid < 0)
102894 +       if (pid < 0) {
102895                 sub_info->retval = pid;
102896 -       else
102897 +       } else {
102898                 /* We don't have a SIGCHLD signal handler, so this
102899                  * always returns -ECHILD, but the important thing is
102900                  * that it blocks. */
102901 -               sys_wait4(pid, NULL, 0, NULL);
102902 +               mm_segment_t fs;
102903  
102904 +               fs = get_fs();
102905 +               set_fs(KERNEL_DS);
102906 +               sys_wait4(pid, &sub_info->retval, 0, NULL);
102907 +               set_fs(fs);
102908 +       }
102909         complete(sub_info->complete);
102910         return 0;
102911  }
102912 @@ -209,7 +215,7 @@ static void __call_usermodehelper(void *
102913          * until that is done.  */
102914         if (sub_info->wait)
102915                 pid = kernel_thread(wait_for_helper, sub_info,
102916 -                                   CLONE_KERNEL | SIGCHLD);
102917 +                                   CLONE_FS | CLONE_FILES | SIGCHLD);
102918         else
102919                 pid = kernel_thread(____call_usermodehelper, sub_info,
102920                                     CLONE_VFORK | SIGCHLD);
102921 --- linux-2.6.0-test6/kernel/ksyms.c    2003-09-27 18:57:47.000000000 -0700
102922 +++ 25/kernel/ksyms.c   2003-10-05 00:36:58.000000000 -0700
102923 @@ -45,8 +45,6 @@
102924  #include <linux/uio.h>
102925  #include <linux/tty.h>
102926  #include <linux/in6.h>
102927 -#include <linux/completion.h>
102928 -#include <linux/seq_file.h>
102929  #include <linux/binfmts.h>
102930  #include <linux/namei.h>
102931  #include <linux/buffer_head.h>
102932 @@ -126,11 +124,11 @@ EXPORT_SYMBOL(get_unmapped_area);
102933  EXPORT_SYMBOL(init_mm);
102934  EXPORT_SYMBOL(blk_queue_bounce);
102935  EXPORT_SYMBOL(blk_congestion_wait);
102936 +EXPORT_SYMBOL(blk_congestion_wait_wq);
102937  #ifdef CONFIG_HIGHMEM
102938  EXPORT_SYMBOL(kmap_high);
102939  EXPORT_SYMBOL(kunmap_high);
102940  EXPORT_SYMBOL(highmem_start_page);
102941 -EXPORT_SYMBOL(kmap_prot);
102942  EXPORT_SYMBOL(kmap_pte);
102943  #endif
102944  #ifdef HASHED_PAGE_VIRTUAL
102945 @@ -139,49 +137,12 @@ EXPORT_SYMBOL(page_address);
102946  EXPORT_SYMBOL(get_user_pages);
102947  
102948  /* filesystem internal functions */
102949 -EXPORT_SYMBOL(def_blk_fops);
102950 -EXPORT_SYMBOL(update_atime);
102951  EXPORT_SYMBOL(get_fs_type);
102952 -EXPORT_SYMBOL(user_get_super);
102953 -EXPORT_SYMBOL(get_super);
102954 -EXPORT_SYMBOL(drop_super);
102955 -EXPORT_SYMBOL(getname);
102956 -EXPORT_SYMBOL(names_cachep);
102957  EXPORT_SYMBOL(fput);
102958  EXPORT_SYMBOL(fget);
102959 -EXPORT_SYMBOL(igrab);
102960 -EXPORT_SYMBOL(iunique);
102961 -EXPORT_SYMBOL(iput);
102962 -EXPORT_SYMBOL(inode_init_once);
102963 -EXPORT_SYMBOL(follow_up);
102964 -EXPORT_SYMBOL(follow_down);
102965  EXPORT_SYMBOL(lookup_mnt);
102966 -EXPORT_SYMBOL(lookup_create);
102967 -EXPORT_SYMBOL(path_lookup);
102968 -EXPORT_SYMBOL(path_walk);
102969 -EXPORT_SYMBOL(path_release);
102970 -EXPORT_SYMBOL(__user_walk);
102971 -EXPORT_SYMBOL(lookup_one_len);
102972 -EXPORT_SYMBOL(lookup_hash);
102973  EXPORT_SYMBOL(sys_close);
102974  EXPORT_SYMBOL(dcache_lock);
102975 -EXPORT_SYMBOL(d_alloc_root);
102976 -EXPORT_SYMBOL(d_delete);
102977 -EXPORT_SYMBOL(dget_locked);
102978 -EXPORT_SYMBOL(d_validate);
102979 -EXPORT_SYMBOL(d_rehash);
102980 -EXPORT_SYMBOL(d_invalidate);   /* May be it will be better in dcache.h? */
102981 -EXPORT_SYMBOL(d_move);
102982 -EXPORT_SYMBOL(d_instantiate);
102983 -EXPORT_SYMBOL(d_alloc);
102984 -EXPORT_SYMBOL(d_alloc_anon);
102985 -EXPORT_SYMBOL(d_splice_alias);
102986 -EXPORT_SYMBOL(d_lookup);
102987 -EXPORT_SYMBOL(d_path);
102988 -EXPORT_SYMBOL(mark_buffer_dirty);
102989 -EXPORT_SYMBOL(end_buffer_read_sync);
102990 -EXPORT_SYMBOL(end_buffer_write_sync);
102991 -EXPORT_SYMBOL(end_buffer_async_write);
102992  EXPORT_SYMBOL(__mark_inode_dirty);
102993  EXPORT_SYMBOL(get_empty_filp);
102994  EXPORT_SYMBOL(open_private_file);
102995 @@ -190,79 +151,20 @@ EXPORT_SYMBOL(filp_open);
102996  EXPORT_SYMBOL(filp_close);
102997  EXPORT_SYMBOL(put_filp);
102998  EXPORT_SYMBOL(files_lock);
102999 -EXPORT_SYMBOL(check_disk_change);
103000 -EXPORT_SYMBOL(invalidate_bdev);
103001 -EXPORT_SYMBOL(invalidate_inodes);
103002 -EXPORT_SYMBOL(__invalidate_device);
103003  EXPORT_SYMBOL(invalidate_inode_pages);
103004  EXPORT_SYMBOL_GPL(invalidate_inode_pages2);
103005  EXPORT_SYMBOL(truncate_inode_pages);
103006 -EXPORT_SYMBOL(fsync_bdev);
103007 -EXPORT_SYMBOL(permission);
103008 -EXPORT_SYMBOL(vfs_permission);
103009  EXPORT_SYMBOL(inode_setattr);
103010  EXPORT_SYMBOL(inode_change_ok);
103011  EXPORT_SYMBOL(write_inode_now);
103012  EXPORT_SYMBOL(notify_change);
103013 -EXPORT_SYMBOL(set_blocksize);
103014 -EXPORT_SYMBOL(sb_set_blocksize);
103015 -EXPORT_SYMBOL(sb_min_blocksize);
103016 -EXPORT_SYMBOL(bdget);
103017 -EXPORT_SYMBOL(bdput);
103018 -EXPORT_SYMBOL(bd_claim);
103019 -EXPORT_SYMBOL(bd_release);
103020 -EXPORT_SYMBOL(open_bdev_excl);
103021 -EXPORT_SYMBOL(close_bdev_excl);
103022 -EXPORT_SYMBOL(open_by_devnum);
103023 -EXPORT_SYMBOL(__brelse);
103024 -EXPORT_SYMBOL(__bforget);
103025 -EXPORT_SYMBOL(ll_rw_block);
103026 -EXPORT_SYMBOL(sync_dirty_buffer);
103027 -EXPORT_SYMBOL(submit_bh);
103028 -EXPORT_SYMBOL(unlock_buffer);
103029 -EXPORT_SYMBOL(__wait_on_buffer);
103030 -EXPORT_SYMBOL(blockdev_direct_IO);
103031 -EXPORT_SYMBOL(block_write_full_page);
103032 -EXPORT_SYMBOL(block_read_full_page);
103033 -EXPORT_SYMBOL(block_prepare_write);
103034 -EXPORT_SYMBOL(block_sync_page);
103035 -EXPORT_SYMBOL(generic_cont_expand);
103036 -EXPORT_SYMBOL(cont_prepare_write);
103037 -EXPORT_SYMBOL(generic_commit_write);
103038 -EXPORT_SYMBOL(block_commit_write);
103039 -EXPORT_SYMBOL(block_truncate_page);
103040 -EXPORT_SYMBOL(generic_block_bmap);
103041 -EXPORT_SYMBOL(generic_file_read);
103042 -EXPORT_SYMBOL(generic_file_sendfile);
103043 -EXPORT_SYMBOL(do_generic_mapping_read);
103044  EXPORT_SYMBOL(file_ra_state_init);
103045 -EXPORT_SYMBOL(generic_file_write);
103046 -EXPORT_SYMBOL(generic_file_write_nolock);
103047 -EXPORT_SYMBOL(generic_file_mmap);
103048 -EXPORT_SYMBOL(generic_file_readonly_mmap);
103049  EXPORT_SYMBOL(generic_ro_fops);
103050 -EXPORT_SYMBOL(dput);
103051 -EXPORT_SYMBOL(have_submounts);
103052 -EXPORT_SYMBOL(d_find_alias);
103053 -EXPORT_SYMBOL(d_prune_aliases);
103054 -EXPORT_SYMBOL(shrink_dcache_sb);
103055 -EXPORT_SYMBOL(shrink_dcache_parent);
103056 -EXPORT_SYMBOL(shrink_dcache_anon);
103057 -EXPORT_SYMBOL(find_inode_number);
103058 -EXPORT_SYMBOL(is_subdir);
103059  EXPORT_SYMBOL(get_unused_fd);
103060  EXPORT_SYMBOL(vfs_read);
103061  EXPORT_SYMBOL(vfs_readv);
103062  EXPORT_SYMBOL(vfs_write);
103063  EXPORT_SYMBOL(vfs_writev);
103064 -EXPORT_SYMBOL(vfs_create);
103065 -EXPORT_SYMBOL(vfs_mkdir);
103066 -EXPORT_SYMBOL(vfs_mknod);
103067 -EXPORT_SYMBOL(vfs_symlink);
103068 -EXPORT_SYMBOL(vfs_link);
103069 -EXPORT_SYMBOL(vfs_rmdir);
103070 -EXPORT_SYMBOL(vfs_unlink);
103071 -EXPORT_SYMBOL(vfs_rename);
103072  EXPORT_SYMBOL(vfs_statfs);
103073  EXPORT_SYMBOL(vfs_fstat);
103074  EXPORT_SYMBOL(vfs_stat);
103075 @@ -272,9 +174,6 @@ EXPORT_SYMBOL(inode_add_bytes);
103076  EXPORT_SYMBOL(inode_sub_bytes);
103077  EXPORT_SYMBOL(inode_get_bytes);
103078  EXPORT_SYMBOL(inode_set_bytes);
103079 -EXPORT_SYMBOL(lock_rename);
103080 -EXPORT_SYMBOL(unlock_rename);
103081 -EXPORT_SYMBOL(generic_read_dir);
103082  EXPORT_SYMBOL(generic_fillattr);
103083  EXPORT_SYMBOL(generic_file_llseek);
103084  EXPORT_SYMBOL(remote_llseek);
103085 @@ -282,70 +181,21 @@ EXPORT_SYMBOL(no_llseek);
103086  EXPORT_SYMBOL(poll_initwait);
103087  EXPORT_SYMBOL(poll_freewait);
103088  EXPORT_SYMBOL(ROOT_DEV);
103089 -EXPORT_SYMBOL(find_get_page);
103090 -EXPORT_SYMBOL(find_lock_page);
103091 -EXPORT_SYMBOL(find_trylock_page);
103092 -EXPORT_SYMBOL(find_or_create_page);
103093 -EXPORT_SYMBOL(grab_cache_page_nowait);
103094 -EXPORT_SYMBOL(read_cache_page);
103095  EXPORT_SYMBOL(read_cache_pages);
103096  EXPORT_SYMBOL(mark_page_accessed);
103097 -EXPORT_SYMBOL(vfs_readlink);
103098 -EXPORT_SYMBOL(vfs_follow_link);
103099 -EXPORT_SYMBOL(page_readlink);
103100 -EXPORT_SYMBOL(page_follow_link);
103101 -EXPORT_SYMBOL(page_symlink_inode_operations);
103102 -EXPORT_SYMBOL(page_symlink);
103103  EXPORT_SYMBOL(vfs_readdir);
103104  EXPORT_SYMBOL(__break_lease);
103105  EXPORT_SYMBOL(lease_get_mtime);
103106  EXPORT_SYMBOL(lock_may_read);
103107  EXPORT_SYMBOL(lock_may_write);
103108 -EXPORT_SYMBOL(dcache_dir_open);
103109 -EXPORT_SYMBOL(dcache_dir_close);
103110 -EXPORT_SYMBOL(dcache_dir_lseek);
103111 -EXPORT_SYMBOL(dcache_readdir);
103112 -EXPORT_SYMBOL(simple_getattr);
103113 -EXPORT_SYMBOL(simple_statfs);
103114 -EXPORT_SYMBOL(simple_lookup);
103115 -EXPORT_SYMBOL(simple_dir_operations);
103116 -EXPORT_SYMBOL(simple_dir_inode_operations);
103117 -EXPORT_SYMBOL(simple_link);
103118 -EXPORT_SYMBOL(simple_unlink);
103119 -EXPORT_SYMBOL(simple_rmdir);
103120 -EXPORT_SYMBOL(simple_rename);
103121 -EXPORT_SYMBOL(simple_sync_file);
103122 -EXPORT_SYMBOL(simple_readpage);
103123 -EXPORT_SYMBOL(simple_prepare_write);
103124 -EXPORT_SYMBOL(simple_commit_write);
103125 -EXPORT_SYMBOL(simple_empty);
103126 -EXPORT_SYMBOL(simple_fill_super);
103127 -EXPORT_SYMBOL(simple_pin_fs);
103128 -EXPORT_SYMBOL(simple_release_fs);
103129  EXPORT_SYMBOL(fd_install);
103130  EXPORT_SYMBOL(put_unused_fd);
103131 -EXPORT_SYMBOL(get_sb_bdev);
103132 -EXPORT_SYMBOL(kill_block_super);
103133 -EXPORT_SYMBOL(get_sb_nodev);
103134 -EXPORT_SYMBOL(get_sb_single);
103135 -EXPORT_SYMBOL(kill_anon_super);
103136 -EXPORT_SYMBOL(kill_litter_super);
103137 -EXPORT_SYMBOL(generic_shutdown_super);
103138 -EXPORT_SYMBOL(deactivate_super);
103139 -EXPORT_SYMBOL(sget);
103140 -EXPORT_SYMBOL(set_anon_super);
103141  EXPORT_SYMBOL(do_select);
103142  
103143  /* for stackable file systems (lofs, wrapfs, cryptfs, etc.) */
103144  EXPORT_SYMBOL(default_llseek);
103145  EXPORT_SYMBOL(dentry_open);
103146 -#ifdef CONFIG_MMU
103147 -EXPORT_SYMBOL(filemap_nopage);
103148 -#endif
103149 -EXPORT_SYMBOL(filemap_fdatawrite);
103150 -EXPORT_SYMBOL(filemap_fdatawait);
103151  EXPORT_SYMBOL(lock_page);
103152 -EXPORT_SYMBOL(unlock_page);
103153  
103154  /* device registration */
103155  EXPORT_SYMBOL(register_blkdev);
103156 @@ -355,16 +205,7 @@ EXPORT_SYMBOL(tty_unregister_driver);
103157  EXPORT_SYMBOL(tty_std_termios);
103158  
103159  /* block device driver support */
103160 -EXPORT_SYMBOL(bmap);
103161 -EXPORT_SYMBOL(blkdev_open);
103162 -EXPORT_SYMBOL(blkdev_get);
103163 -EXPORT_SYMBOL(blkdev_put);
103164 -EXPORT_SYMBOL(ioctl_by_bdev);
103165  EXPORT_SYMBOL(read_dev_sector);
103166 -EXPORT_SYMBOL(init_buffer);
103167 -EXPORT_SYMBOL_GPL(generic_file_direct_IO);
103168 -EXPORT_SYMBOL(generic_file_readv);
103169 -EXPORT_SYMBOL(generic_file_writev);
103170  EXPORT_SYMBOL(iov_shorten);
103171  EXPORT_SYMBOL_GPL(default_backing_dev_info);
103172  
103173 @@ -375,32 +216,9 @@ EXPORT_SYMBOL(tty_flip_buffer_push);
103174  /* filesystem registration */
103175  EXPORT_SYMBOL(register_filesystem);
103176  EXPORT_SYMBOL(unregister_filesystem);
103177 -EXPORT_SYMBOL(kern_mount);
103178  EXPORT_SYMBOL(__mntput);
103179  EXPORT_SYMBOL(may_umount);
103180  
103181 -/* executable format registration */
103182 -EXPORT_SYMBOL(register_binfmt);
103183 -EXPORT_SYMBOL(unregister_binfmt);
103184 -EXPORT_SYMBOL(search_binary_handler);
103185 -EXPORT_SYMBOL(prepare_binprm);
103186 -EXPORT_SYMBOL(compute_creds);
103187 -EXPORT_SYMBOL(remove_arg_zero);
103188 -EXPORT_SYMBOL(set_binfmt);
103189 -
103190 -/* sysctl table registration */
103191 -EXPORT_SYMBOL(register_sysctl_table);
103192 -EXPORT_SYMBOL(unregister_sysctl_table);
103193 -EXPORT_SYMBOL(sysctl_string);
103194 -EXPORT_SYMBOL(sysctl_intvec);
103195 -EXPORT_SYMBOL(sysctl_jiffies);
103196 -EXPORT_SYMBOL(proc_dostring);
103197 -EXPORT_SYMBOL(proc_dointvec);
103198 -EXPORT_SYMBOL(proc_dointvec_jiffies);
103199 -EXPORT_SYMBOL(proc_dointvec_minmax);
103200 -EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
103201 -EXPORT_SYMBOL(proc_doulongvec_minmax);
103202 -
103203  /* interrupt handling */
103204  EXPORT_SYMBOL(request_irq);
103205  EXPORT_SYMBOL(free_irq);
103206 @@ -414,10 +232,6 @@ EXPORT_SYMBOL(prepare_to_wait_exclusive)
103207  EXPORT_SYMBOL(finish_wait);
103208  EXPORT_SYMBOL(autoremove_wake_function);
103209  
103210 -/* completion handling */
103211 -EXPORT_SYMBOL(wait_for_completion);
103212 -EXPORT_SYMBOL(complete);
103213 -
103214  /* The notion of irq probe/assignment is foreign to S/390 */
103215  
103216  #if !defined(CONFIG_ARCH_S390)
103217 @@ -449,30 +263,11 @@ EXPORT_SYMBOL(iomem_resource);
103218  
103219  /* process management */
103220  EXPORT_SYMBOL(complete_and_exit);
103221 -EXPORT_SYMBOL(default_wake_function);
103222 -EXPORT_SYMBOL(__wake_up);
103223  #ifdef CONFIG_SMP
103224  EXPORT_SYMBOL_GPL(__wake_up_sync); /* internal use only */
103225  #endif
103226 -EXPORT_SYMBOL(wake_up_process);
103227 -EXPORT_SYMBOL(sleep_on);
103228 -EXPORT_SYMBOL(sleep_on_timeout);
103229 -EXPORT_SYMBOL(interruptible_sleep_on);
103230 -EXPORT_SYMBOL(interruptible_sleep_on_timeout);
103231 -EXPORT_SYMBOL(schedule);
103232 -#ifdef CONFIG_PREEMPT
103233 -EXPORT_SYMBOL(preempt_schedule);
103234 -#endif
103235  EXPORT_SYMBOL(schedule_timeout);
103236 -EXPORT_SYMBOL(yield);
103237 -EXPORT_SYMBOL(io_schedule);
103238 -EXPORT_SYMBOL(__cond_resched);
103239 -EXPORT_SYMBOL(set_user_nice);
103240 -EXPORT_SYMBOL(task_nice);
103241  EXPORT_SYMBOL_GPL(idle_cpu);
103242 -#ifdef CONFIG_SMP
103243 -EXPORT_SYMBOL_GPL(set_cpus_allowed);
103244 -#endif
103245  #if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
103246  EXPORT_SYMBOL(kernel_flag);
103247  #endif
103248 @@ -485,18 +280,10 @@ EXPORT_SYMBOL(do_settimeofday);
103249  #if (BITS_PER_LONG < 64)
103250  EXPORT_SYMBOL(get_jiffies_64);
103251  #endif
103252 -#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
103253 -EXPORT_SYMBOL(__might_sleep);
103254 -#endif
103255 -#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT)
103256 -EXPORT_SYMBOL(__preempt_spin_lock);
103257 -EXPORT_SYMBOL(__preempt_write_lock);
103258 -#endif
103259  #if !defined(__ia64__)
103260  EXPORT_SYMBOL(loops_per_jiffy);
103261  #endif
103262  
103263 -
103264  /* misc */
103265  EXPORT_SYMBOL(panic);
103266  EXPORT_SYMBOL(panic_notifier_list);
103267 @@ -524,45 +311,16 @@ EXPORT_SYMBOL(securebits);
103268  EXPORT_SYMBOL(cap_bset);
103269  EXPORT_SYMBOL(daemonize);
103270  EXPORT_SYMBOL(csum_partial); /* for networking and md */
103271 -EXPORT_SYMBOL(seq_escape);
103272 -EXPORT_SYMBOL(seq_printf);
103273 -EXPORT_SYMBOL(seq_path);
103274 -EXPORT_SYMBOL(seq_open);
103275 -EXPORT_SYMBOL(seq_release);
103276 -EXPORT_SYMBOL(seq_read);
103277 -EXPORT_SYMBOL(seq_lseek);
103278 -EXPORT_SYMBOL(single_open);
103279 -EXPORT_SYMBOL(single_release);
103280 -EXPORT_SYMBOL(seq_release_private);
103281 -
103282 -/* Program loader interfaces */
103283 -#ifdef CONFIG_MMU
103284 -EXPORT_SYMBOL(setup_arg_pages);
103285 -#endif
103286 -EXPORT_SYMBOL(copy_strings_kernel);
103287 -EXPORT_SYMBOL(do_execve);
103288 -EXPORT_SYMBOL(flush_old_exec);
103289 -EXPORT_SYMBOL(kernel_read);
103290 -EXPORT_SYMBOL(open_exec);
103291  
103292  /* Miscellaneous access points */
103293  EXPORT_SYMBOL(si_meminfo);
103294  
103295  /* Added to make file system as module */
103296  EXPORT_SYMBOL(sys_tz);
103297 -EXPORT_SYMBOL(file_fsync);
103298 -EXPORT_SYMBOL(fsync_buffers_list);
103299 -EXPORT_SYMBOL(clear_inode);
103300 -EXPORT_SYMBOL(init_special_inode);
103301 -EXPORT_SYMBOL(new_inode);
103302 -EXPORT_SYMBOL(__insert_inode_hash);
103303 -EXPORT_SYMBOL(remove_inode_hash);
103304 -EXPORT_SYMBOL(buffer_insert_list);
103305  EXPORT_SYMBOL(make_bad_inode);
103306  EXPORT_SYMBOL(is_bad_inode);
103307  EXPORT_SYMBOL(__inode_dir_notify);
103308  EXPORT_SYMBOL(generic_osync_inode);
103309 -EXPORT_SYMBOL(remove_suid);
103310  
103311  #ifdef CONFIG_UID16
103312  EXPORT_SYMBOL(overflowuid);
103313 @@ -575,9 +333,6 @@ EXPORT_SYMBOL(fs_overflowgid);
103314  EXPORT_SYMBOL(fasync_helper);
103315  EXPORT_SYMBOL(kill_fasync);
103316  
103317 -/* binfmt_aout */
103318 -EXPORT_SYMBOL(get_write_access);
103319 -
103320  /* library functions */
103321  EXPORT_SYMBOL(strnicmp);
103322  EXPORT_SYMBOL(strspn);
103323 @@ -607,6 +362,16 @@ EXPORT_SYMBOL(__per_cpu_offset);
103324  EXPORT_SYMBOL(set_fs_pwd);
103325  EXPORT_SYMBOL(set_fs_root);
103326  
103327 +#if defined(CONFIG_LOCKMETER)
103328 +EXPORT_SYMBOL(_metered_spin_lock);
103329 +EXPORT_SYMBOL(_metered_spin_unlock);
103330 +EXPORT_SYMBOL(_metered_spin_trylock);
103331 +EXPORT_SYMBOL(_metered_read_lock);
103332 +EXPORT_SYMBOL(_metered_read_unlock);
103333 +EXPORT_SYMBOL(_metered_write_lock);
103334 +EXPORT_SYMBOL(_metered_write_unlock);
103335 +#endif
103336 +
103337  /* debug */
103338  EXPORT_SYMBOL(dump_stack);
103339  EXPORT_SYMBOL(ptrace_notify);
103340 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
103341 +++ 25/kernel/lockmeter.c       2003-10-05 00:36:40.000000000 -0700
103342 @@ -0,0 +1,1169 @@
103343 +/*
103344 + *  Copyright (C) 1999,2000 Silicon Graphics, Inc.
103345 + *
103346 + *  Written by John Hawkes (hawkes@sgi.com)
103347 + *  Based on klstat.c by Jack Steiner (steiner@sgi.com)
103348 + *
103349 + *  Modified by Ray Bryant (raybry@us.ibm.com)
103350 + *  Changes Copyright (C) 2000 IBM, Inc.
103351 + *  Added save of index in spinlock_t to improve efficiency
103352 + *  of "hold" time reporting for spinlocks
103353 + *  Added support for hold time statistics for read and write
103354 + *  locks.
103355 + */
103356 +
103357 +#include <linux/config.h>
103358 +#include <linux/types.h>
103359 +#include <linux/errno.h>
103360 +#include <linux/slab.h>
103361 +#include <linux/sched.h>
103362 +#include <linux/smp.h>
103363 +#include <linux/threads.h>
103364 +#include <linux/version.h>
103365 +#include <linux/vmalloc.h>
103366 +#include <linux/spinlock.h>
103367 +#include <linux/utsname.h>
103368 +#include <asm/system.h>
103369 +#include <asm/uaccess.h>
103370 +
103371 +#include <linux/lockmeter.h>
103372 +
103373 +#define ASSERT(cond)
103374 +#define bzero(loc,size)                memset(loc,0,size)
103375 +
103376 +/*<---------------------------------------------------*/
103377 +/*              lockmeter.c                           */
103378 +/*>---------------------------------------------------*/
103379 +
103380 +static lstat_control_t lstat_control __cacheline_aligned =
103381 +       { LSTAT_OFF, SPIN_LOCK_UNLOCKED, SPIN_LOCK_UNLOCKED,
103382 +         19 * 0, NR_CPUS * 0, 0, NR_CPUS * 0 };
103383 +
103384 +static ushort lstat_make_dir_entry(void *, void *);
103385 +
103386 +/*
103387 + * lstat_lookup
103388 + *
103389 + * Given a RA, locate the directory entry for the lock.
103390 + */
103391 +static ushort
103392 +lstat_lookup(void *lock_ptr, void *caller_ra)
103393 +{
103394 +       ushort index;
103395 +       lstat_directory_entry_t *dirp;
103396 +
103397 +       dirp = lstat_control.dir;
103398 +
103399 +       index = lstat_control.hashtab[DIRHASH(caller_ra)];
103400 +       while (dirp[index].caller_ra != caller_ra) {
103401 +               if (index == 0) {
103402 +                       return lstat_make_dir_entry(lock_ptr, caller_ra);
103403 +               }
103404 +               index = dirp[index].next_stat_index;
103405 +       }
103406 +
103407 +       if (dirp[index].lock_ptr != NULL && dirp[index].lock_ptr != lock_ptr) {
103408 +               dirp[index].lock_ptr = NULL;
103409 +       }
103410 +
103411 +       return index;
103412 +}
103413 +
103414 +/*
103415 + * lstat_make_dir_entry
103416 + * Called to add a new lock to the lock directory.
103417 + */
103418 +static ushort
103419 +lstat_make_dir_entry(void *lock_ptr, void *caller_ra)
103420 +{
103421 +       lstat_directory_entry_t *dirp;
103422 +       ushort index, hindex;
103423 +       unsigned long flags;
103424 +
103425 +       /* lock the table without recursively reentering this metering code */
103426 +       local_irq_save(flags);
103427 +       _raw_spin_lock(&lstat_control.directory_lock);
103428 +
103429 +       hindex = DIRHASH(caller_ra);
103430 +       index = lstat_control.hashtab[hindex];
103431 +       dirp = lstat_control.dir;
103432 +       while (index && dirp[index].caller_ra != caller_ra)
103433 +               index = dirp[index].next_stat_index;
103434 +
103435 +       if (index == 0) {
103436 +               if (lstat_control.next_free_dir_index < LSTAT_MAX_STAT_INDEX) {
103437 +                       index = lstat_control.next_free_dir_index++;
103438 +                       lstat_control.dir[index].caller_ra = caller_ra;
103439 +                       lstat_control.dir[index].lock_ptr = lock_ptr;
103440 +                       lstat_control.dir[index].next_stat_index =
103441 +                               lstat_control.hashtab[hindex];
103442 +                       lstat_control.hashtab[hindex] = index;
103443 +               } else {
103444 +                       lstat_control.dir_overflow++;
103445 +               }
103446 +       }
103447 +       _raw_spin_unlock(&lstat_control.directory_lock);
103448 +       local_irq_restore(flags);
103449 +       return index;
103450 +}
103451 +
103452 +int
103453 +lstat_update(void *lock_ptr, void *caller_ra, int action)
103454 +{
103455 +       int index;
103456 +       int cpu;
103457 +
103458 +       ASSERT(action < LSTAT_ACT_MAX_VALUES);
103459 +
103460 +       if (lstat_control.state == LSTAT_OFF)
103461 +               return 0;
103462 +
103463 +       index = lstat_lookup(lock_ptr, caller_ra);
103464 +       cpu = THIS_CPU_NUMBER;
103465 +       (*lstat_control.counts[cpu])[index].count[action]++;
103466 +       (*lstat_control.counts[cpu])[index].acquire_time = get_cycles();
103467 +
103468 +       return index;
103469 +}
103470 +
103471 +int
103472 +lstat_update_time(void *lock_ptr, void *caller_ra, int action, uint32_t ticks)
103473 +{
103474 +       ushort index;
103475 +       int cpu;
103476 +
103477 +       ASSERT(action < LSTAT_ACT_MAX_VALUES);
103478 +
103479 +       if (lstat_control.state == LSTAT_OFF)
103480 +               return 0;
103481 +
103482 +       index = lstat_lookup(lock_ptr, caller_ra);
103483 +       cpu = THIS_CPU_NUMBER;
103484 +       (*lstat_control.counts[cpu])[index].count[action]++;
103485 +       (*lstat_control.counts[cpu])[index].cum_wait_ticks += (uint64_t) ticks;
103486 +       if ((*lstat_control.counts[cpu])[index].max_wait_ticks < ticks)
103487 +               (*lstat_control.counts[cpu])[index].max_wait_ticks = ticks;
103488 +
103489 +       (*lstat_control.counts[cpu])[index].acquire_time = get_cycles();
103490 +
103491 +       return index;
103492 +}
103493 +
103494 +void
103495 +_metered_spin_lock(spinlock_t * lock_ptr)
103496 +{
103497 +       if (lstat_control.state == LSTAT_OFF) {
103498 +               _raw_spin_lock(lock_ptr);       /* do the real lock */
103499 +               PUT_INDEX(lock_ptr, 0); /* clean index in case lockmetering  */
103500 +               /* gets turned on before unlock */
103501 +       } else {
103502 +               void *this_pc = LSTAT_RA(LSTAT_RA_SPIN);
103503 +               int index;
103504 +
103505 +               if (_raw_spin_trylock(lock_ptr)) {
103506 +                       index = lstat_update(lock_ptr, this_pc,
103507 +                                               LSTAT_ACT_NO_WAIT);
103508 +               } else {
103509 +                       uint32_t start_cycles = get_cycles();
103510 +                       _raw_spin_lock(lock_ptr);       /* do the real lock */
103511 +                       index = lstat_update_time(lock_ptr, this_pc,
103512 +                               LSTAT_ACT_SPIN, get_cycles() - start_cycles);
103513 +               }
103514 +               /* save the index in the lock itself for use in spin unlock */
103515 +               PUT_INDEX(lock_ptr, index);
103516 +       }
103517 +}
103518 +
103519 +int
103520 +_metered_spin_trylock(spinlock_t * lock_ptr)
103521 +{
103522 +       if (lstat_control.state == LSTAT_OFF) {
103523 +               return _raw_spin_trylock(lock_ptr);
103524 +       } else {
103525 +               int retval;
103526 +               void *this_pc = LSTAT_RA(LSTAT_RA_SPIN);
103527 +
103528 +               if ((retval = _raw_spin_trylock(lock_ptr))) {
103529 +                       int index = lstat_update(lock_ptr, this_pc,
103530 +                                               LSTAT_ACT_NO_WAIT);
103531 +                       /*
103532 +                        * save the index in the lock itself for use in spin
103533 +                        * unlock
103534 +                        */
103535 +                       PUT_INDEX(lock_ptr, index);
103536 +               } else {
103537 +                       lstat_update(lock_ptr, this_pc, LSTAT_ACT_REJECT);
103538 +               }
103539 +
103540 +               return retval;
103541 +       }
103542 +}
103543 +
103544 +void
103545 +_metered_spin_unlock(spinlock_t * lock_ptr)
103546 +{
103547 +       int index = -1;
103548 +
103549 +       if (lstat_control.state != LSTAT_OFF) {
103550 +               index = GET_INDEX(lock_ptr);
103551 +               /*
103552 +                * If statistics were turned off when we set the lock,
103553 +                * then the index can be zero.  If that is the case,
103554 +                * then collect no stats on this call.
103555 +                */
103556 +               if (index > 0) {
103557 +                       uint32_t hold_time;
103558 +                       int cpu = THIS_CPU_NUMBER;
103559 +                       hold_time = get_cycles() -
103560 +                        (*lstat_control.counts[cpu])[index].acquire_time;
103561 +                       (*lstat_control.counts[cpu])[index].cum_hold_ticks +=
103562 +                               (uint64_t) hold_time;
103563 +                       if ((*lstat_control.counts[cpu])[index].max_hold_ticks <
103564 +                           hold_time)
103565 +                               (*lstat_control.counts[cpu])[index].
103566 +                                   max_hold_ticks = hold_time;
103567 +               }
103568 +       }
103569 +
103570 +       /* make sure we don't have a stale index value saved */
103571 +       PUT_INDEX(lock_ptr, 0);
103572 +       _raw_spin_unlock(lock_ptr);     /* do the real unlock */
103573 +}
103574 +
103575 +/*
103576 + * allocate the next global read lock structure and store its index
103577 + * in the rwlock at "lock_ptr".
103578 + */
103579 +uint32_t
103580 +alloc_rwlock_struct(rwlock_t * rwlock_ptr)
103581 +{
103582 +       int index;
103583 +       unsigned long flags;
103584 +       int cpu = THIS_CPU_NUMBER;
103585 +
103586 +       /* If we've already overflowed, then do a quick exit */
103587 +       if (lstat_control.next_free_read_lock_index >
103588 +                       LSTAT_MAX_READ_LOCK_INDEX) {
103589 +               lstat_control.rwlock_overflow++;
103590 +               return 0;
103591 +       }
103592 +
103593 +       local_irq_save(flags);
103594 +       _raw_spin_lock(&lstat_control.directory_lock);
103595 +
103596 +       /* It is possible this changed while we were waiting for the directory_lock */
103597 +       if (lstat_control.state == LSTAT_OFF) {
103598 +               index = 0;
103599 +               goto unlock;
103600 +       }
103601 +
103602 +       /* It is possible someone else got here first and set the index */
103603 +       if ((index = GET_RWINDEX(rwlock_ptr)) == 0) {
103604 +               /*
103605 +                * we can't turn on read stats for this lock while there are
103606 +                * readers (this would mess up the running hold time sum at
103607 +                * unlock time)
103608 +                */
103609 +               if (RWLOCK_READERS(rwlock_ptr) != 0) {
103610 +                       index = 0;
103611 +                       goto unlock;
103612 +               }
103613 +
103614 +               /*
103615 +                * if stats are turned on after being off, we may need to
103616 +                * return an old index from when the statistics were on last
103617 +                * time.
103618 +                */
103619 +               for (index = 1; index < lstat_control.next_free_read_lock_index;
103620 +                               index++)
103621 +                       if ((*lstat_control.read_lock_counts[cpu])[index].
103622 +                                       lock_ptr == rwlock_ptr)
103623 +                               goto put_index_and_unlock;
103624 +
103625 +               /* allocate the next global read lock structure */
103626 +               if (lstat_control.next_free_read_lock_index >=
103627 +                   LSTAT_MAX_READ_LOCK_INDEX) {
103628 +                       lstat_control.rwlock_overflow++;
103629 +                       index = 0;
103630 +                       goto unlock;
103631 +               }
103632 +               index = lstat_control.next_free_read_lock_index++;
103633 +
103634 +               /*
103635 +                * initialize the global read stats data structure for each
103636 +                * cpu
103637 +                */
103638 +               for (cpu = 0; cpu < num_online_cpus(); cpu++) {
103639 +                       (*lstat_control.read_lock_counts[cpu])[index].lock_ptr =
103640 +                               rwlock_ptr;
103641 +               }
103642 +put_index_and_unlock:
103643 +               /* store the index for the read lock structure into the lock */
103644 +               PUT_RWINDEX(rwlock_ptr, index);
103645 +       }
103646 +
103647 +unlock:
103648 +       _raw_spin_unlock(&lstat_control.directory_lock);
103649 +       local_irq_restore(flags);
103650 +       return index;
103651 +}
103652 +
103653 +void
103654 +_metered_read_lock(rwlock_t * rwlock_ptr)
103655 +{
103656 +       void *this_pc;
103657 +       uint32_t start_cycles;
103658 +       int index;
103659 +       int cpu;
103660 +       unsigned long flags;
103661 +       int readers_before, readers_after;
103662 +       uint64_t cycles64;
103663 +
103664 +       if (lstat_control.state == LSTAT_OFF) {
103665 +               _raw_read_lock(rwlock_ptr);
103666 +               /* clean index in case lockmetering turns on before an unlock */
103667 +               PUT_RWINDEX(rwlock_ptr, 0);
103668 +               return;
103669 +       }
103670 +
103671 +       this_pc = LSTAT_RA(LSTAT_RA_READ);
103672 +       cpu = THIS_CPU_NUMBER;
103673 +       index = GET_RWINDEX(rwlock_ptr);
103674 +
103675 +       /* allocate the global stats entry for this lock, if needed */
103676 +       if (index == 0)
103677 +               index = alloc_rwlock_struct(rwlock_ptr);
103678 +
103679 +       readers_before = RWLOCK_READERS(rwlock_ptr);
103680 +       if (_raw_read_trylock(rwlock_ptr)) {
103681 +               /*
103682 +                * We have decremented the lock to count a new reader,
103683 +                * and have confirmed that no writer has it locked.
103684 +                */
103685 +               /* update statistics if enabled */
103686 +               if (index > 0) {
103687 +                       local_irq_save(flags);
103688 +                       lstat_update((void *) rwlock_ptr, this_pc,
103689 +                                       LSTAT_ACT_NO_WAIT);
103690 +                       /* preserve value of TSC so cum_hold_ticks and start_busy use same value */
103691 +                       cycles64 = get_cycles64();
103692 +                       (*lstat_control.read_lock_counts[cpu])[index].
103693 +                               cum_hold_ticks -= cycles64;
103694 +
103695 +                       /* record time and cpu of start of busy period */
103696 +                       /* this is not perfect (some race conditions are possible) */
103697 +                       if (readers_before == 0) {
103698 +                               (*lstat_control.read_lock_counts[cpu])[index].
103699 +                                       start_busy = cycles64;
103700 +                               PUT_RW_CPU(rwlock_ptr, cpu);
103701 +                       }
103702 +                       readers_after = RWLOCK_READERS(rwlock_ptr);
103703 +                       if (readers_after >
103704 +                               (*lstat_control.read_lock_counts[cpu])[index].
103705 +                                       max_readers)
103706 +                               (*lstat_control.read_lock_counts[cpu])[index].
103707 +                                       max_readers = readers_after;
103708 +                       local_irq_restore(flags);
103709 +               }
103710 +
103711 +               return;
103712 +       }
103713 +       /* If we get here, then we could not quickly grab the read lock */
103714 +
103715 +       start_cycles = get_cycles();    /* start counting the wait time */
103716 +
103717 +       /* Now spin until read_lock is successful */
103718 +       _raw_read_lock(rwlock_ptr);
103719 +
103720 +       lstat_update_time((void *) rwlock_ptr, this_pc, LSTAT_ACT_SPIN,
103721 +                         get_cycles() - start_cycles);
103722 +
103723 +       /* update statistics if they are enabled for this lock */
103724 +       if (index > 0) {
103725 +               local_irq_save(flags);
103726 +               cycles64 = get_cycles64();
103727 +               (*lstat_control.read_lock_counts[cpu])[index].cum_hold_ticks -=
103728 +                               cycles64;
103729 +
103730 +               /* this is not perfect (some race conditions are possible) */
103731 +               if (readers_before == 0) {
103732 +                       (*lstat_control.read_lock_counts[cpu])[index].
103733 +                               start_busy = cycles64;
103734 +                       PUT_RW_CPU(rwlock_ptr, cpu);
103735 +               }
103736 +               readers_after = RWLOCK_READERS(rwlock_ptr);
103737 +               if (readers_after >
103738 +                   (*lstat_control.read_lock_counts[cpu])[index].max_readers)
103739 +                       (*lstat_control.read_lock_counts[cpu])[index].
103740 +                               max_readers = readers_after;
103741 +               local_irq_restore(flags);
103742 +       }
103743 +}
103744 +
103745 +void
103746 +_metered_read_unlock(rwlock_t * rwlock_ptr)
103747 +{
103748 +       int index;
103749 +       int cpu;
103750 +       unsigned long flags;
103751 +       uint64_t busy_length;
103752 +       uint64_t cycles64;
103753 +
103754 +       if (lstat_control.state == LSTAT_OFF) {
103755 +               _raw_read_unlock(rwlock_ptr);
103756 +               return;
103757 +       }
103758 +
103759 +       index = GET_RWINDEX(rwlock_ptr);
103760 +       cpu = THIS_CPU_NUMBER;
103761 +
103762 +       if (index > 0) {
103763 +               local_irq_save(flags);
103764 +               /*
103765 +                * preserve value of TSC so cum_hold_ticks and busy_ticks are
103766 +                * consistent.
103767 +                */
103768 +               cycles64 = get_cycles64();
103769 +               (*lstat_control.read_lock_counts[cpu])[index].cum_hold_ticks +=
103770 +                       cycles64;
103771 +               (*lstat_control.read_lock_counts[cpu])[index].read_lock_count++;
103772 +
103773 +               /*
103774 +                * once again, this is not perfect (some race conditions are
103775 +                * possible)
103776 +                */
103777 +               if (RWLOCK_READERS(rwlock_ptr) == 1) {
103778 +                       int cpu1 = GET_RW_CPU(rwlock_ptr);
103779 +                       uint64_t last_start_busy =
103780 +                               (*lstat_control.read_lock_counts[cpu1])[index].
103781 +                                       start_busy;
103782 +                       (*lstat_control.read_lock_counts[cpu])[index].
103783 +                               busy_periods++;
103784 +                       if (cycles64 > last_start_busy) {
103785 +                               busy_length = cycles64 - last_start_busy;
103786 +                               (*lstat_control.read_lock_counts[cpu])[index].
103787 +                                       busy_ticks += busy_length;
103788 +                               if (busy_length >
103789 +                                       (*lstat_control.
103790 +                                               read_lock_counts[cpu])[index].
103791 +                                                       max_busy)
103792 +                                       (*lstat_control.
103793 +                                        read_lock_counts[cpu])[index].
103794 +                                               max_busy = busy_length;
103795 +                       }
103796 +               }
103797 +               local_irq_restore(flags);
103798 +       }
103799 +       _raw_read_unlock(rwlock_ptr);
103800 +}
103801 +
103802 +void
103803 +_metered_write_lock(rwlock_t * rwlock_ptr)
103804 +{
103805 +       uint32_t start_cycles;
103806 +       void *this_pc;
103807 +       uint32_t spin_ticks = 0; /* in anticipation of a potential wait */
103808 +       int index;
103809 +       int write_index = 0;
103810 +       int cpu;
103811 +       enum {
103812 +               writer_writer_conflict,
103813 +               writer_reader_conflict
103814 +       } why_wait = writer_writer_conflict;
103815 +
103816 +       if (lstat_control.state == LSTAT_OFF) {
103817 +               _raw_write_lock(rwlock_ptr);
103818 +               /* clean index in case lockmetering turns on before an unlock */
103819 +               PUT_RWINDEX(rwlock_ptr, 0);
103820 +               return;
103821 +       }
103822 +
103823 +       this_pc = LSTAT_RA(LSTAT_RA_WRITE);
103824 +       cpu = THIS_CPU_NUMBER;
103825 +       index = GET_RWINDEX(rwlock_ptr);
103826 +
103827 +       /* allocate the global stats entry for this lock, if needed */
103828 +       if (index == 0) {
103829 +               index = alloc_rwlock_struct(rwlock_ptr);
103830 +       }
103831 +
103832 +       if (_raw_write_trylock(rwlock_ptr)) {
103833 +               /* We acquired the lock on the first try */
103834 +               write_index = lstat_update((void *) rwlock_ptr, this_pc,
103835 +                                       LSTAT_ACT_NO_WAIT);
103836 +               /* save the write_index for use in unlock if stats enabled */
103837 +               if (index > 0)
103838 +                       (*lstat_control.read_lock_counts[cpu])[index].
103839 +                               write_index = write_index;
103840 +               return;
103841 +       }
103842 +
103843 +       /* If we get here, then we could not quickly grab the write lock */
103844 +       start_cycles = get_cycles();    /* start counting the wait time */
103845 +
103846 +       why_wait = RWLOCK_READERS(rwlock_ptr) ?
103847 +                       writer_reader_conflict : writer_writer_conflict;
103848 +
103849 +       /* Now set the lock and wait for conflicts to disappear */
103850 +       _raw_write_lock(rwlock_ptr);
103851 +
103852 +       spin_ticks = get_cycles() - start_cycles;
103853 +
103854 +       /* update stats -- if enabled */
103855 +       if (index > 0 && spin_ticks) {
103856 +               if (why_wait == writer_reader_conflict) {
103857 +                       /* waited due to a reader holding the lock */
103858 +                       write_index = lstat_update_time((void *)rwlock_ptr,
103859 +                                       this_pc, LSTAT_ACT_SPIN, spin_ticks);
103860 +               } else {
103861 +                       /*
103862 +                        * waited due to another writer holding the lock
103863 +                        */
103864 +                       write_index = lstat_update_time((void *)rwlock_ptr,
103865 +                               this_pc, LSTAT_ACT_WW_SPIN, spin_ticks);
103866 +                       (*lstat_control.counts[cpu])[write_index].
103867 +                               cum_wait_ww_ticks += spin_ticks;
103868 +                       if (spin_ticks >
103869 +                               (*lstat_control.counts[cpu])[write_index].
103870 +                                       max_wait_ww_ticks) {
103871 +                               (*lstat_control.counts[cpu])[write_index].
103872 +                                       max_wait_ww_ticks = spin_ticks;
103873 +                       }
103874 +               }
103875 +
103876 +               /* save the directory index for use on write_unlock */
103877 +               (*lstat_control.read_lock_counts[cpu])[index].
103878 +                       write_index = write_index;
103879 +       }
103880 +}
103881 +
103882 +void
103883 +_metered_write_unlock(rwlock_t * rwlock_ptr)
103884 +{
103885 +       int index;
103886 +       int cpu;
103887 +       int write_index;
103888 +       uint32_t hold_time;
103889 +
103890 +       if (lstat_control.state == LSTAT_OFF) {
103891 +               _raw_write_unlock(rwlock_ptr);
103892 +               return;
103893 +       }
103894 +
103895 +       cpu = THIS_CPU_NUMBER;
103896 +       index = GET_RWINDEX(rwlock_ptr);
103897 +
103898 +       /* update statistics if stats enabled for this lock */
103899 +       if (index > 0) {
103900 +               write_index =
103901 +                   (*lstat_control.read_lock_counts[cpu])[index].write_index;
103902 +
103903 +               hold_time = get_cycles() -
103904 +                       (*lstat_control.counts[cpu])[write_index].acquire_time;
103905 +               (*lstat_control.counts[cpu])[write_index].cum_hold_ticks +=
103906 +                       (uint64_t) hold_time;
103907 +               if ((*lstat_control.counts[cpu])[write_index].max_hold_ticks <
103908 +                               hold_time)
103909 +                       (*lstat_control.counts[cpu])[write_index].
103910 +                               max_hold_ticks = hold_time;
103911 +       }
103912 +       _raw_write_unlock(rwlock_ptr);
103913 +}
103914 +
103915 +int
103916 +_metered_write_trylock(rwlock_t * rwlock_ptr)
103917 +{
103918 +       int retval;
103919 +       void *this_pc = LSTAT_RA(LSTAT_RA_WRITE);
103920 +
103921 +       if ((retval = _raw_write_trylock(rwlock_ptr))) {
103922 +               lstat_update(rwlock_ptr, this_pc, LSTAT_ACT_NO_WAIT);
103923 +       } else {
103924 +               lstat_update(rwlock_ptr, this_pc, LSTAT_ACT_REJECT);
103925 +       }
103926 +
103927 +       return retval;
103928 +}
103929 +
103930 +static void
103931 +init_control_space(void)
103932 +{
103933 +       /* Set all control space pointers to null and indices to "empty" */
103934 +       int cpu;
103935 +
103936 +       /*
103937 +        * Access CPU_CYCLE_FREQUENCY at the outset, which in some
103938 +        * architectures may trigger a runtime calculation that uses a
103939 +        * spinlock.  Let's do this before lockmetering is turned on.
103940 +        */
103941 +       if (CPU_CYCLE_FREQUENCY == 0)
103942 +               BUG();
103943 +
103944 +       lstat_control.hashtab = NULL;
103945 +       lstat_control.dir = NULL;
103946 +       for (cpu = 0; cpu < NR_CPUS; cpu++) {
103947 +               lstat_control.counts[cpu] = NULL;
103948 +               lstat_control.read_lock_counts[cpu] = NULL;
103949 +       }
103950 +}
103951 +
103952 +static int
103953 +reset_lstat_data(void)
103954 +{
103955 +       int cpu, flags;
103956 +
103957 +       flags = 0;
103958 +       lstat_control.next_free_dir_index = 1;  /* 0 is for overflows */
103959 +       lstat_control.next_free_read_lock_index = 1;
103960 +       lstat_control.dir_overflow = 0;
103961 +       lstat_control.rwlock_overflow = 0;
103962 +
103963 +       lstat_control.started_cycles64 = 0;
103964 +       lstat_control.ending_cycles64 = 0;
103965 +       lstat_control.enabled_cycles64 = 0;
103966 +       lstat_control.first_started_time = 0;
103967 +       lstat_control.started_time = 0;
103968 +       lstat_control.ending_time = 0;
103969 +       lstat_control.intervals = 0;
103970 +
103971 +       /*
103972 +        * paranoia -- in case someone does a "lockstat reset" before
103973 +        * "lockstat on"
103974 +        */
103975 +       if (lstat_control.hashtab) {
103976 +               bzero(lstat_control.hashtab,
103977 +                       LSTAT_HASH_TABLE_SIZE * sizeof (short));
103978 +               bzero(lstat_control.dir, LSTAT_MAX_STAT_INDEX *
103979 +                               sizeof (lstat_directory_entry_t));
103980 +
103981 +               for (cpu = 0; cpu < num_online_cpus(); cpu++) {
103982 +                       bzero(lstat_control.counts[cpu],
103983 +                               sizeof (lstat_cpu_counts_t));
103984 +                       bzero(lstat_control.read_lock_counts[cpu],
103985 +                               sizeof (lstat_read_lock_cpu_counts_t));
103986 +               }
103987 +       }
103988 +#ifdef NOTDEF
103989 +       _raw_spin_unlock(&lstat_control.directory_lock);
103990 +       local_irq_restore(flags);
103991 +#endif
103992 +       return 1;
103993 +}
103994 +
103995 +static void
103996 +release_control_space(void)
103997 +{
103998 +       /*
103999 +        * Called when either (1) allocation of kmem
104000 +        * or (2) when user writes LSTAT_RELEASE to /pro/lockmeter.
104001 +        * Assume that all pointers have been initialized to zero,
104002 +        * i.e., nonzero pointers are valid addresses.
104003 +        */
104004 +       int cpu;
104005 +
104006 +       if (lstat_control.hashtab) {
104007 +               kfree(lstat_control.hashtab);
104008 +               lstat_control.hashtab = NULL;
104009 +       }
104010 +
104011 +       if (lstat_control.dir) {
104012 +               vfree(lstat_control.dir);
104013 +               lstat_control.dir = NULL;
104014 +       }
104015 +
104016 +       for (cpu = 0; cpu < NR_CPUS; cpu++) {
104017 +               if (lstat_control.counts[cpu]) {
104018 +                       vfree(lstat_control.counts[cpu]);
104019 +                       lstat_control.counts[cpu] = NULL;
104020 +               }
104021 +               if (lstat_control.read_lock_counts[cpu]) {
104022 +                       kfree(lstat_control.read_lock_counts[cpu]);
104023 +                       lstat_control.read_lock_counts[cpu] = NULL;
104024 +               }
104025 +       }
104026 +}
104027 +
104028 +int
104029 +get_lockmeter_info_size(void)
104030 +{
104031 +       return sizeof (lstat_user_request_t)
104032 +               + num_online_cpus() * sizeof (lstat_cpu_counts_t)
104033 +               + num_online_cpus() * sizeof (lstat_read_lock_cpu_counts_t)
104034 +               + (LSTAT_MAX_STAT_INDEX * sizeof (lstat_directory_entry_t));
104035 +}
104036 +
104037 +ssize_t
104038 +get_lockmeter_info(char *buffer, size_t max_len, loff_t * last_index)
104039 +{
104040 +       lstat_user_request_t req;
104041 +       struct timeval tv;
104042 +       ssize_t next_ret_bcount;
104043 +       ssize_t actual_ret_bcount = 0;
104044 +       int cpu;
104045 +
104046 +       *last_index = 0;        /* a one-shot read */
104047 +
104048 +       req.lstat_version = LSTAT_VERSION;
104049 +       req.state = lstat_control.state;
104050 +       req.maxcpus = num_online_cpus();
104051 +       req.cycleval = CPU_CYCLE_FREQUENCY;
104052 +#ifdef notyet
104053 +       req.kernel_magic_addr = (void *) &_etext;
104054 +       req.kernel_end_addr = (void *) &_etext;
104055 +#endif
104056 +       req.uts = system_utsname;
104057 +       req.intervals = lstat_control.intervals;
104058 +
104059 +       req.first_started_time = lstat_control.first_started_time;
104060 +       req.started_time = lstat_control.started_time;
104061 +       req.started_cycles64 = lstat_control.started_cycles64;
104062 +
104063 +       req.next_free_dir_index = lstat_control.next_free_dir_index;
104064 +       req.next_free_read_lock_index = lstat_control.next_free_read_lock_index;
104065 +       req.dir_overflow = lstat_control.dir_overflow;
104066 +       req.rwlock_overflow = lstat_control.rwlock_overflow;
104067 +
104068 +       if (lstat_control.state == LSTAT_OFF) {
104069 +               if (req.intervals == 0) {
104070 +                       /* mesasurement is off and no valid data present */
104071 +                       next_ret_bcount = sizeof (lstat_user_request_t);
104072 +                       req.enabled_cycles64 = 0;
104073 +
104074 +                       if ((actual_ret_bcount + next_ret_bcount) > max_len)
104075 +                               return actual_ret_bcount;
104076 +
104077 +                       copy_to_user(buffer, (void *) &req, next_ret_bcount);
104078 +                       actual_ret_bcount += next_ret_bcount;
104079 +                       return actual_ret_bcount;
104080 +               } else {
104081 +                       /*
104082 +                        * measurement is off but valid data present
104083 +                        * fetch time info from lstat_control
104084 +                        */
104085 +                       req.ending_time = lstat_control.ending_time;
104086 +                       req.ending_cycles64 = lstat_control.ending_cycles64;
104087 +                       req.enabled_cycles64 = lstat_control.enabled_cycles64;
104088 +               }
104089 +       } else {
104090 +               /*
104091 +                * this must be a read while data active--use current time,
104092 +                * etc
104093 +                */
104094 +               do_gettimeofday(&tv);
104095 +               req.ending_time = tv.tv_sec;
104096 +               req.ending_cycles64 = get_cycles64();
104097 +               req.enabled_cycles64 = req.ending_cycles64 -
104098 +                       req.started_cycles64 + lstat_control.enabled_cycles64;
104099 +       }
104100 +
104101 +       next_ret_bcount = sizeof (lstat_user_request_t);
104102 +       if ((actual_ret_bcount + next_ret_bcount) > max_len)
104103 +               return actual_ret_bcount;
104104 +
104105 +       copy_to_user(buffer, (void *) &req, next_ret_bcount);
104106 +       actual_ret_bcount += next_ret_bcount;
104107 +
104108 +       if (!lstat_control.counts[0])   /* not initialized? */
104109 +               return actual_ret_bcount;
104110 +
104111 +       next_ret_bcount = sizeof (lstat_cpu_counts_t);
104112 +       for (cpu = 0; cpu < num_online_cpus(); cpu++) {
104113 +               if ((actual_ret_bcount + next_ret_bcount) > max_len)
104114 +                       return actual_ret_bcount;       /* leave early */
104115 +               copy_to_user(buffer + actual_ret_bcount,
104116 +                               lstat_control.counts[cpu], next_ret_bcount);
104117 +               actual_ret_bcount += next_ret_bcount;
104118 +       }
104119 +
104120 +       next_ret_bcount = LSTAT_MAX_STAT_INDEX *
104121 +                       sizeof (lstat_directory_entry_t);
104122 +       if (((actual_ret_bcount + next_ret_bcount) > max_len)
104123 +                       || !lstat_control.dir)
104124 +               return actual_ret_bcount;       /* leave early */
104125 +
104126 +       copy_to_user(buffer + actual_ret_bcount, lstat_control.dir,
104127 +                       next_ret_bcount);
104128 +       actual_ret_bcount += next_ret_bcount;
104129 +
104130 +       next_ret_bcount = sizeof (lstat_read_lock_cpu_counts_t);
104131 +       for (cpu = 0; cpu < num_online_cpus(); cpu++) {
104132 +               if (actual_ret_bcount + next_ret_bcount > max_len)
104133 +                       return actual_ret_bcount;
104134 +               copy_to_user(buffer + actual_ret_bcount,
104135 +                               lstat_control.read_lock_counts[cpu],
104136 +                               next_ret_bcount);
104137 +               actual_ret_bcount += next_ret_bcount;
104138 +       }
104139 +
104140 +       return actual_ret_bcount;
104141 +}
104142 +
104143 +/*
104144 + *  Writing to the /proc lockmeter node enables or disables metering.
104145 + *  based upon the first byte of the "written" data.
104146 + *  The following values are defined:
104147 + *  LSTAT_ON: 1st call: allocates storage, intializes and turns on measurement
104148 + *            subsequent calls just turn on measurement
104149 + *  LSTAT_OFF: turns off measurement
104150 + *  LSTAT_RESET: resets statistics
104151 + *  LSTAT_RELEASE: releases statistics storage
104152 + *
104153 + *  This allows one to accumulate statistics over several lockstat runs:
104154 + *
104155 + *  lockstat on
104156 + *  lockstat off
104157 + *  ...repeat above as desired...
104158 + *  lockstat get
104159 + *  ...now start a new set of measurements...
104160 + *  lockstat reset
104161 + *  lockstat on
104162 + *  ...
104163 + *
104164 + */
104165 +ssize_t
104166 +put_lockmeter_info(const char *buffer, size_t len)
104167 +{
104168 +       int error = 0;
104169 +       int dirsize, countsize, read_lock_countsize, hashsize;
104170 +       int cpu;
104171 +       char put_char;
104172 +       int i, read_lock_blocks;
104173 +       unsigned long flags;
104174 +       rwlock_t *lock_ptr;
104175 +       struct timeval tv;
104176 +
104177 +       if (len <= 0)
104178 +               return -EINVAL;
104179 +
104180 +       _raw_spin_lock(&lstat_control.control_lock);
104181 +
104182 +       get_user(put_char, buffer);
104183 +       switch (put_char) {
104184 +
104185 +       case LSTAT_OFF:
104186 +               if (lstat_control.state != LSTAT_OFF) {
104187 +                       /*
104188 +                        * To avoid seeing read lock hold times in an
104189 +                        * inconsisent state, we have to follow this protocol
104190 +                        * to turn off statistics
104191 +                        */
104192 +                       local_irq_save(flags);
104193 +                       /*
104194 +                        * getting this lock will stop any read lock block
104195 +                        * allocations
104196 +                        */
104197 +                       _raw_spin_lock(&lstat_control.directory_lock);
104198 +                       /*
104199 +                        * keep any more read lock blocks from being
104200 +                        * allocated
104201 +                        */
104202 +                       lstat_control.state = LSTAT_OFF;
104203 +                       /* record how may read lock blocks there are */
104204 +                       read_lock_blocks =
104205 +                               lstat_control.next_free_read_lock_index;
104206 +                       _raw_spin_unlock(&lstat_control.directory_lock);
104207 +                       /* now go through the list of read locks */
104208 +                       cpu = THIS_CPU_NUMBER;
104209 +                       for (i = 1; i < read_lock_blocks; i++) {
104210 +                               lock_ptr =
104211 +                                   (*lstat_control.read_lock_counts[cpu])[i].
104212 +                                   lock_ptr;
104213 +                               /* is this saved lock address still valid? */
104214 +                               if (GET_RWINDEX(lock_ptr) == i) {
104215 +                                       /*
104216 +                                        * lock address appears to still be
104217 +                                        * valid because we only hold one lock
104218 +                                        * at a time, this can't cause a
104219 +                                        * deadlock unless this is a lock held
104220 +                                        * as part of the current system call
104221 +                                        * path. At the moment there
104222 +                                        * are no READ mode locks held to get
104223 +                                        * here from user space, so we solve
104224 +                                        * this by skipping locks held in
104225 +                                        * write mode.
104226 +                                        */
104227 +                                       if (RWLOCK_IS_WRITE_LOCKED(lock_ptr)) {
104228 +                                               PUT_RWINDEX(lock_ptr, 0);
104229 +                                               continue;
104230 +                                       }
104231 +                                       /*
104232 +                                        * now we know there are no read
104233 +                                        * holders of this lock! stop
104234 +                                        * statistics collection for this
104235 +                                        * lock
104236 +                                        */
104237 +                                       _raw_write_lock(lock_ptr);
104238 +                                       PUT_RWINDEX(lock_ptr, 0);
104239 +                                       _raw_write_unlock(lock_ptr);
104240 +                               }
104241 +                               /*
104242 +                                * it may still be possible for the hold time
104243 +                                * sum to be negative e.g. if a lock is
104244 +                                * reallocated while "busy" we will have to fix
104245 +                                * this up in the data reduction program.
104246 +                                */
104247 +                       }
104248 +                       local_irq_restore(flags);
104249 +                       lstat_control.intervals++;
104250 +                       lstat_control.ending_cycles64 = get_cycles64();
104251 +                       lstat_control.enabled_cycles64 +=
104252 +                               lstat_control.ending_cycles64 -
104253 +                               lstat_control.started_cycles64;
104254 +                       do_gettimeofday(&tv);
104255 +                       lstat_control.ending_time = tv.tv_sec;
104256 +                       /*
104257 +                        * don't deallocate the structures -- we may do a
104258 +                        * lockstat on to add to the data that is already
104259 +                        * there. Use LSTAT_RELEASE to release storage
104260 +                        */
104261 +               } else {
104262 +                       error = -EBUSY; /* already OFF */
104263 +               }
104264 +               break;
104265 +
104266 +       case LSTAT_ON:
104267 +               if (lstat_control.state == LSTAT_OFF) {
104268 +#ifdef DEBUG_LOCKMETER
104269 +                       printk("put_lockmeter_info(cpu=%d): LSTAT_ON\n",
104270 +                               THIS_CPU_NUMBER);
104271 +#endif
104272 +                       lstat_control.next_free_dir_index = 1;  /* 0 is for overflows */
104273 +
104274 +                       dirsize = LSTAT_MAX_STAT_INDEX *
104275 +                                       sizeof (lstat_directory_entry_t);
104276 +                       hashsize =
104277 +                               (1 + LSTAT_HASH_TABLE_SIZE) * sizeof (ushort);
104278 +                       countsize = sizeof (lstat_cpu_counts_t);
104279 +                       read_lock_countsize =
104280 +                               sizeof (lstat_read_lock_cpu_counts_t);
104281 +#ifdef DEBUG_LOCKMETER
104282 +                       printk(" dirsize:%d", dirsize);
104283 +                       printk(" hashsize:%d", hashsize);
104284 +                       printk(" countsize:%d", countsize);
104285 +                       printk(" read_lock_countsize:%d\n",
104286 +                               read_lock_countsize);
104287 +#endif
104288 +#ifdef DEBUG_LOCKMETER
104289 +                       {
104290 +                               int secs;
104291 +                               unsigned long cycles;
104292 +                               uint64_t cycles64;
104293 +
104294 +                               do_gettimeofday(&tv);
104295 +                               secs = tv.tv_sec;
104296 +                               do {
104297 +                                       do_gettimeofday(&tv);
104298 +                               } while (secs == tv.tv_sec);
104299 +                               cycles = get_cycles();
104300 +                               cycles64 = get_cycles64();
104301 +                               secs = tv.tv_sec;
104302 +                               do {
104303 +                                       do_gettimeofday(&tv);
104304 +                               } while (secs == tv.tv_sec);
104305 +                               cycles = get_cycles() - cycles;
104306 +                               cycles64 = get_cycles64() - cycles;
104307 +                               printk("lockmeter: cycleFrequency:%d "
104308 +                                       "cycles:%d cycles64:%d\n",
104309 +                                       CPU_CYCLE_FREQUENCY, cycles, cycles64);
104310 +                       }
104311 +#endif
104312 +
104313 +                       /*
104314 +                        * if this is the first call, allocate storage and
104315 +                        * initialize
104316 +                        */
104317 +                       if (!lstat_control.hashtab) {
104318 +
104319 +                               spin_lock_init(&lstat_control.directory_lock);
104320 +
104321 +                               /* guarantee all pointers at zero */
104322 +                               init_control_space();
104323 +
104324 +                               lstat_control.hashtab =
104325 +                                   kmalloc(hashsize, GFP_KERNEL);
104326 +                               if (!lstat_control.hashtab) {
104327 +                                       error = -ENOSPC;
104328 +#ifdef DEBUG_LOCKMETER
104329 +                                       printk("!!error kmalloc of hashtab\n");
104330 +#endif
104331 +                               }
104332 +                               lstat_control.dir = vmalloc(dirsize);
104333 +                               if (!lstat_control.dir) {
104334 +                                       error = -ENOSPC;
104335 +#ifdef DEBUG_LOCKMETER
104336 +                                       printk("!!error kmalloc of dir\n");
104337 +#endif
104338 +                               }
104339 +
104340 +                               for (cpu = 0; cpu < num_online_cpus(); cpu++) {
104341 +                                       lstat_control.counts[cpu] =
104342 +                                               vmalloc(countsize);
104343 +                                       if (!lstat_control.counts[cpu]) {
104344 +                                               error = -ENOSPC;
104345 +#ifdef DEBUG_LOCKMETER
104346 +                                               printk("!!error vmalloc of "
104347 +                                                       "counts[%d]\n", cpu);
104348 +#endif
104349 +                                       }
104350 +                                       lstat_control.read_lock_counts[cpu] =
104351 +                                               (lstat_read_lock_cpu_counts_t *)
104352 +                                               kmalloc(read_lock_countsize,
104353 +                                                       GFP_KERNEL);
104354 +                                       if (!lstat_control.
104355 +                                                       read_lock_counts[cpu]) {
104356 +                                               error = -ENOSPC;
104357 +#ifdef DEBUG_LOCKMETER
104358 +                                               printk("!!error kmalloc of "
104359 +                                                 "read_lock_counts[%d]\n",
104360 +                                                       cpu);
104361 +#endif
104362 +                                       }
104363 +                               }
104364 +                       }
104365 +
104366 +                       if (error) {
104367 +                               /*
104368 +                                * One or more kmalloc failures -- free
104369 +                                * everything
104370 +                                */
104371 +                               release_control_space();
104372 +                       } else {
104373 +
104374 +                               if (!reset_lstat_data()) {
104375 +                                       error = -EINVAL;
104376 +                                       break;
104377 +                               };
104378 +
104379 +                               /*
104380 +                                * record starting and ending times and the
104381 +                                * like
104382 +                                */
104383 +                               if (lstat_control.intervals == 0) {
104384 +                                       do_gettimeofday(&tv);
104385 +                                       lstat_control.first_started_time =
104386 +                                               tv.tv_sec;
104387 +                               }
104388 +                               lstat_control.started_cycles64 = get_cycles64();
104389 +                               do_gettimeofday(&tv);
104390 +                               lstat_control.started_time = tv.tv_sec;
104391 +
104392 +                               lstat_control.state = LSTAT_ON;
104393 +                       }
104394 +               } else {
104395 +                       error = -EBUSY; /* already ON */
104396 +               }
104397 +               break;
104398 +
104399 +       case LSTAT_RESET:
104400 +               if (lstat_control.state == LSTAT_OFF) {
104401 +                       if (!reset_lstat_data())
104402 +                               error = -EINVAL;
104403 +               } else {
104404 +                       error = -EBUSY; /* still on; can't reset */
104405 +               }
104406 +               break;
104407 +
104408 +       case LSTAT_RELEASE:
104409 +               if (lstat_control.state == LSTAT_OFF) {
104410 +                       release_control_space();
104411 +                       lstat_control.intervals = 0;
104412 +                       lstat_control.enabled_cycles64 = 0;
104413 +               } else {
104414 +                       error = -EBUSY;
104415 +               }
104416 +               break;
104417 +
104418 +       default:
104419 +               error = -EINVAL;
104420 +       }                       /* switch */
104421 +
104422 +       _raw_spin_unlock(&lstat_control.control_lock);
104423 +       return error ? error : len;
104424 +}
104425 +
104426 +#ifdef USER_MODE_TESTING
104427 +/* following used for user mode testing */
104428 +void
104429 +lockmeter_init()
104430 +{
104431 +       int dirsize, hashsize, countsize, read_lock_countsize, cpu;
104432 +
104433 +       printf("lstat_control is at %x size=%d\n", &lstat_control,
104434 +               sizeof (lstat_control));
104435 +       printf("sizeof(spinlock_t)=%d\n", sizeof (spinlock_t));
104436 +       lstat_control.state = LSTAT_ON;
104437 +
104438 +       lstat_control.directory_lock = SPIN_LOCK_UNLOCKED;
104439 +       lstat_control.next_free_dir_index = 1;  /* 0 is for overflows */
104440 +       lstat_control.next_free_read_lock_index = 1;
104441 +
104442 +       dirsize = LSTAT_MAX_STAT_INDEX * sizeof (lstat_directory_entry_t);
104443 +       hashsize = (1 + LSTAT_HASH_TABLE_SIZE) * sizeof (ushort);
104444 +       countsize = sizeof (lstat_cpu_counts_t);
104445 +       read_lock_countsize = sizeof (lstat_read_lock_cpu_counts_t);
104446 +
104447 +       lstat_control.hashtab = (ushort *) malloc(hashsize);
104448 +
104449 +       if (lstat_control.hashtab == 0) {
104450 +               printf("malloc failure for at line %d in lockmeter.c\n",
104451 +                       __LINE__);
104452 +               exit(0);
104453 +       }
104454 +
104455 +       lstat_control.dir = (lstat_directory_entry_t *) malloc(dirsize);
104456 +
104457 +       if (lstat_control.dir == 0) {
104458 +               printf("malloc failure for at line %d in lockmeter.c\n", cpu,
104459 +                       __LINE__);
104460 +               exit(0);
104461 +       }
104462 +
104463 +       for (cpu = 0; cpu < num_online_cpus(); cpu++) {
104464 +               int j, k;
104465 +               j = (int) (lstat_control.counts[cpu] =
104466 +                          (lstat_cpu_counts_t *) malloc(countsize));
104467 +               k = (int) (lstat_control.read_lock_counts[cpu] =
104468 +                          (lstat_read_lock_cpu_counts_t *)
104469 +                          malloc(read_lock_countsize));
104470 +               if (j * k == 0) {
104471 +                       printf("malloc failure for cpu=%d at line %d in "
104472 +                               "lockmeter.c\n", cpu, __LINE__);
104473 +                       exit(0);
104474 +               }
104475 +       }
104476 +
104477 +       memset(lstat_control.hashtab, 0, hashsize);
104478 +       memset(lstat_control.dir, 0, dirsize);
104479 +
104480 +       for (cpu = 0; cpu < num_online_cpus(); cpu++) {
104481 +               memset(lstat_control.counts[cpu], 0, countsize);
104482 +               memset(lstat_control.read_lock_counts[cpu], 0,
104483 +                       read_lock_countsize);
104484 +       }
104485 +}
104486 +
104487 +asm(" \
104488 +.align 4 \
104489 +.globl __write_lock_failed \
104490 +__write_lock_failed: \
104491 +       " LOCK "addl    $" RW_LOCK_BIAS_STR ",(%eax) \
104492 +1:     cmpl    $" RW_LOCK_BIAS_STR ",(%eax) \
104493 +       jne     1b \
104494 +\
104495 +       " LOCK "subl    $" RW_LOCK_BIAS_STR ",(%eax) \
104496 +       jnz     __write_lock_failed \
104497 +       ret \
104498 +\
104499 +\
104500 +.align 4 \
104501 +.globl __read_lock_failed \
104502 +__read_lock_failed: \
104503 +       lock ; incl     (%eax) \
104504 +1:     cmpl    $1,(%eax) \
104505 +       js      1b \
104506 +\
104507 +       lock ; decl     (%eax) \
104508 +       js      __read_lock_failed \
104509 +       ret \
104510 +");
104511 +#endif
104512 --- linux-2.6.0-test6/kernel/Makefile   2003-09-27 18:57:47.000000000 -0700
104513 +++ 25/kernel/Makefile  2003-10-05 00:36:40.000000000 -0700
104514 @@ -11,6 +11,7 @@ obj-y     = sched.o fork.o exec_domain.o
104515  obj-$(CONFIG_FUTEX) += futex.o
104516  obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
104517  obj-$(CONFIG_SMP) += cpu.o
104518 +obj-$(CONFIG_LOCKMETER) += lockmeter.o
104519  obj-$(CONFIG_UID16) += uid16.o
104520  obj-$(CONFIG_MODULES) += ksyms.o module.o
104521  obj-$(CONFIG_KALLSYMS) += kallsyms.o
104522 --- linux-2.6.0-test6/kernel/module.c   2003-09-08 13:58:59.000000000 -0700
104523 +++ 25/kernel/module.c  2003-10-05 00:33:25.000000000 -0700
104524 @@ -844,6 +844,7 @@ int set_obsolete(const char *val, struct
104525  {
104526         unsigned int min, max;
104527         unsigned int size, maxsize;
104528 +       int dummy;
104529         char *endp;
104530         const char *p;
104531         struct obsolete_modparm *obsparm = kp->arg;
104532 @@ -866,19 +867,19 @@ int set_obsolete(const char *val, struct
104533         switch (*endp) {
104534         case 'b':
104535                 return param_array(kp->name, val, min, max, obsparm->addr,
104536 -                                  1, param_set_byte);
104537 +                                  1, param_set_byte, &dummy);
104538         case 'h':
104539                 return param_array(kp->name, val, min, max, obsparm->addr,
104540 -                                  sizeof(short), param_set_short);
104541 +                                  sizeof(short), param_set_short, &dummy);
104542         case 'i':
104543                 return param_array(kp->name, val, min, max, obsparm->addr,
104544 -                                  sizeof(int), param_set_int);
104545 +                                  sizeof(int), param_set_int, &dummy);
104546         case 'l':
104547                 return param_array(kp->name, val, min, max, obsparm->addr,
104548 -                                  sizeof(long), param_set_long);
104549 +                                  sizeof(long), param_set_long, &dummy);
104550         case 's':
104551                 return param_array(kp->name, val, min, max, obsparm->addr,
104552 -                                  sizeof(char *), param_set_charp);
104553 +                                  sizeof(char *), param_set_charp, &dummy);
104554  
104555         case 'c':
104556                 /* Undocumented: 1-5c50 means 1-5 strings of up to 49 chars,
104557 @@ -895,7 +896,7 @@ int set_obsolete(const char *val, struct
104558                 if (size >= maxsize) 
104559                         goto oversize;
104560                 return param_array(kp->name, val, min, max, obsparm->addr,
104561 -                                  maxsize, obsparm_copy_string);
104562 +                                  maxsize, obsparm_copy_string, &dummy);
104563         }
104564         printk(KERN_ERR "Unknown obsolete parameter type %s\n", obsparm->type);
104565         return -EINVAL;
104566 --- linux-2.6.0-test6/kernel/params.c   2003-08-22 19:23:42.000000000 -0700
104567 +++ 25/kernel/params.c  2003-10-05 00:33:25.000000000 -0700
104568 @@ -242,10 +242,10 @@ int param_array(const char *name,
104569                 const char *val,
104570                 unsigned int min, unsigned int max,
104571                 void *elem, int elemsize,
104572 -               int (*set)(const char *, struct kernel_param *kp))
104573 +               int (*set)(const char *, struct kernel_param *kp),
104574 +               int *num)
104575  {
104576         int ret;
104577 -       unsigned int count = 0;
104578         struct kernel_param kp;
104579         char save;
104580  
104581 @@ -259,11 +259,12 @@ int param_array(const char *name,
104582                 return -EINVAL;
104583         }
104584  
104585 +       *num = 0;
104586         /* We expect a comma-separated list of values. */
104587         do {
104588                 int len;
104589  
104590 -               if (count > max) {
104591 +               if (*num == max) {
104592                         printk(KERN_ERR "%s: can only take %i arguments\n",
104593                                name, max);
104594                         return -EINVAL;
104595 @@ -279,10 +280,10 @@ int param_array(const char *name,
104596                         return ret;
104597                 kp.arg += elemsize;
104598                 val += len+1;
104599 -               count++;
104600 +               (*num)++;
104601         } while (save == ',');
104602  
104603 -       if (count < min) {
104604 +       if (*num < min) {
104605                 printk(KERN_ERR "%s: needs at least %i arguments\n",
104606                        name, min);
104607                 return -EINVAL;
104608 @@ -290,29 +291,32 @@ int param_array(const char *name,
104609         return 0;
104610  }
104611  
104612 -/* First two elements are the max and min array length (which don't change) */
104613 -int param_set_intarray(const char *val, struct kernel_param *kp)
104614 +int param_array_set(const char *val, struct kernel_param *kp)
104615  {
104616 -       int *array;
104617 +       struct kparam_array *arr = kp->arg;
104618  
104619 -       /* Grab min and max as first two elements */
104620 -       array = kp->arg;
104621 -       return param_array(kp->name, val, array[0], array[1], &array[2],
104622 -                          sizeof(int), param_set_int);
104623 +       return param_array(kp->name, val, 1, arr->max, arr->elem,
104624 +                          arr->elemsize, arr->set, arr->num);
104625  }
104626  
104627 -int param_get_intarray(char *buffer, struct kernel_param *kp)
104628 +int param_array_get(char *buffer, struct kernel_param *kp)
104629  {
104630 -       int max;
104631 -       int *array;
104632 -       unsigned int i;
104633 -
104634 -       array = kp->arg;
104635 -       max = array[1];
104636 -
104637 -       for (i = 2; i < max + 2; i++)
104638 -               sprintf(buffer, "%s%i", i > 2 ? "," : "", array[i]);
104639 -       return strlen(buffer);
104640 +       int i, off, ret;
104641 +       struct kparam_array *arr = kp->arg;
104642 +       struct kernel_param p;
104643 +
104644 +       p = *kp;
104645 +       for (i = off = 0; i < *arr->num; i++) {
104646 +               if (i)
104647 +                       buffer[off++] = ',';
104648 +               p.arg = arr->elem + arr->elemsize * i;
104649 +               ret = arr->get(buffer + off, &p);
104650 +               if (ret < 0)
104651 +                       return ret;
104652 +               off += ret;
104653 +       }
104654 +       buffer[off] = '\0';
104655 +       return off;
104656  }
104657  
104658  int param_set_copystring(const char *val, struct kernel_param *kp)
104659 @@ -346,6 +350,6 @@ EXPORT_SYMBOL(param_set_bool);
104660  EXPORT_SYMBOL(param_get_bool);
104661  EXPORT_SYMBOL(param_set_invbool);
104662  EXPORT_SYMBOL(param_get_invbool);
104663 -EXPORT_SYMBOL(param_set_intarray);
104664 -EXPORT_SYMBOL(param_get_intarray);
104665 +EXPORT_SYMBOL(param_array_set);
104666 +EXPORT_SYMBOL(param_array_get);
104667  EXPORT_SYMBOL(param_set_copystring);
104668 --- linux-2.6.0-test6/kernel/pid.c      2003-09-27 18:57:47.000000000 -0700
104669 +++ 25/kernel/pid.c     2003-10-05 00:36:15.000000000 -0700
104670 @@ -250,14 +250,14 @@ void switch_exec_pids(task_t *leader, ta
104671  
104672         attach_pid(thread, PIDTYPE_PID, thread->pid);
104673         attach_pid(thread, PIDTYPE_TGID, thread->tgid);
104674 -       attach_pid(thread, PIDTYPE_PGID, leader->__pgrp);
104675 -       attach_pid(thread, PIDTYPE_SID, thread->session);
104676 +       attach_pid(thread, PIDTYPE_PGID, thread->signal->pgrp);
104677 +       attach_pid(thread, PIDTYPE_SID, thread->signal->session);
104678         list_add_tail(&thread->tasks, &init_task.tasks);
104679  
104680         attach_pid(leader, PIDTYPE_PID, leader->pid);
104681         attach_pid(leader, PIDTYPE_TGID, leader->tgid);
104682 -       attach_pid(leader, PIDTYPE_PGID, leader->__pgrp);
104683 -       attach_pid(leader, PIDTYPE_SID, leader->session);
104684 +       attach_pid(leader, PIDTYPE_PGID, leader->signal->pgrp);
104685 +       attach_pid(leader, PIDTYPE_SID, leader->signal->session);
104686  }
104687  
104688  /*
104689 @@ -265,6 +265,9 @@ void switch_exec_pids(task_t *leader, ta
104690   * machine.  From a minimum of 16 slots up to 4096 slots at one gigabyte or
104691   * more.
104692   */
104693 +#ifdef CONFIG_KGDB
104694 +int kgdb_pid_init_done; /* so we don't call prior to... */
104695 +#endif
104696  void __init pidhash_init(void)
104697  {
104698         int i, j, pidhash_size;
104699 @@ -286,6 +289,9 @@ void __init pidhash_init(void)
104700                 for (j = 0; j < pidhash_size; j++)
104701                         INIT_LIST_HEAD(&pid_hash[i][j]);
104702         }
104703 +#ifdef CONFIG_KGDB
104704 +       kgdb_pid_init_done++;
104705 +#endif
104706  }
104707  
104708  void __init pidmap_init(void)
104709 --- linux-2.6.0-test6/kernel/printk.c   2003-07-02 14:53:18.000000000 -0700
104710 +++ 25/kernel/printk.c  2003-10-05 00:36:41.000000000 -0700
104711 @@ -29,11 +29,11 @@
104712  #include <linux/delay.h>
104713  #include <linux/smp.h>
104714  #include <linux/security.h>
104715 +#include <linux/bootmem.h>
104716  
104717  #include <asm/uaccess.h>
104718  
104719 -#define LOG_BUF_LEN    (1 << CONFIG_LOG_BUF_SHIFT)
104720 -#define LOG_BUF_MASK   (LOG_BUF_LEN-1)
104721 +#define __LOG_BUF_LEN  (1 << CONFIG_LOG_BUF_SHIFT)
104722  
104723  /* printk's without a loglevel use this.. */
104724  #define DEFAULT_MESSAGE_LOGLEVEL 4 /* KERN_WARNING */
104725 @@ -68,17 +68,21 @@ struct console *console_drivers;
104726   */
104727  static spinlock_t logbuf_lock = SPIN_LOCK_UNLOCKED;
104728  
104729 -static char log_buf[LOG_BUF_LEN];
104730 +static char __log_buf[__LOG_BUF_LEN];
104731 +static char *log_buf = __log_buf;
104732 +static int log_buf_len = __LOG_BUF_LEN;
104733 +
104734 +#define LOG_BUF_MASK   (log_buf_len-1)
104735  #define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK])
104736  
104737  /*
104738 - * The indices into log_buf are not constrained to LOG_BUF_LEN - they
104739 + * The indices into log_buf are not constrained to log_buf_len - they
104740   * must be masked before subscripting
104741   */
104742 -static unsigned long log_start;                        /* Index into log_buf: next char to be read by syslog() */
104743 -static unsigned long con_start;                        /* Index into log_buf: next char to be sent to consoles */
104744 -static unsigned long log_end;                  /* Index into log_buf: most-recently-written-char + 1 */
104745 -static unsigned long logged_chars;             /* Number of chars produced since last read+clear operation */
104746 +static unsigned long log_start;        /* Index into log_buf: next char to be read by syslog() */
104747 +static unsigned long con_start;        /* Index into log_buf: next char to be sent to consoles */
104748 +static unsigned long log_end;  /* Index into log_buf: most-recently-written-char + 1 */
104749 +static unsigned long logged_chars; /* Number of chars produced since last read+clear operation */
104750  
104751  struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];
104752  static int preferred_console = -1;
104753 @@ -141,6 +145,45 @@ static int __init console_setup(char *st
104754  
104755  __setup("console=", console_setup);
104756  
104757 +static int __init log_buf_len_setup(char *str)
104758 +{
104759 +       unsigned long size = memparse(str, &str);
104760 +
104761 +       if (size > log_buf_len) {
104762 +               unsigned long start, dest_idx, offset;
104763 +               char * new_log_buf;
104764 +
104765 +               new_log_buf = alloc_bootmem(size);
104766 +               if (!new_log_buf) {
104767 +                       printk("log_buf_len: allocation failed\n");
104768 +                       goto out;
104769 +               }
104770 +
104771 +               spin_lock_irq(&logbuf_lock);
104772 +               log_buf_len = size;
104773 +               log_buf = new_log_buf;
104774 +
104775 +               offset = start = min(con_start, log_start);
104776 +               dest_idx = 0;
104777 +               while (start != log_end) {
104778 +                       log_buf[dest_idx] = __log_buf[start & (__LOG_BUF_LEN - 1)];
104779 +                       start++;
104780 +                       dest_idx++;
104781 +               }
104782 +               log_start -= offset;
104783 +               con_start -= offset;
104784 +               log_end -= offset;
104785 +               spin_unlock_irq(&logbuf_lock);
104786 +
104787 +               printk("log_buf_len: %d\n", log_buf_len);
104788 +       }
104789 +out:
104790 +
104791 +       return 1;
104792 +}
104793 +
104794 +__setup("log_buf_len=", log_buf_len_setup);
104795 +
104796  /*
104797   * Commands to do_syslog:
104798   *
104799 @@ -213,8 +256,8 @@ int do_syslog(int type, char __user * bu
104800                 if (error)
104801                         goto out;
104802                 count = len;
104803 -               if (count > LOG_BUF_LEN)
104804 -                       count = LOG_BUF_LEN;
104805 +               if (count > log_buf_len)
104806 +                       count = log_buf_len;
104807                 spin_lock_irq(&logbuf_lock);
104808                 if (count > logged_chars)
104809                         count = logged_chars;
104810 @@ -229,7 +272,7 @@ int do_syslog(int type, char __user * bu
104811                  */
104812                 for(i = 0; i < count && !error; i++) {
104813                         j = limit-1-i;
104814 -                       if (j+LOG_BUF_LEN < log_end)
104815 +                       if (j + log_buf_len < log_end)
104816                                 break;
104817                         c = LOG_BUF(j);
104818                         spin_unlock_irq(&logbuf_lock);
104819 @@ -302,12 +345,15 @@ static void __call_console_drivers(unsig
104820  /*
104821   * Write out chars from start to end - 1 inclusive
104822   */
104823 -static void _call_console_drivers(unsigned long start, unsigned long end, int msg_log_level)
104824 +static void _call_console_drivers(unsigned long start,
104825 +                               unsigned long end, int msg_log_level)
104826  {
104827 -       if (msg_log_level < console_loglevel && console_drivers && start != end) {
104828 +       if (msg_log_level < console_loglevel &&
104829 +                       console_drivers && start != end) {
104830                 if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) {
104831                         /* wrapped write */
104832 -                       __call_console_drivers(start & LOG_BUF_MASK, LOG_BUF_LEN);
104833 +                       __call_console_drivers(start & LOG_BUF_MASK,
104834 +                                               log_buf_len);
104835                         __call_console_drivers(0, end & LOG_BUF_MASK);
104836                 } else {
104837                         __call_console_drivers(start, end);
104838 @@ -370,11 +416,11 @@ static void emit_log_char(char c)
104839  {
104840         LOG_BUF(log_end) = c;
104841         log_end++;
104842 -       if (log_end - log_start > LOG_BUF_LEN)
104843 -               log_start = log_end - LOG_BUF_LEN;
104844 -       if (log_end - con_start > LOG_BUF_LEN)
104845 -               con_start = log_end - LOG_BUF_LEN;
104846 -       if (logged_chars < LOG_BUF_LEN)
104847 +       if (log_end - log_start > log_buf_len)
104848 +               log_start = log_end - log_buf_len;
104849 +       if (log_end - con_start > log_buf_len)
104850 +               con_start = log_end - log_buf_len;
104851 +       if (logged_chars < log_buf_len)
104852                 logged_chars++;
104853  }
104854  
104855 @@ -399,9 +445,13 @@ asmlinkage int printk(const char *fmt, .
104856         char *p;
104857         static char printk_buf[1024];
104858         static int log_level_unknown = 1;
104859 +       static int printk_cpu = -1;
104860  
104861 -       if (oops_in_progress) {
104862 -               /* If a crash is occurring, make sure we can't deadlock */
104863 +       if (oops_in_progress && printk_cpu == smp_processor_id()) {
104864 +               /*
104865 +                * If a crash is occurring during printk() on this CPU, make
104866 +                * sure we can't deadlock
104867 +                */
104868                 spin_lock_init(&logbuf_lock);
104869                 /* And make sure that we print immediately */
104870                 init_MUTEX(&console_sem);
104871 @@ -409,6 +459,7 @@ asmlinkage int printk(const char *fmt, .
104872  
104873         /* This stops the holder of console_sem just where we want him */
104874         spin_lock_irqsave(&logbuf_lock, flags);
104875 +       printk_cpu = smp_processor_id();
104876  
104877         /* Emit the output into the temporary buffer */
104878         va_start(args, fmt);
104879 --- linux-2.6.0-test6/kernel/ptrace.c   2003-08-22 19:23:42.000000000 -0700
104880 +++ 25/kernel/ptrace.c  2003-10-05 00:33:25.000000000 -0700
104881 @@ -179,19 +179,14 @@ int access_process_vm(struct task_struct
104882  
104883                 flush_cache_page(vma, addr);
104884  
104885 -               /*
104886 -                * FIXME!  We used to have flush_page_to_ram() in here, but
104887 -                * that was wrong.  davem says we need a new per-arch primitive
104888 -                * to handle this correctly.
104889 -                */
104890 -
104891                 maddr = kmap(page);
104892                 if (write) {
104893 -                       memcpy(maddr + offset, buf, bytes);
104894 -                       flush_icache_user_range(vma, page, addr, bytes);
104895 +                       copy_to_user_page(vma, page, addr,
104896 +                                         maddr + offset, buf, bytes);
104897                         set_page_dirty_lock(page);
104898                 } else {
104899 -                       memcpy(buf, maddr + offset, bytes);
104900 +                       copy_from_user_page(vma, page, addr,
104901 +                                           buf, maddr + offset, bytes);
104902                 }
104903                 kunmap(page);
104904                 page_cache_release(page);
104905 --- linux-2.6.0-test6/kernel/rcupdate.c 2003-08-22 19:23:42.000000000 -0700
104906 +++ 25/kernel/rcupdate.c        2003-10-05 00:33:25.000000000 -0700
104907 @@ -15,7 +15,7 @@
104908   * along with this program; if not, write to the Free Software
104909   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
104910   *
104911 - * Copyright (c) IBM Corporation, 2001
104912 + * Copyright (C) IBM Corporation, 2001
104913   *
104914   * Author: Dipankar Sarma <dipankar@in.ibm.com>
104915   * 
104916 --- linux-2.6.0-test6/kernel/sched.c    2003-09-27 18:57:47.000000000 -0700
104917 +++ 25/kernel/sched.c   2003-10-05 00:36:39.000000000 -0700
104918 @@ -18,6 +18,7 @@
104919   */
104920  
104921  #include <linux/mm.h>
104922 +#include <linux/module.h>
104923  #include <linux/nmi.h>
104924  #include <linux/init.h>
104925  #include <asm/uaccess.h>
104926 @@ -642,6 +643,8 @@ int wake_up_process(task_t * p)
104927         return try_to_wake_up(p, TASK_STOPPED | TASK_INTERRUPTIBLE | TASK_UNINTERRUPTIBLE, 0, 0);
104928  }
104929  
104930 +EXPORT_SYMBOL(wake_up_process);
104931 +
104932  int wake_up_process_kick(task_t * p)
104933  {
104934         return try_to_wake_up(p, TASK_STOPPED | TASK_INTERRUPTIBLE | TASK_UNINTERRUPTIBLE, 0, 1);
104935 @@ -1585,6 +1588,8 @@ switch_tasks:
104936                 goto need_resched;
104937  }
104938  
104939 +EXPORT_SYMBOL(schedule);
104940 +
104941  #ifdef CONFIG_PREEMPT
104942  /*
104943   * this is is the entry point to schedule() from in-kernel preemption
104944 @@ -1612,6 +1617,8 @@ need_resched:
104945         if (unlikely(test_thread_flag(TIF_NEED_RESCHED)))
104946                 goto need_resched;
104947  }
104948 +
104949 +EXPORT_SYMBOL(preempt_schedule);
104950  #endif /* CONFIG_PREEMPT */
104951  
104952  int default_wake_function(wait_queue_t *curr, unsigned mode, int sync)
104953 @@ -1620,6 +1627,8 @@ int default_wake_function(wait_queue_t *
104954         return try_to_wake_up(p, mode, sync, 0);
104955  }
104956  
104957 +EXPORT_SYMBOL(default_wake_function);
104958 +
104959  /*
104960   * The core wakeup function.  Non-exclusive wakeups (nr_exclusive == 0) just
104961   * wake everything up.  If it's an exclusive wakeup (nr_exclusive == small +ve
104962 @@ -1660,6 +1669,8 @@ void __wake_up(wait_queue_head_t *q, uns
104963         spin_unlock_irqrestore(&q->lock, flags);
104964  }
104965  
104966 +EXPORT_SYMBOL(__wake_up);
104967 +
104968  /*
104969   * Same as __wake_up but called with the spinlock in wait_queue_head_t held.
104970   */
104971 @@ -1696,6 +1707,8 @@ void __wake_up_sync(wait_queue_head_t *q
104972         spin_unlock_irqrestore(&q->lock, flags);
104973  }
104974  
104975 +EXPORT_SYMBOL(__wake_up_sync);
104976 +
104977  void complete(struct completion *x)
104978  {
104979         unsigned long flags;
104980 @@ -1706,6 +1719,8 @@ void complete(struct completion *x)
104981         spin_unlock_irqrestore(&x->wait.lock, flags);
104982  }
104983  
104984 +EXPORT_SYMBOL(complete);
104985 +
104986  void complete_all(struct completion *x)
104987  {
104988         unsigned long flags;
104989 @@ -1737,6 +1752,8 @@ void wait_for_completion(struct completi
104990         spin_unlock_irq(&x->wait.lock);
104991  }
104992  
104993 +EXPORT_SYMBOL(wait_for_completion);
104994 +
104995  #define        SLEEP_ON_VAR                            \
104996         unsigned long flags;                    \
104997         wait_queue_t wait;                      \
104998 @@ -1763,6 +1780,8 @@ void interruptible_sleep_on(wait_queue_h
104999         SLEEP_ON_TAIL
105000  }
105001  
105002 +EXPORT_SYMBOL(interruptible_sleep_on);
105003 +
105004  long interruptible_sleep_on_timeout(wait_queue_head_t *q, long timeout)
105005  {
105006         SLEEP_ON_VAR
105007 @@ -1776,6 +1795,8 @@ long interruptible_sleep_on_timeout(wait
105008         return timeout;
105009  }
105010  
105011 +EXPORT_SYMBOL(interruptible_sleep_on_timeout);
105012 +
105013  void sleep_on(wait_queue_head_t *q)
105014  {
105015         SLEEP_ON_VAR
105016 @@ -1787,6 +1808,8 @@ void sleep_on(wait_queue_head_t *q)
105017         SLEEP_ON_TAIL
105018  }
105019  
105020 +EXPORT_SYMBOL(sleep_on);
105021 +
105022  long sleep_on_timeout(wait_queue_head_t *q, long timeout)
105023  {
105024         SLEEP_ON_VAR
105025 @@ -1800,6 +1823,8 @@ long sleep_on_timeout(wait_queue_head_t 
105026         return timeout;
105027  }
105028  
105029 +EXPORT_SYMBOL(sleep_on_timeout);
105030 +
105031  void scheduling_functions_end_here(void) { }
105032  
105033  void set_user_nice(task_t *p, long nice)
105034 @@ -1849,6 +1874,15 @@ out_unlock:
105035         task_rq_unlock(rq, &flags);
105036  }
105037  
105038 +EXPORT_SYMBOL(set_user_nice);
105039 +
105040 +#if defined( CONFIG_KGDB)
105041 +struct task_struct * kgdb_get_idle(int this_cpu)
105042 +{
105043 +        return cpu_rq(this_cpu)->idle;
105044 +}
105045 +#endif
105046 +
105047  #ifndef __alpha__
105048  
105049  /*
105050 @@ -1915,6 +1949,8 @@ int task_nice(task_t *p)
105051         return TASK_NICE(p);
105052  }
105053  
105054 +EXPORT_SYMBOL(task_nice);
105055 +
105056  /**
105057   * task_curr - is this task currently executing on a CPU?
105058   * @p: the task in question.
105059 @@ -1933,6 +1969,8 @@ int idle_cpu(int cpu)
105060         return cpu_curr(cpu) == cpu_rq(cpu)->idle;
105061  }
105062  
105063 +EXPORT_SYMBOL(idle_cpu);
105064 +
105065  /**
105066   * find_process_by_pid - find a process with a matching PID value.
105067   * @pid: the pid in question.
105068 @@ -2260,6 +2298,8 @@ void __cond_resched(void)
105069         schedule();
105070  }
105071  
105072 +EXPORT_SYMBOL(__cond_resched);
105073 +
105074  /**
105075   * yield - yield the current processor to other threads.
105076   *
105077 @@ -2272,6 +2312,8 @@ void yield(void)
105078         sys_sched_yield();
105079  }
105080  
105081 +EXPORT_SYMBOL(yield);
105082 +
105083  /*
105084   * This task is about to go to sleep on IO.  Increment rq->nr_iowait so
105085   * that process accounting knows that this is a task in IO wait state.
105086 @@ -2288,6 +2330,8 @@ void io_schedule(void)
105087         atomic_dec(&rq->nr_iowait);
105088  }
105089  
105090 +EXPORT_SYMBOL(io_schedule);
105091 +
105092  long io_schedule_timeout(long timeout)
105093  {
105094         struct runqueue *rq = this_rq();
105095 @@ -2402,17 +2446,16 @@ static inline struct task_struct *younge
105096  
105097  static void show_task(task_t * p)
105098  {
105099 -       unsigned long free = 0;
105100         task_t *relative;
105101 -       int state;
105102 -       static const char * stat_nam[] = { "R", "S", "D", "T", "Z", "W" };
105103 +       unsigned state;
105104 +       static const char *stat_nam[] = { "R", "S", "D", "T", "Z", "W" };
105105  
105106         printk("%-13.13s ", p->comm);
105107         state = p->state ? __ffs(p->state) + 1 : 0;
105108 -       if (((unsigned) state) < sizeof(stat_nam)/sizeof(char *))
105109 +       if (state < ARRAY_SIZE(stat_nam))
105110                 printk(stat_nam[state]);
105111         else
105112 -               printk(" ");
105113 +               printk("?");
105114  #if (BITS_PER_LONG == 32)
105115         if (p == current)
105116                 printk(" current  ");
105117 @@ -2424,13 +2467,7 @@ static void show_task(task_t * p)
105118         else
105119                 printk(" %016lx ", thread_saved_pc(p));
105120  #endif
105121 -       {
105122 -               unsigned long * n = (unsigned long *) (p->thread_info+1);
105123 -               while (!*n)
105124 -                       n++;
105125 -               free = (unsigned long) n - (unsigned long)(p+1);
105126 -       }
105127 -       printk("%5lu %5d %6d ", free, p->pid, p->parent->pid);
105128 +       printk("%5d %6d ", p->pid, p->parent->pid);
105129         if ((relative = eldest_child(p)))
105130                 printk("%5d ", relative->pid);
105131         else
105132 @@ -2457,12 +2494,12 @@ void show_state(void)
105133  
105134  #if (BITS_PER_LONG == 32)
105135         printk("\n"
105136 -              "                         free                        sibling\n");
105137 -       printk("  task             PC    stack   pid father child younger older\n");
105138 +              "                                               sibling\n");
105139 +       printk("  task             PC      pid father child younger older\n");
105140  #else
105141         printk("\n"
105142 -              "                                 free                        sibling\n");
105143 -       printk("  task                 PC        stack   pid father child younger older\n");
105144 +              "                                                       sibling\n");
105145 +       printk("  task                 PC          pid father child younger older\n");
105146  #endif
105147         read_lock(&tasklist_lock);
105148         do_each_thread(g, p) {
105149 @@ -2574,6 +2611,8 @@ int set_cpus_allowed(task_t *p, cpumask_
105150         return 0;
105151  }
105152  
105153 +EXPORT_SYMBOL_GPL(set_cpus_allowed);
105154 +
105155  /* Move (not current) task off this cpu, onto dest cpu. */
105156  static void move_task_away(struct task_struct *p, int dest_cpu)
105157  {
105158 @@ -2819,6 +2858,7 @@ void __might_sleep(char *file, int line)
105159         }
105160  #endif
105161  }
105162 +EXPORT_SYMBOL(__might_sleep);
105163  #endif
105164  
105165  
105166 @@ -2847,6 +2887,8 @@ void __preempt_spin_lock(spinlock_t *loc
105167         } while (!_raw_spin_trylock(lock));
105168  }
105169  
105170 +EXPORT_SYMBOL(__preempt_spin_lock);
105171 +
105172  void __preempt_write_lock(rwlock_t *lock)
105173  {
105174         if (preempt_count() > 1) {
105175 @@ -2861,4 +2903,6 @@ void __preempt_write_lock(rwlock_t *lock
105176                 preempt_disable();
105177         } while (!_raw_write_trylock(lock));
105178  }
105179 -#endif
105180 +
105181 +EXPORT_SYMBOL(__preempt_write_lock);
105182 +#endif /* defined(CONFIG_SMP) && defined(CONFIG_PREEMPT) */
105183 --- linux-2.6.0-test6/kernel/signal.c   2003-09-27 18:57:47.000000000 -0700
105184 +++ 25/kernel/signal.c  2003-10-05 00:36:15.000000000 -0700
105185 @@ -593,7 +593,8 @@ static int check_kill_permission(int sig
105186         error = -EPERM;
105187         if ((!info || ((unsigned long)info != 1 &&
105188                         (unsigned long)info != 2 && SI_FROMUSER(info)))
105189 -           && ((sig != SIGCONT) || (current->session != t->session))
105190 +           && ((sig != SIGCONT) ||
105191 +               (process_session(current) != process_session(t)))
105192             && (current->euid ^ t->suid) && (current->euid ^ t->uid)
105193             && (current->uid ^ t->suid) && (current->uid ^ t->uid)
105194             && !capable(CAP_KILL))
105195 @@ -1102,7 +1103,7 @@ kill_sl_info(int sig, struct siginfo *in
105196         retval = -ESRCH;
105197         read_lock(&tasklist_lock);
105198         for_each_task_pid(sid, PIDTYPE_SID, p, l, pid) {
105199 -               if (!p->leader)
105200 +               if (!process_session_leader(p))
105201                         continue;
105202                 err = group_send_sig_info(sig, info, p);
105203                 if (retval)
105204 --- linux-2.6.0-test6/kernel/sys.c      2003-09-27 18:57:47.000000000 -0700
105205 +++ 25/kernel/sys.c     2003-10-05 00:36:15.000000000 -0700
105206 @@ -951,7 +951,7 @@ asmlinkage long sys_setpgid(pid_t pid, p
105207  
105208         if (p->parent == current || p->real_parent == current) {
105209                 err = -EPERM;
105210 -               if (p->session != current->session)
105211 +               if (process_session(p) != process_session(current))
105212                         goto out;
105213                 err = -EACCES;
105214                 if (p->did_exec)
105215 @@ -963,7 +963,7 @@ asmlinkage long sys_setpgid(pid_t pid, p
105216         }
105217  
105218         err = -EPERM;
105219 -       if (p->leader)
105220 +       if (process_session_leader(p))
105221                 goto out;
105222  
105223         if (pgid != pid) {
105224 @@ -972,7 +972,7 @@ asmlinkage long sys_setpgid(pid_t pid, p
105225                 struct list_head *l;
105226  
105227                 for_each_task_pid(pgid, PIDTYPE_PGID, p, l, pid)
105228 -                       if (p->session == current->session)
105229 +                       if (process_session(p) == process_session(current))
105230                                 goto ok_pgid;
105231                 goto out;
105232         }
105233 @@ -984,7 +984,7 @@ ok_pgid:
105234  
105235         if (process_group(p) != pgid) {
105236                 detach_pid(p, PIDTYPE_PGID);
105237 -               p->group_leader->__pgrp = pgid;
105238 +               p->signal->pgrp = pgid;
105239                 attach_pid(p, PIDTYPE_PGID, pgid);
105240         }
105241  
105242 @@ -1026,7 +1026,7 @@ asmlinkage long sys_getpgrp(void)
105243  asmlinkage long sys_getsid(pid_t pid)
105244  {
105245         if (!pid) {
105246 -               return current->session;
105247 +               return process_session(current);
105248         } else {
105249                 int retval;
105250                 struct task_struct *p;
105251 @@ -1038,7 +1038,7 @@ asmlinkage long sys_getsid(pid_t pid)
105252                 if(p) {
105253                         retval = security_task_getsid(p);
105254                         if (!retval)
105255 -                               retval = p->session;
105256 +                               retval = process_session(p);
105257                 }
105258                 read_unlock(&tasklist_lock);
105259                 return retval;
105260 @@ -1059,10 +1059,10 @@ asmlinkage long sys_setsid(void)
105261         if (pid)
105262                 goto out;
105263  
105264 -       current->leader = 1;
105265 +       current->signal->leader = 1;
105266         __set_special_pids(current->pid, current->pid);
105267 -       current->tty = NULL;
105268 -       current->tty_old_pgrp = 0;
105269 +       current->signal->tty = NULL;
105270 +       current->signal->tty_old_pgrp = 0;
105271         err = process_group(current);
105272  out:
105273         write_unlock_irq(&tasklist_lock);
105274 --- linux-2.6.0-test6/kernel/sysctl.c   2003-09-27 18:57:47.000000000 -0700
105275 +++ 25/kernel/sysctl.c  2003-10-05 00:33:25.000000000 -0700
105276 @@ -19,6 +19,7 @@
105277   */
105278  
105279  #include <linux/config.h>
105280 +#include <linux/module.h>
105281  #include <linux/mm.h>
105282  #include <linux/swap.h>
105283  #include <linux/slab.h>
105284 @@ -136,17 +137,14 @@ extern ctl_table random_table[];
105285  
105286  static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
105287  static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
105288 -static int proc_sys_permission(struct inode *, int, struct nameidata *);
105289 +static int proc_opensys(struct inode *, struct file *);
105290  
105291  struct file_operations proc_sys_file_operations = {
105292 +       .open           = proc_opensys,
105293         .read           = proc_readsys,
105294         .write          = proc_writesys,
105295  };
105296  
105297 -static struct inode_operations proc_sys_inode_operations = {
105298 -       .permission     = proc_sys_permission,
105299 -};
105300 -
105301  extern struct proc_dir_entry *proc_sys_root;
105302  
105303  static void register_proc_table(ctl_table *, struct proc_dir_entry *);
105304 @@ -1140,10 +1138,8 @@ static void register_proc_table(ctl_tabl
105305                         if (!de)
105306                                 continue;
105307                         de->data = (void *) table;
105308 -                       if (table->proc_handler) {
105309 +                       if (table->proc_handler)
105310                                 de->proc_fops = &proc_sys_file_operations;
105311 -                               de->proc_iops = &proc_sys_inode_operations;
105312 -                       }
105313                 }
105314                 table->de = de;
105315                 if (de->mode & S_IFDIR)
105316 @@ -1212,6 +1208,20 @@ static ssize_t do_rw_proc(int write, str
105317         return res;
105318  }
105319  
105320 +static int proc_opensys(struct inode *inode, struct file *file)
105321 +{
105322 +       if (file->f_mode & FMODE_WRITE) {
105323 +               /*
105324 +                * sysctl entries that are not writable,
105325 +                * are _NOT_ writable, capabilities or not.
105326 +                */
105327 +               if (!(inode->i_mode & S_IWUSR))
105328 +                       return -EPERM;
105329 +       }
105330 +
105331 +       return 0;
105332 +}
105333 +
105334  static ssize_t proc_readsys(struct file * file, char __user * buf,
105335                             size_t count, loff_t *ppos)
105336  {
105337 @@ -1224,11 +1234,6 @@ static ssize_t proc_writesys(struct file
105338         return do_rw_proc(1, file, (char __user *) buf, count, ppos);
105339  }
105340  
105341 -static int proc_sys_permission(struct inode *inode, int op, struct nameidata *nd)
105342 -{
105343 -       return test_perm(inode->i_mode, op);
105344 -}
105345 -
105346  /**
105347   * proc_dostring - read a string sysctl
105348   * @table: the sysctl table
105349 @@ -1994,3 +1999,19 @@ void unregister_sysctl_table(struct ctl_
105350  }
105351  
105352  #endif /* CONFIG_SYSCTL */
105353 +
105354 +/*
105355 + * No sense putting this after each symbol definition, twice,
105356 + * exception granted :-)
105357 + */
105358 +EXPORT_SYMBOL(proc_dointvec);
105359 +EXPORT_SYMBOL(proc_dointvec_jiffies);
105360 +EXPORT_SYMBOL(proc_dointvec_minmax);
105361 +EXPORT_SYMBOL(proc_dostring);
105362 +EXPORT_SYMBOL(proc_doulongvec_minmax);
105363 +EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
105364 +EXPORT_SYMBOL(register_sysctl_table);
105365 +EXPORT_SYMBOL(sysctl_intvec);
105366 +EXPORT_SYMBOL(sysctl_jiffies);
105367 +EXPORT_SYMBOL(sysctl_string);
105368 +EXPORT_SYMBOL(unregister_sysctl_table);
105369 --- linux-2.6.0-test6/lib/kobject.c     2003-09-08 13:58:59.000000000 -0700
105370 +++ 25/lib/kobject.c    2003-10-05 00:34:36.000000000 -0700
105371 @@ -236,8 +236,6 @@ static void unlink(struct kobject * kobj
105372                 list_del_init(&kobj->entry);
105373                 up_write(&kobj->kset->subsys->rwsem);
105374         }
105375 -       if (kobj->parent) 
105376 -               kobject_put(kobj->parent);
105377         kobject_put(kobj);
105378  }
105379  
105380 @@ -448,6 +446,8 @@ void kobject_cleanup(struct kobject * ko
105381         if (kobj->k_name != kobj->name)
105382                 kfree(kobj->k_name);
105383         kobj->k_name = NULL;
105384 +       if (kobj->parent)
105385 +               kobject_put(kobj->parent);
105386         if (t && t->release)
105387                 t->release(kobj);
105388         if (s)
105389 --- linux-2.6.0-test6/lib/Makefile      2003-09-27 18:57:47.000000000 -0700
105390 +++ 25/lib/Makefile     2003-10-05 00:33:25.000000000 -0700
105391 @@ -5,7 +5,7 @@
105392  
105393  lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \
105394          bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \
105395 -        kobject.o idr.o div64.o
105396 +        kobject.o idr.o div64.o parser.o
105397  
105398  lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
105399  lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
105400 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
105401 +++ 25/lib/parser.c     2003-10-05 00:33:25.000000000 -0700
105402 @@ -0,0 +1,138 @@
105403 +/*
105404 + * lib/parser.c - simple parser for mount, etc. options.
105405 + *
105406 + * This source code is licensed under the GNU General Public License,
105407 + * Version 2.  See the file COPYING for more details.
105408 + */
105409 +
105410 +#include <linux/ctype.h>
105411 +#include <linux/module.h>
105412 +#include <linux/parser.h>
105413 +#include <linux/slab.h>
105414 +#include <linux/string.h>
105415 +
105416 +static int match_one(char *s, char *p, substring_t args[])
105417 +{
105418 +       char *meta;
105419 +       int argc = 0;
105420 +
105421 +       if (!p)
105422 +               return 1;
105423 +
105424 +       while(1) {
105425 +               int len = -1;
105426 +               meta = strchr(p, '%');
105427 +               if (!meta)
105428 +                       return strcmp(p, s) == 0;
105429 +
105430 +               if (strncmp(p, s, meta-p))
105431 +                       return 0;
105432 +
105433 +               s += meta - p;
105434 +               p = meta + 1;
105435 +
105436 +               if (isdigit(*p))
105437 +                       len = simple_strtoul(p, &p, 10);
105438 +               else if (*p == '%') {
105439 +                       if (*s++ != '%')
105440 +                               return 0;
105441 +                       continue;
105442 +               }
105443 +
105444 +               if (argc >= MAX_OPT_ARGS)
105445 +                       return 0;
105446 +
105447 +               args[argc].from = s;
105448 +               switch (*p++) {
105449 +               case 's':
105450 +                       if (len == -1 || len > strlen(s))
105451 +                               len = strlen(s);
105452 +                       args[argc].to = s + len;
105453 +                       break;
105454 +               case 'd':
105455 +                       simple_strtol(s, &args[argc].to, 0);
105456 +                       goto num;
105457 +               case 'u':
105458 +                       simple_strtoul(s, &args[argc].to, 0);
105459 +                       goto num;
105460 +               case 'o':
105461 +                       simple_strtoul(s, &args[argc].to, 8);
105462 +                       goto num;
105463 +               case 'x':
105464 +                       simple_strtoul(s, &args[argc].to, 16);
105465 +               num:
105466 +                       if (args[argc].to == args[argc].from)
105467 +                               return 0;
105468 +                       break;
105469 +               default:
105470 +                       return 0;
105471 +               }
105472 +               s = args[argc].to;
105473 +               argc++;
105474 +       }
105475 +}
105476 +
105477 +int match_token(char *s, match_table_t table, substring_t args[])
105478 +{
105479 +       struct match_token *p;
105480 +
105481 +       for (p = table; !match_one(s, p->pattern, args) ; p++)
105482 +               ;
105483 +
105484 +       return p->token;
105485 +}
105486 +
105487 +static int match_number(substring_t *s, int *result, int base)
105488 +{
105489 +       char *endp;
105490 +       char *buf;
105491 +       int ret;
105492 +
105493 +       buf = kmalloc(s->to - s->from + 1, GFP_KERNEL);
105494 +       if (!buf)
105495 +               return -ENOMEM;
105496 +       memcpy(buf, s->from, s->to - s->from);
105497 +       buf[s->to - s->from] = '\0';
105498 +       *result = simple_strtol(buf, &endp, base);
105499 +       ret = 0;
105500 +       if (endp == buf)
105501 +               ret = -EINVAL;
105502 +       kfree(buf);
105503 +       return ret;
105504 +}
105505 +
105506 +int match_int(substring_t *s, int *result)
105507 +{
105508 +       return match_number(s, result, 0);
105509 +}
105510 +
105511 +int match_octal(substring_t *s, int *result)
105512 +{
105513 +       return match_number(s, result, 8);
105514 +}
105515 +
105516 +int match_hex(substring_t *s, int *result)
105517 +{
105518 +       return match_number(s, result, 16);
105519 +}
105520 +
105521 +void match_strcpy(char *to, substring_t *s)
105522 +{
105523 +       memcpy(to, s->from, s->to - s->from);
105524 +       to[s->to - s->from] = '\0';
105525 +}
105526 +
105527 +char *match_strdup(substring_t *s)
105528 +{
105529 +       char *p = kmalloc(s->to - s->from + 1, GFP_KERNEL);
105530 +       if (p)
105531 +               match_strcpy(p, s);
105532 +       return p;
105533 +}
105534 +
105535 +EXPORT_SYMBOL(match_token);
105536 +EXPORT_SYMBOL(match_int);
105537 +EXPORT_SYMBOL(match_octal);
105538 +EXPORT_SYMBOL(match_hex);
105539 +EXPORT_SYMBOL(match_strcpy);
105540 +EXPORT_SYMBOL(match_strdup);
105541 --- linux-2.6.0-test6/MAINTAINERS       2003-09-27 18:57:43.000000000 -0700
105542 +++ 25/MAINTAINERS      2003-10-05 00:34:22.000000000 -0700
105543 @@ -114,8 +114,8 @@ W:  http://sourceforge.net/projects/gkern
105544  S:     Maintained
105545  
105546  8250/16?50 (AND CLONE UARTS) SERIAL DRIVER
105547 -P:     Theodore Ts'o
105548 -M:     tytso@mit.edu
105549 +P:     Russell King
105550 +M:     rmk+serial@arm.linux.org.uk
105551  L:     linux-serial@vger.kernel.org
105552  W:     http://serial.sourceforge.net
105553  S:     Maintained
105554 @@ -284,6 +284,16 @@ P: Jonathan Layes
105555  L:     linux-net@vger.kernel.org
105556  S:     Maintained
105557  
105558 +ASUS ACPI EXTRAS DRIVER
105559 +P:     Karol Kozimor
105560 +M:     sziwan@users.sourceforge.net
105561 +P:     Julien Lerouge
105562 +M:     julien.lerouge@free.fr
105563 +L:     acpi4asus-user@lists.sourceforge.net
105564 +W:     http://sourceforge.net/projects/acpi4asus
105565 +W:     http://julien.lerouge.free.fr
105566 +S:     Maintained
105567 +
105568  ATM
105569  P:     Chas Williams
105570  M:     chas@cmf.nrl.navy.mil
105571 @@ -509,7 +519,7 @@ S:  Maintained
105572  
105573  CRYPTO API
105574  P:     James Morris
105575 -M:     jmorris@intercode.com.au
105576 +M:     jmorris@redhat.com
105577  P:     David S. Miller
105578  M:     davem@redhat.com
105579  W      http://samba.org/~jamesm/crypto/
105580 @@ -624,7 +634,7 @@ DIGIBOARD PC/XE AND PC/XI DRIVER
105581  P:     Christoph Lameter
105582  M:     christoph@lameter.com
105583  W:     http://www.digi.com
105584 -L:     digilnux@dgii.com
105585 +L:     digilnux@digi.com
105586  S:     Orphaned
105587  
105588  DIRECTORY NOTIFICATION
105589 @@ -669,6 +679,12 @@ M: romieu@cogenit.fr
105590  M:     romieu@ensta.fr
105591  S:     Maintained
105592  
105593 +DVB SUBSYSTEM AND DRIVERS
105594 +P:     LinuxTV.org Project
105595 +L:     linux-dvb@linuxtv.org
105596 +W:     http://linuxtv.org/developer/dvb.xml
105597 +S:     Supported
105598 +
105599  EATA-DMA SCSI DRIVER
105600  P:     Michael Neuffer
105601  L:     linux-eata@i-connect.net, linux-scsi@vger.kernel.org
105602 @@ -706,6 +722,11 @@ L: emu10k1-devel@lists.sourceforge.net
105603  W:     http://sourceforge.net/projects/emu10k1/
105604  S:     Maintained
105605  
105606 +EPSON 1355 FRAMEBUFFER DRIVER
105607 +P:     Christopher Hoover
105608 +M:     ch@murgatroid.com, ch@hpl.hp.com
105609 +S:     Maintained
105610 +
105611  ETHEREXPRESS-16 NETWORK DRIVER
105612  P:     Philip Blundell
105613  M:     Philip.Blundell@pobox.com
105614 @@ -1139,6 +1160,12 @@ W:       http://sf.net/projects/kernel-janitor
105615  W:     http://developer.osdl.org/rddunlap/kj-patches/
105616  S:     Maintained
105617  
105618 +KGDB FOR I386 PLATFORM
105619 +P:     George Anzinger
105620 +M:     george@mvista.com
105621 +L:     linux-net@vger.kernel.org
105622 +S:     Supported
105623 +
105624  KERNEL NFSD
105625  P:     Neil Brown
105626  M:     neilb@cse.unsw.edu.au
105627 @@ -1386,7 +1413,7 @@ M:        kuznet@ms2.inr.ac.ru
105628  P:     Pekka Savola (ipv6)
105629  M:     pekkas@netcore.fi
105630  P:     James Morris
105631 -M:     jmorris@intercode.com.au
105632 +M:     jmorris@redhat.com
105633  P:     Hideaki YOSHIFUJI
105634  M:     yoshfuji@linux-ipv6.org
105635  L:     netdev@oss.sgi.com
105636 @@ -1658,6 +1685,12 @@ L:       linux-390@vm.marist.edu
105637  W:     http://oss.software.ibm.com/developerworks/opensource/linux390
105638  S:     Supported
105639  
105640 +SAA7146 VIDEO4LINUX-2 DRIVER
105641 +P:     Michael Hunold
105642 +M:     michael@mihu.de
105643 +W:     http://www.mihu.de/linux/saa7146
105644 +S:     Maintained
105645 +
105646  SA1100 SUPPORT
105647  P:     Nicolas Pitre
105648  M:     nico@cam.org
105649 --- linux-2.6.0-test6/Makefile  2003-09-27 18:57:43.000000000 -0700
105650 +++ 25/Makefile 2003-10-05 00:37:37.000000000 -0700
105651 @@ -1,7 +1,7 @@
105652  VERSION = 2
105653  PATCHLEVEL = 6
105654  SUBLEVEL = 0
105655 -EXTRAVERSION = -test6
105656 +EXTRAVERSION = -test6-mm4
105657  
105658  # *DOCUMENTATION*
105659  # To see a list of typical targets execute "make help"
105660 @@ -37,7 +37,7 @@ ifdef V
105661    endif
105662  endif
105663  ifndef KBUILD_VERBOSE
105664 -  KBUILD_VERBOSE = 0 
105665 +  KBUILD_VERBOSE = 0
105666  endif
105667  
105668  # Call sparse as part of compilation of C files
105669 @@ -79,16 +79,24 @@ ifdef O
105670    endif
105671  endif
105672  
105673 +# That's our default target when none is given on the command line
105674 +.PHONY: all
105675 +all:
105676 +  
105677  ifneq ($(KBUILD_OUTPUT),)
105678  # Invoke a second make in the output directory, passing relevant variables
105679 -       KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT); /bin/pwd)
105680 +# check that the output directory actually exists
105681 +saved-output := $(KBUILD_OUTPUT)
105682 +KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
105683 +$(if $(wildcard $(KBUILD_OUTPUT)),, \
105684 +     $(error output directory "$(saved-output)" does not exist))
105685  
105686 -.PHONY: $(MAKECMDGOALS) all
105687 +.PHONY: $(MAKECMDGOALS)
105688  
105689 -$(MAKECMDGOALS) all:
105690 +$(filter-out all,$(MAKECMDGOALS)) all:
105691         $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT)         \
105692         KBUILD_SRC=$(CURDIR)    KBUILD_VERBOSE=$(KBUILD_VERBOSE)        \
105693 -       KBUILD_CHECK=$(KBUILD_CHECK) -f $(CURDIR)/Makefile $(MAKECMDGOALS)
105694 +       KBUILD_CHECK=$(KBUILD_CHECK) -f $(CURDIR)/Makefile $@
105695  
105696  # Leave processing to above invocation of make
105697  skip-makefile := 1
105698 @@ -156,13 +164,6 @@ HOSTCXX    = g++
105699  HOSTCFLAGS     = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
105700  HOSTCXXFLAGS   = -O2
105701  
105702 -
105703 -#      That's our default target when none is given on the command line
105704 -#      Note that 'modules' will be added as a prerequisite as well, 
105705 -#      in the CONFIG_MODULES part below
105706 -
105707 -all:   vmlinux
105708 -
105709  #      Decide whether to build built-in, modular, or both.
105710  #      Normally, just do built-in.
105711  
105712 @@ -366,6 +367,12 @@ else
105713  # Build targets only - this includes vmlinux, arch specific targets, clean
105714  # targets and others. In general all targets except *config targets.
105715  
105716 +# That's our default target when none is given on the command line
105717 +# Note that 'modules' will be added as a prerequisite as well, 
105718 +# in the CONFIG_MODULES part below
105719 +
105720 +all:   vmlinux
105721 +
105722  # Objects we will link into vmlinux / subdirs we need to visit
105723  init-y         := init/
105724  drivers-y      := drivers/ sound/
105725 @@ -753,7 +760,7 @@ MRPROPER_FILES += \
105726         .menuconfig.log \
105727         include/asm \
105728         .hdepend include/linux/modversions.h \
105729 -       tags TAGS cscope.out kernel.spec \
105730 +       tags TAGS cscope* kernel.spec \
105731         .tmp*
105732  
105733  # Directories removed with 'make mrproper'
105734 @@ -877,7 +884,7 @@ help:
105735         @echo  '  mrproper        - remove all generated files + config + various backup files'
105736         @echo  ''
105737         @echo  'Configuration targets:'
105738 -       @$(MAKE) -f scripts/kconfig/Makefile help
105739 +       @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
105740         @echo  ''
105741         @echo  'Other generic targets:'
105742         @echo  '  all             - Build all targets marked with [*]'
105743 @@ -890,7 +897,7 @@ help:
105744         @echo  '  tags/TAGS       - Generate tags file for editors'
105745         @echo  ''
105746         @echo  'Documentation targets:'
105747 -       @$(MAKE) -f Documentation/DocBook/Makefile dochelp
105748 +       @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp
105749         @echo  ''
105750         @echo  'Architecture specific targets ($(ARCH)):'
105751         @$(if $(archhelp),$(archhelp),\
105752 --- linux-2.6.0-test6/mm/bootmem.c      2003-08-08 22:55:14.000000000 -0700
105753 +++ 25/mm/bootmem.c     2003-10-05 00:33:25.000000000 -0700
105754 @@ -146,7 +146,7 @@ static void __init free_bootmem_core(boo
105755   * We 'merge' subsequent allocations to save space. We might 'lose'
105756   * some fraction of a page if allocations cannot be satisfied due to
105757   * size constraints on boxes where there is physical RAM space
105758 - * fragmentation - in these cases * (mostly large memory boxes) this
105759 + * fragmentation - in these cases (mostly large memory boxes) this
105760   * is not a problem.
105761   *
105762   * On low memory boxes we get it right in 100% of the cases.
105763 --- linux-2.6.0-test6/mm/fadvise.c      2003-09-27 18:57:47.000000000 -0700
105764 +++ 25/mm/fadvise.c     2003-10-05 00:34:08.000000000 -0700
105765 @@ -23,7 +23,6 @@
105766  asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
105767  {
105768         struct file *file = fget(fd);
105769 -       struct inode *inode;
105770         struct address_space *mapping;
105771         struct backing_dev_info *bdi;
105772         pgoff_t start_index;
105773 @@ -33,8 +32,7 @@ asmlinkage long sys_fadvise64_64(int fd,
105774         if (!file)
105775                 return -EBADF;
105776  
105777 -       inode = file->f_dentry->d_inode;
105778 -       mapping = inode->i_mapping;
105779 +       mapping = file->f_mapping;
105780         if (!mapping) {
105781                 ret = -EINVAL;
105782                 goto out;
105783 --- linux-2.6.0-test6/mm/filemap.c      2003-09-27 18:57:47.000000000 -0700
105784 +++ 25/mm/filemap.c     2003-10-05 00:37:07.000000000 -0700
105785 @@ -61,6 +61,9 @@
105786   *        ->swap_device_lock   (exclusive_swap_page, others)
105787   *          ->mapping->page_lock
105788   *
105789 + *  ->i_sem
105790 + *    ->i_shared_sem           (truncate->invalidate_mmap_range)
105791 + *
105792   *  ->mmap_sem
105793   *    ->i_shared_sem           (various places)
105794   *
105795 @@ -70,6 +73,9 @@
105796   *  ->mmap_sem
105797   *    ->i_sem                  (msync)
105798   *
105799 + *  ->i_sem
105800 + *    ->i_alloc_sem             (various)
105801 + *
105802   *  ->inode_lock
105803   *    ->sb_lock                        (fs/fs-writeback.c)
105804   *    ->mapping->page_lock     (__sync_single_inode)
105805 @@ -151,6 +157,8 @@ int filemap_fdatawrite(struct address_sp
105806         return __filemap_fdatawrite(mapping, WB_SYNC_ALL);
105807  }
105808  
105809 +EXPORT_SYMBOL(filemap_fdatawrite);
105810 +
105811  /*
105812   * This is a mostly non-blocking flush.  Not suitable for data-integrity
105813   * purposes.
105814 @@ -216,6 +224,20 @@ restart:
105815         return ret;
105816  }
105817  
105818 +EXPORT_SYMBOL(filemap_fdatawait);
105819 +
105820 +int filemap_write_and_wait(struct address_space *mapping)
105821 +{
105822 +       int retval = 0;
105823 +
105824 +       if (mapping->nrpages) {
105825 +               retval = filemap_fdatawrite(mapping);
105826 +               if (retval == 0)
105827 +                       retval = filemap_fdatawait(mapping);
105828 +       }
105829 +       return retval;
105830 +}
105831 +
105832  /*
105833   * This adds a page to the page cache, starting out as locked, unreferenced,
105834   * not uptodate and with no errors.
105835 @@ -253,6 +275,7 @@ int add_to_page_cache(struct page *page,
105836         }
105837         return error;
105838  }
105839 +
105840  EXPORT_SYMBOL(add_to_page_cache);
105841  
105842  int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
105843 @@ -281,21 +304,42 @@ static wait_queue_head_t *page_waitqueue
105844         return &zone->wait_table[hash_ptr(page, zone->wait_table_bits)];
105845  }
105846  
105847 -void wait_on_page_bit(struct page *page, int bit_nr)
105848 +/*
105849 + * wait for the specified page bit to be cleared
105850 + * this could be a synchronous wait or could just queue an async
105851 + * notification callback depending on the wait queue entry parameter
105852 + *
105853 + * A NULL wait queue parameter defaults to sync behaviour
105854 + */
105855 +int wait_on_page_bit_wq(struct page *page, int bit_nr, wait_queue_t *wait)
105856  {
105857         wait_queue_head_t *waitqueue = page_waitqueue(page);
105858 -       DEFINE_WAIT(wait);
105859 +       DEFINE_WAIT(local_wait);
105860 +
105861 +       if (!wait)
105862 +               wait = &local_wait; /* default to a sync wait entry */
105863  
105864         do {
105865 -               prepare_to_wait(waitqueue, &wait, TASK_UNINTERRUPTIBLE);
105866 +               prepare_to_wait(waitqueue, wait, TASK_UNINTERRUPTIBLE);
105867                 if (test_bit(bit_nr, &page->flags)) {
105868                         sync_page(page);
105869 +                       if (!is_sync_wait(wait)) {
105870 +                               /*
105871 +                                * if we've queued an async wait queue
105872 +                                * callback do not block; just tell the
105873 +                                * caller to return and retry later when
105874 +                                * the callback is notified
105875 +                                */
105876 +                               return -EIOCBRETRY;
105877 +                       }
105878                         io_schedule();
105879                 }
105880         } while (test_bit(bit_nr, &page->flags));
105881 -       finish_wait(waitqueue, &wait);
105882 +       finish_wait(waitqueue, wait);
105883 +
105884 +       return 0;
105885  }
105886 -EXPORT_SYMBOL(wait_on_page_bit);
105887 +EXPORT_SYMBOL(wait_on_page_bit_wq);
105888  
105889  /**
105890   * unlock_page() - unlock a locked page
105891 @@ -305,7 +349,9 @@ EXPORT_SYMBOL(wait_on_page_bit);
105892   * Unlocks the page and wakes up sleepers in ___wait_on_page_locked().
105893   * Also wakes sleepers in wait_on_page_writeback() because the wakeup
105894   * mechananism between PageLocked pages and PageWriteback pages is shared.
105895 - * But that's OK - sleepers in wait_on_page_writeback() just go back to sleep.
105896 + * But that's OK - sleepers in wait_on_page_writeback() just go back to sleep,
105897 + * or in case the wakeup notifies async wait queue entries, as in the case
105898 + * of aio, retries would be triggered and may re-queue their callbacks.
105899   *
105900   * The first mb is necessary to safely close the critical section opened by the
105901   * TestSetPageLocked(), the second mb is necessary to enforce ordering between
105902 @@ -323,6 +369,8 @@ void unlock_page(struct page *page)
105903                 wake_up_all(waitqueue);
105904  }
105905  
105906 +EXPORT_SYMBOL(unlock_page);
105907 +
105908  /*
105909   * End writeback against a page.
105910   */
105911 @@ -339,30 +387,57 @@ void end_page_writeback(struct page *pag
105912         if (waitqueue_active(waitqueue))
105913                 wake_up_all(waitqueue);
105914  }
105915 +
105916  EXPORT_SYMBOL(end_page_writeback);
105917  
105918  /*
105919 - * Get a lock on the page, assuming we need to sleep to get it.
105920 + * Get a lock on the page, assuming we need to either sleep to get it
105921 + * or to queue an async notification callback to try again when its
105922 + * available.
105923 + *
105924 + * A NULL wait queue parameter defaults to sync behaviour. Otherwise
105925 + * it specifies the wait queue entry to be used for async notification
105926 + * or waiting.
105927   *
105928   * Ugly: running sync_page() in state TASK_UNINTERRUPTIBLE is scary.  If some
105929   * random driver's requestfn sets TASK_RUNNING, we could busywait.  However
105930   * chances are that on the second loop, the block layer's plug list is empty,
105931   * so sync_page() will then return in state TASK_UNINTERRUPTIBLE.
105932   */
105933 -void __lock_page(struct page *page)
105934 +int __lock_page_wq(struct page *page, wait_queue_t *wait)
105935  {
105936         wait_queue_head_t *wqh = page_waitqueue(page);
105937 -       DEFINE_WAIT(wait);
105938 +       DEFINE_WAIT(local_wait);
105939 +
105940 +       if (!wait)
105941 +               wait = &local_wait;
105942  
105943         while (TestSetPageLocked(page)) {
105944 -               prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE);
105945 +               prepare_to_wait(wqh, wait, TASK_UNINTERRUPTIBLE);
105946                 if (PageLocked(page)) {
105947                         sync_page(page);
105948 +                       if (!is_sync_wait(wait)) {
105949 +                               /*
105950 +                                * if we've queued an async wait queue
105951 +                                * callback do not block; just tell the
105952 +                                * caller to return and retry later when
105953 +                                * the callback is notified
105954 +                                */
105955 +                               return -EIOCBRETRY;
105956 +                       }
105957                         io_schedule();
105958                 }
105959         }
105960 -       finish_wait(wqh, &wait);
105961 +       finish_wait(wqh, wait);
105962 +       return 0;
105963 +}
105964 +EXPORT_SYMBOL(__lock_page_wq);
105965 +
105966 +void __lock_page(struct page *page)
105967 +{
105968 +       __lock_page_wq(page, NULL);
105969  }
105970 +
105971  EXPORT_SYMBOL(__lock_page);
105972  
105973  /*
105974 @@ -385,6 +460,8 @@ struct page * find_get_page(struct addre
105975         return page;
105976  }
105977  
105978 +EXPORT_SYMBOL(find_get_page);
105979 +
105980  /*
105981   * Same as above, but trylock it instead of incrementing the count.
105982   */
105983 @@ -400,6 +477,8 @@ struct page *find_trylock_page(struct ad
105984         return page;
105985  }
105986  
105987 +EXPORT_SYMBOL(find_trylock_page);
105988 +
105989  /**
105990   * find_lock_page - locate, pin and lock a pagecache page
105991   *
105992 @@ -411,8 +490,8 @@ struct page *find_trylock_page(struct ad
105993   *
105994   * Returns zero if the page was not present. find_lock_page() may sleep.
105995   */
105996 -struct page *find_lock_page(struct address_space *mapping,
105997 -                               unsigned long offset)
105998 +struct page *find_lock_page_wq(struct address_space *mapping,
105999 +                               unsigned long offset, wait_queue_t *wait)
106000  {
106001         struct page *page;
106002  
106003 @@ -423,7 +502,10 @@ repeat:
106004                 page_cache_get(page);
106005                 if (TestSetPageLocked(page)) {
106006                         spin_unlock(&mapping->page_lock);
106007 -                       lock_page(page);
106008 +                       if (-EIOCBRETRY == lock_page_wq(page, wait)) {
106009 +                               page_cache_release(page);
106010 +                               return ERR_PTR(-EIOCBRETRY);
106011 +                       }
106012                         spin_lock(&mapping->page_lock);
106013  
106014                         /* Has the page been truncated while we slept? */
106015 @@ -438,6 +520,14 @@ repeat:
106016         return page;
106017  }
106018  
106019 +EXPORT_SYMBOL(find_lock_page);
106020 +
106021 +struct page *find_lock_page(struct address_space *mapping,
106022 +                               unsigned long offset)
106023 +{
106024 +       return find_lock_page_wq(mapping, offset, NULL);
106025 +}
106026 +
106027  /**
106028   * find_or_create_page - locate or add a pagecache page
106029   *
106030 @@ -482,6 +572,8 @@ repeat:
106031         return page;
106032  }
106033  
106034 +EXPORT_SYMBOL(find_or_create_page);
106035 +
106036  /**
106037   * find_get_pages - gang pagecache lookup
106038   * @mapping:   The address_space to search
106039 @@ -496,9 +588,12 @@ repeat:
106040   * The search returns a group of mapping-contiguous pages with ascending
106041   * indexes.  There may be holes in the indices due to not-present pages.
106042   *
106043 - * find_get_pages() returns the number of pages which were found.
106044 + * find_get_pages() returns the number of pages which were found
106045 + * and also atomically sets the next offset to continue looking up
106046 + * mapping contiguous pages from (useful when doing a range of
106047 + * pagevec lookups in chunks of PAGEVEC_SIZE).
106048   */
106049 -unsigned int find_get_pages(struct address_space *mapping, pgoff_t start,
106050 +unsigned int find_get_pages(struct address_space *mapping, pgoff_t *next,
106051                             unsigned int nr_pages, struct page **pages)
106052  {
106053         unsigned int i;
106054 @@ -506,9 +601,12 @@ unsigned int find_get_pages(struct addre
106055  
106056         spin_lock(&mapping->page_lock);
106057         ret = radix_tree_gang_lookup(&mapping->page_tree,
106058 -                               (void **)pages, start, nr_pages);
106059 +                               (void **)pages, *next, nr_pages);
106060         for (i = 0; i < ret; i++)
106061                 page_cache_get(pages[i]);
106062 +       if (ret)
106063 +               *next = pages[ret - 1]->index + 1;
106064 +
106065         spin_unlock(&mapping->page_lock);
106066         return ret;
106067  }
106068 @@ -543,6 +641,8 @@ grab_cache_page_nowait(struct address_sp
106069         return page;
106070  }
106071  
106072 +EXPORT_SYMBOL(grab_cache_page_nowait);
106073 +
106074  /*
106075   * This is a generic file read routine, and uses the
106076   * inode->i_op->readpage() function for the actual low-level
106077 @@ -560,21 +660,47 @@ void do_generic_mapping_read(struct addr
106078                              read_actor_t actor)
106079  {
106080         struct inode *inode = mapping->host;
106081 -       unsigned long index, offset;
106082 +       unsigned long index, offset, first, last, end_index;
106083         struct page *cached_page;
106084 +       loff_t isize = i_size_read(inode);
106085         int error;
106086  
106087         cached_page = NULL;
106088 -       index = *ppos >> PAGE_CACHE_SHIFT;
106089 +       first = *ppos >> PAGE_CACHE_SHIFT;
106090         offset = *ppos & ~PAGE_CACHE_MASK;
106091  
106092 +       last = (*ppos + desc->count) >> PAGE_CACHE_SHIFT;
106093 +       end_index = isize >> PAGE_CACHE_SHIFT;
106094 +       if (last > end_index)
106095 +               last = end_index;
106096 +
106097 +       /* Don't repeat the readahead if we are executing aio retries */
106098 +       if (in_aio()) {
106099 +               if (is_retried_kiocb(io_wait_to_kiocb(current->io_wait)))
106100 +                       goto done_readahead;
106101 +       }
106102 +
106103 +       /*
106104 +        * Let the readahead logic know upfront about all
106105 +        * the pages we'll need to satisfy this request
106106 +        */
106107 +       for (index = first ; index < last; index++)
106108 +               page_cache_readahead(mapping, ra, filp, index);
106109 +
106110 +       if (ra->next_size == -1UL) {
106111 +               /* the readahead window was maximally shrunk */
106112 +               /* explicitly readahead at least what is needed now */
106113 +               for (index = first; index < last; index++)
106114 +                       handle_ra_miss(mapping, ra, index);
106115 +               do_page_cache_readahead(mapping, filp, first, last - first);
106116 +       }
106117 +
106118 +done_readahead:
106119 +       index = first;
106120         for (;;) {
106121                 struct page *page;
106122 -               unsigned long end_index, nr, ret;
106123 -               loff_t isize = i_size_read(inode);
106124 +               unsigned long nr, ret;
106125  
106126 -               end_index = isize >> PAGE_CACHE_SHIFT;
106127 -                       
106128                 if (index > end_index)
106129                         break;
106130                 nr = PAGE_CACHE_SIZE;
106131 @@ -585,7 +711,6 @@ void do_generic_mapping_read(struct addr
106132                 }
106133  
106134                 cond_resched();
106135 -               page_cache_readahead(mapping, ra, filp, index);
106136  
106137                 nr = nr - offset;
106138  find_page:
106139 @@ -635,7 +760,12 @@ page_not_up_to_date:
106140                         goto page_ok;
106141  
106142                 /* Get exclusive access to the page ... */
106143 -               lock_page(page);
106144 +
106145 +               if (lock_page_wq(page, current->io_wait)) {
106146 +                       pr_debug("queued lock page \n");
106147 +                       error = -EIOCBRETRY;
106148 +                       goto sync_error;
106149 +               }
106150  
106151                 /* Did it get unhashed before we got the lock? */
106152                 if (!page->mapping) {
106153 @@ -657,13 +787,23 @@ readpage:
106154                 if (!error) {
106155                         if (PageUptodate(page))
106156                                 goto page_ok;
106157 -                       wait_on_page_locked(page);
106158 +                       if (wait_on_page_locked_wq(page, current->io_wait)) {
106159 +                               pr_debug("queued wait_on_page \n");
106160 +                               error = -EIOCBRETRY;
106161 +                               goto sync_error;
106162 +                       }
106163 +
106164                         if (PageUptodate(page))
106165                                 goto page_ok;
106166                         error = -EIO;
106167                 }
106168  
106169 -               /* UHHUH! A synchronous read error occurred. Report it */
106170 +sync_error:
106171 +               /* We don't have uptodate data in the page yet */
106172 +               /* Could be due to an error or because we need to
106173 +                * retry when we get an async i/o notification.
106174 +                * Report the reason.
106175 +                */
106176                 desc->error = error;
106177                 page_cache_release(page);
106178                 break;
106179 @@ -699,6 +839,8 @@ no_cached_page:
106180         update_atime(inode);
106181  }
106182  
106183 +EXPORT_SYMBOL(do_generic_mapping_read);
106184 +
106185  int file_read_actor(read_descriptor_t *desc, struct page *page,
106186                         unsigned long offset, unsigned long size)
106187  {
106188 @@ -775,7 +917,7 @@ __generic_file_aio_read(struct kiocb *io
106189                 struct address_space *mapping;
106190                 struct inode *inode;
106191  
106192 -               mapping = filp->f_dentry->d_inode->i_mapping;
106193 +               mapping = filp->f_mapping;
106194                 inode = mapping->host;
106195                 retval = 0;
106196                 if (!count)
106197 @@ -815,20 +957,19 @@ __generic_file_aio_read(struct kiocb *io
106198  out:
106199         return retval;
106200  }
106201 +EXPORT_SYMBOL(__generic_file_aio_read);
106202  
106203 -ssize_t
106204 -generic_file_aio_read(struct kiocb *iocb, char __user *buf, size_t count, loff_t pos)
106205 +ssize_t generic_file_aio_read(struct kiocb *iocb, char __user *buf,
106206 +                               size_t count, loff_t pos)
106207  {
106208         struct iovec local_iov = { .iov_base = buf, .iov_len = count };
106209  
106210 -       BUG_ON(iocb->ki_pos != pos);
106211         return __generic_file_aio_read(iocb, &local_iov, 1, &iocb->ki_pos);
106212  }
106213  EXPORT_SYMBOL(generic_file_aio_read);
106214 -EXPORT_SYMBOL(__generic_file_aio_read);
106215  
106216 -ssize_t
106217 -generic_file_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
106218 +ssize_t generic_file_read(struct file *filp, char __user *buf,
106219 +                               size_t count, loff_t *ppos)
106220  {
106221         struct iovec local_iov = { .iov_base = buf, .iov_len = count };
106222         struct kiocb kiocb;
106223 @@ -840,8 +981,10 @@ generic_file_read(struct file *filp, cha
106224                 ret = wait_on_sync_kiocb(&kiocb);
106225         return ret;
106226  }
106227 +EXPORT_SYMBOL(generic_file_read);
106228  
106229 -int file_send_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size)
106230 +int file_send_actor(read_descriptor_t * desc, struct page *page,
106231 +                               unsigned long offset, unsigned long size)
106232  {
106233         ssize_t written;
106234         unsigned long count = desc->count;
106235 @@ -880,6 +1023,8 @@ ssize_t generic_file_sendfile(struct fil
106236         return desc.error;
106237  }
106238  
106239 +EXPORT_SYMBOL(generic_file_sendfile);
106240 +
106241  static ssize_t
106242  do_readahead(struct address_space *mapping, struct file *filp,
106243              unsigned long index, unsigned long nr)
106244 @@ -901,7 +1046,7 @@ asmlinkage ssize_t sys_readahead(int fd,
106245         file = fget(fd);
106246         if (file) {
106247                 if (file->f_mode & FMODE_READ) {
106248 -                       struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
106249 +                       struct address_space *mapping = file->f_mapping;
106250                         unsigned long start = offset >> PAGE_CACHE_SHIFT;
106251                         unsigned long end = (offset + count - 1) >> PAGE_CACHE_SHIFT;
106252                         unsigned long len = end - start + 1;
106253 @@ -920,7 +1065,7 @@ asmlinkage ssize_t sys_readahead(int fd,
106254  static int FASTCALL(page_cache_read(struct file * file, unsigned long offset));
106255  static int page_cache_read(struct file * file, unsigned long offset)
106256  {
106257 -       struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
106258 +       struct address_space *mapping = file->f_mapping;
106259         struct page *page; 
106260         int error;
106261  
106262 @@ -959,7 +1104,7 @@ struct page * filemap_nopage(struct vm_a
106263  {
106264         int error;
106265         struct file *file = area->vm_file;
106266 -       struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
106267 +       struct address_space *mapping = file->f_mapping;
106268         struct file_ra_state *ra = &file->f_ra;
106269         struct inode *inode = mapping->host;
106270         struct page *page;
106271 @@ -1126,10 +1271,12 @@ page_not_uptodate:
106272         return NULL;
106273  }
106274  
106275 +EXPORT_SYMBOL(filemap_nopage);
106276 +
106277  static struct page * filemap_getpage(struct file *file, unsigned long pgoff,
106278                                         int nonblock)
106279  {
106280 -       struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
106281 +       struct address_space *mapping = file->f_mapping;
106282         struct page *page;
106283         int error;
106284  
106285 @@ -1241,7 +1388,7 @@ static int filemap_populate(struct vm_ar
106286                         int nonblock)
106287  {
106288         struct file *file = vma->vm_file;
106289 -       struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
106290 +       struct address_space *mapping = file->f_mapping;
106291         struct inode *inode = mapping->host;
106292         unsigned long size;
106293         struct mm_struct *mm = vma->vm_mm;
106294 @@ -1300,7 +1447,7 @@ static struct vm_operations_struct gener
106295  
106296  int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
106297  {
106298 -       struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
106299 +       struct address_space *mapping = file->f_mapping;
106300         struct inode *inode = mapping->host;
106301  
106302         if (!mapping->a_ops->readpage)
106303 @@ -1330,6 +1477,9 @@ int generic_file_readonly_mmap(struct fi
106304  }
106305  #endif /* CONFIG_MMU */
106306  
106307 +EXPORT_SYMBOL(generic_file_mmap);
106308 +EXPORT_SYMBOL(generic_file_readonly_mmap);
106309 +
106310  static inline struct page *__read_cache_page(struct address_space *mapping,
106311                                 unsigned long index,
106312                                 int (*filler)(void *,struct page*),
106313 @@ -1406,6 +1556,8 @@ retry:
106314         return page;
106315  }
106316  
106317 +EXPORT_SYMBOL(read_cache_page);
106318 +
106319  /*
106320   * If the page was newly created, increment its refcount and add it to the
106321   * caller's lru-buffering pagevec.  This function is specifically for
106322 @@ -1418,7 +1570,9 @@ __grab_cache_page(struct address_space *
106323         int err;
106324         struct page *page;
106325  repeat:
106326 -       page = find_lock_page(mapping, index);
106327 +       page = find_lock_page_wq(mapping, index, current->io_wait);
106328 +       if (IS_ERR(page))
106329 +               return page;
106330         if (!page) {
106331                 if (!*cached_page) {
106332                         *cached_page = page_cache_alloc(mapping);
106333 @@ -1456,6 +1610,8 @@ void remove_suid(struct dentry *dentry)
106334         }
106335  }
106336  
106337 +EXPORT_SYMBOL(remove_suid);
106338 +
106339  /*
106340   * Copy as much as we can into the page and return the number of bytes which
106341   * were sucessfully copied.  If a fault is encountered then clear the page
106342 @@ -1561,9 +1717,9 @@ filemap_set_next_iovec(const struct iove
106343   * Returns appropriate error code that caller should return or
106344   * zero in case that write should be allowed.
106345   */
106346 -inline int generic_write_checks(struct inode *inode,
106347 -               struct file *file, loff_t *pos, size_t *count, int isblk)
106348 +inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk)
106349  {
106350 +       struct inode *inode = file->f_mapping->host;
106351         unsigned long limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
106352  
106353          if (unlikely(*pos < 0))
106354 @@ -1625,7 +1781,7 @@ inline int generic_write_checks(struct i
106355                         *count = inode->i_sb->s_maxbytes - *pos;
106356         } else {
106357                 loff_t isize;
106358 -               if (bdev_read_only(inode->i_bdev))
106359 +               if (bdev_read_only(I_BDEV(inode)))
106360                         return -EPERM;
106361                 isize = i_size_read(inode);
106362                 if (*pos >= isize) {
106363 @@ -1638,10 +1794,12 @@ inline int generic_write_checks(struct i
106364         }
106365         return 0;
106366  }
106367 +
106368  EXPORT_SYMBOL(generic_write_checks);
106369  
106370  /*
106371   * Write to a file through the page cache. 
106372 + * Called under i_sem for S_ISREG files.
106373   *
106374   * We put everything into the page cache prior to writing it. This is not a
106375   * problem when writing full pages. With partial pages, however, we first have
106376 @@ -1650,11 +1808,11 @@ EXPORT_SYMBOL(generic_write_checks);
106377   *                                                     okir@monad.swb.de
106378   */
106379  ssize_t
106380 -generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
106381 +__generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
106382                                 unsigned long nr_segs, loff_t *ppos)
106383  {
106384         struct file *file = iocb->ki_filp;
106385 -       struct address_space * mapping = file->f_dentry->d_inode->i_mapping;
106386 +       struct address_space * mapping = file->f_mapping;
106387         struct address_space_operations *a_ops = mapping->a_ops;
106388         size_t ocount;          /* original count */
106389         size_t count;           /* after file limit checks */
106390 @@ -1701,11 +1859,10 @@ generic_file_aio_write_nolock(struct kio
106391         current->backing_dev_info = mapping->backing_dev_info;
106392         written = 0;
106393  
106394 -       err = generic_write_checks(inode, file, &pos, &count, isblk);
106395 +       err = generic_write_checks(file, &pos, &count, isblk);
106396         if (err)
106397                 goto out;
106398  
106399 -
106400         if (count == 0)
106401                 goto out;
106402  
106403 @@ -1730,12 +1887,19 @@ generic_file_aio_write_nolock(struct kio
106404                 /*
106405                  * Sync the fs metadata but not the minor inode changes and
106406                  * of course not the data as we did direct DMA for the IO.
106407 +                * i_sem is held, which protects generic_osync_inode() from
106408 +                * livelocking.
106409                  */
106410                 if (written >= 0 && file->f_flags & O_SYNC)
106411 -                       status = generic_osync_inode(inode, OSYNC_METADATA);
106412 +                       status = generic_osync_inode(inode, mapping, OSYNC_METADATA);
106413                 if (written >= 0 && !is_sync_kiocb(iocb))
106414                         written = -EIOCBQUEUED;
106415 -               goto out_status;
106416 +               if (written != -ENOTBLK)
106417 +                       goto out_status;
106418 +               /*
106419 +                * direct-io write to a hole: fall through to buffered I/O
106420 +                */
106421 +               written = 0;
106422         }
106423  
106424         buf = iov->iov_base;
106425 @@ -1759,6 +1923,10 @@ generic_file_aio_write_nolock(struct kio
106426                 fault_in_pages_readable(buf, bytes);
106427  
106428                 page = __grab_cache_page(mapping,index,&cached_page,&lru_pvec);
106429 +               if (IS_ERR(page)) {
106430 +                       status = PTR_ERR(page);
106431 +                       break;
106432 +               }
106433                 if (!page) {
106434                         status = -ENOMEM;
106435                         break;
106436 @@ -1807,7 +1975,11 @@ generic_file_aio_write_nolock(struct kio
106437                 page_cache_release(page);
106438                 if (status < 0)
106439                         break;
106440 -               balance_dirty_pages_ratelimited(mapping);
106441 +               status = balance_dirty_pages_ratelimited(mapping);
106442 +               if (status < 0) {
106443 +                       pr_debug("async balance_dirty_pages\n");
106444 +                       break;
106445 +               }
106446                 cond_resched();
106447         } while (count);
106448         *ppos = pos;
106449 @@ -1818,12 +1990,22 @@ generic_file_aio_write_nolock(struct kio
106450         /*
106451          * For now, when the user asks for O_SYNC, we'll actually give O_DSYNC
106452          */
106453 -       if (status >= 0) {
106454 -               if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
106455 -                       status = generic_osync_inode(inode,
106456 -                                       OSYNC_METADATA|OSYNC_DATA);
106457 -       }
106458 +       if (likely(status >= 0)) {
106459 +               if (unlikely((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
106460 +                       if (!a_ops->writepage)
106461 +                               status = generic_osync_inode(inode, mapping,
106462 +                                               OSYNC_METADATA|OSYNC_DATA);
106463 +               }
106464 +       }
106465         
106466 +       /*
106467 +        * If we get here for O_DIRECT writes then we must have fallen through
106468 +        * to buffered writes (block instantiation inside i_size).  So we sync
106469 +        * the file data here, to try to honour O_DIRECT expectations.
106470 +        */
106471 +       if (unlikely(file->f_flags & O_DIRECT) && written)
106472 +               status = filemap_write_and_wait(mapping);
106473 +
106474  out_status:    
106475         err = written ? written : status;
106476  out:
106477 @@ -1832,6 +2014,57 @@ out:
106478         return err;
106479  }
106480  
106481 +EXPORT_SYMBOL(generic_file_aio_write_nolock);
106482 +
106483 +ssize_t
106484 +generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
106485 +                               unsigned long nr_segs, loff_t *ppos)
106486 +{
106487 +       struct file *file = iocb->ki_filp;
106488 +       struct address_space *mapping = file->f_mapping;
106489 +       struct inode *inode = mapping->host;
106490 +       ssize_t ret;
106491 +       loff_t pos = *ppos;
106492 +
106493 +       if (!iov->iov_base && !is_sync_kiocb(iocb)) {
106494 +               /* nothing to transfer, may just need to sync data */
106495 +               ret = iov->iov_len; /* vector AIO not supported yet */
106496 +               goto osync;
106497 +       }
106498 +
106499 +       ret = __generic_file_aio_write_nolock(iocb, iov, nr_segs, ppos);
106500 +
106501 +       /*
106502 +        * Avoid doing a sync in parts for aio - its more efficient to
106503 +        * call in again after all the data has been copied
106504 +        */
106505 +       if (!is_sync_kiocb(iocb))
106506 +               return ret;
106507 +
106508 +osync:
106509 +       if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
106510 +               ret = sync_page_range_nolock(inode, mapping, pos, ret);
106511 +               if (ret >= 0)
106512 +                       *ppos = pos + ret;
106513 +       }
106514 +       return ret;
106515 +}
106516 +
106517 +
106518 +ssize_t
106519 +__generic_file_write_nolock(struct file *file, const struct iovec *iov,
106520 +                               unsigned long nr_segs, loff_t *ppos)
106521 +{
106522 +       struct kiocb kiocb;
106523 +       ssize_t ret;
106524 +
106525 +       init_sync_kiocb(&kiocb, file);
106526 +       ret = __generic_file_aio_write_nolock(&kiocb, iov, nr_segs, ppos);
106527 +       if (-EIOCBQUEUED == ret)
106528 +               ret = wait_on_sync_kiocb(&kiocb);
106529 +       return ret;
106530 +}
106531 +
106532  ssize_t
106533  generic_file_write_nolock(struct file *file, const struct iovec *iov,
106534                                 unsigned long nr_segs, loff_t *ppos)
106535 @@ -1846,39 +2079,69 @@ generic_file_write_nolock(struct file *f
106536         return ret;
106537  }
106538  
106539 +EXPORT_SYMBOL(generic_file_write_nolock);
106540 +
106541  ssize_t generic_file_aio_write(struct kiocb *iocb, const char __user *buf,
106542                                size_t count, loff_t pos)
106543  {
106544         struct file *file = iocb->ki_filp;
106545 -       struct inode *inode = file->f_dentry->d_inode->i_mapping->host;
106546 -       ssize_t err;
106547 -       struct iovec local_iov = { .iov_base = (void __user *)buf, .iov_len = count };
106548 +       struct address_space *mapping = file->f_mapping;
106549 +       struct inode *inode = mapping->host;
106550 +       ssize_t ret;
106551 +       struct iovec local_iov = { .iov_base = (void __user *)buf,
106552 +                                       .iov_len = count };
106553  
106554 -       BUG_ON(iocb->ki_pos != pos);
106555 +       if (!buf && !is_sync_kiocb(iocb)) {
106556 +               /* nothing to transfer, may just need to sync data */
106557 +               ret = count;
106558 +               goto osync;
106559 +       }
106560  
106561         down(&inode->i_sem);
106562 -       err = generic_file_aio_write_nolock(iocb, &local_iov, 1, 
106563 +       ret = __generic_file_aio_write_nolock(iocb, &local_iov, 1,
106564                                                 &iocb->ki_pos);
106565         up(&inode->i_sem);
106566  
106567 -       return err;
106568 +       /*
106569 +        * Avoid doing a sync in parts for aio - its more efficient to
106570 +        * call in again after all the data has been copied
106571 +        */
106572 +       if (!is_sync_kiocb(iocb))
106573 +               return ret;
106574 +
106575 +osync:
106576 +       if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
106577 +               ret = sync_page_range(inode, mapping, pos, ret);
106578 +               if (ret >= 0)
106579 +                       iocb->ki_pos = pos + ret;
106580 +       }
106581 +       return ret;
106582  }
106583  EXPORT_SYMBOL(generic_file_aio_write);
106584 -EXPORT_SYMBOL(generic_file_aio_write_nolock);
106585  
106586  ssize_t generic_file_write(struct file *file, const char __user *buf,
106587                            size_t count, loff_t *ppos)
106588  {
106589 -       struct inode    *inode = file->f_dentry->d_inode->i_mapping->host;
106590 -       ssize_t         err;
106591 -       struct iovec local_iov = { .iov_base = (void __user *)buf, .iov_len = count };
106592 +       struct address_space *mapping = file->f_mapping;
106593 +       struct inode *inode = mapping->host;
106594 +       ssize_t ret;
106595 +       struct iovec local_iov = { .iov_base = (void __user *)buf,
106596 +                                       .iov_len = count };
106597  
106598         down(&inode->i_sem);
106599 -       err = generic_file_write_nolock(file, &local_iov, 1, ppos);
106600 +       ret = __generic_file_write_nolock(file, &local_iov, 1, ppos);
106601         up(&inode->i_sem);
106602  
106603 -       return err;
106604 +       if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
106605 +               ssize_t err;
106606 +
106607 +               err = sync_page_range(inode, mapping, *ppos - ret, ret);
106608 +               if (err < 0)
106609 +                       ret = err;
106610 +       }
106611 +       return ret;
106612  }
106613 +EXPORT_SYMBOL(generic_file_write);
106614  
106615  ssize_t generic_file_readv(struct file *filp, const struct iovec *iov,
106616                         unsigned long nr_segs, loff_t *ppos)
106617 @@ -1893,37 +2156,50 @@ ssize_t generic_file_readv(struct file *
106618         return ret;
106619  }
106620  
106621 +EXPORT_SYMBOL(generic_file_readv);
106622 +
106623  ssize_t generic_file_writev(struct file *file, const struct iovec *iov,
106624 -                       unsigned long nr_segs, loff_t * ppos) 
106625 +                       unsigned long nr_segs, loff_t *ppos)
106626  {
106627 -       struct inode *inode = file->f_dentry->d_inode;
106628 +       struct address_space *mapping = file->f_mapping;
106629 +       struct inode *inode = mapping->host;
106630         ssize_t ret;
106631  
106632         down(&inode->i_sem);
106633 -       ret = generic_file_write_nolock(file, iov, nr_segs, ppos);
106634 +       ret = __generic_file_write_nolock(file, iov, nr_segs, ppos);
106635         up(&inode->i_sem);
106636 +
106637 +       if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
106638 +               ssize_t err;
106639 +
106640 +               err = sync_page_range(inode, mapping, *ppos - ret, ret);
106641 +               if (err < 0)
106642 +                       ret = err;
106643 +       }
106644         return ret;
106645  }
106646  
106647 +EXPORT_SYMBOL(generic_file_writev);
106648 +
106649 +/*
106650 + * Called under i_sem for writes to S_ISREG files
106651 + */
106652  ssize_t
106653  generic_file_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
106654         loff_t offset, unsigned long nr_segs)
106655  {
106656         struct file *file = iocb->ki_filp;
106657 -       struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
106658 +       struct address_space *mapping = file->f_mapping;
106659         ssize_t retval;
106660  
106661 -       if (mapping->nrpages) {
106662 -               retval = filemap_fdatawrite(mapping);
106663 -               if (retval == 0)
106664 -                       retval = filemap_fdatawait(mapping);
106665 -               if (retval)
106666 -                       goto out;
106667 +       retval = filemap_write_and_wait(mapping);
106668 +       if (retval == 0) {
106669 +               retval = mapping->a_ops->direct_IO(rw, iocb, iov,
106670 +                                               offset, nr_segs);
106671 +               if (rw == WRITE && mapping->nrpages)
106672 +                       invalidate_inode_pages2(mapping);
106673         }
106674 -
106675 -       retval = mapping->a_ops->direct_IO(rw, iocb, iov, offset, nr_segs);
106676 -       if (rw == WRITE && mapping->nrpages)
106677 -               invalidate_inode_pages2(mapping);
106678 -out:
106679         return retval;
106680  }
106681 +
106682 +EXPORT_SYMBOL_GPL(generic_file_direct_IO);
106683 --- linux-2.6.0-test6/mm/highmem.c      2003-06-14 12:18:24.000000000 -0700
106684 +++ 25/mm/highmem.c     2003-10-05 00:33:25.000000000 -0700
106685 @@ -24,6 +24,7 @@
106686  #include <linux/blkdev.h>
106687  #include <linux/init.h>
106688  #include <linux/hash.h>
106689 +#include <linux/highmem.h>
106690  #include <asm/pgalloc.h>
106691  #include <asm/tlbflush.h>
106692  
106693 @@ -62,7 +63,7 @@ static void flush_all_zero_pkmaps(void)
106694  {
106695         int i;
106696  
106697 -       flush_cache_all();
106698 +       flush_cache_kmaps();
106699  
106700         for (i = 0; i < LAST_PKMAP; i++) {
106701                 struct page *page;
106702 --- linux-2.6.0-test6/mm/madvise.c      2003-08-08 22:55:14.000000000 -0700
106703 +++ 25/mm/madvise.c     2003-10-05 00:34:07.000000000 -0700
106704 @@ -65,7 +65,7 @@ static long madvise_willneed(struct vm_a
106705                 end = vma->vm_end;
106706         end = ((end - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
106707  
106708 -       force_page_cache_readahead(file->f_dentry->d_inode->i_mapping,
106709 +       force_page_cache_readahead(file->f_mapping,
106710                         file, start, max_sane_readahead(end - start));
106711         return 0;
106712  }
106713 --- linux-2.6.0-test6/mm/Makefile       2003-09-08 13:58:59.000000000 -0700
106714 +++ 25/mm/Makefile      2003-10-05 00:36:48.000000000 -0700
106715 @@ -12,3 +12,6 @@ obj-y                 := bootmem.o filemap.o mempool.o
106716                            slab.o swap.o truncate.o vmscan.o $(mmu-y)
106717  
106718  obj-$(CONFIG_SWAP)     += page_io.o swap_state.o swapfile.o
106719 +
106720 +obj-$(CONFIG_X86_4G) += usercopy.o
106721 +
106722 --- linux-2.6.0-test6/mm/memory.c       2003-09-27 18:57:47.000000000 -0700
106723 +++ 25/mm/memory.c      2003-10-05 00:36:48.000000000 -0700
106724 @@ -100,7 +100,8 @@ static inline void free_one_pmd(struct m
106725         pte_free_tlb(tlb, page);
106726  }
106727  
106728 -static inline void free_one_pgd(struct mmu_gather *tlb, pgd_t * dir)
106729 +static inline void free_one_pgd(struct mmu_gather *tlb, pgd_t * dir,
106730 +                                                       int pgd_idx)
106731  {
106732         int j;
106733         pmd_t * pmd;
106734 @@ -114,8 +115,11 @@ static inline void free_one_pgd(struct m
106735         }
106736         pmd = pmd_offset(dir, 0);
106737         pgd_clear(dir);
106738 -       for (j = 0; j < PTRS_PER_PMD ; j++)
106739 +       for (j = 0; j < PTRS_PER_PMD ; j++) {
106740 +               if (pgd_idx * PGDIR_SIZE + j * PMD_SIZE >= TASK_SIZE)
106741 +                       break;
106742                 free_one_pmd(tlb, pmd+j);
106743 +       }
106744         pmd_free_tlb(tlb, pmd);
106745  }
106746  
106747 @@ -128,11 +132,13 @@ static inline void free_one_pgd(struct m
106748  void clear_page_tables(struct mmu_gather *tlb, unsigned long first, int nr)
106749  {
106750         pgd_t * page_dir = tlb->mm->pgd;
106751 +       int pgd_idx = first;
106752  
106753         page_dir += first;
106754         do {
106755 -               free_one_pgd(tlb, page_dir);
106756 +               free_one_pgd(tlb, page_dir, pgd_idx);
106757                 page_dir++;
106758 +               pgd_idx++;
106759         } while (--nr);
106760  }
106761  
106762 @@ -430,7 +436,7 @@ zap_pmd_range(struct mmu_gather *tlb, pg
106763                 unsigned long address, unsigned long size)
106764  {
106765         pmd_t * pmd;
106766 -       unsigned long end;
106767 +       unsigned long end, pgd_boundary;
106768  
106769         if (pgd_none(*dir))
106770                 return;
106771 @@ -441,8 +447,9 @@ zap_pmd_range(struct mmu_gather *tlb, pg
106772         }
106773         pmd = pmd_offset(dir, address);
106774         end = address + size;
106775 -       if (end > ((address + PGDIR_SIZE) & PGDIR_MASK))
106776 -               end = ((address + PGDIR_SIZE) & PGDIR_MASK);
106777 +       pgd_boundary = ((address + PGDIR_SIZE) & PGDIR_MASK);
106778 +       if (pgd_boundary && (end > pgd_boundary))
106779 +               end = pgd_boundary;
106780         do {
106781                 zap_pte_range(tlb, pmd, address, end - address);
106782                 address = (address + PMD_SIZE) & PMD_MASK; 
106783 @@ -518,7 +525,7 @@ int unmap_vmas(struct mmu_gather **tlbp,
106784                 unsigned long end_addr, unsigned long *nr_accounted)
106785  {
106786         unsigned long zap_bytes = ZAP_BLOCK_SIZE;
106787 -       unsigned long tlb_start;        /* For tlb_finish_mmu */
106788 +       unsigned long tlb_start = 0;    /* For tlb_finish_mmu */
106789         int tlb_start_valid = 0;
106790         int ret = 0;
106791  
106792 @@ -596,6 +603,11 @@ void zap_page_range(struct vm_area_struc
106793         might_sleep();
106794  
106795         if (is_vm_hugetlb_page(vma)) {
106796 +               static int x;
106797 +               if (x < 10) {
106798 +                       x++;
106799 +                       dump_stack();
106800 +               }
106801                 zap_hugepage_range(vma, address, size);
106802                 return;
106803         }
106804 @@ -678,6 +690,7 @@ int get_user_pages(struct task_struct *t
106805                 struct page **pages, struct vm_area_struct **vmas)
106806  {
106807         int i;
106808 +       int vm_io;
106809         unsigned int flags;
106810  
106811         /* 
106812 @@ -734,8 +747,10 @@ int get_user_pages(struct task_struct *t
106813                 }
106814  #endif
106815  
106816 -               if (!vma || (pages && (vma->vm_flags & VM_IO))
106817 -                               || !(flags & vma->vm_flags))
106818 +               if (!vma)
106819 +                       return i ? : -EFAULT;
106820 +               vm_io = vma->vm_flags & VM_IO;
106821 +               if ((pages && vm_io) || !(flags & vma->vm_flags))
106822                         return i ? : -EFAULT;
106823  
106824                 if (is_vm_hugetlb_page(vma)) {
106825 @@ -743,9 +758,17 @@ int get_user_pages(struct task_struct *t
106826                                                 &start, &len, i);
106827                         continue;
106828                 }
106829 +
106830                 spin_lock(&mm->page_table_lock);
106831                 do {
106832 -                       struct page *map;
106833 +                       struct page *map = NULL;
106834 +
106835 +                       /*
106836 +                        * We don't follow pagetables for VM_IO regions - they
106837 +                        * may have no pageframes.
106838 +                        */
106839 +                       if (vm_io)
106840 +                               goto no_follow;
106841                         while (!(map = follow_page(mm, start, write))) {
106842                                 spin_unlock(&mm->page_table_lock);
106843                                 switch (handle_mm_fault(mm,vma,start,write)) {
106844 @@ -777,6 +800,7 @@ int get_user_pages(struct task_struct *t
106845                                 if (!PageReserved(pages[i]))
106846                                         page_cache_get(pages[i]);
106847                         }
106848 +no_follow:
106849                         if (vmas)
106850                                 vmas[i] = vma;
106851                         i++;
106852 @@ -1398,7 +1422,7 @@ do_no_page(struct mm_struct *mm, struct 
106853         spin_unlock(&mm->page_table_lock);
106854  
106855         if (vma->vm_file) {
106856 -               mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
106857 +               mapping = vma->vm_file->f_mapping;
106858                 sequence = atomic_read(&mapping->truncate_count);
106859         }
106860         smp_rmb();  /* Prevent CPU from reordering lock-free ->nopage() */
106861 @@ -1441,6 +1465,7 @@ retry:
106862                 sequence = atomic_read(&mapping->truncate_count);
106863                 spin_unlock(&mm->page_table_lock);
106864                 page_cache_release(new_page);
106865 +               pte_chain_free(pte_chain);
106866                 goto retry;
106867         }
106868         page_table = pte_offset_map(pmd, address);
106869 --- linux-2.6.0-test6/mm/mincore.c      2003-06-14 12:18:48.000000000 -0700
106870 +++ 25/mm/mincore.c     2003-10-05 00:34:07.000000000 -0700
106871 @@ -26,7 +26,7 @@ static unsigned char mincore_page(struct
106872         unsigned long pgoff)
106873  {
106874         unsigned char present = 0;
106875 -       struct address_space * as = vma->vm_file->f_dentry->d_inode->i_mapping;
106876 +       struct address_space * as = vma->vm_file->f_mapping;
106877         struct page * page;
106878  
106879         page = find_get_page(as, pgoff);
106880 --- linux-2.6.0-test6/mm/mmap.c 2003-09-27 18:57:47.000000000 -0700
106881 +++ 25/mm/mmap.c        2003-10-05 00:36:32.000000000 -0700
106882 @@ -79,11 +79,10 @@ static void remove_shared_vm_struct(stru
106883         struct file *file = vma->vm_file;
106884  
106885         if (file) {
106886 -               struct inode *inode = file->f_dentry->d_inode;
106887 -
106888 -               down(&inode->i_mapping->i_shared_sem);
106889 -               __remove_shared_vm_struct(vma, inode);
106890 -               up(&inode->i_mapping->i_shared_sem);
106891 +               struct address_space *mapping = file->f_mapping;
106892 +               down(&mapping->i_shared_sem);
106893 +               __remove_shared_vm_struct(vma, file->f_dentry->d_inode);
106894 +               up(&mapping->i_shared_sem);
106895         }
106896  }
106897  
106898 @@ -234,11 +233,10 @@ static inline void __vma_link_file(struc
106899  
106900         file = vma->vm_file;
106901         if (file) {
106902 -               struct inode * inode = file->f_dentry->d_inode;
106903 -               struct address_space *mapping = inode->i_mapping;
106904 +               struct address_space *mapping = file->f_mapping;
106905  
106906                 if (vma->vm_flags & VM_DENYWRITE)
106907 -                       atomic_dec(&inode->i_writecount);
106908 +                       atomic_dec(&file->f_dentry->d_inode->i_writecount);
106909  
106910                 if (vma->vm_flags & VM_SHARED)
106911                         list_add_tail(&vma->shared, &mapping->i_mmap_shared);
106912 @@ -264,7 +262,7 @@ static void vma_link(struct mm_struct *m
106913         struct address_space *mapping = NULL;
106914  
106915         if (vma->vm_file)
106916 -               mapping = vma->vm_file->f_dentry->d_inode->i_mapping;
106917 +               mapping = vma->vm_file->f_mapping;
106918  
106919         if (mapping)
106920                 down(&mapping->i_shared_sem);
106921 @@ -280,6 +278,26 @@ static void vma_link(struct mm_struct *m
106922  }
106923  
106924  /*
106925 + * Insert vm structure into process list sorted by address and into the inode's
106926 + * i_mmap ring. The caller should hold mm->page_table_lock and
106927 + * ->f_mappping->i_shared_sem if vm_file is non-NULL.
106928 + */
106929 +static void
106930 +__insert_vm_struct(struct mm_struct * mm, struct vm_area_struct * vma)
106931 +{
106932 +       struct vm_area_struct * __vma, * prev;
106933 +       struct rb_node ** rb_link, * rb_parent;
106934 +
106935 +       __vma = find_vma_prepare(mm, vma->vm_start,&prev, &rb_link, &rb_parent);
106936 +       if (__vma && __vma->vm_start < vma->vm_end)
106937 +               BUG();
106938 +       __vma_link(mm, vma, prev, rb_link, rb_parent);
106939 +       mark_mm_hugetlb(mm, vma);
106940 +       mm->map_count++;
106941 +       validate_mm(mm);
106942 +}
106943 +
106944 +/*
106945   * If the vma has a ->close operation then the driver probably needs to release
106946   * per-vma resources, so we don't attempt to merge those.
106947   */
106948 @@ -351,7 +369,8 @@ static int vma_merge(struct mm_struct *m
106949                         unsigned long end, unsigned long vm_flags,
106950                         struct file *file, unsigned long pgoff)
106951  {
106952 -       spinlock_t * lock = &mm->page_table_lock;
106953 +       spinlock_t *lock = &mm->page_table_lock;
106954 +       struct semaphore *i_shared_sem;
106955  
106956         /*
106957          * We later require that vma->vm_flags == vm_flags, so this tests
106958 @@ -360,6 +379,8 @@ static int vma_merge(struct mm_struct *m
106959         if (vm_flags & VM_SPECIAL)
106960                 return 0;
106961  
106962 +       i_shared_sem = file ? &file->f_mapping->i_shared_sem : NULL;
106963 +
106964         if (!prev) {
106965                 prev = rb_entry(rb_parent, struct vm_area_struct, vm_rb);
106966                 goto merge_next;
106967 @@ -377,7 +398,7 @@ static int vma_merge(struct mm_struct *m
106968  
106969                 if (unlikely(file && prev->vm_next &&
106970                                 prev->vm_next->vm_file == file)) {
106971 -                       down(&inode->i_mapping->i_shared_sem);
106972 +                       down(i_shared_sem);
106973                         need_up = 1;
106974                 }
106975                 spin_lock(lock);
106976 @@ -395,7 +416,7 @@ static int vma_merge(struct mm_struct *m
106977                         __remove_shared_vm_struct(next, inode);
106978                         spin_unlock(lock);
106979                         if (need_up)
106980 -                               up(&inode->i_mapping->i_shared_sem);
106981 +                               up(i_shared_sem);
106982                         if (file)
106983                                 fput(file);
106984  
106985 @@ -405,7 +426,7 @@ static int vma_merge(struct mm_struct *m
106986                 }
106987                 spin_unlock(lock);
106988                 if (need_up)
106989 -                       up(&inode->i_mapping->i_shared_sem);
106990 +                       up(i_shared_sem);
106991                 return 1;
106992         }
106993  
106994 @@ -419,14 +440,17 @@ static int vma_merge(struct mm_struct *m
106995                                 pgoff, (end - addr) >> PAGE_SHIFT))
106996                         return 0;
106997                 if (end == prev->vm_start) {
106998 +                       if (file)
106999 +                               down(i_shared_sem); /* invalidate_mmap_range */
107000                         spin_lock(lock);
107001                         prev->vm_start = addr;
107002                         prev->vm_pgoff -= (end - addr) >> PAGE_SHIFT;
107003                         spin_unlock(lock);
107004 +                       if (file)
107005 +                               up(i_shared_sem);
107006                         return 1;
107007                 }
107008         }
107009 -
107010         return 0;
107011  }
107012  
107013 @@ -1136,6 +1160,7 @@ int split_vma(struct mm_struct * mm, str
107014               unsigned long addr, int new_below)
107015  {
107016         struct vm_area_struct *new;
107017 +       struct address_space *mapping = NULL;
107018  
107019         if (mm->map_count >= MAX_MAP_COUNT)
107020                 return -ENOMEM;
107021 @@ -1149,12 +1174,9 @@ int split_vma(struct mm_struct * mm, str
107022  
107023         INIT_LIST_HEAD(&new->shared);
107024  
107025 -       if (new_below) {
107026 +       if (new_below)
107027                 new->vm_end = addr;
107028 -               vma->vm_start = addr;
107029 -               vma->vm_pgoff += ((addr - new->vm_start) >> PAGE_SHIFT);
107030 -       } else {
107031 -               vma->vm_end = addr;
107032 +       else {
107033                 new->vm_start = addr;
107034                 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
107035         }
107036 @@ -1165,7 +1187,25 @@ int split_vma(struct mm_struct * mm, str
107037         if (new->vm_ops && new->vm_ops->open)
107038                 new->vm_ops->open(new);
107039  
107040 -       insert_vm_struct(mm, new);
107041 +       if (vma->vm_file)
107042 +                mapping = vma->vm_file->f_mapping;
107043 +
107044 +       if (mapping)
107045 +               down(&mapping->i_shared_sem);
107046 +       spin_lock(&mm->page_table_lock);
107047 +
107048 +       if (new_below) {
107049 +               vma->vm_start = addr;
107050 +               vma->vm_pgoff += ((addr - new->vm_start) >> PAGE_SHIFT);
107051 +       } else
107052 +               vma->vm_end = addr;
107053 +
107054 +       __insert_vm_struct(mm, new);
107055 +
107056 +       spin_unlock(&mm->page_table_lock);
107057 +       if (mapping)
107058 +               up(&mapping->i_shared_sem);
107059 +
107060         return 0;
107061  }
107062  
107063 --- linux-2.6.0-test6/mm/msync.c        2003-06-14 12:18:07.000000000 -0700
107064 +++ 25/mm/msync.c       2003-10-05 00:34:08.000000000 -0700
107065 @@ -146,20 +146,20 @@ static int msync_interval(struct vm_area
107066                 ret = filemap_sync(vma, start, end-start, flags);
107067  
107068                 if (!ret && (flags & MS_SYNC)) {
107069 -                       struct inode *inode = file->f_dentry->d_inode;
107070 +                       struct address_space *mapping = file->f_mapping;
107071                         int err;
107072  
107073 -                       down(&inode->i_sem);
107074 -                       ret = filemap_fdatawrite(inode->i_mapping);
107075 +                       down(&mapping->host->i_sem);
107076 +                       ret = filemap_fdatawrite(mapping);
107077                         if (file->f_op && file->f_op->fsync) {
107078                                 err = file->f_op->fsync(file,file->f_dentry,1);
107079                                 if (err && !ret)
107080                                         ret = err;
107081                         }
107082 -                       err = filemap_fdatawait(inode->i_mapping);
107083 +                       err = filemap_fdatawait(mapping);
107084                         if (!ret)
107085                                 ret = err;
107086 -                       up(&inode->i_sem);
107087 +                       up(&mapping->host->i_sem);
107088                 }
107089         }
107090         return ret;
107091 --- linux-2.6.0-test6/mm/page_alloc.c   2003-09-27 18:57:47.000000000 -0700
107092 +++ 25/mm/page_alloc.c  2003-10-05 00:34:39.000000000 -0700
107093 @@ -50,7 +50,7 @@ EXPORT_SYMBOL(nr_swap_pages);
107094   * Used by page_zone() to look up the address of the struct zone whose
107095   * id is encoded in the upper bits of page->flags
107096   */
107097 -struct zone *zone_table[MAX_NR_ZONES*MAX_NR_NODES];
107098 +struct zone *zone_table[MAX_NR_ZONES*MAX_NUMNODES];
107099  EXPORT_SYMBOL(zone_table);
107100  
107101  static char *zone_names[MAX_NR_ZONES] = { "DMA", "Normal", "HighMem" };
107102 --- linux-2.6.0-test6/mm/page-writeback.c       2003-09-27 18:57:47.000000000 -0700
107103 +++ 25/mm/page-writeback.c      2003-10-05 00:37:06.000000000 -0700
107104 @@ -28,6 +28,7 @@
107105  #include <linux/smp.h>
107106  #include <linux/sysctl.h>
107107  #include <linux/cpu.h>
107108 +#include <linux/pagevec.h>
107109  
107110  /*
107111   * The maximum number of pages to writeout in a single bdflush/kupdate
107112 @@ -146,7 +147,7 @@ get_dirty_limits(struct page_state *ps, 
107113   * If we're over `background_thresh' then pdflush is woken to perform some
107114   * writeout.
107115   */
107116 -static void balance_dirty_pages(struct address_space *mapping)
107117 +static int balance_dirty_pages(struct address_space *mapping)
107118  {
107119         struct page_state ps;
107120         long nr_reclaimable;
107121 @@ -163,6 +164,7 @@ static void balance_dirty_pages(struct a
107122                         .sync_mode      = WB_SYNC_NONE,
107123                         .older_than_this = NULL,
107124                         .nr_to_write    = write_chunk,
107125 +                       .nonblocking    = !is_sync_wait(current->io_wait)
107126                 };
107127  
107128                 get_dirty_limits(&ps, &background_thresh, &dirty_thresh);
107129 @@ -189,7 +191,11 @@ static void balance_dirty_pages(struct a
107130                         if (pages_written >= write_chunk)
107131                                 break;          /* We've done our duty */
107132                 }
107133 -               blk_congestion_wait(WRITE, HZ/10);
107134 +               if (-EIOCBRETRY == blk_congestion_wait_wq(WRITE, HZ/10,
107135 +                       current->io_wait)) {
107136 +                       pr_debug("async blk congestion wait\n");
107137 +                       return -EIOCBRETRY;
107138 +               }
107139         }
107140  
107141         if (nr_reclaimable + ps.nr_writeback <= dirty_thresh)
107142 @@ -197,6 +203,8 @@ static void balance_dirty_pages(struct a
107143  
107144         if (!writeback_in_progress(bdi) && nr_reclaimable > background_thresh)
107145                 pdflush_operation(background_writeout, 0);
107146 +
107147 +       return 0;
107148  }
107149  
107150  /**
107151 @@ -212,7 +220,7 @@ static void balance_dirty_pages(struct a
107152   * decrease the ratelimiting by a lot, to prevent individual processes from
107153   * overshooting the limit by (ratelimit_pages) each.
107154   */
107155 -void balance_dirty_pages_ratelimited(struct address_space *mapping)
107156 +int balance_dirty_pages_ratelimited(struct address_space *mapping)
107157  {
107158         static DEFINE_PER_CPU(int, ratelimits) = 0;
107159         long ratelimit;
107160 @@ -228,10 +236,10 @@ void balance_dirty_pages_ratelimited(str
107161         if (get_cpu_var(ratelimits)++ >= ratelimit) {
107162                 __get_cpu_var(ratelimits) = 0;
107163                 put_cpu_var(ratelimits);
107164 -               balance_dirty_pages(mapping);
107165 -               return;
107166 +               return balance_dirty_pages(mapping);
107167         }
107168         put_cpu_var(ratelimits);
107169 +       return 0;
107170  }
107171  
107172  /*
107173 @@ -566,3 +574,152 @@ int test_clear_page_dirty(struct page *p
107174         return 0;
107175  }
107176  EXPORT_SYMBOL(test_clear_page_dirty);
107177 +
107178 +
107179 +static ssize_t operate_on_page_range(struct address_space *mapping,
107180 +               loff_t pos, size_t count, int (*operator)(struct page *))
107181 +{
107182 +       pgoff_t first = pos >> PAGE_CACHE_SHIFT;
107183 +       pgoff_t last = (pos + count - 1) >> PAGE_CACHE_SHIFT;   /* inclusive */
107184 +       pgoff_t next = first, curr = first;
107185 +       struct pagevec pvec;
107186 +       ssize_t ret = 0, bytes = 0;
107187 +       int i, nr;
107188 +
107189 +       if (count == 0)
107190 +               return 0;
107191 +
107192 +       pagevec_init(&pvec, 0);
107193 +       while ((nr = pagevec_lookup(&pvec, mapping, &next,
107194 +                               min((pgoff_t)PAGEVEC_SIZE, last - next + 1)))) {
107195 +               for (i = 0; i < pagevec_count(&pvec); i++) {
107196 +                       struct page *page = pvec.pages[i];
107197 +
107198 +                       curr = page->index;
107199 +                       if (page->mapping != mapping) /* truncated ?*/ {
107200 +                               curr = next;
107201 +                               break;
107202 +                       } else {
107203 +                               ret = (*operator)(page);
107204 +                               if (ret == -EIOCBRETRY)
107205 +                                       break;
107206 +                               if (PageError(page)) {
107207 +                                       if (!ret)
107208 +                                               ret = -EIO;
107209 +                               } else
107210 +                                       curr++;
107211 +                       }
107212 +               }
107213 +               pagevec_release(&pvec);
107214 +               if ((ret == -EIOCBRETRY) || (next > last))
107215 +                       break;
107216 +       }
107217 +       if (!nr)
107218 +               curr = last + 1;
107219 +
107220 +       bytes = (curr << PAGE_CACHE_SHIFT) - pos;
107221 +       if (bytes > count)
107222 +               bytes = count;
107223 +       return (bytes && (!ret || (ret == -EIOCBRETRY))) ? bytes : ret;
107224 +}
107225 +
107226 +static int page_waiter(struct page *page)
107227 +{
107228 +       return wait_on_page_writeback_wq(page, current->io_wait);
107229 +}
107230 +
107231 +static size_t
107232 +wait_on_page_range(struct address_space *mapping, loff_t pos, size_t count)
107233 +{
107234 +       return operate_on_page_range(mapping, pos, count, page_waiter);
107235 +}
107236 +
107237 +static int page_writer(struct page *page)
107238 +{
107239 +       struct writeback_control wbc = {
107240 +               .sync_mode      = WB_SYNC_ALL,
107241 +               .nr_to_write    = 1,
107242 +       };
107243 +
107244 +       lock_page(page);
107245 +       if (!page->mapping) {   /* truncated */
107246 +               unlock_page(page);
107247 +               return 0;
107248 +       }
107249 +       if (!test_clear_page_dirty(page)) {
107250 +               unlock_page(page);
107251 +               return 0;
107252 +       }
107253 +       wait_on_page_writeback(page);
107254 +       return page->mapping->a_ops->writepage(page, &wbc);
107255 +}
107256 +
107257 +static ssize_t
107258 +write_out_page_range(struct address_space *mapping, loff_t pos, size_t count)
107259 +{
107260 +       return operate_on_page_range(mapping, pos, count, page_writer);
107261 +}
107262 +
107263 +/*
107264 + * Write and wait upon all the pages in the passed range.  This is a "data
107265 + * integrity" operation.  It waits upon in-flight writeout before starting and
107266 + * waiting upon new writeout.  If there was an IO error, return it.
107267 + *
107268 + * We need to re-take i_sem during the generic_osync_inode list walk because
107269 + * it is otherwise livelockable.
107270 + */
107271 +ssize_t sync_page_range(struct inode *inode, struct address_space *mapping,
107272 +                       loff_t pos, size_t count)
107273 +{
107274 +       int ret = 0;
107275 +
107276 +       if (in_aio()) {
107277 +               /* Already issued writeouts for this iocb ? */
107278 +               if (kiocbTrySync(io_wait_to_kiocb(current->io_wait)))
107279 +                       goto do_wait; /* just need to check if done */
107280 +       }
107281 +       if (!mapping->a_ops->writepage)
107282 +               return 0;
107283 +       if (mapping->backing_dev_info->memory_backed)
107284 +               return 0;
107285 +       ret = write_out_page_range(mapping, pos, count);
107286 +       if (ret >= 0) {
107287 +               down(&inode->i_sem);
107288 +               ret = generic_osync_inode(inode, mapping, OSYNC_METADATA);
107289 +               up(&inode->i_sem);
107290 +       }
107291 +do_wait:
107292 +       if (ret >= 0)
107293 +               ret = wait_on_page_range(mapping, pos, count);
107294 +       return ret;
107295 +}
107296 +
107297 +/*
107298 + * It is really better to use sync_page_range, rather than call
107299 + * sync_page_range_nolock while holding i_sem, if you don't
107300 + * want to block parallel O_SYNC writes until the pages in this
107301 + * range are written out.
107302 + */
107303 +ssize_t sync_page_range_nolock(struct inode *inode, struct address_space
107304 +       *mapping, loff_t pos, size_t count)
107305 +{
107306 +       ssize_t ret = 0;
107307 +
107308 +       if (in_aio()) {
107309 +               /* Already issued writeouts for this iocb ? */
107310 +               if (kiocbTrySync(io_wait_to_kiocb(current->io_wait)))
107311 +                       goto do_wait; /* just need to check if done */
107312 +       }
107313 +       if (!mapping->a_ops->writepage)
107314 +               return 0;
107315 +       if (mapping->backing_dev_info->memory_backed)
107316 +               return 0;
107317 +       ret = write_out_page_range(mapping, pos, count);
107318 +       if (ret >= 0) {
107319 +               ret = generic_osync_inode(inode, mapping, OSYNC_METADATA);
107320 +       }
107321 +do_wait:
107322 +       if (ret >= 0)
107323 +               ret = wait_on_page_range(mapping, pos, count);
107324 +       return ret;
107325 +}
107326 --- linux-2.6.0-test6/mm/pdflush.c      2003-06-14 12:18:52.000000000 -0700
107327 +++ 25/mm/pdflush.c     2003-10-05 00:34:35.000000000 -0700
107328 @@ -84,6 +84,8 @@ struct pdflush_work {
107329         unsigned long when_i_went_to_sleep;
107330  };
107331  
107332 +static int wakeup_count = 100;
107333 +
107334  static int __pdflush(struct pdflush_work *my_work)
107335  {
107336         daemonize("pdflush");
107337 @@ -112,7 +114,10 @@ static int __pdflush(struct pdflush_work
107338  
107339                 spin_lock_irq(&pdflush_lock);
107340                 if (!list_empty(&my_work->list)) {
107341 -                       printk("pdflush: bogus wakeup!\n");
107342 +                       if (wakeup_count > 0) {
107343 +                               wakeup_count--;
107344 +                               printk("pdflush: bogus wakeup!\n");
107345 +                       }
107346                         my_work->fn = NULL;
107347                         continue;
107348                 }
107349 @@ -182,6 +187,7 @@ int pdflush_operation(void (*fn)(unsigne
107350  {
107351         unsigned long flags;
107352         int ret = 0;
107353 +       static int poke_count = 0;
107354  
107355         if (fn == NULL)
107356                 BUG();          /* Hard to diagnose if it's deferred */
107357 @@ -190,9 +196,19 @@ int pdflush_operation(void (*fn)(unsigne
107358         if (list_empty(&pdflush_list)) {
107359                 spin_unlock_irqrestore(&pdflush_lock, flags);
107360                 ret = -1;
107361 +               if (wakeup_count < 100 && poke_count < 10) {
107362 +                       printk("%s: no threads\n", __FUNCTION__);
107363 +                       dump_stack();
107364 +                       poke_count++;
107365 +               }
107366         } else {
107367                 struct pdflush_work *pdf;
107368  
107369 +               if (wakeup_count < 100 && poke_count < 10) {
107370 +                       printk("%s: found a thread\n", __FUNCTION__);
107371 +                       dump_stack();
107372 +                       poke_count++;
107373 +               }
107374                 pdf = list_entry(pdflush_list.next, struct pdflush_work, list);
107375                 list_del_init(&pdf->list);
107376                 if (list_empty(&pdflush_list))
107377 --- linux-2.6.0-test6/mm/shmem.c        2003-09-27 18:57:47.000000000 -0700
107378 +++ 25/mm/shmem.c       2003-10-05 00:34:11.000000000 -0700
107379 @@ -1147,7 +1147,7 @@ shmem_file_write(struct file *file, cons
107380         pos = *ppos;
107381         written = 0;
107382  
107383 -       err = generic_write_checks(inode, file, &pos, &count, 0);
107384 +       err = generic_write_checks(file, &pos, &count, 0);
107385         if (err || !count)
107386                 goto out;
107387  
107388 @@ -1933,6 +1933,7 @@ struct file *shmem_file_setup(char *name
107389         inode->i_nlink = 0;     /* It is unlinked */
107390         file->f_vfsmnt = mntget(shm_mnt);
107391         file->f_dentry = dentry;
107392 +       file->f_mapping = inode->i_mapping;
107393         file->f_op = &shmem_file_operations;
107394         file->f_mode = FMODE_WRITE | FMODE_READ;
107395         return(file);
107396 --- linux-2.6.0-test6/mm/slab.c 2003-09-27 18:57:47.000000000 -0700
107397 +++ 25/mm/slab.c        2003-10-05 00:36:48.000000000 -0700
107398 @@ -250,7 +250,7 @@ struct kmem_cache_s {
107399         unsigned int            limit;
107400  /* 2) touched by every alloc & free from the backend */
107401         struct kmem_list3       lists;
107402 -       /* NUMA: kmem_3list_t   *nodelists[NR_NODES] */
107403 +       /* NUMA: kmem_3list_t   *nodelists[MAX_NUMNODES] */
107404         unsigned int            objsize;
107405         unsigned int            flags;  /* constant flags */
107406         unsigned int            num;    /* # of objs per slab */
107407 @@ -1178,7 +1178,8 @@ next:
107408                 cachep = NULL;
107409                 goto opps;
107410         }
107411 -       slab_size = L1_CACHE_ALIGN(cachep->num*sizeof(kmem_bufctl_t)+sizeof(struct slab));
107412 +       slab_size = L1_CACHE_ALIGN(cachep->num*sizeof(kmem_bufctl_t) +
107413 +                       sizeof(struct slab));
107414  
107415         /*
107416          * If the slab has been placed off-slab, and we have enough space then
107417 @@ -1222,10 +1223,13 @@ next:
107418                          * the cache that's used by kmalloc(24), otherwise
107419                          * the creation of further caches will BUG().
107420                          */
107421 -                       cachep->array[smp_processor_id()] = &initarray_generic.cache;
107422 +                       cachep->array[smp_processor_id()] =
107423 +                                       &initarray_generic.cache;
107424                         g_cpucache_up = PARTIAL;
107425                 } else {
107426 -                       cachep->array[smp_processor_id()] = kmalloc(sizeof(struct arraycache_init),GFP_KERNEL);
107427 +                       cachep->array[smp_processor_id()] =
107428 +                               kmalloc(sizeof(struct arraycache_init),
107429 +                                       GFP_KERNEL);
107430                 }
107431                 BUG_ON(!ac_data(cachep));
107432                 ac_data(cachep)->avail = 0;
107433 @@ -1239,7 +1243,7 @@ next:
107434         } 
107435  
107436         cachep->lists.next_reap = jiffies + REAPTIMEOUT_LIST3 +
107437 -                                       ((unsigned long)cachep)%REAPTIMEOUT_LIST3;
107438 +                               ((unsigned long)cachep)%REAPTIMEOUT_LIST3;
107439  
107440         /* Need the semaphore to access the chain. */
107441         down(&cache_chain_sem);
107442 @@ -1252,16 +1256,24 @@ next:
107443                 list_for_each(p, &cache_chain) {
107444                         kmem_cache_t *pc = list_entry(p, kmem_cache_t, next);
107445                         char tmp;
107446 -                       /* This happens when the module gets unloaded and doesn't
107447 -                          destroy its slab cache and noone else reuses the vmalloc
107448 -                          area of the module. Print a warning. */
107449 -                       if (__get_user(tmp,pc->name)) { 
107450 -                               printk("SLAB: cache with size %d has lost its name\n", 
107451 -                                       pc->objsize); 
107452 +
107453 +                       /*
107454 +                        * This happens when the module gets unloaded and
107455 +                        * doesn't destroy its slab cache and noone else reuses
107456 +                        * the vmalloc area of the module. Print a warning.
107457 +                        */
107458 +#ifdef CONFIG_X86_UACCESS_INDIRECT
107459 +                       if (__direct_get_user(tmp,pc->name)) {
107460 +#else
107461 +                       if (__get_user(tmp,pc->name)) {
107462 +#endif
107463 +                               printk("SLAB: cache with size %d has lost its "
107464 +                                               "name\n", pc->objsize);
107465                                 continue; 
107466                         }       
107467                         if (!strcmp(pc->name,name)) { 
107468 -                               printk("kmem_cache_create: duplicate cache %s\n",name); 
107469 +                               printk("kmem_cache_create: duplicate "
107470 +                                               "cache %s\n",name);
107471                                 up(&cache_chain_sem); 
107472                                 BUG(); 
107473                         }       
107474 @@ -2675,8 +2687,8 @@ struct seq_operations slabinfo_op = {
107475   * slabinfo_write - Tuning for the slab allocator
107476   * @file: unused
107477   * @buffer: user buffer
107478 - * @count: data len
107479 - * @data: unused
107480 + * @count: data length
107481 + * @ppos: unused
107482   */
107483  ssize_t slabinfo_write(struct file *file, const char __user *buffer,
107484                                 size_t count, loff_t *ppos)
107485 --- linux-2.6.0-test6/mm/swap.c 2003-07-10 18:50:32.000000000 -0700
107486 +++ 25/mm/swap.c        2003-10-05 00:37:03.000000000 -0700
107487 @@ -339,12 +339,15 @@ void pagevec_strip(struct pagevec *pvec)
107488   * The search returns a group of mapping-contiguous pages with ascending
107489   * indexes.  There may be holes in the indices due to not-present pages.
107490   *
107491 - * pagevec_lookup() returns the number of pages which were found.
107492 + * pagevec_lookup() returns the number of pages which were found
107493 + * and also atomically sets the next offset to continue looking up
107494 + * mapping contiguous pages from (useful when doing a range of
107495 + * pagevec lookups in chunks of PAGEVEC_SIZE).
107496   */
107497  unsigned int pagevec_lookup(struct pagevec *pvec, struct address_space *mapping,
107498 -               pgoff_t start, unsigned int nr_pages)
107499 +               pgoff_t *next, unsigned int nr_pages)
107500  {
107501 -       pvec->nr = find_get_pages(mapping, start, nr_pages, pvec->pages);
107502 +       pvec->nr = find_get_pages(mapping, next, nr_pages, pvec->pages);
107503         return pagevec_count(pvec);
107504  }
107505  
107506 --- linux-2.6.0-test6/mm/swapfile.c     2003-09-08 13:58:59.000000000 -0700
107507 +++ 25/mm/swapfile.c    2003-10-05 00:34:11.000000000 -0700
107508 @@ -912,7 +912,7 @@ static int setup_swap_extents(struct swa
107509         sector_t last_block;
107510         int ret;
107511  
107512 -       inode = sis->swap_file->f_dentry->d_inode;
107513 +       inode = sis->swap_file->f_mapping->host;
107514         if (S_ISBLK(inode->i_mode)) {
107515                 ret = add_swap_extent(sis, 0, sis->max, 0);
107516                 goto done;
107517 @@ -1031,13 +1031,13 @@ asmlinkage long sys_swapoff(const char _
107518         if (IS_ERR(victim))
107519                 goto out;
107520  
107521 -       mapping = victim->f_dentry->d_inode->i_mapping;
107522 +       mapping = victim->f_mapping;
107523         prev = -1;
107524         swap_list_lock();
107525         for (type = swap_list.head; type >= 0; type = swap_info[type].next) {
107526                 p = swap_info + type;
107527                 if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) {
107528 -                       if (p->swap_file->f_dentry->d_inode->i_mapping==mapping)
107529 +                       if (p->swap_file->f_mapping == mapping)
107530                                 break;
107531                 }
107532                 prev = type;
107533 @@ -1099,13 +1099,12 @@ asmlinkage long sys_swapoff(const char _
107534         swap_device_unlock(p);
107535         swap_list_unlock();
107536         vfree(swap_map);
107537 -       if (S_ISBLK(swap_file->f_dentry->d_inode->i_mode)) {
107538 -               struct block_device *bdev;
107539 -               bdev = swap_file->f_dentry->d_inode->i_bdev;
107540 +       if (S_ISBLK(mapping->host->i_mode)) {
107541 +               struct block_device *bdev = I_BDEV(mapping->host);
107542                 set_blocksize(bdev, p->old_block_size);
107543                 bd_release(bdev);
107544         } else {
107545 -               up(&swap_file->f_dentry->d_inode->i_mapping->host->i_sem);
107546 +               up(&mapping->host->i_sem);
107547         }
107548         filp_close(swap_file, NULL);
107549         err = 0;
107550 @@ -1231,8 +1230,8 @@ asmlinkage long sys_swapon(const char __
107551         int swapfilesize;
107552         unsigned short *swap_map;
107553         struct page *page = NULL;
107554 -       struct inode *inode;
107555 -       struct inode *downed_inode = NULL;
107556 +       struct inode *inode = NULL;
107557 +       int did_down = 0;
107558  
107559         if (!capable(CAP_SYS_ADMIN))
107560                 return -EPERM;
107561 @@ -1279,8 +1278,8 @@ asmlinkage long sys_swapon(const char __
107562         }
107563  
107564         p->swap_file = swap_file;
107565 -       inode = swap_file->f_dentry->d_inode;
107566 -       mapping = swap_file->f_dentry->d_inode->i_mapping;
107567 +       mapping = swap_file->f_mapping;
107568 +       inode = mapping->host;
107569  
107570         error = -EBUSY;
107571         for (i = 0; i < nr_swapfiles; i++) {
107572 @@ -1288,32 +1287,32 @@ asmlinkage long sys_swapon(const char __
107573  
107574                 if (i == type || !q->swap_file)
107575                         continue;
107576 -               if (mapping == q->swap_file->f_dentry->d_inode->i_mapping)
107577 +               if (mapping == q->swap_file->f_mapping)
107578                         goto bad_swap;
107579         }
107580  
107581         error = -EINVAL;
107582         if (S_ISBLK(inode->i_mode)) {
107583 -               bdev = inode->i_bdev;
107584 +               bdev = I_BDEV(inode);
107585                 error = bd_claim(bdev, sys_swapon);
107586                 if (error < 0) {
107587                         bdev = NULL;
107588                         goto bad_swap;
107589                 }
107590                 p->old_block_size = block_size(bdev);
107591 -               error = set_blocksize(inode->i_bdev, PAGE_SIZE);
107592 +               error = set_blocksize(bdev, PAGE_SIZE);
107593                 if (error < 0)
107594                         goto bad_swap;
107595                 p->bdev = bdev;
107596         } else if (S_ISREG(inode->i_mode)) {
107597                 p->bdev = inode->i_sb->s_bdev;
107598 -               downed_inode = mapping->host;
107599 -               down(&downed_inode->i_sem);
107600 +               down(&inode->i_sem);
107601 +               did_down = 1;
107602         } else {
107603                 goto bad_swap;
107604         }
107605  
107606 -       swapfilesize = i_size_read(mapping->host) >> PAGE_SHIFT;
107607 +       swapfilesize = i_size_read(inode) >> PAGE_SHIFT;
107608  
107609         /*
107610          * Read the swap header.
107611 @@ -1461,8 +1460,8 @@ out:
107612         }
107613         if (name)
107614                 putname(name);
107615 -       if (error && downed_inode)
107616 -               up(&downed_inode->i_sem);
107617 +       if (error && did_down)
107618 +               up(&inode->i_sem);
107619         return error;
107620  }
107621  
107622 --- linux-2.6.0-test6/mm/truncate.c     2003-06-14 12:18:34.000000000 -0700
107623 +++ 25/mm/truncate.c    2003-10-05 00:37:03.000000000 -0700
107624 @@ -121,14 +121,10 @@ void truncate_inode_pages(struct address
107625  
107626         pagevec_init(&pvec, 0);
107627         next = start;
107628 -       while (pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)) {
107629 +       while (pagevec_lookup(&pvec, mapping, &next, PAGEVEC_SIZE)) {
107630                 for (i = 0; i < pagevec_count(&pvec); i++) {
107631                         struct page *page = pvec.pages[i];
107632 -                       pgoff_t page_index = page->index;
107633  
107634 -                       if (page_index > next)
107635 -                               next = page_index;
107636 -                       next++;
107637                         if (TestSetPageLocked(page))
107638                                 continue;
107639                         if (PageWriteback(page)) {
107640 @@ -154,7 +150,7 @@ void truncate_inode_pages(struct address
107641  
107642         next = start;
107643         for ( ; ; ) {
107644 -               if (!pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)) {
107645 +               if (!pagevec_lookup(&pvec, mapping, &next, PAGEVEC_SIZE)) {
107646                         if (next == start)
107647                                 break;
107648                         next = start;
107649 @@ -165,9 +161,6 @@ void truncate_inode_pages(struct address
107650  
107651                         lock_page(page);
107652                         wait_on_page_writeback(page);
107653 -                       if (page->index > next)
107654 -                               next = page->index;
107655 -                       next++;
107656                         truncate_complete_page(mapping, page);
107657                         unlock_page(page);
107658                 }
107659 @@ -198,17 +191,13 @@ unsigned long invalidate_mapping_pages(s
107660  
107661         pagevec_init(&pvec, 0);
107662         while (next <= end &&
107663 -                       pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)) {
107664 +                       pagevec_lookup(&pvec, mapping, &next, PAGEVEC_SIZE)) {
107665                 for (i = 0; i < pagevec_count(&pvec); i++) {
107666                         struct page *page = pvec.pages[i];
107667  
107668                         if (TestSetPageLocked(page)) {
107669 -                               next++;
107670                                 continue;
107671                         }
107672 -                       if (page->index > next)
107673 -                               next = page->index;
107674 -                       next++;
107675                         if (PageDirty(page) || PageWriteback(page))
107676                                 goto unlock;
107677                         if (page_mapped(page))
107678 @@ -245,14 +234,13 @@ void invalidate_inode_pages2(struct addr
107679         int i;
107680  
107681         pagevec_init(&pvec, 0);
107682 -       while (pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)) {
107683 +       while (pagevec_lookup(&pvec, mapping, &next, PAGEVEC_SIZE)) {
107684                 for (i = 0; i < pagevec_count(&pvec); i++) {
107685                         struct page *page = pvec.pages[i];
107686  
107687                         lock_page(page);
107688                         if (page->mapping == mapping) { /* truncate race? */
107689                                 wait_on_page_writeback(page);
107690 -                               next = page->index + 1;
107691                                 if (page_mapped(page))
107692                                         clear_page_dirty(page);
107693                                 else
107694 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
107695 +++ 25/mm/usercopy.c    2003-10-05 00:36:48.000000000 -0700
107696 @@ -0,0 +1,279 @@
107697 +/*
107698 + * linux/mm/usercopy.c
107699 + *
107700 + * (C) Copyright 2003 Ingo Molnar
107701 + *
107702 + * Generic implementation of all the user-VM access functions, without
107703 + * relying on being able to access the VM directly.
107704 + */
107705 +
107706 +#include <linux/module.h>
107707 +#include <linux/sched.h>
107708 +#include <linux/errno.h>
107709 +#include <linux/mm.h>
107710 +#include <linux/highmem.h>
107711 +#include <linux/pagemap.h>
107712 +#include <linux/smp_lock.h>
107713 +#include <linux/ptrace.h>
107714 +#include <linux/interrupt.h>
107715 +
107716 +#include <asm/pgtable.h>
107717 +#include <asm/uaccess.h>
107718 +#include <asm/atomic_kmap.h>
107719 +
107720 +/*
107721 + * Get kernel address of the user page and pin it.
107722 + */
107723 +static inline struct page *pin_page(unsigned long addr, int write)
107724 +{
107725 +       struct mm_struct *mm = current->mm ? : &init_mm;
107726 +       struct page *page = NULL;
107727 +       int ret;
107728 +
107729 +       spin_lock(&mm->page_table_lock);
107730 +       /*
107731 +        * Do a quick atomic lookup first - this is the fastpath.
107732 +        */
107733 +       page = follow_page(mm, addr, write);
107734 +       if (likely(page != NULL)) {
107735 +               if (!PageReserved(page))
107736 +                       get_page(page);
107737 +               spin_unlock(&mm->page_table_lock);
107738 +               return page;
107739 +       }
107740 +
107741 +       /*
107742 +        * No luck - bad address or need to fault in the page:
107743 +        */
107744 +       spin_unlock(&mm->page_table_lock);
107745 +
107746 +       /*
107747 +        * In the context of filemap_copy_from_user(), we are not allowed
107748 +        * to sleep.  We must fail this usercopy attempt and allow
107749 +        * filemap_copy_from_user() to recover: drop its atomic kmap and use
107750 +        * a sleeping kmap instead.
107751 +        */
107752 +       if (in_atomic())
107753 +               return NULL;
107754 +
107755 +       down_read(&mm->mmap_sem);
107756 +       ret = get_user_pages(current, mm, addr, 1, write, 0, &page, NULL);
107757 +       up_read(&mm->mmap_sem);
107758 +       if (ret <= 0)
107759 +               return NULL;
107760 +       return page;
107761 +}
107762 +
107763 +static inline void unpin_page(struct page *page)
107764 +{
107765 +       put_page(page);
107766 +}
107767 +
107768 +/*
107769 + * Access another process' address space.
107770 + * Source/target buffer must be kernel space,
107771 + * Do not walk the page table directly, use get_user_pages
107772 + */
107773 +static int rw_vm(unsigned long addr, void *buf, int len, int write)
107774 +{
107775 +       if (!len)
107776 +               return 0;
107777 +
107778 +       /* ignore errors, just check how much was sucessfully transfered */
107779 +       while (len) {
107780 +               struct page *page = NULL;
107781 +               int bytes, offset;
107782 +               void *maddr;
107783 +
107784 +               page = pin_page(addr, write);
107785 +               if (!page)
107786 +                       break;
107787 +
107788 +               bytes = len;
107789 +               offset = addr & (PAGE_SIZE-1);
107790 +               if (bytes > PAGE_SIZE-offset)
107791 +                       bytes = PAGE_SIZE-offset;
107792 +
107793 +               maddr = kmap_atomic(page, KM_USER_COPY);
107794 +
107795 +#define HANDLE_TYPE(type) \
107796 +       case sizeof(type): *(type *)(maddr+offset) = *(type *)(buf); break;
107797 +
107798 +               if (write) {
107799 +                       switch (bytes) {
107800 +                       HANDLE_TYPE(char);
107801 +                       HANDLE_TYPE(int);
107802 +                       HANDLE_TYPE(long long);
107803 +                       default:
107804 +                               memcpy(maddr + offset, buf, bytes);
107805 +                       }
107806 +               } else {
107807 +#undef HANDLE_TYPE
107808 +#define HANDLE_TYPE(type) \
107809 +       case sizeof(type): *(type *)(buf) = *(type *)(maddr+offset); break;
107810 +                       switch (bytes) {
107811 +                       HANDLE_TYPE(char);
107812 +                       HANDLE_TYPE(int);
107813 +                       HANDLE_TYPE(long long);
107814 +                       default:
107815 +                               memcpy(buf, maddr + offset, bytes);
107816 +                       }
107817 +#undef HANDLE_TYPE
107818 +               }
107819 +               kunmap_atomic(maddr, KM_USER_COPY);
107820 +               unpin_page(page);
107821 +               len -= bytes;
107822 +               buf += bytes;
107823 +               addr += bytes;
107824 +       }
107825 +
107826 +       return len;
107827 +}
107828 +
107829 +static int str_vm(unsigned long addr, void *buf0, int len, int copy)
107830 +{
107831 +       struct mm_struct *mm = current->mm ? : &init_mm;
107832 +       struct page *page;
107833 +       void *buf = buf0;
107834 +
107835 +       if (!len)
107836 +               return len;
107837 +
107838 +       down_read(&mm->mmap_sem);
107839 +       /* ignore errors, just check how much was sucessfully transfered */
107840 +       while (len) {
107841 +               int bytes, ret, offset, left, copied;
107842 +               char *maddr;
107843 +
107844 +               ret = get_user_pages(current, mm, addr, 1, copy == 2, 0, &page, NULL);
107845 +               if (ret <= 0) {
107846 +                       up_read(&mm->mmap_sem);
107847 +                       return -EFAULT;
107848 +               }
107849 +
107850 +               bytes = len;
107851 +               offset = addr & (PAGE_SIZE-1);
107852 +               if (bytes > PAGE_SIZE-offset)
107853 +                       bytes = PAGE_SIZE-offset;
107854 +
107855 +               maddr = kmap_atomic(page, KM_USER_COPY);
107856 +               if (copy == 2) {
107857 +                       memset(maddr + offset, 0, bytes);
107858 +                       copied = bytes;
107859 +                       left = 0;
107860 +               } else if (copy == 1) {
107861 +                       left = strncpy_count(buf, maddr + offset, bytes);
107862 +                       copied = bytes - left;
107863 +               } else {
107864 +                       copied = strnlen(maddr + offset, bytes);
107865 +                       left = bytes - copied;
107866 +               }
107867 +               BUG_ON(bytes < 0 || copied < 0);
107868 +               kunmap_atomic(maddr, KM_USER_COPY);
107869 +               page_cache_release(page);
107870 +               len -= copied;
107871 +               buf += copied;
107872 +               addr += copied;
107873 +               if (left)
107874 +                       break;
107875 +       }
107876 +       up_read(&mm->mmap_sem);
107877 +
107878 +       return len;
107879 +}
107880 +
107881 +/*
107882 + * Copies memory from userspace (ptr) into kernelspace (val).
107883 + *
107884 + * returns # of bytes not copied.
107885 + */
107886 +int get_user_size(unsigned int size, void *val, const void *ptr)
107887 +{
107888 +       int ret;
107889 +
107890 +       if (unlikely(segment_eq(get_fs(), KERNEL_DS))) {
107891 +               __direct_copy_from_user(val, ptr, size);
107892 +               return 0;
107893 +       }
107894 +       ret = rw_vm((unsigned long)ptr, val, size, 0);
107895 +       if (ret)
107896 +               /*
107897 +                * Zero the rest:
107898 +                */
107899 +               memset(val + size - ret, 0, ret);
107900 +       return ret;
107901 +}
107902 +
107903 +/*
107904 + * Copies memory from kernelspace (val) into userspace (ptr).
107905 + *
107906 + * returns # of bytes not copied.
107907 + */
107908 +int put_user_size(unsigned int size, const void *val, void *ptr)
107909 +{
107910 +       if (unlikely(segment_eq(get_fs(), KERNEL_DS))) {
107911 +               __direct_copy_to_user(ptr, val, size);
107912 +               return 0;
107913 +       }
107914 +       return rw_vm((unsigned long)ptr, (void *)val, size, 1);
107915 +}
107916 +
107917 +int copy_str_fromuser_size(unsigned int size, void *val, const void *ptr)
107918 +{
107919 +       int copied, left;
107920 +
107921 +       if (unlikely(segment_eq(get_fs(), KERNEL_DS))) {
107922 +               left = strncpy_count(val, ptr, size);
107923 +               copied = size - left;
107924 +               BUG_ON(copied < 0);
107925 +
107926 +               return copied;
107927 +       }
107928 +       left = str_vm((unsigned long)ptr, val, size, 1);
107929 +       if (left < 0)
107930 +               return left;
107931 +       copied = size - left;
107932 +       BUG_ON(copied < 0);
107933 +
107934 +       return copied;
107935 +}
107936 +
107937 +int strlen_fromuser_size(unsigned int size, const void *ptr)
107938 +{
107939 +       int copied, left;
107940 +
107941 +       if (unlikely(segment_eq(get_fs(), KERNEL_DS))) {
107942 +               copied = strnlen(ptr, size) + 1;
107943 +               BUG_ON(copied < 0);
107944 +
107945 +               return copied;
107946 +       }
107947 +       left = str_vm((unsigned long)ptr, NULL, size, 0);
107948 +       if (left < 0)
107949 +               return 0;
107950 +       copied = size - left + 1;
107951 +       BUG_ON(copied < 0);
107952 +
107953 +       return copied;
107954 +}
107955 +
107956 +int zero_user_size(unsigned int size, void *ptr)
107957 +{
107958 +       int left;
107959 +
107960 +       if (unlikely(segment_eq(get_fs(), KERNEL_DS))) {
107961 +               memset(ptr, 0, size);
107962 +               return 0;
107963 +       }
107964 +       left = str_vm((unsigned long)ptr, NULL, size, 2);
107965 +       if (left < 0)
107966 +               return size;
107967 +       return left;
107968 +}
107969 +
107970 +EXPORT_SYMBOL(get_user_size);
107971 +EXPORT_SYMBOL(put_user_size);
107972 +EXPORT_SYMBOL(zero_user_size);
107973 +EXPORT_SYMBOL(copy_str_fromuser_size);
107974 +EXPORT_SYMBOL(strlen_fromuser_size);
107975 +
107976 --- linux-2.6.0-test6/mm/vmalloc.c      2003-08-22 19:23:42.000000000 -0700
107977 +++ 25/mm/vmalloc.c     2003-10-05 00:33:25.000000000 -0700
107978 @@ -135,23 +135,23 @@ static int map_area_pmd(pmd_t *pmd, unsi
107979  
107980  void unmap_vm_area(struct vm_struct *area)
107981  {
107982 -       unsigned long address = VMALLOC_VMADDR(area->addr);
107983 +       unsigned long address = (unsigned long) area->addr;
107984         unsigned long end = (address + area->size);
107985         pgd_t *dir;
107986  
107987         dir = pgd_offset_k(address);
107988 -       flush_cache_all();
107989 +       flush_cache_vunmap(address, end);
107990         do {
107991                 unmap_area_pmd(dir, address, end - address);
107992                 address = (address + PGDIR_SIZE) & PGDIR_MASK;
107993                 dir++;
107994         } while (address && (address < end));
107995 -       flush_tlb_kernel_range(VMALLOC_VMADDR(area->addr), end);
107996 +       flush_tlb_kernel_range((unsigned long) area->addr, end);
107997  }
107998  
107999  int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page ***pages)
108000  {
108001 -       unsigned long address = VMALLOC_VMADDR(area->addr);
108002 +       unsigned long address = (unsigned long) area->addr;
108003         unsigned long end = address + (area->size-PAGE_SIZE);
108004         pgd_t *dir;
108005         int err = 0;
108006 @@ -174,7 +174,7 @@ int map_vm_area(struct vm_struct *area, 
108007         } while (address && (address < end));
108008  
108009         spin_unlock(&init_mm.page_table_lock);
108010 -       flush_cache_all();
108011 +       flush_cache_vmap((unsigned long) area->addr, end);
108012         return err;
108013  }
108014  
108015 --- linux-2.6.0-test6/net/802/fddi.c    2003-06-14 12:18:30.000000000 -0700
108016 +++ 25/net/802/fddi.c   2003-10-05 00:33:25.000000000 -0700
108017 @@ -27,6 +27,7 @@
108018   */
108019   
108020  #include <linux/config.h>
108021 +#include <linux/module.h>
108022  #include <asm/system.h>
108023  #include <linux/types.h>
108024  #include <linux/kernel.h>
108025 @@ -163,3 +164,5 @@ unsigned short fddi_type_trans(struct sk
108026  
108027         return(type);
108028  }
108029 +
108030 +EXPORT_SYMBOL(fddi_type_trans);
108031 --- linux-2.6.0-test6/net/802/hippi.c   2003-06-14 12:18:21.000000000 -0700
108032 +++ 25/net/802/hippi.c  2003-10-05 00:33:25.000000000 -0700
108033 @@ -20,6 +20,7 @@
108034   *             2 of the License, or (at your option) any later version.
108035   */
108036  
108037 +#include <linux/module.h>
108038  #include <linux/types.h>
108039  #include <linux/kernel.h>
108040  #include <linux/sched.h>
108041 @@ -151,3 +152,5 @@ unsigned short hippi_type_trans(struct s
108042  
108043         return hip->snap.ethertype;
108044  }
108045 +
108046 +EXPORT_SYMBOL(hippi_type_trans);
108047 --- linux-2.6.0-test6/net/802/p8023.c   2003-06-14 12:17:57.000000000 -0700
108048 +++ 25/net/802/p8023.c  2003-10-05 00:33:25.000000000 -0700
108049 @@ -12,22 +12,24 @@
108050   *     running raw 802.3 on different devices. Thankfully nobody else
108051   *     has done anything like the old IPX.
108052   */
108053
108054 +
108055 +#include <linux/in.h>
108056 +#include <linux/mm.h>
108057 +#include <linux/module.h>
108058  #include <linux/netdevice.h>
108059  #include <linux/skbuff.h>
108060 +
108061  #include <net/datalink.h>
108062 -#include <linux/mm.h>
108063 -#include <linux/in.h>
108064  
108065  /*
108066   *     Place an 802.3 header on a packet. The driver will do the mac
108067   *     addresses, we just need to give it the buffer length.
108068   */
108069
108070 -static int p8023_request(struct datalink_proto *dl, 
108071 -               struct sk_buff *skb, unsigned char *dest_node)
108072 +static int p8023_request(struct datalink_proto *dl,
108073 +                        struct sk_buff *skb, unsigned char *dest_node)
108074  {
108075 -       struct net_device       *dev = skb->dev;
108076 +       struct net_device *dev = skb->dev;
108077 +
108078         dev->hard_header(skb, dev, ETH_P_802_3, dest_node, NULL, skb->len);
108079         return dev_queue_xmit(skb);
108080  }
108081 @@ -35,16 +37,13 @@ static int p8023_request(struct datalink
108082  /*
108083   *     Create an 802.3 client. Note there can be only one 802.3 client
108084   */
108085
108086  struct datalink_proto *make_8023_client(void)
108087  {
108088 -       struct datalink_proto   *proto;
108089 +       struct datalink_proto *proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
108090  
108091 -       proto = (struct datalink_proto *) kmalloc(sizeof(*proto), GFP_ATOMIC);
108092 -       if (proto != NULL) 
108093 -       {
108094 +       if (proto) {
108095                 proto->header_length = 0;
108096 -               proto->request = p8023_request;
108097 +               proto->request       = p8023_request;
108098         }
108099         return proto;
108100  }
108101 @@ -52,10 +51,11 @@ struct datalink_proto *make_8023_client(
108102  /*
108103   *     Destroy the 802.3 client.
108104   */
108105
108106  void destroy_8023_client(struct datalink_proto *dl)
108107  {
108108         if (dl)
108109                 kfree(dl);
108110  }
108111  
108112 +EXPORT_SYMBOL(destroy_8023_client);
108113 +EXPORT_SYMBOL(make_8023_client);
108114 --- linux-2.6.0-test6/net/802/tr.c      2003-09-27 18:57:47.000000000 -0700
108115 +++ 25/net/802/tr.c     2003-10-05 00:33:25.000000000 -0700
108116 @@ -18,6 +18,7 @@
108117  #include <asm/uaccess.h>
108118  #include <asm/system.h>
108119  #include <linux/config.h>
108120 +#include <linux/module.h>
108121  #include <linux/types.h>
108122  #include <linux/kernel.h>
108123  #include <linux/jiffies.h>
108124 @@ -600,3 +601,6 @@ static int __init rif_init(void)
108125  }
108126  
108127  module_init(rif_init);
108128 +
108129 +EXPORT_SYMBOL(tr_source_route);
108130 +EXPORT_SYMBOL(tr_type_trans);
108131 --- /dev/null   2002-08-30 16:31:37.000000000 -0700
108132 +++ 25/net/bridge/netfilter/ebt_limit.c 2003-10-05 00:33:25.000000000 -0700
108133 @@ -0,0 +1,104 @@
108134 +/*
108135 + *  ebt_limit
108136 + *
108137 + *     Authors:
108138 + *     Tom Marshall <tommy@home.tig-grr.com>
108139 + *
108140 + *     Mostly copied from netfilter's ipt_limit.c, see that file for
108141 + *     more explanation
108142 + *
108143 + *  September, 2003
108144 + *
108145 + */
108146 +
108147 +#include <linux/netfilter_bridge/ebtables.h>
108148 +#include <linux/netfilter_bridge/ebt_limit.h>
108149 +#include <linux/module.h>
108150 +
108151 +#include <linux/netdevice.h>
108152 +#include <linux/spinlock.h>
108153 +
108154 +static spinlock_t limit_lock = SPIN_LOCK_UNLOCKED;
108155 +
108156 +#define CREDITS_PER_JIFFY 128
108157 +
108158 +static int ebt_limit_match(const struct sk_buff *skb,
108159 +   const struct net_device *in, const struct net_device *out,
108160 +   const void *data, unsigned int datalen)
108161 +{
108162 +       struct ebt_limit_info *info = (struct ebt_limit_info *)data;
108163 +       unsigned long now = jiffies;
108164 +
108165 +       spin_lock_bh(&limit_lock);
108166 +       info->credit += (now - xchg(&info->prev, now)) * CREDITS_PER_JIFFY;
108167 +       if (info->credit > info->credit_cap)
108168 +               info->credit = info->credit_cap;
108169 +
108170 +       if (info->credit >= info->cost) {
108171 +               /* We're not limited. */
108172 +               info->credit -= info->cost;
108173 +               spin_unlock_bh(&limit_lock);
108174 +               return EBT_MATCH;
108175 +       }
108176 +
108177 +       spin_unlock_bh(&limit_lock);
108178 +       return EBT_NOMATCH;
108179 +}
108180 +
108181 +/* Precision saver. */
108182 +static u_int32_t
108183 +user2credits(u_int32_t user)
108184 +{
108185 +       /* If multiplying would overflow... */
108186 +       if (user > 0xFFFFFFFF / (HZ*CREDITS_PER_JIFFY))
108187 +               /* Divide first. */
108188 +               return (user / EBT_LIMIT_SCALE) * HZ * CREDITS_PER_JIFFY;
108189 +
108190 +       return (user * HZ * CREDITS_PER_JIFFY) / EBT_LIMIT_SCALE;
108191 +}
108192 +
108193 +static int ebt_limit_check(const char *tablename, unsigned int hookmask,
108194 +   const struct ebt_entry *e, void *data, unsigned int datalen)
108195 +{
108196 +       struct ebt_limit_info *info = (struct ebt_limit_info *)data;
108197 +
108198 +       if (datalen != EBT_ALIGN(sizeof(struct ebt_limit_info)))
108199 +               return -EINVAL;
108200 +
108201 +       /* Check for overflow. */
108202 +       if (info->burst == 0 ||
108203 +           user2credits(info->avg * info->burst) < user2credits(info->avg)) {
108204 +               printk("Overflow in ebt_limit: %u/%u\n",
108205 +                       info->avg, info->burst);
108206 +               return -EINVAL;
108207 +       }
108208 +
108209 +       /* User avg in seconds * EBT_LIMIT_SCALE: convert to jiffies * 128. */
108210 +       info->prev = jiffies;
108211 +       info->credit = user2credits(info->avg * info->burst);
108212 +       info->credit_cap = user2credits(info->avg * info->burst);
108213 +       info->cost = user2credits(info->avg);
108214 +       return 0;
108215 +}
108216 +
108217 +static struct ebt_match ebt_limit_reg =
108218 +{
108219 +       .name           = EBT_LIMIT_MATCH,
108220 +       .match          = ebt_limit_match,
108221 +       .check          = ebt_limit_check,
108222 +       .me             = THIS_MODULE,
108223 +};
108224 +
108225 +static int __init init(void)
108226 +{
108227 +       return ebt_register_match(&ebt_limit_reg);
108228 +}
108229 +
108230 +static void __exit fini(void)
108231 +{
108232 +       ebt_unregister_match(&ebt_limit_reg);
108233 +}
108234 +
108235 +module_init(init);
108236 +module_exit(fini);
108237 +MODULE_LICENSE("GPL");
108238 --- linux-2.6.0-test6/net/bridge/netfilter/ebt_vlan.c   2003-07-27 12:14:40.000000000 -0700
108239 +++ 25/net/bridge/netfilter/ebt_vlan.c  2003-10-05 00:33:25.000000000 -0700
108240 @@ -48,7 +48,7 @@ ebt_filter_vlan(const struct sk_buff *sk
108241                 const void *data, unsigned int datalen)
108242  {
108243         struct ebt_vlan_info *info = (struct ebt_vlan_info *) data;
108244 -       struct vlan_ethhdr frame;
108245 +       struct vlan_hdr frame;
108246  
108247         unsigned short TCI;     /* Whole TCI, given from parsed frame */
108248         unsigned short id;      /* VLAN ID, given from frame TCI */
108249 --- linux-2.6.0-test6/net/bridge/netfilter/Kconfig      2003-09-27 18:57:47.000000000 -0700
108250 +++ 25/net/bridge/netfilter/Kconfig     2003-10-05 00:33:25.000000000 -0700
108251 @@ -73,6 +73,17 @@ config BRIDGE_EBT_IP
108252  
108253           To compile it as a module, choose M here.  If unsure, say N.
108254  
108255 +config BRIDGE_EBT_LIMIT
108256 +       tristate "ebt: limit match support"
108257 +       depends on BRIDGE_NF_EBTABLES
108258 +       help
108259 +         This option adds the limit match, which allows you to control
108260 +         the rate at which a rule can be matched. This match is the
108261 +         equivalent of the iptables limit match.
108262 +
108263 +         If you want to compile it as a module, say M here and read
108264 +         <file:Documentation/modules.txt>.  If unsure, say `N'.
108265 +
108266  config BRIDGE_EBT_MARK
108267         tristate "ebt: mark filter support"
108268         depends on BRIDGE_NF_EBTABLES
108269 --- linux-2.6.0-test6/net/bridge/netfilter/Makefile     2003-09-08 13:58:59.000000000 -0700
108270 +++ 25/net/bridge/netfilter/Makefile    2003-10-05 00:33:25.000000000 -0700
108271 @@ -13,6 +13,7 @@ obj-$(CONFIG_BRIDGE_EBT_T_NAT) += ebtabl
108272  obj-$(CONFIG_BRIDGE_EBT_802_3) += ebt_802_3.o
108273  obj-$(CONFIG_BRIDGE_EBT_ARP) += ebt_arp.o
108274  obj-$(CONFIG_BRIDGE_EBT_IP) += ebt_ip.o
108275 +obj-$(CONFIG_BRIDGE_EBT_LIMIT) += ebt_limit.o
108276  obj-$(CONFIG_BRIDGE_EBT_MARK) += ebt_mark_m.o
108277  obj-$(CONFIG_BRIDGE_EBT_PKTTYPE) += ebt_pkttype.o
108278  obj-$(CONFIG_BRIDGE_EBT_STP) += ebt_stp.o
108279 --- linux-2.6.0-test6/net/core/datagram.c       2003-06-14 12:18:24.000000000 -0700
108280 +++ 25/net/core/datagram.c      2003-10-05 00:33:25.000000000 -0700
108281 @@ -33,6 +33,7 @@
108282   *
108283   */
108284  
108285 +#include <linux/module.h>
108286  #include <linux/types.h>
108287  #include <linux/kernel.h>
108288  #include <asm/uaccess.h>
108289 @@ -485,3 +486,10 @@ unsigned int datagram_poll(struct file *
108290  
108291         return mask;
108292  }
108293 +
108294 +EXPORT_SYMBOL(datagram_poll);
108295 +EXPORT_SYMBOL(skb_copy_and_csum_datagram_iovec);
108296 +EXPORT_SYMBOL(skb_copy_datagram);
108297 +EXPORT_SYMBOL(skb_copy_datagram_iovec);
108298 +EXPORT_SYMBOL(skb_free_datagram);
108299 +EXPORT_SYMBOL(skb_recv_datagram);
108300 --- linux-2.6.0-test6/net/core/dev.c    2003-09-27 18:57:47.000000000 -0700
108301 +++ 25/net/core/dev.c   2003-10-05 00:36:10.000000000 -0700
108302 @@ -111,6 +111,10 @@
108303  #endif /* CONFIG_NET_RADIO */
108304  #include <asm/current.h>
108305  
108306 +#ifdef CONFIG_KGDB
108307 +#include <asm/kgdb.h>
108308 +#endif
108309 +
108310  /* This define, if set, will randomly drop a packet when congestion
108311   * is more than moderate.  It helps fairness in the multi-interface
108312   * case when one of them is a hog, but it kills performance for the
108313 @@ -915,6 +919,8 @@ int unregister_netdevice_notifier(struct
108314  
108315  /**
108316   *     call_netdevice_notifiers - call all network notifier blocks
108317 + *      @val: value passed unmodified to notifier function
108318 + *      @v:   pointer passed unmodified to notifier function
108319   *
108320   *     Call all network notifier blocks.  Parameters and return value
108321   *     are as for notifier_call_chain().
108322 @@ -1322,7 +1328,6 @@ static void sample_queue(unsigned long d
108323  }
108324  #endif
108325  
108326 -
108327  /**
108328   *     netif_rx        -       post buffer to the network code
108329   *     @skb: buffer to post
108330 @@ -1347,6 +1352,21 @@ int netif_rx(struct sk_buff *skb)
108331         struct softnet_data *queue;
108332         unsigned long flags;
108333  
108334 +#ifdef CONFIG_KGDB
108335 +       /* See if kgdb_eth wants this packet */
108336 +       if (!kgdb_net_interrupt(skb)) {
108337 +               /* No.. if we're 'trapped' then junk it */
108338 +               if (kgdb_eth_is_trapped()) {
108339 +                       kfree_skb(skb);
108340 +                       return NET_RX_DROP;
108341 +               }
108342 +       } else {
108343 +               /* kgdb_eth ate the packet... drop it silently */
108344 +               kfree_skb(skb);
108345 +               return NET_RX_DROP;
108346 +       }
108347 +#endif
108348 +
108349         if (!skb->stamp.tv_sec)
108350                 do_gettimeofday(&skb->stamp);
108351  
108352 @@ -1488,6 +1508,18 @@ static void net_tx_action(struct softirq
108353         }
108354  }
108355  
108356 +static __inline__ int deliver_skb(struct sk_buff *skb,
108357 +                                 struct packet_type *pt_prev, int last)
108358 +{
108359 +       if (unlikely(!pt_prev->data))
108360 +               return deliver_to_old_ones(pt_prev, skb, last);
108361 +       else {
108362 +               atomic_inc(&skb->users);
108363 +               return pt_prev->func(skb, skb->dev, pt_prev);
108364 +       }
108365 +}
108366 +
108367 +
108368  #if defined(CONFIG_BRIDGE) || defined (CONFIG_BRIDGE_MODULE)
108369  int (*br_handle_frame_hook)(struct sk_buff *skb);
108370  
108371 @@ -1495,15 +1527,8 @@ static __inline__ int handle_bridge(stru
108372                                      struct packet_type *pt_prev)
108373  {
108374         int ret = NET_RX_DROP;
108375 -
108376 -       if (pt_prev) {
108377 -               if (!pt_prev->data)
108378 -                       ret = deliver_to_old_ones(pt_prev, skb, 0);
108379 -               else {
108380 -                       atomic_inc(&skb->users);
108381 -                       ret = pt_prev->func(skb, skb->dev, pt_prev);
108382 -               }
108383 -       }
108384 +       if (pt_prev)
108385 +               ret = deliver_skb(skb, pt_prev, 0);
108386  
108387         return ret;
108388  }
108389 @@ -1551,16 +1576,8 @@ int netif_receive_skb(struct sk_buff *sk
108390         rcu_read_lock();
108391         list_for_each_entry_rcu(ptype, &ptype_all, list) {
108392                 if (!ptype->dev || ptype->dev == skb->dev) {
108393 -                       if (pt_prev) {
108394 -                               if (!pt_prev->data) {
108395 -                                       ret = deliver_to_old_ones(pt_prev,
108396 -                                                                 skb, 0);
108397 -                               } else {
108398 -                                       atomic_inc(&skb->users);
108399 -                                       ret = pt_prev->func(skb, skb->dev,
108400 -                                                           pt_prev);
108401 -                               }
108402 -                       }
108403 +                       if (pt_prev) 
108404 +                               ret = deliver_skb(skb, pt_prev, 0);
108405                         pt_prev = ptype;
108406                 }
108407         }
108408 @@ -1573,16 +1590,8 @@ int netif_receive_skb(struct sk_buff *sk
108409         list_for_each_entry_rcu(ptype, &ptype_base[ntohs(type)&15], list) {
108410                 if (ptype->type == type &&
108411                     (!ptype->dev || ptype->dev == skb->dev)) {
108412 -                       if (pt_prev) {
108413 -                               if (!pt_prev->data) {
108414 -                                       ret = deliver_to_old_ones(pt_prev,
108415 -                                                                 skb, 0);
108416 -                               } else {
108417 -                                       atomic_inc(&skb->users);
108418 -                                       ret = pt_prev->func(skb, skb->dev,
108419 -                                                           pt_prev);
108420 -                               }
108421 -                       }
108422 +                       if (pt_prev) 
108423 +                               ret = deliver_skb(skb, pt_prev, 0);
108424                         pt_prev = ptype;
108425                 }
108426         }
108427 @@ -1637,8 +1646,8 @@ static int process_backlog(struct net_de
108428  #ifdef CONFIG_NET_HW_FLOWCONTROL
108429                 if (queue->throttle &&
108430                     queue->input_pkt_queue.qlen < no_cong_thresh ) {
108431 +                       queue->throttle = 0;
108432                         if (atomic_dec_and_test(&netdev_dropping)) {
108433 -                               queue->throttle = 0;
108434                                 netdev_wakeup();
108435                                 break;
108436                         }
108437 @@ -3036,3 +3045,63 @@ out:
108438  }
108439  
108440  subsys_initcall(net_dev_init);
108441 +
108442 +EXPORT_SYMBOL(__dev_get);
108443 +EXPORT_SYMBOL(__dev_get_by_flags);
108444 +EXPORT_SYMBOL(__dev_get_by_index);
108445 +EXPORT_SYMBOL(__dev_get_by_name);
108446 +EXPORT_SYMBOL(__dev_remove_pack);
108447 +EXPORT_SYMBOL(__skb_linearize);
108448 +EXPORT_SYMBOL(call_netdevice_notifiers);
108449 +EXPORT_SYMBOL(dev_add_pack);
108450 +EXPORT_SYMBOL(dev_alloc);
108451 +EXPORT_SYMBOL(dev_alloc_name);
108452 +EXPORT_SYMBOL(dev_close);
108453 +EXPORT_SYMBOL(dev_get_by_flags);
108454 +EXPORT_SYMBOL(dev_get_by_index);
108455 +EXPORT_SYMBOL(dev_get_by_name);
108456 +EXPORT_SYMBOL(dev_getbyhwaddr);
108457 +EXPORT_SYMBOL(dev_ioctl);
108458 +EXPORT_SYMBOL(dev_new_index);
108459 +EXPORT_SYMBOL(dev_open);
108460 +EXPORT_SYMBOL(dev_queue_xmit);
108461 +EXPORT_SYMBOL(dev_queue_xmit_nit);
108462 +EXPORT_SYMBOL(dev_remove_pack);
108463 +EXPORT_SYMBOL(dev_set_allmulti);
108464 +EXPORT_SYMBOL(dev_set_promiscuity);
108465 +EXPORT_SYMBOL(free_netdev);
108466 +EXPORT_SYMBOL(netdev_boot_setup_check);
108467 +EXPORT_SYMBOL(netdev_set_master);
108468 +EXPORT_SYMBOL(netdev_state_change);
108469 +EXPORT_SYMBOL(netif_receive_skb);
108470 +EXPORT_SYMBOL(netif_rx);
108471 +EXPORT_SYMBOL(register_gifconf);
108472 +EXPORT_SYMBOL(register_netdevice);
108473 +EXPORT_SYMBOL(register_netdevice_notifier);
108474 +EXPORT_SYMBOL(skb_checksum_help);
108475 +EXPORT_SYMBOL(synchronize_net);
108476 +EXPORT_SYMBOL(unregister_netdevice);
108477 +EXPORT_SYMBOL(unregister_netdevice_notifier);
108478 +
108479 +#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
108480 +EXPORT_SYMBOL(br_handle_frame_hook);
108481 +#endif
108482 +/* for 801q VLAN support */
108483 +#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
108484 +EXPORT_SYMBOL(dev_change_flags);
108485 +#endif
108486 +#ifdef CONFIG_KMOD
108487 +EXPORT_SYMBOL(dev_load);
108488 +#endif
108489 +#ifdef CONFIG_NET_HW_FLOWCONTROL
108490 +EXPORT_SYMBOL(netdev_dropping);
108491 +EXPORT_SYMBOL(netdev_fc_xoff);
108492 +EXPORT_SYMBOL(netdev_register_fc);
108493 +EXPORT_SYMBOL(netdev_unregister_fc);
108494 +#endif
108495 +#ifdef CONFIG_NET_FASTROUTE
108496 +EXPORT_SYMBOL(netdev_fastroute);
108497 +EXPORT_SYMBOL(netdev_fastroute_obstacles);
108498 +#endif
108499 +
108500 +EXPORT_PER_CPU_SYMBOL(softnet_data);
108501 --- linux-2.6.0-test6/net/core/dev_mcast.c      2003-06-14 12:18:06.000000000 -0700
108502 +++ 25/net/core/dev_mcast.c     2003-10-05 00:33:25.000000000 -0700
108503 @@ -22,6 +22,7 @@
108504   */
108505  
108506  #include <linux/config.h> 
108507 +#include <linux/module.h> 
108508  #include <asm/uaccess.h>
108509  #include <asm/system.h>
108510  #include <asm/bitops.h>
108511 @@ -273,3 +274,6 @@ void __init dev_mcast_init(void)
108512  #endif
108513  }
108514  
108515 +EXPORT_SYMBOL(dev_mc_add);
108516 +EXPORT_SYMBOL(dev_mc_delete);
108517 +EXPORT_SYMBOL(dev_mc_upload);
108518 --- linux-2.6.0-test6/net/core/dst.c    2003-06-14 12:18:23.000000000 -0700
108519 +++ 25/net/core/dst.c   2003-10-05 00:33:25.000000000 -0700
108520 @@ -6,15 +6,16 @@
108521   */
108522  
108523  #include <linux/bitops.h>
108524 -#include <linux/types.h>
108525 +#include <linux/errno.h>
108526 +#include <linux/init.h>
108527  #include <linux/kernel.h>
108528 -#include <linux/sched.h>
108529  #include <linux/mm.h>
108530 -#include <linux/string.h>
108531 -#include <linux/errno.h>
108532 +#include <linux/module.h>
108533  #include <linux/netdevice.h>
108534 +#include <linux/sched.h>
108535  #include <linux/skbuff.h>
108536 -#include <linux/init.h>
108537 +#include <linux/string.h>
108538 +#include <linux/types.h>
108539  
108540  #include <net/dst.h>
108541  
108542 @@ -257,3 +258,7 @@ void __init dst_init(void)
108543  {
108544         register_netdevice_notifier(&dst_dev_notifier);
108545  }
108546 +
108547 +EXPORT_SYMBOL(__dst_free);
108548 +EXPORT_SYMBOL(dst_alloc);
108549 +EXPORT_SYMBOL(dst_destroy);
108550 --- linux-2.6.0-test6/net/core/dv.c     2003-09-08 13:58:59.000000000 -0700
108551 +++ 25/net/core/dv.c    2003-10-05 00:33:25.000000000 -0700
108552 @@ -10,6 +10,7 @@
108553   *             Dave Miller:    improvement on the code (correctness, performance and source files)
108554   *
108555   */
108556 +#include <linux/module.h>
108557  #include <linux/types.h>
108558  #include <linux/kernel.h>
108559  #include <linux/sched.h>
108560 @@ -237,7 +238,7 @@ int divert_ioctl(unsigned int cmd, struc
108561  
108562                 default:
108563                         return -EINVAL;
108564 -               };
108565 +               }
108566  
108567                 break;
108568  
108569 @@ -281,7 +282,7 @@ int divert_ioctl(unsigned int cmd, struc
108570  
108571                         default:
108572                                 return -EINVAL;
108573 -                       };
108574 +                       }
108575  
108576                         break;
108577  
108578 @@ -301,7 +302,7 @@ int divert_ioctl(unsigned int cmd, struc
108579  
108580                         default:
108581                                 return -EINVAL;
108582 -                       };
108583 +                       }
108584  
108585                         break;
108586  
108587 @@ -321,7 +322,7 @@ int divert_ioctl(unsigned int cmd, struc
108588  
108589                         default:
108590                                 return -EINVAL;
108591 -                       };
108592 +                       }
108593  
108594                         break;
108595  
108596 @@ -337,7 +338,7 @@ int divert_ioctl(unsigned int cmd, struc
108597  
108598                         default:
108599                                 return -EINVAL;
108600 -                       };
108601 +                       }
108602  
108603                         break;
108604  
108605 @@ -353,7 +354,7 @@ int divert_ioctl(unsigned int cmd, struc
108606  
108607                         default:
108608                                 return -EINVAL;
108609 -                       };
108610 +                       }
108611  
108612                         break;
108613  
108614 @@ -373,7 +374,7 @@ int divert_ioctl(unsigned int cmd, struc
108615  
108616                         default:
108617                                 return -EINVAL;
108618 -                       };
108619 +                       }
108620  
108621                         break;
108622  
108623 @@ -389,7 +390,7 @@ int divert_ioctl(unsigned int cmd, struc
108624  
108625                         default:
108626                                 return -EINVAL;
108627 -                       };
108628 +                       }
108629  
108630                         break;
108631  
108632 @@ -405,7 +406,7 @@ int divert_ioctl(unsigned int cmd, struc
108633  
108634                         default:
108635                                 return -EINVAL;
108636 -                       };
108637 +                       }
108638  
108639                         break;
108640  
108641 @@ -425,19 +426,19 @@ int divert_ioctl(unsigned int cmd, struc
108642  
108643                         default:
108644                                 return -EINVAL;
108645 -                       };
108646 +                       }
108647  
108648                         break;
108649  
108650                 default:
108651                         return -EINVAL;
108652 -               };
108653 +               }
108654  
108655                 break;
108656  
108657         default:
108658                 return -EINVAL;
108659 -       };
108660 +       }
108661  
108662         return 0;
108663  }
108664 @@ -550,8 +551,8 @@ void divert_frame(struct sk_buff *skb)
108665                         }
108666                 }
108667                 break;
108668 -       };
108669 -
108670 -       return;
108671 +       }
108672  }
108673  
108674 +EXPORT_SYMBOL(alloc_divert_blk);
108675 +EXPORT_SYMBOL(free_divert_blk);
108676 --- linux-2.6.0-test6/net/core/ethtool.c        2003-09-08 13:58:59.000000000 -0700
108677 +++ 25/net/core/ethtool.c       2003-10-05 00:33:25.000000000 -0700
108678 @@ -9,6 +9,7 @@
108679   * It's GPL, stupid.
108680   */
108681  
108682 +#include <linux/module.h>
108683  #include <linux/types.h>
108684  #include <linux/errno.h>
108685  #include <linux/ethtool.h>
108686 @@ -727,3 +728,11 @@ int dev_ethtool(struct ifreq *ifr)
108687                 return dev->do_ioctl(dev, ifr, SIOCETHTOOL);
108688         return -EOPNOTSUPP;
108689  }
108690 +
108691 +EXPORT_SYMBOL(ethtool_op_get_link);
108692 +EXPORT_SYMBOL(ethtool_op_get_sg);
108693 +EXPORT_SYMBOL(ethtool_op_get_tso);
108694 +EXPORT_SYMBOL(ethtool_op_get_tx_csum);
108695 +EXPORT_SYMBOL(ethtool_op_set_sg);
108696 +EXPORT_SYMBOL(ethtool_op_set_tso);
108697 +EXPORT_SYMBOL(ethtool_op_set_tx_csum);
108698 --- linux-2.6.0-test6/net/core/filter.c 2003-07-27 12:14:40.000000000 -0700
108699 +++ 25/net/core/filter.c        2003-10-05 00:33:25.000000000 -0700
108700 @@ -424,3 +424,6 @@ int sk_attach_filter(struct sock_fprog *
108701                 sk_filter_release(sk, fp);
108702         return err;
108703  }
108704 +
108705 +EXPORT_SYMBOL(sk_chk_filter);
108706 +EXPORT_SYMBOL(sk_run_filter);
108707 --- linux-2.6.0-test6/net/core/flow.c   2003-06-22 12:04:45.000000000 -0700
108708 +++ 25/net/core/flow.c  2003-10-05 00:33:25.000000000 -0700
108709 @@ -5,6 +5,7 @@
108710   */
108711  
108712  #include <linux/kernel.h>
108713 +#include <linux/module.h>
108714  #include <linux/list.h>
108715  #include <linux/jhash.h>
108716  #include <linux/interrupt.h>
108717 @@ -401,3 +402,6 @@ static int __init flow_cache_init(void)
108718  }
108719  
108720  module_init(flow_cache_init);
108721 +
108722 +EXPORT_SYMBOL(flow_cache_genid);
108723 +EXPORT_SYMBOL(flow_cache_lookup);
108724 --- linux-2.6.0-test6/net/core/iovec.c  2003-06-14 12:18:52.000000000 -0700
108725 +++ 25/net/core/iovec.c 2003-10-05 00:33:25.000000000 -0700
108726 @@ -16,8 +16,8 @@
108727   *             Andi Kleen      :       Fix csum*fromiovecend for IPv6.
108728   */
108729  
108730 -
108731  #include <linux/errno.h>
108732 +#include <linux/module.h>
108733  #include <linux/sched.h>
108734  #include <linux/kernel.h>
108735  #include <linux/mm.h>
108736 @@ -254,3 +254,9 @@ out_fault:
108737         err = -EFAULT;
108738         goto out;
108739  }
108740 +
108741 +EXPORT_SYMBOL(csum_partial_copy_fromiovecend);
108742 +EXPORT_SYMBOL(memcpy_fromiovec);
108743 +EXPORT_SYMBOL(memcpy_fromiovecend);
108744 +EXPORT_SYMBOL(memcpy_toiovec);
108745 +EXPORT_SYMBOL(memcpy_tokerneliovec);
108746 --- linux-2.6.0-test6/net/core/link_watch.c     2003-09-08 13:58:59.000000000 -0700
108747 +++ 25/net/core/link_watch.c    2003-10-05 00:33:25.000000000 -0700
108748 @@ -1,5 +1,5 @@
108749  /*
108750 - * Linux network device link state notifaction
108751 + * Linux network device link state notification
108752   *
108753   * Author:
108754   *     Stefan Rompf <sux@loplof.de>
108755 @@ -12,6 +12,7 @@
108756   */
108757  
108758  #include <linux/config.h>
108759 +#include <linux/module.h>
108760  #include <linux/netdevice.h>
108761  #include <linux/if.h>
108762  #include <linux/rtnetlink.h>
108763 @@ -132,3 +133,4 @@ void linkwatch_fire_event(struct net_dev
108764         }
108765  }
108766  
108767 +EXPORT_SYMBOL(linkwatch_fire_event);
108768 --- linux-2.6.0-test6/net/core/neighbour.c      2003-08-22 19:23:42.000000000 -0700
108769 +++ 25/net/core/neighbour.c     2003-10-05 00:33:25.000000000 -0700
108770 @@ -17,6 +17,7 @@
108771  #include <linux/config.h>
108772  #include <linux/types.h>
108773  #include <linux/kernel.h>
108774 +#include <linux/module.h>
108775  #include <linux/socket.h>
108776  #include <linux/sched.h>
108777  #include <linux/netdevice.h>
108778 @@ -1683,3 +1684,34 @@ void neigh_sysctl_unregister(struct neig
108779  }
108780  
108781  #endif /* CONFIG_SYSCTL */
108782 +
108783 +EXPORT_SYMBOL(__neigh_event_send);
108784 +EXPORT_SYMBOL(neigh_add);
108785 +EXPORT_SYMBOL(neigh_changeaddr);
108786 +EXPORT_SYMBOL(neigh_compat_output);
108787 +EXPORT_SYMBOL(neigh_connected_output);
108788 +EXPORT_SYMBOL(neigh_create);
108789 +EXPORT_SYMBOL(neigh_delete);
108790 +EXPORT_SYMBOL(neigh_destroy);
108791 +EXPORT_SYMBOL(neigh_dump_info);
108792 +EXPORT_SYMBOL(neigh_event_ns);
108793 +EXPORT_SYMBOL(neigh_ifdown);
108794 +EXPORT_SYMBOL(neigh_lookup);
108795 +EXPORT_SYMBOL(neigh_parms_alloc);
108796 +EXPORT_SYMBOL(neigh_parms_release);
108797 +EXPORT_SYMBOL(neigh_rand_reach_time);
108798 +EXPORT_SYMBOL(neigh_resolve_output);
108799 +EXPORT_SYMBOL(neigh_table_clear);
108800 +EXPORT_SYMBOL(neigh_table_init);
108801 +EXPORT_SYMBOL(neigh_update);
108802 +EXPORT_SYMBOL(neigh_update_hhs);
108803 +EXPORT_SYMBOL(pneigh_enqueue);
108804 +EXPORT_SYMBOL(pneigh_lookup);
108805 +
108806 +#ifdef CONFIG_ARPD
108807 +EXPORT_SYMBOL(neigh_app_ns);
108808 +#endif
108809 +#ifdef CONFIG_SYSCTL
108810 +EXPORT_SYMBOL(neigh_sysctl_register);
108811 +EXPORT_SYMBOL(neigh_sysctl_unregister);
108812 +#endif
108813 --- linux-2.6.0-test6/net/core/netfilter.c      2003-09-08 13:58:59.000000000 -0700
108814 +++ 25/net/core/netfilter.c     2003-10-05 00:33:25.000000000 -0700
108815 @@ -759,3 +759,17 @@ void __init netfilter_init(void)
108816                         INIT_LIST_HEAD(&nf_hooks[i][h]);
108817         }
108818  }
108819 +
108820 +EXPORT_SYMBOL(ip_ct_attach);
108821 +EXPORT_SYMBOL(ip_route_me_harder);
108822 +EXPORT_SYMBOL(nf_getsockopt);
108823 +EXPORT_SYMBOL(nf_hook_slow);
108824 +EXPORT_SYMBOL(nf_hooks);
108825 +EXPORT_SYMBOL(nf_register_hook);
108826 +EXPORT_SYMBOL(nf_register_queue_handler);
108827 +EXPORT_SYMBOL(nf_register_sockopt);
108828 +EXPORT_SYMBOL(nf_reinject);
108829 +EXPORT_SYMBOL(nf_setsockopt);
108830 +EXPORT_SYMBOL(nf_unregister_hook);
108831 +EXPORT_SYMBOL(nf_unregister_queue_handler);
108832 +EXPORT_SYMBOL(nf_unregister_sockopt);
108833 --- linux-2.6.0-test6/net/core/rtnetlink.c      2003-09-08 13:58:59.000000000 -0700
108834 +++ 25/net/core/rtnetlink.c     2003-10-05 00:33:25.000000000 -0700
108835 @@ -18,6 +18,7 @@
108836  
108837  #include <linux/config.h>
108838  #include <linux/errno.h>
108839 +#include <linux/module.h>
108840  #include <linux/types.h>
108841  #include <linux/socket.h>
108842  #include <linux/kernel.h>
108843 @@ -556,7 +557,6 @@ struct notifier_block rtnetlink_dev_noti
108844         .notifier_call  = rtnetlink_event,
108845  };
108846  
108847 -
108848  void __init rtnetlink_init(void)
108849  {
108850         rtnl = netlink_kernel_create(NETLINK_ROUTE, rtnetlink_rcv);
108851 @@ -567,3 +567,13 @@ void __init rtnetlink_init(void)
108852         rtnetlink_links[PF_UNSPEC] = link_rtnetlink_table;
108853         rtnetlink_links[PF_PACKET] = link_rtnetlink_table;
108854  }
108855 +
108856 +EXPORT_SYMBOL(__rta_fill);
108857 +EXPORT_SYMBOL(rtattr_parse);
108858 +EXPORT_SYMBOL(rtnetlink_dump_ifinfo);
108859 +EXPORT_SYMBOL(rtnetlink_links);
108860 +EXPORT_SYMBOL(rtnetlink_put_metrics);
108861 +EXPORT_SYMBOL(rtnl);
108862 +EXPORT_SYMBOL(rtnl_lock);
108863 +EXPORT_SYMBOL(rtnl_sem);
108864 +EXPORT_SYMBOL(rtnl_unlock);
108865 --- linux-2.6.0-test6/net/core/scm.c    2003-09-08 13:58:59.000000000 -0700
108866 +++ 25/net/core/scm.c   2003-10-05 00:33:25.000000000 -0700
108867 @@ -9,6 +9,7 @@
108868   *             2 of the License, or (at your option) any later version.
108869   */
108870  
108871 +#include <linux/module.h>
108872  #include <linux/signal.h>
108873  #include <linux/errno.h>
108874  #include <linux/sched.h>
108875 @@ -282,3 +283,9 @@ struct scm_fp_list *scm_fp_dup(struct sc
108876         }
108877         return new_fpl;
108878  }
108879 +
108880 +EXPORT_SYMBOL(__scm_destroy);
108881 +EXPORT_SYMBOL(__scm_send);
108882 +EXPORT_SYMBOL(put_cmsg);
108883 +EXPORT_SYMBOL(scm_detach_fds);
108884 +EXPORT_SYMBOL(scm_fp_dup);
108885 --- linux-2.6.0-test6/net/core/skbuff.c 2003-09-08 13:58:59.000000000 -0700
108886 +++ 25/net/core/skbuff.c        2003-10-05 00:33:25.000000000 -0700
108887 @@ -39,6 +39,7 @@
108888   */
108889  
108890  #include <linux/config.h>
108891 +#include <linux/module.h>
108892  #include <linux/types.h>
108893  #include <linux/kernel.h>
108894  #include <linux/sched.h>
108895 @@ -1103,3 +1104,22 @@ void __init skb_init(void)
108896         if (!skbuff_head_cache)
108897                 panic("cannot create skbuff cache");
108898  }
108899 +
108900 +EXPORT_SYMBOL(___pskb_trim);
108901 +EXPORT_SYMBOL(__kfree_skb);
108902 +EXPORT_SYMBOL(__pskb_pull_tail);
108903 +EXPORT_SYMBOL(alloc_skb);
108904 +EXPORT_SYMBOL(pskb_copy);
108905 +EXPORT_SYMBOL(pskb_expand_head);
108906 +EXPORT_SYMBOL(skb_checksum);
108907 +EXPORT_SYMBOL(skb_clone);
108908 +EXPORT_SYMBOL(skb_clone_fraglist);
108909 +EXPORT_SYMBOL(skb_copy);
108910 +EXPORT_SYMBOL(skb_copy_and_csum_bits);
108911 +EXPORT_SYMBOL(skb_copy_and_csum_dev);
108912 +EXPORT_SYMBOL(skb_copy_bits);
108913 +EXPORT_SYMBOL(skb_copy_expand);
108914 +EXPORT_SYMBOL(skb_over_panic);
108915 +EXPORT_SYMBOL(skb_pad);
108916 +EXPORT_SYMBOL(skb_realloc_headroom);
108917 +EXPORT_SYMBOL(skb_under_panic);
108918 --- linux-2.6.0-test6/net/core/sock.c   2003-06-14 12:18:29.000000000 -0700
108919 +++ 25/net/core/sock.c  2003-10-05 00:33:25.000000000 -0700
108920 @@ -98,6 +98,7 @@
108921  #include <linux/in.h>
108922  #include <linux/kernel.h>
108923  #include <linux/major.h>
108924 +#include <linux/module.h>
108925  #include <linux/sched.h>
108926  #include <linux/timer.h>
108927  #include <linux/string.h>
108928 @@ -1111,3 +1112,40 @@ void sock_init_data(struct socket *sock,
108929  
108930         atomic_set(&sk->sk_refcnt, 1);
108931  }
108932 +
108933 +EXPORT_SYMBOL(__lock_sock);
108934 +EXPORT_SYMBOL(__release_sock);
108935 +EXPORT_SYMBOL(sk_alloc);
108936 +EXPORT_SYMBOL(sk_free);
108937 +EXPORT_SYMBOL(sk_send_sigurg);
108938 +EXPORT_SYMBOL(sock_alloc_send_pskb);
108939 +EXPORT_SYMBOL(sock_alloc_send_skb);
108940 +EXPORT_SYMBOL(sock_getsockopt);
108941 +EXPORT_SYMBOL(sock_init_data);
108942 +EXPORT_SYMBOL(sock_kfree_s);
108943 +EXPORT_SYMBOL(sock_kmalloc);
108944 +EXPORT_SYMBOL(sock_no_accept);
108945 +EXPORT_SYMBOL(sock_no_bind);
108946 +EXPORT_SYMBOL(sock_no_connect);
108947 +EXPORT_SYMBOL(sock_no_getname);
108948 +EXPORT_SYMBOL(sock_no_getsockopt);
108949 +EXPORT_SYMBOL(sock_no_ioctl);
108950 +EXPORT_SYMBOL(sock_no_listen);
108951 +EXPORT_SYMBOL(sock_no_mmap);
108952 +EXPORT_SYMBOL(sock_no_poll);
108953 +EXPORT_SYMBOL(sock_no_recvmsg);
108954 +EXPORT_SYMBOL(sock_no_release);
108955 +EXPORT_SYMBOL(sock_no_sendmsg);
108956 +EXPORT_SYMBOL(sock_no_sendpage);
108957 +EXPORT_SYMBOL(sock_no_setsockopt);
108958 +EXPORT_SYMBOL(sock_no_shutdown);
108959 +EXPORT_SYMBOL(sock_no_socketpair);
108960 +EXPORT_SYMBOL(sock_rfree);
108961 +EXPORT_SYMBOL(sock_rmalloc);
108962 +EXPORT_SYMBOL(sock_setsockopt);
108963 +EXPORT_SYMBOL(sock_wfree);
108964 +EXPORT_SYMBOL(sock_wmalloc);
108965 +#ifdef CONFIG_SYSCTL
108966 +EXPORT_SYMBOL(sysctl_rmem_max);
108967 +EXPORT_SYMBOL(sysctl_wmem_max);
108968 +#endif
108969 --- linux-2.6.0-test6/net/core/utils.c  2003-06-14 12:17:55.000000000 -0700
108970 +++ 25/net/core/utils.c 2003-10-05 00:33:25.000000000 -0700
108971 @@ -13,13 +13,15 @@
108972   *      2 of the License, or (at your option) any later version.
108973   */
108974  
108975 -#include <asm/uaccess.h>
108976 -#include <asm/system.h>
108977 -#include <linux/types.h>
108978 -#include <linux/kernel.h>
108979 +#include <linux/module.h>
108980  #include <linux/jiffies.h>
108981 -#include <linux/string.h>
108982 +#include <linux/kernel.h>
108983  #include <linux/mm.h>
108984 +#include <linux/string.h>
108985 +#include <linux/types.h>
108986 +
108987 +#include <asm/system.h>
108988 +#include <asm/uaccess.h>
108989  
108990  static unsigned long net_rand_seed = 152L;
108991  
108992 @@ -71,3 +73,7 @@ int net_ratelimit(void)
108993         spin_unlock_irqrestore(&ratelimit_lock, flags);
108994         return 0;
108995  }
108996 +
108997 +EXPORT_SYMBOL(net_random);
108998 +EXPORT_SYMBOL(net_ratelimit);
108999 +EXPORT_SYMBOL(net_srandom);
109000 --- linux-2.6.0-test6/net/core/wireless.c       2003-09-27 18:57:47.000000000 -0700
109001 +++ 25/net/core/wireless.c      2003-10-05 00:33:25.000000000 -0700
109002 @@ -1365,3 +1365,10 @@ void wireless_spy_update(struct net_devi
109003  #endif /* IW_WIRELESS_THRSPY */
109004  #endif /* IW_WIRELESS_SPY */
109005  }
109006 +
109007 +EXPORT_SYMBOL(iw_handler_get_spy);
109008 +EXPORT_SYMBOL(iw_handler_get_thrspy);
109009 +EXPORT_SYMBOL(iw_handler_set_spy);
109010 +EXPORT_SYMBOL(iw_handler_set_thrspy);
109011 +EXPORT_SYMBOL(wireless_send_event);
109012 +EXPORT_SYMBOL(wireless_spy_update);
109013 --- linux-2.6.0-test6/net/ethernet/eth.c        2003-06-22 12:04:45.000000000 -0700
109014 +++ 25/net/ethernet/eth.c       2003-10-05 00:33:25.000000000 -0700
109015 @@ -37,6 +37,7 @@
109016   *             as published by the Free Software Foundation; either version
109017   *             2 of the License, or (at your option) any later version.
109018   */
109019 +#include <linux/module.h>
109020  #include <linux/types.h>
109021  #include <linux/kernel.h>
109022  #include <linux/sched.h>
109023 @@ -241,3 +242,5 @@ void eth_header_cache_update(struct hh_c
109024         memcpy(((u8*)hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)),
109025                haddr, dev->addr_len);
109026  }
109027 +
109028 +EXPORT_SYMBOL(eth_type_trans);
109029 --- linux-2.6.0-test6/net/ethernet/pe2.c        2003-06-14 12:18:51.000000000 -0700
109030 +++ 25/net/ethernet/pe2.c       2003-10-05 00:33:25.000000000 -0700
109031 @@ -1,27 +1,28 @@
109032 +#include <linux/in.h>
109033 +#include <linux/mm.h>
109034 +#include <linux/module.h>
109035  #include <linux/netdevice.h>
109036  #include <linux/skbuff.h>
109037 +
109038  #include <net/datalink.h>
109039 -#include <linux/mm.h>
109040 -#include <linux/in.h>
109041  
109042 -static int pEII_request(struct datalink_proto *dl, 
109043 -               struct sk_buff *skb, unsigned char *dest_node)
109044 +static int pEII_request(struct datalink_proto *dl,
109045 +                       struct sk_buff *skb, unsigned char *dest_node)
109046  {
109047 -       struct net_device       *dev = skb->dev;
109048 +       struct net_device *dev = skb->dev;
109049  
109050 -       skb->protocol = htons (ETH_P_IPX);
109051 -       if(dev->hard_header)
109052 -               dev->hard_header(skb, dev, ETH_P_IPX, dest_node, NULL, skb->len);
109053 +       skb->protocol = htons(ETH_P_IPX);
109054 +       if (dev->hard_header)
109055 +               dev->hard_header(skb, dev, ETH_P_IPX,
109056 +                                dest_node, NULL, skb->len);
109057         return dev_queue_xmit(skb);
109058  }
109059  
109060 -struct datalink_proto *
109061 -make_EII_client(void)
109062 +struct datalink_proto *make_EII_client(void)
109063  {
109064 -       struct datalink_proto   *proto;
109065 +       struct datalink_proto *proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
109066  
109067 -       proto = (struct datalink_proto *) kmalloc(sizeof(*proto), GFP_ATOMIC);
109068 -       if (proto != NULL) {
109069 +       if (proto) {
109070                 proto->header_length = 0;
109071                 proto->request = pEII_request;
109072         }
109073 @@ -34,3 +35,6 @@ void destroy_EII_client(struct datalink_
109074         if (dl)
109075                 kfree(dl);
109076  }
109077 +
109078 +EXPORT_SYMBOL(destroy_EII_client);
109079 +EXPORT_SYMBOL(make_EII_client);
109080 --- linux-2.6.0-test6/net/ipv4/af_inet.c        2003-09-08 13:58:59.000000000 -0700
109081 +++ 25/net/ipv4/af_inet.c       2003-10-05 00:33:25.000000000 -0700
109082 @@ -74,6 +74,7 @@
109083  #include <linux/in.h>
109084  #include <linux/kernel.h>
109085  #include <linux/major.h>
109086 +#include <linux/module.h>
109087  #include <linux/sched.h>
109088  #include <linux/timer.h>
109089  #include <linux/string.h>
109090 @@ -1246,4 +1247,33 @@ int __init ipv4_proc_init(void)
109091         return 0;
109092  }
109093  #endif /* CONFIG_PROC_FS */
109094 +
109095  MODULE_ALIAS_NETPROTO(PF_INET);
109096 +
109097 +EXPORT_SYMBOL(inet_accept);
109098 +EXPORT_SYMBOL(inet_bind);
109099 +EXPORT_SYMBOL(inet_dgram_connect);
109100 +EXPORT_SYMBOL(inet_dgram_ops);
109101 +EXPORT_SYMBOL(inet_family_ops);
109102 +EXPORT_SYMBOL(inet_getname);
109103 +EXPORT_SYMBOL(inet_getsockopt);
109104 +EXPORT_SYMBOL(inet_ioctl);
109105 +EXPORT_SYMBOL(inet_listen);
109106 +EXPORT_SYMBOL(inet_recvmsg);
109107 +EXPORT_SYMBOL(inet_register_protosw);
109108 +EXPORT_SYMBOL(inet_release);
109109 +EXPORT_SYMBOL(inet_sendmsg);
109110 +EXPORT_SYMBOL(inet_setsockopt);
109111 +EXPORT_SYMBOL(inet_shutdown);
109112 +EXPORT_SYMBOL(inet_sock_destruct);
109113 +EXPORT_SYMBOL(inet_sock_release);
109114 +EXPORT_SYMBOL(inet_stream_connect);
109115 +EXPORT_SYMBOL(inet_stream_ops);
109116 +EXPORT_SYMBOL(inet_unregister_protosw);
109117 +EXPORT_SYMBOL(net_statistics);
109118 +EXPORT_SYMBOL(tcp_protocol);
109119 +EXPORT_SYMBOL(udp_protocol);
109120 +
109121 +#ifdef INET_REFCNT_DEBUG
109122 +EXPORT_SYMBOL(inet_sock_nr);
109123 +#endif
109124 --- linux-2.6.0-test6/net/ipv4/arp.c    2003-09-27 18:57:47.000000000 -0700
109125 +++ 25/net/ipv4/arp.c   2003-10-05 00:33:25.000000000 -0700
109126 @@ -69,6 +69,7 @@
109127   *             Arnaldo C. Melo :       convert /proc/net/arp to seq_file
109128   */
109129  
109130 +#include <linux/module.h>
109131  #include <linux/types.h>
109132  #include <linux/string.h>
109133  #include <linux/kernel.h>
109134 @@ -630,12 +631,6 @@ int arp_process(struct sk_buff *skb)
109135         if (in_dev == NULL)
109136                 goto out;
109137  
109138 -       /* ARP header, plus 2 device addresses, plus 2 IP addresses.  */
109139 -       if (!pskb_may_pull(skb, (sizeof(struct arphdr) +
109140 -                                (2 * dev->addr_len) +
109141 -                                (2 * sizeof(u32)))))
109142 -               goto out;
109143 -
109144         arp = skb->nh.arph;
109145  
109146         switch (dev_type) {
109147 @@ -835,8 +830,15 @@ out:
109148  
109149  int arp_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
109150  {
109151 -       struct arphdr *arp = skb->nh.arph;
109152 +       struct arphdr *arp;
109153 +
109154 +       /* ARP header, plus 2 device addresses, plus 2 IP addresses.  */
109155 +       if (!pskb_may_pull(skb, (sizeof(struct arphdr) +
109156 +                                (2 * dev->addr_len) +
109157 +                                (2 * sizeof(u32)))))
109158 +               goto freeskb;
109159  
109160 +       arp = skb->nh.arph;
109161         if (arp->ar_hln != dev->addr_len ||
109162             dev->flags & IFF_NOARP ||
109163             skb->pkt_type == PACKET_OTHERHOST ||
109164 @@ -1429,3 +1431,13 @@ static int __init arp_proc_init(void)
109165  }
109166  
109167  #endif /* CONFIG_PROC_FS */
109168 +
109169 +EXPORT_SYMBOL(arp_broken_ops);
109170 +EXPORT_SYMBOL(arp_find);
109171 +EXPORT_SYMBOL(arp_rcv);
109172 +EXPORT_SYMBOL(arp_send);
109173 +EXPORT_SYMBOL(arp_tbl);
109174 +
109175 +#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
109176 +EXPORT_SYMBOL(clip_tbl_hook);
109177 +#endif
109178 --- linux-2.6.0-test6/net/ipv4/devinet.c        2003-08-22 19:23:42.000000000 -0700
109179 +++ 25/net/ipv4/devinet.c       2003-10-05 00:33:25.000000000 -0700
109180 @@ -32,6 +32,7 @@
109181  #include <asm/uaccess.h>
109182  #include <asm/system.h>
109183  #include <asm/bitops.h>
109184 +#include <linux/module.h>
109185  #include <linux/types.h>
109186  #include <linux/kernel.h>
109187  #include <linux/sched.h>
109188 @@ -1354,3 +1355,11 @@ void __init devinet_init(void)
109189         devinet_sysctl_register(NULL, &ipv4_devconf_dflt);
109190  #endif
109191  }
109192 +
109193 +EXPORT_SYMBOL(devinet_ioctl);
109194 +EXPORT_SYMBOL(in_dev_finish_destroy);
109195 +EXPORT_SYMBOL(inet_select_addr);
109196 +EXPORT_SYMBOL(inetdev_by_index);
109197 +EXPORT_SYMBOL(inetdev_lock);
109198 +EXPORT_SYMBOL(register_inetaddr_notifier);
109199 +EXPORT_SYMBOL(unregister_inetaddr_notifier);
109200 --- linux-2.6.0-test6/net/ipv4/fib_frontend.c   2003-06-14 12:18:51.000000000 -0700
109201 +++ 25/net/ipv4/fib_frontend.c  2003-10-05 00:33:25.000000000 -0700
109202 @@ -16,6 +16,7 @@
109203   */
109204  
109205  #include <linux/config.h>
109206 +#include <linux/module.h>
109207  #include <asm/uaccess.h>
109208  #include <asm/system.h>
109209  #include <asm/bitops.h>
109210 @@ -605,3 +606,6 @@ void __init ip_fib_init(void)
109211         register_inetaddr_notifier(&fib_inetaddr_notifier);
109212  }
109213  
109214 +EXPORT_SYMBOL(inet_addr_type);
109215 +EXPORT_SYMBOL(ip_dev_find);
109216 +EXPORT_SYMBOL(ip_rt_ioctl);
109217 --- linux-2.6.0-test6/net/ipv4/icmp.c   2003-09-27 18:57:47.000000000 -0700
109218 +++ 25/net/ipv4/icmp.c  2003-10-05 00:33:25.000000000 -0700
109219 @@ -65,6 +65,7 @@
109220   */
109221  
109222  #include <linux/config.h>
109223 +#include <linux/module.h>
109224  #include <linux/types.h>
109225  #include <linux/jiffies.h>
109226  #include <linux/kernel.h>
109227 @@ -1126,3 +1127,8 @@ void __init icmp_init(struct net_proto_f
109228                 per_cpu(__icmp_socket, i)->sk->sk_prot->unhash(per_cpu(__icmp_socket, i)->sk);
109229         }
109230  }
109231 +
109232 +EXPORT_SYMBOL(icmp_err_convert);
109233 +EXPORT_SYMBOL(icmp_send);
109234 +EXPORT_SYMBOL(icmp_statistics);
109235 +EXPORT_SYMBOL(xrlim_allow);
109236 --- linux-2.6.0-test6/net/ipv4/igmp.c   2003-09-27 18:57:47.000000000 -0700
109237 +++ 25/net/ipv4/igmp.c  2003-10-05 00:33:25.000000000 -0700
109238 @@ -72,8 +72,8 @@
109239   *                                     Vinay Kulkarni
109240   */
109241  
109242 -
109243  #include <linux/config.h>
109244 +#include <linux/module.h>
109245  #include <asm/uaccess.h>
109246  #include <asm/system.h>
109247  #include <linux/types.h>
109248 @@ -2438,3 +2438,6 @@ int __init igmp_mc_proc_init(void)
109249  }
109250  #endif
109251  
109252 +EXPORT_SYMBOL(ip_mc_dec_group);
109253 +EXPORT_SYMBOL(ip_mc_inc_group);
109254 +EXPORT_SYMBOL(ip_mc_join_group);
109255 --- linux-2.6.0-test6/net/ipv4/inetpeer.c       2003-06-14 12:18:33.000000000 -0700
109256 +++ 25/net/ipv4/inetpeer.c      2003-10-05 00:33:25.000000000 -0700
109257 @@ -8,6 +8,7 @@
109258   *  Authors:   Andrey V. Savochkin <saw@msu.ru>
109259   */
109260  
109261 +#include <linux/module.h>
109262  #include <linux/types.h>
109263  #include <linux/slab.h>
109264  #include <linux/interrupt.h>
109265 @@ -452,3 +453,5 @@ static void peer_check_expire(unsigned l
109266                         peer_total / inet_peer_threshold * HZ;
109267         add_timer(&peer_periodic_timer);
109268  }
109269 +
109270 +EXPORT_SYMBOL(inet_peer_idlock);
109271 --- linux-2.6.0-test6/net/ipv4/ip_fragment.c    2003-06-14 12:18:05.000000000 -0700
109272 +++ 25/net/ipv4/ip_fragment.c   2003-10-05 00:33:25.000000000 -0700
109273 @@ -23,6 +23,7 @@
109274   */
109275  
109276  #include <linux/config.h>
109277 +#include <linux/module.h>
109278  #include <linux/types.h>
109279  #include <linux/mm.h>
109280  #include <linux/jiffies.h>
109281 @@ -675,3 +676,5 @@ void ipfrag_init(void)
109282         ipfrag_secret_timer.expires = jiffies + sysctl_ipfrag_secret_interval;
109283         add_timer(&ipfrag_secret_timer);
109284  }
109285 +
109286 +EXPORT_SYMBOL(ip_defrag);
109287 --- linux-2.6.0-test6/net/ipv4/ip_input.c       2003-09-27 18:57:47.000000000 -0700
109288 +++ 25/net/ipv4/ip_input.c      2003-10-05 00:33:25.000000000 -0700
109289 @@ -116,6 +116,7 @@
109290   */
109291  
109292  #include <asm/system.h>
109293 +#include <linux/module.h>
109294  #include <linux/types.h>
109295  #include <linux/kernel.h>
109296  #include <linux/string.h>
109297 @@ -432,3 +433,5 @@ out:
109298          return NET_RX_DROP;
109299  }
109300  
109301 +EXPORT_SYMBOL(ip_rcv);
109302 +EXPORT_SYMBOL(ip_statistics);
109303 --- linux-2.6.0-test6/net/ipv4/ipip.c   2003-08-22 19:23:42.000000000 -0700
109304 +++ 25/net/ipv4/ipip.c  2003-10-05 00:33:25.000000000 -0700
109305 @@ -483,6 +483,11 @@ static int ipip_rcv(struct sk_buff *skb)
109306  
109307         read_lock(&ipip_lock);
109308         if ((tunnel = ipip_tunnel_lookup(iph->saddr, iph->daddr)) != NULL) {
109309 +               if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
109310 +                       kfree_skb(skb);
109311 +                       return 0;
109312 +               }
109313 +
109314                 tunnel->stat.rx_packets++;
109315                 tunnel->stat.rx_bytes += skb->len;
109316                 skb->dev = tunnel->dev;
109317 --- linux-2.6.0-test6/net/ipv4/ip_options.c     2003-06-14 12:18:28.000000000 -0700
109318 +++ 25/net/ipv4/ip_options.c    2003-10-05 00:33:25.000000000 -0700
109319 @@ -11,6 +11,7 @@
109320   *             
109321   */
109322  
109323 +#include <linux/module.h>
109324  #include <linux/types.h>
109325  #include <asm/uaccess.h>
109326  #include <linux/skbuff.h>
109327 @@ -617,3 +618,6 @@ int ip_options_rcv_srr(struct sk_buff *s
109328         }
109329         return 0;
109330  }
109331 +
109332 +EXPORT_SYMBOL(ip_options_compile);
109333 +EXPORT_SYMBOL(ip_options_undo);
109334 --- linux-2.6.0-test6/net/ipv4/ip_output.c      2003-09-27 18:57:47.000000000 -0700
109335 +++ 25/net/ipv4/ip_output.c     2003-10-05 00:33:25.000000000 -0700
109336 @@ -46,6 +46,7 @@
109337  
109338  #include <asm/uaccess.h>
109339  #include <asm/system.h>
109340 +#include <linux/module.h>
109341  #include <linux/types.h>
109342  #include <linux/kernel.h>
109343  #include <linux/sched.h>
109344 @@ -1317,3 +1318,13 @@ void __init ip_init(void)
109345         igmp_mc_proc_init();
109346  #endif
109347  }
109348 +
109349 +EXPORT_SYMBOL(ip_finish_output);
109350 +EXPORT_SYMBOL(ip_fragment);
109351 +EXPORT_SYMBOL(ip_generic_getfrag);
109352 +EXPORT_SYMBOL(ip_queue_xmit);
109353 +EXPORT_SYMBOL(ip_send_check);
109354 +
109355 +#ifdef CONFIG_SYSCTL
109356 +EXPORT_SYMBOL(sysctl_ip_default_ttl);
109357 +#endif
109358 --- linux-2.6.0-test6/net/ipv4/ip_sockglue.c    2003-06-14 12:18:06.000000000 -0700
109359 +++ 25/net/ipv4/ip_sockglue.c   2003-10-05 00:33:25.000000000 -0700
109360 @@ -18,6 +18,7 @@
109361   */
109362  
109363  #include <linux/config.h>
109364 +#include <linux/module.h>
109365  #include <linux/types.h>
109366  #include <linux/mm.h>
109367  #include <linux/sched.h>
109368 @@ -1055,3 +1056,10 @@ int ip_getsockopt(struct sock *sk, int l
109369         }
109370         return 0;
109371  }
109372 +
109373 +EXPORT_SYMBOL(ip_cmsg_recv);
109374 +
109375 +#ifdef CONFIG_IP_SCTP_MODULE
109376 +EXPORT_SYMBOL(ip_getsockopt);
109377 +EXPORT_SYMBOL(ip_setsockopt);
109378 +#endif
109379 --- linux-2.6.0-test6/net/ipv4/ipvs/ip_vs_lblc.c        2003-09-27 18:57:47.000000000 -0700
109380 +++ 25/net/ipv4/ipvs/ip_vs_lblc.c       2003-10-05 00:33:25.000000000 -0700
109381 @@ -458,10 +458,11 @@ __ip_vs_wlc_schedule(struct ip_vs_servic
109382          * The server with weight=0 is quiesced and will not receive any
109383          * new connection.
109384          */
109385 -       list_for_each_entry(least, &svc->destinations, n_list) {
109386 -               if (least->flags & IP_VS_DEST_F_OVERLOAD)
109387 +       list_for_each_entry(dest, &svc->destinations, n_list) {
109388 +               if (dest->flags & IP_VS_DEST_F_OVERLOAD)
109389                         continue;
109390 -               if (atomic_read(&least->weight) > 0) {
109391 +               if (atomic_read(&dest->weight) > 0) {
109392 +                       least = dest;
109393                         loh = atomic_read(&least->activeconns) * 50
109394                                 + atomic_read(&least->inactconns);
109395                         goto nextstage;
109396 @@ -473,7 +474,7 @@ __ip_vs_wlc_schedule(struct ip_vs_servic
109397          *    Find the destination with the least load.
109398          */
109399    nextstage:
109400 -       list_for_each_entry(dest, &svc->destinations, n_list) {
109401 +       list_for_each_entry_continue(dest, &svc->destinations, n_list) {
109402                 if (dest->flags & IP_VS_DEST_F_OVERLOAD)
109403                         continue;
109404  
109405 --- linux-2.6.0-test6/net/ipv4/ipvs/ip_vs_lblcr.c       2003-09-27 18:57:47.000000000 -0700
109406 +++ 25/net/ipv4/ipvs/ip_vs_lblcr.c      2003-10-05 00:33:25.000000000 -0700
109407 @@ -711,11 +711,12 @@ __ip_vs_wlc_schedule(struct ip_vs_servic
109408          * The server with weight=0 is quiesced and will not receive any
109409          * new connection.
109410          */
109411 -       list_for_each_entry(least, &svc->destinations, n_list) {
109412 -               if (least->flags & IP_VS_DEST_F_OVERLOAD)
109413 +       list_for_each_entry(dest, &svc->destinations, n_list) {
109414 +               if (dest->flags & IP_VS_DEST_F_OVERLOAD)
109415                         continue;
109416  
109417 -               if (atomic_read(&least->weight) > 0) {
109418 +               if (atomic_read(&dest->weight) > 0) {
109419 +                       least = dest;
109420                         loh = atomic_read(&least->activeconns) * 50
109421                                 + atomic_read(&least->inactconns);
109422                         goto nextstage;
109423 @@ -727,7 +728,7 @@ __ip_vs_wlc_schedule(struct ip_vs_servic
109424          *    Find the destination with the least load.
109425          */
109426    nextstage:
109427 -       list_for_each_entry(dest, &svc->destinations, n_list) {
109428 +       list_for_each_entry_continue(dest, &svc->destinations, n_list) {
109429                 if (dest->flags & IP_VS_DEST_F_OVERLOAD)
109430                         continue;
109431  
109432 --- linux-2.6.0-test6/net/ipv4/ipvs/ip_vs_lc.c  2003-09-27 18:57:47.000000000 -0700
109433 +++ 25/net/ipv4/ipvs/ip_vs_lc.c 2003-10-05 00:33:25.000000000 -0700
109434 @@ -65,8 +65,8 @@ ip_vs_lc_dest_overhead(struct ip_vs_dest
109435  static struct ip_vs_dest *
109436  ip_vs_lc_schedule(struct ip_vs_service *svc, struct iphdr *iph)
109437  {
109438 -       struct ip_vs_dest *dest, *least;
109439 -       unsigned int loh, doh;
109440 +       struct ip_vs_dest *dest, *least = NULL;
109441 +       unsigned int loh = 0, doh;
109442  
109443         IP_VS_DBG(6, "ip_vs_lc_schedule(): Scheduling...\n");
109444  
109445 @@ -79,31 +79,18 @@ ip_vs_lc_schedule(struct ip_vs_service *
109446          * served, but no new connection is assigned to the server.
109447          */
109448  
109449 -       list_for_each_entry(least, &svc->destinations, n_list) {
109450 -               if (least->flags & IP_VS_DEST_F_OVERLOAD)
109451 -                       continue;
109452 -               if (atomic_read(&least->weight) > 0) {
109453 -                       loh = ip_vs_lc_dest_overhead(least);
109454 -                       goto nextstage;
109455 -               }
109456 -       }
109457 -       return NULL;
109458 -
109459 -       /*
109460 -        *    Find the destination with the least load.
109461 -        */
109462 -  nextstage:
109463         list_for_each_entry(dest, &svc->destinations, n_list) {
109464                 if ((dest->flags & IP_VS_DEST_F_OVERLOAD) ||
109465                     atomic_read(&dest->weight) == 0)
109466                         continue;
109467                 doh = ip_vs_lc_dest_overhead(dest);
109468 -               if (doh < loh) {
109469 +               if (!least || doh < loh) {
109470                         least = dest;
109471                         loh = doh;
109472                 }
109473         }
109474  
109475 +       if (least)
109476         IP_VS_DBG(6, "LC: server %u.%u.%u.%u:%u activeconns %d inactconns %d\n",
109477                   NIPQUAD(least->addr), ntohs(least->port),
109478                   atomic_read(&least->activeconns),
109479 --- linux-2.6.0-test6/net/ipv4/ipvs/ip_vs_nq.c  2003-09-27 18:57:47.000000000 -0700
109480 +++ 25/net/ipv4/ipvs/ip_vs_nq.c 2003-10-05 00:33:25.000000000 -0700
109481 @@ -81,8 +81,8 @@ ip_vs_nq_dest_overhead(struct ip_vs_dest
109482  static struct ip_vs_dest *
109483  ip_vs_nq_schedule(struct ip_vs_service *svc, struct iphdr *iph)
109484  {
109485 -       struct ip_vs_dest *dest, *least;
109486 -       unsigned int loh, doh;
109487 +       struct ip_vs_dest *dest, *least = NULL;
109488 +       unsigned int loh = 0, doh;
109489  
109490         IP_VS_DBG(6, "ip_vs_nq_schedule(): Scheduling...\n");
109491  
109492 @@ -99,27 +99,10 @@ ip_vs_nq_schedule(struct ip_vs_service *
109493          * new connections.
109494          */
109495  
109496 -       list_for_each_entry(least, &svc->destinations, n_list) {
109497 -               if (!(least->flags & IP_VS_DEST_F_OVERLOAD) &&
109498 -                   atomic_read(&least->weight) > 0) {
109499 -                       loh = ip_vs_nq_dest_overhead(least);
109500 -
109501 -                       /* return the server directly if it is idle */
109502 -                       if (atomic_read(&least->activeconns) == 0)
109503 -                               goto out;
109504 -
109505 -                       goto nextstage;
109506 -               }
109507 -       }
109508 -       return NULL;
109509 -
109510 -       /*
109511 -        *    Find the destination with the least load.
109512 -        */
109513 -  nextstage:
109514         list_for_each_entry(dest, &svc->destinations, n_list) {
109515  
109516 -               if (dest->flags & IP_VS_DEST_F_OVERLOAD)
109517 +               if (dest->flags & IP_VS_DEST_F_OVERLOAD ||
109518 +                   !atomic_read(&dest->weight))
109519                         continue;
109520  
109521                 doh = ip_vs_nq_dest_overhead(dest);
109522 @@ -127,16 +110,21 @@ ip_vs_nq_schedule(struct ip_vs_service *
109523                 /* return the server directly if it is idle */
109524                 if (atomic_read(&dest->activeconns) == 0) {
109525                         least = dest;
109526 +                       loh = doh;
109527                         goto out;
109528                 }
109529  
109530 -               if (loh * atomic_read(&dest->weight) >
109531 -                   doh * atomic_read(&least->weight)) {
109532 +               if (!least ||
109533 +                   (loh * atomic_read(&dest->weight) >
109534 +                    doh * atomic_read(&least->weight))) {
109535                         least = dest;
109536                         loh = doh;
109537                 }
109538         }
109539  
109540 +       if (!least)
109541 +               return NULL;
109542 +
109543    out:
109544         IP_VS_DBG(6, "NQ: server %u.%u.%u.%u:%u "
109545                   "activeconns %d refcnt %d weight %d overhead %d\n",
109546 --- linux-2.6.0-test6/net/ipv4/ipvs/ip_vs_sed.c 2003-09-27 18:57:47.000000000 -0700
109547 +++ 25/net/ipv4/ipvs/ip_vs_sed.c        2003-10-05 00:33:25.000000000 -0700
109548 @@ -103,9 +103,10 @@ ip_vs_sed_schedule(struct ip_vs_service 
109549          * new connections.
109550          */
109551  
109552 -       list_for_each_entry(least, &svc->destinations, n_list) {
109553 -               if (!(least->flags & IP_VS_DEST_F_OVERLOAD) &&
109554 -                   atomic_read(&least->weight) > 0) {
109555 +       list_for_each_entry(dest, &svc->destinations, n_list) {
109556 +               if (!(dest->flags & IP_VS_DEST_F_OVERLOAD) &&
109557 +                   atomic_read(&dest->weight) > 0) {
109558 +                       least = dest;
109559                         loh = ip_vs_sed_dest_overhead(least);
109560                         goto nextstage;
109561                 }
109562 @@ -116,7 +117,7 @@ ip_vs_sed_schedule(struct ip_vs_service 
109563          *    Find the destination with the least load.
109564          */
109565    nextstage:
109566 -       list_for_each_entry(dest, &svc->destinations, n_list) {
109567 +       list_for_each_entry_continue(dest, &svc->destinations, n_list) {
109568                 if (dest->flags & IP_VS_DEST_F_OVERLOAD)
109569                         continue;
109570                 doh = ip_vs_sed_dest_overhead(dest);
109571 --- linux-2.6.0-test6/net/ipv4/ipvs/ip_vs_wlc.c 2003-09-27 18:57:47.000000000 -0700
109572 +++ 25/net/ipv4/ipvs/ip_vs_wlc.c        2003-10-05 00:33:25.000000000 -0700
109573 @@ -91,9 +91,10 @@ ip_vs_wlc_schedule(struct ip_vs_service 
109574          * new connections.
109575          */
109576  
109577 -       list_for_each_entry(least, &svc->destinations, n_list) {
109578 -               if (!(least->flags & IP_VS_DEST_F_OVERLOAD) &&
109579 -                   atomic_read(&least->weight) > 0) {
109580 +       list_for_each_entry(dest, &svc->destinations, n_list) {
109581 +               if (!(dest->flags & IP_VS_DEST_F_OVERLOAD) &&
109582 +                   atomic_read(&dest->weight) > 0) {
109583 +                       least = dest;
109584                         loh = ip_vs_wlc_dest_overhead(least);
109585                         goto nextstage;
109586                 }
109587 @@ -104,7 +105,7 @@ ip_vs_wlc_schedule(struct ip_vs_service 
109588          *    Find the destination with the least load.
109589          */
109590    nextstage:
109591 -       list_for_each_entry(dest, &svc->destinations, n_list) {
109592 +       list_for_each_entry_continue(dest, &svc->destinations, n_list) {
109593                 if (dest->flags & IP_VS_DEST_F_OVERLOAD)
109594                         continue;
109595                 doh = ip_vs_wlc_dest_overhead(dest);
109596 --- linux-2.6.0-test6/net/ipv4/ipvs/ip_vs_wrr.c 2003-09-27 18:57:47.000000000 -0700
109597 +++ 25/net/ipv4/ipvs/ip_vs_wrr.c        2003-10-05 00:33:25.000000000 -0700
109598 @@ -58,26 +58,18 @@ static int ip_vs_wrr_gcd_weight(struct i
109599  {
109600         struct ip_vs_dest *dest;
109601         int weight;
109602 -       int g = 1;
109603 +       int g = 0;
109604  
109605         list_for_each_entry(dest, &svc->destinations, n_list) {
109606                 weight = atomic_read(&dest->weight);
109607                 if (weight > 0) {
109608 -                       g = weight;
109609 -                       goto search_gcd;
109610 +                       if (g > 0)
109611 +                               g = gcd(weight, g);
109612 +                       else
109613 +                               g = weight;
109614                 }
109615         }
109616 -
109617 -       return g;
109618 -
109619 - search_gcd:
109620 -       list_for_each_entry(dest, &svc->destinations, n_list) {
109621 -               weight = atomic_read(&dest->weight);
109622 -               if (weight > 0)
109623 -                       g = gcd(weight, g);
109624 -       }
109625 -
109626 -       return g;
109627 +       return g ? g : 1;
109628  }
109629  
109630  
109631 --- linux-2.6.0-test6/net/ipv4/netfilter/ip_conntrack_core.c    2003-09-08 13:58:59.000000000 -0700
109632 +++ 25/net/ipv4/netfilter/ip_conntrack_core.c   2003-10-05 00:33:25.000000000 -0700
109633 @@ -59,7 +59,7 @@ LIST_HEAD(ip_conntrack_expect_list);
109634  LIST_HEAD(protocol_list);
109635  static LIST_HEAD(helpers);
109636  unsigned int ip_conntrack_htable_size = 0;
109637 -static int ip_conntrack_max;
109638 +int ip_conntrack_max;
109639  static atomic_t ip_conntrack_count = ATOMIC_INIT(0);
109640  struct list_head *ip_conntrack_hash;
109641  static kmem_cache_t *ip_conntrack_cachep;
109642 @@ -301,7 +301,7 @@ clean_from_lists(struct ip_conntrack *ct
109643  static void
109644  destroy_conntrack(struct nf_conntrack *nfct)
109645  {
109646 -       struct ip_conntrack *ct = (struct ip_conntrack *)nfct;
109647 +       struct ip_conntrack *ct = (struct ip_conntrack *)nfct, *master = NULL;
109648         struct ip_conntrack_protocol *proto;
109649  
109650         DEBUGP("destroy_conntrack(%p)\n", ct);
109651 @@ -328,12 +328,15 @@ destroy_conntrack(struct nf_conntrack *n
109652                         /* can't call __unexpect_related here,
109653                          * since it would screw up expect_list */
109654                         list_del(&ct->master->expected_list);
109655 -                       ip_conntrack_put(ct->master->expectant);
109656 +                       master = ct->master->expectant;
109657                 }
109658                 kfree(ct->master);
109659         }
109660         WRITE_UNLOCK(&ip_conntrack_lock);
109661  
109662 +       if (master)
109663 +               ip_conntrack_put(master);
109664 +
109665         DEBUGP("destroy_conntrack: returning ct=%p to slab\n", ct);
109666         kmem_cache_free(ip_conntrack_cachep, ct);
109667         atomic_dec(&ip_conntrack_count);
109668 @@ -1276,11 +1279,14 @@ getorigdst(struct sock *sk, int optval, 
109669  {
109670         struct inet_opt *inet = inet_sk(sk);
109671         struct ip_conntrack_tuple_hash *h;
109672 -       struct ip_conntrack_tuple tuple = { { inet->rcv_saddr,
109673 -                                               { .tcp = { inet->sport } } },
109674 -                                           { inet->daddr,
109675 -                                               { .tcp = { inet->dport } },
109676 -                                             IPPROTO_TCP } };
109677 +       struct ip_conntrack_tuple tuple;
109678 +       
109679 +       IP_CT_TUPLE_U_BLANK(&tuple);
109680 +       tuple.src.ip = inet->rcv_saddr;
109681 +       tuple.src.u.tcp.port = inet->sport;
109682 +       tuple.dst.ip = inet->daddr;
109683 +       tuple.dst.u.tcp.port = inet->dport;
109684 +       tuple.dst.protonum = IPPROTO_TCP;
109685  
109686         /* We only do TCP at the moment: is there a better way? */
109687         if (strcmp(sk->sk_prot->name, "TCP")) {
109688 @@ -1325,45 +1331,6 @@ static struct nf_sockopt_ops so_getorigd
109689         .get            = &getorigdst,
109690  };
109691  
109692 -#define NET_IP_CONNTRACK_MAX 2089
109693 -#define NET_IP_CONNTRACK_MAX_NAME "ip_conntrack_max"
109694 -
109695 -#ifdef CONFIG_SYSCTL
109696 -static struct ctl_table_header *ip_conntrack_sysctl_header;
109697 -
109698 -static ctl_table ip_conntrack_table[] = {
109699 -       {
109700 -               .ctl_name       = NET_IP_CONNTRACK_MAX,
109701 -               .procname       = NET_IP_CONNTRACK_MAX_NAME,
109702 -               .data           = &ip_conntrack_max,
109703 -               .maxlen         = sizeof(ip_conntrack_max),
109704 -               .mode           = 0644,
109705 -               .proc_handler   = proc_dointvec
109706 -       },
109707 -       { .ctl_name = 0 }
109708 -};
109709 -
109710 -static ctl_table ip_conntrack_dir_table[] = {
109711 -       {
109712 -               .ctl_name       = NET_IPV4,
109713 -               .procname       = "ipv4",
109714 -               .mode           = 0555,
109715 -               .child          = ip_conntrack_table
109716 -       },
109717 -       { .ctl_name = 0 }
109718 -};
109719 -
109720 -static ctl_table ip_conntrack_root_table[] = {
109721 -       {
109722 -               .ctl_name       = CTL_NET,
109723 -               .procname       = "net",
109724 -               .mode           = 0555,
109725 -               .child          = ip_conntrack_dir_table
109726 -       },
109727 -       { .ctl_name = 0 }
109728 -};
109729 -#endif /*CONFIG_SYSCTL*/
109730 -
109731  static int kill_all(const struct ip_conntrack *i, void *data)
109732  {
109733         return 1;
109734 @@ -1373,9 +1340,6 @@ static int kill_all(const struct ip_conn
109735     supposed to kill the mall. */
109736  void ip_conntrack_cleanup(void)
109737  {
109738 -#ifdef CONFIG_SYSCTL
109739 -       unregister_sysctl_table(ip_conntrack_sysctl_header);
109740 -#endif
109741         ip_ct_attach = NULL;
109742         /* This makes sure all current packets have passed through
109743             netfilter framework.  Roll on, two-stage module
109744 @@ -1453,25 +1417,10 @@ int __init ip_conntrack_init(void)
109745         for (i = 0; i < ip_conntrack_htable_size; i++)
109746                 INIT_LIST_HEAD(&ip_conntrack_hash[i]);
109747  
109748 -/* This is fucking braindead.  There is NO WAY of doing this without
109749 -   the CONFIG_SYSCTL unless you don't want to detect errors.
109750 -   Grrr... --RR */
109751 -#ifdef CONFIG_SYSCTL
109752 -       ip_conntrack_sysctl_header
109753 -               = register_sysctl_table(ip_conntrack_root_table, 0);
109754 -       if (ip_conntrack_sysctl_header == NULL) {
109755 -               goto err_free_ct_cachep;
109756 -       }
109757 -#endif /*CONFIG_SYSCTL*/
109758 -
109759         /* For use by ipt_REJECT */
109760         ip_ct_attach = ip_conntrack_attach;
109761         return ret;
109762  
109763 -#ifdef CONFIG_SYSCTL
109764 -err_free_ct_cachep:
109765 -       kmem_cache_destroy(ip_conntrack_cachep);
109766 -#endif /*CONFIG_SYSCTL*/
109767  err_free_hash:
109768         vfree(ip_conntrack_hash);
109769  err_unreg_sockopt:
109770 --- linux-2.6.0-test6/net/ipv4/netfilter/ip_conntrack_irc.c     2003-09-08 13:58:59.000000000 -0700
109771 +++ 25/net/ipv4/netfilter/ip_conntrack_irc.c    2003-10-05 00:33:25.000000000 -0700
109772 @@ -177,7 +177,10 @@ static int help(struct sk_buff *skb,
109773                         DEBUGP("DCC bound ip/port: %u.%u.%u.%u:%u\n",
109774                                 HIPQUAD(dcc_ip), dcc_port);
109775  
109776 -                       if (ct->tuplehash[dir].tuple.src.ip != htonl(dcc_ip)) {
109777 +                       /* dcc_ip can be the internal OR external (NAT'ed) IP
109778 +                        * Tiago Sousa <mirage@kaotik.org> */
109779 +                       if (ct->tuplehash[dir].tuple.src.ip != htonl(dcc_ip)
109780 +                           && ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip != htonl(dcc_ip)) {
109781                                 if (net_ratelimit())
109782                                         printk(KERN_WARNING
109783                                                 "Forged DCC command from "
109784 @@ -201,7 +204,7 @@ static int help(struct sk_buff *skb,
109785  
109786                         exp->tuple = ((struct ip_conntrack_tuple)
109787                                 { { 0, { 0 } },
109788 -                                 { htonl(dcc_ip), { .tcp = { htons(dcc_port) } },
109789 +                                 { ct->tuplehash[dir].tuple.src.ip, { .tcp = { htons(dcc_port) } },
109790                                     IPPROTO_TCP }});
109791                         exp->mask = ((struct ip_conntrack_tuple)
109792                                 { { 0, { 0 } },
109793 --- linux-2.6.0-test6/net/ipv4/netfilter/ip_conntrack_proto_generic.c   2003-06-14 12:18:07.000000000 -0700
109794 +++ 25/net/ipv4/netfilter/ip_conntrack_proto_generic.c  2003-10-05 00:33:25.000000000 -0700
109795 @@ -4,7 +4,7 @@
109796  #include <linux/netfilter.h>
109797  #include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
109798  
109799 -#define GENERIC_TIMEOUT (600*HZ)
109800 +unsigned long ip_ct_generic_timeout = 600*HZ;
109801  
109802  static int generic_pkt_to_tuple(const struct sk_buff *skb,
109803                                 unsigned int dataoff,
109804 @@ -44,7 +44,7 @@ static int packet(struct ip_conntrack *c
109805                   const struct sk_buff *skb,
109806                   enum ip_conntrack_info conntrackinfo)
109807  {
109808 -       ip_ct_refresh(conntrack, GENERIC_TIMEOUT);
109809 +       ip_ct_refresh(conntrack, ip_ct_generic_timeout);
109810         return NF_ACCEPT;
109811  }
109812  
109813 --- linux-2.6.0-test6/net/ipv4/netfilter/ip_conntrack_proto_icmp.c      2003-06-14 12:17:56.000000000 -0700
109814 +++ 25/net/ipv4/netfilter/ip_conntrack_proto_icmp.c     2003-10-05 00:33:25.000000000 -0700
109815 @@ -6,7 +6,7 @@
109816  #include <linux/icmp.h>
109817  #include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
109818  
109819 -#define ICMP_TIMEOUT (30*HZ)
109820 +unsigned long ip_ct_icmp_timeout = 30*HZ;
109821  
109822  #if 0
109823  #define DEBUGP printk
109824 @@ -86,7 +86,7 @@ static int icmp_packet(struct ip_conntra
109825                         ct->timeout.function((unsigned long)ct);
109826         } else {
109827                 atomic_inc(&ct->proto.icmp.count);
109828 -               ip_ct_refresh(ct, ICMP_TIMEOUT);
109829 +               ip_ct_refresh(ct, ip_ct_icmp_timeout);
109830         }
109831  
109832         return NF_ACCEPT;
109833 --- linux-2.6.0-test6/net/ipv4/netfilter/ip_conntrack_proto_tcp.c       2003-06-14 12:18:51.000000000 -0700
109834 +++ 25/net/ipv4/netfilter/ip_conntrack_proto_tcp.c      2003-10-05 00:33:25.000000000 -0700
109835 @@ -49,20 +49,28 @@ static const char *tcp_conntrack_names[]
109836  #define HOURS * 60 MINS
109837  #define DAYS * 24 HOURS
109838  
109839 -
109840 -static unsigned long tcp_timeouts[]
109841 -= { 30 MINS,   /*      TCP_CONNTRACK_NONE,     */
109842 -    5 DAYS,    /*      TCP_CONNTRACK_ESTABLISHED,      */
109843 -    2 MINS,    /*      TCP_CONNTRACK_SYN_SENT, */
109844 -    60 SECS,   /*      TCP_CONNTRACK_SYN_RECV, */
109845 -    2 MINS,    /*      TCP_CONNTRACK_FIN_WAIT, */
109846 -    2 MINS,    /*      TCP_CONNTRACK_TIME_WAIT,        */
109847 -    10 SECS,   /*      TCP_CONNTRACK_CLOSE,    */
109848 -    60 SECS,   /*      TCP_CONNTRACK_CLOSE_WAIT,       */
109849 -    30 SECS,   /*      TCP_CONNTRACK_LAST_ACK, */
109850 -    2 MINS,    /*      TCP_CONNTRACK_LISTEN,   */
109851 -};
109852 -
109853 +unsigned long ip_ct_tcp_timeout_syn_sent =      2 MINS;
109854 +unsigned long ip_ct_tcp_timeout_syn_recv =     60 SECS;
109855 +unsigned long ip_ct_tcp_timeout_established =   5 DAYS;
109856 +unsigned long ip_ct_tcp_timeout_fin_wait =      2 MINS;
109857 +unsigned long ip_ct_tcp_timeout_close_wait =    3 DAYS;
109858 +unsigned long ip_ct_tcp_timeout_last_ack =     30 SECS;
109859 +unsigned long ip_ct_tcp_timeout_time_wait =     2 MINS;
109860 +unsigned long ip_ct_tcp_timeout_close =        10 SECS;
109861 +
109862 +static unsigned long * tcp_timeouts[]
109863 += { 0,                                 /*      TCP_CONNTRACK_NONE */
109864 +    &ip_ct_tcp_timeout_established,    /*      TCP_CONNTRACK_ESTABLISHED,      */
109865 +    &ip_ct_tcp_timeout_syn_sent,       /*      TCP_CONNTRACK_SYN_SENT, */
109866 +    &ip_ct_tcp_timeout_syn_recv,       /*      TCP_CONNTRACK_SYN_RECV, */
109867 +    &ip_ct_tcp_timeout_fin_wait,       /*      TCP_CONNTRACK_FIN_WAIT, */
109868 +    &ip_ct_tcp_timeout_time_wait,      /*      TCP_CONNTRACK_TIME_WAIT,        */
109869 +    &ip_ct_tcp_timeout_close,          /*      TCP_CONNTRACK_CLOSE,    */
109870 +    &ip_ct_tcp_timeout_close_wait,     /*      TCP_CONNTRACK_CLOSE_WAIT,       */
109871 +    &ip_ct_tcp_timeout_last_ack,       /*      TCP_CONNTRACK_LAST_ACK, */
109872 +    0,                                 /*      TCP_CONNTRACK_LISTEN */
109873 + };
109874
109875  #define sNO TCP_CONNTRACK_NONE
109876  #define sES TCP_CONNTRACK_ESTABLISHED
109877  #define sSS TCP_CONNTRACK_SYN_SENT
109878 @@ -204,7 +212,7 @@ static int tcp_packet(struct ip_conntrac
109879                         set_bit(IPS_ASSURED_BIT, &conntrack->status);
109880  
109881                 WRITE_UNLOCK(&tcp_lock);
109882 -               ip_ct_refresh(conntrack, tcp_timeouts[newconntrack]);
109883 +               ip_ct_refresh(conntrack, *tcp_timeouts[newconntrack]);
109884         }
109885  
109886         return NF_ACCEPT;
109887 --- linux-2.6.0-test6/net/ipv4/netfilter/ip_conntrack_proto_udp.c       2003-06-14 12:17:55.000000000 -0700
109888 +++ 25/net/ipv4/netfilter/ip_conntrack_proto_udp.c      2003-10-05 00:33:25.000000000 -0700
109889 @@ -6,8 +6,8 @@
109890  #include <linux/udp.h>
109891  #include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
109892  
109893 -#define UDP_TIMEOUT (30*HZ)
109894 -#define UDP_STREAM_TIMEOUT (180*HZ)
109895 +unsigned long ip_ct_udp_timeout = 30*HZ;
109896 +unsigned long ip_ct_udp_timeout_stream = 180*HZ;
109897  
109898  static int udp_pkt_to_tuple(const struct sk_buff *skb,
109899                              unsigned int dataoff,
109900 @@ -57,11 +57,11 @@ static int udp_packet(struct ip_conntrac
109901         /* If we've seen traffic both ways, this is some kind of UDP
109902            stream.  Extend timeout. */
109903         if (test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)) {
109904 -               ip_ct_refresh(conntrack, UDP_STREAM_TIMEOUT);
109905 +               ip_ct_refresh(conntrack, ip_ct_udp_timeout_stream);
109906                 /* Also, more likely to be important, and not a probe */
109907                 set_bit(IPS_ASSURED_BIT, &conntrack->status);
109908         } else
109909 -               ip_ct_refresh(conntrack, UDP_TIMEOUT);
109910 +               ip_ct_refresh(conntrack, ip_ct_udp_timeout);
109911  
109912         return NF_ACCEPT;
109913  }
109914 --- linux-2.6.0-test6/net/ipv4/netfilter/ip_conntrack_standalone.c      2003-09-08 13:58:59.000000000 -0700
109915 +++ 25/net/ipv4/netfilter/ip_conntrack_standalone.c     2003-10-05 00:33:25.000000000 -0700
109916 @@ -7,6 +7,7 @@
109917  /* (c) 1999 Paul `Rusty' Russell.  Licenced under the GNU General
109918     Public Licence. */
109919  
109920 +#include <linux/config.h>
109921  #include <linux/types.h>
109922  #include <linux/ip.h>
109923  #include <linux/netfilter.h>
109924 @@ -14,6 +15,9 @@
109925  #include <linux/module.h>
109926  #include <linux/skbuff.h>
109927  #include <linux/proc_fs.h>
109928 +#ifdef CONFIG_SYSCTL
109929 +#include <linux/sysctl.h>
109930 +#endif
109931  #include <net/checksum.h>
109932  
109933  #define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_conntrack_lock)
109934 @@ -256,6 +260,98 @@ static struct nf_hook_ops ip_conntrack_l
109935         .priority       = NF_IP_PRI_LAST-1,
109936  };
109937  
109938 +/* Sysctl support */
109939 +
109940 +#ifdef CONFIG_SYSCTL
109941 +
109942 +/* From ip_conntrack_core.c */
109943 +extern int ip_conntrack_max;
109944 +
109945 +/* From ip_conntrack_proto_tcp.c */
109946 +extern unsigned long ip_ct_tcp_timeout_syn_sent;
109947 +extern unsigned long ip_ct_tcp_timeout_syn_recv;
109948 +extern unsigned long ip_ct_tcp_timeout_established;
109949 +extern unsigned long ip_ct_tcp_timeout_fin_wait;
109950 +extern unsigned long ip_ct_tcp_timeout_close_wait;
109951 +extern unsigned long ip_ct_tcp_timeout_last_ack;
109952 +extern unsigned long ip_ct_tcp_timeout_time_wait;
109953 +extern unsigned long ip_ct_tcp_timeout_close;
109954 +
109955 +/* From ip_conntrack_proto_udp.c */
109956 +extern unsigned long ip_ct_udp_timeout;
109957 +extern unsigned long ip_ct_udp_timeout_stream;
109958 +
109959 +/* From ip_conntrack_proto_icmp.c */
109960 +extern unsigned long ip_ct_icmp_timeout;
109961 +
109962 +/* From ip_conntrack_proto_icmp.c */
109963 +extern unsigned long ip_ct_generic_timeout;
109964 +
109965 +static struct ctl_table_header *ip_ct_sysctl_header;
109966 +
109967 +static ctl_table ip_ct_sysctl_table[] = {
109968 +       {NET_IPV4_NF_CONNTRACK_MAX, "ip_conntrack_max",
109969 +        &ip_conntrack_max, sizeof(int), 0644, NULL,
109970 +        &proc_dointvec},
109971 +       {NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT, "ip_conntrack_tcp_timeout_syn_sent",
109972 +        &ip_ct_tcp_timeout_syn_sent, sizeof(unsigned int), 0644, NULL,
109973 +        &proc_dointvec_jiffies},
109974 +       {NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV, "ip_conntrack_tcp_timeout_syn_recv",
109975 +        &ip_ct_tcp_timeout_syn_recv, sizeof(unsigned int), 0644, NULL,
109976 +        &proc_dointvec_jiffies},
109977 +       {NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED, "ip_conntrack_tcp_timeout_established",
109978 +        &ip_ct_tcp_timeout_established, sizeof(unsigned int), 0644, NULL,
109979 +        &proc_dointvec_jiffies},
109980 +       {NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT, "ip_conntrack_tcp_timeout_fin_wait",
109981 +        &ip_ct_tcp_timeout_fin_wait, sizeof(unsigned int), 0644, NULL,
109982 +        &proc_dointvec_jiffies},
109983 +       {NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT, "ip_conntrack_tcp_timeout_close_wait",
109984 +        &ip_ct_tcp_timeout_close_wait, sizeof(unsigned int), 0644, NULL,
109985 +        &proc_dointvec_jiffies},
109986 +       {NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK, "ip_conntrack_tcp_timeout_last_ack",
109987 +        &ip_ct_tcp_timeout_last_ack, sizeof(unsigned int), 0644, NULL,
109988 +        &proc_dointvec_jiffies},
109989 +       {NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT, "ip_conntrack_tcp_timeout_time_wait",
109990 +        &ip_ct_tcp_timeout_time_wait, sizeof(unsigned int), 0644, NULL,
109991 +        &proc_dointvec_jiffies},
109992 +       {NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE, "ip_conntrack_tcp_timeout_close",
109993 +        &ip_ct_tcp_timeout_close, sizeof(unsigned int), 0644, NULL,
109994 +        &proc_dointvec_jiffies},
109995 +       {NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT, "ip_conntrack_udp_timeout",
109996 +        &ip_ct_udp_timeout, sizeof(unsigned int), 0644, NULL,
109997 +        &proc_dointvec_jiffies},
109998 +       {NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT_STREAM, "ip_conntrack_udp_timeout_stream",
109999 +        &ip_ct_udp_timeout_stream, sizeof(unsigned int), 0644, NULL,
110000 +        &proc_dointvec_jiffies},
110001 +       {NET_IPV4_NF_CONNTRACK_ICMP_TIMEOUT, "ip_conntrack_icmp_timeout",
110002 +        &ip_ct_icmp_timeout, sizeof(unsigned int), 0644, NULL,
110003 +        &proc_dointvec_jiffies},
110004 +       {NET_IPV4_NF_CONNTRACK_GENERIC_TIMEOUT, "ip_conntrack_generic_timeout",
110005 +        &ip_ct_generic_timeout, sizeof(unsigned int), 0644, NULL,
110006 +        &proc_dointvec_jiffies},
110007 +       {0}
110008 +};
110009 +
110010 +#define NET_IP_CONNTRACK_MAX 2089
110011 +
110012 +static ctl_table ip_ct_netfilter_table[] = {
110013 +       {NET_IPV4_NETFILTER, "netfilter", NULL, 0, 0555, ip_ct_sysctl_table, 0, 0, 0, 0, 0},
110014 +       {NET_IP_CONNTRACK_MAX, "ip_conntrack_max",
110015 +        &ip_conntrack_max, sizeof(int), 0644, NULL,
110016 +        &proc_dointvec},
110017 +       {0}
110018 +};
110019 +
110020 +static ctl_table ip_ct_ipv4_table[] = {
110021 +       {NET_IPV4, "ipv4", NULL, 0, 0555, ip_ct_netfilter_table, 0, 0, 0, 0, 0},
110022 +       {0}
110023 +};
110024 +
110025 +static ctl_table ip_ct_net_table[] = {
110026 +       {CTL_NET, "net", NULL, 0, 0555, ip_ct_ipv4_table, 0, 0, 0, 0, 0},
110027 +       {0}
110028 +};
110029 +#endif
110030  static int init_or_cleanup(int init)
110031  {
110032         struct proc_dir_entry *proc;
110033 @@ -291,10 +387,20 @@ static int init_or_cleanup(int init)
110034                 printk("ip_conntrack: can't register local in hook.\n");
110035                 goto cleanup_inoutandlocalops;
110036         }
110037 +#ifdef CONFIG_SYSCTL
110038 +       ip_ct_sysctl_header = register_sysctl_table(ip_ct_net_table, 0);
110039 +       if (ip_ct_sysctl_header == NULL) {
110040 +               printk("ip_conntrack: can't register to sysctl.\n");
110041 +               goto cleanup;
110042 +       }
110043 +#endif
110044  
110045         return ret;
110046  
110047   cleanup:
110048 +#ifdef CONFIG_SYSCTL
110049 +       unregister_sysctl_table(ip_ct_sysctl_header);
110050 +#endif
110051         nf_unregister_hook(&ip_conntrack_local_in_ops);
110052   cleanup_inoutandlocalops:
110053         nf_unregister_hook(&ip_conntrack_out_ops);
110054 --- linux-2.6.0-test6/net/ipv4/netfilter/ip_nat_core.c  2003-09-08 13:58:59.000000000 -0700
110055 +++ 25/net/ipv4/netfilter/ip_nat_core.c 2003-10-05 00:33:25.000000000 -0700
110056 @@ -516,12 +516,14 @@ ip_nat_setup_info(struct ip_conntrack *c
110057         struct ip_conntrack_tuple new_tuple, inv_tuple, reply;
110058         struct ip_conntrack_tuple orig_tp;
110059         struct ip_nat_info *info = &conntrack->nat.info;
110060 +       int in_hashes = info->initialized;
110061  
110062         MUST_BE_WRITE_LOCKED(&ip_nat_lock);
110063         IP_NF_ASSERT(hooknum == NF_IP_PRE_ROUTING
110064                      || hooknum == NF_IP_POST_ROUTING
110065                      || hooknum == NF_IP_LOCAL_OUT);
110066         IP_NF_ASSERT(info->num_manips < IP_NAT_MAX_MANIPS);
110067 +       IP_NF_ASSERT(!(info->initialized & (1 << HOOK2MANIP(hooknum))));
110068  
110069         /* What we've got will look like inverse of reply. Normally
110070            this is what is in the conntrack, except for prior
110071 @@ -638,6 +640,14 @@ ip_nat_setup_info(struct ip_conntrack *c
110072  
110073         /* It's done. */
110074         info->initialized |= (1 << HOOK2MANIP(hooknum));
110075 +
110076 +       if (in_hashes) {
110077 +               IP_NF_ASSERT(info->bysource.conntrack);
110078 +               replace_in_hashes(conntrack, info);
110079 +       } else {
110080 +               place_in_hashes(conntrack, info);
110081 +       }
110082 +
110083         return NF_ACCEPT;
110084  }
110085  
110086 @@ -761,11 +771,6 @@ do_bindings(struct ip_conntrack *ct,
110087         enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
110088         int proto = (*pskb)->nh.iph->protocol;
110089  
110090 -       /* Skip everything and don't call helpers if there are no
110091 -        * manips for this connection */
110092 -       if (info->num_manips == 0)
110093 -               return NF_ACCEPT;
110094 -
110095         /* Need nat lock to protect against modification, but neither
110096            conntrack (referenced) and helper (deleted with
110097            synchronize_bh()) can vanish. */
110098 --- linux-2.6.0-test6/net/ipv4/netfilter/ip_nat_helper.c        2003-09-08 13:58:59.000000000 -0700
110099 +++ 25/net/ipv4/netfilter/ip_nat_helper.c       2003-10-05 00:33:25.000000000 -0700
110100 @@ -122,7 +122,6 @@ static void mangle_contents(struct sk_bu
110101         /* fix IP hdr checksum information */
110102         skb->nh.iph->tot_len = htons(skb->len);
110103         ip_send_check(skb->nh.iph);
110104 -       skb->csum = csum_partial(data, skb->len - dataoff, 0);
110105  }
110106  
110107  /* Unusual, but possible case. */
110108 @@ -167,6 +166,7 @@ ip_nat_mangle_tcp_packet(struct sk_buff 
110109  {
110110         struct iphdr *iph;
110111         struct tcphdr *tcph;
110112 +       int datalen;
110113  
110114         if (!skb_ip_make_writable(pskb, (*pskb)->len))
110115                 return 0;
110116 @@ -184,11 +184,11 @@ ip_nat_mangle_tcp_packet(struct sk_buff 
110117         mangle_contents(*pskb, iph->ihl*4 + tcph->doff*4,
110118                         match_offset, match_len, rep_buffer, rep_len);
110119  
110120 +       datalen = (*pskb)->len - iph->ihl*4;
110121         tcph->check = 0;
110122 -       tcph->check = tcp_v4_check(tcph, (*pskb)->len - iph->ihl*4,
110123 -                                  iph->saddr, iph->daddr,
110124 -                                  csum_partial((char *)tcph, tcph->doff*4,
110125 -                                               (*pskb)->csum));
110126 +       tcph->check = tcp_v4_check(tcph, datalen, iph->saddr, iph->daddr,
110127 +                                  csum_partial((char *)tcph, datalen, 0));
110128 +
110129         adjust_tcp_sequence(ntohl(tcph->seq),
110130                             (int)rep_len - (int)match_len,
110131                             ct, ctinfo);
110132 @@ -216,7 +216,12 @@ ip_nat_mangle_udp_packet(struct sk_buff 
110133  {
110134         struct iphdr *iph;
110135         struct udphdr *udph;
110136 -       int need_csum = ((*pskb)->csum != 0);
110137 +
110138 +       /* UDP helpers might accidentally mangle the wrong packet */
110139 +       iph = (*pskb)->nh.iph;
110140 +       if ((*pskb)->len < iph->ihl*4 + sizeof(*udph) + 
110141 +                              match_offset + match_len)
110142 +               return 0;
110143  
110144         if (!skb_ip_make_writable(pskb, (*pskb)->len))
110145                 return 0;
110146 @@ -235,17 +240,15 @@ ip_nat_mangle_udp_packet(struct sk_buff 
110147         udph->len = htons((*pskb)->len - iph->ihl*4);
110148  
110149         /* fix udp checksum if udp checksum was previously calculated */
110150 -       if (need_csum) {
110151 +       if (udph->check) {
110152 +               int datalen = (*pskb)->len - iph->ihl * 4;
110153                 udph->check = 0;
110154 -               udph->check
110155 -                       = csum_tcpudp_magic(iph->saddr, iph->daddr,
110156 -                                           (*pskb)->len - iph->ihl*4,
110157 -                                           IPPROTO_UDP,
110158 -                                           csum_partial((char *)udph,
110159 -                                                        sizeof(struct udphdr),
110160 -                                                        (*pskb)->csum));
110161 -       } else
110162 -               (*pskb)->csum = 0;
110163 +               udph->check = csum_tcpudp_magic(iph->saddr, iph->daddr,
110164 +                                               datalen, IPPROTO_UDP,
110165 +                                               csum_partial((char *)udph,
110166 +                                                            datalen, 0));
110167 +       }
110168 +
110169         return 1;
110170  }
110171  
110172 --- linux-2.6.0-test6/net/ipv4/netfilter/ip_nat_rule.c  2003-09-08 13:58:59.000000000 -0700
110173 +++ 25/net/ipv4/netfilter/ip_nat_rule.c 2003-10-05 00:33:25.000000000 -0700
110174 @@ -233,7 +233,7 @@ static int ipt_dnat_checkentry(const cha
110175         return 1;
110176  }
110177  
110178 -static inline unsigned int
110179 +inline unsigned int
110180  alloc_null_binding(struct ip_conntrack *conntrack,
110181                    struct ip_nat_info *info,
110182                    unsigned int hooknum)
110183 --- linux-2.6.0-test6/net/ipv4/netfilter/ip_nat_standalone.c    2003-09-08 13:58:59.000000000 -0700
110184 +++ 25/net/ipv4/netfilter/ip_nat_standalone.c   2003-10-05 00:33:25.000000000 -0700
110185 @@ -119,7 +119,6 @@ ip_nat_fn(unsigned int hooknum,
110186                 /* Seen it before?  This can happen for loopback, retrans,
110187                    or local packets.. */
110188                 if (!(info->initialized & (1 << maniptype))) {
110189 -                       int in_hashes = info->initialized;
110190                         unsigned int ret;
110191  
110192                         if (ct->master
110193 @@ -130,9 +129,10 @@ ip_nat_fn(unsigned int hooknum,
110194                         } else {
110195  #ifdef CONFIG_IP_NF_NAT_LOCAL
110196                                 /* LOCAL_IN hook doesn't have a chain!  */
110197 -                               if (hooknum == NF_IP_LOCAL_IN) {
110198 -                                       ret = NF_ACCEPT;
110199 -                               } else
110200 +                               if (hooknum == NF_IP_LOCAL_IN)
110201 +                                       ret = alloc_null_binding(ct, info,
110202 +                                                                hooknum);
110203 +                               else
110204  #endif
110205                                 ret = ip_nat_rule_find(pskb, hooknum, in, out,
110206                                                        ct, info);
110207 @@ -142,13 +142,6 @@ ip_nat_fn(unsigned int hooknum,
110208                                 WRITE_UNLOCK(&ip_nat_lock);
110209                                 return ret;
110210                         }
110211 -
110212 -                       if (in_hashes) {
110213 -                               IP_NF_ASSERT(info->bysource.conntrack);
110214 -                               replace_in_hashes(ct, info);
110215 -                       } else {
110216 -                               place_in_hashes(ct, info);
110217 -                       }
110218                 } else
110219                         DEBUGP("Already setup manip %s for ct %p\n",
110220                                maniptype == IP_NAT_MANIP_SRC ? "SRC" : "DST",
110221 @@ -199,6 +192,7 @@ ip_nat_out(unsigned int hooknum,
110222         return ip_nat_fn(hooknum, pskb, in, out, okfn);
110223  }
110224  
110225 +#ifdef CONFIG_IP_NF_NAT_LOCAL
110226  static unsigned int
110227  ip_nat_local_fn(unsigned int hooknum,
110228                 struct sk_buff **pskb,
110229 @@ -224,6 +218,7 @@ ip_nat_local_fn(unsigned int hooknum,
110230                 return ip_route_me_harder(pskb) == 0 ? ret : NF_DROP;
110231         return ret;
110232  }
110233 +#endif
110234  
110235  /* We must be after connection tracking and before packet filtering. */
110236  
110237 @@ -245,6 +240,7 @@ static struct nf_hook_ops ip_nat_out_ops
110238         .priority       = NF_IP_PRI_NAT_SRC,
110239  };
110240  
110241 +#ifdef CONFIG_IP_NF_NAT_LOCAL
110242  /* Before packet filtering, change destination */
110243  static struct nf_hook_ops ip_nat_local_out_ops = {
110244         .hook           = ip_nat_local_fn,
110245 @@ -254,7 +250,7 @@ static struct nf_hook_ops ip_nat_local_o
110246         .priority       = NF_IP_PRI_NAT_DST,
110247  };
110248  
110249 -#ifdef CONFIG_IP_NF_NAT_LOCAL
110250 +/* After packet filtering, change source for reply packets of LOCAL_OUT DNAT */
110251  static struct nf_hook_ops ip_nat_local_in_ops = {
110252         .hook           = ip_nat_fn,
110253         .owner          = THIS_MODULE,
110254 @@ -324,12 +320,12 @@ static int init_or_cleanup(int init)
110255                 printk("ip_nat_init: can't register out hook.\n");
110256                 goto cleanup_inops;
110257         }
110258 +#ifdef CONFIG_IP_NF_NAT_LOCAL
110259         ret = nf_register_hook(&ip_nat_local_out_ops);
110260         if (ret < 0) {
110261                 printk("ip_nat_init: can't register local out hook.\n");
110262                 goto cleanup_outops;
110263         }
110264 -#ifdef CONFIG_IP_NF_NAT_LOCAL
110265         ret = nf_register_hook(&ip_nat_local_in_ops);
110266         if (ret < 0) {
110267                 printk("ip_nat_init: can't register local in hook.\n");
110268 @@ -342,9 +338,9 @@ static int init_or_cleanup(int init)
110269  #ifdef CONFIG_IP_NF_NAT_LOCAL
110270         nf_unregister_hook(&ip_nat_local_in_ops);
110271   cleanup_localoutops:
110272 -#endif
110273         nf_unregister_hook(&ip_nat_local_out_ops);
110274   cleanup_outops:
110275 +#endif
110276         nf_unregister_hook(&ip_nat_out_ops);
110277   cleanup_inops:
110278         nf_unregister_hook(&ip_nat_in_ops);
110279 --- linux-2.6.0-test6/net/ipv4/netfilter/ipt_owner.c    2003-09-08 13:58:59.000000000 -0700
110280 +++ 25/net/ipv4/netfilter/ipt_owner.c   2003-10-05 00:36:15.000000000 -0700
110281 @@ -90,7 +90,7 @@ match_sid(const struct sk_buff *skb, pid
110282         read_lock(&tasklist_lock);
110283         do_each_thread(g, p) {
110284                 struct files_struct *files;
110285 -               if (p->session != sid)
110286 +               if (process_session(p) != sid)
110287                         continue;
110288  
110289                 task_lock(p);
110290 --- linux-2.6.0-test6/net/ipv4/netfilter/ipt_REJECT.c   2003-09-27 18:57:47.000000000 -0700
110291 +++ 25/net/ipv4/netfilter/ipt_REJECT.c  2003-10-05 00:33:25.000000000 -0700
110292 @@ -40,16 +40,17 @@ static void connection_attach(struct sk_
110293         }
110294  }
110295  
110296 -static inline struct rtable *route_reverse(struct sk_buff *skb, int local)
110297 +static inline struct rtable *route_reverse(struct sk_buff *skb, int hook)
110298  {
110299         struct iphdr *iph = skb->nh.iph;
110300         struct dst_entry *odst;
110301         struct flowi fl = {};
110302         struct rtable *rt;
110303  
110304 -       if (local) {
110305 +       if (hook != NF_IP_FORWARD) {
110306                 fl.nl_u.ip4_u.daddr = iph->saddr;
110307 -               fl.nl_u.ip4_u.saddr = iph->daddr;
110308 +               if (hook == NF_IP_LOCAL_IN)
110309 +                       fl.nl_u.ip4_u.saddr = iph->daddr;
110310                 fl.nl_u.ip4_u.tos = RT_TOS(iph->tos);
110311  
110312                 if (ip_route_output_key(&rt, &fl) != 0)
110313 @@ -81,7 +82,7 @@ static inline struct rtable *route_rever
110314  }
110315  
110316  /* Send RST reply */
110317 -static void send_reset(struct sk_buff *oldskb, int local)
110318 +static void send_reset(struct sk_buff *oldskb, int hook)
110319  {
110320         struct sk_buff *nskb;
110321         struct tcphdr otcph, *tcph;
110322 @@ -104,7 +105,7 @@ static void send_reset(struct sk_buff *o
110323                 return;
110324  
110325         /* FIXME: Check checksum --RR */
110326 -       if ((rt = route_reverse(oldskb, local)) == NULL)
110327 +       if ((rt = route_reverse(oldskb, hook)) == NULL)
110328                 return;
110329  
110330         hh_len = (rt->u.dst.dev->hard_header_len + 15)&~15;
110331 @@ -390,7 +391,7 @@ static unsigned int reject(struct sk_buf
110332                 send_unreach(*pskb, ICMP_PKT_FILTERED);
110333                 break;
110334         case IPT_TCP_RESET:
110335 -               send_reset(*pskb, hooknum == NF_IP_LOCAL_IN);
110336 +               send_reset(*pskb, hooknum);
110337         case IPT_ICMP_ECHOREPLY:
110338                 /* Doesn't happen. */
110339                 break;
110340 --- linux-2.6.0-test6/net/ipv4/protocol.c       2003-06-14 12:17:58.000000000 -0700
110341 +++ 25/net/ipv4/protocol.c      2003-10-05 00:33:25.000000000 -0700
110342 @@ -27,6 +27,7 @@
110343  
110344  #include <asm/uaccess.h>
110345  #include <asm/system.h>
110346 +#include <linux/module.h>
110347  #include <linux/types.h>
110348  #include <linux/kernel.h>
110349  #include <linux/sched.h>
110350 @@ -95,3 +96,6 @@ int inet_del_protocol(struct inet_protoc
110351  
110352         return ret;
110353  }
110354 +
110355 +EXPORT_SYMBOL(inet_add_protocol);
110356 +EXPORT_SYMBOL(inet_del_protocol);
110357 --- linux-2.6.0-test6/net/ipv4/route.c  2003-09-27 18:57:47.000000000 -0700
110358 +++ 25/net/ipv4/route.c 2003-10-05 00:33:25.000000000 -0700
110359 @@ -62,6 +62,7 @@
110360   */
110361  
110362  #include <linux/config.h>
110363 +#include <linux/module.h>
110364  #include <asm/uaccess.h>
110365  #include <asm/system.h>
110366  #include <asm/bitops.h>
110367 @@ -2823,3 +2824,7 @@ out_enomem1:
110368         rc = -ENOMEM;
110369         goto out;
110370  }
110371 +
110372 +EXPORT_SYMBOL(__ip_select_ident);
110373 +EXPORT_SYMBOL(ip_route_input);
110374 +EXPORT_SYMBOL(ip_route_output_key);
110375 --- linux-2.6.0-test6/net/ipv4/sysctl_net_ipv4.c        2003-08-22 19:23:42.000000000 -0700
110376 +++ 25/net/ipv4/sysctl_net_ipv4.c       2003-10-05 00:33:25.000000000 -0700
110377 @@ -8,6 +8,7 @@
110378   */
110379  
110380  #include <linux/mm.h>
110381 +#include <linux/module.h>
110382  #include <linux/sysctl.h>
110383  #include <linux/config.h>
110384  #include <net/snmp.h>
110385 @@ -587,3 +588,5 @@ ctl_table ipv4_table[] = {
110386  };
110387  
110388  #endif /* CONFIG_SYSCTL */
110389 +
110390 +EXPORT_SYMBOL(ipv4_config);
110391 --- linux-2.6.0-test6/net/ipv4/tcp.c    2003-06-22 12:04:45.000000000 -0700
110392 +++ 25/net/ipv4/tcp.c   2003-10-05 00:33:25.000000000 -0700
110393 @@ -248,6 +248,7 @@
110394   */
110395  
110396  #include <linux/config.h>
110397 +#include <linux/module.h>
110398  #include <linux/types.h>
110399  #include <linux/fcntl.h>
110400  #include <linux/poll.h>
110401 @@ -2682,3 +2683,26 @@ void __init tcp_init(void)
110402  
110403         tcpdiag_init();
110404  }
110405 +
110406 +EXPORT_SYMBOL(__tcp_mem_reclaim);
110407 +EXPORT_SYMBOL(sysctl_tcp_rmem);
110408 +EXPORT_SYMBOL(sysctl_tcp_wmem);
110409 +EXPORT_SYMBOL(tcp_accept);
110410 +EXPORT_SYMBOL(tcp_close);
110411 +EXPORT_SYMBOL(tcp_close_state);
110412 +EXPORT_SYMBOL(tcp_destroy_sock);
110413 +EXPORT_SYMBOL(tcp_disconnect);
110414 +EXPORT_SYMBOL(tcp_getsockopt);
110415 +EXPORT_SYMBOL(tcp_ioctl);
110416 +EXPORT_SYMBOL(tcp_openreq_cachep);
110417 +EXPORT_SYMBOL(tcp_poll);
110418 +EXPORT_SYMBOL(tcp_read_sock);
110419 +EXPORT_SYMBOL(tcp_recvmsg);
110420 +EXPORT_SYMBOL(tcp_sendmsg);
110421 +EXPORT_SYMBOL(tcp_sendpage);
110422 +EXPORT_SYMBOL(tcp_setsockopt);
110423 +EXPORT_SYMBOL(tcp_shutdown);
110424 +EXPORT_SYMBOL(tcp_sockets_allocated);
110425 +EXPORT_SYMBOL(tcp_statistics);
110426 +EXPORT_SYMBOL(tcp_timewait_cachep);
110427 +EXPORT_SYMBOL(tcp_write_space);
110428 --- linux-2.6.0-test6/net/ipv4/tcp_input.c      2003-07-27 12:14:40.000000000 -0700
110429 +++ 25/net/ipv4/tcp_input.c     2003-10-05 00:33:25.000000000 -0700
110430 @@ -65,6 +65,7 @@
110431  
110432  #include <linux/config.h>
110433  #include <linux/mm.h>
110434 +#include <linux/module.h>
110435  #include <linux/sysctl.h>
110436  #include <net/tcp.h>
110437  #include <net/inet_common.h>
110438 @@ -4089,3 +4090,10 @@ discard:
110439         }
110440         return 0;
110441  }
110442 +
110443 +EXPORT_SYMBOL(sysctl_tcp_ecn);
110444 +EXPORT_SYMBOL(sysctl_tcp_reordering);
110445 +EXPORT_SYMBOL(tcp_cwnd_application_limited);
110446 +EXPORT_SYMBOL(tcp_parse_options);
110447 +EXPORT_SYMBOL(tcp_rcv_established);
110448 +EXPORT_SYMBOL(tcp_rcv_state_process);
110449 --- linux-2.6.0-test6/net/ipv4/tcp_ipv4.c       2003-09-27 18:57:47.000000000 -0700
110450 +++ 25/net/ipv4/tcp_ipv4.c      2003-10-05 00:33:25.000000000 -0700
110451 @@ -56,6 +56,7 @@
110452  
110453  #include <linux/types.h>
110454  #include <linux/fcntl.h>
110455 +#include <linux/module.h>
110456  #include <linux/random.h>
110457  #include <linux/cache.h>
110458  #include <linux/jhash.h>
110459 @@ -2644,3 +2645,32 @@ void __init tcp_v4_init(struct net_proto
110460          */
110461         tcp_socket->sk->sk_prot->unhash(tcp_socket->sk);
110462  }
110463 +
110464 +EXPORT_SYMBOL(ipv4_specific);
110465 +EXPORT_SYMBOL(tcp_bind_hash);
110466 +EXPORT_SYMBOL(tcp_bucket_create);
110467 +EXPORT_SYMBOL(tcp_hashinfo);
110468 +EXPORT_SYMBOL(tcp_inherit_port);
110469 +EXPORT_SYMBOL(tcp_listen_wlock);
110470 +EXPORT_SYMBOL(tcp_port_rover);
110471 +EXPORT_SYMBOL(tcp_prot);
110472 +EXPORT_SYMBOL(tcp_put_port);
110473 +EXPORT_SYMBOL(tcp_unhash);
110474 +EXPORT_SYMBOL(tcp_v4_conn_request);
110475 +EXPORT_SYMBOL(tcp_v4_connect);
110476 +EXPORT_SYMBOL(tcp_v4_do_rcv);
110477 +EXPORT_SYMBOL(tcp_v4_lookup_listener);
110478 +EXPORT_SYMBOL(tcp_v4_rebuild_header);
110479 +EXPORT_SYMBOL(tcp_v4_remember_stamp);
110480 +EXPORT_SYMBOL(tcp_v4_send_check);
110481 +EXPORT_SYMBOL(tcp_v4_syn_recv_sock);
110482 +
110483 +#ifdef CONFIG_PROC_FS
110484 +EXPORT_SYMBOL(tcp_proc_register);
110485 +EXPORT_SYMBOL(tcp_proc_unregister);
110486 +#endif
110487 +#ifdef CONFIG_SYSCTL
110488 +EXPORT_SYMBOL(sysctl_local_port_range);
110489 +EXPORT_SYMBOL(sysctl_max_syn_backlog);
110490 +EXPORT_SYMBOL(sysctl_tcp_low_latency);
110491 +#endif
110492 --- linux-2.6.0-test6/net/ipv4/tcp_minisocks.c  2003-07-02 14:53:18.000000000 -0700
110493 +++ 25/net/ipv4/tcp_minisocks.c 2003-10-05 00:33:25.000000000 -0700
110494 @@ -22,6 +22,7 @@
110495  
110496  #include <linux/config.h>
110497  #include <linux/mm.h>
110498 +#include <linux/module.h>
110499  #include <linux/sysctl.h>
110500  #include <linux/workqueue.h>
110501  #include <net/tcp.h>
110502 @@ -1053,3 +1054,13 @@ int tcp_child_process(struct sock *paren
110503         sock_put(child);
110504         return ret;
110505  }
110506 +
110507 +EXPORT_SYMBOL(tcp_check_req);
110508 +EXPORT_SYMBOL(tcp_child_process);
110509 +EXPORT_SYMBOL(tcp_create_openreq_child);
110510 +EXPORT_SYMBOL(tcp_timewait_state_process);
110511 +EXPORT_SYMBOL(tcp_tw_deschedule);
110512 +
110513 +#ifdef CONFIG_SYSCTL
110514 +EXPORT_SYMBOL(sysctl_tcp_tw_recycle);
110515 +#endif
110516 --- linux-2.6.0-test6/net/ipv4/tcp_output.c     2003-07-02 14:53:18.000000000 -0700
110517 +++ 25/net/ipv4/tcp_output.c    2003-10-05 00:33:25.000000000 -0700
110518 @@ -39,6 +39,7 @@
110519  #include <net/tcp.h>
110520  
110521  #include <linux/compiler.h>
110522 +#include <linux/module.h>
110523  #include <linux/smp_lock.h>
110524  
110525  /* People can turn this off for buggy TCP's found in printers etc. */
110526 @@ -1542,3 +1543,14 @@ void tcp_send_probe0(struct sock *sk)
110527                                       min(tp->rto << tp->backoff, TCP_RESOURCE_PROBE_INTERVAL));
110528         }
110529  }
110530 +
110531 +EXPORT_SYMBOL(tcp_acceptable_seq);
110532 +EXPORT_SYMBOL(tcp_connect);
110533 +EXPORT_SYMBOL(tcp_connect_init);
110534 +EXPORT_SYMBOL(tcp_make_synack);
110535 +EXPORT_SYMBOL(tcp_send_synack);
110536 +EXPORT_SYMBOL(tcp_simple_retransmit);
110537 +EXPORT_SYMBOL(tcp_sync_mss);
110538 +EXPORT_SYMBOL(tcp_transmit_skb);
110539 +EXPORT_SYMBOL(tcp_write_wakeup);
110540 +EXPORT_SYMBOL(tcp_write_xmit);
110541 --- linux-2.6.0-test6/net/ipv4/tcp_timer.c      2003-06-16 22:32:21.000000000 -0700
110542 +++ 25/net/ipv4/tcp_timer.c     2003-10-05 00:33:25.000000000 -0700
110543 @@ -20,6 +20,7 @@
110544   *             Jorge Cwik, <jorge@laser.satlink.net>
110545   */
110546  
110547 +#include <linux/module.h>
110548  #include <net/tcp.h>
110549  
110550  int sysctl_tcp_syn_retries = TCP_SYN_RETRIES; 
110551 @@ -656,3 +657,8 @@ out:
110552         bh_unlock_sock(sk);
110553         sock_put(sk);
110554  }
110555 +
110556 +EXPORT_SYMBOL(tcp_clear_xmit_timers);
110557 +EXPORT_SYMBOL(tcp_delete_keepalive_timer);
110558 +EXPORT_SYMBOL(tcp_init_xmit_timers);
110559 +EXPORT_SYMBOL(tcp_reset_keepalive_timer);
110560 --- linux-2.6.0-test6/net/ipv4/udp.c    2003-09-27 18:57:47.000000000 -0700
110561 +++ 25/net/ipv4/udp.c   2003-10-05 00:33:25.000000000 -0700
110562 @@ -83,6 +83,7 @@
110563  #include <asm/ioctls.h>
110564  #include <linux/types.h>
110565  #include <linux/fcntl.h>
110566 +#include <linux/module.h>
110567  #include <linux/socket.h>
110568  #include <linux/sockios.h>
110569  #include <linux/in.h>
110570 @@ -1532,3 +1533,17 @@ void udp4_proc_exit(void)
110571         udp_proc_unregister(&udp4_seq_afinfo);
110572  }
110573  #endif /* CONFIG_PROC_FS */
110574 +
110575 +EXPORT_SYMBOL(udp_connect);
110576 +EXPORT_SYMBOL(udp_disconnect);
110577 +EXPORT_SYMBOL(udp_hash);
110578 +EXPORT_SYMBOL(udp_hash_lock);
110579 +EXPORT_SYMBOL(udp_ioctl);
110580 +EXPORT_SYMBOL(udp_port_rover);
110581 +EXPORT_SYMBOL(udp_prot);
110582 +EXPORT_SYMBOL(udp_sendmsg);
110583 +
110584 +#ifdef CONFIG_PROC_FS
110585 +EXPORT_SYMBOL(udp_proc_register);
110586 +EXPORT_SYMBOL(udp_proc_unregister);
110587 +#endif
110588 --- linux-2.6.0-test6/net/ipv4/utils.c  2003-07-02 14:53:18.000000000 -0700
110589 +++ 25/net/ipv4/utils.c 2003-10-05 00:33:25.000000000 -0700
110590 @@ -21,6 +21,7 @@
110591   *             2 of the License, or (at your option) any later version.
110592   */
110593  
110594 +#include <linux/module.h>
110595  #include <linux/types.h>
110596  #include <asm/byteorder.h>
110597  
110598 @@ -55,3 +56,4 @@ __u32 in_aton(const char *str)
110599         return(htonl(l));
110600  }
110601  
110602 +EXPORT_SYMBOL(in_aton);
110603 --- linux-2.6.0-test6/net/ipv4/xfrm4_tunnel.c   2003-08-22 19:23:42.000000000 -0700
110604 +++ 25/net/ipv4/xfrm4_tunnel.c  2003-10-05 00:33:25.000000000 -0700
110605 @@ -169,6 +169,7 @@ static struct xfrm_type ipip_type = {
110606  static struct inet_protocol ipip_protocol = {
110607         .handler        =       ipip_rcv,
110608         .err_handler    =       ipip_err,
110609 +       .no_policy      =       1,
110610  };
110611  
110612  static int __init ipip_init(void)
110613 --- linux-2.6.0-test6/net/ipv6/netfilter/ip6t_ipv6header.c      2003-06-14 12:18:51.000000000 -0700
110614 +++ 25/net/ipv6/netfilter/ip6t_ipv6header.c     2003-10-05 00:33:25.000000000 -0700
110615 @@ -126,18 +126,11 @@ ipv6header_checkentry(const char *tablen
110616         return 1;
110617  }
110618  
110619 -static void
110620 -ipv6header_destroy(void *matchinfo,
110621 -                  unsigned int matchinfosize)
110622 -{
110623 -       return;
110624 -}
110625 -
110626  static struct ip6t_match ip6t_ipv6header_match = {
110627         .name           = "ipv6header",
110628         .match          = &ipv6header_match,
110629         .checkentry     = &ipv6header_checkentry,
110630 -       .destroy        = &ipv6header_destroy,
110631 +       .destroy        = NULL,
110632         .me             = THIS_MODULE,
110633  };
110634  
110635 --- linux-2.6.0-test6/net/ipv6/netfilter/ip6t_owner.c   2003-06-14 12:18:30.000000000 -0700
110636 +++ 25/net/ipv6/netfilter/ip6t_owner.c  2003-10-05 00:36:15.000000000 -0700
110637 @@ -56,7 +56,7 @@ match_sid(const struct sk_buff *skb, pid
110638         read_lock(&tasklist_lock);
110639         do_each_thread(g, p) {
110640                 struct files_struct *files;
110641 -               if (p->session != sid)
110642 +               if (process_session(p) != sid)
110643                         continue;
110644  
110645                 task_lock(p);
110646 --- linux-2.6.0-test6/net/irda/irda_device.c    2003-09-08 13:58:59.000000000 -0700
110647 +++ 25/net/irda/irda_device.c   2003-10-05 00:33:25.000000000 -0700
110648 @@ -85,7 +85,7 @@ static void irda_task_timer_expired(void
110649  
110650  int __init irda_device_init( void)
110651  {
110652 -       dongles = hashbin_new(HB_LOCK);
110653 +       dongles = hashbin_new(HB_NOLOCK);
110654         if (dongles == NULL) {
110655                 printk(KERN_WARNING "IrDA: Can't allocate dongles hashbin!\n");
110656                 return -ENOMEM;
110657 @@ -109,7 +109,9 @@ void __exit irda_device_cleanup(void)
110658         IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
110659  
110660         hashbin_delete(tasks, (FREE_FUNC) __irda_task_delete);
110661 +       spin_lock(&dongles->hb_spinlock);
110662         hashbin_delete(dongles, NULL);
110663 +       spin_unlock(&dongles->hb_spinlock);
110664  }
110665  
110666  /*
110667 @@ -378,8 +380,6 @@ void irda_device_setup(struct net_device
110668          dev->hard_header_len = 0;
110669          dev->addr_len        = 0;
110670  
110671 -       dev->destructor      = free_netdev;
110672 -
110673          dev->type            = ARPHRD_IRDA;
110674          dev->tx_queue_len    = 8; /* Window size + 1 s-frame */
110675  
110676 @@ -390,6 +390,17 @@ void irda_device_setup(struct net_device
110677  }
110678  
110679  /*
110680 + * Funciton  alloc_irdadev 
110681 + *     Allocates and sets up an IRDA device in a manner similar to
110682 + *     alloc_etherdev.
110683 + */
110684 +struct net_device *alloc_irdadev(int sizeof_priv)
110685 +{
110686 +       return alloc_netdev(sizeof_priv, "irda%d", irda_device_setup);
110687 +}
110688 +
110689 +
110690 +/*
110691   * Function irda_device_txqueue_empty (dev)
110692   *
110693   *    Check if there is still some frames in the transmit queue for this
110694 @@ -415,25 +426,34 @@ int irda_device_txqueue_empty(struct net
110695  dongle_t *irda_device_dongle_init(struct net_device *dev, int type)
110696  {
110697         struct dongle_reg *reg;
110698 -       dongle_t *dongle;
110699 +       dongle_t *dongle = NULL;
110700 +
110701 +       might_sleep();
110702  
110703 -       ASSERT(dev != NULL, return NULL;);
110704 +       spin_lock(&dongles->hb_spinlock);
110705 +       reg = hashbin_find(dongles, type, NULL);
110706  
110707  #ifdef CONFIG_KMOD
110708 -       ASSERT(!in_interrupt(), return NULL;);
110709         /* Try to load the module needed */
110710 -       request_module("irda-dongle-%d", type);
110711 +       if (!reg && capable(CAP_SYS_MODULE)) {
110712 +               spin_unlock(&dongles->hb_spinlock);
110713 +       
110714 +               request_module("irda-dongle-%d", type);
110715 +               
110716 +               spin_lock(&dongles->hb_spinlock);
110717 +               reg = hashbin_find(dongles, type, NULL);
110718 +       }
110719  #endif
110720  
110721 -       if (!(reg = hashbin_lock_find(dongles, type, NULL))) {
110722 -               ERROR("IrDA: Unable to find requested dongle\n");
110723 -               return NULL;
110724 +       if (!reg || !try_module_get(reg->owner) ) {
110725 +               ERROR("IrDA: Unable to find requested dongle type %x\n", type);
110726 +               goto out;
110727         }
110728  
110729         /* Allocate dongle info for this instance */
110730         dongle = kmalloc(sizeof(dongle_t), GFP_KERNEL);
110731         if (!dongle)
110732 -               return NULL;
110733 +               goto out;
110734  
110735         memset(dongle, 0, sizeof(dongle_t));
110736  
110737 @@ -441,6 +461,8 @@ dongle_t *irda_device_dongle_init(struct
110738         dongle->issue = reg;
110739         dongle->dev = dev;
110740  
110741 + out:
110742 +       spin_unlock(&dongles->hb_spinlock);
110743         return dongle;
110744  }
110745  
110746 @@ -452,7 +474,7 @@ int irda_device_dongle_cleanup(dongle_t 
110747         ASSERT(dongle != NULL, return -1;);
110748  
110749         dongle->issue->close(dongle);
110750 -
110751 +       module_put(dongle->issue->owner);
110752         kfree(dongle);
110753  
110754         return 0;
110755 @@ -463,14 +485,16 @@ int irda_device_dongle_cleanup(dongle_t 
110756   */
110757  int irda_device_register_dongle(struct dongle_reg *new)
110758  {
110759 +       spin_lock(&dongles->hb_spinlock);
110760         /* Check if this dongle has been registered before */
110761 -       if (hashbin_lock_find(dongles, new->type, NULL)) {
110762 -               MESSAGE("%s: Dongle already registered\n", __FUNCTION__);
110763 -                return 0;
110764 -        }
110765 -
110766 -       /* Insert IrDA dongle into hashbin */
110767 -       hashbin_insert(dongles, (irda_queue_t *) new, new->type, NULL);
110768 +       if (hashbin_find(dongles, new->type, NULL)) {
110769 +               MESSAGE("%s: Dongle type %x already registered\n", 
110770 +                       __FUNCTION__, new->type);
110771 +        } else {
110772 +               /* Insert IrDA dongle into hashbin */
110773 +               hashbin_insert(dongles, (irda_queue_t *) new, new->type, NULL);
110774 +       }
110775 +       spin_unlock(&dongles->hb_spinlock);
110776  
110777          return 0;
110778  }
110779 @@ -485,11 +509,11 @@ void irda_device_unregister_dongle(struc
110780  {
110781         struct dongle *node;
110782  
110783 +       spin_lock(&dongles->hb_spinlock);
110784         node = hashbin_remove(dongles, dongle->type, NULL);
110785 -       if (!node) {
110786 +       if (!node) 
110787                 ERROR("%s: dongle not found!\n", __FUNCTION__);
110788 -               return;
110789 -       }
110790 +       spin_unlock(&dongles->hb_spinlock);
110791  }
110792  
110793  /*
110794 --- linux-2.6.0-test6/net/irda/irsyms.c 2003-09-27 18:57:47.000000000 -0700
110795 +++ 25/net/irda/irsyms.c        2003-10-05 00:33:25.000000000 -0700
110796 @@ -150,6 +150,7 @@ EXPORT_SYMBOL(irlap_close);
110797  EXPORT_SYMBOL(irda_init_max_qos_capabilies);
110798  EXPORT_SYMBOL(irda_qos_bits_to_value);
110799  EXPORT_SYMBOL(irda_device_setup);
110800 +EXPORT_SYMBOL(alloc_irdadev);
110801  EXPORT_SYMBOL(irda_device_set_media_busy);
110802  EXPORT_SYMBOL(irda_device_txqueue_empty);
110803  
110804 --- linux-2.6.0-test6/net/Makefile      2003-06-14 12:18:08.000000000 -0700
110805 +++ 25/net/Makefile     2003-10-05 00:33:25.000000000 -0700
110806 @@ -40,6 +40,5 @@ obj-$(CONFIG_VLAN_8021Q)      += 8021q/
110807  obj-$(CONFIG_IP_SCTP)          += sctp/
110808  
110809  ifeq ($(CONFIG_NET),y)
110810 -obj-$(CONFIG_MODULES)          += netsyms.o
110811  obj-$(CONFIG_SYSCTL)           += sysctl_net.o
110812  endif
110813 --- linux-2.6.0-test6/net/netlink/af_netlink.c  2003-09-27 18:57:47.000000000 -0700
110814 +++ 25/net/netlink/af_netlink.c 2003-10-05 00:33:25.000000000 -0700
110815 @@ -1133,4 +1133,22 @@ core_initcall(netlink_proto_init);
110816  module_exit(netlink_proto_exit);
110817  
110818  MODULE_LICENSE("GPL");
110819 +
110820  MODULE_ALIAS_NETPROTO(PF_NETLINK);
110821 +
110822 +EXPORT_SYMBOL(netlink_ack);
110823 +EXPORT_SYMBOL(netlink_broadcast);
110824 +EXPORT_SYMBOL(netlink_broadcast_deliver);
110825 +EXPORT_SYMBOL(netlink_dump_start);
110826 +EXPORT_SYMBOL(netlink_kernel_create);
110827 +EXPORT_SYMBOL(netlink_register_notifier);
110828 +EXPORT_SYMBOL(netlink_set_err);
110829 +EXPORT_SYMBOL(netlink_set_nonroot);
110830 +EXPORT_SYMBOL(netlink_unicast);
110831 +EXPORT_SYMBOL(netlink_unregister_notifier);
110832 +
110833 +#if defined(CONFIG_NETLINK_DEV) || defined(CONFIG_NETLINK_DEV_MODULE)
110834 +EXPORT_SYMBOL(netlink_attach);
110835 +EXPORT_SYMBOL(netlink_detach);
110836 +EXPORT_SYMBOL(netlink_post);
110837 +#endif
110838 --- linux-2.6.0-test6/net/netsyms.c     2003-09-27 18:57:47.000000000 -0700
110839 +++ /dev/null   2002-08-30 16:31:37.000000000 -0700
110840 @@ -1,640 +0,0 @@
110841 -/*
110842 - *  linux/net/netsyms.c
110843 - *
110844 - *  Symbol table for the linux networking subsystem. Moved here to
110845 - *  make life simpler in ksyms.c.
110846 - */
110847 -
110848 -#include <linux/config.h>
110849 -#include <linux/module.h>
110850 -
110851 -#include <linux/types.h>
110852 -#include <linux/net.h>
110853 -#include <linux/in.h>
110854 -#include <linux/netdevice.h>
110855 -#include <linux/inetdevice.h>
110856 -#include <linux/fddidevice.h>
110857 -#include <linux/trdevice.h>
110858 -#include <linux/fcdevice.h>
110859 -#include <linux/ioport.h>
110860 -#include <linux/tty.h>
110861 -#include <linux/ethtool.h>
110862 -#include <net/neighbour.h>
110863 -#include <net/snmp.h>
110864 -#include <net/dst.h>
110865 -#include <net/checksum.h>
110866 -#include <linux/etherdevice.h>
110867 -#include <net/route.h>
110868 -#ifdef CONFIG_HIPPI
110869 -#include <linux/hippidevice.h>
110870 -#endif
110871 -#include <net/pkt_sched.h>
110872 -#include <net/scm.h>
110873 -#include <linux/if_bridge.h>
110874 -#include <linux/if_vlan.h>
110875 -#include <linux/random.h>
110876 -#ifdef CONFIG_NET_DIVERT
110877 -#include <linux/divert.h>
110878 -#endif /* CONFIG_NET_DIVERT */
110879 -
110880 -#ifdef CONFIG_NET
110881 -extern __u32 sysctl_wmem_max;
110882 -extern __u32 sysctl_rmem_max;
110883 -#endif
110884 -
110885 -#ifdef CONFIG_INET
110886 -#include <linux/ip.h>
110887 -#include <net/protocol.h>
110888 -#include <net/arp.h>
110889 -#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
110890 -#include <net/atmclip.h>
110891 -#endif
110892 -#include <net/ip.h>
110893 -#include <net/udp.h>
110894 -#include <net/tcp.h>
110895 -#include <net/icmp.h>
110896 -#include <net/inet_common.h>
110897 -#include <linux/inet.h>
110898 -#include <linux/mroute.h>
110899 -#include <linux/igmp.h>
110900 -#if defined(CONFIG_INET_AH) || defined(CONFIG_INET_AH_MODULE) || defined(CONFIG_INET6_AH) || defined(CONFIG_INET6_AH_MODULE)
110901 -#include <net/ah.h>
110902 -#endif
110903 -#if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE)
110904 -#include <net/esp.h>
110905 -#endif
110906 -
110907 -extern struct net_proto_family inet_family_ops;
110908 -
110909 -#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) \
110910 -   || defined (CONFIG_IP_SCTP_MODULE)
110911 -#include <linux/in6.h>
110912 -#include <linux/icmpv6.h>
110913 -#include <net/ipv6.h>
110914 -#include <net/ndisc.h>
110915 -#include <net/transp_v6.h>
110916 -#include <net/addrconf.h>
110917 -
110918 -extern int sysctl_local_port_range[2];
110919 -extern int tcp_port_rover;
110920 -extern int udp_port_rover;
110921 -#endif
110922 -
110923 -#endif
110924 -
110925 -#include <linux/rtnetlink.h>
110926 -
110927 -#ifdef CONFIG_IPX_MODULE
110928 -extern struct datalink_proto   *make_EII_client(void);
110929 -extern struct datalink_proto   *make_8023_client(void);
110930 -extern void destroy_EII_client(struct datalink_proto *);
110931 -extern void destroy_8023_client(struct datalink_proto *);
110932 -#endif
110933 -
110934 -#ifdef CONFIG_ATALK_MODULE
110935 -#include <net/sock.h>
110936 -#endif
110937 -
110938 -#ifdef CONFIG_SYSCTL
110939 -extern int sysctl_max_syn_backlog;
110940 -#endif
110941 -
110942 -/* Skbuff symbols. */
110943 -EXPORT_SYMBOL(skb_over_panic);
110944 -EXPORT_SYMBOL(skb_under_panic);
110945 -
110946 -/* Socket layer registration */
110947 -EXPORT_SYMBOL(sock_register);
110948 -EXPORT_SYMBOL(sock_unregister);
110949 -
110950 -/* Socket locking */
110951 -EXPORT_SYMBOL(__lock_sock);
110952 -EXPORT_SYMBOL(__release_sock);
110953 -
110954 -/* Socket layer support routines */
110955 -EXPORT_SYMBOL(memcpy_fromiovec);
110956 -EXPORT_SYMBOL(memcpy_tokerneliovec);
110957 -EXPORT_SYMBOL(sock_create);
110958 -EXPORT_SYMBOL(sock_alloc);
110959 -EXPORT_SYMBOL(sock_release);
110960 -EXPORT_SYMBOL(sock_setsockopt);
110961 -EXPORT_SYMBOL(sock_getsockopt);
110962 -EXPORT_SYMBOL(sock_sendmsg);
110963 -EXPORT_SYMBOL(sock_recvmsg);
110964 -EXPORT_SYMBOL(sk_alloc);
110965 -EXPORT_SYMBOL(sk_free);
110966 -EXPORT_SYMBOL(sk_send_sigurg);
110967 -EXPORT_SYMBOL(sock_wake_async);
110968 -EXPORT_SYMBOL(sock_alloc_send_skb);
110969 -EXPORT_SYMBOL(sock_alloc_send_pskb);
110970 -EXPORT_SYMBOL(sock_init_data);
110971 -EXPORT_SYMBOL(sock_no_release);
110972 -EXPORT_SYMBOL(sock_no_bind);
110973 -EXPORT_SYMBOL(sock_no_connect);
110974 -EXPORT_SYMBOL(sock_no_socketpair);
110975 -EXPORT_SYMBOL(sock_no_accept);
110976 -EXPORT_SYMBOL(sock_no_getname);
110977 -EXPORT_SYMBOL(sock_no_poll);
110978 -EXPORT_SYMBOL(sock_no_ioctl);
110979 -EXPORT_SYMBOL(sock_no_listen);
110980 -EXPORT_SYMBOL(sock_no_shutdown);
110981 -EXPORT_SYMBOL(sock_no_getsockopt);
110982 -EXPORT_SYMBOL(sock_no_setsockopt);
110983 -EXPORT_SYMBOL(sock_no_sendmsg);
110984 -EXPORT_SYMBOL(sock_no_recvmsg);
110985 -EXPORT_SYMBOL(sock_no_mmap);
110986 -EXPORT_SYMBOL(sock_no_sendpage);
110987 -EXPORT_SYMBOL(sock_rfree);
110988 -EXPORT_SYMBOL(sock_wfree);
110989 -EXPORT_SYMBOL(sock_wmalloc);
110990 -EXPORT_SYMBOL(sock_rmalloc);
110991 -EXPORT_SYMBOL(__skb_linearize);
110992 -EXPORT_SYMBOL(skb_checksum);
110993 -EXPORT_SYMBOL(skb_checksum_help);
110994 -EXPORT_SYMBOL(skb_recv_datagram);
110995 -EXPORT_SYMBOL(skb_free_datagram);
110996 -EXPORT_SYMBOL(skb_copy_datagram);
110997 -EXPORT_SYMBOL(skb_copy_datagram_iovec);
110998 -EXPORT_SYMBOL(skb_copy_and_csum_datagram_iovec);
110999 -EXPORT_SYMBOL(skb_copy_bits);
111000 -EXPORT_SYMBOL(skb_copy_and_csum_bits);
111001 -EXPORT_SYMBOL(skb_copy_and_csum_dev);
111002 -EXPORT_SYMBOL(skb_copy_expand);
111003 -EXPORT_SYMBOL(___pskb_trim);
111004 -EXPORT_SYMBOL(__pskb_pull_tail);
111005 -EXPORT_SYMBOL(pskb_expand_head);
111006 -EXPORT_SYMBOL(pskb_copy);
111007 -EXPORT_SYMBOL(skb_realloc_headroom);
111008 -EXPORT_SYMBOL(datagram_poll);
111009 -EXPORT_SYMBOL(put_cmsg);
111010 -EXPORT_SYMBOL(sock_kmalloc);
111011 -EXPORT_SYMBOL(sock_kfree_s);
111012 -EXPORT_SYMBOL(sock_map_fd);
111013 -EXPORT_SYMBOL(sockfd_lookup);
111014 -
111015 -EXPORT_SYMBOL(sk_run_filter);
111016 -EXPORT_SYMBOL(sk_chk_filter);
111017 -
111018 -EXPORT_SYMBOL(neigh_table_init);
111019 -EXPORT_SYMBOL(neigh_table_clear);
111020 -EXPORT_SYMBOL(neigh_resolve_output);
111021 -EXPORT_SYMBOL(neigh_connected_output);
111022 -EXPORT_SYMBOL(neigh_update);
111023 -EXPORT_SYMBOL(neigh_create);
111024 -EXPORT_SYMBOL(neigh_lookup);
111025 -EXPORT_SYMBOL(__neigh_event_send);
111026 -EXPORT_SYMBOL(neigh_event_ns);
111027 -EXPORT_SYMBOL(neigh_ifdown);
111028 -#ifdef CONFIG_ARPD
111029 -EXPORT_SYMBOL(neigh_app_ns);
111030 -#endif
111031 -#ifdef CONFIG_SYSCTL
111032 -EXPORT_SYMBOL(neigh_sysctl_register);
111033 -EXPORT_SYMBOL(neigh_sysctl_unregister);
111034 -#endif
111035 -EXPORT_SYMBOL(pneigh_lookup);
111036 -EXPORT_SYMBOL(pneigh_enqueue);
111037 -EXPORT_SYMBOL(neigh_destroy);
111038 -EXPORT_SYMBOL(neigh_parms_alloc);
111039 -EXPORT_SYMBOL(neigh_parms_release);
111040 -EXPORT_SYMBOL(neigh_rand_reach_time);
111041 -EXPORT_SYMBOL(neigh_compat_output); 
111042 -EXPORT_SYMBOL(neigh_changeaddr); 
111043 -
111044 -/*     dst_entry       */
111045 -EXPORT_SYMBOL(dst_alloc);
111046 -EXPORT_SYMBOL(__dst_free);
111047 -EXPORT_SYMBOL(dst_destroy);
111048 -
111049 -/*     misc. support routines */
111050 -EXPORT_SYMBOL(net_ratelimit);
111051 -EXPORT_SYMBOL(net_random);
111052 -EXPORT_SYMBOL(net_srandom);
111053 -
111054 -/* Needed by smbfs.o */
111055 -EXPORT_SYMBOL(__scm_destroy);
111056 -EXPORT_SYMBOL(__scm_send);
111057 -
111058 -/* Needed by unix.o */
111059 -EXPORT_SYMBOL(scm_fp_dup);
111060 -EXPORT_SYMBOL(files_stat);
111061 -EXPORT_SYMBOL(memcpy_toiovec);
111062 -
111063 -#ifdef CONFIG_IPX_MODULE
111064 -EXPORT_SYMBOL(make_8023_client);
111065 -EXPORT_SYMBOL(destroy_8023_client);
111066 -EXPORT_SYMBOL(make_EII_client);
111067 -EXPORT_SYMBOL(destroy_EII_client);
111068 -#endif
111069 -
111070 -/* for 801q VLAN support */
111071 -#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
111072 -EXPORT_SYMBOL(dev_change_flags);
111073 -#endif
111074 -
111075 -EXPORT_SYMBOL(scm_detach_fds);
111076 -
111077 -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
111078 -EXPORT_SYMBOL(br_handle_frame_hook);
111079 -#endif
111080 -
111081 -#ifdef CONFIG_NET_DIVERT
111082 -EXPORT_SYMBOL(alloc_divert_blk);
111083 -EXPORT_SYMBOL(free_divert_blk);
111084 -#endif /* CONFIG_NET_DIVERT */
111085 -
111086 -#ifdef CONFIG_INET
111087 -/* Internet layer registration */
111088 -EXPORT_SYMBOL(inetdev_lock);
111089 -EXPORT_SYMBOL(inet_add_protocol);
111090 -EXPORT_SYMBOL(inet_del_protocol);
111091 -EXPORT_SYMBOL(inet_register_protosw);
111092 -EXPORT_SYMBOL(inet_unregister_protosw);
111093 -EXPORT_SYMBOL(ip_route_output_key);
111094 -EXPORT_SYMBOL(ip_route_input);
111095 -EXPORT_SYMBOL(icmp_send);
111096 -EXPORT_SYMBOL(icmp_statistics);
111097 -EXPORT_SYMBOL(icmp_err_convert);
111098 -EXPORT_SYMBOL(ip_options_compile);
111099 -EXPORT_SYMBOL(ip_options_undo);
111100 -EXPORT_SYMBOL(arp_send);
111101 -EXPORT_SYMBOL(arp_broken_ops);
111102 -EXPORT_SYMBOL(__ip_select_ident);
111103 -EXPORT_SYMBOL(ip_send_check);
111104 -EXPORT_SYMBOL(ip_fragment);
111105 -EXPORT_SYMBOL(inet_family_ops);
111106 -EXPORT_SYMBOL(in_aton);
111107 -EXPORT_SYMBOL(ip_mc_inc_group);
111108 -EXPORT_SYMBOL(ip_mc_dec_group);
111109 -EXPORT_SYMBOL(ip_mc_join_group);
111110 -EXPORT_SYMBOL(ip_finish_output);
111111 -EXPORT_SYMBOL(inet_stream_ops);
111112 -EXPORT_SYMBOL(inet_dgram_ops);
111113 -EXPORT_SYMBOL(ip_cmsg_recv);
111114 -EXPORT_SYMBOL(inet_addr_type); 
111115 -EXPORT_SYMBOL(inet_select_addr);
111116 -EXPORT_SYMBOL(ip_dev_find);
111117 -EXPORT_SYMBOL(inetdev_by_index);
111118 -EXPORT_SYMBOL(in_dev_finish_destroy);
111119 -EXPORT_SYMBOL(ip_defrag);
111120 -EXPORT_SYMBOL(inet_peer_idlock);
111121 -
111122 -/* Route manipulation */
111123 -EXPORT_SYMBOL(ip_rt_ioctl);
111124 -EXPORT_SYMBOL(devinet_ioctl);
111125 -EXPORT_SYMBOL(register_inetaddr_notifier);
111126 -EXPORT_SYMBOL(unregister_inetaddr_notifier);
111127 -
111128 -/* proc */
111129 -#ifdef CONFIG_PROC_FS
111130 -EXPORT_SYMBOL(udp_proc_register);
111131 -EXPORT_SYMBOL(udp_proc_unregister);
111132 -EXPORT_SYMBOL(tcp_proc_register);
111133 -EXPORT_SYMBOL(tcp_proc_unregister);
111134 -#endif
111135 -
111136 -/* needed for ip_gre -cw */
111137 -EXPORT_SYMBOL(ip_statistics);
111138 -#if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE)
111139 -EXPORT_SYMBOL_GPL(skb_cow_data);
111140 -EXPORT_SYMBOL_GPL(pskb_put);
111141 -EXPORT_SYMBOL_GPL(skb_to_sgvec);
111142 -#endif
111143 -
111144 -EXPORT_SYMBOL(flow_cache_lookup);
111145 -EXPORT_SYMBOL(flow_cache_genid);
111146 -
111147 -#if defined (CONFIG_IPV6_MODULE) || defined (CONFIG_IP_SCTP_MODULE)
111148 -/* inet functions common to v4 and v6 */
111149 -EXPORT_SYMBOL(inet_release);
111150 -EXPORT_SYMBOL(inet_stream_connect);
111151 -EXPORT_SYMBOL(inet_dgram_connect);
111152 -EXPORT_SYMBOL(inet_accept);
111153 -EXPORT_SYMBOL(inet_listen);
111154 -EXPORT_SYMBOL(inet_shutdown);
111155 -EXPORT_SYMBOL(inet_setsockopt);
111156 -EXPORT_SYMBOL(inet_getsockopt);
111157 -EXPORT_SYMBOL(inet_sendmsg);
111158 -EXPORT_SYMBOL(inet_recvmsg);
111159 -#ifdef INET_REFCNT_DEBUG
111160 -EXPORT_SYMBOL(inet_sock_nr);
111161 -#endif
111162 -EXPORT_SYMBOL(inet_sock_destruct);
111163 -EXPORT_SYMBOL(inet_sock_release);
111164 -
111165 -/* Socket demultiplexing. */
111166 -EXPORT_SYMBOL(tcp_hashinfo);
111167 -EXPORT_SYMBOL(tcp_listen_wlock);
111168 -EXPORT_SYMBOL(udp_hash);
111169 -EXPORT_SYMBOL(udp_hash_lock);
111170 -
111171 -EXPORT_SYMBOL(tcp_destroy_sock);
111172 -EXPORT_SYMBOL(ip_queue_xmit);
111173 -EXPORT_SYMBOL(memcpy_fromiovecend);
111174 -EXPORT_SYMBOL(csum_partial_copy_fromiovecend);
111175 -EXPORT_SYMBOL(tcp_v4_lookup_listener);
111176 -/* UDP/TCP exported functions for TCPv6 */
111177 -EXPORT_SYMBOL(udp_ioctl);
111178 -EXPORT_SYMBOL(udp_connect);
111179 -EXPORT_SYMBOL(udp_disconnect);
111180 -EXPORT_SYMBOL(udp_sendmsg);
111181 -EXPORT_SYMBOL(tcp_bind_hash);
111182 -EXPORT_SYMBOL(tcp_close);
111183 -EXPORT_SYMBOL(tcp_disconnect);
111184 -EXPORT_SYMBOL(tcp_accept);
111185 -EXPORT_SYMBOL(tcp_write_wakeup);
111186 -EXPORT_SYMBOL(tcp_write_space);
111187 -EXPORT_SYMBOL(tcp_poll);
111188 -EXPORT_SYMBOL(tcp_ioctl);
111189 -EXPORT_SYMBOL(tcp_shutdown);
111190 -EXPORT_SYMBOL(tcp_setsockopt);
111191 -EXPORT_SYMBOL(tcp_getsockopt);
111192 -EXPORT_SYMBOL(tcp_recvmsg);
111193 -EXPORT_SYMBOL(tcp_send_synack);
111194 -EXPORT_SYMBOL(tcp_check_req);
111195 -EXPORT_SYMBOL(tcp_child_process);
111196 -EXPORT_SYMBOL(tcp_parse_options);
111197 -EXPORT_SYMBOL(tcp_rcv_established);
111198 -EXPORT_SYMBOL(tcp_init_xmit_timers);
111199 -EXPORT_SYMBOL(tcp_clear_xmit_timers);
111200 -EXPORT_SYMBOL(tcp_statistics);
111201 -EXPORT_SYMBOL(tcp_rcv_state_process);
111202 -EXPORT_SYMBOL(tcp_timewait_state_process);
111203 -EXPORT_SYMBOL(tcp_timewait_cachep);
111204 -EXPORT_SYMBOL(tcp_sendmsg);
111205 -EXPORT_SYMBOL(tcp_v4_rebuild_header);
111206 -EXPORT_SYMBOL(tcp_v4_send_check);
111207 -EXPORT_SYMBOL(tcp_v4_conn_request);
111208 -EXPORT_SYMBOL(tcp_create_openreq_child);
111209 -EXPORT_SYMBOL(tcp_bucket_create);
111210 -EXPORT_SYMBOL(tcp_put_port);
111211 -EXPORT_SYMBOL(tcp_inherit_port);
111212 -EXPORT_SYMBOL(tcp_v4_syn_recv_sock);
111213 -EXPORT_SYMBOL(tcp_v4_do_rcv);
111214 -EXPORT_SYMBOL(tcp_v4_connect);
111215 -EXPORT_SYMBOL(tcp_unhash);
111216 -EXPORT_SYMBOL(udp_prot);
111217 -EXPORT_SYMBOL(tcp_prot);
111218 -EXPORT_SYMBOL(tcp_openreq_cachep);
111219 -EXPORT_SYMBOL(ipv4_specific);
111220 -EXPORT_SYMBOL(tcp_simple_retransmit);
111221 -EXPORT_SYMBOL(tcp_transmit_skb);
111222 -EXPORT_SYMBOL(tcp_connect);
111223 -EXPORT_SYMBOL(tcp_make_synack);
111224 -EXPORT_SYMBOL(tcp_tw_deschedule);
111225 -EXPORT_SYMBOL(tcp_delete_keepalive_timer);
111226 -EXPORT_SYMBOL(tcp_reset_keepalive_timer);
111227 -EXPORT_SYMBOL(sysctl_local_port_range);
111228 -EXPORT_SYMBOL(tcp_port_rover);
111229 -EXPORT_SYMBOL(udp_port_rover);
111230 -EXPORT_SYMBOL(tcp_sync_mss);
111231 -EXPORT_SYMBOL(net_statistics); 
111232 -EXPORT_SYMBOL(__tcp_mem_reclaim);
111233 -EXPORT_SYMBOL(tcp_sockets_allocated);
111234 -EXPORT_SYMBOL(sysctl_tcp_reordering);
111235 -EXPORT_SYMBOL(sysctl_tcp_rmem);
111236 -EXPORT_SYMBOL(sysctl_tcp_wmem);
111237 -EXPORT_SYMBOL(sysctl_tcp_ecn);
111238 -EXPORT_SYMBOL(tcp_cwnd_application_limited);
111239 -EXPORT_SYMBOL(tcp_sendpage);
111240 -EXPORT_SYMBOL(sysctl_tcp_low_latency);
111241 -
111242 -EXPORT_SYMBOL(tcp_write_xmit);
111243 -
111244 -EXPORT_SYMBOL(tcp_v4_remember_stamp); 
111245 -
111246 -extern int sysctl_tcp_tw_recycle;
111247 -
111248 -#ifdef CONFIG_SYSCTL
111249 -EXPORT_SYMBOL(sysctl_tcp_tw_recycle); 
111250 -EXPORT_SYMBOL(sysctl_max_syn_backlog);
111251 -#endif
111252 -
111253 -EXPORT_SYMBOL(ip_generic_getfrag);
111254 -
111255 -#endif
111256 -
111257 -EXPORT_SYMBOL(tcp_read_sock);
111258 -
111259 -#ifdef CONFIG_IP_SCTP_MODULE
111260 -EXPORT_SYMBOL(ip_setsockopt);
111261 -EXPORT_SYMBOL(ip_getsockopt);
111262 -EXPORT_SYMBOL(inet_ioctl);
111263 -EXPORT_SYMBOL(inet_bind);
111264 -EXPORT_SYMBOL(inet_getname);
111265 -#endif /* CONFIG_IP_SCTP_MODULE */
111266 -
111267 -EXPORT_SYMBOL(netlink_set_err);
111268 -EXPORT_SYMBOL(netlink_broadcast);
111269 -EXPORT_SYMBOL(netlink_unicast);
111270 -EXPORT_SYMBOL(netlink_kernel_create);
111271 -EXPORT_SYMBOL(netlink_dump_start);
111272 -EXPORT_SYMBOL(netlink_ack);
111273 -EXPORT_SYMBOL(netlink_set_nonroot);
111274 -EXPORT_SYMBOL(netlink_register_notifier);
111275 -EXPORT_SYMBOL(netlink_unregister_notifier);
111276 -#if defined(CONFIG_NETLINK_DEV) || defined(CONFIG_NETLINK_DEV_MODULE)
111277 -EXPORT_SYMBOL(netlink_attach);
111278 -EXPORT_SYMBOL(netlink_detach);
111279 -EXPORT_SYMBOL(netlink_post);
111280 -#endif
111281 -
111282 -EXPORT_SYMBOL(rtattr_parse);
111283 -EXPORT_SYMBOL(__rta_fill);
111284 -EXPORT_SYMBOL(neigh_delete);
111285 -EXPORT_SYMBOL(neigh_add);
111286 -EXPORT_SYMBOL(neigh_dump_info);
111287 -
111288 -
111289 -/* ABI emulation layers need this */
111290 -EXPORT_SYMBOL(move_addr_to_kernel);
111291 -EXPORT_SYMBOL(move_addr_to_user);
111292 -                  
111293 -/* Used by at least ipip.c.  */
111294 -EXPORT_SYMBOL(ipv4_config);
111295 -
111296 -/* Used by other modules */
111297 -EXPORT_SYMBOL(xrlim_allow);
111298 -
111299 -EXPORT_SYMBOL(ip_rcv);
111300 -EXPORT_SYMBOL(arp_rcv);
111301 -EXPORT_SYMBOL(arp_tbl);
111302 -#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
111303 -EXPORT_SYMBOL(clip_tbl_hook);
111304 -#endif
111305 -EXPORT_SYMBOL(arp_find);
111306 -
111307 -#endif  /* CONFIG_INET */
111308 -
111309 -#ifdef CONFIG_TR
111310 -EXPORT_SYMBOL(tr_source_route);
111311 -EXPORT_SYMBOL(tr_type_trans);
111312 -#endif
111313 -
111314 -/* Device callback registration */
111315 -EXPORT_SYMBOL(register_netdevice_notifier);
111316 -EXPORT_SYMBOL(unregister_netdevice_notifier);
111317 -EXPORT_SYMBOL(call_netdevice_notifiers);
111318 -
111319 -/* support for loadable net drivers */
111320 -#ifdef CONFIG_NET
111321 -EXPORT_SYMBOL(loopback_dev);
111322 -EXPORT_SYMBOL(register_netdevice);
111323 -EXPORT_SYMBOL(unregister_netdevice);
111324 -EXPORT_SYMBOL(free_netdev);
111325 -EXPORT_SYMBOL(synchronize_net);
111326 -EXPORT_SYMBOL(netdev_state_change);
111327 -EXPORT_SYMBOL(netdev_boot_setup_check);
111328 -EXPORT_SYMBOL(dev_new_index);
111329 -EXPORT_SYMBOL(dev_get_by_flags);
111330 -EXPORT_SYMBOL(__dev_get_by_flags);
111331 -EXPORT_SYMBOL(dev_get_by_index);
111332 -EXPORT_SYMBOL(__dev_get_by_index);
111333 -EXPORT_SYMBOL(dev_get_by_name);
111334 -EXPORT_SYMBOL(__dev_get_by_name);
111335 -EXPORT_SYMBOL(dev_getbyhwaddr);
111336 -EXPORT_SYMBOL(netdev_set_master);
111337 -EXPORT_SYMBOL(eth_type_trans);
111338 -#ifdef CONFIG_FDDI
111339 -EXPORT_SYMBOL(fddi_type_trans);
111340 -#endif /* CONFIG_FDDI */
111341 -#if 0
111342 -EXPORT_SYMBOL(eth_copy_and_sum);
111343 -#endif
111344 -EXPORT_SYMBOL(alloc_skb);
111345 -EXPORT_SYMBOL(__kfree_skb);
111346 -EXPORT_SYMBOL(skb_clone);
111347 -EXPORT_SYMBOL(skb_copy);
111348 -EXPORT_SYMBOL(skb_pad);
111349 -EXPORT_SYMBOL(netif_rx);
111350 -EXPORT_SYMBOL(netif_receive_skb);
111351 -EXPORT_SYMBOL(dev_add_pack);
111352 -EXPORT_SYMBOL(dev_remove_pack);
111353 -EXPORT_SYMBOL(__dev_remove_pack);
111354 -EXPORT_SYMBOL(__dev_get);
111355 -EXPORT_SYMBOL(dev_alloc);
111356 -EXPORT_SYMBOL(dev_alloc_name);
111357 -EXPORT_SYMBOL(__netdev_watchdog_up);
111358 -#ifdef CONFIG_KMOD
111359 -EXPORT_SYMBOL(dev_load);
111360 -#endif
111361 -EXPORT_SYMBOL(dev_ioctl);
111362 -EXPORT_SYMBOL(dev_queue_xmit);
111363 -#ifdef CONFIG_NET_HW_FLOWCONTROL
111364 -EXPORT_SYMBOL(netdev_dropping);
111365 -EXPORT_SYMBOL(netdev_register_fc);
111366 -EXPORT_SYMBOL(netdev_unregister_fc);
111367 -EXPORT_SYMBOL(netdev_fc_xoff);
111368 -#endif
111369 -EXPORT_SYMBOL(dev_base);
111370 -EXPORT_SYMBOL(dev_base_lock);
111371 -EXPORT_SYMBOL(dev_open);
111372 -EXPORT_SYMBOL(dev_close);
111373 -EXPORT_SYMBOL(dev_mc_add);
111374 -EXPORT_SYMBOL(dev_mc_delete);
111375 -EXPORT_SYMBOL(dev_mc_upload);
111376 -EXPORT_SYMBOL(dev_set_allmulti);
111377 -EXPORT_SYMBOL(dev_set_promiscuity);
111378 -EXPORT_SYMBOL(__kill_fasync);
111379 -
111380 -EXPORT_SYMBOL(rtnl);
111381 -EXPORT_SYMBOL(rtnetlink_links);
111382 -EXPORT_SYMBOL(rtnetlink_dump_ifinfo);
111383 -EXPORT_SYMBOL(rtnetlink_put_metrics);
111384 -EXPORT_SYMBOL(rtnl_sem);
111385 -EXPORT_SYMBOL(rtnl_lock);
111386 -EXPORT_SYMBOL(rtnl_unlock);
111387 -
111388 -#ifdef CONFIG_HIPPI
111389 -EXPORT_SYMBOL(hippi_type_trans);
111390 -#endif
111391 -
111392 -#ifdef CONFIG_NET_FASTROUTE
111393 -EXPORT_SYMBOL(netdev_fastroute);
111394 -#endif
111395 -
111396 -#ifdef CONFIG_SYSCTL
111397 -EXPORT_SYMBOL(sysctl_wmem_max);
111398 -EXPORT_SYMBOL(sysctl_rmem_max);
111399 -#ifdef CONFIG_INET
111400 -EXPORT_SYMBOL(sysctl_ip_default_ttl);
111401 -#endif
111402 -#endif
111403 -
111404 -/* Packet scheduler modules want these. */
111405 -EXPORT_SYMBOL(qdisc_destroy);
111406 -EXPORT_SYMBOL(qdisc_reset);
111407 -EXPORT_SYMBOL(qdisc_restart);
111408 -EXPORT_SYMBOL(qdisc_create_dflt);
111409 -EXPORT_SYMBOL(noop_qdisc);
111410 -EXPORT_SYMBOL(qdisc_tree_lock);
111411 -#ifdef CONFIG_NET_SCHED
111412 -PSCHED_EXPORTLIST;
111413 -EXPORT_SYMBOL(pfifo_qdisc_ops);
111414 -EXPORT_SYMBOL(bfifo_qdisc_ops);
111415 -EXPORT_SYMBOL(register_qdisc);
111416 -EXPORT_SYMBOL(unregister_qdisc);
111417 -EXPORT_SYMBOL(qdisc_get_rtab);
111418 -EXPORT_SYMBOL(qdisc_put_rtab);
111419 -EXPORT_SYMBOL(qdisc_copy_stats);
111420 -#ifdef CONFIG_NET_ESTIMATOR
111421 -EXPORT_SYMBOL(qdisc_new_estimator);
111422 -EXPORT_SYMBOL(qdisc_kill_estimator);
111423 -#endif
111424 -#ifdef CONFIG_NET_CLS_POLICE
111425 -EXPORT_SYMBOL(tcf_police);
111426 -EXPORT_SYMBOL(tcf_police_locate);
111427 -EXPORT_SYMBOL(tcf_police_destroy);
111428 -EXPORT_SYMBOL(tcf_police_dump);
111429 -#endif
111430 -#endif
111431 -#ifdef CONFIG_NET_CLS
111432 -EXPORT_SYMBOL(register_tcf_proto_ops);
111433 -EXPORT_SYMBOL(unregister_tcf_proto_ops);
111434 -#endif
111435 -#ifdef CONFIG_NETFILTER
111436 -#include <linux/netfilter.h>
111437 -EXPORT_SYMBOL(nf_register_hook);
111438 -EXPORT_SYMBOL(nf_unregister_hook);
111439 -EXPORT_SYMBOL(nf_register_sockopt);
111440 -EXPORT_SYMBOL(nf_unregister_sockopt);
111441 -EXPORT_SYMBOL(nf_reinject);
111442 -EXPORT_SYMBOL(nf_register_queue_handler);
111443 -EXPORT_SYMBOL(nf_unregister_queue_handler);
111444 -EXPORT_SYMBOL(nf_hook_slow);
111445 -EXPORT_SYMBOL(nf_hooks);
111446 -EXPORT_SYMBOL(nf_setsockopt);
111447 -EXPORT_SYMBOL(nf_getsockopt);
111448 -EXPORT_SYMBOL(ip_ct_attach);
111449 -#ifdef CONFIG_INET
111450 -#include <linux/netfilter_ipv4.h>
111451 -EXPORT_SYMBOL(ip_route_me_harder);
111452 -#endif
111453 -#endif
111454 -
111455 -EXPORT_SYMBOL(register_gifconf);
111456 -
111457 -EXPORT_PER_CPU_SYMBOL(softnet_data);
111458 -
111459 -#ifdef CONFIG_NET_RADIO
111460 -#include <net/iw_handler.h>            /* Wireless Extensions driver API */
111461 -EXPORT_SYMBOL(wireless_send_event);
111462 -EXPORT_SYMBOL(iw_handler_set_spy);
111463 -EXPORT_SYMBOL(iw_handler_get_spy);
111464 -EXPORT_SYMBOL(iw_handler_set_thrspy);
111465 -EXPORT_SYMBOL(iw_handler_get_thrspy);
111466 -EXPORT_SYMBOL(wireless_spy_update);
111467 -#endif /* CONFIG_NET_RADIO */
111468 -
111469 -EXPORT_SYMBOL(linkwatch_fire_event);
111470 -
111471 -/* ethtool.c */
111472 -EXPORT_SYMBOL(ethtool_op_get_link);
111473 -EXPORT_SYMBOL(ethtool_op_get_tx_csum);
111474 -EXPORT_SYMBOL(ethtool_op_set_tx_csum);
111475 -EXPORT_SYMBOL(ethtool_op_get_sg);
111476 -EXPORT_SYMBOL(ethtool_op_set_sg);
111477 -EXPORT_SYMBOL(ethtool_op_get_tso);
111478 -EXPORT_SYMBOL(ethtool_op_set_tso);
111479 -
111480 -#endif  /* CONFIG_NET */
111481 --- linux-2.6.0-test6/net/sched/cls_api.c       2003-06-14 12:18:03.000000000 -0700
111482 +++ 25/net/sched/cls_api.c      2003-10-05 00:33:25.000000000 -0700
111483 @@ -467,3 +467,6 @@ int __init tc_filter_init(void)
111484  #endif
111485         return 0;
111486  }
111487 +
111488 +EXPORT_SYMBOL(register_tcf_proto_ops);
111489 +EXPORT_SYMBOL(unregister_tcf_proto_ops);
111490 --- linux-2.6.0-test6/net/sched/estimator.c     2003-09-27 18:57:47.000000000 -0700
111491 +++ 25/net/sched/estimator.c    2003-10-05 00:33:25.000000000 -0700
111492 @@ -12,6 +12,7 @@
111493  #include <asm/uaccess.h>
111494  #include <asm/system.h>
111495  #include <asm/bitops.h>
111496 +#include <linux/module.h>
111497  #include <linux/types.h>
111498  #include <linux/kernel.h>
111499  #include <linux/jiffies.h>
111500 @@ -194,3 +195,5 @@ void qdisc_kill_estimator(struct tc_stat
111501         }
111502  }
111503  
111504 +EXPORT_SYMBOL(qdisc_kill_estimator);
111505 +EXPORT_SYMBOL(qdisc_new_estimator);
111506 --- linux-2.6.0-test6/net/sched/police.c        2003-09-27 18:57:47.000000000 -0700
111507 +++ 25/net/sched/police.c       2003-10-05 00:33:25.000000000 -0700
111508 @@ -13,6 +13,7 @@
111509  #include <asm/system.h>
111510  #include <asm/bitops.h>
111511  #include <linux/config.h>
111512 +#include <linux/module.h>
111513  #include <linux/types.h>
111514  #include <linux/kernel.h>
111515  #include <linux/sched.h>
111516 @@ -248,3 +249,12 @@ rtattr_failure:
111517         skb_trim(skb, b - skb->data);
111518         return -1;
111519  }
111520 +
111521 +EXPORT_SYMBOL(tcf_police);
111522 +EXPORT_SYMBOL(tcf_police_destroy);
111523 +EXPORT_SYMBOL(tcf_police_dump);
111524 +EXPORT_SYMBOL(tcf_police_hash);
111525 +EXPORT_SYMBOL(tcf_police_ht);
111526 +EXPORT_SYMBOL(tcf_police_locate);
111527 +EXPORT_SYMBOL(tcf_police_lookup);
111528 +EXPORT_SYMBOL(tcf_police_new_index);
111529 --- linux-2.6.0-test6/net/sched/sch_api.c       2003-09-27 18:57:47.000000000 -0700
111530 +++ 25/net/sched/sch_api.c      2003-10-05 00:33:25.000000000 -0700
111531 @@ -1255,3 +1255,10 @@ int __init pktsched_init(void)
111532  
111533         return 0;
111534  }
111535 +
111536 +EXPORT_SYMBOL(qdisc_copy_stats);
111537 +EXPORT_SYMBOL(qdisc_get_rtab);
111538 +EXPORT_SYMBOL(qdisc_put_rtab);
111539 +EXPORT_SYMBOL(register_qdisc);
111540 +EXPORT_SYMBOL(unregister_qdisc);
111541 +PSCHED_EXPORTLIST;
111542 --- linux-2.6.0-test6/net/sched/sch_fifo.c      2003-07-10 18:50:32.000000000 -0700
111543 +++ 25/net/sched/sch_fifo.c     2003-10-05 00:33:25.000000000 -0700
111544 @@ -203,3 +203,6 @@ struct Qdisc_ops bfifo_qdisc_ops = {
111545         .dump           =       fifo_dump,
111546         .owner          =       THIS_MODULE,
111547  };
111548 +
111549 +EXPORT_SYMBOL(bfifo_qdisc_ops);
111550 +EXPORT_SYMBOL(pfifo_qdisc_ops);
111551 --- linux-2.6.0-test6/net/sched/sch_generic.c   2003-09-27 18:57:47.000000000 -0700
111552 +++ 25/net/sched/sch_generic.c  2003-10-05 00:33:25.000000000 -0700
111553 @@ -531,3 +531,12 @@ void dev_shutdown(struct net_device *dev
111554         spin_unlock_bh(&dev->queue_lock);
111555         write_unlock(&qdisc_tree_lock);
111556  }
111557 +
111558 +EXPORT_SYMBOL(__netdev_watchdog_up);
111559 +EXPORT_SYMBOL(noop_qdisc);
111560 +EXPORT_SYMBOL(noop_qdisc_ops);
111561 +EXPORT_SYMBOL(qdisc_create_dflt);
111562 +EXPORT_SYMBOL(qdisc_destroy);
111563 +EXPORT_SYMBOL(qdisc_reset);
111564 +EXPORT_SYMBOL(qdisc_restart);
111565 +EXPORT_SYMBOL(qdisc_tree_lock);
111566 --- linux-2.6.0-test6/net/sctp/associola.c      2003-09-08 13:58:59.000000000 -0700
111567 +++ 25/net/sctp/associola.c     2003-10-05 00:33:25.000000000 -0700
111568 @@ -141,9 +141,9 @@ struct sctp_association *sctp_associatio
111569          * socket values.
111570          */
111571         asoc->max_retrans = sp->assocparams.sasoc_asocmaxrxt;
111572 -       asoc->rto_initial = sp->rtoinfo.srto_initial * HZ / 1000;
111573 -       asoc->rto_max = sp->rtoinfo.srto_max * HZ / 1000;
111574 -       asoc->rto_min = sp->rtoinfo.srto_min * HZ / 1000;
111575 +       asoc->rto_initial = MSECS_TO_JIFFIES(sp->rtoinfo.srto_initial);
111576 +       asoc->rto_max = MSECS_TO_JIFFIES(sp->rtoinfo.srto_max);
111577 +       asoc->rto_min = MSECS_TO_JIFFIES(sp->rtoinfo.srto_min);
111578  
111579         asoc->overall_error_count = 0;
111580  
111581 @@ -168,7 +168,8 @@ struct sctp_association *sctp_associatio
111582         asoc->c.sinit_num_ostreams  = sp->initmsg.sinit_num_ostreams;
111583         asoc->max_init_attempts = sp->initmsg.sinit_max_attempts;
111584  
111585 -       asoc->max_init_timeo    = sp->initmsg.sinit_max_init_timeo * HZ / 1000;
111586 +       asoc->max_init_timeo =
111587 +                MSECS_TO_JIFFIES(sp->initmsg.sinit_max_init_timeo);
111588  
111589         /* Allocate storage for the ssnmap after the inbound and outbound
111590          * streams have been negotiated during Init.
111591 @@ -246,6 +247,11 @@ struct sctp_association *sctp_associatio
111592          */
111593         asoc->peer.sack_needed = 1;
111594  
111595 +       /* Assume that the peer recongizes ASCONF until reported otherwise
111596 +        * via an ERROR chunk.
111597 +        */
111598 +       asoc->peer.asconf_capable = 1;
111599 +
111600         /* Create an input queue.  */
111601         sctp_inq_init(&asoc->base.inqueue);
111602         sctp_inq_set_th_handler(&asoc->base.inqueue,
111603 @@ -495,7 +501,7 @@ struct sctp_transport *sctp_assoc_add_pe
111604         /* Initialize the peer's heartbeat interval based on the
111605          * sock configured value.
111606          */
111607 -       peer->hb_interval = sp->paddrparam.spp_hbinterval * HZ;
111608 +       peer->hb_interval = MSECS_TO_JIFFIES(sp->paddrparam.spp_hbinterval);
111609  
111610         /* Set the path max_retrans.  */
111611         peer->max_retrans = asoc->max_retrans;
111612 --- linux-2.6.0-test6/net/sctp/bind_addr.c      2003-09-08 13:58:59.000000000 -0700
111613 +++ 25/net/sctp/bind_addr.c     2003-10-05 00:33:25.000000000 -0700
111614 @@ -324,6 +324,43 @@ int sctp_bind_addr_match(struct sctp_bin
111615         return 0;
111616  }
111617  
111618 +/* Find the first address in the bind address list that is not present in
111619 + * the addrs packed array.
111620 + */
111621 +union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr  *bp,
111622 +                                       const union sctp_addr   *addrs,
111623 +                                       int                     addrcnt,
111624 +                                       struct sctp_opt         *opt)
111625 +{
111626 +       struct sctp_sockaddr_entry      *laddr;
111627 +       union sctp_addr                 *addr;
111628 +       void                            *addr_buf;
111629 +       struct sctp_af                  *af;
111630 +       struct list_head                *pos;
111631 +       int                             i;
111632 +
111633 +       list_for_each(pos, &bp->address_list) {
111634 +               laddr = list_entry(pos, struct sctp_sockaddr_entry, list);
111635 +               
111636 +               addr_buf = (union sctp_addr *)addrs;
111637 +               for (i = 0; i < addrcnt; i++) {
111638 +                       addr = (union sctp_addr *)addr_buf;
111639 +                       af = sctp_get_af_specific(addr->v4.sin_family);
111640 +                       if (!af) 
111641 +                               return NULL;
111642 +
111643 +                       if (opt->pf->cmp_addr(&laddr->a, addr, opt))
111644 +                               break;
111645 +
111646 +                       addr_buf += af->sockaddr_len;
111647 +               }
111648 +               if (i == addrcnt)
111649 +                       return &laddr->a;
111650 +       }
111651 +
111652 +       return NULL;
111653 +}
111654 +
111655  /* Copy out addresses from the global local address list. */
111656  static int sctp_copy_one_addr(struct sctp_bind_addr *dest, 
111657                               union sctp_addr *addr,
111658 --- linux-2.6.0-test6/net/sctp/endpointola.c    2003-08-08 22:55:14.000000000 -0700
111659 +++ 25/net/sctp/endpointola.c   2003-10-05 00:33:25.000000000 -0700
111660 @@ -129,7 +129,7 @@ struct sctp_endpoint *sctp_endpoint_init
111661         ep->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT] =
111662                 SCTP_DEFAULT_TIMEOUT_T1_INIT;
111663         ep->timeouts[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN] =
111664 -               sp->rtoinfo.srto_initial * HZ / 1000;
111665 +               MSECS_TO_JIFFIES(sp->rtoinfo.srto_initial);
111666         ep->timeouts[SCTP_EVENT_TIMEOUT_T3_RTX] = 0;
111667         ep->timeouts[SCTP_EVENT_TIMEOUT_T4_RTO] = 0;
111668  
111669 @@ -138,7 +138,7 @@ struct sctp_endpoint *sctp_endpoint_init
111670          * recommended value of 5 times 'RTO.Max'.
111671          */
111672          ep->timeouts[SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD]
111673 -               = 5 * (sp->rtoinfo.srto_max * HZ / 1000);
111674 +               = 5 * MSECS_TO_JIFFIES(sp->rtoinfo.srto_max);
111675  
111676         ep->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] =
111677                 SCTP_DEFAULT_TIMEOUT_HEARTBEAT;
111678 --- linux-2.6.0-test6/net/sctp/sm_make_chunk.c  2003-09-08 13:58:59.000000000 -0700
111679 +++ 25/net/sctp/sm_make_chunk.c 2003-10-05 00:33:25.000000000 -0700
111680 @@ -1,5 +1,5 @@
111681  /* SCTP kernel reference Implementation
111682 - * Copyright (C) IBM Corp. 2001, 2003
111683 + * (C) Copyright IBM Corp. 2001, 2003
111684   * Copyright (c) 1999-2000 Cisco, Inc.
111685   * Copyright (c) 1999-2001 Motorola, Inc.
111686   * Copyright (c) 2001-2002 Intel Corp.
111687 @@ -1288,7 +1288,7 @@ sctp_cookie_param_t *sctp_pack_cookie(co
111688  
111689         /* Set an expiration time for the cookie.  */
111690         do_gettimeofday(&cookie->c.expiration);
111691 -       tv_add(&asoc->cookie_life, &cookie->c.expiration);
111692 +       TIMEVAL_ADD(asoc->cookie_life, cookie->c.expiration);
111693  
111694         /* Copy the peer's init packet.  */
111695         memcpy(&cookie->c.peer_init[0], init_chunk->chunk_hdr,
111696 @@ -2021,11 +2021,11 @@ struct sctp_chunk *sctp_make_asconf(stru
111697         sctp_addiphdr_t asconf;
111698         struct sctp_chunk *retval;
111699         int length = sizeof(asconf) + vparam_len;
111700 -       union sctp_params addrparam;
111701 +       union sctp_addr_param addrparam;
111702         int addrlen;
111703         struct sctp_af *af = sctp_get_af_specific(addr->v4.sin_family);
111704  
111705 -       addrlen = af->to_addr_param(addr, (union sctp_addr_param *)&addrparam);
111706 +       addrlen = af->to_addr_param(addr, &addrparam);
111707         if (!addrlen)
111708                 return NULL;
111709         length += addrlen;
111710 @@ -2046,6 +2046,83 @@ struct sctp_chunk *sctp_make_asconf(stru
111711  }
111712  
111713  /* ADDIP
111714 + * 3.2.1 Add IP Address
111715 + *     0                   1                   2                   3
111716 + *     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
111717 + *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111718 + *     |        Type = 0xC001          |    Length = Variable          |
111719 + *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111720 + *     |               ASCONF-Request Correlation ID                   |
111721 + *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111722 + *     |                       Address Parameter                       |
111723 + *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111724 + *
111725 + * 3.2.2 Delete IP Address
111726 + *     0                   1                   2                   3
111727 + *     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
111728 + *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111729 + *     |        Type = 0xC002          |    Length = Variable          |
111730 + *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111731 + *     |               ASCONF-Request Correlation ID                   |
111732 + *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111733 + *     |                       Address Parameter                       |
111734 + *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111735 + *
111736 + */
111737 +struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc,
111738 +                                             union sctp_addr         *laddr,
111739 +                                             struct sockaddr         *addrs,
111740 +                                             int                     addrcnt,
111741 +                                             int                     flags)
111742 +{
111743 +       sctp_addip_param_t      param;
111744 +       struct sctp_chunk       *retval;
111745 +       union sctp_addr_param   addr_param;
111746 +       union sctp_addr         *addr;
111747 +       void                    *addr_buf;
111748 +       struct sctp_af          *af;
111749 +       int                     paramlen = sizeof(param);
111750 +       int                     addr_param_len = 0;
111751 +       int                     totallen = 0;
111752 +       int                     i;
111753 +
111754 +       /* Get total length of all the address parameters. */
111755 +       addr_buf = addrs;
111756 +       for (i = 0; i < addrcnt; i++) {
111757 +               addr = (union sctp_addr *)addr_buf;
111758 +               af = sctp_get_af_specific(addr->v4.sin_family);
111759 +               addr_param_len = af->to_addr_param(addr, &addr_param);
111760 +
111761 +               totallen += paramlen;
111762 +               totallen += addr_param_len;
111763 +
111764 +               addr_buf += af->sockaddr_len;
111765 +       }
111766 +
111767 +       /* Create an asconf chunk with the required length. */
111768 +       retval = sctp_make_asconf(asoc, laddr, totallen);
111769 +       if (!retval)
111770 +               return NULL;
111771 +
111772 +       /* Add the address parameters to the asconf chunk. */
111773 +       addr_buf = addrs;
111774 +       for (i = 0; i < addrcnt; i++) {
111775 +               addr = (union sctp_addr *)addr_buf;
111776 +               af = sctp_get_af_specific(addr->v4.sin_family);
111777 +               addr_param_len = af->to_addr_param(addr, &addr_param);
111778 +               param.param_hdr.type = flags;
111779 +               param.param_hdr.length = htons(paramlen + addr_param_len);
111780 +               param.crr_id = htonl(i);
111781 +
111782 +               sctp_addto_chunk(retval, paramlen, &param);
111783 +               sctp_addto_chunk(retval, addr_param_len, &addr_param);
111784 +
111785 +               addr_buf += af->sockaddr_len;
111786 +       }
111787 +       return retval;
111788 +}
111789 +
111790 +/* ADDIP
111791   * 3.2.4 Set Primary IP Address
111792   *     0                   1                   2                   3
111793   *     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
111794 @@ -2065,11 +2142,11 @@ struct sctp_chunk *sctp_make_asconf_set_
111795         sctp_addip_param_t      param;
111796         struct sctp_chunk       *retval;
111797         int                     len = sizeof(param);
111798 -       union sctp_params       addrparam;
111799 +       union sctp_addr_param   addrparam;
111800         int                     addrlen;
111801         struct sctp_af          *af = sctp_get_af_specific(addr->v4.sin_family);
111802  
111803 -       addrlen = af->to_addr_param(addr, (union sctp_addr_param *)&addrparam);
111804 +       addrlen = af->to_addr_param(addr, &addrparam);
111805         if (!addrlen)
111806                 return NULL;
111807         len += addrlen;
111808 @@ -2089,11 +2166,7 @@ struct sctp_chunk *sctp_make_asconf_set_
111809         return retval;
111810  }
111811  
111812 -/*
111813 - * Unpack the parameters in an ASCONF chunk into an association and
111814 - * generate ASCONF-ACK chunk.
111815 - *
111816 - * ADDIP 3.1.2 Address Configuration Acknowledgement Chunk (ASCONF-ACK)
111817 +/* ADDIP 3.1.2 Address Configuration Acknowledgement Chunk (ASCONF-ACK)
111818   *      0                   1                   2                   3
111819   *      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
111820   *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111821 @@ -2110,8 +2183,28 @@ struct sctp_chunk *sctp_make_asconf_set_
111822   *     |                 ASCONF Parameter Response#N                   |
111823   *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111824   *
111825 - * All the parameter respoinces will be added in this function.
111826 + * Create an ASCONF_ACK chunk with enough space for the parameter responses. 
111827   */
111828 +struct sctp_chunk *sctp_make_asconf_ack(struct sctp_association        *asoc,
111829 +                                       int serial, int vparam_len)
111830 +{
111831 +       sctp_addiphdr_t         asconf;
111832 +       struct sctp_chunk       *retval;
111833 +       int                     length = sizeof(asconf) + vparam_len;
111834 +
111835 +       /* Create the chunk.  */
111836 +       retval = sctp_make_chunk(asoc, SCTP_CID_ASCONF_ACK, 0, length);
111837 +       if (!retval)
111838 +               return NULL;
111839 +
111840 +       asconf.serial = serial;
111841 +
111842 +       retval->subh.addip_hdr =
111843 +               sctp_addto_chunk(retval, sizeof(asconf), &asconf);
111844 +
111845 +       return retval;
111846 +}
111847 +
111848  struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
111849                                         struct sctp_chunk *asconf,
111850                                         int vparam_len)
111851 --- linux-2.6.0-test6/net/sctp/sm_sideeffect.c  2003-08-08 22:55:14.000000000 -0700
111852 +++ 25/net/sctp/sm_sideeffect.c 2003-10-05 00:33:25.000000000 -0700
111853 @@ -1,7 +1,7 @@
111854  /* SCTP kernel reference Implementation
111855 + * (C) Copyright IBM Corp. 2001, 2003
111856   * Copyright (c) 1999 Cisco, Inc.
111857   * Copyright (c) 1999-2001 Motorola, Inc.
111858 - * Copyright (c) 2001-2002 International Business Machines Corp.
111859   *
111860   * This file is part of the SCTP kernel reference Implementation
111861   *
111862 @@ -690,6 +690,44 @@ static void sctp_cmd_setup_t4(sctp_cmd_s
111863         chunk->transport = t;
111864  }
111865  
111866 +/* Process an incoming Operation Error Chunk. */ 
111867 +static void sctp_cmd_process_operr(sctp_cmd_seq_t *cmds,
111868 +                                  struct sctp_association *asoc,
111869 +                                  struct sctp_chunk *chunk)
111870 +{
111871 +       struct sctp_operr_chunk *operr_chunk;
111872 +       struct sctp_errhdr *err_hdr;
111873 +
111874 +       operr_chunk = (struct sctp_operr_chunk *)chunk->chunk_hdr;
111875 +       err_hdr = &operr_chunk->err_hdr;
111876 +
111877 +       switch (err_hdr->cause) {
111878 +       case SCTP_ERROR_UNKNOWN_CHUNK:
111879 +       {
111880 +               struct sctp_chunkhdr *unk_chunk_hdr;
111881 +
111882 +               unk_chunk_hdr = (struct sctp_chunkhdr *)err_hdr->variable;
111883 +               switch (unk_chunk_hdr->type) {
111884 +               /* ADDIP 4.1 A9) If the peer responds to an ASCONF with an
111885 +                * ERROR chunk reporting that it did not recognized the ASCONF
111886 +                * chunk type, the sender of the ASCONF MUST NOT send any
111887 +                * further ASCONF chunks and MUST stop its T-4 timer.
111888 +                */
111889 +               case SCTP_CID_ASCONF:
111890 +                       asoc->peer.asconf_capable = 0;
111891 +                       sctp_add_cmd_sf(cmds, SCTP_CMD_TIMER_STOP,
111892 +                                       SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO));
111893 +                       break;
111894 +               default:
111895 +                       break;
111896 +               }
111897 +               break;
111898 +       }
111899 +       default:
111900 +               break;
111901 +       }
111902 +}
111903 +
111904  /* These three macros allow us to pull the debugging code out of the
111905   * main flow of sctp_do_sm() to keep attention focused on the real
111906   * functionality there.
111907 @@ -1205,6 +1243,9 @@ int sctp_cmd_interpreter(sctp_event_t ev
111908                         sctp_cmd_setup_t4(commands, asoc, cmd->obj.ptr);
111909                         break;
111910  
111911 +               case SCTP_CMD_PROCESS_OPERR:
111912 +                       sctp_cmd_process_operr(commands, asoc, chunk);
111913 +                       break;
111914                 default:
111915                         printk(KERN_WARNING "Impossible command: %u, %p\n",
111916                                cmd->verb, cmd->obj.ptr);
111917 --- linux-2.6.0-test6/net/sctp/sm_statefuns.c   2003-09-08 13:58:59.000000000 -0700
111918 +++ 25/net/sctp/sm_statefuns.c  2003-10-05 00:33:25.000000000 -0700
111919 @@ -1,7 +1,7 @@
111920  /* SCTP kernel reference Implementation
111921 + * (C) Copyright IBM Corp. 2001, 2003
111922   * Copyright (c) 1999-2000 Cisco, Inc.
111923   * Copyright (c) 1999-2001 Motorola, Inc.
111924 - * Copyright (c) 2001-2002 International Business Machines, Corp.
111925   * Copyright (c) 2001-2002 Intel Corp.
111926   * Copyright (c) 2002      Nokia Corp.
111927   *
111928 @@ -2864,6 +2864,9 @@ sctp_disposition_t sctp_sf_operr_notify(
111929                         sctp_ulpevent_free(ev);
111930                         goto nomem;
111931                 }
111932 +
111933 +               sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_OPERR,
111934 +                               SCTP_CHUNK(chunk));     
111935         }
111936         return SCTP_DISPOSITION_CONSUME;
111937  
111938 --- linux-2.6.0-test6/net/sctp/socket.c 2003-09-08 13:58:59.000000000 -0700
111939 +++ 25/net/sctp/socket.c        2003-10-05 00:33:25.000000000 -0700
111940 @@ -97,6 +97,8 @@ static void sctp_wait_for_close(struct s
111941  static inline int sctp_verify_addr(struct sock *, union sctp_addr *, int);
111942  static int sctp_bindx_add(struct sock *, struct sockaddr *, int);
111943  static int sctp_bindx_rem(struct sock *, struct sockaddr *, int);
111944 +static int sctp_send_asconf_add_ip(struct sock *, struct sockaddr *, int);
111945 +static int sctp_send_asconf_del_ip(struct sock *, struct sockaddr *, int);
111946  static int sctp_do_bind(struct sock *, union sctp_addr *, int);
111947  static int sctp_autobind(struct sock *sk);
111948  static void sctp_sock_migrate(struct sock *, struct sock *,
111949 @@ -349,6 +351,106 @@ err_bindx_add:
111950         return retval;
111951  }
111952  
111953 +/* Send an ASCONF chunk with Add IP address parameters to all the peers of the
111954 + * associations that are part of the endpoint indicating that a list of local
111955 + * addresses are added to the endpoint.
111956 + *
111957 + * If any of the addresses is already in the bind address list of the 
111958 + * association, we do not send the chunk for that association.  But it will not
111959 + * affect other associations.
111960 + *
111961 + * Only sctp_setsockopt_bindx() is supposed to call this function.
111962 + */
111963 +static int sctp_send_asconf_add_ip(struct sock         *sk, 
111964 +                                  struct sockaddr      *addrs,
111965 +                                  int                  addrcnt)
111966 +{
111967 +       struct sctp_opt                 *sp;
111968 +       struct sctp_endpoint            *ep;
111969 +       struct sctp_association         *asoc;
111970 +       struct sctp_bind_addr           *bp;
111971 +       struct sctp_chunk               *chunk;
111972 +       struct sctp_sockaddr_entry      *laddr;
111973 +       union sctp_addr                 *addr;
111974 +       void                            *addr_buf;
111975 +       struct sctp_af                  *af;
111976 +       struct list_head                *pos;
111977 +       struct list_head                *p;
111978 +       int                             i;
111979 +       int                             retval = 0;
111980 +
111981 +       sp = sctp_sk(sk);
111982 +       ep = sp->ep;
111983 +
111984 +       SCTP_DEBUG_PRINTK("%s: (sk: %p, addrs: %p, addrcnt: %d)\n",
111985 +                         __FUNCTION__, sk, addrs, addrcnt);
111986 +
111987 +       list_for_each(pos, &ep->asocs) {
111988 +               asoc = list_entry(pos, struct sctp_association, asocs);
111989 +
111990 +               if (!sctp_state(asoc, ESTABLISHED))
111991 +                       continue;
111992 +
111993 +               if (!asoc->peer.asconf_capable)
111994 +                       continue;
111995 +               
111996 +               /* Check if any address in the packed array of addresses is
111997 +                * in the bind address list of the association. If so, 
111998 +                * do not send the asconf chunk to its peer, but continue with 
111999 +                * other associations.
112000 +                */
112001 +               addr_buf = addrs;
112002 +               for (i = 0; i < addrcnt; i++) {
112003 +                       addr = (union sctp_addr *)addr_buf;
112004 +                       af = sctp_get_af_specific(addr->v4.sin_family);
112005 +                       if (!af) {
112006 +                               retval = -EINVAL;
112007 +                               goto out;
112008 +                       }
112009 +
112010 +                       if (sctp_assoc_lookup_laddr(asoc, addr))                
112011 +                               break;
112012 +                       
112013 +                       addr_buf += af->sockaddr_len;
112014 +               }
112015 +               if (i < addrcnt)
112016 +                       continue;
112017 +
112018 +               /* Use the first address in bind addr list of association as
112019 +                * Address Parameter of ASCONF CHUNK.
112020 +                */
112021 +               sctp_read_lock(&asoc->base.addr_lock);
112022 +               bp = &asoc->base.bind_addr;
112023 +               p = bp->address_list.next;
112024 +               laddr = list_entry(p, struct sctp_sockaddr_entry, list);
112025 +               sctp_read_unlock(&asoc->base.addr_lock);
112026 +
112027 +               chunk = sctp_make_asconf_update_ip(asoc, &laddr->a, addrs,
112028 +                                                  addrcnt, SCTP_PARAM_ADD_IP);
112029 +               if (!chunk) {
112030 +                       retval = -ENOMEM;
112031 +                       goto out;
112032 +               }
112033 +
112034 +               retval = sctp_primitive_ASCONF(asoc, chunk);
112035 +               if (retval) {
112036 +                       sctp_chunk_free(chunk);
112037 +                       goto out;
112038 +               }
112039 +
112040 +               /* FIXME: After sending the add address ASCONF chunk, we 
112041 +                * cannot append the address to the association's binding 
112042 +                * address list, because the new address may be used as the
112043 +                * source of a message sent to the peer before the ASCONF
112044 +                * chunk is received by the peer.  So we should wait until
112045 +                * ASCONF_ACK is received.
112046 +                */
112047 +       }
112048 +
112049 +out:
112050 +       return retval;
112051 +}
112052 +
112053  /* Remove a list of addresses from bind addresses list.  Do not remove the
112054   * last address.
112055   *
112056 @@ -436,6 +538,106 @@ err_bindx_rem:
112057         return retval;
112058  }
112059  
112060 +/* Send an ASCONF chunk with Delete IP address parameters to all the peers of
112061 + * the associations that are part of the endpoint indicating that a list of
112062 + * local addresses are removed from the endpoint.
112063 + *
112064 + * If any of the addresses is already in the bind address list of the 
112065 + * association, we do not send the chunk for that association.  But it will not
112066 + * affect other associations.
112067 + *
112068 + * Only sctp_setsockopt_bindx() is supposed to call this function.
112069 + */
112070 +static int sctp_send_asconf_del_ip(struct sock         *sk,
112071 +                                  struct sockaddr      *addrs,
112072 +                                  int                  addrcnt)
112073 +{
112074 +       struct sctp_opt         *sp;
112075 +       struct sctp_endpoint    *ep;
112076 +       struct sctp_association *asoc;
112077 +       struct sctp_bind_addr   *bp;
112078 +       struct sctp_chunk       *chunk;
112079 +       union sctp_addr         *laddr;
112080 +       void                    *addr_buf;
112081 +       struct sctp_af          *af;
112082 +       struct list_head        *pos;
112083 +       int                     i;
112084 +       int                     retval = 0;
112085 +
112086 +       sp = sctp_sk(sk);
112087 +       ep = sp->ep;
112088 +
112089 +       SCTP_DEBUG_PRINTK("%s: (sk: %p, addrs: %p, addrcnt: %d)\n",
112090 +                         __FUNCTION__, sk, addrs, addrcnt);
112091 +
112092 +       list_for_each(pos, &ep->asocs) {
112093 +               asoc = list_entry(pos, struct sctp_association, asocs);
112094 +
112095 +               if (!sctp_state(asoc, ESTABLISHED))
112096 +                       continue;
112097 +
112098 +               if (!asoc->peer.asconf_capable)
112099 +                       continue;
112100 +
112101 +               /* Check if any address in the packed array of addresses is
112102 +                * not present in the bind address list of the association.
112103 +                * If so, do not send the asconf chunk to its peer, but
112104 +                * continue with other associations.
112105 +                */
112106 +               addr_buf = addrs;
112107 +               for (i = 0; i < addrcnt; i++) {
112108 +                       laddr = (union sctp_addr *)addr_buf;
112109 +                       af = sctp_get_af_specific(laddr->v4.sin_family);
112110 +                       if (!af) {
112111 +                               retval = -EINVAL;
112112 +                               goto out;
112113 +                       }
112114 +
112115 +                       if (!sctp_assoc_lookup_laddr(asoc, laddr))              
112116 +                               break;
112117 +                       
112118 +                       addr_buf += af->sockaddr_len;
112119 +               }
112120 +               if (i < addrcnt)
112121 +                       continue;
112122 +
112123 +               /* Find one address in the association's bind address list
112124 +                * that is not in the packed array of addresses. This is to
112125 +                * make sure that we do not delete all the addresses in the
112126 +                * association.
112127 +                */
112128 +               sctp_read_lock(&asoc->base.addr_lock);
112129 +               bp = &asoc->base.bind_addr;
112130 +               laddr = sctp_find_unmatch_addr(bp, (union sctp_addr *)addrs,
112131 +                                              addrcnt, sp);
112132 +               sctp_read_unlock(&asoc->base.addr_lock);                
112133 +               if (!laddr)
112134 +                       continue;
112135 +
112136 +               chunk = sctp_make_asconf_update_ip(asoc, laddr, addrs, addrcnt, 
112137 +                                                  SCTP_PARAM_DEL_IP);
112138 +               if (!chunk) {
112139 +                       retval = -ENOMEM;
112140 +                       goto out;
112141 +               }
112142 +
112143 +               retval = sctp_primitive_ASCONF(asoc, chunk);
112144 +               if (retval) {
112145 +                       sctp_chunk_free(chunk);
112146 +                       goto out;
112147 +               }
112148 +
112149 +               /* FIXME: After sending the delete address ASCONF chunk, we
112150 +                * cannot remove the addresses from the association's bind
112151 +                * address list, because there maybe some packet send to
112152 +                * the delete addresses, so we should wait until ASCONF_ACK 
112153 +                * packet is received.
112154 +                */
112155 +       }
112156 +out:
112157 +       return retval;
112158 +}
112159 +
112160  /* Helper for tunneling sctp_bindx() requests through sctp_setsockopt()
112161   *
112162   * API 8.1
112163 @@ -564,10 +766,16 @@ SCTP_STATIC int sctp_setsockopt_bindx(st
112164         switch (op) {
112165         case SCTP_BINDX_ADD_ADDR:
112166                 err = sctp_bindx_add(sk, kaddrs, addrcnt);
112167 +               if (err)
112168 +                       goto out;
112169 +               err = sctp_send_asconf_add_ip(sk, kaddrs, addrcnt);
112170                 break;
112171  
112172         case SCTP_BINDX_REM_ADDR:
112173                 err = sctp_bindx_rem(sk, kaddrs, addrcnt);
112174 +               if (err)
112175 +                       goto out;
112176 +               err = sctp_send_asconf_del_ip(sk, kaddrs, addrcnt);
112177                 break;
112178  
112179         default:
112180 @@ -575,6 +783,7 @@ SCTP_STATIC int sctp_setsockopt_bindx(st
112181                 break;
112182          };
112183  
112184 +out:
112185         kfree(kaddrs);
112186  
112187         return err;
112188 @@ -962,8 +1171,8 @@ SCTP_STATIC int sctp_sendmsg(struct kioc
112189                                         = sinit->sinit_max_attempts;
112190                         }
112191                         if (sinit->sinit_max_init_timeo) {
112192 -                               asoc->max_init_timeo
112193 -                                       = sinit->sinit_max_init_timeo * HZ;
112194 +                               asoc->max_init_timeo = 
112195 +                                MSECS_TO_JIFFIES(sinit->sinit_max_init_timeo);
112196                         }
112197                 }
112198  
112199 @@ -1401,7 +1610,8 @@ static int sctp_setsockopt_peer_addr_par
112200          */
112201                 if (params.spp_hbinterval) {
112202                         trans->hb_allowed = 1;
112203 -                       trans->hb_interval = params.spp_hbinterval * HZ / 1000;
112204 +                       trans->hb_interval = 
112205 +                               MSECS_TO_JIFFIES(params.spp_hbinterval);
112206                 } else
112207                         trans->hb_allowed = 0;
112208         }
112209 @@ -1560,11 +1770,12 @@ static int sctp_setsockopt_rtoinfo(struc
112210  
112211         if (asoc) {
112212                 if (rtoinfo.srto_initial != 0)
112213 -                       asoc->rto_initial = rtoinfo.srto_initial * HZ / 1000;
112214 +                       asoc->rto_initial = 
112215 +                               MSECS_TO_JIFFIES(rtoinfo.srto_initial);
112216                 if (rtoinfo.srto_max != 0)
112217 -                       asoc->rto_max = rtoinfo.srto_max * HZ / 1000;
112218 +                       asoc->rto_max = MSECS_TO_JIFFIES(rtoinfo.srto_max);
112219                 if (rtoinfo.srto_min != 0)
112220 -                       asoc->rto_min = rtoinfo.srto_min * HZ / 1000;
112221 +                       asoc->rto_min = MSECS_TO_JIFFIES(rtoinfo.srto_min);
112222         } else {
112223                 /* If there is no association or the association-id = 0
112224                  * set the values to the endpoint.
112225 @@ -2088,14 +2299,14 @@ SCTP_STATIC int sctp_init_sock(struct so
112226         sp->initmsg.sinit_num_ostreams   = sctp_max_outstreams;
112227         sp->initmsg.sinit_max_instreams  = sctp_max_instreams;
112228         sp->initmsg.sinit_max_attempts   = sctp_max_retrans_init;
112229 -       sp->initmsg.sinit_max_init_timeo = (sctp_rto_max / HZ) * 1000;
112230 +       sp->initmsg.sinit_max_init_timeo = JIFFIES_TO_MSECS(sctp_rto_max);
112231  
112232         /* Initialize default RTO related parameters.  These parameters can
112233          * be modified for with the SCTP_RTOINFO socket option.
112234          */
112235 -       sp->rtoinfo.srto_initial = (sctp_rto_initial / HZ) * 1000;
112236 -       sp->rtoinfo.srto_max     = (sctp_rto_max / HZ) * 1000;
112237 -       sp->rtoinfo.srto_min     = (sctp_rto_min / HZ) * 1000;
112238 +       sp->rtoinfo.srto_initial = JIFFIES_TO_MSECS(sctp_rto_initial);
112239 +       sp->rtoinfo.srto_max     = JIFFIES_TO_MSECS(sctp_rto_max);
112240 +       sp->rtoinfo.srto_min     = JIFFIES_TO_MSECS(sctp_rto_min);
112241  
112242         /* Initialize default association related parameters. These parameters
112243          * can be modified with the SCTP_ASSOCINFO socket option.
112244 @@ -2104,8 +2315,8 @@ SCTP_STATIC int sctp_init_sock(struct so
112245         sp->assocparams.sasoc_number_peer_destinations = 0;
112246         sp->assocparams.sasoc_peer_rwnd = 0;
112247         sp->assocparams.sasoc_local_rwnd = 0;
112248 -       sp->assocparams.sasoc_cookie_life = (sctp_valid_cookie_life / HZ)
112249 -                                       * 1000;
112250 +       sp->assocparams.sasoc_cookie_life = 
112251 +               JIFFIES_TO_MSECS(sctp_valid_cookie_life);
112252  
112253         /* Initialize default event subscriptions. By default, all the
112254          * options are off. 
112255 @@ -2115,7 +2326,7 @@ SCTP_STATIC int sctp_init_sock(struct so
112256         /* Default Peer Address Parameters.  These defaults can
112257          * be modified via SCTP_PEER_ADDR_PARAMS
112258          */
112259 -       sp->paddrparam.spp_hbinterval = (sctp_hb_interval / HZ) * 1000;
112260 +       sp->paddrparam.spp_hbinterval = JIFFIES_TO_MSECS(sctp_hb_interval);
112261         sp->paddrparam.spp_pathmaxrxt = sctp_max_retrans_path;
112262  
112263         /* If enabled no SCTP message fragmentation will be performed.
112264 @@ -2265,7 +2476,7 @@ static int sctp_getsockopt_sctp_status(s
112265         status.sstat_primary.spinfo_state = transport->active;
112266         status.sstat_primary.spinfo_cwnd = transport->cwnd;
112267         status.sstat_primary.spinfo_srtt = transport->srtt;
112268 -       status.sstat_primary.spinfo_rto = (transport->rto / HZ) * 1000;
112269 +       status.sstat_primary.spinfo_rto = JIFFIES_TO_MSECS(transport->rto);
112270         status.sstat_primary.spinfo_mtu = transport->pmtu;
112271  
112272         if (put_user(len, optlen)) {
112273 @@ -2320,7 +2531,7 @@ static int sctp_getsockopt_peer_addr_inf
112274         pinfo.spinfo_state = transport->active;
112275         pinfo.spinfo_cwnd = transport->cwnd;
112276         pinfo.spinfo_srtt = transport->srtt;
112277 -       pinfo.spinfo_rto = (transport->rto / HZ) * 1000;
112278 +       pinfo.spinfo_rto = JIFFIES_TO_MSECS(transport->rto);
112279         pinfo.spinfo_mtu = transport->pmtu;
112280  
112281         if (put_user(len, optlen)) {
112282 @@ -2524,7 +2735,7 @@ static int sctp_getsockopt_peer_addr_par
112283         if (!trans->hb_allowed)
112284                 params.spp_hbinterval = 0;
112285         else
112286 -               params.spp_hbinterval = trans->hb_interval * 1000 / HZ;
112287 +               params.spp_hbinterval = JIFFIES_TO_MSECS(trans->hb_interval);
112288  
112289         /* spp_pathmaxrxt contains the maximum number of retransmissions
112290          * before this address shall be considered unreachable.
112291 @@ -2582,10 +2793,8 @@ static int sctp_getsockopt_peer_addrs_nu
112292         list_for_each(pos, &asoc->peer.transport_addr_list) {
112293                 cnt ++;
112294         }
112295 -       if (copy_to_user(optval, &cnt, sizeof(int)))
112296 -               return -EFAULT;
112297  
112298 -       return 0;
112299 +       return cnt;
112300  }
112301  
112302  static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
112303 @@ -2666,10 +2875,8 @@ static int sctp_getsockopt_local_addrs_n
112304         list_for_each(pos, &bp->address_list) {
112305                 cnt ++;
112306         }
112307 -       if (copy_to_user(optval, &cnt, sizeof(int)))
112308 -               return -EFAULT;
112309  
112310 -       return 0;
112311 +       return cnt;
112312  }
112313  
112314  static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
112315 @@ -2879,9 +3086,9 @@ static int sctp_getsockopt_rtoinfo(struc
112316  
112317         /* Values corresponding to the specific association. */
112318         if (asoc) {
112319 -               rtoinfo.srto_initial = (asoc->rto_initial / HZ) * 1000;
112320 -               rtoinfo.srto_max = (asoc->rto_max / HZ) * 1000;
112321 -               rtoinfo.srto_min = (asoc->rto_min / HZ) * 1000;
112322 +               rtoinfo.srto_initial = JIFFIES_TO_MSECS(asoc->rto_initial);
112323 +               rtoinfo.srto_max = JIFFIES_TO_MSECS(asoc->rto_max);
112324 +               rtoinfo.srto_min = JIFFIES_TO_MSECS(asoc->rto_min);
112325         } else {
112326                 /* Values corresponding to the endpoint. */
112327                 struct sctp_opt *sp = sctp_sk(sk);
112328 --- linux-2.6.0-test6/net/sctp/sysctl.c 2003-09-08 13:58:59.000000000 -0700
112329 +++ 25/net/sctp/sysctl.c        2003-10-05 00:33:25.000000000 -0700
112330 @@ -44,7 +44,7 @@
112331  #include <linux/sysctl.h>
112332  
112333  static ctl_handler sctp_sysctl_jiffies_ms;
112334 -static long rto_timer_min = 0;
112335 +static long rto_timer_min = 1;
112336  static long rto_timer_max = 86400000; /* One day */
112337  
112338  static ctl_table sctp_table[] = {
112339 --- linux-2.6.0-test6/net/socket.c      2003-09-08 13:58:59.000000000 -0700
112340 +++ 25/net/socket.c     2003-10-05 00:34:03.000000000 -0700
112341 @@ -394,6 +394,7 @@ int sock_map_fd(struct socket *sock)
112342                 file->f_dentry->d_op = &sockfs_dentry_operations;
112343                 d_add(file->f_dentry, SOCK_INODE(sock));
112344                 file->f_vfsmnt = mntget(sock_mnt);
112345 +               file->f_mapping = file->f_dentry->d_inode->i_mapping;
112346  
112347                 sock->file = file;
112348                 file->f_op = SOCK_INODE(sock)->i_fop = &socket_file_ops;
112349 @@ -1989,3 +1990,18 @@ void socket_seq_show(struct seq_file *se
112350         seq_printf(seq, "sockets: used %d\n", counter);
112351  }
112352  #endif /* CONFIG_PROC_FS */
112353 +
112354 +/* ABI emulation layers need these two */
112355 +EXPORT_SYMBOL(move_addr_to_kernel);
112356 +EXPORT_SYMBOL(move_addr_to_user);
112357 +EXPORT_SYMBOL(sock_alloc);
112358 +EXPORT_SYMBOL(sock_alloc_inode);
112359 +EXPORT_SYMBOL(sock_create);
112360 +EXPORT_SYMBOL(sock_map_fd);
112361 +EXPORT_SYMBOL(sock_recvmsg);
112362 +EXPORT_SYMBOL(sock_register);
112363 +EXPORT_SYMBOL(sock_release);
112364 +EXPORT_SYMBOL(sock_sendmsg);
112365 +EXPORT_SYMBOL(sock_unregister);
112366 +EXPORT_SYMBOL(sock_wake_async);
112367 +EXPORT_SYMBOL(sockfd_lookup);
112368 --- linux-2.6.0-test6/net/unix/af_unix.c        2003-09-08 13:58:59.000000000 -0700
112369 +++ 25/net/unix/af_unix.c       2003-10-05 00:33:25.000000000 -0700
112370 @@ -448,7 +448,7 @@ static int unix_listen(struct socket *so
112371         sk->sk_max_ack_backlog  = backlog;
112372         sk->sk_state            = TCP_LISTEN;
112373         /* set credentials so connect can copy them */
112374 -       sk->sk_peercred.pid     = current->pid;
112375 +       sk->sk_peercred.pid     = current->tgid;
112376         sk->sk_peercred.uid     = current->euid;
112377         sk->sk_peercred.gid     = current->egid;
112378         err = 0;
112379 @@ -983,7 +983,7 @@ restart:
112380         unix_peer(newsk)        = sk;
112381         newsk->sk_state         = TCP_ESTABLISHED;
112382         newsk->sk_type          = SOCK_STREAM;
112383 -       newsk->sk_peercred.pid  = current->pid;
112384 +       newsk->sk_peercred.pid  = current->tgid;
112385         newsk->sk_peercred.uid  = current->euid;
112386         newsk->sk_peercred.gid  = current->egid;
112387         newu = unix_sk(newsk);
112388 @@ -1045,7 +1045,7 @@ static int unix_socketpair(struct socket
112389         sock_hold(skb);
112390         unix_peer(ska)=skb;
112391         unix_peer(skb)=ska;
112392 -       ska->sk_peercred.pid = skb->sk_peercred.pid = current->pid;
112393 +       ska->sk_peercred.pid = skb->sk_peercred.pid = current->tgid;
112394         ska->sk_peercred.uid = skb->sk_peercred.uid = current->euid;
112395         ska->sk_peercred.gid = skb->sk_peercred.gid = current->egid;
112396  
112397 --- linux-2.6.0-test6/net/x25/af_x25.c  2003-09-08 13:58:59.000000000 -0700
112398 +++ 25/net/x25/af_x25.c 2003-10-05 00:34:48.000000000 -0700
112399 @@ -345,10 +345,8 @@ void x25_destroy_socket(struct sock *sk)
112400         if (atomic_read(&sk->sk_wmem_alloc) ||
112401             atomic_read(&sk->sk_rmem_alloc)) {
112402                 /* Defer: outstanding buffers */
112403 -               init_timer(&sk->sk_timer);
112404                 sk->sk_timer.expires  = jiffies + 10 * HZ;
112405                 sk->sk_timer.function = x25_destroy_timer;
112406 -               sk->sk_timer.data     = (unsigned long)sk;
112407                 add_timer(&sk->sk_timer);
112408         } else {
112409                 /* drop last reference so sock_put will free */
112410 @@ -463,6 +461,8 @@ frees:
112411         goto out;
112412  }
112413  
112414 +void x25_init_timers(struct sock *sk);
112415 +
112416  static int x25_create(struct socket *sock, int protocol)
112417  {
112418         struct sock *sk;
112419 @@ -481,7 +481,7 @@ static int x25_create(struct socket *soc
112420         sock_init_data(sock, sk);
112421         sk_set_owner(sk, THIS_MODULE);
112422  
112423 -       init_timer(&x25->timer);
112424 +       x25_init_timers(sk);
112425  
112426         sock->ops    = &x25_proto_ops;
112427         sk->sk_protocol = protocol;
112428 @@ -537,7 +537,7 @@ static struct sock *x25_make_new(struct 
112429         x25->facilities = ox25->facilities;
112430         x25->qbitincl   = ox25->qbitincl;
112431  
112432 -       init_timer(&x25->timer);
112433 +       x25_init_timers(sk);
112434  out:
112435         return sk;
112436  }
112437 --- linux-2.6.0-test6/net/x25/x25_link.c        2003-06-14 12:17:57.000000000 -0700
112438 +++ 25/net/x25/x25_link.c       2003-10-05 00:34:48.000000000 -0700
112439 @@ -51,15 +51,9 @@ static void x25_t20timer_expiry(unsigned
112440  /*
112441   *     Linux set/reset timer routines
112442   */
112443 -static void x25_start_t20timer(struct x25_neigh *nb)
112444 +static inline void x25_start_t20timer(struct x25_neigh *nb)
112445  {
112446 -       del_timer(&nb->t20timer);
112447 -
112448 -       nb->t20timer.data     = (unsigned long)nb;
112449 -       nb->t20timer.function = &x25_t20timer_expiry;
112450 -       nb->t20timer.expires  = jiffies + nb->t20;
112451 -
112452 -       add_timer(&nb->t20timer);
112453 +       mod_timer(&nb->t20timer, jiffies + nb->t20);
112454  }
112455  
112456  static void x25_t20timer_expiry(unsigned long param)
112457 @@ -71,12 +65,12 @@ static void x25_t20timer_expiry(unsigned
112458         x25_start_t20timer(nb);
112459  }
112460  
112461 -static void x25_stop_t20timer(struct x25_neigh *nb)
112462 +static inline void x25_stop_t20timer(struct x25_neigh *nb)
112463  {
112464         del_timer(&nb->t20timer);
112465  }
112466  
112467 -static int x25_t20timer_pending(struct x25_neigh *nb)
112468 +static inline int x25_t20timer_pending(struct x25_neigh *nb)
112469  {
112470         return timer_pending(&nb->t20timer);
112471  }
112472 @@ -291,6 +285,8 @@ void x25_link_device_up(struct net_devic
112473         skb_queue_head_init(&nb->queue);
112474  
112475         init_timer(&nb->t20timer);
112476 +       nb->t20timer.data     = (unsigned long)nb;
112477 +       nb->t20timer.function = &x25_t20timer_expiry;
112478  
112479         dev_hold(dev);
112480         nb->dev      = dev;
112481 --- linux-2.6.0-test6/net/x25/x25_timer.c       2003-06-14 12:17:57.000000000 -0700
112482 +++ 25/net/x25/x25_timer.c      2003-10-05 00:34:48.000000000 -0700
112483 @@ -43,15 +43,22 @@
112484  static void x25_heartbeat_expiry(unsigned long);
112485  static void x25_timer_expiry(unsigned long);
112486  
112487 -void x25_start_heartbeat(struct sock *sk)
112488 +void x25_init_timers(struct sock *sk)
112489  {
112490 -       del_timer(&sk->sk_timer);
112491 +       struct x25_opt *x25 = x25_sk(sk);
112492  
112493 +       init_timer(&x25->timer);
112494 +       x25->timer.data     = (unsigned long)sk;
112495 +       x25->timer.function = &x25_timer_expiry;
112496 +
112497 +       /* initialized by sock_init_data */
112498         sk->sk_timer.data     = (unsigned long)sk;
112499         sk->sk_timer.function = &x25_heartbeat_expiry;
112500 -       sk->sk_timer.expires  = jiffies + 5 * HZ;
112501 +}
112502  
112503 -       add_timer(&sk->sk_timer);
112504 +void x25_start_heartbeat(struct sock *sk)
112505 +{
112506 +       mod_timer(&sk->sk_timer, jiffies + 5 * HZ);
112507  }
112508  
112509  void x25_stop_heartbeat(struct sock *sk)
112510 @@ -63,52 +70,28 @@ void x25_start_t2timer(struct sock *sk)
112511  {
112512         struct x25_opt *x25 = x25_sk(sk);
112513  
112514 -       del_timer(&x25->timer);
112515 -
112516 -       x25->timer.data     = (unsigned long)sk;
112517 -       x25->timer.function = &x25_timer_expiry;
112518 -       x25->timer.expires  = jiffies + x25->t2;
112519 -
112520 -       add_timer(&x25->timer);
112521 +       mod_timer(&x25->timer, jiffies + x25->t2);
112522  }
112523  
112524  void x25_start_t21timer(struct sock *sk)
112525  {
112526         struct x25_opt *x25 = x25_sk(sk);
112527  
112528 -       del_timer(&x25->timer);
112529 -
112530 -       x25->timer.data     = (unsigned long)sk;
112531 -       x25->timer.function = &x25_timer_expiry;
112532 -       x25->timer.expires  = jiffies + x25->t21;
112533 -
112534 -       add_timer(&x25->timer);
112535 +       mod_timer(&x25->timer, jiffies + x25->t21);
112536  }
112537  
112538  void x25_start_t22timer(struct sock *sk)
112539  {
112540         struct x25_opt *x25 = x25_sk(sk);
112541  
112542 -       del_timer(&x25->timer);
112543 -
112544 -       x25->timer.data     = (unsigned long)sk;
112545 -       x25->timer.function = &x25_timer_expiry;
112546 -       x25->timer.expires  = jiffies + x25->t22;
112547 -
112548 -       add_timer(&x25->timer);
112549 +       mod_timer(&x25->timer, jiffies + x25->t22);
112550  }
112551  
112552  void x25_start_t23timer(struct sock *sk)
112553  {
112554         struct x25_opt *x25 = x25_sk(sk);
112555  
112556 -       del_timer(&x25->timer);
112557 -
112558 -       x25->timer.data     = (unsigned long)sk;
112559 -       x25->timer.function = &x25_timer_expiry;
112560 -       x25->timer.expires  = jiffies + x25->t23;
112561 -
112562 -       add_timer(&x25->timer);
112563 +       mod_timer(&x25->timer, jiffies + x25->t23);
112564  }
112565  
112566  void x25_stop_timer(struct sock *sk)
112567 --- linux-2.6.0-test6/net/xfrm/xfrm_algo.c      2003-08-22 19:23:42.000000000 -0700
112568 +++ 25/net/xfrm/xfrm_algo.c     2003-10-05 00:33:25.000000000 -0700
112569 @@ -8,7 +8,9 @@
112570   * Software Foundation; either version 2 of the License, or (at your option) 
112571   * any later version.
112572   */
112573 +
112574  #include <linux/config.h>
112575 +#include <linux/module.h>
112576  #include <linux/kernel.h>
112577  #include <linux/pfkeyv2.h>
112578  #include <net/xfrm.h>
112579 @@ -617,6 +619,7 @@ skb_to_sgvec(struct sk_buff *skb, struct
112580                 BUG();
112581         return elt;
112582  }
112583 +EXPORT_SYMBOL_GPL(skb_to_sgvec);
112584  
112585  /* Check that skb data bits are writable. If they are not, copy data
112586   * to newly created private area. If "tailbits" is given, make sure that
112587 @@ -717,6 +720,7 @@ int skb_cow_data(struct sk_buff *skb, in
112588  
112589         return elt;
112590  }
112591 +EXPORT_SYMBOL_GPL(skb_cow_data);
112592  
112593  void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len)
112594  {
112595 @@ -726,4 +730,5 @@ void *pskb_put(struct sk_buff *skb, stru
112596         }
112597         return skb_put(tail, len);
112598  }
112599 +EXPORT_SYMBOL_GPL(pskb_put);
112600  #endif
112601 --- linux-2.6.0-test6/scripts/bin2c.c   2003-09-27 18:57:47.000000000 -0700
112602 +++ 25/scripts/bin2c.c  2003-10-05 00:33:25.000000000 -0700
112603 @@ -1,3 +1,12 @@
112604 +/*
112605 + * Unloved program to convert a binary on stdin to a C include on stdout
112606 + *
112607 + * Jan 1999 Matt Mackall <mpm@selenic.com>
112608 + *
112609 + * This software may be used and distributed according to the terms
112610 + * of the GNU General Public License, incorporated herein by reference.
112611 + */
112612 +
112613  #include <stdio.h>
112614  
112615  int main(int argc, char *argv[])
112616 --- linux-2.6.0-test6/scripts/pnmtologo.c       2003-08-08 22:55:14.000000000 -0700
112617 +++ 25/scripts/pnmtologo.c      2003-10-05 00:33:25.000000000 -0700
112618 @@ -119,7 +119,8 @@ static unsigned int get_number255(FILE *
112619  static void read_image(void)
112620  {
112621      FILE *fp;
112622 -    int i, j, magic;
112623 +    unsigned int i, j;
112624 +    int magic;
112625      unsigned int maxval;
112626  
112627      /* open image file */
112628 @@ -274,7 +275,7 @@ static void write_hex(unsigned char byte
112629  
112630  static void write_logo_mono(void)
112631  {
112632 -    int i, j;
112633 +    unsigned int i, j;
112634      unsigned char val, bit;
112635  
112636      /* validate image */
112637 @@ -302,7 +303,7 @@ static void write_logo_mono(void)
112638  
112639  static void write_logo_vga16(void)
112640  {
112641 -    int i, j, k;
112642 +    unsigned int i, j, k;
112643      unsigned char val;
112644  
112645      /* validate image */
112646 @@ -342,7 +343,7 @@ static void write_logo_vga16(void)
112647  
112648  static void write_logo_clut224(void)
112649  {
112650 -    int i, j, k;
112651 +    unsigned int i, j, k;
112652  
112653      /* validate image */
112654      for (i = 0; i < logo_height; i++)
112655 @@ -388,7 +389,7 @@ static void write_logo_clut224(void)
112656  
112657  static void write_logo_gray256(void)
112658  {
112659 -    int i, j;
112660 +    unsigned int i, j;
112661  
112662      /* validate image */
112663      for (i = 0; i < logo_height; i++)
112664 --- linux-2.6.0-test6/security/dummy.c  2003-07-10 18:50:32.000000000 -0700
112665 +++ 25/security/dummy.c 2003-10-05 00:33:25.000000000 -0700
112666 @@ -364,7 +364,7 @@ static int dummy_inode_follow_link (stru
112667         return 0;
112668  }
112669  
112670 -static int dummy_inode_permission (struct inode *inode, int mask)
112671 +static int dummy_inode_permission (struct inode *inode, int mask, struct nameidata *nd)
112672  {
112673         return 0;
112674  }
112675 --- linux-2.6.0-test6/security/selinux/hooks.c  2003-09-27 18:57:47.000000000 -0700
112676 +++ 25/security/selinux/hooks.c 2003-10-05 00:33:25.000000000 -0700
112677 @@ -1730,13 +1730,18 @@ static int selinux_inode_follow_link(str
112678         return dentry_has_perm(current, NULL, dentry, FILE__READ);
112679  }
112680  
112681 -static int selinux_inode_permission(struct inode *inode, int mask)
112682 +static int selinux_inode_permission(struct inode *inode, int mask,
112683 +                                   struct nameidata *nd)
112684  {
112685         if (!mask) {
112686                 /* No permission to check.  Existence test. */
112687                 return 0;
112688         }
112689  
112690 +       if (nd && nd->dentry)
112691 +               return dentry_has_perm(current, nd->mnt, nd->dentry,
112692 +                                      file_mask_to_av(inode->i_mode, mask));
112693 +
112694         return inode_has_perm(current, inode,
112695                                file_mask_to_av(inode->i_mode, mask), NULL, NULL);
112696  }
112697 --- linux-2.6.0-test6/security/selinux/ss/services.c    2003-08-08 22:55:14.000000000 -0700
112698 +++ 25/security/selinux/ss/services.c   2003-10-05 00:33:25.000000000 -0700
112699 @@ -896,7 +896,7 @@ static int convert_context(u32 key,
112700         struct user_datum *usrdatum;
112701         char *s;
112702         u32 len;
112703 -       int rc = -EINVAL;
112704 +       int rc;
112705  
112706         args = p;
112707  
112708 @@ -904,6 +904,8 @@ static int convert_context(u32 key,
112709         if (rc)
112710                 goto out;
112711  
112712 +       rc = -EINVAL;
112713 +
112714         /* Convert the user. */
112715         usrdatum = hashtab_search(args->newp->p_users.table,
112716                                   args->oldp->p_user_val_to_name[c->user - 1]);
112717 --- linux-2.6.0-test6/sound/oss/ac97_codec.c    2003-09-27 18:57:47.000000000 -0700
112718 +++ 25/sound/oss/ac97_codec.c   2003-10-05 00:33:25.000000000 -0700
112719 @@ -46,7 +46,6 @@
112720   *     Isolated from trident.c to support multiple ac97 codec
112721   */
112722  #include <linux/module.h>
112723 -#include <linux/version.h>
112724  #include <linux/kernel.h>
112725  #include <linux/slab.h>
112726  #include <linux/string.h>
112727 --- linux-2.6.0-test6/sound/oss/ali5455.c       2003-09-08 13:58:59.000000000 -0700
112728 +++ 25/sound/oss/ali5455.c      2003-10-05 00:33:25.000000000 -0700
112729 @@ -47,7 +47,6 @@
112730   */
112731  
112732  #include <linux/module.h>
112733 -#include <linux/version.h>
112734  #include <linux/string.h>
112735  #include <linux/ctype.h>
112736  #include <linux/ioport.h>
112737 --- linux-2.6.0-test6/sound/oss/au1000.c        2003-09-08 13:58:59.000000000 -0700
112738 +++ 25/sound/oss/au1000.c       2003-10-05 00:33:25.000000000 -0700
112739 @@ -50,7 +50,6 @@
112740   *                channels [stevel].
112741   *
112742   */
112743 -#include <linux/version.h>
112744  #include <linux/module.h>
112745  #include <linux/string.h>
112746  #include <linux/ioport.h>
112747 @@ -2223,8 +2222,9 @@ static int __init au1000_setup(char *opt
112748         if (!options || !*options)
112749                 return 0;
112750  
112751 -       for(this_opt=strtok(options, ",");
112752 -           this_opt; this_opt=strtok(NULL, ",")) {
112753 +       while (this_opt = strsep(&options, ",")) {
112754 +               if (!*this_opt)
112755 +                       continue;
112756                 if (!strncmp(this_opt, "vra", 3)) {
112757                         vra = 1;
112758                 }
112759 --- linux-2.6.0-test6/sound/oss/btaudio.c       2003-09-08 13:58:59.000000000 -0700
112760 +++ 25/sound/oss/btaudio.c      2003-10-05 00:33:25.000000000 -0700
112761 @@ -177,8 +177,11 @@ static int alloc_buffer(struct btaudio *
112762                 bta->risc_size = PAGE_SIZE;
112763                 bta->risc_cpu = pci_alloc_consistent
112764                         (bta->pci, bta->risc_size, &bta->risc_dma);
112765 -               if (NULL == bta->risc_cpu)
112766 +               if (NULL == bta->risc_cpu) {
112767 +                       pci_free_consistent(bta->pci, bta->buf_size, bta->buf_cpu, bta->buf_dma);
112768 +                       bta->buf_cpu = NULL;
112769                         return -ENOMEM;
112770 +               }
112771         }
112772         return 0;
112773  }
112774 --- linux-2.6.0-test6/sound/oss/dmasound/dac3550a.c     2003-09-27 18:57:48.000000000 -0700
112775 +++ 25/sound/oss/dmasound/dac3550a.c    2003-10-05 00:33:25.000000000 -0700
112776 @@ -7,7 +7,6 @@
112777   *  for more details.
112778   */
112779  
112780 -#include <linux/version.h>
112781  #include <linux/module.h>
112782  #include <linux/slab.h>
112783  #include <linux/proc_fs.h>
112784 --- linux-2.6.0-test6/sound/oss/dmasound/Kconfig        2003-09-27 18:57:47.000000000 -0700
112785 +++ 25/sound/oss/dmasound/Kconfig       2003-10-05 00:33:25.000000000 -0700
112786 @@ -1,7 +1,7 @@
112787 -# drivers/sound/dmasound/Config.in
112788  config DMASOUND_ATARI
112789         tristate "Atari DMA sound support"
112790         depends on ATARI && SOUND
112791 +       select DMASOUND
112792         help
112793           If you want to use the internal audio of your Atari in Linux, answer
112794           Y to this question. This will provide a Sun-like /dev/audio,
112795 @@ -15,6 +15,7 @@ config DMASOUND_ATARI
112796  config DMASOUND_PMAC
112797         tristate "PowerMac DMA sound support"
112798         depends on PPC_PMAC && SOUND && I2C
112799 +       select DMASOUND
112800         help
112801           If you want to use the internal audio of your PowerMac in Linux,
112802           answer Y to this question. This will provide a Sun-like /dev/audio,
112803 @@ -28,6 +29,7 @@ config DMASOUND_PMAC
112804  config DMASOUND_PAULA
112805         tristate "Amiga DMA sound support"
112806         depends on (AMIGA || APUS) && SOUND
112807 +       select DMASOUND
112808         help
112809           If you want to use the internal audio of your Amiga in Linux, answer
112810           Y to this question. This will provide a Sun-like /dev/audio,
112811 @@ -41,6 +43,7 @@ config DMASOUND_PAULA
112812  config DMASOUND_Q40
112813         tristate "Q40 sound support"
112814         depends on Q40 && SOUND
112815 +       select DMASOUND
112816         help
112817           If you want to use the internal audio of your Q40 in Linux, answer
112818           Y to this question. This will provide a Sun-like /dev/audio,
112819 @@ -53,13 +56,3 @@ config DMASOUND_Q40
112820  
112821  config DMASOUND
112822         tristate
112823 -       depends on SOUND!=n
112824 -       default m if DMASOUND_ATARI!=y && DMASOUND_AWACS!=y && DMASOUND_PAULA!=y && DMASOUND_Q40!=y && (DMASOUND_ATARI=m || DMASOUND_AWACS=m || DMASOUND_PAULA=m || DMASOUND_Q40=m)
112825 -       default y if DMASOUND_ATARI=y || DMASOUND_AWACS=y || DMASOUND_PAULA=y || DMASOUND_Q40=y
112826 -       help
112827 -         Support built-in audio chips accessible by DMA on various machines
112828 -         that have them.  Note that this symbol does not affect the kernel
112829 -         directly; rather, it controls whether configuration questions
112830 -         enabling DMA sound drivers for various specific machine
112831 -         architectures will be used.
112832 -
112833 --- linux-2.6.0-test6/sound/oss/dmasound/tas3001c.c     2003-09-27 18:57:48.000000000 -0700
112834 +++ 25/sound/oss/dmasound/tas3001c.c    2003-10-05 00:33:25.000000000 -0700
112835 @@ -15,7 +15,6 @@
112836   *
112837   */
112838  
112839 -#include <linux/version.h>
112840  #include <linux/module.h>
112841  #include <linux/slab.h>
112842  #include <linux/proc_fs.h>
112843 --- linux-2.6.0-test6/sound/oss/dmasound/tas3004.c      2003-09-27 18:57:48.000000000 -0700
112844 +++ 25/sound/oss/dmasound/tas3004.c     2003-10-05 00:33:25.000000000 -0700
112845 @@ -13,7 +13,6 @@
112846   *
112847   */
112848  
112849 -#include <linux/version.h>
112850  #include <linux/module.h>
112851  #include <linux/slab.h>
112852  #include <linux/proc_fs.h>
112853 --- linux-2.6.0-test6/sound/oss/dmasound/tas_common.c   2003-09-27 18:57:48.000000000 -0700
112854 +++ 25/sound/oss/dmasound/tas_common.c  2003-10-05 00:33:25.000000000 -0700
112855 @@ -1,4 +1,3 @@
112856 -#include <linux/version.h>
112857  #include <linux/module.h>
112858  #include <linux/slab.h>
112859  #include <linux/proc_fs.h>
112860 --- linux-2.6.0-test6/sound/oss/harmony.c       2003-09-08 13:58:59.000000000 -0700
112861 +++ 25/sound/oss/harmony.c      2003-10-05 00:33:25.000000000 -0700
112862 @@ -28,14 +28,14 @@ TODO:
112863  #include <linux/delay.h>
112864  #include <linux/errno.h>
112865  #include <linux/init.h>
112866 +#include <linux/interrupt.h>
112867  #include <linux/ioport.h>
112868  #include <linux/types.h>
112869  #include <linux/mm.h>
112870  #include <linux/pci.h>
112871  
112872 -#include <asm/gsc.h>
112873 +#include <asm/parisc-device.h>
112874  #include <asm/io.h>
112875 -#include <asm/pgalloc.h>
112876  
112877  #include "sound_config.h"
112878  
112879 --- linux-2.6.0-test6/sound/oss/ite8172.c       2003-09-08 13:58:59.000000000 -0700
112880 +++ 25/sound/oss/ite8172.c      2003-10-05 00:33:25.000000000 -0700
112881 @@ -54,7 +54,6 @@
112882   *    07.30.2003  Removed initialisation to zero for static variables
112883   *                (spdif[NR_DEVICE], i2s_fmt[NR_DEVICE], and devindex)
112884   */
112885 -#include <linux/version.h>
112886  #include <linux/module.h>
112887  #include <linux/string.h>
112888  #include <linux/ioport.h>
112889 @@ -2238,8 +2237,9 @@ static int __init it8172_setup(char *opt
112890         if (!options || !*options)
112891                 return 0;
112892  
112893 -       for(this_opt=strtok(options, ",");
112894 -           this_opt; this_opt=strtok(NULL, ",")) {
112895 +       while (this_opt = strsep(&options, ",")) {
112896 +               if (!*this_opt)
112897 +                       continue;
112898                 if (!strncmp(this_opt, "spdif", 5)) {
112899                         spdif[nr_dev] = 1;
112900                 } else if (!strncmp(this_opt, "i2s:", 4)) {
112901 --- linux-2.6.0-test6/sound/oss/opl3sa2.c       2003-08-22 19:23:43.000000000 -0700
112902 +++ 25/sound/oss/opl3sa2.c      2003-10-05 00:33:25.000000000 -0700
112903 @@ -324,15 +324,6 @@ static void opl3sa3_set_treble(opl3sa2_s
112904  }
112905  
112906  
112907 -static void opl3sa3_set_wide(opl3sa2_state_t* devc, int left, int right)
112908 -{      
112909 -       unsigned char wide;
112910 -
112911 -       wide = left ? ((unsigned char) (8 * left / 101)) : 0; 
112912 -       wide |= (right ? ((unsigned char) (8 * right / 101)) : 0) << 4;
112913 -
112914 -       opl3sa2_write(devc->cfg_port, OPL3SA3_WIDE, wide);
112915 -}
112916  
112917  
112918  static void opl3sa2_mixer_reset(opl3sa2_state_t* devc)
112919 @@ -401,7 +392,7 @@ static inline int ret_vol_stereo(int lef
112920  
112921  static int opl3sa2_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
112922  {
112923 -       int cmdf = cmd & 0xff;
112924 +       int retval, value, cmdf = cmd & 0xff;
112925  
112926         opl3sa2_state_t* devc = &opl3sa2_state[dev];
112927         
112928 @@ -422,23 +413,31 @@ static int opl3sa2_mixer_ioctl(int dev, 
112929         if (((cmd >> 8) & 0xff) != 'M')
112930                 return -EINVAL;
112931                 
112932 +       retval = 0;
112933         if (_SIOC_DIR (cmd) & _SIOC_WRITE) {
112934                 switch (cmdf) {
112935                         case SOUND_MIXER_VOLUME:
112936 -                               arg_to_vol_stereo(*(unsigned int*)arg,
112937 -                                                 &devc->volume_l, &devc->volume_r); 
112938 +                               retval = get_user(value, (unsigned int *) arg);
112939 +                               if (retval)
112940 +                                       break;
112941 +                               arg_to_vol_stereo(value, &devc->volume_l, &devc->volume_r);
112942                                 opl3sa2_set_volume(devc, devc->volume_l, devc->volume_r);
112943 -                               *(int*)arg = ret_vol_stereo(devc->volume_l, devc->volume_r);
112944 -                               return 0;
112945 +                               value = ret_vol_stereo(devc->volume_l, devc->volume_r);
112946 +                               retval = put_user(value, (int *) arg);
112947 +                               break;
112948                   
112949                         case SOUND_MIXER_MIC:
112950 -                               arg_to_vol_mono(*(unsigned int*)arg, &devc->mic);
112951 +                               retval = get_user(value, (unsigned int *) arg);
112952 +                               if (retval)
112953 +                                       break;
112954 +                               arg_to_vol_mono(value, &devc->mic);
112955                                 opl3sa2_set_mic(devc, devc->mic);
112956 -                               *(int*)arg = ret_vol_mono(devc->mic);
112957 -                               return 0;
112958 +                               value = ret_vol_mono(devc->mic);
112959 +                               retval = put_user(value, (int *) arg);
112960 +                               break;
112961  
112962                         default:
112963 -                               return -EINVAL;
112964 +                               retval = -EINVAL;
112965                 }
112966         }
112967         else {
112968 @@ -447,122 +446,72 @@ static int opl3sa2_mixer_ioctl(int dev, 
112969                  */
112970                 switch (cmdf) {
112971                         case SOUND_MIXER_DEVMASK:
112972 -                               *(int*)arg = (SOUND_MASK_VOLUME | SOUND_MASK_MIC);
112973 -                               return 0;
112974 +                               retval = put_user(SOUND_MASK_VOLUME | SOUND_MASK_MIC, (int *) arg);
112975 +                               break;
112976                   
112977                         case SOUND_MIXER_STEREODEVS:
112978 -                               *(int*)arg = SOUND_MASK_VOLUME;
112979 -                               return 0;
112980 +                               retval = put_user(SOUND_MASK_VOLUME, (int *) arg);
112981 +                               break;
112982                   
112983                         case SOUND_MIXER_RECMASK:
112984                                 /* No recording devices */
112985 -                               return (*(int*)arg = 0);
112986 +                               retval = put_user(0, (int *) arg);
112987 +                               break;
112988  
112989                         case SOUND_MIXER_CAPS:
112990 -                               *(int*)arg = SOUND_CAP_EXCL_INPUT;
112991 -                               return 0;
112992 +                               retval = put_user(SOUND_CAP_EXCL_INPUT, (int *) arg);
112993 +                               break;
112994  
112995                         case SOUND_MIXER_RECSRC:
112996                                 /* No recording source */
112997 -                               return (*(int*)arg = 0);
112998 +                               retval = put_user(0, (int *) arg);
112999 +                               break;
113000  
113001                         case SOUND_MIXER_VOLUME:
113002 -                               *(int*)arg = ret_vol_stereo(devc->volume_l, devc->volume_r);
113003 -                               return 0;
113004 +                               value = ret_vol_stereo(devc->volume_l, devc->volume_r);
113005 +                               retval = put_user(value, (int *) arg);
113006 +                               break;
113007                           
113008                         case SOUND_MIXER_MIC:
113009 -                               *(int*)arg = ret_vol_mono(devc->mic);
113010 -                               return 0;
113011 +                               value = ret_vol_mono(devc->mic);
113012 +                               put_user(value, (int *) arg);
113013 +                               break;
113014  
113015                         default:
113016 -                               return -EINVAL;
113017 +                               retval = -EINVAL;
113018                 }
113019         }
113020 +       return retval;
113021  }
113022  /* opl3sa2_mixer_ioctl end */
113023  
113024  
113025  static int opl3sa3_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
113026  {
113027 -       int cmdf = cmd & 0xff;
113028 +       int value, retval, cmdf = cmd & 0xff;
113029  
113030         opl3sa2_state_t* devc = &opl3sa2_state[dev];
113031  
113032         switch (cmdf) {
113033 -               case SOUND_MIXER_BASS:
113034 -               case SOUND_MIXER_TREBLE:
113035 -               case SOUND_MIXER_DIGITAL1:
113036 -               case SOUND_MIXER_DEVMASK:
113037 -               case SOUND_MIXER_STEREODEVS: 
113038 -                       break;
113039 -
113040 -               default:
113041 -                       return opl3sa2_mixer_ioctl(dev, cmd, arg);
113042 -       }
113043 -
113044 -       if (((cmd >> 8) & 0xff) != 'M')
113045 -               return -EINVAL;
113046 +       case SOUND_MIXER_BASS:
113047 +               value = ret_vol_stereo(devc->bass_l, devc->bass_r);
113048 +               retval = put_user(value, (int *) arg);
113049 +               break;
113050                 
113051 -       if (_SIOC_DIR (cmd) & _SIOC_WRITE) {
113052 -               switch (cmdf) {
113053 -                       case SOUND_MIXER_BASS:
113054 -                               arg_to_vol_stereo(*(unsigned int*)arg,
113055 -                                                 &devc->bass_l, &devc->bass_r); 
113056 -                               opl3sa3_set_bass(devc, devc->bass_l, devc->bass_r);
113057 -                               *(int*)arg = ret_vol_stereo(devc->bass_l, devc->bass_r);
113058 -                               return 0;
113059 -                 
113060 -                       case SOUND_MIXER_TREBLE:
113061 -                               arg_to_vol_stereo(*(unsigned int*)arg,
113062 -                                                 &devc->treble_l, &devc->treble_r); 
113063 -                               opl3sa3_set_treble(devc, devc->treble_l, devc->treble_r);
113064 -                               *(int*)arg = ret_vol_stereo(devc->treble_l, devc->treble_r);
113065 -                               return 0;
113066 -
113067 -                       case SOUND_MIXER_DIGITAL1:
113068 -                               arg_to_vol_stereo(*(unsigned int*)arg,
113069 -                                                 &devc->wide_l, &devc->wide_r); 
113070 -                               opl3sa3_set_wide(devc, devc->wide_l, devc->wide_r);
113071 -                               *(int*)arg = ret_vol_stereo(devc->wide_l, devc->wide_r);
113072 -                               return 0;
113073 +       case SOUND_MIXER_TREBLE:
113074 +               value = ret_vol_stereo(devc->treble_l, devc->treble_r);
113075 +               retval = put_user(value, (int *) arg);
113076 +               break;
113077  
113078 -                       default:
113079 -                               return -EINVAL;
113080 -               }
113081 -       }
113082 -       else                    
113083 -       {
113084 -               /*
113085 -                * Return parameters
113086 -                */
113087 -               switch (cmdf) {
113088 -                       case SOUND_MIXER_DEVMASK:
113089 -                               *(int*)arg = (SOUND_MASK_VOLUME | SOUND_MASK_MIC |
113090 -                                             SOUND_MASK_BASS | SOUND_MASK_TREBLE |
113091 -                                             SOUND_MASK_DIGITAL1);
113092 -                               return 0;
113093 -                 
113094 -                       case SOUND_MIXER_STEREODEVS:
113095 -                               *(int*)arg = (SOUND_MASK_VOLUME | SOUND_MASK_BASS |
113096 -                                             SOUND_MASK_TREBLE | SOUND_MASK_DIGITAL1);
113097 -                               return 0;
113098 -                 
113099 -                       case SOUND_MIXER_BASS:
113100 -                               *(int*)arg = ret_vol_stereo(devc->bass_l, devc->bass_r);
113101 -                               return 0;
113102 -                         
113103 -                       case SOUND_MIXER_TREBLE:
113104 -                               *(int*)arg = ret_vol_stereo(devc->treble_l, devc->treble_r);
113105 -                               return 0;
113106 -
113107 -                       case SOUND_MIXER_DIGITAL1:
113108 -                               *(int*)arg = ret_vol_stereo(devc->wide_l, devc->wide_r);
113109 -                               return 0;
113110 +       case SOUND_MIXER_DIGITAL1:
113111 +               value = ret_vol_stereo(devc->wide_l, devc->wide_r);
113112 +               retval = put_user(value, (int *) arg);
113113 +               break;
113114  
113115 -                       default:
113116 -                               return -EINVAL;
113117 -               }
113118 +       default:
113119 +               retval = -EINVAL;
113120         }
113121 +       return retval;
113122  }
113123  /* opl3sa3_mixer_ioctl end */
113124  
113125 --- linux-2.6.0-test6/sound/oss/swarm_cs4297a.c 2003-09-08 13:58:59.000000000 -0700
113126 +++ 25/sound/oss/swarm_cs4297a.c        2003-10-05 00:33:25.000000000 -0700
113127 @@ -59,7 +59,6 @@
113128  *******************************************************************************/
113129  
113130  #include <linux/list.h>
113131 -#include <linux/version.h>
113132  #include <linux/module.h>
113133  #include <linux/string.h>
113134  #include <linux/ioport.h>
113135 --- linux-2.6.0-test6/sound/oss/via82cxxx_audio.c       2003-09-08 13:58:59.000000000 -0700
113136 +++ 25/sound/oss/via82cxxx_audio.c      2003-10-05 00:36:10.000000000 -0700
113137 @@ -1844,6 +1844,7 @@ static void via_ac97_cleanup (struct via
113138  
113139  /**
113140   *     via_intr_channel - handle an interrupt for a single channel
113141 + *      @card: unused
113142   *     @chan: handle interrupt for this channel
113143   *
113144   *     This is the "meat" of the interrupt handler,
113145 --- linux-2.6.0-test6/sound/parisc/harmony.c    2003-08-22 19:23:43.000000000 -0700
113146 +++ 25/sound/parisc/harmony.c   2003-10-05 00:33:25.000000000 -0700
113147 @@ -66,6 +66,7 @@
113148  #include <linux/delay.h>
113149  #include <sound/driver.h>
113150  #include <linux/init.h>
113151 +#include <linux/interrupt.h>
113152  #include <linux/slab.h>
113153  #include <linux/time.h>
113154  #include <linux/wait.h>
113155 @@ -77,8 +78,8 @@
113156  #include <sound/initval.h>
113157  #include <sound/info.h>
113158  #include <asm/hardware.h>
113159 -#include <asm/gsc.h>
113160  #include <asm/io.h>
113161 +#include <asm/parisc-device.h>
113162  
113163  MODULE_AUTHOR("Laurent Canet <canetl@esiee.fr>");
113164  MODULE_DESCRIPTION("ALSA Harmony sound driver");
113165 @@ -709,8 +710,8 @@ static int snd_card_harmony_playback_ope
113166          * harmony is not "real" pci, but we need a pci_dev
113167          * to alloc PCI DMA pages
113168          */
113169 -       substream->dma_private = harmony->fake_pci_dev;
113170 -       substream->dma_type = SNDRV_PCM_DMA_TYPE_PCI;
113171 +       substream->runtime->dma_private = harmony->fake_pci_dev;
113172 +//     substream->dma_type = SNDRV_PCM_DMA_TYPE_PCI;
113173         
113174         harmony->playback_substream = substream;
113175         runtime->hw = snd_card_harmony_playback;
113176 @@ -733,8 +734,8 @@ static int snd_card_harmony_capture_open
113177          * harmony is not "real" pci, but we need a pci_dev
113178          * to alloc PCI DMA pages
113179          */
113180 -       substream->dma_private = harmony->fake_pci_dev;
113181 -       substream->dma_type = SNDRV_PCM_DMA_TYPE_PCI;
113182 +       substream->runtime->dma_private = harmony->fake_pci_dev;
113183 +//     substream->dma_type = SNDRV_PCM_DMA_TYPE_PCI;
113184  
113185         harmony->capture_substream = substream;
113186         runtime->hw = snd_card_harmony_capture;
113187 --- linux-2.6.0-test6/sound/pci/cmipci.c        2003-08-08 22:55:15.000000000 -0700
113188 +++ 25/sound/pci/cmipci.c       2003-10-05 00:33:25.000000000 -0700
113189 @@ -2791,6 +2791,7 @@ static int __devinit snd_cmipci_mixer_ne
113190   * proc interface
113191   */
113192  
113193 +#ifdef CONFIG_PROC_FS
113194  static void snd_cmipci_proc_read(snd_info_entry_t *entry, 
113195                                  snd_info_buffer_t *buffer)
113196  {
113197 @@ -2817,6 +2818,9 @@ static void __devinit snd_cmipci_proc_in
113198         if (! snd_card_proc_new(cm->card, "cmipci", &entry))
113199                 snd_info_set_text_ops(entry, cm, snd_cmipci_proc_read);
113200  }
113201 +#else /* !CONFIG_PROC_FS */
113202 +static inline void snd_cmipci_proc_init(cmipci_t *cm) {}
113203 +#endif
113204  
113205  
113206  static struct pci_device_id snd_cmipci_ids[] = {
113207 --- linux-2.6.0-test6/sound/pci/intel8x0.c      2003-09-27 18:57:48.000000000 -0700
113208 +++ 25/sound/pci/intel8x0.c     2003-10-05 00:34:31.000000000 -0700
113209 @@ -2271,10 +2271,8 @@ static void __devinit intel8x0_measure_a
113210  
113211         t = stop_time.tv_sec - start_time.tv_sec;
113212         t *= 1000000;
113213 -       if (stop_time.tv_usec < start_time.tv_usec)
113214 -               t -= start_time.tv_usec - stop_time.tv_usec;
113215 -       else
113216 -               t += stop_time.tv_usec - start_time.tv_usec;
113217 +       t += stop_time.tv_usec - start_time.tv_usec;
113218 +       printk(KERN_INFO "%s: measured %lu usecs\n", __FUNCTION__, t);
113219         if (t == 0) {
113220                 snd_printk(KERN_ERR "?? calculation error..\n");
113221                 return;
113222 --- linux-2.6.0-test6/sound/pci/Kconfig 2003-09-27 18:57:48.000000000 -0700
113223 +++ 25/sound/pci/Kconfig        2003-10-05 00:34:45.000000000 -0700
113224 @@ -17,7 +17,8 @@ config SND_AZT3328
113225  
113226  config SND_CS46XX
113227         tristate "Cirrus Logic (Sound Fusion) CS4280/CS461x/CS462x/CS463x"
113228 -       depends on SND && GAMEPORT
113229 +       depends on SND
113230 +       select GAMEPORT
113231         help
113232           Say 'Y' or 'M' to include support for Cirrus Logic CS4610 / CS4612 /
113233           CS4614 / CS4615 / CS4622 / CS4624 / CS4630 / CS4280 chips.
113234 @@ -30,7 +31,8 @@ config SND_CS46XX_NEW_DSP
113235  
113236  config SND_CS4281
113237         tristate "Cirrus Logic (Sound Fusion) CS4281"
113238 -       depends on SND && GAMEPORT
113239 +       depends on SND
113240 +       select GAMEPORT
113241         help
113242           Say 'Y' or 'M' to include support for Cirrus Logic CS4281.
113243  
113244 @@ -83,7 +85,8 @@ config SND_HDSP
113245  
113246  config SND_TRIDENT
113247         tristate "Trident 4D-Wave DX/NX; SiS 7018"
113248 -       depends on SND && GAMEPORT
113249 +       depends on SND
113250 +       select GAMEPORT
113251         help
113252           Say 'Y' or 'M' to include support for Trident 4D-Wave DX/NX and
113253           SiS 7018 soundcards.
113254 @@ -110,20 +113,23 @@ config SND_CMIPCI
113255  
113256  config SND_ENS1370
113257         tristate "(Creative) Ensoniq AudioPCI 1370"
113258 -       depends on SND && GAMEPORT
113259 +       depends on SND
113260 +       select GAMEPORT
113261         help
113262           Say 'Y' or 'M' to include support for Ensoniq AudioPCI ES1370.
113263  
113264  config SND_ENS1371
113265         tristate "(Creative) Ensoniq AudioPCI 1371/1373"
113266 -       depends on SND && GAMEPORT
113267 +       depends on SND
113268 +       select GAMEPORT
113269         help
113270           Say 'Y' or 'M' to include support for Ensoniq AudioPCI ES1371 and
113271           Sound Blaster PCI 64 or 128 soundcards.
113272  
113273  config SND_ES1938
113274         tristate "ESS ES1938/1946/1969 (Solo-1)"
113275 -       depends on SND && GAMEPORT
113276 +       depends on SND
113277 +       select GAMEPORT
113278         help
113279           Say 'Y' or 'M' to include support for ESS Solo-1 (ES1938, ES1946, ES1969)
113280           soundcard.
113281 @@ -173,7 +179,8 @@ config SND_INTEL8X0
113282  
113283  config SND_SONICVIBES
113284         tristate "S3 SonicVibes"
113285 -       depends on SND && GAMEPORT
113286 +       depends on SND
113287 +       select GAMEPORT
113288         help
113289           Say 'Y' or 'M' to include support for S3 SonicVibes based soundcards.
113290